Rollup merge of #64110 - estebank:receiver-type, r=Centril
Refer to "`self` type" instead of "receiver type" Fix https://github.com/rust-lang/rust/issues/42603.
This commit is contained in:
commit
8ef11fcf4b
42 changed files with 283 additions and 150 deletions
|
|
@ -4,11 +4,11 @@ struct Foo<'a> {
|
|||
|
||||
impl <'a> Foo<'a>{
|
||||
fn bar(self: &mut Foo) {
|
||||
//~^ mismatched method receiver
|
||||
//~^ mismatched `self` parameter type
|
||||
//~| expected type `Foo<'a>`
|
||||
//~| found type `Foo<'_>`
|
||||
//~| lifetime mismatch
|
||||
//~| mismatched method receiver
|
||||
//~| mismatched `self` parameter type
|
||||
//~| expected type `Foo<'a>`
|
||||
//~| found type `Foo<'_>`
|
||||
//~| lifetime mismatch
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0308]: mismatched method receiver
|
||||
error[E0308]: mismatched `self` parameter type
|
||||
--> $DIR/issue-17740.rs:6:18
|
||||
|
|
||||
LL | fn bar(self: &mut Foo) {
|
||||
|
|
@ -23,7 +23,7 @@ note: ...does not necessarily outlive the lifetime 'a as defined on the impl at
|
|||
LL | impl <'a> Foo<'a>{
|
||||
| ^^
|
||||
|
||||
error[E0308]: mismatched method receiver
|
||||
error[E0308]: mismatched `self` parameter type
|
||||
--> $DIR/issue-17740.rs:6:18
|
||||
|
|
||||
LL | fn bar(self: &mut Foo) {
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ impl Pair<
|
|||
isize
|
||||
> {
|
||||
fn say(self: &Pair<&str, isize>) {
|
||||
//~^ ERROR mismatched method receiver
|
||||
//~| ERROR mismatched method receiver
|
||||
//~^ ERROR mismatched `self` parameter type
|
||||
//~| ERROR mismatched `self` parameter type
|
||||
println!("{:?}", self);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0308]: mismatched method receiver
|
||||
error[E0308]: mismatched `self` parameter type
|
||||
--> $DIR/issue-17905-2.rs:8:18
|
||||
|
|
||||
LL | fn say(self: &Pair<&str, isize>) {
|
||||
|
|
@ -21,7 +21,7 @@ note: ...does not necessarily outlive the lifetime '_ as defined on the impl at
|
|||
LL | &str,
|
||||
| ^
|
||||
|
||||
error[E0308]: mismatched method receiver
|
||||
error[E0308]: mismatched `self` parameter type
|
||||
--> $DIR/issue-17905-2.rs:8:18
|
||||
|
|
||||
LL | fn say(self: &Pair<&str, isize>) {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
error[E0038]: the trait `Bar` cannot be made into an object
|
||||
--> $DIR/issue-18959.rs:11:1
|
||||
|
|
||||
LL | pub trait Foo { fn foo<T>(&self, ext_thing: &T); }
|
||||
| --- method `foo` has generic type parameters
|
||||
...
|
||||
LL | fn foo(b: &dyn Bar) {
|
||||
| ^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object
|
||||
|
|
||||
= note: method `foo` has generic type parameters
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
error[E0038]: the trait `Qiz` cannot be made into an object
|
||||
--> $DIR/issue-19380.rs:11:3
|
||||
|
|
||||
LL | fn qiz();
|
||||
| --- associated function `qiz` has no `self` parameter
|
||||
...
|
||||
LL | foos: &'static [&'static (dyn Qiz + 'static)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Qiz` cannot be made into an object
|
||||
|
|
||||
= note: method `qiz` has no receiver
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,21 @@
|
|||
error[E0038]: the trait `Bar` cannot be made into an object
|
||||
--> $DIR/issue-19538.rs:17:15
|
||||
|
|
||||
LL | fn foo<T>(&self, val: T);
|
||||
| --- method `foo` has generic type parameters
|
||||
...
|
||||
LL | let test: &mut dyn Bar = &mut thing;
|
||||
| ^^^^^^^^^^^^ the trait `Bar` cannot be made into an object
|
||||
|
|
||||
= note: method `foo` has generic type parameters
|
||||
|
||||
error[E0038]: the trait `Bar` cannot be made into an object
|
||||
--> $DIR/issue-19538.rs:17:30
|
||||
|
|
||||
LL | fn foo<T>(&self, val: T);
|
||||
| --- method `foo` has generic type parameters
|
||||
...
|
||||
LL | let test: &mut dyn Bar = &mut thing;
|
||||
| ^^^^^^^^^^ the trait `Bar` cannot be made into an object
|
||||
|
|
||||
= note: method `foo` has generic type parameters
|
||||
= note: required because of the requirements on the impl of `std::ops::CoerceUnsized<&mut dyn Bar>` for `&mut Thing`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error: the trait `X` cannot be made into an object
|
||||
--> $DIR/issue-50781.rs:6:5
|
||||
--> $DIR/issue-50781.rs:6:8
|
||||
|
|
||||
LL | fn foo(&self) where Self: Trait;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| ^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/issue-50781.rs:1:9
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
pub trait Trait {
|
||||
fn dyn_instead_of_self(self: Box<dyn Trait>);
|
||||
//~^ ERROR invalid method receiver type: std::boxed::Box<(dyn Trait + 'static)>
|
||||
//~^ ERROR invalid `self` parameter type
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
}
|
||||
pub fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
error[E0307]: invalid method receiver type: std::boxed::Box<(dyn Trait + 'static)>
|
||||
error[E0307]: invalid `self` parameter type: std::boxed::Box<(dyn Trait + 'static)>
|
||||
--> $DIR/issue-56806.rs:2:34
|
||||
|
|
||||
LL | fn dyn_instead_of_self(self: Box<dyn Trait>);
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: type must be `Self` or a type that dereferences to it
|
||||
= note: type of `self` must be `Self` or a type that dereferences to it
|
||||
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0307`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue