Rollup merge of #134262 - adetaylor:revert-diagnostics, r=compiler-errors
Arbitrary self types v2: adjust diagnostic. The recently landed PR #132961 to adjust arbitrary self types was a bit overenthusiastic, advising folks to use the new Receiver trait even before it's been stabilized. Revert to the older wording of the lint in such cases. Tracking issue #44874 r? ``@wesleywiser``
This commit is contained in:
commit
2fc9ce7080
12 changed files with 45 additions and 23 deletions
|
@ -246,6 +246,12 @@ hir_analysis_invalid_receiver_ty = invalid `self` parameter type: `{$receiver_ty
|
||||||
hir_analysis_invalid_receiver_ty_help =
|
hir_analysis_invalid_receiver_ty_help =
|
||||||
consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
|
consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
|
||||||
|
|
||||||
|
hir_analysis_invalid_receiver_ty_help_no_arbitrary_self_types =
|
||||||
|
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`)
|
||||||
|
|
||||||
|
hir_analysis_invalid_receiver_ty_no_arbitrary_self_types = invalid `self` parameter type: `{$receiver_ty}`
|
||||||
|
.note = type of `self` must be `Self` or a type that dereferences to it
|
||||||
|
|
||||||
hir_analysis_invalid_union_field =
|
hir_analysis_invalid_union_field =
|
||||||
field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union
|
field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union
|
||||||
.note = union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>`
|
.note = union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>`
|
||||||
|
|
|
@ -1748,9 +1748,15 @@ fn check_method_receiver<'tcx>(
|
||||||
// Report error; would not have worked with `arbitrary_self_types[_pointers]`.
|
// Report error; would not have worked with `arbitrary_self_types[_pointers]`.
|
||||||
{
|
{
|
||||||
match receiver_validity_err {
|
match receiver_validity_err {
|
||||||
ReceiverValidityError::DoesNotDeref => {
|
ReceiverValidityError::DoesNotDeref if arbitrary_self_types_level.is_some() => {
|
||||||
tcx.dcx().emit_err(errors::InvalidReceiverTy { span, receiver_ty })
|
tcx.dcx().emit_err(errors::InvalidReceiverTy { span, receiver_ty })
|
||||||
}
|
}
|
||||||
|
ReceiverValidityError::DoesNotDeref => {
|
||||||
|
tcx.dcx().emit_err(errors::InvalidReceiverTyNoArbitrarySelfTypes {
|
||||||
|
span,
|
||||||
|
receiver_ty,
|
||||||
|
})
|
||||||
|
}
|
||||||
ReceiverValidityError::MethodGenericParamUsed => {
|
ReceiverValidityError::MethodGenericParamUsed => {
|
||||||
tcx.dcx().emit_err(errors::InvalidGenericReceiverTy { span, receiver_ty })
|
tcx.dcx().emit_err(errors::InvalidGenericReceiverTy { span, receiver_ty })
|
||||||
}
|
}
|
||||||
|
|
|
@ -1655,6 +1655,16 @@ pub(crate) struct NonConstRange {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(hir_analysis_invalid_receiver_ty_no_arbitrary_self_types, code = E0307)]
|
||||||
|
#[note]
|
||||||
|
#[help(hir_analysis_invalid_receiver_ty_help_no_arbitrary_self_types)]
|
||||||
|
pub(crate) struct InvalidReceiverTyNoArbitrarySelfTypes<'tcx> {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span,
|
||||||
|
pub receiver_ty: Ty<'tcx>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(hir_analysis_invalid_receiver_ty, code = E0307)]
|
#[diag(hir_analysis_invalid_receiver_ty, code = E0307)]
|
||||||
#[note]
|
#[note]
|
||||||
|
|
|
@ -4,8 +4,8 @@ error[E0307]: invalid `self` parameter type: `&dyn Foo`
|
||||||
LL | async fn foo(self: &dyn Foo) {
|
LL | async fn foo(self: &dyn Foo) {
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: type of `self` must be `Self` or some type implementing `Receiver`
|
= note: type of `self` must be `Self` or a type that dereferences to it
|
||||||
= help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
|
= 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[E0038]: the trait `Foo` cannot be made into an object
|
error[E0038]: the trait `Foo` cannot be made into an object
|
||||||
--> $DIR/inference_var_self_argument.rs:5:5
|
--> $DIR/inference_var_self_argument.rs:5:5
|
||||||
|
|
|
@ -4,8 +4,8 @@ error[E0307]: invalid `self` parameter type: `T`
|
||||||
LL | fn is_some(self: T);
|
LL | fn is_some(self: T);
|
||||||
| ^
|
| ^
|
||||||
|
|
|
|
||||||
= note: type of `self` must be `Self` or some type implementing `Receiver`
|
= note: type of `self` must be `Self` or a type that dereferences to it
|
||||||
= help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
|
= 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 types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/issue-66312.rs:9:8
|
--> $DIR/issue-66312.rs:9:8
|
||||||
|
|
|
@ -4,8 +4,8 @@ error[E0307]: invalid `self` parameter type: `Cell<&Self>`
|
||||||
LL | fn cell(self: Cell<&Self>);
|
LL | fn cell(self: Cell<&Self>);
|
||||||
| ^^^^^^^^^^^
|
| ^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: type of `self` must be `Self` or some type implementing `Receiver`
|
= note: type of `self` must be `Self` or a type that dereferences to it
|
||||||
= help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
|
= 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 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ error[E0307]: invalid `self` parameter type: `Box<(dyn Trait + 'static)>`
|
||||||
LL | fn dyn_instead_of_self(self: Box<dyn Trait>);
|
LL | fn dyn_instead_of_self(self: Box<dyn Trait>);
|
||||||
| ^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: type of `self` must be `Self` or some type implementing `Receiver`
|
= note: type of `self` must be `Self` or a type that dereferences to it
|
||||||
= help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
|
= 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 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ error[E0307]: invalid `self` parameter type: `Bar`
|
||||||
LL | fn foo(self: Bar) {}
|
LL | fn foo(self: Bar) {}
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
|
|
||||||
= note: type of `self` must be `Self` or some type implementing `Receiver`
|
= note: type of `self` must be `Self` or a type that dereferences to it
|
||||||
= help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
|
= 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: item does not constrain `Bar::{opaque#0}`, but has it in its signature
|
error: item does not constrain `Bar::{opaque#0}`, but has it in its signature
|
||||||
--> $DIR/arbitrary-self-opaque.rs:7:8
|
--> $DIR/arbitrary-self-opaque.rs:7:8
|
||||||
|
|
|
@ -4,8 +4,8 @@ error[E0307]: invalid `self` parameter type: `&SomeType`
|
||||||
LL | fn handler(self: &SomeType);
|
LL | fn handler(self: &SomeType);
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: type of `self` must be `Self` or some type implementing `Receiver`
|
= note: type of `self` must be `Self` or a type that dereferences to it
|
||||||
= help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
|
= 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 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,8 @@ error[E0307]: invalid `self` parameter type: `()`
|
||||||
LL | fn bar(self: ()) {}
|
LL | fn bar(self: ()) {}
|
||||||
| ^^
|
| ^^
|
||||||
|
|
|
|
||||||
= note: type of `self` must be `Self` or some type implementing `Receiver`
|
= note: type of `self` must be `Self` or a type that dereferences to it
|
||||||
= help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
|
= 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 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
|
@ -61,8 +61,8 @@ error[E0307]: invalid `self` parameter type: `Smaht<Self, T>`
|
||||||
LL | fn foo(self: Smaht<Self, T>);
|
LL | fn foo(self: Smaht<Self, T>);
|
||||||
| ^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: type of `self` must be `Self` or some type implementing `Receiver`
|
= note: type of `self` must be `Self` or a type that dereferences to it
|
||||||
= help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
|
= 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[E0378]: the trait `DispatchFromDyn` may only be implemented for a coercion between structures
|
error[E0378]: the trait `DispatchFromDyn` may only be implemented for a coercion between structures
|
||||||
--> $DIR/issue-78372.rs:3:1
|
--> $DIR/issue-78372.rs:3:1
|
||||||
|
|
|
@ -22,8 +22,8 @@ error[E0307]: invalid `self` parameter type: `isize`
|
||||||
LL | fn foo(self: isize, x: isize) -> isize {
|
LL | fn foo(self: isize, x: isize) -> isize {
|
||||||
| ^^^^^
|
| ^^^^^
|
||||||
|
|
|
|
||||||
= note: type of `self` must be `Self` or some type implementing `Receiver`
|
= note: type of `self` must be `Self` or a type that dereferences to it
|
||||||
= help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
|
= 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 `self` parameter type: `Bar<isize>`
|
error[E0307]: invalid `self` parameter type: `Bar<isize>`
|
||||||
--> $DIR/ufcs-explicit-self-bad.rs:19:18
|
--> $DIR/ufcs-explicit-self-bad.rs:19:18
|
||||||
|
@ -31,8 +31,8 @@ error[E0307]: invalid `self` parameter type: `Bar<isize>`
|
||||||
LL | fn foo(self: Bar<isize>, x: isize) -> isize {
|
LL | fn foo(self: Bar<isize>, x: isize) -> isize {
|
||||||
| ^^^^^^^^^^
|
| ^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: type of `self` must be `Self` or some type implementing `Receiver`
|
= note: type of `self` must be `Self` or a type that dereferences to it
|
||||||
= help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
|
= 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 `self` parameter type: `&Bar<usize>`
|
error[E0307]: invalid `self` parameter type: `&Bar<usize>`
|
||||||
--> $DIR/ufcs-explicit-self-bad.rs:23:18
|
--> $DIR/ufcs-explicit-self-bad.rs:23:18
|
||||||
|
@ -40,8 +40,8 @@ error[E0307]: invalid `self` parameter type: `&Bar<usize>`
|
||||||
LL | fn bar(self: &Bar<usize>, x: isize) -> isize {
|
LL | fn bar(self: &Bar<usize>, x: isize) -> isize {
|
||||||
| ^^^^^^^^^^^
|
| ^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: type of `self` must be `Self` or some type implementing `Receiver`
|
= note: type of `self` must be `Self` or a type that dereferences to it
|
||||||
= help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
|
= 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 `self` parameter type
|
error[E0308]: mismatched `self` parameter type
|
||||||
--> $DIR/ufcs-explicit-self-bad.rs:37:21
|
--> $DIR/ufcs-explicit-self-bad.rs:37:21
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue