-
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
Discard overflow obligations in impl_may_apply
#123618
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2398,12 +2398,12 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { | |
if ambiguities.len() > 5 { | ||
let infcx = self.infcx; | ||
if !ambiguities.iter().all(|option| match option { | ||
DefId(did) => infcx.fresh_args_for_item(DUMMY_SP, *did).is_empty(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a very strange way of computing |
||
DefId(did) => infcx.tcx.generics_of(*did).count() == 0, | ||
ParamEnv(_) => true, | ||
}) { | ||
// If not all are blanket impls, we filter blanked impls out. | ||
ambiguities.retain(|option| match option { | ||
DefId(did) => infcx.fresh_args_for_item(DUMMY_SP, *did).is_empty(), | ||
DefId(did) => infcx.tcx.generics_of(*did).count() == 0, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just commenting to note that we do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a good idea. I can add those. A lot of the places where we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll do this as a follow-up actually |
||
ParamEnv(_) => true, | ||
}); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
trait Hello {} | ||
|
||
struct Foo<'a, T: ?Sized>(&'a T); | ||
|
||
impl<'a, T: ?Sized> Hello for Foo<'a, &'a T> where Foo<'a, T>: Hello {} | ||
|
||
impl Hello for Foo<'static, i32> {} | ||
|
||
fn hello<T: ?Sized + Hello>() {} | ||
|
||
fn main() { | ||
hello(); | ||
//~^ ERROR type annotations needed | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
error[E0283]: type annotations needed | ||
--> $DIR/overflow-computing-ambiguity.rs:12:5 | ||
| | ||
LL | hello(); | ||
| ^^^^^ cannot infer type of the type parameter `T` declared on the function `hello` | ||
| | ||
= note: cannot satisfy `_: Hello` | ||
= help: the following types implement trait `Hello`: | ||
Foo<'a, &'a T> | ||
Foo<'static, i32> | ||
note: required by a bound in `hello` | ||
--> $DIR/overflow-computing-ambiguity.rs:9:22 | ||
| | ||
LL | fn hello<T: ?Sized + Hello>() {} | ||
| ^^^^^ required by this bound in `hello` | ||
help: consider specifying the generic argument | ||
| | ||
LL | hello::<T>(); | ||
| +++++ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0283`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering if we should add a FIXME here or something and if you have some kind of thought about how we could potentially get rid of the "hack" at some point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We get rid of the hack when the new solver is stabilized, which at that point someone will replace all the
infcx.next_solver
withtrue
and do the const-folding to remove this whole filter.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, at that point it will be obvious but maybe worth adding a
FIXME(next_solver)
or something like that