Skip to content

Commit

Permalink
Add more information link to orphan impls
Browse files Browse the repository at this point in the history
  • Loading branch information
cafce25 committed Aug 11, 2024
1 parent 86a9959 commit ca94dd5
Show file tree
Hide file tree
Showing 37 changed files with 121 additions and 59 deletions.
4 changes: 3 additions & 1 deletion compiler/rustc_hir_analysis/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,9 @@ 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 use any uncovered types from inside the current crate
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
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_hir_analysis/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,7 @@ pub enum OnlyCurrentTraits {
Outside {
#[primary_span]
#[label(hir_analysis_only_current_traits_label)]
#[label(hir_analysis_only_current_traits_label_more_info)]
span: Span,
#[note(hir_analysis_only_current_traits_note)]
note: (),
Expand All @@ -1449,6 +1450,7 @@ pub enum OnlyCurrentTraits {
Primitive {
#[primary_span]
#[label(hir_analysis_only_current_traits_label)]
#[label(hir_analysis_only_current_traits_label_more_info)]
span: Span,
#[note(hir_analysis_only_current_traits_note)]
note: (),
Expand All @@ -1457,6 +1459,7 @@ pub enum OnlyCurrentTraits {
Arbitrary {
#[primary_span]
#[label(hir_analysis_only_current_traits_label)]
#[label(hir_analysis_only_current_traits_label_more_info)]
span: Span,
#[note(hir_analysis_only_current_traits_note)]
note: (),
Expand Down
3 changes: 2 additions & 1 deletion tests/ui/coherence/coherence-cow.re_a.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ LL | impl<T> Remote for Pair<T,Cover<T>> { }
| ^^^^^^^^^^^^^^^^^^^----------------
| | |
| | `Pair` is not defined in the current crate
| impl doesn't use any uncovered types from inside 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
|
= note: define and implement a trait or new type instead

Expand Down
3 changes: 2 additions & 1 deletion tests/ui/coherence/coherence-cow.re_b.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ LL | impl<T> Remote for Pair<Cover<T>,T> { }
| ^^^^^^^^^^^^^^^^^^^----------------
| | |
| | `Pair` is not defined in the current crate
| impl doesn't use any uncovered types from inside 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
|
= note: define and implement a trait or new type instead

Expand Down
3 changes: 2 additions & 1 deletion tests/ui/coherence/coherence-cow.re_c.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ LL | impl<T,U> Remote for Pair<Cover<T>,U> { }
| ^^^^^^^^^^^^^^^^^^^^^----------------
| | |
| | `Pair` is not defined in the current crate
| impl doesn't use any uncovered types from inside 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
|
= note: define and implement a trait or new type instead

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ LL | impl Misc for dyn Fundamental<Local> {}
| ^^^^^^^^^^^^^^----------------------
| | |
| | `dyn Fundamental<Local>` is not defined in the current crate
| impl doesn't use any uncovered types from inside 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
|
= note: define and implement a trait or new type instead

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ LL | impl !Send for dyn Marker2 {}
| ^^^^^^^^^^^^^^^-----------
| | |
| | `dyn Marker2` is not defined in the current crate
| impl doesn't use any uncovered types from inside 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
|
= note: define and implement a trait or new type instead

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ LL | unsafe impl Send for dyn Marker2 {}
| ^^^^^^^^^^^^^^^^^^^^^-----------
| | |
| | `dyn Marker2` is not defined in the current crate
| impl doesn't use any uncovered types from inside 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
|
= note: define and implement a trait or new type instead

Expand Down
12 changes: 8 additions & 4 deletions tests/ui/coherence/coherence-impls-copy.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ LL | impl Copy for &'static [NotSync] {}
| ^^^^^^^^^^^^^^------------------
| | |
| | this is not defined in the current crate because slices are always foreign
| impl doesn't use any uncovered types from inside 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
|
= note: define and implement a trait or new type instead

Expand All @@ -26,7 +27,8 @@ LL | impl Copy for i32 {}
| ^^^^^^^^^^^^^^---
| | |
| | `i32` is not defined in the current crate
| impl doesn't use any uncovered types from inside 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
|
= note: define and implement a trait or new type instead

Expand All @@ -43,7 +45,8 @@ LL | impl Copy for (MyType, MyType) {}
| ^^^^^^^^^^^^^^----------------
| | |
| | this is not defined in the current crate because tuples are always foreign
| impl doesn't use any uncovered types from inside 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
|
= note: define and implement a trait or new type instead

Expand All @@ -60,7 +63,8 @@ LL | impl Copy for [MyType] {}
| ^^^^^^^^^^^^^^--------
| | |
| | this is not defined in the current crate because slices are always foreign
| impl doesn't use any uncovered types from inside 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
|
= note: define and implement a trait or new type instead

Expand Down
9 changes: 6 additions & 3 deletions tests/ui/coherence/coherence-impls-send.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ LL | unsafe impl Send for &'static [NotSync] {}
| ^^^^^^^^^^^^^^^^^^^^^------------------
| | |
| | this is not defined in the current crate because slices are always foreign
| impl doesn't use any uncovered types from inside 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
|
= note: define and implement a trait or new type instead

Expand All @@ -16,7 +17,8 @@ LL | unsafe impl Send for (MyType, MyType) {}
| ^^^^^^^^^^^^^^^^^^^^^----------------
| | |
| | this is not defined in the current crate because tuples are always foreign
| impl doesn't use any uncovered types from inside 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
|
= note: define and implement a trait or new type instead

Expand All @@ -33,7 +35,8 @@ LL | unsafe impl Send for [MyType] {}
| ^^^^^^^^^^^^^^^^^^^^^--------
| | |
| | this is not defined in the current crate because slices are always foreign
| impl doesn't use any uncovered types from inside 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
|
= note: define and implement a trait or new type instead

Expand Down
9 changes: 6 additions & 3 deletions tests/ui/coherence/coherence-impls-sized.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ LL | impl Sized for (MyType, MyType) {}
| ^^^^^^^^^^^^^^^----------------
| | |
| | this is not defined in the current crate because tuples are always foreign
| impl doesn't use any uncovered types from inside 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
|
= note: define and implement a trait or new type instead

Expand All @@ -46,7 +47,8 @@ LL | impl Sized for [MyType] {}
| ^^^^^^^^^^^^^^^--------
| | |
| | this is not defined in the current crate because slices are always foreign
| impl doesn't use any uncovered types from inside 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
|
= note: define and implement a trait or new type instead

Expand All @@ -63,7 +65,8 @@ LL | impl Sized for &'static [NotSync] {}
| ^^^^^^^^^^^^^^^------------------
| | |
| | this is not defined in the current crate because slices are always foreign
| impl doesn't use any uncovered types from inside 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
|
= note: define and implement a trait or new type instead

Expand Down
9 changes: 6 additions & 3 deletions tests/ui/coherence/coherence-negative-impls-copy-bad.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ LL | impl !Copy for str {}
| ^^^^^^^^^^^^^^^---
| | |
| | `str` is not defined in the current crate
| impl doesn't use any uncovered types from inside 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
|
= note: define and implement a trait or new type instead

Expand All @@ -16,7 +17,8 @@ LL | impl !Copy for fn() {}
| ^^^^^^^^^^^^^^^----
| | |
| | `fn()` is not defined in the current crate
| impl doesn't use any uncovered types from inside 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
|
= note: define and implement a trait or new type instead

Expand All @@ -27,7 +29,8 @@ LL | impl !Copy for () {}
| ^^^^^^^^^^^^^^^--
| | |
| | this is not defined in the current crate because tuples are always foreign
| impl doesn't use any uncovered types from inside 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
|
= note: define and implement a trait or new type instead

Expand Down
6 changes: 4 additions & 2 deletions tests/ui/coherence/coherence-orphan.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ LL | impl TheTrait<usize> for isize {}
| | | |
| | | `isize` is not defined in the current crate
| | `usize` is not defined in the current crate
| impl doesn't use any uncovered types from inside 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
|
= note: define and implement a trait or new type instead

Expand All @@ -17,7 +18,8 @@ LL | impl !Send for Vec<isize> {}
| ^^^^^^^^^^^^^^^----------
| | |
| | `Vec` is not defined in the current crate
| impl doesn't use any uncovered types from inside 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
|
= note: define and implement a trait or new type instead

Expand Down
3 changes: 2 additions & 1 deletion tests/ui/coherence/coherence-overlapping-pairs.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ LL | impl<T> Remote for lib::Pair<T,Foo> { }
| ^^^^^^^^^^^^^^^^^^^----------------
| | |
| | `Pair` is not defined in the current crate
| impl doesn't use any uncovered types from inside 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
|
= note: define and implement a trait or new type instead

Expand Down
3 changes: 2 additions & 1 deletion tests/ui/coherence/coherence-pair-covered-uncovered-1.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ LL | impl<T, U> Remote1<Pair<T, Local<U>>> for i32 { }
| | | |
| | | `i32` is not defined in the current crate
| | `Pair` is not defined in the current crate
| impl doesn't use any uncovered types from inside 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
|
= note: define and implement a trait or new type instead

Expand Down
3 changes: 2 additions & 1 deletion tests/ui/coherence/coherence-pair-covered-uncovered.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ LL | impl<T,U> Remote for Pair<T,Local<U>> { }
| ^^^^^^^^^^^^^^^^^^^^^----------------
| | |
| | `Pair` is not defined in the current crate
| impl doesn't use any uncovered types from inside 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
|
= note: define and implement a trait or new type instead

Expand Down
3 changes: 2 additions & 1 deletion tests/ui/coherence/coherence-vec-local-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ LL | impl<T> Remote for Vec<Local<T>> { }
| ^^^^^^^^^^^^^^^^^^^-------------
| | |
| | `Vec` is not defined in the current crate
| impl doesn't use any uncovered types from inside 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
|
= note: define and implement a trait or new type instead

Expand Down
3 changes: 2 additions & 1 deletion tests/ui/coherence/coherence-vec-local.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ LL | impl Remote for Vec<Local> { }
| ^^^^^^^^^^^^^^^^----------
| | |
| | `Vec` is not defined in the current crate
| impl doesn't use any uncovered types from inside 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
|
= note: define and implement a trait or new type instead

Expand Down
3 changes: 2 additions & 1 deletion tests/ui/coherence/coherence_local_err_struct.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ LL | impl lib::MyCopy for lib::MyStruct<MyType> { }
| ^^^^^^^^^^^^^^^^^^^^^---------------------
| | |
| | `MyStruct` is not defined in the current crate
| impl doesn't use any uncovered types from inside 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
|
= note: define and implement a trait or new type instead

Expand Down
3 changes: 2 additions & 1 deletion tests/ui/coherence/coherence_local_err_tuple.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ LL | impl lib::MyCopy for (MyType,) { }
| ^^^^^^^^^^^^^^^^^^^^^---------
| | |
| | this is not defined in the current crate because tuples are always foreign
| impl doesn't use any uncovered types from inside 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
|
= note: define and implement a trait or new type instead

Expand Down
3 changes: 2 additions & 1 deletion tests/ui/coherence/impl-foreign-for-foreign.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ LL | impl Remote for i32 {
| ^^^^^^^^^^^^^^^^---
| | |
| | `i32` is not defined in the current crate
| impl doesn't use any uncovered types from inside 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
|
= note: define and implement a trait or new type instead

Expand Down
9 changes: 6 additions & 3 deletions tests/ui/coherence/impl-foreign-for-foreign[foreign].stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ LL | impl Remote1<Rc<i32>> for i32 {
| | | |
| | | `i32` is not defined in the current crate
| | `Rc` is not defined in the current crate
| impl doesn't use any uncovered types from inside 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
|
= note: define and implement a trait or new type instead

Expand All @@ -18,7 +19,8 @@ LL | impl Remote1<Rc<Local>> for f64 {
| | | |
| | | `f64` is not defined in the current crate
| | `Rc` is not defined in the current crate
| impl doesn't use any uncovered types from inside 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
|
= note: define and implement a trait or new type instead

Expand All @@ -30,7 +32,8 @@ LL | impl<T> Remote1<Rc<T>> for f32 {
| | | |
| | | `f32` is not defined in the current crate
| | `Rc` is not defined in the current crate
| impl doesn't use any uncovered types from inside 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
|
= note: define and implement a trait or new type instead

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ LL | impl Remote for Box<i32> {
| | | |
| | | `i32` is not defined in the current crate
| | `std::alloc::Global` is not defined in the current crate
| impl doesn't use any uncovered types from inside 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
|
= note: define and implement a trait or new type instead

Expand All @@ -18,7 +19,8 @@ LL | impl<T> Remote for Box<Rc<T>> {
| | | |
| | | `Rc` is not defined in the current crate
| | `std::alloc::Global` is not defined in the current crate
| impl doesn't use any uncovered types from inside 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
|
= note: define and implement a trait or new type instead

Expand Down
3 changes: 2 additions & 1 deletion tests/ui/coherence/impl-foreign[foreign]-for-foreign.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ LL | impl Remote1<u32> for f64 {
| | | |
| | | `f64` is not defined in the current crate
| | `u32` is not defined in the current crate
| impl doesn't use any uncovered types from inside 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
|
= note: define and implement a trait or new type instead

Expand Down
Loading

0 comments on commit ca94dd5

Please sign in to comment.