-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 #131024 - compiler-errors:deref-sugg, r=estebank
Don't give method suggestions when method probe fails due to bad implementation of `Deref` If we have a bad `Deref` impl, we used to bail with `MethodError::NoMatch`, which makes the error reporting code think that there was no applicable method (and thus try to suggest importing something, even if it's in scope). Suppress this error, which fixes #131003.
- Loading branch information
Showing
5 changed files
with
54 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use std::clone::Clone; | ||
use std::ops::Deref; | ||
|
||
#[derive(Clone)] | ||
pub struct Foo {} | ||
|
||
impl Deref for Foo {} | ||
//~^ ERROR not all trait items implemented | ||
|
||
pub fn main() { | ||
let f = Foo {}; | ||
let _ = f.clone(); | ||
} |
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,12 @@ | ||
error[E0046]: not all trait items implemented, missing: `Target`, `deref` | ||
--> $DIR/dont-suggest-import-on-deref-err.rs:7:1 | ||
| | ||
LL | impl Deref for Foo {} | ||
| ^^^^^^^^^^^^^^^^^^ missing `Target`, `deref` in implementation | ||
| | ||
= help: implement the missing item: `type Target = /* Type */;` | ||
= help: implement the missing item: `fn deref(&self) -> &<Self as Deref>::Target { todo!() }` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0046`. |