-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #101990 - clubby789:dont-machine-apply-placeholder-meth…
…od, r=compiler-errors Fix auto-application of associated generic functions with placeholders Fixes #101920
- Loading branch information
Showing
12 changed files
with
286 additions
and
35 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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
11 changes: 11 additions & 0 deletions
11
src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish-placeholder.rs
This file contains 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,11 @@ | ||
struct GenericAssocMethod<T>(T); | ||
|
||
impl<T> GenericAssocMethod<T> { | ||
fn default_hello() {} | ||
} | ||
|
||
fn main() { | ||
let x = GenericAssocMethod(33); | ||
x.default_hello(); | ||
//~^ ERROR no method named `default_hello` found | ||
} |
22 changes: 22 additions & 0 deletions
22
src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish-placeholder.stderr
This file contains 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[E0599]: no method named `default_hello` found for struct `GenericAssocMethod<{integer}>` in the current scope | ||
--> $DIR/suggest-assoc-fn-call-with-turbofish-placeholder.rs:9:7 | ||
| | ||
LL | struct GenericAssocMethod<T>(T); | ||
| ---------------------------- method `default_hello` not found for this struct | ||
... | ||
LL | x.default_hello(); | ||
| --^^^^^^^^^^^^^-- | ||
| | | | ||
| | this is an associated function, not a method | ||
| help: use associated function syntax instead: `GenericAssocMethod::<_>::default_hello()` | ||
| | ||
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter | ||
note: the candidate is defined in an impl for the type `GenericAssocMethod<T>` | ||
--> $DIR/suggest-assoc-fn-call-with-turbofish-placeholder.rs:4:5 | ||
| | ||
LL | fn default_hello() {} | ||
| ^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0599`. |
This file contains 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
26 changes: 26 additions & 0 deletions
26
src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.fixed
This file contains 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,26 @@ | ||
// run-rustfix | ||
|
||
struct GenericAssocMethod<T>(T); | ||
|
||
impl<T> GenericAssocMethod<T> { | ||
fn default_hello() {} | ||
fn self_ty_hello(_: Self) {} | ||
fn self_ty_ref_hello(_: &Self) {} | ||
} | ||
|
||
fn main() { | ||
// Test for inferred types | ||
let x = GenericAssocMethod(33); | ||
GenericAssocMethod::<_>::self_ty_ref_hello(&x); | ||
//~^ ERROR no method named `self_ty_ref_hello` found | ||
GenericAssocMethod::<_>::self_ty_hello(x); | ||
//~^ ERROR no method named `self_ty_hello` found | ||
// Test for known types | ||
let y = GenericAssocMethod(33i32); | ||
GenericAssocMethod::<i32>::default_hello(); | ||
//~^ ERROR no method named `default_hello` found | ||
GenericAssocMethod::<i32>::self_ty_ref_hello(&y); | ||
//~^ ERROR no method named `self_ty_ref_hello` found | ||
GenericAssocMethod::<i32>::self_ty_hello(y); | ||
//~^ ERROR no method named `self_ty_hello` found | ||
} |
19 changes: 17 additions & 2 deletions
19
src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.rs
This file contains 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,11 +1,26 @@ | ||
// run-rustfix | ||
|
||
struct GenericAssocMethod<T>(T); | ||
|
||
impl<T> GenericAssocMethod<T> { | ||
fn default_hello() {} | ||
fn self_ty_hello(_: Self) {} | ||
fn self_ty_ref_hello(_: &Self) {} | ||
} | ||
|
||
fn main() { | ||
let x = GenericAssocMethod(33i32); | ||
x.default_hello(); | ||
// Test for inferred types | ||
let x = GenericAssocMethod(33); | ||
x.self_ty_ref_hello(); | ||
//~^ ERROR no method named `self_ty_ref_hello` found | ||
x.self_ty_hello(); | ||
//~^ ERROR no method named `self_ty_hello` found | ||
// Test for known types | ||
let y = GenericAssocMethod(33i32); | ||
y.default_hello(); | ||
//~^ ERROR no method named `default_hello` found | ||
y.self_ty_ref_hello(); | ||
//~^ ERROR no method named `self_ty_ref_hello` found | ||
y.self_ty_hello(); | ||
//~^ ERROR no method named `self_ty_hello` found | ||
} |
Oops, something went wrong.