Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change orphan hint from "only" to "any uncovered type inside..." #128391

Merged
merged 4 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 only 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 only 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 only 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vibe: I feel like these two lines should be notes, not labels

|
= 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 only 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 only 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 only 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 only 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 only 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 only 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 only 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 only 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 only 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 only 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 only 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 only 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 only 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 only 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 only 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 only 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 only 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 only 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 only 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 only 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 only 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 only 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 only 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 only 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 only 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 only 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 only 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 only 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 only 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 only 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 only 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 only 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 only 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
Loading