-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Elide object safety errors on non-existent trait function
Fix #58734.
- Loading branch information
Showing
6 changed files
with
74 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
trait Trait { | ||
fn exists(self) -> (); | ||
|
||
fn not_object_safe() -> Self; | ||
} | ||
|
||
impl Trait for () { | ||
fn exists(self) -> () { | ||
} | ||
|
||
fn not_object_safe() -> Self { | ||
() | ||
} | ||
} | ||
|
||
fn main() { | ||
// object-safe or not, this call is OK | ||
Trait::exists(()); | ||
// no object safety error | ||
Trait::nonexistent(()); | ||
//~^ ERROR no function or associated item named `nonexistent` found for type `dyn Trait` | ||
} |
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 @@ | ||
error[E0599]: no function or associated item named `nonexistent` found for type `dyn Trait` in the current scope | ||
--> $DIR/issue-58734.rs:20:12 | ||
| | ||
LL | Trait::nonexistent(()); | ||
| -------^^^^^^^^^^^ | ||
| | | ||
| function or associated item not found in `dyn Trait` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0599`. |