Elide object safety errors on non-existent trait function

Fix #58734.
This commit is contained in:
Esteban Küber 2019-03-04 19:24:52 -08:00
parent ad8a3eb039
commit d7bb98f7a1
6 changed files with 74 additions and 21 deletions

View file

@ -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`
}

View file

@ -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`.