-
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
<Box<T> as Deref>::Target
is not equivalent to T
in this case.
#76956
Comments
We currently do not normalize projections cc @eddyb @nikomatsakis but I don't think we can do much about cases like this for now. |
Using trait objects instead of use std::ops::Deref;
fn use_data(v: &'static i32, user: &dyn for<'a> Fn(<Box<&'a i32> as Deref>::Target)) {
user(v)
} |
Came up with another interesting version. This will fail to typecheck: struct Container<'a>(std::marker::PhantomData<&'a ()>);
struct Empty;
trait Trait {
type Assoc;
}
impl<'a> Trait for Container<'a> {
type Assoc = Empty;
}
fn foo(x: impl for <'a> FnOnce(<Container<'a> as Trait>::Assoc)) {
x(Empty);
} Replacing the header of foo with this will successfully typecheck: fn foo<'a>(x: impl FnOnce(<Container<'a> as Trait>::Assoc)) { Might be useful for diffing. |
…komatsakis Normalize projections under binders Fixes rust-lang#70243 Fixes rust-lang#70120 Fixes rust-lang#62529 Fixes rust-lang#87219 Issues to followup on after (probably fixed, but no test added here): rust-lang#76956 rust-lang#56556 rust-lang#79207 rust-lang#85636 r? `@nikomatsakis`
Fixed by #85499. Not going to close this because this is a simple example that didn't ICE, but still failed to compile. |
Add a couple tests for normalize under binder issues Closes rust-lang#56556 Closes rust-lang#76956 r? `@nikomatsakis`
This code compiles correctly:
However, this code does not:
The only change was effectively replacing
T
with<Box<T> as Deref>::Target
. My understanding is that these are supposed to be equivalent as it is defined that way in the standard library. The exact compile error is as follows:Meta
The error also occurs on the Nightly compiler.
The text was updated successfully, but these errors were encountered: