-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
regression: non-defining opaque type use in defining scope #105826
Comments
This is #103491. Cc @cjgillot. It is related to the invariance: fn absurd<T>() -> T { todo!() }
fn one<'a: 'a>() -> *mut impl Sized {
absurd::<*mut ()>()
}
fn two<'a: 'a>() -> *mut impl Sized {
one::<'a>()
//~^ ERROR non-defining opaque type use in defining scope
} Another case that doesn't rely on member constraints in the second function and yields a different error message: fn absurd<T>() -> T { todo!() }
fn assert_static<T: 'static>(_: T) {}
fn one<'a: 'a>() -> *mut impl Sized {
absurd::<*mut ()>()
}
fn two<'a>() {
assert_static(one::<'a>());
//~^ ERROR lifetime may not live long enough
} I also found a distantly related regression that doesn't require invariance. It looks like a missed subtyping opportunity: fn one<'a, 'b: 'b>() -> &'a impl Sized {
&()
}
fn two<'a, 'b>() {
one::<'a, 'b>();
//~^ ERROR lifetime may not live long enough
} |
Another version using TAIT: #![feature(type_alias_impl_trait)]
type Opaque<'a> = impl Sized;
fn define<'a>() -> Opaque<'a> {}
fn test<'a>() {
None::<&'static Opaque<'a>>;
} At this point there are two classes of regression: The first is related to the fact that @rustbot label I-types-nominated T-types T-compiler |
WG-prioritization assigning priority (Zulip discussion). @rustbot label -I-prioritize +P-critical |
Do not filter substs in `remap_generic_params_to_declaration_params`. The relevant filtering should have been performed by borrowck. Fixes rust-lang#105826 r? types
unnominating as it will get fixed by #106503 which is approved again. Have to try to get this into beta though, only have 1 more day for that |
Do not filter substs in `remap_generic_params_to_declaration_params`. The relevant filtering should have been performed by borrowck. Fixes rust-lang/rust#105826 r? types
Here is an example which uses a RPIT on a borrowed type in three different ways:
IMO this is perfectly reasonable code and
there should be no errors(EDIT: see below). On stable (rustc 1.66.0 (69f9c33d7 2022-12-12)
) we have the following:And on beta (
rustc 1.67.0-beta.2 (352eb59a4 2022-12-13)
) and nightly (rustc 1.68.0-nightly (b70baa4f9 2022-12-14)
) we get some additional errors:EDIT: On second thought, I guess the first error (on stable) is reasonable, since we are actually returning a
&mut &'a mut Vec<u8>
in that case. If you either use&mut *self.two
in the body or&mut (impl Write + 'a)
in the return type then the error goes away. But the second error is still a regression.Version it worked on
It most recently worked on: rustc 1.66.0 (69f9c33 2022-12-12)
Version with regression
rustc --version --verbose
:@rustbot modify labels: +regression-from-stable-to-beta -regression-untriaged
The text was updated successfully, but these errors were encountered: