Skip to content

Commit

Permalink
Make information notes instead of labels
Browse files Browse the repository at this point in the history
  • Loading branch information
cafce25 committed Sep 26, 2024
1 parent 6e275e8 commit 77cabd9
Show file tree
Hide file tree
Showing 36 changed files with 688 additions and 248 deletions.
8 changes: 4 additions & 4 deletions compiler/rustc_hir_analysis/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -352,14 +352,14 @@ hir_analysis_only_current_traits_arbitrary = only traits defined in the current
hir_analysis_only_current_traits_foreign = this is not defined in the current crate because this is a foreign trait
hir_analysis_only_current_traits_label = impl doesn't have any local type before any uncovered type parameters
hir_analysis_only_current_traits_label_more_info = for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
hir_analysis_only_current_traits_name = this is not defined in the current crate because {$name} are always foreign
hir_analysis_only_current_traits_note = define and implement a trait or new type instead
hir_analysis_only_current_traits_note_more_info = for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
hir_analysis_only_current_traits_note_uncovered = impl doesn't have any local type before any uncovered type parameters
hir_analysis_only_current_traits_opaque = type alias impl trait is treated as if it were foreign, because its hidden type could be from a foreign crate
hir_analysis_only_current_traits_outside = only traits defined in the current crate can be implemented for types defined outside of the crate
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_hir_analysis/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1441,26 +1441,26 @@ pub(crate) enum OnlyCurrentTraits {
#[diag(hir_analysis_only_current_traits_outside, code = E0117)]
Outside {
#[primary_span]
#[label(hir_analysis_only_current_traits_label)]
#[label(hir_analysis_only_current_traits_label_more_info)]
#[note(hir_analysis_only_current_traits_note_uncovered)]
#[note(hir_analysis_only_current_traits_note_more_info)]
span: Span,
#[note(hir_analysis_only_current_traits_note)]
note: (),
},
#[diag(hir_analysis_only_current_traits_primitive, code = E0117)]
Primitive {
#[primary_span]
#[label(hir_analysis_only_current_traits_label)]
#[label(hir_analysis_only_current_traits_label_more_info)]
#[note(hir_analysis_only_current_traits_note_uncovered)]
#[note(hir_analysis_only_current_traits_note_more_info)]
span: Span,
#[note(hir_analysis_only_current_traits_note)]
note: (),
},
#[diag(hir_analysis_only_current_traits_arbitrary, code = E0117)]
Arbitrary {
#[primary_span]
#[label(hir_analysis_only_current_traits_label)]
#[label(hir_analysis_only_current_traits_label_more_info)]
#[note(hir_analysis_only_current_traits_note_uncovered)]
#[note(hir_analysis_only_current_traits_note_more_info)]
span: Span,
#[note(hir_analysis_only_current_traits_note)]
note: (),
Expand Down
16 changes: 12 additions & 4 deletions tests/ui/coherence/coherence-cow.re_a.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@ error[E0117]: only traits defined in the current crate can be implemented for ty
|
LL | impl<T> Remote for Pair<T,Cover<T>> { }
| ^^^^^^^^^^^^^^^^^^^----------------
| | |
| | `Pair` is not defined in the current crate
| impl doesn't have any local type before any uncovered type parameters
| for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
| |
| `Pair` is not defined in the current crate
|
note: impl doesn't have any local type before any uncovered type parameters
--> $DIR/coherence-cow.rs:18:1
|
LL | impl<T> Remote for Pair<T,Cover<T>> { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
--> $DIR/coherence-cow.rs:18:1
|
LL | impl<T> Remote for Pair<T,Cover<T>> { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: define and implement a trait or new type instead

error: aborting due to 1 previous error
Expand Down
16 changes: 12 additions & 4 deletions tests/ui/coherence/coherence-cow.re_b.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@ error[E0117]: only traits defined in the current crate can be implemented for ty
|
LL | impl<T> Remote for Pair<Cover<T>,T> { }
| ^^^^^^^^^^^^^^^^^^^----------------
| | |
| | `Pair` is not defined in the current crate
| impl doesn't have any local type before any uncovered type parameters
| for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
| |
| `Pair` is not defined in the current crate
|
note: impl doesn't have any local type before any uncovered type parameters
--> $DIR/coherence-cow.rs:22:1
|
LL | impl<T> Remote for Pair<Cover<T>,T> { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
--> $DIR/coherence-cow.rs:22:1
|
LL | impl<T> Remote for Pair<Cover<T>,T> { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: define and implement a trait or new type instead

error: aborting due to 1 previous error
Expand Down
16 changes: 12 additions & 4 deletions tests/ui/coherence/coherence-cow.re_c.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@ error[E0117]: only traits defined in the current crate can be implemented for ty
|
LL | impl<T,U> Remote for Pair<Cover<T>,U> { }
| ^^^^^^^^^^^^^^^^^^^^^----------------
| | |
| | `Pair` is not defined in the current crate
| impl doesn't have any local type before any uncovered type parameters
| for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
| |
| `Pair` is not defined in the current crate
|
note: impl doesn't have any local type before any uncovered type parameters
--> $DIR/coherence-cow.rs:26:1
|
LL | impl<T,U> Remote for Pair<Cover<T>,U> { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
--> $DIR/coherence-cow.rs:26:1
|
LL | impl<T,U> Remote for Pair<Cover<T>,U> { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: define and implement a trait or new type instead

error: aborting due to 1 previous error
Expand Down
16 changes: 12 additions & 4 deletions tests/ui/coherence/coherence-fundamental-trait-objects.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@ error[E0117]: only traits defined in the current crate can be implemented for ar
|
LL | impl Misc for dyn Fundamental<Local> {}
| ^^^^^^^^^^^^^^----------------------
| | |
| | `dyn Fundamental<Local>` is not defined in the current crate
| impl doesn't have any local type before any uncovered type parameters
| for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
| |
| `dyn Fundamental<Local>` is not defined in the current crate
|
note: impl doesn't have any local type before any uncovered type parameters
--> $DIR/coherence-fundamental-trait-objects.rs:12:1
|
LL | impl Misc for dyn Fundamental<Local> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
--> $DIR/coherence-fundamental-trait-objects.rs:12:1
|
LL | impl Misc for dyn Fundamental<Local> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: define and implement a trait or new type instead

error: aborting due to 1 previous error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,19 @@ error[E0117]: only traits defined in the current crate can be implemented for ar
|
LL | impl !Send for dyn Marker2 {}
| ^^^^^^^^^^^^^^^-----------
| | |
| | `dyn Marker2` is not defined in the current crate
| impl doesn't have any local type before any uncovered type parameters
| for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
| |
| `dyn Marker2` is not defined in the current crate
|
note: impl doesn't have any local type before any uncovered type parameters
--> $DIR/coherence-impl-trait-for-marker-trait-negative.rs:22:1
|
LL | impl !Send for dyn Marker2 {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
--> $DIR/coherence-impl-trait-for-marker-trait-negative.rs:22:1
|
LL | impl !Send for dyn Marker2 {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: define and implement a trait or new type instead

error[E0321]: cross-crate traits with a default impl, like `Send`, can only be implemented for a struct/enum type, not `(dyn Object + 'static)`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,19 @@ error[E0117]: only traits defined in the current crate can be implemented for ar
|
LL | unsafe impl Send for dyn Marker2 {}
| ^^^^^^^^^^^^^^^^^^^^^-----------
| | |
| | `dyn Marker2` is not defined in the current crate
| impl doesn't have any local type before any uncovered type parameters
| for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
| |
| `dyn Marker2` is not defined in the current crate
|
note: impl doesn't have any local type before any uncovered type parameters
--> $DIR/coherence-impl-trait-for-marker-trait-positive.rs:22:1
|
LL | unsafe impl Send for dyn Marker2 {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
--> $DIR/coherence-impl-trait-for-marker-trait-positive.rs:22:1
|
LL | unsafe impl Send for dyn Marker2 {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: define and implement a trait or new type instead

error[E0321]: cross-crate traits with a default impl, like `Send`, can only be implemented for a struct/enum type, not `(dyn Object + 'static)`
Expand Down
64 changes: 48 additions & 16 deletions tests/ui/coherence/coherence-impls-copy.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,39 @@ error[E0117]: only traits defined in the current crate can be implemented for ar
|
LL | impl Copy for &'static [NotSync] {}
| ^^^^^^^^^^^^^^------------------
| | |
| | this is not defined in the current crate because slices are always foreign
| impl doesn't have any local type before any uncovered type parameters
| for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
| |
| this is not defined in the current crate because slices are always foreign
|
note: impl doesn't have any local type before any uncovered type parameters
--> $DIR/coherence-impls-copy.rs:33:1
|
LL | impl Copy for &'static [NotSync] {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
--> $DIR/coherence-impls-copy.rs:33:1
|
LL | impl Copy for &'static [NotSync] {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: define and implement a trait or new type instead

error[E0117]: only traits defined in the current crate can be implemented for primitive types
--> $DIR/coherence-impls-copy.rs:5:1
|
LL | impl Copy for i32 {}
| ^^^^^^^^^^^^^^---
| | |
| | `i32` is not defined in the current crate
| impl doesn't have any local type before any uncovered type parameters
| for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
| |
| `i32` is not defined in the current crate
|
note: impl doesn't have any local type before any uncovered type parameters
--> $DIR/coherence-impls-copy.rs:5:1
|
LL | impl Copy for i32 {}
| ^^^^^^^^^^^^^^^^^
note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
--> $DIR/coherence-impls-copy.rs:5:1
|
LL | impl Copy for i32 {}
| ^^^^^^^^^^^^^^^^^
= note: define and implement a trait or new type instead

error[E0206]: the trait `Copy` cannot be implemented for this type
Expand All @@ -43,11 +59,19 @@ error[E0117]: only traits defined in the current crate can be implemented for ar
|
LL | impl Copy for (MyType, MyType) {}
| ^^^^^^^^^^^^^^----------------
| | |
| | this is not defined in the current crate because tuples are always foreign
| impl doesn't have any local type before any uncovered type parameters
| for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
| |
| this is not defined in the current crate because tuples are always foreign
|
note: impl doesn't have any local type before any uncovered type parameters
--> $DIR/coherence-impls-copy.rs:25:1
|
LL | impl Copy for (MyType, MyType) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
--> $DIR/coherence-impls-copy.rs:25:1
|
LL | impl Copy for (MyType, MyType) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: define and implement a trait or new type instead

error[E0206]: the trait `Copy` cannot be implemented for this type
Expand All @@ -61,11 +85,19 @@ error[E0117]: only traits defined in the current crate can be implemented for ar
|
LL | impl Copy for [MyType] {}
| ^^^^^^^^^^^^^^--------
| | |
| | this is not defined in the current crate because slices are always foreign
| impl doesn't have any local type before any uncovered type parameters
| for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
| |
| this is not defined in the current crate because slices are always foreign
|
note: impl doesn't have any local type before any uncovered type parameters
--> $DIR/coherence-impls-copy.rs:30:1
|
LL | impl Copy for [MyType] {}
| ^^^^^^^^^^^^^^^^^^^^^^
note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
--> $DIR/coherence-impls-copy.rs:30:1
|
LL | impl Copy for [MyType] {}
| ^^^^^^^^^^^^^^^^^^^^^^
= note: define and implement a trait or new type instead

error[E0206]: the trait `Copy` cannot be implemented for this type
Expand Down
48 changes: 36 additions & 12 deletions tests/ui/coherence/coherence-impls-send.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,39 @@ error[E0117]: only traits defined in the current crate can be implemented for ar
|
LL | unsafe impl Send for &'static [NotSync] {}
| ^^^^^^^^^^^^^^^^^^^^^------------------
| | |
| | this is not defined in the current crate because slices are always foreign
| impl doesn't have any local type before any uncovered type parameters
| for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
| |
| this is not defined in the current crate because slices are always foreign
|
note: impl doesn't have any local type before any uncovered type parameters
--> $DIR/coherence-impls-send.rs:25:1
|
LL | unsafe impl Send for &'static [NotSync] {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
--> $DIR/coherence-impls-send.rs:25:1
|
LL | unsafe impl Send for &'static [NotSync] {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: define and implement a trait or new type instead

error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/coherence-impls-send.rs:16:1
|
LL | unsafe impl Send for (MyType, MyType) {}
| ^^^^^^^^^^^^^^^^^^^^^----------------
| | |
| | this is not defined in the current crate because tuples are always foreign
| impl doesn't have any local type before any uncovered type parameters
| for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
| |
| this is not defined in the current crate because tuples are always foreign
|
note: impl doesn't have any local type before any uncovered type parameters
--> $DIR/coherence-impls-send.rs:16:1
|
LL | unsafe impl Send for (MyType, MyType) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
--> $DIR/coherence-impls-send.rs:16:1
|
LL | unsafe impl Send for (MyType, MyType) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: define and implement a trait or new type instead

error[E0321]: cross-crate traits with a default impl, like `Send`, can only be implemented for a struct/enum type, not `&'static NotSync`
Expand All @@ -33,11 +49,19 @@ error[E0117]: only traits defined in the current crate can be implemented for ar
|
LL | unsafe impl Send for [MyType] {}
| ^^^^^^^^^^^^^^^^^^^^^--------
| | |
| | this is not defined in the current crate because slices are always foreign
| impl doesn't have any local type before any uncovered type parameters
| for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
| |
| this is not defined in the current crate because slices are always foreign
|
note: impl doesn't have any local type before any uncovered type parameters
--> $DIR/coherence-impls-send.rs:22:1
|
LL | unsafe impl Send for [MyType] {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
--> $DIR/coherence-impls-send.rs:22:1
|
LL | unsafe impl Send for [MyType] {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: define and implement a trait or new type instead

error: aborting due to 4 previous errors
Expand Down
Loading

0 comments on commit 77cabd9

Please sign in to comment.