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:
Mazdak Farrokhzad 2019-09-05 03:59:44 +02:00 committed by GitHub
commit 8ef11fcf4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 283 additions and 150 deletions

View file

@ -1,10 +1,11 @@
error[E0038]: the trait `Trait` cannot be made into an object
--> $DIR/associated-const-in-trait.rs:9:6
|
LL | const N: usize;
| - the trait cannot contain associated consts like `N`
...
LL | impl dyn Trait {
| ^^^^^^^^^ the trait `Trait` cannot be made into an object
|
= note: the trait cannot contain associated consts like `N`
error: aborting due to previous error

View file

@ -1,10 +1,10 @@
error[E0038]: the trait `NotObjectSafe` cannot be made into an object
--> $DIR/coherence-impl-trait-for-trait-object-safe.rs:11:6
|
LL | trait NotObjectSafe { fn eq(&self, other: Self); }
| -- method `eq` references the `Self` type in its parameters or return type
LL | impl NotObjectSafe for dyn NotObjectSafe { }
| ^^^^^^^^^^^^^ the trait `NotObjectSafe` cannot be made into an object
|
= note: method `eq` references the `Self` type in its arguments or return type
error: aborting due to previous error

View file

@ -1,10 +1,10 @@
error[E0038]: the trait `NotObjectSafe` cannot be made into an object
--> $DIR/coherence-impl-trait-for-trait-object-safe.rs:11:6
|
LL | trait NotObjectSafe { fn eq(&self, other: Self); }
| -- method `eq` references the `Self` type in its parameters or return type
LL | impl NotObjectSafe for dyn NotObjectSafe { }
| ^^^^^^^^^^^^^ the trait `NotObjectSafe` cannot be made into an object
|
= note: method `eq` references the `Self` type in its arguments or return type
error: aborting due to previous error

View file

@ -61,8 +61,9 @@ error[E0038]: the trait `X` cannot be made into an object
|
LL | impl dyn X {
| ^^^^^ the trait `X` cannot be made into an object
|
= note: method `xxx` has no receiver
...
LL | fn xxx() { ### }
| --- associated function `xxx` has no `self` parameter
error: aborting due to 9 previous errors

View file

@ -1,14 +1,13 @@
// compile-flags: -Z teach
trait SomeTrait {
fn foo();
fn foo(); //~ associated function `foo` has no `self` parameter
}
fn main() {
let trait_obj: &dyn SomeTrait = SomeTrait;
//~^ ERROR expected value, found trait `SomeTrait`
//~| ERROR E0038
//~| method `foo` has no receiver
let &invalid = trait_obj;
//~^ ERROR E0033

View file

@ -7,13 +7,14 @@ LL | let trait_obj: &dyn SomeTrait = SomeTrait;
error[E0038]: the trait `SomeTrait` cannot be made into an object
--> $DIR/E0033-teach.rs:8:20
|
LL | fn foo();
| --- associated function `foo` has no `self` parameter
...
LL | let trait_obj: &dyn SomeTrait = SomeTrait;
| ^^^^^^^^^^^^^^ the trait `SomeTrait` cannot be made into an object
|
= note: method `foo` has no receiver
error[E0033]: type `&dyn SomeTrait` cannot be dereferenced
--> $DIR/E0033-teach.rs:13:9
--> $DIR/E0033-teach.rs:12:9
|
LL | let &invalid = trait_obj;
| ^^^^^^^^ type `&dyn SomeTrait` cannot be dereferenced

View file

@ -1,12 +1,11 @@
trait SomeTrait {
fn foo();
fn foo(); //~ associated function `foo` has no `self` parameter
}
fn main() {
let trait_obj: &dyn SomeTrait = SomeTrait;
//~^ ERROR expected value, found trait `SomeTrait`
//~| ERROR E0038
//~| method `foo` has no receiver
let &invalid = trait_obj;
//~^ ERROR E0033

View file

@ -7,13 +7,14 @@ LL | let trait_obj: &dyn SomeTrait = SomeTrait;
error[E0038]: the trait `SomeTrait` cannot be made into an object
--> $DIR/E0033.rs:6:20
|
LL | fn foo();
| --- associated function `foo` has no `self` parameter
...
LL | let trait_obj: &dyn SomeTrait = SomeTrait;
| ^^^^^^^^^^^^^^ the trait `SomeTrait` cannot be made into an object
|
= note: method `foo` has no receiver
error[E0033]: type `&dyn SomeTrait` cannot be dereferenced
--> $DIR/E0033.rs:11:9
--> $DIR/E0033.rs:10:9
|
LL | let &invalid = trait_obj;
| ^^^^^^^^ type `&dyn SomeTrait` cannot be dereferenced

View file

@ -1,10 +1,11 @@
error[E0038]: the trait `Trait` cannot be made into an object
--> $DIR/E0038.rs:5:1
|
LL | fn foo(&self) -> Self;
| --- method `foo` references the `Self` type in its parameters or return type
...
LL | fn call_foo(x: Box<dyn Trait>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` cannot be made into an object
|
= note: method `foo` references the `Self` type in its arguments or return type
error: aborting due to previous error

View file

@ -6,11 +6,11 @@ struct Foo<'a,'b> {
impl<'a,'b> Foo<'a,'b> {
fn bar(self:
Foo<'b,'a>
//~^ ERROR mismatched method receiver
//~^ ERROR mismatched `self` parameter type
//~| expected type `Foo<'a, 'b>`
//~| found type `Foo<'b, 'a>`
//~| lifetime mismatch
//~| ERROR mismatched method receiver
//~| ERROR mismatched `self` parameter type
//~| expected type `Foo<'a, 'b>`
//~| found type `Foo<'b, 'a>`
//~| lifetime mismatch

View file

@ -1,4 +1,4 @@
error[E0308]: mismatched method receiver
error[E0308]: mismatched `self` parameter type
--> $DIR/explicit-self-lifetime-mismatch.rs:8:12
|
LL | Foo<'b,'a>
@ -17,7 +17,7 @@ note: ...does not necessarily outlive the lifetime 'a as defined on the impl at
LL | impl<'a,'b> Foo<'a,'b> {
| ^^
error[E0308]: mismatched method receiver
error[E0308]: mismatched `self` parameter type
--> $DIR/explicit-self-lifetime-mismatch.rs:8:12
|
LL | Foo<'b,'a>

View file

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

View file

@ -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) {

View file

@ -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);
}
}

View file

@ -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>) {

View file

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

View file

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

View file

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

View file

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

View file

@ -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() {}

View file

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

View file

@ -1,10 +1,11 @@
error[E0038]: the trait `Bar` cannot be made into an object
--> $DIR/object-safety-associated-consts.rs:9:1
|
LL | const X: usize;
| - the trait cannot contain associated consts like `X`
...
LL | fn make_bar<T:Bar>(t: &T) -> &dyn Bar {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object
|
= note: the trait cannot contain associated consts like `X`
error: aborting due to previous error

View file

@ -1,18 +1,20 @@
error[E0038]: the trait `Bar` cannot be made into an object
--> $DIR/object-safety-generics.rs:14:1
|
LL | fn bar<T>(&self, t: T);
| --- method `bar` has generic type parameters
...
LL | fn make_bar<T:Bar>(t: &T) -> &dyn Bar {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object
|
= note: method `bar` has generic type parameters
error[E0038]: the trait `Bar` cannot be made into an object
--> $DIR/object-safety-generics.rs:19:1
|
LL | fn bar<T>(&self, t: T);
| --- method `bar` has generic type parameters
...
LL | fn make_bar_explicit<T:Bar>(t: &T) -> &dyn Bar {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object
|
= note: method `bar` has generic type parameters
error: aborting due to 2 previous errors

View file

@ -1,18 +1,20 @@
error[E0038]: the trait `Bar` cannot be made into an object
--> $DIR/object-safety-mentions-Self.rs:17:1
|
LL | fn bar(&self, x: &Self);
| --- method `bar` references the `Self` type in its parameters or return type
...
LL | fn make_bar<T:Bar>(t: &T) -> &dyn Bar {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object
|
= note: method `bar` references the `Self` type in its arguments or return type
error[E0038]: the trait `Baz` cannot be made into an object
--> $DIR/object-safety-mentions-Self.rs:22:1
|
LL | fn bar(&self) -> Self;
| --- method `bar` references the `Self` type in its parameters or return type
...
LL | fn make_baz<T:Baz>(t: &T) -> &dyn Baz {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Baz` cannot be made into an object
|
= note: method `bar` references the `Self` type in its arguments or return type
error: aborting due to 2 previous errors

View file

@ -1,10 +1,11 @@
error[E0038]: the trait `Foo` cannot be made into an object
--> $DIR/object-safety-no-static.rs:8:1
|
LL | fn foo();
| --- associated function `foo` has no `self` parameter
...
LL | fn foo_implicit<T:Foo+'static>(b: Box<T>) -> Box<dyn Foo + 'static> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` cannot be made into an object
|
= note: method `foo` has no receiver
error: aborting due to previous error

View file

@ -4,7 +4,7 @@ error[E0038]: the trait `issue_3907::Foo` cannot be made into an object
LL | fn bar(_x: Foo) {}
| ^^^^^^^^^^^^^^^ the trait `issue_3907::Foo` cannot be made into an object
|
= note: method `bar` has no receiver
= note: associated function `bar` has no `self` parameter
error: aborting due to previous error

View file

@ -1,18 +1,21 @@
error[E0038]: the trait `Foo` cannot be made into an object
--> $DIR/arbitrary-self-types-not-object-safe.rs:31:32
|
LL | fn foo(self: &Rc<Self>) -> usize;
| --- method `foo`'s `self` parameter cannot be dispatched on
...
LL | let x = Rc::new(5usize) as Rc<dyn Foo>;
| ^^^^^^^^^^^ the trait `Foo` cannot be made into an object
|
= note: method `foo`'s receiver cannot be dispatched on
error[E0038]: the trait `Foo` cannot be made into an object
--> $DIR/arbitrary-self-types-not-object-safe.rs:31:13
|
LL | fn foo(self: &Rc<Self>) -> usize;
| --- method `foo`'s `self` parameter cannot be dispatched on
...
LL | let x = Rc::new(5usize) as Rc<dyn Foo>;
| ^^^^^^^^^^^^^^^ the trait `Foo` cannot be made into an object
|
= note: method `foo`'s receiver cannot be dispatched on
= note: required because of the requirements on the impl of `std::ops::CoerceUnsized<std::rc::Rc<dyn Foo>>` for `std::rc::Rc<usize>`
error: aborting due to 2 previous errors

View file

@ -3,7 +3,7 @@
struct SomeType {}
trait Foo {
fn handler(self: &SomeType); //~ ERROR invalid method receiver type
fn handler(self: &SomeType); //~ ERROR invalid `self` parameter type
}
fn main() {}

View file

@ -1,11 +1,12 @@
error[E0307]: invalid method receiver type: &SomeType
error[E0307]: invalid `self` parameter type: &SomeType
--> $DIR/issue-27522.rs:6:22
|
LL | fn handler(self: &SomeType);
| ^^^^^^^^^
|
= 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`.

View file

@ -110,12 +110,17 @@ LL | C::A;
error[E0038]: the trait `assoc_const::C` cannot be made into an object
--> $DIR/trait-item-privacy.rs:101:5
|
LL | const A: u8 = 0;
| - the trait cannot contain associated consts like `A`
...
LL | const B: u8 = 0;
| - the trait cannot contain associated consts like `B`
...
LL | const C: u8 = 0;
| - the trait cannot contain associated consts like `C`
...
LL | C::A;
| ^^^^ the trait `assoc_const::C` cannot be made into an object
|
= note: the trait cannot contain associated consts like `C`
= note: the trait cannot contain associated consts like `B`
= note: the trait cannot contain associated consts like `A`
error[E0223]: ambiguous associated type
--> $DIR/trait-item-privacy.rs:115:12

View file

@ -1,19 +1,22 @@
error[E0038]: the trait `Tr` cannot be made into an object
--> $DIR/trait-object-safety.rs:15:22
|
LL | fn foo();
| --- associated function `foo` has no `self` parameter
...
LL | let _: &dyn Tr = &St;
| ^^^ the trait `Tr` cannot be made into an object
|
= note: method `foo` has no receiver
= note: required because of the requirements on the impl of `std::ops::CoerceUnsized<&dyn Tr>` for `&St`
error[E0038]: the trait `Tr` cannot be made into an object
--> $DIR/trait-object-safety.rs:15:12
|
LL | fn foo();
| --- associated function `foo` has no `self` parameter
...
LL | let _: &dyn Tr = &St;
| ^^^^^^^ the trait `Tr` cannot be made into an object
|
= note: method `foo` has no receiver
error: aborting due to 2 previous errors

View file

@ -13,20 +13,25 @@ LL | 10.blah::<i32, i32>();
error[E0038]: the trait `bar` cannot be made into an object
--> $DIR/trait-test-2.rs:11:16
|
LL | trait bar { fn dup(&self) -> Self; fn blah<X>(&self); }
| --- ---- method `blah` has generic type parameters
| |
| method `dup` references the `Self` type in its parameters or return type
...
LL | (box 10 as Box<dyn bar>).dup();
| ^^^^^^^^^^^^ the trait `bar` cannot be made into an object
|
= note: method `dup` references the `Self` type in its arguments or return type
= note: method `blah` has generic type parameters
error[E0038]: the trait `bar` cannot be made into an object
--> $DIR/trait-test-2.rs:11:6
|
LL | trait bar { fn dup(&self) -> Self; fn blah<X>(&self); }
| --- ---- method `blah` has generic type parameters
| |
| method `dup` references the `Self` type in its parameters or return type
...
LL | (box 10 as Box<dyn bar>).dup();
| ^^^^^^ the trait `bar` cannot be made into an object
|
= note: method `dup` references the `Self` type in its arguments or return type
= note: method `blah` has generic type parameters
= note: required because of the requirements on the impl of `std::ops::CoerceUnsized<std::boxed::Box<dyn bar>>` for `std::boxed::Box<{integer}>`
error: aborting due to 4 previous errors

View file

@ -13,10 +13,11 @@ LL | let y = x as dyn MyAdd<i32>;
error[E0038]: the trait `MyAdd` cannot be made into an object
--> $DIR/type-parameter-defaults-referencing-Self-ppaux.rs:14:18
|
LL | trait MyAdd<Rhs=Self> { fn add(&self, other: &Rhs) -> Self; }
| --- method `add` references the `Self` type in its parameters or return type
...
LL | let y = x as dyn MyAdd<i32>;
| ^^^^^^^^^^^^^^ the trait `MyAdd` cannot be made into an object
|
= note: method `add` references the `Self` type in its arguments or return type
error: aborting due to 2 previous errors

View file

@ -6,7 +6,7 @@ struct Foo {
impl Foo {
fn foo(self: isize, x: isize) -> isize {
//~^ ERROR invalid method receiver type
//~^ ERROR invalid `self` parameter type
self.f + x
}
}
@ -17,11 +17,11 @@ struct Bar<T> {
impl<T> Bar<T> {
fn foo(self: Bar<isize>, x: isize) -> isize {
//~^ ERROR invalid method receiver type
//~^ ERROR invalid `self` parameter type
x
}
fn bar(self: &Bar<usize>, x: isize) -> isize {
//~^ ERROR invalid method receiver type
//~^ ERROR invalid `self` parameter type
x
}
}
@ -34,14 +34,14 @@ trait SomeTrait {
impl<'a, T> SomeTrait for &'a Bar<T> {
fn dummy1(self: &&'a Bar<T>) { }
fn dummy2(self: &Bar<T>) {} //~ ERROR mismatched method receiver
//~^ ERROR mismatched method receiver
fn dummy2(self: &Bar<T>) {} //~ ERROR mismatched `self` parameter type
//~^ ERROR mismatched `self` parameter type
fn dummy3(self: &&Bar<T>) {}
//~^ ERROR mismatched method receiver
//~^ ERROR mismatched `self` parameter type
//~| expected type `&'a Bar<T>`
//~| found type `&Bar<T>`
//~| lifetime mismatch
//~| ERROR mismatched method receiver
//~| ERROR mismatched `self` parameter type
//~| expected type `&'a Bar<T>`
//~| found type `&Bar<T>`
//~| lifetime mismatch

View file

@ -1,31 +1,31 @@
error[E0307]: invalid method receiver type: isize
error[E0307]: invalid `self` parameter type: isize
--> $DIR/ufcs-explicit-self-bad.rs:8:18
|
LL | fn foo(self: isize, x: isize) -> isize {
| ^^^^^
|
= 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[E0307]: invalid method receiver type: Bar<isize>
error[E0307]: invalid `self` parameter type: Bar<isize>
--> $DIR/ufcs-explicit-self-bad.rs:19:18
|
LL | fn foo(self: Bar<isize>, x: isize) -> isize {
| ^^^^^^^^^^
|
= 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[E0307]: invalid method receiver type: &Bar<usize>
error[E0307]: invalid `self` parameter type: &Bar<usize>
--> $DIR/ufcs-explicit-self-bad.rs:23:18
|
LL | fn bar(self: &Bar<usize>, x: isize) -> isize {
| ^^^^^^^^^^^
|
= 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[E0308]: mismatched method receiver
error[E0308]: mismatched `self` parameter type
--> $DIR/ufcs-explicit-self-bad.rs:37:21
|
LL | fn dummy2(self: &Bar<T>) {}
@ -44,7 +44,7 @@ note: ...does not necessarily outlive the lifetime 'a as defined on the impl at
LL | impl<'a, T> SomeTrait for &'a Bar<T> {
| ^^
error[E0308]: mismatched method receiver
error[E0308]: mismatched `self` parameter type
--> $DIR/ufcs-explicit-self-bad.rs:37:21
|
LL | fn dummy2(self: &Bar<T>) {}
@ -63,7 +63,7 @@ note: ...does not necessarily outlive the anonymous lifetime #1 defined on the m
LL | fn dummy2(self: &Bar<T>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched method receiver
error[E0308]: mismatched `self` parameter type
--> $DIR/ufcs-explicit-self-bad.rs:39:21
|
LL | fn dummy3(self: &&Bar<T>) {}
@ -82,7 +82,7 @@ note: ...does not necessarily outlive the lifetime 'a as defined on the impl at
LL | impl<'a, T> SomeTrait for &'a Bar<T> {
| ^^
error[E0308]: mismatched method receiver
error[E0308]: mismatched `self` parameter type
--> $DIR/ufcs-explicit-self-bad.rs:39:21
|
LL | fn dummy3(self: &&Bar<T>) {}
@ -103,4 +103,5 @@ LL | fn dummy3(self: &&Bar<T>) {}
error: aborting due to 7 previous errors
For more information about this error, try `rustc --explain E0308`.
Some errors have detailed explanations: E0307, E0308.
For more information about an error, try `rustc --explain E0307`.

View file

@ -1,10 +1,11 @@
error[E0038]: the trait `A` cannot be made into an object
--> $DIR/wf-object-safe.rs:9:13
|
LL | fn foo(&self, _x: &Self);
| --- method `foo` references the `Self` type in its parameters or return type
...
LL | let _x: &dyn A;
| ^^^^^^ the trait `A` cannot be made into an object
|
= note: method `foo` references the `Self` type in its arguments or return type
error: aborting due to previous error