Skip to content

Commit 21c57f5

Browse files
authored
Rollup merge of #128391 - cafce25:issue-128390, r=lcnr
Change orphan hint from "only" to "any uncovered type inside..." Fix #128390
2 parents 06d261d + b89c620 commit 21c57f5

37 files changed

+260
-198
lines changed

compiler/rustc_hir_analysis/messages.ftl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,12 +356,14 @@ hir_analysis_only_current_traits_arbitrary = only traits defined in the current
356356
357357
hir_analysis_only_current_traits_foreign = this is not defined in the current crate because this is a foreign trait
358358
359-
hir_analysis_only_current_traits_label = impl doesn't use only types from inside the current crate
360-
361359
hir_analysis_only_current_traits_name = this is not defined in the current crate because {$name} are always foreign
362360
363361
hir_analysis_only_current_traits_note = define and implement a trait or new type instead
364362
363+
hir_analysis_only_current_traits_note_more_info = for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
364+
365+
hir_analysis_only_current_traits_note_uncovered = impl doesn't have any local type before any uncovered type parameters
366+
365367
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
366368
367369
hir_analysis_only_current_traits_outside = only traits defined in the current crate can be implemented for types defined outside of the crate

compiler/rustc_hir_analysis/src/errors.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,24 +1434,27 @@ pub(crate) enum OnlyCurrentTraits {
14341434
#[diag(hir_analysis_only_current_traits_outside, code = E0117)]
14351435
Outside {
14361436
#[primary_span]
1437-
#[label(hir_analysis_only_current_traits_label)]
14381437
span: Span,
1438+
#[note(hir_analysis_only_current_traits_note_uncovered)]
1439+
#[note(hir_analysis_only_current_traits_note_more_info)]
14391440
#[note(hir_analysis_only_current_traits_note)]
14401441
note: (),
14411442
},
14421443
#[diag(hir_analysis_only_current_traits_primitive, code = E0117)]
14431444
Primitive {
14441445
#[primary_span]
1445-
#[label(hir_analysis_only_current_traits_label)]
14461446
span: Span,
1447+
#[note(hir_analysis_only_current_traits_note_uncovered)]
1448+
#[note(hir_analysis_only_current_traits_note_more_info)]
14471449
#[note(hir_analysis_only_current_traits_note)]
14481450
note: (),
14491451
},
14501452
#[diag(hir_analysis_only_current_traits_arbitrary, code = E0117)]
14511453
Arbitrary {
14521454
#[primary_span]
1453-
#[label(hir_analysis_only_current_traits_label)]
14541455
span: Span,
1456+
#[note(hir_analysis_only_current_traits_note_uncovered)]
1457+
#[note(hir_analysis_only_current_traits_note_more_info)]
14551458
#[note(hir_analysis_only_current_traits_note)]
14561459
note: (),
14571460
},

tests/ui/coherence/coherence-cow.re_a.stderr

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ty
33
|
44
LL | impl<T> Remote for Pair<T,Cover<T>> { }
55
| ^^^^^^^^^^^^^^^^^^^----------------
6-
| | |
7-
| | `Pair` is not defined in the current crate
8-
| impl doesn't use only types from inside the current crate
6+
| |
7+
| `Pair` is not defined in the current crate
98
|
9+
= note: impl doesn't have any local type before any uncovered type parameters
10+
= note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
1011
= note: define and implement a trait or new type instead
1112

1213
error: aborting due to 1 previous error

tests/ui/coherence/coherence-cow.re_b.stderr

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ty
33
|
44
LL | impl<T> Remote for Pair<Cover<T>,T> { }
55
| ^^^^^^^^^^^^^^^^^^^----------------
6-
| | |
7-
| | `Pair` is not defined in the current crate
8-
| impl doesn't use only types from inside the current crate
6+
| |
7+
| `Pair` is not defined in the current crate
98
|
9+
= note: impl doesn't have any local type before any uncovered type parameters
10+
= note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
1011
= note: define and implement a trait or new type instead
1112

1213
error: aborting due to 1 previous error

tests/ui/coherence/coherence-cow.re_c.stderr

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ty
33
|
44
LL | impl<T,U> Remote for Pair<Cover<T>,U> { }
55
| ^^^^^^^^^^^^^^^^^^^^^----------------
6-
| | |
7-
| | `Pair` is not defined in the current crate
8-
| impl doesn't use only types from inside the current crate
6+
| |
7+
| `Pair` is not defined in the current crate
98
|
9+
= note: impl doesn't have any local type before any uncovered type parameters
10+
= note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
1011
= note: define and implement a trait or new type instead
1112

1213
error: aborting due to 1 previous error

tests/ui/coherence/coherence-fundamental-trait-objects.stderr

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar
33
|
44
LL | impl Misc for dyn Fundamental<Local> {}
55
| ^^^^^^^^^^^^^^----------------------
6-
| | |
7-
| | `dyn Fundamental<Local>` is not defined in the current crate
8-
| impl doesn't use only types from inside the current crate
6+
| |
7+
| `dyn Fundamental<Local>` is not defined in the current crate
98
|
9+
= note: impl doesn't have any local type before any uncovered type parameters
10+
= note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
1011
= note: define and implement a trait or new type instead
1112

1213
error: aborting due to 1 previous error

tests/ui/coherence/coherence-impl-trait-for-marker-trait-negative.stderr

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar
3939
|
4040
LL | impl !Send for dyn Marker2 {}
4141
| ^^^^^^^^^^^^^^^-----------
42-
| | |
43-
| | `dyn Marker2` is not defined in the current crate
44-
| impl doesn't use only types from inside the current crate
42+
| |
43+
| `dyn Marker2` is not defined in the current crate
4544
|
45+
= note: impl doesn't have any local type before any uncovered type parameters
46+
= note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
4647
= note: define and implement a trait or new type instead
4748

4849
error[E0321]: cross-crate traits with a default impl, like `Send`, can only be implemented for a struct/enum type, not `(dyn Object + 'static)`

tests/ui/coherence/coherence-impl-trait-for-marker-trait-positive.stderr

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar
3939
|
4040
LL | unsafe impl Send for dyn Marker2 {}
4141
| ^^^^^^^^^^^^^^^^^^^^^-----------
42-
| | |
43-
| | `dyn Marker2` is not defined in the current crate
44-
| impl doesn't use only types from inside the current crate
42+
| |
43+
| `dyn Marker2` is not defined in the current crate
4544
|
45+
= note: impl doesn't have any local type before any uncovered type parameters
46+
= note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
4647
= note: define and implement a trait or new type instead
4748

4849
error[E0321]: cross-crate traits with a default impl, like `Send`, can only be implemented for a struct/enum type, not `(dyn Object + 'static)`

tests/ui/coherence/coherence-impls-copy.stderr

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,23 @@ error[E0117]: only traits defined in the current crate can be implemented for ar
1313
|
1414
LL | impl Copy for &'static [NotSync] {}
1515
| ^^^^^^^^^^^^^^------------------
16-
| | |
17-
| | this is not defined in the current crate because slices are always foreign
18-
| impl doesn't use only types from inside the current crate
16+
| |
17+
| this is not defined in the current crate because slices are always foreign
1918
|
19+
= note: impl doesn't have any local type before any uncovered type parameters
20+
= note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
2021
= note: define and implement a trait or new type instead
2122

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

3335
error[E0206]: the trait `Copy` cannot be implemented for this type
@@ -41,10 +43,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar
4143
|
4244
LL | impl Copy for (MyType, MyType) {}
4345
| ^^^^^^^^^^^^^^----------------
44-
| | |
45-
| | this is not defined in the current crate because tuples are always foreign
46-
| impl doesn't use only types from inside the current crate
46+
| |
47+
| this is not defined in the current crate because tuples are always foreign
4748
|
49+
= note: impl doesn't have any local type before any uncovered type parameters
50+
= note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
4851
= note: define and implement a trait or new type instead
4952

5053
error[E0206]: the trait `Copy` cannot be implemented for this type
@@ -58,10 +61,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar
5861
|
5962
LL | impl Copy for [MyType] {}
6063
| ^^^^^^^^^^^^^^--------
61-
| | |
62-
| | this is not defined in the current crate because slices are always foreign
63-
| impl doesn't use only types from inside the current crate
64+
| |
65+
| this is not defined in the current crate because slices are always foreign
6466
|
67+
= note: impl doesn't have any local type before any uncovered type parameters
68+
= note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
6569
= note: define and implement a trait or new type instead
6670

6771
error[E0206]: the trait `Copy` cannot be implemented for this type

tests/ui/coherence/coherence-impls-send.stderr

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,23 @@ error[E0117]: only traits defined in the current crate can be implemented for ar
33
|
44
LL | unsafe impl Send for &'static [NotSync] {}
55
| ^^^^^^^^^^^^^^^^^^^^^------------------
6-
| | |
7-
| | this is not defined in the current crate because slices are always foreign
8-
| impl doesn't use only types from inside the current crate
6+
| |
7+
| this is not defined in the current crate because slices are always foreign
98
|
9+
= note: impl doesn't have any local type before any uncovered type parameters
10+
= note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
1011
= note: define and implement a trait or new type instead
1112

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

2325
error[E0321]: cross-crate traits with a default impl, like `Send`, can only be implemented for a struct/enum type, not `&'static NotSync`
@@ -31,10 +33,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar
3133
|
3234
LL | unsafe impl Send for [MyType] {}
3335
| ^^^^^^^^^^^^^^^^^^^^^--------
34-
| | |
35-
| | this is not defined in the current crate because slices are always foreign
36-
| impl doesn't use only types from inside the current crate
36+
| |
37+
| this is not defined in the current crate because slices are always foreign
3738
|
39+
= note: impl doesn't have any local type before any uncovered type parameters
40+
= note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
3841
= note: define and implement a trait or new type instead
3942

4043
error: aborting due to 4 previous errors

0 commit comments

Comments
 (0)