Adapted from examples given on #55748. Note that observing this bug requires use of feature(type_ascription) and therefore is not high priority.
consider the following code (play):
#![feature(nll, type_ascription)]
#![allow(dead_code, unused_mut)]
type PairCoupledTypes<T> = (T, T);
#[cfg(this_is_just_here_for_comparison_it_behaves_same_with_and_without_nll)]
fn coupled_types_rhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 {
let ((y, _z),) = ((s, &_x),): (PairCoupledTypes<&u32>,);
y //~ ERROR unsatisfied lifetime constraints
}
fn coupled_wilds_rhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 {
let ((y, _z),) = ((s, &_x),): (PairCoupledTypes<_>,);
y //~ ERROR unsatisfied lifetime constraints
}
fn main() {}
Right now, as written, this compiles without error. (Note that fn coupled_types_rhs is not included; that function will error with and without NLL.)
If you remove the nll in the feature declaration, the code for fn coupled_wilds_rhs is rejected.
This is an indication that either:
- NLL has a bug in how it is handling
_ in the type-ascription expression form EXPR: TYPE, or
- there exists some argument that
fn coupled_wilds_rhs should be accepted (and that NLL is correct in accepting it), but I do not see how such an argument exists that would not also imply that we should be seeing the same behavior in fn coupled_types_rhs.
Adapted from examples given on #55748. Note that observing this bug requires use of
feature(type_ascription)and therefore is not high priority.consider the following code (play):
Right now, as written, this compiles without error. (Note that
fn coupled_types_rhsis not included; that function will error with and without NLL.)If you remove the
nllin the feature declaration, the code forfn coupled_wilds_rhsis rejected.This is an indication that either:
_in the type-ascription expression formEXPR: TYPE, orfn coupled_wilds_rhsshould be accepted (and that NLL is correct in accepting it), but I do not see how such an argument exists that would not also imply that we should be seeing the same behavior infn coupled_types_rhs.