-
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.
Account for derefs when suggesting assoc function
- Loading branch information
Showing
4 changed files
with
52 additions
and
3 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`. |