-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Do not eagerly reject inference vars when trying to resolve method calls. #126316
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
Open
oli-obk
wants to merge
4
commits into
rust-lang:master
Choose a base branch
from
oli-obk:recursive_rpit3
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+306
−322
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0baacd7
Revert "Revert "When checking whether an impl applies, constrain hidd…
oli-obk 0b401c1
Leave error reporting of method calls on inference variables to metho…
oli-obk 193ac2b
Do not fail `method_autoderef_steps` on infer types. Let method resol…
oli-obk d6c0560
Show that a test fails on the new solver, too
oli-obk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
tests/ui/associated-types/param_mismatch_on_associatedtype_constructor.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//! This test used to ICE #121613 | ||
//! Using a generic parameter where there are none expected | ||
//! caused an ICE, hiding the important later errors. | ||
|
||
#![feature(more_qualified_paths)] | ||
|
||
fn main() { | ||
let _ = <Foo as A>::Assoc { br: 2 }; | ||
|
||
let <E>::V(..) = E::V(|a, b| a.cmp(b)); | ||
//~^ ERROR: multiple applicable items in scope | ||
} | ||
|
||
struct StructStruct { | ||
br: i8, | ||
} | ||
|
||
struct Foo; | ||
|
||
trait A { | ||
type Assoc; | ||
} | ||
|
||
impl A for Foo { | ||
type Assoc = StructStruct; | ||
} | ||
|
||
enum E { | ||
V(u8), | ||
} |
22 changes: 22 additions & 0 deletions
22
tests/ui/associated-types/param_mismatch_on_associatedtype_constructor.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
error[E0034]: multiple applicable items in scope | ||
--> $DIR/param_mismatch_on_associatedtype_constructor.rs:10:36 | ||
| | ||
LL | let <E>::V(..) = E::V(|a, b| a.cmp(b)); | ||
| ^^^ multiple `cmp` found | ||
| | ||
note: candidate #1 is defined in the trait `Iterator` | ||
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL | ||
note: candidate #2 is defined in the trait `Ord` | ||
--> $SRC_DIR/core/src/cmp.rs:LL:COL | ||
help: disambiguate the method for candidate #1 | ||
| | ||
LL | let <E>::V(..) = E::V(|a, b| Iterator::cmp(a, b)); | ||
| ~~~~~~~~~~~~~~~~~~~ | ||
help: disambiguate the method for candidate #2 | ||
| | ||
LL | let <E>::V(..) = E::V(|a, b| Ord::cmp(&a, b)); | ||
| ~~~~~~~~~~~~~~~ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0034`. |
19 changes: 19 additions & 0 deletions
19
tests/ui/auto-traits/opaque_type_candidate_selection.next.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
error[E0119]: conflicting implementations of trait `Trait<_>` | ||
--> $DIR/opaque_type_candidate_selection.rs:28:1 | ||
| | ||
LL | impl<T> Trait<T> for T { | ||
| ---------------------- first implementation here | ||
... | ||
LL | impl<T> Trait<T> for defining_scope::Alias<T> { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation | ||
|
||
error[E0282]: type annotations needed | ||
--> $DIR/opaque_type_candidate_selection.rs:11:23 | ||
| | ||
LL | pub fn cast<T>(x: Container<Alias<T>, T>) -> Container<T, T> { | ||
| ^^^^^^^^^^^^^^^^^^^^^^ cannot infer type | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0119, E0282. | ||
For more information about an error, try `rustc --explain E0119`. |
12 changes: 12 additions & 0 deletions
12
tests/ui/auto-traits/opaque_type_candidate_selection.old.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
error[E0119]: conflicting implementations of trait `Trait<_>` | ||
--> $DIR/opaque_type_candidate_selection.rs:28:1 | ||
| | ||
LL | impl<T> Trait<T> for T { | ||
| ---------------------- first implementation here | ||
... | ||
LL | impl<T> Trait<T> for defining_scope::Alias<T> { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0119`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//@revisions: old next | ||
//@[next] compile-flags: -Znext-solver | ||
|
||
//! used to ICE: #119272 | ||
|
||
#![feature(type_alias_impl_trait)] | ||
mod defining_scope { | ||
use super::*; | ||
pub type Alias<T> = impl Sized; | ||
|
||
pub fn cast<T>(x: Container<Alias<T>, T>) -> Container<T, T> { | ||
//[next]~^ ERROR: type annotations needed | ||
x | ||
} | ||
} | ||
|
||
struct Container<T: Trait<U>, U> { | ||
x: <T as Trait<U>>::Assoc, | ||
} | ||
|
||
trait Trait<T> { | ||
type Assoc; | ||
} | ||
|
||
impl<T> Trait<T> for T { | ||
type Assoc = Box<u32>; | ||
} | ||
impl<T> Trait<T> for defining_scope::Alias<T> { | ||
//~^ ERROR: conflicting implementations | ||
type Assoc = usize; | ||
} | ||
|
||
fn main() {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 10 additions & 10 deletions
20
tests/ui/autoref-autoderef/deref-ambiguity-becomes-nonambiguous.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
error[E0282]: type annotations needed for `Value<Rc<_>>` | ||
--> $DIR/deref-ambiguity-becomes-nonambiguous.rs:31:9 | ||
error[E0283]: type annotations needed | ||
--> $DIR/deref-ambiguity-becomes-nonambiguous.rs:38:9 | ||
| | ||
LL | let var_fn = Value::wrap(); | ||
| ^^^^^^ | ||
... | ||
LL | let _ = var_fn.clone(); | ||
| ----- type must be known at this point | ||
| ^ ------ ----- required by a bound introduced by this call | ||
| | | ||
| type must be known at this point | ||
| | ||
help: consider giving `var_fn` an explicit type, where the placeholders `_` are specified | ||
= note: cannot satisfy `_: Clone` | ||
help: consider giving this pattern a type | ||
| | ||
LL | let var_fn: Value<Rc<_>> = Value::wrap(); | ||
| ++++++++++++++ | ||
LL | let _: /* Type */ = var_fn.clone(); | ||
| ++++++++++++ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0282`. | ||
For more information about this error, try `rustc --explain E0283`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
tests/ui/impl-trait/call_method_on_inherent_impl_on_rigid_type.current.stderr
This file was deleted.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
tests/ui/impl-trait/call_method_on_inherent_impl_on_rigid_type.next.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 7 additions & 23 deletions
30
tests/ui/impl-trait/hidden-type-is-opaque-2.default.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,15 @@ | ||
error[E0282]: type annotations needed | ||
--> $DIR/hidden-type-is-opaque-2.rs:10:17 | ||
error[E0599]: no method named `reify_as` found for type `_` in the current scope | ||
--> $DIR/hidden-type-is-opaque-2.rs:11:14 | ||
| | ||
LL | Thunk::new(|mut cont| { | ||
| ^^^^^^^^ | ||
LL | | ||
LL | cont.reify_as(); | ||
| ---- type must be known at this point | ||
| | ||
help: consider giving this closure parameter an explicit type | ||
| | ||
LL | Thunk::new(|mut cont: /* Type */| { | ||
| ++++++++++++ | ||
| ^^^^^^^^ method not found in `_` | ||
|
||
error[E0282]: type annotations needed | ||
--> $DIR/hidden-type-is-opaque-2.rs:20:17 | ||
error[E0599]: no method named `reify_as` found for type `_` in the current scope | ||
--> $DIR/hidden-type-is-opaque-2.rs:21:14 | ||
| | ||
LL | Thunk::new(|mut cont| { | ||
| ^^^^^^^^ | ||
LL | | ||
LL | cont.reify_as(); | ||
| ---- type must be known at this point | ||
| | ||
help: consider giving this closure parameter an explicit type | ||
| | ||
LL | Thunk::new(|mut cont: /* Type */| { | ||
| ++++++++++++ | ||
| ^^^^^^^^ method not found in `_` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0282`. | ||
For more information about this error, try `rustc --explain E0599`. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.