Skip to content

Commit de084f9

Browse files
committed
some nits before squash
1 parent 7485db9 commit de084f9

File tree

5 files changed

+19
-13
lines changed

5 files changed

+19
-13
lines changed
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
//! Trait objects only allow access to methods defined in the trait.
22
33
trait MyTrait {
4-
fn do_something(&mut self);
4+
fn trait_method(&mut self);
55
}
66

77
struct ImplType;
88

99
impl MyTrait for ImplType {
10-
fn do_something(&mut self) {}
10+
fn trait_method(&mut self) {}
1111
}
1212

1313
impl ImplType {
14-
fn extra_method(&mut self) {}
14+
fn struct_impl_method(&mut self) {}
1515
}
1616

1717
fn main() {
1818
let obj: Box<dyn MyTrait> = Box::new(ImplType);
19-
obj.extra_method(); //~ ERROR no method named `extra_method` found
19+
obj.struct_impl_method(); //~ ERROR no method named `struct_impl_method` found
2020
}

tests/ui/privacy/trait-object-method-error.stderr

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
error[E0599]: no method named `extra_method` found for struct `Box<dyn MyTrait>` in the current scope
1+
error[E0599]: no method named `struct_impl_method` found for struct `Box<dyn MyTrait>` in the current scope
22
--> $DIR/trait-object-method-error.rs:19:9
33
|
4-
LL | obj.extra_method();
5-
| ^^^^^^^^^^^^ method not found in `Box<dyn MyTrait>`
4+
LL | obj.struct_impl_method();
5+
| ^^^^^^^^^^^^^^^^^^
6+
|
7+
help: there is a method `trait_method` with a similar name
8+
|
9+
LL - obj.struct_impl_method();
10+
LL + obj.trait_method();
11+
|
612

713
error: aborting due to 1 previous error
814

tests/ui/traits/trait-impl-missing-method.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
//! Trait impls must define all required methods.
22
33
trait MyTrait {
4-
fn do_something(&self);
4+
fn trait_method(&self);
55
}
66

77
struct ImplType;
88

9-
impl MyTrait for ImplType {} //~ ERROR not all trait items implemented, missing: `do_something`
9+
impl MyTrait for ImplType {} //~ ERROR not all trait items implemented, missing: `trait_method`
1010

1111
fn main() {
1212
let _ = ImplType;

tests/ui/traits/trait-impl-missing-method.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
error[E0046]: not all trait items implemented, missing: `do_something`
1+
error[E0046]: not all trait items implemented, missing: `trait_method`
22
--> $DIR/trait-impl-missing-method.rs:9:1
33
|
4-
LL | fn do_something(&self);
5-
| ----------------------- `do_something` from trait
4+
LL | fn trait_method(&self);
5+
| ----------------------- `trait_method` from trait
66
...
77
LL | impl MyTrait for ImplType {}
8-
| ^^^^^^^^^^^^^^^^^^^^^^^^^ missing `do_something` in implementation
8+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ missing `trait_method` in implementation
99

1010
error: aborting due to 1 previous error
1111

0 commit comments

Comments
 (0)