forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#65145 - estebank:turbofish-assoc-fn-call, r…
…=varkor When suggesting assoc function with type params, include turbofish Fix rust-lang#61412, fix rust-lang#61411.
- Loading branch information
Showing
6 changed files
with
102 additions
and
9 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
13 changes: 13 additions & 0 deletions
13
src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish-through-deref.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,13 @@ | ||
use std::cell::RefCell; | ||
|
||
struct HasAssocMethod; | ||
|
||
impl HasAssocMethod { | ||
fn hello() {} | ||
} | ||
fn main() { | ||
let shared_state = RefCell::new(HasAssocMethod); | ||
let state = shared_state.borrow_mut(); | ||
state.hello(); | ||
//~^ ERROR no method named `hello` found for type `std::cell::RefMut<'_, HasAssocMethod>` | ||
} |
19 changes: 19 additions & 0 deletions
19
src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish-through-deref.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,19 @@ | ||
error[E0599]: no method named `hello` found for type `std::cell::RefMut<'_, HasAssocMethod>` in the current scope | ||
--> $DIR/suggest-assoc-fn-call-with-turbofish-through-deref.rs:11:11 | ||
| | ||
LL | state.hello(); | ||
| ------^^^^^ | ||
| | | | ||
| | this is an associated function, not a method | ||
| help: use associated function syntax instead: `HasAssocMethod::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 `HasAssocMethod` | ||
--> $DIR/suggest-assoc-fn-call-with-turbofish-through-deref.rs:6:5 | ||
| | ||
LL | fn hello() {} | ||
| ^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0599`. |
11 changes: 11 additions & 0 deletions
11
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
struct GenericAssocMethod<T>(T); | ||
|
||
impl<T> GenericAssocMethod<T> { | ||
fn default_hello() {} | ||
} | ||
|
||
fn main() { | ||
let x = GenericAssocMethod(33i32); | ||
x.default_hello(); | ||
//~^ ERROR no method named `default_hello` found for type `GenericAssocMethod<i32>` | ||
} |
22 changes: 22 additions & 0 deletions
22
src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.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 type `GenericAssocMethod<i32>` in the current scope | ||
--> $DIR/suggest-assoc-fn-call-with-turbofish.rs:9:7 | ||
| | ||
LL | struct GenericAssocMethod<T>(T); | ||
| -------------------------------- method `default_hello` not found for this | ||
... | ||
LL | x.default_hello(); | ||
| --^^^^^^^^^^^^^ | ||
| | | | ||
| | this is an associated function, not a method | ||
| help: use associated function syntax instead: `GenericAssocMethod::<i32>::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<_>` | ||
--> $DIR/suggest-assoc-fn-call-with-turbofish.rs:4:5 | ||
| | ||
LL | fn default_hello() {} | ||
| ^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0599`. |