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 2 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
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ 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 use any uncovered types from inside the current crate
Copy link
Contributor

@lcnr lcnr Jul 31, 2024

Choose a reason for hiding this comment

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

this is also not quite correct

the requirement is that given an impl impl<T0..TN> Trait<P1..Pn> for P0, there exists an uncovered local type at position Pi such that P0..Pi does not contain any uncovered generic parameters

impl<T> Trait<Local> for T {} also results in this error

Copy link
Contributor Author

@cafce25 cafce25 Jul 31, 2024

Choose a reason for hiding this comment

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

That's correct of course, I didn't want to increase the verbosity too much.

What do you think of appending "before any uncovered generic type parameters". This again isn't totally bullet proof as P0 is only logically before the other Pn but is not before them in the source.

Copy link
Contributor

@lcnr lcnr Aug 1, 2024

Choose a reason for hiding this comment

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

maybe something like:

  • "note: impl has uncovered type parameters before any local types"
  • "note: for more information see "

Copy link
Contributor Author

@cafce25 cafce25 Aug 4, 2024

Choose a reason for hiding this comment

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

I think it's not so clear that "no local types" is also problematic when inverted like this. I prefer the original negated version. I do like the shortened "local type" instead of "types from inside the current crate", when we link to the reference anyways I think we can get away with it as it expands on what a "local type" is:

I'm guessing that's the link you meant to add here? Is it ok to link to a fragment of the reference?

I'll see if I can figure out how to add multi line notes (multiple notes?).

Copy link
Contributor

Choose a reason for hiding this comment

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

mutliple notes, yeah

your suggestion looks good to me


hir_analysis_only_current_traits_name = this is not defined in the current crate because {$name} are always foreign

Expand Down
2 changes: 1 addition & 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,7 @@ 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 use any uncovered types from inside the current crate
|
= note: define and implement a trait or new type instead

Expand Down
2 changes: 1 addition & 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,7 @@ 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 use any uncovered types from inside the current crate
|
= note: define and implement a trait or new type instead

Expand Down
2 changes: 1 addition & 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,7 @@ 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 use any uncovered types from inside the current crate
|
= 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,7 @@ 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 use any uncovered types from inside the current crate
|
= 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,7 @@ 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 use any uncovered types from inside the current crate
|
= 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,7 @@ 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 use any uncovered types from inside the current crate
|
= note: define and implement a trait or new type instead

Expand Down
8 changes: 4 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,7 @@ 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 use any uncovered types from inside the current crate
|
= note: define and implement a trait or new type instead

Expand All @@ -26,7 +26,7 @@ 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 use any uncovered types from inside the current crate
|
= note: define and implement a trait or new type instead

Expand All @@ -43,7 +43,7 @@ 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 use any uncovered types from inside the current crate
|
= note: define and implement a trait or new type instead

Expand All @@ -60,7 +60,7 @@ 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 use any uncovered types from inside the current crate
|
= note: define and implement a trait or new type instead

Expand Down
6 changes: 3 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,7 @@ 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 use any uncovered types from inside the current crate
|
= note: define and implement a trait or new type instead

Expand All @@ -16,7 +16,7 @@ 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 use any uncovered types from inside the current crate
|
= note: define and implement a trait or new type instead

Expand All @@ -33,7 +33,7 @@ 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 use any uncovered types from inside the current crate
|
= note: define and implement a trait or new type instead

Expand Down
6 changes: 3 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,7 @@ 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 use any uncovered types from inside the current crate
|
= note: define and implement a trait or new type instead

Expand All @@ -46,7 +46,7 @@ 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 use any uncovered types from inside the current crate
|
= note: define and implement a trait or new type instead

Expand All @@ -63,7 +63,7 @@ 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 use any uncovered types from inside the current crate
|
= note: define and implement a trait or new type instead

Expand Down
6 changes: 3 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,7 @@ 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 use any uncovered types from inside the current crate
|
= note: define and implement a trait or new type instead

Expand All @@ -16,7 +16,7 @@ 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 use any uncovered types from inside the current crate
|
= note: define and implement a trait or new type instead

Expand All @@ -27,7 +27,7 @@ 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 use any uncovered types from inside the current crate
|
= note: define and implement a trait or new type instead

Expand Down
4 changes: 2 additions & 2 deletions tests/ui/coherence/coherence-orphan.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ 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 use any uncovered types from inside the current crate
|
= note: define and implement a trait or new type instead

Expand All @@ -17,7 +17,7 @@ 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 use any uncovered types from inside the current crate
|
= note: define and implement a trait or new type instead

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/coherence/coherence-overlapping-pairs.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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 use any uncovered types from inside the current crate
|
= 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,7 @@ 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 use any uncovered types from inside the current crate
|
= note: define and implement a trait or new type instead

Expand Down
2 changes: 1 addition & 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,7 @@ 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 use any uncovered types from inside the current crate
|
= note: define and implement a trait or new type instead

Expand Down
2 changes: 1 addition & 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,7 @@ 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 use any uncovered types from inside the current crate
|
= note: define and implement a trait or new type instead

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/coherence/coherence-vec-local.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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 use any uncovered types from inside the current crate
|
= note: define and implement a trait or new type instead

Expand Down
2 changes: 1 addition & 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,7 @@ 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 use any uncovered types from inside the current crate
|
= note: define and implement a trait or new type instead

Expand Down
2 changes: 1 addition & 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,7 @@ 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 use any uncovered types from inside the current crate
|
= note: define and implement a trait or new type instead

Expand Down
2 changes: 1 addition & 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,7 @@ 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 use any uncovered types from inside the current crate
|
= note: define and implement a trait or new type instead

Expand Down
6 changes: 3 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,7 @@ 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 use any uncovered types from inside the current crate
|
= note: define and implement a trait or new type instead

Expand All @@ -18,7 +18,7 @@ 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 use any uncovered types from inside the current crate
|
= note: define and implement a trait or new type instead

Expand All @@ -30,7 +30,7 @@ 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 use any uncovered types from inside the current crate
|
= 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,7 @@ 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 use any uncovered types from inside the current crate
|
= note: define and implement a trait or new type instead

Expand All @@ -18,7 +18,7 @@ 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 use any uncovered types from inside the current crate
|
= 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,7 @@ 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 use any uncovered types from inside the current crate
|
= note: define and implement a trait or new type instead

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

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

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

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

Expand All @@ -16,7 +16,7 @@ LL | impl<T> Remote for Arc<T> {
| ^^^^^^^^^^^^^^^^^^^------
| | |
| | `Arc` is not defined in the current crate
| impl doesn't use only types from inside the current crate
| impl doesn't use any uncovered types from inside the current crate
|
= note: define and implement a trait or new type instead

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/dropck/drop-on-non-struct.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ LL | impl<'a> Drop for &'a mut isize {
| ^^^^^^^^^^^^^^^^^^-------------
| | |
| | `isize` is not defined in the current crate
| impl doesn't use only types from inside the current crate
| impl doesn't use any uncovered types from inside the current crate
|
= note: define and implement a trait or new type instead

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/error-codes/E0117.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | impl Drop for u32 {}
| ^^^^^^^^^^^^^^---
| | |
| | `u32` is not defined in the current crate
| impl doesn't use only types from inside the current crate
| impl doesn't use any uncovered types from inside the current crate
|
= note: define and implement a trait or new type instead

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/error-codes/e0119/complex-impl.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | impl<R> External for (Q, R) {}
| ^^^^^^^^^^^^^^^^^^^^^------
| | |
| | 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 use any uncovered types from inside the current crate
|
= note: define and implement a trait or new type instead

Expand Down
Loading
Loading