From adfe9a45d60198316952baa5088ae77a8a5e919a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 11 Oct 2019 12:37:48 -0700 Subject: [PATCH 1/8] Call out the types that are non local on E0117 --- src/librustc/traits/coherence.rs | 11 ++++++--- src/librustc_typeck/coherence/orphan.rs | 24 +++++++++++-------- .../ui/coherence/coherence-cow.re_a.stderr | 2 +- .../ui/coherence/coherence-cow.re_b.stderr | 2 +- .../ui/coherence/coherence-cow.re_c.stderr | 2 +- ...rence-fundamental-trait-objects.old.stderr | 2 +- ...erence-fundamental-trait-objects.re.stderr | 2 +- ...mpl-trait-for-marker-trait-negative.stderr | 2 +- ...mpl-trait-for-marker-trait-positive.stderr | 2 +- .../coherence/coherence-impls-copy.old.stderr | 8 +++---- .../coherence/coherence-impls-copy.re.stderr | 8 +++---- .../coherence/coherence-impls-send.old.stderr | 6 ++--- .../coherence/coherence-impls-send.re.stderr | 6 ++--- .../coherence-impls-sized.old.stderr | 6 ++--- .../coherence/coherence-impls-sized.re.stderr | 6 ++--- .../ui/coherence/coherence-orphan.old.stderr | 5 ++-- .../ui/coherence/coherence-orphan.re.stderr | 5 ++-- .../coherence-overlapping-pairs.re.stderr | 2 +- ...herence-pair-covered-uncovered-1.re.stderr | 3 ++- ...coherence-pair-covered-uncovered.re.stderr | 2 +- .../coherence/coherence-vec-local-2.re.stderr | 2 +- .../coherence/coherence-vec-local.old.stderr | 2 +- .../coherence/coherence-vec-local.re.stderr | 2 +- .../coherence_local_err_struct.old.stderr | 2 +- .../coherence_local_err_struct.re.stderr | 2 +- .../coherence_local_err_tuple.old.stderr | 2 +- .../coherence_local_err_tuple.re.stderr | 2 +- .../impl-foreign[foreign]-for-foreign.stderr | 3 ++- src/test/ui/dropck/drop-on-non-struct.stderr | 2 +- src/test/ui/error-codes/E0117.stderr | 2 +- src/test/ui/error-codes/E0206.stderr | 2 +- ...lt-trait-impl-cross-crate-coherence.stderr | 6 ++--- 32 files changed, 74 insertions(+), 61 deletions(-) diff --git a/src/librustc/traits/coherence.rs b/src/librustc/traits/coherence.rs index 2734fce4ea55a..da095ed5f36e4 100644 --- a/src/librustc/traits/coherence.rs +++ b/src/librustc/traits/coherence.rs @@ -237,7 +237,7 @@ pub fn trait_ref_is_local_or_fundamental<'tcx>( } pub enum OrphanCheckErr<'tcx> { - NoLocalInputType, + NonLocalInputType(Vec>), UncoveredTy(Ty<'tcx>), } @@ -390,6 +390,7 @@ fn orphan_check_trait_ref<'tcx>( } } + let mut non_local_spans = vec![]; for input_ty in trait_ref.input_types().flat_map(|ty| uncover_fundamental_ty(tcx, ty, in_crate)) { @@ -401,11 +402,13 @@ fn orphan_check_trait_ref<'tcx>( debug!("orphan_check_trait_ref: uncovered ty: `{:?}`", input_ty); return Err(OrphanCheckErr::UncoveredTy(input_ty)) } + non_local_spans.push(input_ty); } // If we exit above loop, never found a local type. debug!("orphan_check_trait_ref: no local type"); - Err(OrphanCheckErr::NoLocalInputType) + Err(OrphanCheckErr::NonLocalInputType(non_local_spans)) } else { + let mut non_local_spans = vec![]; // First, create an ordered iterator over all the type // parameters to the trait, with the self type appearing // first. Find the first input type that either references a @@ -438,10 +441,12 @@ fn orphan_check_trait_ref<'tcx>( debug!("orphan_check_trait_ref: uncovered type `{:?}`", param); return Err(OrphanCheckErr::UncoveredTy(param)); } + + non_local_spans.push(input_ty); } // If we exit above loop, never found a local type. debug!("orphan_check_trait_ref: no local type"); - Err(OrphanCheckErr::NoLocalInputType) + Err(OrphanCheckErr::NonLocalInputType(non_local_spans)) } } diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs index 667fa50a7cfa4..c19b588eb078d 100644 --- a/src/librustc_typeck/coherence/orphan.rs +++ b/src/librustc_typeck/coherence/orphan.rs @@ -33,16 +33,20 @@ impl ItemLikeVisitor<'v> for OrphanChecker<'tcx> { let sp = cm.def_span(item.span); match traits::orphan_check(self.tcx, def_id) { Ok(()) => {} - Err(traits::OrphanCheckErr::NoLocalInputType) => { - struct_span_err!(self.tcx.sess, - sp, - E0117, - "only traits defined in the current crate can be \ - implemented for arbitrary types") - .span_label(sp, "impl doesn't use types inside crate") - .note("the impl does not reference only types defined in this crate") - .note("define and implement a trait or new type instead") - .emit(); + Err(traits::OrphanCheckErr::NonLocalInputType(tys)) => { + let mut err = struct_span_err!( + self.tcx.sess, + sp, + E0117, + "only traits defined in the current crate can be implemented for \ + arbitrary types" + ); + err.span_label(sp, "impl doesn't use types inside crate"); + for ty in &tys { + err.note(&format!("`{}` is not defined in the current create", ty)); + } + err.note("define and implement a trait or new type instead"); + err.emit(); return; } Err(traits::OrphanCheckErr::UncoveredTy(param_ty)) => { diff --git a/src/test/ui/coherence/coherence-cow.re_a.stderr b/src/test/ui/coherence/coherence-cow.re_a.stderr index b0ec55a9bc578..be4fe4c8f6dd8 100644 --- a/src/test/ui/coherence/coherence-cow.re_a.stderr +++ b/src/test/ui/coherence/coherence-cow.re_a.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Remote for Pair> { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `lib::Pair>` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-cow.re_b.stderr b/src/test/ui/coherence/coherence-cow.re_b.stderr index ce2611270938d..3d248e8b589dd 100644 --- a/src/test/ui/coherence/coherence-cow.re_b.stderr +++ b/src/test/ui/coherence/coherence-cow.re_b.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Remote for Pair,T> { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `lib::Pair, T>` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-cow.re_c.stderr b/src/test/ui/coherence/coherence-cow.re_c.stderr index 1c2030d8dfea8..e07c21aa915d2 100644 --- a/src/test/ui/coherence/coherence-cow.re_c.stderr +++ b/src/test/ui/coherence/coherence-cow.re_c.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Remote for Pair,U> { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `lib::Pair, U>` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-fundamental-trait-objects.old.stderr b/src/test/ui/coherence/coherence-fundamental-trait-objects.old.stderr index 2d1247e831ec4..e96c30bb0d60e 100644 --- a/src/test/ui/coherence/coherence-fundamental-trait-objects.old.stderr +++ b/src/test/ui/coherence/coherence-fundamental-trait-objects.old.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Misc for dyn Fundamental {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `(dyn coherence_fundamental_trait_lib::Fundamental + 'static)` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-fundamental-trait-objects.re.stderr b/src/test/ui/coherence/coherence-fundamental-trait-objects.re.stderr index 2d1247e831ec4..e96c30bb0d60e 100644 --- a/src/test/ui/coherence/coherence-fundamental-trait-objects.re.stderr +++ b/src/test/ui/coherence/coherence-fundamental-trait-objects.re.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Misc for dyn Fundamental {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `(dyn coherence_fundamental_trait_lib::Fundamental + 'static)` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-impl-trait-for-marker-trait-negative.stderr b/src/test/ui/coherence/coherence-impl-trait-for-marker-trait-negative.stderr index edadb9b93d6d5..8832203dd5568 100644 --- a/src/test/ui/coherence/coherence-impl-trait-for-marker-trait-negative.stderr +++ b/src/test/ui/coherence/coherence-impl-trait-for-marker-trait-negative.stderr @@ -16,7 +16,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl !Send for dyn Marker2 {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `(dyn Marker2 + 'static)` is not defined in the current create = note: define and implement a trait or new type instead error[E0321]: cross-crate traits with a default impl, like `std::marker::Send`, can only be implemented for a struct/enum type, not `(dyn Object + 'static)` diff --git a/src/test/ui/coherence/coherence-impl-trait-for-marker-trait-positive.stderr b/src/test/ui/coherence/coherence-impl-trait-for-marker-trait-positive.stderr index 322e7a5af29f9..0fe1b933394b6 100644 --- a/src/test/ui/coherence/coherence-impl-trait-for-marker-trait-positive.stderr +++ b/src/test/ui/coherence/coherence-impl-trait-for-marker-trait-positive.stderr @@ -16,7 +16,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | unsafe impl Send for dyn Marker2 {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `(dyn Marker2 + 'static)` is not defined in the current create = note: define and implement a trait or new type instead error[E0321]: cross-crate traits with a default impl, like `std::marker::Send`, can only be implemented for a struct/enum type, not `(dyn Object + 'static)` diff --git a/src/test/ui/coherence/coherence-impls-copy.old.stderr b/src/test/ui/coherence/coherence-impls-copy.old.stderr index 5c95cc173f2b0..9556e4f8e33e8 100644 --- a/src/test/ui/coherence/coherence-impls-copy.old.stderr +++ b/src/test/ui/coherence/coherence-impls-copy.old.stderr @@ -51,7 +51,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Copy for i32 {} | ^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `i32` is not defined in the current create = 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 @@ -60,7 +60,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Copy for (MyType, MyType) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `(MyType, MyType)` is not defined in the current create = 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 @@ -69,7 +69,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Copy for [MyType] {} | ^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `[MyType]` is not defined in the current create = 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 @@ -78,7 +78,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Copy for &'static [NotSync] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `&'static [NotSync]` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to 10 previous errors diff --git a/src/test/ui/coherence/coherence-impls-copy.re.stderr b/src/test/ui/coherence/coherence-impls-copy.re.stderr index 5c95cc173f2b0..d5374aaed017a 100644 --- a/src/test/ui/coherence/coherence-impls-copy.re.stderr +++ b/src/test/ui/coherence/coherence-impls-copy.re.stderr @@ -51,7 +51,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Copy for i32 {} | ^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `i32` is not defined in the current create = 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 @@ -60,7 +60,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Copy for (MyType, MyType) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `(MyType, MyType)` is not defined in the current create = 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 @@ -69,7 +69,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Copy for [MyType] {} | ^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `[MyType]` is not defined in the current create = 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 @@ -78,7 +78,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Copy for &'static [NotSync] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `[NotSync]` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to 10 previous errors diff --git a/src/test/ui/coherence/coherence-impls-send.old.stderr b/src/test/ui/coherence/coherence-impls-send.old.stderr index b67f4d517b1b7..e30b8b11f194c 100644 --- a/src/test/ui/coherence/coherence-impls-send.old.stderr +++ b/src/test/ui/coherence/coherence-impls-send.old.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | unsafe impl Send for (MyType, MyType) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `(MyType, MyType)` is not defined in the current create = note: define and implement a trait or new type instead error[E0321]: cross-crate traits with a default impl, like `std::marker::Send`, can only be implemented for a struct/enum type, not `&'static NotSync` @@ -19,7 +19,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | unsafe impl Send for [MyType] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `[MyType]` is not defined in the current create = 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 @@ -28,7 +28,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | unsafe impl Send for &'static [NotSync] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `&'static [NotSync]` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to 4 previous errors diff --git a/src/test/ui/coherence/coherence-impls-send.re.stderr b/src/test/ui/coherence/coherence-impls-send.re.stderr index b67f4d517b1b7..b6ff4b23fd31f 100644 --- a/src/test/ui/coherence/coherence-impls-send.re.stderr +++ b/src/test/ui/coherence/coherence-impls-send.re.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | unsafe impl Send for (MyType, MyType) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `(MyType, MyType)` is not defined in the current create = note: define and implement a trait or new type instead error[E0321]: cross-crate traits with a default impl, like `std::marker::Send`, can only be implemented for a struct/enum type, not `&'static NotSync` @@ -19,7 +19,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | unsafe impl Send for [MyType] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `[MyType]` is not defined in the current create = 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 @@ -28,7 +28,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | unsafe impl Send for &'static [NotSync] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `[NotSync]` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to 4 previous errors diff --git a/src/test/ui/coherence/coherence-impls-sized.old.stderr b/src/test/ui/coherence/coherence-impls-sized.old.stderr index a19ecfdc3c5b5..a0b025b8a49e9 100644 --- a/src/test/ui/coherence/coherence-impls-sized.old.stderr +++ b/src/test/ui/coherence/coherence-impls-sized.old.stderr @@ -40,7 +40,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Sized for (MyType, MyType) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `(MyType, MyType)` is not defined in the current create = 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 @@ -49,7 +49,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Sized for [MyType] {} | ^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `[MyType]` is not defined in the current create = 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 @@ -58,7 +58,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Sized for &'static [NotSync] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `&'static [NotSync]` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to 9 previous errors diff --git a/src/test/ui/coherence/coherence-impls-sized.re.stderr b/src/test/ui/coherence/coherence-impls-sized.re.stderr index a19ecfdc3c5b5..6515b98ba4af5 100644 --- a/src/test/ui/coherence/coherence-impls-sized.re.stderr +++ b/src/test/ui/coherence/coherence-impls-sized.re.stderr @@ -40,7 +40,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Sized for (MyType, MyType) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `(MyType, MyType)` is not defined in the current create = 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 @@ -49,7 +49,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Sized for [MyType] {} | ^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `[MyType]` is not defined in the current create = 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 @@ -58,7 +58,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Sized for &'static [NotSync] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `[NotSync]` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to 9 previous errors diff --git a/src/test/ui/coherence/coherence-orphan.old.stderr b/src/test/ui/coherence/coherence-orphan.old.stderr index e6dc17d95a241..83d1bc2d4ad7f 100644 --- a/src/test/ui/coherence/coherence-orphan.old.stderr +++ b/src/test/ui/coherence/coherence-orphan.old.stderr @@ -4,7 +4,8 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl TheTrait for isize { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `isize` is not defined in the current create + = note: `usize` is not defined in the current create = 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 @@ -13,7 +14,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl !Send for Vec { } | ^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `std::vec::Vec` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to 2 previous errors diff --git a/src/test/ui/coherence/coherence-orphan.re.stderr b/src/test/ui/coherence/coherence-orphan.re.stderr index e6dc17d95a241..83d1bc2d4ad7f 100644 --- a/src/test/ui/coherence/coherence-orphan.re.stderr +++ b/src/test/ui/coherence/coherence-orphan.re.stderr @@ -4,7 +4,8 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl TheTrait for isize { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `isize` is not defined in the current create + = note: `usize` is not defined in the current create = 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 @@ -13,7 +14,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl !Send for Vec { } | ^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `std::vec::Vec` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to 2 previous errors diff --git a/src/test/ui/coherence/coherence-overlapping-pairs.re.stderr b/src/test/ui/coherence/coherence-overlapping-pairs.re.stderr index a6fa609deb214..577a9576c9df5 100644 --- a/src/test/ui/coherence/coherence-overlapping-pairs.re.stderr +++ b/src/test/ui/coherence/coherence-overlapping-pairs.re.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Remote for lib::Pair { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `lib::Pair` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-pair-covered-uncovered-1.re.stderr b/src/test/ui/coherence/coherence-pair-covered-uncovered-1.re.stderr index e45cd78363ca7..44fb85fba0807 100644 --- a/src/test/ui/coherence/coherence-pair-covered-uncovered-1.re.stderr +++ b/src/test/ui/coherence/coherence-pair-covered-uncovered-1.re.stderr @@ -4,7 +4,8 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Remote1>> for i32 { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `i32` is not defined in the current create + = note: `lib::Pair>` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-pair-covered-uncovered.re.stderr b/src/test/ui/coherence/coherence-pair-covered-uncovered.re.stderr index 54d5f3058a85c..e42470940b2f6 100644 --- a/src/test/ui/coherence/coherence-pair-covered-uncovered.re.stderr +++ b/src/test/ui/coherence/coherence-pair-covered-uncovered.re.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Remote for Pair> { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `lib::Pair>` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-vec-local-2.re.stderr b/src/test/ui/coherence/coherence-vec-local-2.re.stderr index 6992aa7a0bdc6..ef31e1f0b25a7 100644 --- a/src/test/ui/coherence/coherence-vec-local-2.re.stderr +++ b/src/test/ui/coherence/coherence-vec-local-2.re.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Remote for Vec> { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `std::vec::Vec>` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-vec-local.old.stderr b/src/test/ui/coherence/coherence-vec-local.old.stderr index b35e7a8ba8bed..cb8ac28fab0c0 100644 --- a/src/test/ui/coherence/coherence-vec-local.old.stderr +++ b/src/test/ui/coherence/coherence-vec-local.old.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Remote for Vec { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `std::vec::Vec` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-vec-local.re.stderr b/src/test/ui/coherence/coherence-vec-local.re.stderr index b35e7a8ba8bed..cb8ac28fab0c0 100644 --- a/src/test/ui/coherence/coherence-vec-local.re.stderr +++ b/src/test/ui/coherence/coherence-vec-local.re.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Remote for Vec { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `std::vec::Vec` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence_local_err_struct.old.stderr b/src/test/ui/coherence/coherence_local_err_struct.old.stderr index e1f651493f67c..818195f184160 100644 --- a/src/test/ui/coherence/coherence_local_err_struct.old.stderr +++ b/src/test/ui/coherence/coherence_local_err_struct.old.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl lib::MyCopy for lib::MyStruct { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `lib::MyStruct` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence_local_err_struct.re.stderr b/src/test/ui/coherence/coherence_local_err_struct.re.stderr index e1f651493f67c..818195f184160 100644 --- a/src/test/ui/coherence/coherence_local_err_struct.re.stderr +++ b/src/test/ui/coherence/coherence_local_err_struct.re.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl lib::MyCopy for lib::MyStruct { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `lib::MyStruct` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence_local_err_tuple.old.stderr b/src/test/ui/coherence/coherence_local_err_tuple.old.stderr index 171daa54861fe..aebca9cfacc09 100644 --- a/src/test/ui/coherence/coherence_local_err_tuple.old.stderr +++ b/src/test/ui/coherence/coherence_local_err_tuple.old.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl lib::MyCopy for (MyType,) { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `(MyType,)` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence_local_err_tuple.re.stderr b/src/test/ui/coherence/coherence_local_err_tuple.re.stderr index 171daa54861fe..aebca9cfacc09 100644 --- a/src/test/ui/coherence/coherence_local_err_tuple.re.stderr +++ b/src/test/ui/coherence/coherence_local_err_tuple.re.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl lib::MyCopy for (MyType,) { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `(MyType,)` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to previous error diff --git a/src/test/ui/coherence/impl-foreign[foreign]-for-foreign.stderr b/src/test/ui/coherence/impl-foreign[foreign]-for-foreign.stderr index 04e96f29230fb..cfd4685528924 100644 --- a/src/test/ui/coherence/impl-foreign[foreign]-for-foreign.stderr +++ b/src/test/ui/coherence/impl-foreign[foreign]-for-foreign.stderr @@ -4,7 +4,8 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Remote1 for f64 { | ^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `f64` is not defined in the current create + = note: `u32` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to previous error diff --git a/src/test/ui/dropck/drop-on-non-struct.stderr b/src/test/ui/dropck/drop-on-non-struct.stderr index 6ff16402b0e6e..334adb27fda26 100644 --- a/src/test/ui/dropck/drop-on-non-struct.stderr +++ b/src/test/ui/dropck/drop-on-non-struct.stderr @@ -10,7 +10,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl<'a> Drop for &'a mut isize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `&'a mut isize` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to 2 previous errors diff --git a/src/test/ui/error-codes/E0117.stderr b/src/test/ui/error-codes/E0117.stderr index 6c0bbc2b62801..ecd0c152f28c8 100644 --- a/src/test/ui/error-codes/E0117.stderr +++ b/src/test/ui/error-codes/E0117.stderr @@ -10,7 +10,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Drop for u32 {} | ^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `u32` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to 2 previous errors diff --git a/src/test/ui/error-codes/E0206.stderr b/src/test/ui/error-codes/E0206.stderr index cd5d74854eff8..322fdd9f11d05 100644 --- a/src/test/ui/error-codes/E0206.stderr +++ b/src/test/ui/error-codes/E0206.stderr @@ -16,7 +16,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Copy for Foo { } | ^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `[u8; _]` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to 3 previous errors diff --git a/src/test/ui/typeck/typeck-default-trait-impl-cross-crate-coherence.stderr b/src/test/ui/typeck/typeck-default-trait-impl-cross-crate-coherence.stderr index 6518684496559..42d6792d0d0e6 100644 --- a/src/test/ui/typeck/typeck-default-trait-impl-cross-crate-coherence.stderr +++ b/src/test/ui/typeck/typeck-default-trait-impl-cross-crate-coherence.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl DefaultedTrait for (A,) { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `(A,)` is not defined in the current create = 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 @@ -13,7 +13,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl !DefaultedTrait for (B,) { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `(B,)` is not defined in the current create = note: define and implement a trait or new type instead error[E0321]: cross-crate traits with a default impl, like `lib::DefaultedTrait`, can only be implemented for a struct/enum type defined in the current crate @@ -28,7 +28,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl DefaultedTrait for lib::Something { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `lib::Something` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to 4 previous errors From 9b4f811b7f646ebb7273fa3cf8f9d092a44058b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sat, 12 Oct 2019 14:31:23 -0700 Subject: [PATCH 2/8] Use more targeted spans for orphan rule errors --- src/librustc/traits/coherence.rs | 14 +++--- src/librustc_typeck/coherence/orphan.rs | 49 ++++++++++++------- .../coherence/coherence-all-remote.old.stderr | 4 +- .../coherence/coherence-all-remote.re.stderr | 4 +- .../coherence-bigint-param.old.stderr | 4 +- .../coherence-bigint-param.re.stderr | 4 +- src/test/ui/coherence/coherence-cow.a.stderr | 4 +- src/test/ui/coherence/coherence-cow.b.stderr | 4 +- src/test/ui/coherence/coherence-cow.c.stderr | 4 +- .../ui/coherence/coherence-cow.re_a.stderr | 6 ++- .../ui/coherence/coherence-cow.re_b.stderr | 6 ++- .../ui/coherence/coherence-cow.re_c.stderr | 6 ++- .../coherence-cross-crate-conflict.old.stderr | 4 +- .../coherence-cross-crate-conflict.re.stderr | 4 +- ...rence-fundamental-trait-objects.old.stderr | 6 ++- ...erence-fundamental-trait-objects.re.stderr | 6 ++- ...mpl-trait-for-marker-trait-negative.stderr | 6 ++- ...mpl-trait-for-marker-trait-positive.stderr | 6 ++- .../coherence/coherence-impls-copy.old.stderr | 24 ++++++--- .../coherence/coherence-impls-copy.re.stderr | 24 ++++++--- .../coherence/coherence-impls-send.old.stderr | 18 ++++--- .../coherence/coherence-impls-send.re.stderr | 18 ++++--- .../coherence-impls-sized.old.stderr | 18 ++++--- .../coherence/coherence-impls-sized.re.stderr | 18 ++++--- .../coherence-lone-type-parameter.old.stderr | 4 +- .../coherence-lone-type-parameter.re.stderr | 4 +- .../ui/coherence/coherence-orphan.old.stderr | 14 ++++-- .../ui/coherence/coherence-orphan.re.stderr | 14 ++++-- .../coherence-overlapping-pairs.old.stderr | 4 +- .../coherence-overlapping-pairs.re.stderr | 6 ++- ...erence-pair-covered-uncovered-1.old.stderr | 4 +- ...herence-pair-covered-uncovered-1.re.stderr | 8 +-- ...oherence-pair-covered-uncovered.old.stderr | 4 +- ...coherence-pair-covered-uncovered.re.stderr | 6 ++- .../coherence-vec-local-2.old.stderr | 4 +- .../coherence/coherence-vec-local-2.re.stderr | 6 ++- .../coherence/coherence-vec-local.old.stderr | 6 ++- .../coherence/coherence-vec-local.re.stderr | 6 ++- .../coherence_local_err_struct.old.stderr | 6 ++- .../coherence_local_err_struct.re.stderr | 6 ++- .../coherence_local_err_tuple.old.stderr | 6 ++- .../coherence_local_err_tuple.re.stderr | 6 ++- .../impl-foreign[foreign]-for-foreign.stderr | 8 +-- ...foreign[foreign]-for-fundamental[t].stderr | 8 +-- .../impl[t]-foreign[foreign]-for-t.stderr | 4 +- ...foreign[fundamental[t]]-for-foreign.stderr | 8 +-- ...[fundamental[t]]-for-fundamental[t].stderr | 8 +-- ...pl[t]-foreign[fundamental[t]]-for-t.stderr | 8 +-- ...n[fundamental[t]_local]-for-foreign.stderr | 8 +-- ...]-foreign[local]-for-fundamental[t].stderr | 8 +-- .../impl[t]-foreign[local]-for-t.stderr | 4 +- .../impl[t]-foreign[t]-for-foreign.stderr | 4 +- .../impl[t]-foreign[t]-for-fundamental.stderr | 8 +-- .../coherence/impl[t]-foreign[t]-for-t.stderr | 4 +- src/test/ui/dropck/drop-on-non-struct.stderr | 6 ++- src/test/ui/error-codes/E0117.stderr | 6 ++- src/test/ui/error-codes/E0206.stderr | 6 ++- .../ui/error-codes/e0119/complex-impl.stderr | 4 +- .../ui/error-codes/e0119/issue-28981.stderr | 4 +- ...feature-gate-re-rebalance-coherence.stderr | 4 +- src/test/ui/issues/issue-41974.stderr | 4 +- src/test/ui/orphan-check-diagnostics.stderr | 4 +- ...lt-trait-impl-cross-crate-coherence.stderr | 18 ++++--- 63 files changed, 312 insertions(+), 199 deletions(-) diff --git a/src/librustc/traits/coherence.rs b/src/librustc/traits/coherence.rs index da095ed5f36e4..71a39b21f779c 100644 --- a/src/librustc/traits/coherence.rs +++ b/src/librustc/traits/coherence.rs @@ -237,7 +237,7 @@ pub fn trait_ref_is_local_or_fundamental<'tcx>( } pub enum OrphanCheckErr<'tcx> { - NonLocalInputType(Vec>), + NonLocalInputType(Vec<(Ty<'tcx>, usize)>), UncoveredTy(Ty<'tcx>), } @@ -391,8 +391,10 @@ fn orphan_check_trait_ref<'tcx>( } let mut non_local_spans = vec![]; - for input_ty in - trait_ref.input_types().flat_map(|ty| uncover_fundamental_ty(tcx, ty, in_crate)) + for (i, input_ty) in trait_ref + .input_types() + .flat_map(|ty| uncover_fundamental_ty(tcx, ty, in_crate)) + .enumerate() { debug!("orphan_check_trait_ref: check ty `{:?}`", input_ty); if ty_is_local(tcx, input_ty, in_crate) { @@ -402,7 +404,7 @@ fn orphan_check_trait_ref<'tcx>( debug!("orphan_check_trait_ref: uncovered ty: `{:?}`", input_ty); return Err(OrphanCheckErr::UncoveredTy(input_ty)) } - non_local_spans.push(input_ty); + non_local_spans.push((input_ty, i)); } // If we exit above loop, never found a local type. debug!("orphan_check_trait_ref: no local type"); @@ -413,7 +415,7 @@ fn orphan_check_trait_ref<'tcx>( // parameters to the trait, with the self type appearing // first. Find the first input type that either references a // type parameter OR some local type. - for input_ty in trait_ref.input_types() { + for (i, input_ty) in trait_ref.input_types().enumerate() { if ty_is_local(tcx, input_ty, in_crate) { debug!("orphan_check_trait_ref: ty_is_local `{:?}`", input_ty); @@ -442,7 +444,7 @@ fn orphan_check_trait_ref<'tcx>( return Err(OrphanCheckErr::UncoveredTy(param)); } - non_local_spans.push(input_ty); + non_local_spans.push((input_ty, i)); } // If we exit above loop, never found a local type. debug!("orphan_check_trait_ref: no local type"); diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs index c19b588eb078d..3bcea6d173aa5 100644 --- a/src/librustc_typeck/coherence/orphan.rs +++ b/src/librustc_typeck/coherence/orphan.rs @@ -24,7 +24,7 @@ impl ItemLikeVisitor<'v> for OrphanChecker<'tcx> { fn visit_item(&mut self, item: &hir::Item) { let def_id = self.tcx.hir().local_def_id(item.hir_id); // "Trait" impl - if let hir::ItemKind::Impl(.., Some(_), _, _) = item.kind { + if let hir::ItemKind::Impl(.., generics, Some(_), impl_ty, _) = &item.kind { debug!("coherence2::orphan check: trait impl {}", self.tcx.hir().node_to_string(item.hir_id)); let trait_ref = self.tcx.impl_trait_ref(def_id).unwrap(); @@ -41,28 +41,43 @@ impl ItemLikeVisitor<'v> for OrphanChecker<'tcx> { "only traits defined in the current crate can be implemented for \ arbitrary types" ); - err.span_label(sp, "impl doesn't use types inside crate"); - for ty in &tys { - err.note(&format!("`{}` is not defined in the current create", ty)); + err.span_label(sp, "impl doesn't use only types from inside the current crate"); + for (ty, i) in &tys { + let msg = format!("`{}` is not defined in the current crate", ty); + if *i == 0 { + err.span_label(impl_ty.span, &msg); + } else { + err.note(&msg); + } } err.note("define and implement a trait or new type instead"); err.emit(); return; } Err(traits::OrphanCheckErr::UncoveredTy(param_ty)) => { - struct_span_err!(self.tcx.sess, - sp, - E0210, - "type parameter `{}` must be used as the type parameter \ - for some local type (e.g., `MyStruct<{}>`)", - param_ty, - param_ty) - .span_label(sp, - format!("type parameter `{}` must be used as the type \ - parameter for some local type", param_ty)) - .note("only traits defined in the current crate can be implemented \ - for a type parameter") - .emit(); + let mut sp = sp; + for param in &generics.params { + if param.name.ident().to_string() == param_ty.to_string() { + sp = param.span; + } + } + let mut err = struct_span_err!( + self.tcx.sess, + sp, + E0210, + "type parameter `{}` must be used as the type parameter for some local \ + type (e.g., `MyStruct<{}>`)", + param_ty, + param_ty + ); + err.span_label(sp, format!( + "type parameter `{}` must be used as the type parameter for some local \ + type", + param_ty, + )); + err.note("only traits defined in the current crate can be implemented for a \ + type parameter"); + err.emit(); return; } } diff --git a/src/test/ui/coherence/coherence-all-remote.old.stderr b/src/test/ui/coherence/coherence-all-remote.old.stderr index 0389a6228efcd..0541db2b8505f 100644 --- a/src/test/ui/coherence/coherence-all-remote.old.stderr +++ b/src/test/ui/coherence/coherence-all-remote.old.stderr @@ -1,8 +1,8 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-all-remote.rs:9:1 + --> $DIR/coherence-all-remote.rs:9:6 | LL | impl Remote1 for isize { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | ^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/coherence/coherence-all-remote.re.stderr b/src/test/ui/coherence/coherence-all-remote.re.stderr index 0389a6228efcd..0541db2b8505f 100644 --- a/src/test/ui/coherence/coherence-all-remote.re.stderr +++ b/src/test/ui/coherence/coherence-all-remote.re.stderr @@ -1,8 +1,8 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-all-remote.rs:9:1 + --> $DIR/coherence-all-remote.rs:9:6 | LL | impl Remote1 for isize { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | ^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/coherence/coherence-bigint-param.old.stderr b/src/test/ui/coherence/coherence-bigint-param.old.stderr index 54fec07e65a0d..816ad949a2bce 100644 --- a/src/test/ui/coherence/coherence-bigint-param.old.stderr +++ b/src/test/ui/coherence/coherence-bigint-param.old.stderr @@ -1,8 +1,8 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-bigint-param.rs:11:1 + --> $DIR/coherence-bigint-param.rs:11:6 | LL | impl Remote1 for T { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | ^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/coherence/coherence-bigint-param.re.stderr b/src/test/ui/coherence/coherence-bigint-param.re.stderr index 54fec07e65a0d..816ad949a2bce 100644 --- a/src/test/ui/coherence/coherence-bigint-param.re.stderr +++ b/src/test/ui/coherence/coherence-bigint-param.re.stderr @@ -1,8 +1,8 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-bigint-param.rs:11:1 + --> $DIR/coherence-bigint-param.rs:11:6 | LL | impl Remote1 for T { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | ^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/coherence/coherence-cow.a.stderr b/src/test/ui/coherence/coherence-cow.a.stderr index dd9cfab503f72..d3f8ba63f07eb 100644 --- a/src/test/ui/coherence/coherence-cow.a.stderr +++ b/src/test/ui/coherence/coherence-cow.a.stderr @@ -1,8 +1,8 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-cow.rs:18:1 + --> $DIR/coherence-cow.rs:18:6 | LL | impl Remote for Pair> { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | ^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/coherence/coherence-cow.b.stderr b/src/test/ui/coherence/coherence-cow.b.stderr index fb3ca3fc6b777..d8db025cbcf27 100644 --- a/src/test/ui/coherence/coherence-cow.b.stderr +++ b/src/test/ui/coherence/coherence-cow.b.stderr @@ -1,8 +1,8 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-cow.rs:23:1 + --> $DIR/coherence-cow.rs:23:6 | LL | impl Remote for Pair,T> { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | ^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/coherence/coherence-cow.c.stderr b/src/test/ui/coherence/coherence-cow.c.stderr index f17823b7f8954..ff46d7ea28032 100644 --- a/src/test/ui/coherence/coherence-cow.c.stderr +++ b/src/test/ui/coherence/coherence-cow.c.stderr @@ -1,8 +1,8 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-cow.rs:28:1 + --> $DIR/coherence-cow.rs:28:6 | LL | impl Remote for Pair,U> { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | ^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/coherence/coherence-cow.re_a.stderr b/src/test/ui/coherence/coherence-cow.re_a.stderr index be4fe4c8f6dd8..69d391378c195 100644 --- a/src/test/ui/coherence/coherence-cow.re_a.stderr +++ b/src/test/ui/coherence/coherence-cow.re_a.stderr @@ -2,9 +2,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/coherence-cow.rs:18:1 | LL | impl Remote for Pair> { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^---------------- + | | | + | | `lib::Pair>` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `lib::Pair>` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-cow.re_b.stderr b/src/test/ui/coherence/coherence-cow.re_b.stderr index 3d248e8b589dd..9be92ef3e0eb3 100644 --- a/src/test/ui/coherence/coherence-cow.re_b.stderr +++ b/src/test/ui/coherence/coherence-cow.re_b.stderr @@ -2,9 +2,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/coherence-cow.rs:23:1 | LL | impl Remote for Pair,T> { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^---------------- + | | | + | | `lib::Pair, T>` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `lib::Pair, T>` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-cow.re_c.stderr b/src/test/ui/coherence/coherence-cow.re_c.stderr index e07c21aa915d2..5e942978d5a33 100644 --- a/src/test/ui/coherence/coherence-cow.re_c.stderr +++ b/src/test/ui/coherence/coherence-cow.re_c.stderr @@ -2,9 +2,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/coherence-cow.rs:28:1 | LL | impl Remote for Pair,U> { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^^^---------------- + | | | + | | `lib::Pair, U>` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `lib::Pair, U>` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-cross-crate-conflict.old.stderr b/src/test/ui/coherence/coherence-cross-crate-conflict.old.stderr index 93be25702810f..971abe29639ff 100644 --- a/src/test/ui/coherence/coherence-cross-crate-conflict.old.stderr +++ b/src/test/ui/coherence/coherence-cross-crate-conflict.old.stderr @@ -8,10 +8,10 @@ LL | impl Foo for A { - impl trait_impl_conflict::Foo for isize; error[E0210]: type parameter `A` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-cross-crate-conflict.rs:12:1 + --> $DIR/coherence-cross-crate-conflict.rs:12:6 | LL | impl Foo for A { - | ^^^^^^^^^^^^^^^^^ type parameter `A` must be used as the type parameter for some local type + | ^ type parameter `A` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/coherence/coherence-cross-crate-conflict.re.stderr b/src/test/ui/coherence/coherence-cross-crate-conflict.re.stderr index 93be25702810f..971abe29639ff 100644 --- a/src/test/ui/coherence/coherence-cross-crate-conflict.re.stderr +++ b/src/test/ui/coherence/coherence-cross-crate-conflict.re.stderr @@ -8,10 +8,10 @@ LL | impl Foo for A { - impl trait_impl_conflict::Foo for isize; error[E0210]: type parameter `A` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-cross-crate-conflict.rs:12:1 + --> $DIR/coherence-cross-crate-conflict.rs:12:6 | LL | impl Foo for A { - | ^^^^^^^^^^^^^^^^^ type parameter `A` must be used as the type parameter for some local type + | ^ type parameter `A` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/coherence/coherence-fundamental-trait-objects.old.stderr b/src/test/ui/coherence/coherence-fundamental-trait-objects.old.stderr index e96c30bb0d60e..2efa2702a2452 100644 --- a/src/test/ui/coherence/coherence-fundamental-trait-objects.old.stderr +++ b/src/test/ui/coherence/coherence-fundamental-trait-objects.old.stderr @@ -2,9 +2,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/coherence-fundamental-trait-objects.rs:15:1 | LL | impl Misc for dyn Fundamental {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^---------------------- + | | | + | | `(dyn coherence_fundamental_trait_lib::Fundamental + 'static)` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `(dyn coherence_fundamental_trait_lib::Fundamental + 'static)` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-fundamental-trait-objects.re.stderr b/src/test/ui/coherence/coherence-fundamental-trait-objects.re.stderr index e96c30bb0d60e..2efa2702a2452 100644 --- a/src/test/ui/coherence/coherence-fundamental-trait-objects.re.stderr +++ b/src/test/ui/coherence/coherence-fundamental-trait-objects.re.stderr @@ -2,9 +2,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/coherence-fundamental-trait-objects.rs:15:1 | LL | impl Misc for dyn Fundamental {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^---------------------- + | | | + | | `(dyn coherence_fundamental_trait_lib::Fundamental + 'static)` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `(dyn coherence_fundamental_trait_lib::Fundamental + 'static)` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-impl-trait-for-marker-trait-negative.stderr b/src/test/ui/coherence/coherence-impl-trait-for-marker-trait-negative.stderr index 8832203dd5568..5a157434fb48e 100644 --- a/src/test/ui/coherence/coherence-impl-trait-for-marker-trait-negative.stderr +++ b/src/test/ui/coherence/coherence-impl-trait-for-marker-trait-negative.stderr @@ -14,9 +14,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/coherence-impl-trait-for-marker-trait-negative.rs:22:1 | LL | impl !Send for dyn Marker2 {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^----------- + | | | + | | `(dyn Marker2 + 'static)` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `(dyn Marker2 + 'static)` is not defined in the current create = note: define and implement a trait or new type instead error[E0321]: cross-crate traits with a default impl, like `std::marker::Send`, can only be implemented for a struct/enum type, not `(dyn Object + 'static)` diff --git a/src/test/ui/coherence/coherence-impl-trait-for-marker-trait-positive.stderr b/src/test/ui/coherence/coherence-impl-trait-for-marker-trait-positive.stderr index 0fe1b933394b6..9ba125d58dfc5 100644 --- a/src/test/ui/coherence/coherence-impl-trait-for-marker-trait-positive.stderr +++ b/src/test/ui/coherence/coherence-impl-trait-for-marker-trait-positive.stderr @@ -14,9 +14,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/coherence-impl-trait-for-marker-trait-positive.rs:22:1 | LL | unsafe impl Send for dyn Marker2 {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^^^----------- + | | | + | | `(dyn Marker2 + 'static)` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `(dyn Marker2 + 'static)` is not defined in the current create = note: define and implement a trait or new type instead error[E0321]: cross-crate traits with a default impl, like `std::marker::Send`, can only be implemented for a struct/enum type, not `(dyn Object + 'static)` diff --git a/src/test/ui/coherence/coherence-impls-copy.old.stderr b/src/test/ui/coherence/coherence-impls-copy.old.stderr index 9556e4f8e33e8..4da32a9accd22 100644 --- a/src/test/ui/coherence/coherence-impls-copy.old.stderr +++ b/src/test/ui/coherence/coherence-impls-copy.old.stderr @@ -49,36 +49,44 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/coherence-impls-copy.rs:8:1 | LL | impl Copy for i32 {} - | ^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^--- + | | | + | | `i32` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `i32` is not defined in the current create = 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-copy.rs:32:1 | LL | impl Copy for (MyType, MyType) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^---------------- + | | | + | | `(MyType, MyType)` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `(MyType, MyType)` is not defined in the current create = 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-copy.rs:40:1 | LL | impl Copy for [MyType] {} - | ^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^-------- + | | | + | | `[MyType]` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `[MyType]` is not defined in the current create = 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-copy.rs:45:1 | LL | impl Copy for &'static [NotSync] {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^------------------ + | | | + | | `&'static [NotSync]` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `&'static [NotSync]` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to 10 previous errors diff --git a/src/test/ui/coherence/coherence-impls-copy.re.stderr b/src/test/ui/coherence/coherence-impls-copy.re.stderr index d5374aaed017a..09aa831319058 100644 --- a/src/test/ui/coherence/coherence-impls-copy.re.stderr +++ b/src/test/ui/coherence/coherence-impls-copy.re.stderr @@ -49,36 +49,44 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/coherence-impls-copy.rs:8:1 | LL | impl Copy for i32 {} - | ^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^--- + | | | + | | `i32` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `i32` is not defined in the current create = 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-copy.rs:32:1 | LL | impl Copy for (MyType, MyType) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^---------------- + | | | + | | `(MyType, MyType)` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `(MyType, MyType)` is not defined in the current create = 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-copy.rs:40:1 | LL | impl Copy for [MyType] {} - | ^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^-------- + | | | + | | `[MyType]` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `[MyType]` is not defined in the current create = 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-copy.rs:45:1 | LL | impl Copy for &'static [NotSync] {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^------------------ + | | | + | | `[NotSync]` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `[NotSync]` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to 10 previous errors diff --git a/src/test/ui/coherence/coherence-impls-send.old.stderr b/src/test/ui/coherence/coherence-impls-send.old.stderr index e30b8b11f194c..0b49a6bf6dee7 100644 --- a/src/test/ui/coherence/coherence-impls-send.old.stderr +++ b/src/test/ui/coherence/coherence-impls-send.old.stderr @@ -2,9 +2,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/coherence-impls-send.rs:20:1 | LL | unsafe impl Send for (MyType, MyType) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^^^---------------- + | | | + | | `(MyType, MyType)` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `(MyType, MyType)` is not defined in the current create = note: define and implement a trait or new type instead error[E0321]: cross-crate traits with a default impl, like `std::marker::Send`, can only be implemented for a struct/enum type, not `&'static NotSync` @@ -17,18 +19,22 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/coherence-impls-send.rs:28:1 | LL | unsafe impl Send for [MyType] {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^^^-------- + | | | + | | `[MyType]` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `[MyType]` is not defined in the current create = 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:32:1 | LL | unsafe impl Send for &'static [NotSync] {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^^^------------------ + | | | + | | `&'static [NotSync]` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `&'static [NotSync]` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to 4 previous errors diff --git a/src/test/ui/coherence/coherence-impls-send.re.stderr b/src/test/ui/coherence/coherence-impls-send.re.stderr index b6ff4b23fd31f..60d439a32354c 100644 --- a/src/test/ui/coherence/coherence-impls-send.re.stderr +++ b/src/test/ui/coherence/coherence-impls-send.re.stderr @@ -2,9 +2,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/coherence-impls-send.rs:20:1 | LL | unsafe impl Send for (MyType, MyType) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^^^---------------- + | | | + | | `(MyType, MyType)` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `(MyType, MyType)` is not defined in the current create = note: define and implement a trait or new type instead error[E0321]: cross-crate traits with a default impl, like `std::marker::Send`, can only be implemented for a struct/enum type, not `&'static NotSync` @@ -17,18 +19,22 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/coherence-impls-send.rs:28:1 | LL | unsafe impl Send for [MyType] {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^^^-------- + | | | + | | `[MyType]` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `[MyType]` is not defined in the current create = 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:32:1 | LL | unsafe impl Send for &'static [NotSync] {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^^^------------------ + | | | + | | `[NotSync]` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `[NotSync]` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to 4 previous errors diff --git a/src/test/ui/coherence/coherence-impls-sized.old.stderr b/src/test/ui/coherence/coherence-impls-sized.old.stderr index a0b025b8a49e9..9da3c26931f4d 100644 --- a/src/test/ui/coherence/coherence-impls-sized.old.stderr +++ b/src/test/ui/coherence/coherence-impls-sized.old.stderr @@ -38,27 +38,33 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/coherence-impls-sized.rs:27:1 | LL | impl Sized for (MyType, MyType) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^---------------- + | | | + | | `(MyType, MyType)` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `(MyType, MyType)` is not defined in the current create = 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-sized.rs:39:1 | LL | impl Sized for [MyType] {} - | ^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^-------- + | | | + | | `[MyType]` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `[MyType]` is not defined in the current create = 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-sized.rs:46:1 | LL | impl Sized for &'static [NotSync] {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^------------------ + | | | + | | `&'static [NotSync]` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `&'static [NotSync]` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to 9 previous errors diff --git a/src/test/ui/coherence/coherence-impls-sized.re.stderr b/src/test/ui/coherence/coherence-impls-sized.re.stderr index 6515b98ba4af5..4f5f31b80861e 100644 --- a/src/test/ui/coherence/coherence-impls-sized.re.stderr +++ b/src/test/ui/coherence/coherence-impls-sized.re.stderr @@ -38,27 +38,33 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/coherence-impls-sized.rs:27:1 | LL | impl Sized for (MyType, MyType) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^---------------- + | | | + | | `(MyType, MyType)` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `(MyType, MyType)` is not defined in the current create = 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-sized.rs:39:1 | LL | impl Sized for [MyType] {} - | ^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^-------- + | | | + | | `[MyType]` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `[MyType]` is not defined in the current create = 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-sized.rs:46:1 | LL | impl Sized for &'static [NotSync] {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^------------------ + | | | + | | `[NotSync]` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `[NotSync]` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to 9 previous errors diff --git a/src/test/ui/coherence/coherence-lone-type-parameter.old.stderr b/src/test/ui/coherence/coherence-lone-type-parameter.old.stderr index ac77241e9e791..731752045cd34 100644 --- a/src/test/ui/coherence/coherence-lone-type-parameter.old.stderr +++ b/src/test/ui/coherence/coherence-lone-type-parameter.old.stderr @@ -1,8 +1,8 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-lone-type-parameter.rs:9:1 + --> $DIR/coherence-lone-type-parameter.rs:9:6 | LL | impl Remote for T { } - | ^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | ^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/coherence/coherence-lone-type-parameter.re.stderr b/src/test/ui/coherence/coherence-lone-type-parameter.re.stderr index ac77241e9e791..731752045cd34 100644 --- a/src/test/ui/coherence/coherence-lone-type-parameter.re.stderr +++ b/src/test/ui/coherence/coherence-lone-type-parameter.re.stderr @@ -1,8 +1,8 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-lone-type-parameter.rs:9:1 + --> $DIR/coherence-lone-type-parameter.rs:9:6 | LL | impl Remote for T { } - | ^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | ^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/coherence/coherence-orphan.old.stderr b/src/test/ui/coherence/coherence-orphan.old.stderr index 83d1bc2d4ad7f..3594224abac44 100644 --- a/src/test/ui/coherence/coherence-orphan.old.stderr +++ b/src/test/ui/coherence/coherence-orphan.old.stderr @@ -2,19 +2,23 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/coherence-orphan.rs:13:1 | LL | impl TheTrait for isize { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^^^^^^^----- + | | | + | | `isize` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `isize` is not defined in the current create - = note: `usize` is not defined in the current create + = note: `usize` is not defined in the current crate = 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-orphan.rs:21:1 | LL | impl !Send for Vec { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^---------- + | | | + | | `std::vec::Vec` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `std::vec::Vec` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to 2 previous errors diff --git a/src/test/ui/coherence/coherence-orphan.re.stderr b/src/test/ui/coherence/coherence-orphan.re.stderr index 83d1bc2d4ad7f..3594224abac44 100644 --- a/src/test/ui/coherence/coherence-orphan.re.stderr +++ b/src/test/ui/coherence/coherence-orphan.re.stderr @@ -2,19 +2,23 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/coherence-orphan.rs:13:1 | LL | impl TheTrait for isize { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^^^^^^^----- + | | | + | | `isize` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `isize` is not defined in the current create - = note: `usize` is not defined in the current create + = note: `usize` is not defined in the current crate = 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-orphan.rs:21:1 | LL | impl !Send for Vec { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^---------- + | | | + | | `std::vec::Vec` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `std::vec::Vec` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to 2 previous errors diff --git a/src/test/ui/coherence/coherence-overlapping-pairs.old.stderr b/src/test/ui/coherence/coherence-overlapping-pairs.old.stderr index b275af9668d16..7c62716f7058c 100644 --- a/src/test/ui/coherence/coherence-overlapping-pairs.old.stderr +++ b/src/test/ui/coherence/coherence-overlapping-pairs.old.stderr @@ -1,8 +1,8 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-overlapping-pairs.rs:11:1 + --> $DIR/coherence-overlapping-pairs.rs:11:6 | LL | impl Remote for lib::Pair { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | ^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/coherence/coherence-overlapping-pairs.re.stderr b/src/test/ui/coherence/coherence-overlapping-pairs.re.stderr index 577a9576c9df5..3b40137064f10 100644 --- a/src/test/ui/coherence/coherence-overlapping-pairs.re.stderr +++ b/src/test/ui/coherence/coherence-overlapping-pairs.re.stderr @@ -2,9 +2,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/coherence-overlapping-pairs.rs:11:1 | LL | impl Remote for lib::Pair { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^---------------- + | | | + | | `lib::Pair` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `lib::Pair` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-pair-covered-uncovered-1.old.stderr b/src/test/ui/coherence/coherence-pair-covered-uncovered-1.old.stderr index 8b25bee6e2f82..9f55df4c974b8 100644 --- a/src/test/ui/coherence/coherence-pair-covered-uncovered-1.old.stderr +++ b/src/test/ui/coherence/coherence-pair-covered-uncovered-1.old.stderr @@ -1,8 +1,8 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-pair-covered-uncovered-1.rs:15:1 + --> $DIR/coherence-pair-covered-uncovered-1.rs:15:6 | LL | impl Remote1>> for i32 { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | ^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/coherence/coherence-pair-covered-uncovered-1.re.stderr b/src/test/ui/coherence/coherence-pair-covered-uncovered-1.re.stderr index 44fb85fba0807..3af9d93833d2e 100644 --- a/src/test/ui/coherence/coherence-pair-covered-uncovered-1.re.stderr +++ b/src/test/ui/coherence/coherence-pair-covered-uncovered-1.re.stderr @@ -2,10 +2,12 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/coherence-pair-covered-uncovered-1.rs:15:1 | LL | impl Remote1>> for i32 { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- + | | | + | | `i32` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `i32` is not defined in the current create - = note: `lib::Pair>` is not defined in the current create + = note: `lib::Pair>` is not defined in the current crate = note: define and implement a trait or new type instead error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-pair-covered-uncovered.old.stderr b/src/test/ui/coherence/coherence-pair-covered-uncovered.old.stderr index 39558d8dcc037..4084061eb4ac5 100644 --- a/src/test/ui/coherence/coherence-pair-covered-uncovered.old.stderr +++ b/src/test/ui/coherence/coherence-pair-covered-uncovered.old.stderr @@ -1,8 +1,8 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-pair-covered-uncovered.rs:11:1 + --> $DIR/coherence-pair-covered-uncovered.rs:11:6 | LL | impl Remote for Pair> { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | ^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/coherence/coherence-pair-covered-uncovered.re.stderr b/src/test/ui/coherence/coherence-pair-covered-uncovered.re.stderr index e42470940b2f6..44c829669515f 100644 --- a/src/test/ui/coherence/coherence-pair-covered-uncovered.re.stderr +++ b/src/test/ui/coherence/coherence-pair-covered-uncovered.re.stderr @@ -2,9 +2,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/coherence-pair-covered-uncovered.rs:11:1 | LL | impl Remote for Pair> { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^^^---------------- + | | | + | | `lib::Pair>` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `lib::Pair>` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-vec-local-2.old.stderr b/src/test/ui/coherence/coherence-vec-local-2.old.stderr index 1c1118a58c6f0..fbcf8fb762a01 100644 --- a/src/test/ui/coherence/coherence-vec-local-2.old.stderr +++ b/src/test/ui/coherence/coherence-vec-local-2.old.stderr @@ -1,8 +1,8 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-vec-local-2.rs:14:1 + --> $DIR/coherence-vec-local-2.rs:14:6 | LL | impl Remote for Vec> { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | ^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/coherence/coherence-vec-local-2.re.stderr b/src/test/ui/coherence/coherence-vec-local-2.re.stderr index ef31e1f0b25a7..640eb11ee636a 100644 --- a/src/test/ui/coherence/coherence-vec-local-2.re.stderr +++ b/src/test/ui/coherence/coherence-vec-local-2.re.stderr @@ -2,9 +2,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/coherence-vec-local-2.rs:14:1 | LL | impl Remote for Vec> { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^------------- + | | | + | | `std::vec::Vec>` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `std::vec::Vec>` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-vec-local.old.stderr b/src/test/ui/coherence/coherence-vec-local.old.stderr index cb8ac28fab0c0..d441f9b25fa88 100644 --- a/src/test/ui/coherence/coherence-vec-local.old.stderr +++ b/src/test/ui/coherence/coherence-vec-local.old.stderr @@ -2,9 +2,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/coherence-vec-local.rs:14:1 | LL | impl Remote for Vec { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^---------- + | | | + | | `std::vec::Vec` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `std::vec::Vec` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-vec-local.re.stderr b/src/test/ui/coherence/coherence-vec-local.re.stderr index cb8ac28fab0c0..d441f9b25fa88 100644 --- a/src/test/ui/coherence/coherence-vec-local.re.stderr +++ b/src/test/ui/coherence/coherence-vec-local.re.stderr @@ -2,9 +2,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/coherence-vec-local.rs:14:1 | LL | impl Remote for Vec { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^---------- + | | | + | | `std::vec::Vec` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `std::vec::Vec` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence_local_err_struct.old.stderr b/src/test/ui/coherence/coherence_local_err_struct.old.stderr index 818195f184160..2d94edcd95d7b 100644 --- a/src/test/ui/coherence/coherence_local_err_struct.old.stderr +++ b/src/test/ui/coherence/coherence_local_err_struct.old.stderr @@ -2,9 +2,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/coherence_local_err_struct.rs:17:1 | LL | impl lib::MyCopy for lib::MyStruct { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^^^--------------------- + | | | + | | `lib::MyStruct` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `lib::MyStruct` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence_local_err_struct.re.stderr b/src/test/ui/coherence/coherence_local_err_struct.re.stderr index 818195f184160..2d94edcd95d7b 100644 --- a/src/test/ui/coherence/coherence_local_err_struct.re.stderr +++ b/src/test/ui/coherence/coherence_local_err_struct.re.stderr @@ -2,9 +2,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/coherence_local_err_struct.rs:17:1 | LL | impl lib::MyCopy for lib::MyStruct { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^^^--------------------- + | | | + | | `lib::MyStruct` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `lib::MyStruct` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence_local_err_tuple.old.stderr b/src/test/ui/coherence/coherence_local_err_tuple.old.stderr index aebca9cfacc09..7c3c26f5b9204 100644 --- a/src/test/ui/coherence/coherence_local_err_tuple.old.stderr +++ b/src/test/ui/coherence/coherence_local_err_tuple.old.stderr @@ -2,9 +2,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/coherence_local_err_tuple.rs:17:1 | LL | impl lib::MyCopy for (MyType,) { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^^^--------- + | | | + | | `(MyType,)` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `(MyType,)` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence_local_err_tuple.re.stderr b/src/test/ui/coherence/coherence_local_err_tuple.re.stderr index aebca9cfacc09..7c3c26f5b9204 100644 --- a/src/test/ui/coherence/coherence_local_err_tuple.re.stderr +++ b/src/test/ui/coherence/coherence_local_err_tuple.re.stderr @@ -2,9 +2,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/coherence_local_err_tuple.rs:17:1 | LL | impl lib::MyCopy for (MyType,) { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^^^--------- + | | | + | | `(MyType,)` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `(MyType,)` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to previous error diff --git a/src/test/ui/coherence/impl-foreign[foreign]-for-foreign.stderr b/src/test/ui/coherence/impl-foreign[foreign]-for-foreign.stderr index cfd4685528924..0a36f7cf3c692 100644 --- a/src/test/ui/coherence/impl-foreign[foreign]-for-foreign.stderr +++ b/src/test/ui/coherence/impl-foreign[foreign]-for-foreign.stderr @@ -2,10 +2,12 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/impl-foreign[foreign]-for-foreign.rs:12:1 | LL | impl Remote1 for f64 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^^^^--- + | | | + | | `f64` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `f64` is not defined in the current create - = note: `u32` is not defined in the current create + = note: `u32` is not defined in the current crate = note: define and implement a trait or new type instead error: aborting due to previous error diff --git a/src/test/ui/coherence/impl[t]-foreign[foreign]-for-fundamental[t].stderr b/src/test/ui/coherence/impl[t]-foreign[foreign]-for-fundamental[t].stderr index 2467097b1a8b3..cbead462e6790 100644 --- a/src/test/ui/coherence/impl[t]-foreign[foreign]-for-fundamental[t].stderr +++ b/src/test/ui/coherence/impl[t]-foreign[foreign]-for-fundamental[t].stderr @@ -1,16 +1,16 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/impl[t]-foreign[foreign]-for-fundamental[t].rs:12:1 + --> $DIR/impl[t]-foreign[foreign]-for-fundamental[t].rs:12:6 | LL | impl Remote1 for Box { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | ^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/impl[t]-foreign[foreign]-for-fundamental[t].rs:16:1 + --> $DIR/impl[t]-foreign[foreign]-for-fundamental[t].rs:16:10 | LL | impl<'a, T> Remote1 for &'a T { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | ^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/coherence/impl[t]-foreign[foreign]-for-t.stderr b/src/test/ui/coherence/impl[t]-foreign[foreign]-for-t.stderr index 5c28406f113fc..3d9afdf6cf605 100644 --- a/src/test/ui/coherence/impl[t]-foreign[foreign]-for-t.stderr +++ b/src/test/ui/coherence/impl[t]-foreign[foreign]-for-t.stderr @@ -1,8 +1,8 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/impl[t]-foreign[foreign]-for-t.rs:12:1 + --> $DIR/impl[t]-foreign[foreign]-for-t.rs:12:6 | LL | impl Remote1 for T { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | ^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/coherence/impl[t]-foreign[fundamental[t]]-for-foreign.stderr b/src/test/ui/coherence/impl[t]-foreign[fundamental[t]]-for-foreign.stderr index dd9702650795e..150b1962acb84 100644 --- a/src/test/ui/coherence/impl[t]-foreign[fundamental[t]]-for-foreign.stderr +++ b/src/test/ui/coherence/impl[t]-foreign[fundamental[t]]-for-foreign.stderr @@ -1,16 +1,16 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/impl[t]-foreign[fundamental[t]]-for-foreign.rs:12:1 + --> $DIR/impl[t]-foreign[fundamental[t]]-for-foreign.rs:12:6 | LL | impl Remote1> for u32 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | ^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/impl[t]-foreign[fundamental[t]]-for-foreign.rs:16:1 + --> $DIR/impl[t]-foreign[fundamental[t]]-for-foreign.rs:16:10 | LL | impl<'a, T> Remote1<&'a T> for u32 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | ^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/coherence/impl[t]-foreign[fundamental[t]]-for-fundamental[t].stderr b/src/test/ui/coherence/impl[t]-foreign[fundamental[t]]-for-fundamental[t].stderr index eec57fccea762..0d86e74788cf8 100644 --- a/src/test/ui/coherence/impl[t]-foreign[fundamental[t]]-for-fundamental[t].stderr +++ b/src/test/ui/coherence/impl[t]-foreign[fundamental[t]]-for-fundamental[t].stderr @@ -1,16 +1,16 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/impl[t]-foreign[fundamental[t]]-for-fundamental[t].rs:12:1 + --> $DIR/impl[t]-foreign[fundamental[t]]-for-fundamental[t].rs:12:10 | LL | impl<'a, T> Remote1> for &'a T { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | ^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/impl[t]-foreign[fundamental[t]]-for-fundamental[t].rs:15:1 + --> $DIR/impl[t]-foreign[fundamental[t]]-for-fundamental[t].rs:15:10 | LL | impl<'a, T> Remote1<&'a T> for Box { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | ^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/coherence/impl[t]-foreign[fundamental[t]]-for-t.stderr b/src/test/ui/coherence/impl[t]-foreign[fundamental[t]]-for-t.stderr index e017c3ffe6c05..04ac6a868fa1a 100644 --- a/src/test/ui/coherence/impl[t]-foreign[fundamental[t]]-for-t.stderr +++ b/src/test/ui/coherence/impl[t]-foreign[fundamental[t]]-for-t.stderr @@ -1,16 +1,16 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/impl[t]-foreign[fundamental[t]]-for-t.rs:12:1 + --> $DIR/impl[t]-foreign[fundamental[t]]-for-t.rs:12:6 | LL | impl Remote1> for T { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | ^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/impl[t]-foreign[fundamental[t]]-for-t.rs:15:1 + --> $DIR/impl[t]-foreign[fundamental[t]]-for-t.rs:15:10 | LL | impl<'a, T> Remote1<&'a T> for T { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | ^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/coherence/impl[t]-foreign[fundamental[t]_local]-for-foreign.stderr b/src/test/ui/coherence/impl[t]-foreign[fundamental[t]_local]-for-foreign.stderr index 3d8561956ae7f..f1fdcecf57df8 100644 --- a/src/test/ui/coherence/impl[t]-foreign[fundamental[t]_local]-for-foreign.stderr +++ b/src/test/ui/coherence/impl[t]-foreign[fundamental[t]_local]-for-foreign.stderr @@ -1,16 +1,16 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/impl[t]-foreign[fundamental[t]_local]-for-foreign.rs:12:1 + --> $DIR/impl[t]-foreign[fundamental[t]_local]-for-foreign.rs:12:6 | LL | impl Remote2, Local> for u32 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | ^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/impl[t]-foreign[fundamental[t]_local]-for-foreign.rs:16:1 + --> $DIR/impl[t]-foreign[fundamental[t]_local]-for-foreign.rs:16:10 | LL | impl<'a, T> Remote2<&'a T, Local> for u32 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | ^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/coherence/impl[t]-foreign[local]-for-fundamental[t].stderr b/src/test/ui/coherence/impl[t]-foreign[local]-for-fundamental[t].stderr index 7859665a7bb58..99ccbb89fc2fc 100644 --- a/src/test/ui/coherence/impl[t]-foreign[local]-for-fundamental[t].stderr +++ b/src/test/ui/coherence/impl[t]-foreign[local]-for-fundamental[t].stderr @@ -1,16 +1,16 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/impl[t]-foreign[local]-for-fundamental[t].rs:12:1 + --> $DIR/impl[t]-foreign[local]-for-fundamental[t].rs:12:6 | LL | impl Remote1 for Box { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | ^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/impl[t]-foreign[local]-for-fundamental[t].rs:16:1 + --> $DIR/impl[t]-foreign[local]-for-fundamental[t].rs:16:6 | LL | impl Remote1 for &T { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | ^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/coherence/impl[t]-foreign[local]-for-t.stderr b/src/test/ui/coherence/impl[t]-foreign[local]-for-t.stderr index be7de8cccb467..08cf414c139af 100644 --- a/src/test/ui/coherence/impl[t]-foreign[local]-for-t.stderr +++ b/src/test/ui/coherence/impl[t]-foreign[local]-for-t.stderr @@ -1,8 +1,8 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/impl[t]-foreign[local]-for-t.rs:12:1 + --> $DIR/impl[t]-foreign[local]-for-t.rs:12:6 | LL | impl Remote1 for T { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | ^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/coherence/impl[t]-foreign[t]-for-foreign.stderr b/src/test/ui/coherence/impl[t]-foreign[t]-for-foreign.stderr index 5544729b5d640..e9d1ea8a81575 100644 --- a/src/test/ui/coherence/impl[t]-foreign[t]-for-foreign.stderr +++ b/src/test/ui/coherence/impl[t]-foreign[t]-for-foreign.stderr @@ -1,8 +1,8 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/impl[t]-foreign[t]-for-foreign.rs:12:1 + --> $DIR/impl[t]-foreign[t]-for-foreign.rs:12:6 | LL | impl Remote1 for u32 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | ^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/coherence/impl[t]-foreign[t]-for-fundamental.stderr b/src/test/ui/coherence/impl[t]-foreign[t]-for-fundamental.stderr index be8cc29a6e5b0..d8b0d25a5782b 100644 --- a/src/test/ui/coherence/impl[t]-foreign[t]-for-fundamental.stderr +++ b/src/test/ui/coherence/impl[t]-foreign[t]-for-fundamental.stderr @@ -1,16 +1,16 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/impl[t]-foreign[t]-for-fundamental.rs:12:1 + --> $DIR/impl[t]-foreign[t]-for-fundamental.rs:12:6 | LL | impl Remote1 for Box { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | ^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter error[E0210]: type parameter `B` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/impl[t]-foreign[t]-for-fundamental.rs:16:1 + --> $DIR/impl[t]-foreign[t]-for-fundamental.rs:16:13 | LL | impl<'a, A, B> Remote1 for &'a B { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `B` must be used as the type parameter for some local type + | ^ type parameter `B` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/coherence/impl[t]-foreign[t]-for-t.stderr b/src/test/ui/coherence/impl[t]-foreign[t]-for-t.stderr index de857afd20b15..7b651e66c3dcb 100644 --- a/src/test/ui/coherence/impl[t]-foreign[t]-for-t.stderr +++ b/src/test/ui/coherence/impl[t]-foreign[t]-for-t.stderr @@ -1,8 +1,8 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/impl[t]-foreign[t]-for-t.rs:12:1 + --> $DIR/impl[t]-foreign[t]-for-t.rs:12:6 | LL | impl Remote1 for T { - | ^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | ^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/dropck/drop-on-non-struct.stderr b/src/test/ui/dropck/drop-on-non-struct.stderr index 334adb27fda26..91b146dee937e 100644 --- a/src/test/ui/dropck/drop-on-non-struct.stderr +++ b/src/test/ui/dropck/drop-on-non-struct.stderr @@ -8,9 +8,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/drop-on-non-struct.rs:1:1 | LL | impl<'a> Drop for &'a mut isize { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^------------- + | | | + | | `&'a mut isize` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `&'a mut isize` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to 2 previous errors diff --git a/src/test/ui/error-codes/E0117.stderr b/src/test/ui/error-codes/E0117.stderr index ecd0c152f28c8..f0cfc8a253324 100644 --- a/src/test/ui/error-codes/E0117.stderr +++ b/src/test/ui/error-codes/E0117.stderr @@ -8,9 +8,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/E0117.rs:1:1 | LL | impl Drop for u32 {} - | ^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^--- + | | | + | | `u32` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `u32` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to 2 previous errors diff --git a/src/test/ui/error-codes/E0206.stderr b/src/test/ui/error-codes/E0206.stderr index 322fdd9f11d05..12962e0d3d876 100644 --- a/src/test/ui/error-codes/E0206.stderr +++ b/src/test/ui/error-codes/E0206.stderr @@ -14,9 +14,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/E0206.rs:3:1 | LL | impl Copy for Foo { } - | ^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^--- + | | | + | | `[u8; _]` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `[u8; _]` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to 3 previous errors diff --git a/src/test/ui/error-codes/e0119/complex-impl.stderr b/src/test/ui/error-codes/e0119/complex-impl.stderr index 7ed89a5b1aeb1..f7516d20af472 100644 --- a/src/test/ui/error-codes/e0119/complex-impl.stderr +++ b/src/test/ui/error-codes/e0119/complex-impl.stderr @@ -9,10 +9,10 @@ LL | impl External for (Q, R) {} where >::Output == V, ::Item == T, 'b : 'a, T : 'a, U: std::ops::FnOnce<(T,)>, U : 'static, V: std::iter::Iterator, V: std::clone::Clone, W: std::ops::Add, ::Output: std::marker::Copy; error[E0210]: type parameter `R` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/complex-impl.rs:9:1 + --> $DIR/complex-impl.rs:9:6 | LL | impl External for (Q, R) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `R` must be used as the type parameter for some local type + | ^ type parameter `R` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/error-codes/e0119/issue-28981.stderr b/src/test/ui/error-codes/e0119/issue-28981.stderr index 70c83e1412da6..ec8e8144d42cf 100644 --- a/src/test/ui/error-codes/e0119/issue-28981.stderr +++ b/src/test/ui/error-codes/e0119/issue-28981.stderr @@ -9,10 +9,10 @@ LL | impl Deref for Foo { } where T: ?Sized; error[E0210]: type parameter `Foo` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/issue-28981.rs:5:1 + --> $DIR/issue-28981.rs:5:6 | LL | impl Deref for Foo { } - | ^^^^^^^^^^^^^^^^^^^^^^^ type parameter `Foo` must be used as the type parameter for some local type + | ^^^ type parameter `Foo` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/feature-gates/feature-gate-re-rebalance-coherence.stderr b/src/test/ui/feature-gates/feature-gate-re-rebalance-coherence.stderr index 5972e610e47d6..504bfb5697960 100644 --- a/src/test/ui/feature-gates/feature-gate-re-rebalance-coherence.stderr +++ b/src/test/ui/feature-gates/feature-gate-re-rebalance-coherence.stderr @@ -1,8 +1,8 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/feature-gate-re-rebalance-coherence.rs:10:1 + --> $DIR/feature-gate-re-rebalance-coherence.rs:10:10 | LL | impl<'a, T:'a, Tab> QueryFragment for BatchInsert<'a, T, Tab> {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | ^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/issues/issue-41974.stderr b/src/test/ui/issues/issue-41974.stderr index 20121878a0754..12d4da7159929 100644 --- a/src/test/ui/issues/issue-41974.stderr +++ b/src/test/ui/issues/issue-41974.stderr @@ -16,10 +16,10 @@ LL | impl Drop for T where T: A { | ^ implementing Drop requires a struct error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/issue-41974.rs:7:1 + --> $DIR/issue-41974.rs:7:6 | LL | impl Drop for T where T: A { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | ^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/orphan-check-diagnostics.stderr b/src/test/ui/orphan-check-diagnostics.stderr index 3f868422c7fcb..cb21b26bba75a 100644 --- a/src/test/ui/orphan-check-diagnostics.stderr +++ b/src/test/ui/orphan-check-diagnostics.stderr @@ -1,8 +1,8 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/orphan-check-diagnostics.rs:11:1 + --> $DIR/orphan-check-diagnostics.rs:11:6 | LL | impl RemoteTrait for T where T: LocalTrait {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | ^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/typeck/typeck-default-trait-impl-cross-crate-coherence.stderr b/src/test/ui/typeck/typeck-default-trait-impl-cross-crate-coherence.stderr index 42d6792d0d0e6..69a8100096cef 100644 --- a/src/test/ui/typeck/typeck-default-trait-impl-cross-crate-coherence.stderr +++ b/src/test/ui/typeck/typeck-default-trait-impl-cross-crate-coherence.stderr @@ -2,18 +2,22 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/typeck-default-trait-impl-cross-crate-coherence.rs:13:1 | LL | impl DefaultedTrait for (A,) { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^^^^^^---- + | | | + | | `(A,)` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `(A,)` is not defined in the current create = 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/typeck-default-trait-impl-cross-crate-coherence.rs:16:1 | LL | impl !DefaultedTrait for (B,) { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^^^^^^^---- + | | | + | | `(B,)` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `(B,)` is not defined in the current create = note: define and implement a trait or new type instead error[E0321]: cross-crate traits with a default impl, like `lib::DefaultedTrait`, can only be implemented for a struct/enum type defined in the current crate @@ -26,9 +30,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/typeck-default-trait-impl-cross-crate-coherence.rs:21:1 | LL | impl DefaultedTrait for lib::Something { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^^^^^^----------------- + | | | + | | `lib::Something` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `lib::Something` is not defined in the current create = note: define and implement a trait or new type instead error: aborting due to 4 previous errors From 56aa89cdbec7d020dbeff76d0a2f6d0f28a1c12f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sat, 12 Oct 2019 14:44:16 -0700 Subject: [PATCH 3/8] Further tweak spans for better readability --- src/librustc_typeck/coherence/orphan.rs | 4 ++-- src/test/ui/coherence/coherence-orphan.old.stderr | 8 ++++---- src/test/ui/coherence/coherence-orphan.re.stderr | 8 ++++---- .../coherence-pair-covered-uncovered-1.re.stderr | 8 ++++---- .../ui/coherence/impl-foreign[foreign]-for-foreign.stderr | 8 ++++---- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs index 3bcea6d173aa5..7024927bf8dff 100644 --- a/src/librustc_typeck/coherence/orphan.rs +++ b/src/librustc_typeck/coherence/orphan.rs @@ -24,7 +24,7 @@ impl ItemLikeVisitor<'v> for OrphanChecker<'tcx> { fn visit_item(&mut self, item: &hir::Item) { let def_id = self.tcx.hir().local_def_id(item.hir_id); // "Trait" impl - if let hir::ItemKind::Impl(.., generics, Some(_), impl_ty, _) = &item.kind { + if let hir::ItemKind::Impl(.., generics, Some(tr), impl_ty, _) = &item.kind { debug!("coherence2::orphan check: trait impl {}", self.tcx.hir().node_to_string(item.hir_id)); let trait_ref = self.tcx.impl_trait_ref(def_id).unwrap(); @@ -47,7 +47,7 @@ impl ItemLikeVisitor<'v> for OrphanChecker<'tcx> { if *i == 0 { err.span_label(impl_ty.span, &msg); } else { - err.note(&msg); + err.span_label(tr.path.span, &msg); } } err.note("define and implement a trait or new type instead"); diff --git a/src/test/ui/coherence/coherence-orphan.old.stderr b/src/test/ui/coherence/coherence-orphan.old.stderr index 3594224abac44..8d3605983179e 100644 --- a/src/test/ui/coherence/coherence-orphan.old.stderr +++ b/src/test/ui/coherence/coherence-orphan.old.stderr @@ -2,12 +2,12 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/coherence-orphan.rs:13:1 | LL | impl TheTrait for isize { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^----- - | | | - | | `isize` is not defined in the current crate + | ^^^^^---------------^^^^^----- + | | | | + | | | `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 | - = note: `usize` is not defined in the current crate = 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 diff --git a/src/test/ui/coherence/coherence-orphan.re.stderr b/src/test/ui/coherence/coherence-orphan.re.stderr index 3594224abac44..8d3605983179e 100644 --- a/src/test/ui/coherence/coherence-orphan.re.stderr +++ b/src/test/ui/coherence/coherence-orphan.re.stderr @@ -2,12 +2,12 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/coherence-orphan.rs:13:1 | LL | impl TheTrait for isize { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^----- - | | | - | | `isize` is not defined in the current crate + | ^^^^^---------------^^^^^----- + | | | | + | | | `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 | - = note: `usize` is not defined in the current crate = 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 diff --git a/src/test/ui/coherence/coherence-pair-covered-uncovered-1.re.stderr b/src/test/ui/coherence/coherence-pair-covered-uncovered-1.re.stderr index 3af9d93833d2e..db9989c666490 100644 --- a/src/test/ui/coherence/coherence-pair-covered-uncovered-1.re.stderr +++ b/src/test/ui/coherence/coherence-pair-covered-uncovered-1.re.stderr @@ -2,12 +2,12 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/coherence-pair-covered-uncovered-1.rs:15:1 | LL | impl Remote1>> for i32 { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- - | | | - | | `i32` is not defined in the current crate + | ^^^^^^^^^^^--------------------------^^^^^--- + | | | | + | | | `i32` is not defined in the current crate + | | `lib::Pair>` is not defined in the current crate | impl doesn't use only types from inside the current crate | - = note: `lib::Pair>` is not defined in the current crate = note: define and implement a trait or new type instead error: aborting due to previous error diff --git a/src/test/ui/coherence/impl-foreign[foreign]-for-foreign.stderr b/src/test/ui/coherence/impl-foreign[foreign]-for-foreign.stderr index 0a36f7cf3c692..07c7632a53ff4 100644 --- a/src/test/ui/coherence/impl-foreign[foreign]-for-foreign.stderr +++ b/src/test/ui/coherence/impl-foreign[foreign]-for-foreign.stderr @@ -2,12 +2,12 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/impl-foreign[foreign]-for-foreign.rs:12:1 | LL | impl Remote1 for f64 { - | ^^^^^^^^^^^^^^^^^^^^^^--- - | | | - | | `f64` is not defined in the current crate + | ^^^^^------------^^^^^--- + | | | | + | | | `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 | - = note: `u32` is not defined in the current crate = note: define and implement a trait or new type instead error: aborting due to previous error From daeafd895d26892d9adac2f7103b071b6c07823e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 13 Oct 2019 11:25:30 -0700 Subject: [PATCH 4/8] Talk about specific types and remove lifetimes from output --- src/librustc/traits/coherence.rs | 84 ++++++++++++++----- src/librustc_typeck/coherence/orphan.rs | 23 ++++- ...rence-fundamental-trait-objects.old.stderr | 2 +- ...erence-fundamental-trait-objects.re.stderr | 2 +- ...mpl-trait-for-marker-trait-negative.stderr | 2 +- ...mpl-trait-for-marker-trait-positive.stderr | 2 +- .../coherence/coherence-impls-copy.old.stderr | 4 +- .../coherence/coherence-impls-copy.re.stderr | 4 +- .../coherence/coherence-impls-send.old.stderr | 4 +- .../coherence/coherence-impls-send.re.stderr | 4 +- .../coherence-impls-sized.old.stderr | 4 +- .../coherence/coherence-impls-sized.re.stderr | 4 +- src/test/ui/dropck/drop-on-non-struct.stderr | 2 +- src/test/ui/error-codes/E0206.stderr | 2 +- 14 files changed, 100 insertions(+), 43 deletions(-) diff --git a/src/librustc/traits/coherence.rs b/src/librustc/traits/coherence.rs index 71a39b21f779c..edf95bf76125d 100644 --- a/src/librustc/traits/coherence.rs +++ b/src/librustc/traits/coherence.rs @@ -237,7 +237,7 @@ pub fn trait_ref_is_local_or_fundamental<'tcx>( } pub enum OrphanCheckErr<'tcx> { - NonLocalInputType(Vec<(Ty<'tcx>, usize)>), + NonLocalInputType(Vec<(Ty<'tcx>, bool)>), UncoveredTy(Ty<'tcx>), } @@ -355,7 +355,7 @@ pub fn orphan_check( /// Note that this function is never called for types that have both type /// parameters and inference variables. fn orphan_check_trait_ref<'tcx>( - tcx: TyCtxt<'_>, + tcx: TyCtxt<'tcx>, trait_ref: ty::TraitRef<'tcx>, in_crate: InCrate, ) -> Result<(), OrphanCheckErr<'tcx>> { @@ -397,14 +397,19 @@ fn orphan_check_trait_ref<'tcx>( .enumerate() { debug!("orphan_check_trait_ref: check ty `{:?}`", input_ty); - if ty_is_local(tcx, input_ty, in_crate) { + let non_local_tys = ty_is_non_local(tcx, input_ty, in_crate); + if non_local_tys.is_none() { debug!("orphan_check_trait_ref: ty_is_local `{:?}`", input_ty); return Ok(()); } else if let ty::Param(_) = input_ty.kind { debug!("orphan_check_trait_ref: uncovered ty: `{:?}`", input_ty); return Err(OrphanCheckErr::UncoveredTy(input_ty)) } - non_local_spans.push((input_ty, i)); + if let Some(non_local_tys) = non_local_tys { + for input_ty in non_local_tys { + non_local_spans.push((input_ty, i == 0)); + } + } } // If we exit above loop, never found a local type. debug!("orphan_check_trait_ref: no local type"); @@ -416,7 +421,8 @@ fn orphan_check_trait_ref<'tcx>( // first. Find the first input type that either references a // type parameter OR some local type. for (i, input_ty) in trait_ref.input_types().enumerate() { - if ty_is_local(tcx, input_ty, in_crate) { + let non_local_tys = ty_is_non_local(tcx, input_ty, in_crate); + if non_local_tys.is_none() { debug!("orphan_check_trait_ref: ty_is_local `{:?}`", input_ty); // First local input type. Check that there are no @@ -444,7 +450,11 @@ fn orphan_check_trait_ref<'tcx>( return Err(OrphanCheckErr::UncoveredTy(param)); } - non_local_spans.push((input_ty, i)); + if let Some(non_local_tys) = non_local_tys { + for input_ty in non_local_tys { + non_local_spans.push((input_ty, i == 0)); + } + } } // If we exit above loop, never found a local type. debug!("orphan_check_trait_ref: no local type"); @@ -452,8 +462,8 @@ fn orphan_check_trait_ref<'tcx>( } } -fn uncovered_tys<'tcx>(tcx: TyCtxt<'_>, ty: Ty<'tcx>, in_crate: InCrate) -> Vec> { - if ty_is_local_constructor(tcx, ty, in_crate) { +fn uncovered_tys<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, in_crate: InCrate) -> Vec> { + if ty_is_non_local_constructor(tcx, ty, in_crate).is_none() { vec![] } else if fundamental_ty(ty) { ty.walk_shallow() @@ -471,9 +481,23 @@ fn is_possibly_remote_type(ty: Ty<'_>, _in_crate: InCrate) -> bool { } } -fn ty_is_local(tcx: TyCtxt<'_>, ty: Ty<'_>, in_crate: InCrate) -> bool { - ty_is_local_constructor(tcx, ty, in_crate) || - fundamental_ty(ty) && ty.walk_shallow().any(|t| ty_is_local(tcx, t, in_crate)) +fn ty_is_non_local<'t>(tcx: TyCtxt<'t>, ty: Ty<'t>, in_crate: InCrate) -> Option>> { + match ty_is_non_local_constructor(tcx, ty, in_crate) { + Some(ty) => if !fundamental_ty(ty) { + Some(vec![ty]) + } else { + let tys: Vec<_> = ty.walk_shallow() + .filter_map(|t| ty_is_non_local(tcx, t, in_crate)) + .flat_map(|i| i) + .collect(); + if tys.is_empty() { + None + } else { + Some(tys) + } + }, + None => None, + } } fn fundamental_ty(ty: Ty<'_>) -> bool { @@ -493,8 +517,12 @@ fn def_id_is_local(def_id: DefId, in_crate: InCrate) -> bool { } } -fn ty_is_local_constructor(tcx: TyCtxt<'_>, ty: Ty<'_>, in_crate: InCrate) -> bool { - debug!("ty_is_local_constructor({:?})", ty); +fn ty_is_non_local_constructor<'tcx>( + tcx: TyCtxt<'tcx>, + ty: Ty<'tcx>, + in_crate: InCrate, +) -> Option> { + debug!("ty_is_non_local_constructor({:?})", ty); match ty.kind { ty::Bool | @@ -513,18 +541,26 @@ fn ty_is_local_constructor(tcx: TyCtxt<'_>, ty: Ty<'_>, in_crate: InCrate) -> bo ty::Tuple(..) | ty::Param(..) | ty::Projection(..) => { - false + Some(ty) } ty::Placeholder(..) | ty::Bound(..) | ty::Infer(..) => match in_crate { - InCrate::Local => false, + InCrate::Local => Some(ty), // The inference variable might be unified with a local // type in that remote crate. - InCrate::Remote => true, + InCrate::Remote => None, }, - ty::Adt(def, _) => def_id_is_local(def.did, in_crate), - ty::Foreign(did) => def_id_is_local(did, in_crate), + ty::Adt(def, _) => if def_id_is_local(def.did, in_crate) { + None + } else { + Some(ty) + }, + ty::Foreign(did) => if def_id_is_local(did, in_crate) { + None + } else { + Some(ty) + }, ty::Opaque(did, _) => { // Check the underlying type that this opaque // type resolves to. @@ -532,18 +568,22 @@ fn ty_is_local_constructor(tcx: TyCtxt<'_>, ty: Ty<'_>, in_crate: InCrate) -> bo // since we've already managed to successfully // resolve all opaque types by this point let real_ty = tcx.type_of(did); - ty_is_local_constructor(tcx, real_ty, in_crate) + ty_is_non_local_constructor(tcx, real_ty, in_crate) } ty::Dynamic(ref tt, ..) => { if let Some(principal) = tt.principal() { - def_id_is_local(principal.def_id(), in_crate) + if def_id_is_local(principal.def_id(), in_crate) { + None + } else { + Some(ty) + } } else { - false + Some(ty) } } - ty::Error => true, + ty::Error => None, ty::UnnormalizedProjection(..) | ty::Closure(..) | diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs index 7024927bf8dff..ef2de50b2cb46 100644 --- a/src/librustc_typeck/coherence/orphan.rs +++ b/src/librustc_typeck/coherence/orphan.rs @@ -42,11 +42,28 @@ impl ItemLikeVisitor<'v> for OrphanChecker<'tcx> { arbitrary types" ); err.span_label(sp, "impl doesn't use only types from inside the current crate"); - for (ty, i) in &tys { - let msg = format!("`{}` is not defined in the current crate", ty); - if *i == 0 { + for (ty, is_target_ty) in &tys { + // FIXME: We want to remove the type arguments from the displayed type. + // The reverse of `resolve_vars_if_possible`. + let mut ty = *ty; + self.tcx.infer_ctxt().enter(|infcx| { + // Remove the lifetimes unnecessary for this error. + ty = infcx.freshen(ty); + }); + let msg = format!( + "`{}` is not defined in the current crate{}", + ty, + match &ty.kind { + ty::Slice(_) => " because slices are always considered foreign", + ty::Array(..) => " because arrays are always considered foreign", + _ => "", + }, + ); + if *is_target_ty { + // Point at `D` in `impl for C in D` err.span_label(impl_ty.span, &msg); } else { + // Point at `C` in `impl for C in D` err.span_label(tr.path.span, &msg); } } diff --git a/src/test/ui/coherence/coherence-fundamental-trait-objects.old.stderr b/src/test/ui/coherence/coherence-fundamental-trait-objects.old.stderr index 2efa2702a2452..a3da52fe484ac 100644 --- a/src/test/ui/coherence/coherence-fundamental-trait-objects.old.stderr +++ b/src/test/ui/coherence/coherence-fundamental-trait-objects.old.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Misc for dyn Fundamental {} | ^^^^^^^^^^^^^^---------------------- | | | - | | `(dyn coherence_fundamental_trait_lib::Fundamental + 'static)` is not defined in the current crate + | | `dyn coherence_fundamental_trait_lib::Fundamental` is not defined in the current crate | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence-fundamental-trait-objects.re.stderr b/src/test/ui/coherence/coherence-fundamental-trait-objects.re.stderr index 2efa2702a2452..a3da52fe484ac 100644 --- a/src/test/ui/coherence/coherence-fundamental-trait-objects.re.stderr +++ b/src/test/ui/coherence/coherence-fundamental-trait-objects.re.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Misc for dyn Fundamental {} | ^^^^^^^^^^^^^^---------------------- | | | - | | `(dyn coherence_fundamental_trait_lib::Fundamental + 'static)` is not defined in the current crate + | | `dyn coherence_fundamental_trait_lib::Fundamental` is not defined in the current crate | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence-impl-trait-for-marker-trait-negative.stderr b/src/test/ui/coherence/coherence-impl-trait-for-marker-trait-negative.stderr index 5a157434fb48e..b8137b36948cd 100644 --- a/src/test/ui/coherence/coherence-impl-trait-for-marker-trait-negative.stderr +++ b/src/test/ui/coherence/coherence-impl-trait-for-marker-trait-negative.stderr @@ -16,7 +16,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl !Send for dyn Marker2 {} | ^^^^^^^^^^^^^^^----------- | | | - | | `(dyn Marker2 + 'static)` is not defined in the current crate + | | `dyn Marker2` is not defined in the current crate | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence-impl-trait-for-marker-trait-positive.stderr b/src/test/ui/coherence/coherence-impl-trait-for-marker-trait-positive.stderr index 9ba125d58dfc5..d68337bed0066 100644 --- a/src/test/ui/coherence/coherence-impl-trait-for-marker-trait-positive.stderr +++ b/src/test/ui/coherence/coherence-impl-trait-for-marker-trait-positive.stderr @@ -16,7 +16,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | unsafe impl Send for dyn Marker2 {} | ^^^^^^^^^^^^^^^^^^^^^----------- | | | - | | `(dyn Marker2 + 'static)` is not defined in the current crate + | | `dyn Marker2` is not defined in the current crate | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence-impls-copy.old.stderr b/src/test/ui/coherence/coherence-impls-copy.old.stderr index 4da32a9accd22..c2c61fd6d916e 100644 --- a/src/test/ui/coherence/coherence-impls-copy.old.stderr +++ b/src/test/ui/coherence/coherence-impls-copy.old.stderr @@ -73,7 +73,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Copy for [MyType] {} | ^^^^^^^^^^^^^^-------- | | | - | | `[MyType]` is not defined in the current crate + | | `[MyType]` is not defined in the current crate because slices are always considered foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead @@ -84,7 +84,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Copy for &'static [NotSync] {} | ^^^^^^^^^^^^^^------------------ | | | - | | `&'static [NotSync]` is not defined in the current crate + | | `[NotSync]` is not defined in the current crate because slices are always considered foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence-impls-copy.re.stderr b/src/test/ui/coherence/coherence-impls-copy.re.stderr index 09aa831319058..c2c61fd6d916e 100644 --- a/src/test/ui/coherence/coherence-impls-copy.re.stderr +++ b/src/test/ui/coherence/coherence-impls-copy.re.stderr @@ -73,7 +73,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Copy for [MyType] {} | ^^^^^^^^^^^^^^-------- | | | - | | `[MyType]` is not defined in the current crate + | | `[MyType]` is not defined in the current crate because slices are always considered foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead @@ -84,7 +84,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Copy for &'static [NotSync] {} | ^^^^^^^^^^^^^^------------------ | | | - | | `[NotSync]` is not defined in the current crate + | | `[NotSync]` is not defined in the current crate because slices are always considered foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence-impls-send.old.stderr b/src/test/ui/coherence/coherence-impls-send.old.stderr index 0b49a6bf6dee7..3c504c591ba69 100644 --- a/src/test/ui/coherence/coherence-impls-send.old.stderr +++ b/src/test/ui/coherence/coherence-impls-send.old.stderr @@ -21,7 +21,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | unsafe impl Send for [MyType] {} | ^^^^^^^^^^^^^^^^^^^^^-------- | | | - | | `[MyType]` is not defined in the current crate + | | `[MyType]` is not defined in the current crate because slices are always considered foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead @@ -32,7 +32,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | unsafe impl Send for &'static [NotSync] {} | ^^^^^^^^^^^^^^^^^^^^^------------------ | | | - | | `&'static [NotSync]` is not defined in the current crate + | | `[NotSync]` is not defined in the current crate because slices are always considered foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence-impls-send.re.stderr b/src/test/ui/coherence/coherence-impls-send.re.stderr index 60d439a32354c..3c504c591ba69 100644 --- a/src/test/ui/coherence/coherence-impls-send.re.stderr +++ b/src/test/ui/coherence/coherence-impls-send.re.stderr @@ -21,7 +21,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | unsafe impl Send for [MyType] {} | ^^^^^^^^^^^^^^^^^^^^^-------- | | | - | | `[MyType]` is not defined in the current crate + | | `[MyType]` is not defined in the current crate because slices are always considered foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead @@ -32,7 +32,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | unsafe impl Send for &'static [NotSync] {} | ^^^^^^^^^^^^^^^^^^^^^------------------ | | | - | | `[NotSync]` is not defined in the current crate + | | `[NotSync]` is not defined in the current crate because slices are always considered foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence-impls-sized.old.stderr b/src/test/ui/coherence/coherence-impls-sized.old.stderr index 9da3c26931f4d..a2a653cf330fe 100644 --- a/src/test/ui/coherence/coherence-impls-sized.old.stderr +++ b/src/test/ui/coherence/coherence-impls-sized.old.stderr @@ -51,7 +51,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Sized for [MyType] {} | ^^^^^^^^^^^^^^^-------- | | | - | | `[MyType]` is not defined in the current crate + | | `[MyType]` is not defined in the current crate because slices are always considered foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead @@ -62,7 +62,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Sized for &'static [NotSync] {} | ^^^^^^^^^^^^^^^------------------ | | | - | | `&'static [NotSync]` is not defined in the current crate + | | `[NotSync]` is not defined in the current crate because slices are always considered foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence-impls-sized.re.stderr b/src/test/ui/coherence/coherence-impls-sized.re.stderr index 4f5f31b80861e..a2a653cf330fe 100644 --- a/src/test/ui/coherence/coherence-impls-sized.re.stderr +++ b/src/test/ui/coherence/coherence-impls-sized.re.stderr @@ -51,7 +51,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Sized for [MyType] {} | ^^^^^^^^^^^^^^^-------- | | | - | | `[MyType]` is not defined in the current crate + | | `[MyType]` is not defined in the current crate because slices are always considered foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead @@ -62,7 +62,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Sized for &'static [NotSync] {} | ^^^^^^^^^^^^^^^------------------ | | | - | | `[NotSync]` is not defined in the current crate + | | `[NotSync]` is not defined in the current crate because slices are always considered foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/dropck/drop-on-non-struct.stderr b/src/test/ui/dropck/drop-on-non-struct.stderr index 91b146dee937e..a374b0d2636cd 100644 --- a/src/test/ui/dropck/drop-on-non-struct.stderr +++ b/src/test/ui/dropck/drop-on-non-struct.stderr @@ -10,7 +10,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl<'a> Drop for &'a mut isize { | ^^^^^^^^^^^^^^^^^^------------- | | | - | | `&'a mut isize` is not defined in the current crate + | | `isize` is not defined in the current crate | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/error-codes/E0206.stderr b/src/test/ui/error-codes/E0206.stderr index 12962e0d3d876..7d5175246d19e 100644 --- a/src/test/ui/error-codes/E0206.stderr +++ b/src/test/ui/error-codes/E0206.stderr @@ -16,7 +16,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Copy for Foo { } | ^^^^^^^^^^^^^^--- | | | - | | `[u8; _]` is not defined in the current crate + | | `[u8; _]` is not defined in the current crate because arrays are always considered foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead From db1bfbdbc07454ac4b35290e79931b51d5e5b36f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 13 Oct 2019 11:35:21 -0700 Subject: [PATCH 5/8] Account for tuples in explanation --- src/librustc_typeck/coherence/orphan.rs | 5 +++-- src/test/ui/coherence/coherence-impls-copy.old.stderr | 6 +++--- src/test/ui/coherence/coherence-impls-copy.re.stderr | 6 +++--- src/test/ui/coherence/coherence-impls-send.old.stderr | 6 +++--- src/test/ui/coherence/coherence-impls-send.re.stderr | 6 +++--- src/test/ui/coherence/coherence-impls-sized.old.stderr | 6 +++--- src/test/ui/coherence/coherence-impls-sized.re.stderr | 6 +++--- src/test/ui/coherence/coherence_local_err_tuple.old.stderr | 2 +- src/test/ui/coherence/coherence_local_err_tuple.re.stderr | 2 +- src/test/ui/error-codes/E0206.stderr | 2 +- .../typeck-default-trait-impl-cross-crate-coherence.stderr | 4 ++-- 11 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs index ef2de50b2cb46..1ae9b93d9a690 100644 --- a/src/librustc_typeck/coherence/orphan.rs +++ b/src/librustc_typeck/coherence/orphan.rs @@ -54,8 +54,9 @@ impl ItemLikeVisitor<'v> for OrphanChecker<'tcx> { "`{}` is not defined in the current crate{}", ty, match &ty.kind { - ty::Slice(_) => " because slices are always considered foreign", - ty::Array(..) => " because arrays are always considered foreign", + ty::Slice(_) => " because slices are always foreign", + ty::Array(..) => " because arrays are always foreign", + ty::Tuple(..) => " because tuples are always foreign", _ => "", }, ); diff --git a/src/test/ui/coherence/coherence-impls-copy.old.stderr b/src/test/ui/coherence/coherence-impls-copy.old.stderr index c2c61fd6d916e..bd0debadbb0e9 100644 --- a/src/test/ui/coherence/coherence-impls-copy.old.stderr +++ b/src/test/ui/coherence/coherence-impls-copy.old.stderr @@ -62,7 +62,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Copy for (MyType, MyType) {} | ^^^^^^^^^^^^^^---------------- | | | - | | `(MyType, MyType)` is not defined in the current crate + | | `(MyType, MyType)` is not defined in the current crate because tuples are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead @@ -73,7 +73,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Copy for [MyType] {} | ^^^^^^^^^^^^^^-------- | | | - | | `[MyType]` is not defined in the current crate because slices are always considered foreign + | | `[MyType]` is not defined in the current crate because slices are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead @@ -84,7 +84,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Copy for &'static [NotSync] {} | ^^^^^^^^^^^^^^------------------ | | | - | | `[NotSync]` is not defined in the current crate because slices are always considered foreign + | | `[NotSync]` is not defined in the current crate because slices are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence-impls-copy.re.stderr b/src/test/ui/coherence/coherence-impls-copy.re.stderr index c2c61fd6d916e..bd0debadbb0e9 100644 --- a/src/test/ui/coherence/coherence-impls-copy.re.stderr +++ b/src/test/ui/coherence/coherence-impls-copy.re.stderr @@ -62,7 +62,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Copy for (MyType, MyType) {} | ^^^^^^^^^^^^^^---------------- | | | - | | `(MyType, MyType)` is not defined in the current crate + | | `(MyType, MyType)` is not defined in the current crate because tuples are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead @@ -73,7 +73,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Copy for [MyType] {} | ^^^^^^^^^^^^^^-------- | | | - | | `[MyType]` is not defined in the current crate because slices are always considered foreign + | | `[MyType]` is not defined in the current crate because slices are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead @@ -84,7 +84,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Copy for &'static [NotSync] {} | ^^^^^^^^^^^^^^------------------ | | | - | | `[NotSync]` is not defined in the current crate because slices are always considered foreign + | | `[NotSync]` is not defined in the current crate because slices are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence-impls-send.old.stderr b/src/test/ui/coherence/coherence-impls-send.old.stderr index 3c504c591ba69..024080a621de8 100644 --- a/src/test/ui/coherence/coherence-impls-send.old.stderr +++ b/src/test/ui/coherence/coherence-impls-send.old.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | unsafe impl Send for (MyType, MyType) {} | ^^^^^^^^^^^^^^^^^^^^^---------------- | | | - | | `(MyType, MyType)` is not defined in the current crate + | | `(MyType, MyType)` is not defined in the current crate because tuples are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead @@ -21,7 +21,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | unsafe impl Send for [MyType] {} | ^^^^^^^^^^^^^^^^^^^^^-------- | | | - | | `[MyType]` is not defined in the current crate because slices are always considered foreign + | | `[MyType]` is not defined in the current crate because slices are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead @@ -32,7 +32,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | unsafe impl Send for &'static [NotSync] {} | ^^^^^^^^^^^^^^^^^^^^^------------------ | | | - | | `[NotSync]` is not defined in the current crate because slices are always considered foreign + | | `[NotSync]` is not defined in the current crate because slices are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence-impls-send.re.stderr b/src/test/ui/coherence/coherence-impls-send.re.stderr index 3c504c591ba69..024080a621de8 100644 --- a/src/test/ui/coherence/coherence-impls-send.re.stderr +++ b/src/test/ui/coherence/coherence-impls-send.re.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | unsafe impl Send for (MyType, MyType) {} | ^^^^^^^^^^^^^^^^^^^^^---------------- | | | - | | `(MyType, MyType)` is not defined in the current crate + | | `(MyType, MyType)` is not defined in the current crate because tuples are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead @@ -21,7 +21,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | unsafe impl Send for [MyType] {} | ^^^^^^^^^^^^^^^^^^^^^-------- | | | - | | `[MyType]` is not defined in the current crate because slices are always considered foreign + | | `[MyType]` is not defined in the current crate because slices are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead @@ -32,7 +32,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | unsafe impl Send for &'static [NotSync] {} | ^^^^^^^^^^^^^^^^^^^^^------------------ | | | - | | `[NotSync]` is not defined in the current crate because slices are always considered foreign + | | `[NotSync]` is not defined in the current crate because slices are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence-impls-sized.old.stderr b/src/test/ui/coherence/coherence-impls-sized.old.stderr index a2a653cf330fe..84328d915efba 100644 --- a/src/test/ui/coherence/coherence-impls-sized.old.stderr +++ b/src/test/ui/coherence/coherence-impls-sized.old.stderr @@ -40,7 +40,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Sized for (MyType, MyType) {} | ^^^^^^^^^^^^^^^---------------- | | | - | | `(MyType, MyType)` is not defined in the current crate + | | `(MyType, MyType)` is not defined in the current crate because tuples are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead @@ -51,7 +51,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Sized for [MyType] {} | ^^^^^^^^^^^^^^^-------- | | | - | | `[MyType]` is not defined in the current crate because slices are always considered foreign + | | `[MyType]` is not defined in the current crate because slices are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead @@ -62,7 +62,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Sized for &'static [NotSync] {} | ^^^^^^^^^^^^^^^------------------ | | | - | | `[NotSync]` is not defined in the current crate because slices are always considered foreign + | | `[NotSync]` is not defined in the current crate because slices are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence-impls-sized.re.stderr b/src/test/ui/coherence/coherence-impls-sized.re.stderr index a2a653cf330fe..84328d915efba 100644 --- a/src/test/ui/coherence/coherence-impls-sized.re.stderr +++ b/src/test/ui/coherence/coherence-impls-sized.re.stderr @@ -40,7 +40,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Sized for (MyType, MyType) {} | ^^^^^^^^^^^^^^^---------------- | | | - | | `(MyType, MyType)` is not defined in the current crate + | | `(MyType, MyType)` is not defined in the current crate because tuples are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead @@ -51,7 +51,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Sized for [MyType] {} | ^^^^^^^^^^^^^^^-------- | | | - | | `[MyType]` is not defined in the current crate because slices are always considered foreign + | | `[MyType]` is not defined in the current crate because slices are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead @@ -62,7 +62,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Sized for &'static [NotSync] {} | ^^^^^^^^^^^^^^^------------------ | | | - | | `[NotSync]` is not defined in the current crate because slices are always considered foreign + | | `[NotSync]` is not defined in the current crate because slices are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence_local_err_tuple.old.stderr b/src/test/ui/coherence/coherence_local_err_tuple.old.stderr index 7c3c26f5b9204..0bc55eff3d218 100644 --- a/src/test/ui/coherence/coherence_local_err_tuple.old.stderr +++ b/src/test/ui/coherence/coherence_local_err_tuple.old.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl lib::MyCopy for (MyType,) { } | ^^^^^^^^^^^^^^^^^^^^^--------- | | | - | | `(MyType,)` is not defined in the current crate + | | `(MyType,)` is not defined in the current crate because tuples are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence_local_err_tuple.re.stderr b/src/test/ui/coherence/coherence_local_err_tuple.re.stderr index 7c3c26f5b9204..0bc55eff3d218 100644 --- a/src/test/ui/coherence/coherence_local_err_tuple.re.stderr +++ b/src/test/ui/coherence/coherence_local_err_tuple.re.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl lib::MyCopy for (MyType,) { } | ^^^^^^^^^^^^^^^^^^^^^--------- | | | - | | `(MyType,)` is not defined in the current crate + | | `(MyType,)` is not defined in the current crate because tuples are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/error-codes/E0206.stderr b/src/test/ui/error-codes/E0206.stderr index 7d5175246d19e..7d7336cdff260 100644 --- a/src/test/ui/error-codes/E0206.stderr +++ b/src/test/ui/error-codes/E0206.stderr @@ -16,7 +16,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Copy for Foo { } | ^^^^^^^^^^^^^^--- | | | - | | `[u8; _]` is not defined in the current crate because arrays are always considered foreign + | | `[u8; _]` is not defined in the current crate because arrays are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/typeck/typeck-default-trait-impl-cross-crate-coherence.stderr b/src/test/ui/typeck/typeck-default-trait-impl-cross-crate-coherence.stderr index 69a8100096cef..4773ac7f7dbe9 100644 --- a/src/test/ui/typeck/typeck-default-trait-impl-cross-crate-coherence.stderr +++ b/src/test/ui/typeck/typeck-default-trait-impl-cross-crate-coherence.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl DefaultedTrait for (A,) { } | ^^^^^^^^^^^^^^^^^^^^^^^^---- | | | - | | `(A,)` is not defined in the current crate + | | `(A,)` is not defined in the current crate because tuples are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead @@ -15,7 +15,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl !DefaultedTrait for (B,) { } | ^^^^^^^^^^^^^^^^^^^^^^^^^---- | | | - | | `(B,)` is not defined in the current crate + | | `(B,)` is not defined in the current crate because tuples are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead From 95364df6bca42e6e4ce3657e0e745185f116e282 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 23 Oct 2019 17:06:01 -0700 Subject: [PATCH 6/8] Do not display ADT type arguments and fix rebase --- src/librustc_typeck/coherence/orphan.rs | 29 +++++++++++-------- .../ui/coherence/coherence-cow.re_a.stderr | 2 +- .../ui/coherence/coherence-cow.re_b.stderr | 2 +- .../ui/coherence/coherence-cow.re_c.stderr | 2 +- .../coherence/coherence-impls-copy.old.stderr | 6 ++-- .../coherence/coherence-impls-copy.re.stderr | 6 ++-- .../coherence/coherence-impls-send.old.stderr | 6 ++-- .../coherence/coherence-impls-send.re.stderr | 6 ++-- .../coherence-impls-sized.old.stderr | 6 ++-- .../coherence/coherence-impls-sized.re.stderr | 6 ++-- .../ui/coherence/coherence-orphan.old.stderr | 2 +- .../ui/coherence/coherence-orphan.re.stderr | 2 +- .../coherence-overlapping-pairs.re.stderr | 2 +- ...herence-pair-covered-uncovered-1.re.stderr | 2 +- ...coherence-pair-covered-uncovered.re.stderr | 2 +- .../coherence/coherence-vec-local-2.re.stderr | 2 +- .../coherence/coherence-vec-local.old.stderr | 2 +- .../coherence/coherence-vec-local.re.stderr | 2 +- .../coherence_local_err_struct.old.stderr | 2 +- .../coherence_local_err_struct.re.stderr | 2 +- .../coherence_local_err_tuple.old.stderr | 2 +- .../coherence_local_err_tuple.re.stderr | 2 +- .../coherence/impl-foreign-for-foreign.stderr | 6 ++-- .../impl-foreign-for-foreign[foreign].stderr | 21 ++++++++++---- ...pl-foreign-for-fundamental[foreign].stderr | 12 +++++--- ...n[fundemental[foreign]]-for-foreign.stderr | 21 ++++++++++---- .../impl[t]-foreign-for-foreign[t].stderr | 12 +++++--- .../impl[t]-foreign-for-fundamental[t].stderr | 4 +-- src/test/ui/error-codes/E0206.stderr | 2 +- ...lt-trait-impl-cross-crate-coherence.stderr | 6 ++-- 30 files changed, 106 insertions(+), 73 deletions(-) diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs index 1ae9b93d9a690..f066ca762c09e 100644 --- a/src/librustc_typeck/coherence/orphan.rs +++ b/src/librustc_typeck/coherence/orphan.rs @@ -43,23 +43,28 @@ impl ItemLikeVisitor<'v> for OrphanChecker<'tcx> { ); err.span_label(sp, "impl doesn't use only types from inside the current crate"); for (ty, is_target_ty) in &tys { - // FIXME: We want to remove the type arguments from the displayed type. - // The reverse of `resolve_vars_if_possible`. let mut ty = *ty; self.tcx.infer_ctxt().enter(|infcx| { // Remove the lifetimes unnecessary for this error. ty = infcx.freshen(ty); }); - let msg = format!( - "`{}` is not defined in the current crate{}", - ty, - match &ty.kind { - ty::Slice(_) => " because slices are always foreign", - ty::Array(..) => " because arrays are always foreign", - ty::Tuple(..) => " because tuples are always foreign", - _ => "", - }, - ); + ty = match ty.kind { + // Remove the type arguments from the output, as they are not relevant. + // You can think of this as the reverse of `resolve_vars_if_possible`. + // That way if we had `Vec`, we will properly attribute the + // problem to `Vec` and avoid confusing the user if they were to see + // `MyType` in the error. + ty::Adt(def, _) => self.tcx.mk_adt(def, ty::List::empty()), + _ => ty, + }; + let this = "this".to_string(); + let (ty, postfix) = match &ty.kind { + ty::Slice(_) => (this, " because slices are always foreign"), + ty::Array(..) => (this, " because arrays are always foreign"), + ty::Tuple(..) => (this, " because tuples are always foreign"), + _ => (format!("`{}`", ty), ""), + }; + let msg = format!("{} is not defined in the current crate{}", ty, postfix); if *is_target_ty { // Point at `D` in `impl for C in D` err.span_label(impl_ty.span, &msg); diff --git a/src/test/ui/coherence/coherence-cow.re_a.stderr b/src/test/ui/coherence/coherence-cow.re_a.stderr index 69d391378c195..06e77b2797d25 100644 --- a/src/test/ui/coherence/coherence-cow.re_a.stderr +++ b/src/test/ui/coherence/coherence-cow.re_a.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Remote for Pair> { } | ^^^^^^^^^^^^^^^^^^^---------------- | | | - | | `lib::Pair>` is not defined in the current crate + | | `lib::Pair` is not defined in the current crate | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence-cow.re_b.stderr b/src/test/ui/coherence/coherence-cow.re_b.stderr index 9be92ef3e0eb3..146232ac02b0f 100644 --- a/src/test/ui/coherence/coherence-cow.re_b.stderr +++ b/src/test/ui/coherence/coherence-cow.re_b.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Remote for Pair,T> { } | ^^^^^^^^^^^^^^^^^^^---------------- | | | - | | `lib::Pair, T>` is not defined in the current crate + | | `lib::Pair` is not defined in the current crate | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence-cow.re_c.stderr b/src/test/ui/coherence/coherence-cow.re_c.stderr index 5e942978d5a33..e0cf6aab7bbde 100644 --- a/src/test/ui/coherence/coherence-cow.re_c.stderr +++ b/src/test/ui/coherence/coherence-cow.re_c.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Remote for Pair,U> { } | ^^^^^^^^^^^^^^^^^^^^^---------------- | | | - | | `lib::Pair, U>` is not defined in the current crate + | | `lib::Pair` is not defined in the current crate | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence-impls-copy.old.stderr b/src/test/ui/coherence/coherence-impls-copy.old.stderr index bd0debadbb0e9..742845b190737 100644 --- a/src/test/ui/coherence/coherence-impls-copy.old.stderr +++ b/src/test/ui/coherence/coherence-impls-copy.old.stderr @@ -62,7 +62,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Copy for (MyType, MyType) {} | ^^^^^^^^^^^^^^---------------- | | | - | | `(MyType, MyType)` is not defined in the current crate because tuples are always foreign + | | this is not defined in the current crate because tuples are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead @@ -73,7 +73,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Copy for [MyType] {} | ^^^^^^^^^^^^^^-------- | | | - | | `[MyType]` is not defined in the current crate because slices are always foreign + | | this is not defined in the current crate because slices are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead @@ -84,7 +84,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Copy for &'static [NotSync] {} | ^^^^^^^^^^^^^^------------------ | | | - | | `[NotSync]` is not defined in the current crate because slices are always foreign + | | this is not defined in the current crate because slices are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence-impls-copy.re.stderr b/src/test/ui/coherence/coherence-impls-copy.re.stderr index bd0debadbb0e9..742845b190737 100644 --- a/src/test/ui/coherence/coherence-impls-copy.re.stderr +++ b/src/test/ui/coherence/coherence-impls-copy.re.stderr @@ -62,7 +62,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Copy for (MyType, MyType) {} | ^^^^^^^^^^^^^^---------------- | | | - | | `(MyType, MyType)` is not defined in the current crate because tuples are always foreign + | | this is not defined in the current crate because tuples are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead @@ -73,7 +73,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Copy for [MyType] {} | ^^^^^^^^^^^^^^-------- | | | - | | `[MyType]` is not defined in the current crate because slices are always foreign + | | this is not defined in the current crate because slices are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead @@ -84,7 +84,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Copy for &'static [NotSync] {} | ^^^^^^^^^^^^^^------------------ | | | - | | `[NotSync]` is not defined in the current crate because slices are always foreign + | | this is not defined in the current crate because slices are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence-impls-send.old.stderr b/src/test/ui/coherence/coherence-impls-send.old.stderr index 024080a621de8..7584b01ca8930 100644 --- a/src/test/ui/coherence/coherence-impls-send.old.stderr +++ b/src/test/ui/coherence/coherence-impls-send.old.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | unsafe impl Send for (MyType, MyType) {} | ^^^^^^^^^^^^^^^^^^^^^---------------- | | | - | | `(MyType, MyType)` is not defined in the current crate because tuples are always foreign + | | this is not defined in the current crate because tuples are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead @@ -21,7 +21,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | unsafe impl Send for [MyType] {} | ^^^^^^^^^^^^^^^^^^^^^-------- | | | - | | `[MyType]` is not defined in the current crate because slices are always foreign + | | this is not defined in the current crate because slices are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead @@ -32,7 +32,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | unsafe impl Send for &'static [NotSync] {} | ^^^^^^^^^^^^^^^^^^^^^------------------ | | | - | | `[NotSync]` is not defined in the current crate because slices are always foreign + | | this is not defined in the current crate because slices are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence-impls-send.re.stderr b/src/test/ui/coherence/coherence-impls-send.re.stderr index 024080a621de8..7584b01ca8930 100644 --- a/src/test/ui/coherence/coherence-impls-send.re.stderr +++ b/src/test/ui/coherence/coherence-impls-send.re.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | unsafe impl Send for (MyType, MyType) {} | ^^^^^^^^^^^^^^^^^^^^^---------------- | | | - | | `(MyType, MyType)` is not defined in the current crate because tuples are always foreign + | | this is not defined in the current crate because tuples are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead @@ -21,7 +21,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | unsafe impl Send for [MyType] {} | ^^^^^^^^^^^^^^^^^^^^^-------- | | | - | | `[MyType]` is not defined in the current crate because slices are always foreign + | | this is not defined in the current crate because slices are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead @@ -32,7 +32,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | unsafe impl Send for &'static [NotSync] {} | ^^^^^^^^^^^^^^^^^^^^^------------------ | | | - | | `[NotSync]` is not defined in the current crate because slices are always foreign + | | this is not defined in the current crate because slices are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence-impls-sized.old.stderr b/src/test/ui/coherence/coherence-impls-sized.old.stderr index 84328d915efba..ef999bcf461bc 100644 --- a/src/test/ui/coherence/coherence-impls-sized.old.stderr +++ b/src/test/ui/coherence/coherence-impls-sized.old.stderr @@ -40,7 +40,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Sized for (MyType, MyType) {} | ^^^^^^^^^^^^^^^---------------- | | | - | | `(MyType, MyType)` is not defined in the current crate because tuples are always foreign + | | this is not defined in the current crate because tuples are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead @@ -51,7 +51,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Sized for [MyType] {} | ^^^^^^^^^^^^^^^-------- | | | - | | `[MyType]` is not defined in the current crate because slices are always foreign + | | this is not defined in the current crate because slices are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead @@ -62,7 +62,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Sized for &'static [NotSync] {} | ^^^^^^^^^^^^^^^------------------ | | | - | | `[NotSync]` is not defined in the current crate because slices are always foreign + | | this is not defined in the current crate because slices are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence-impls-sized.re.stderr b/src/test/ui/coherence/coherence-impls-sized.re.stderr index 84328d915efba..ef999bcf461bc 100644 --- a/src/test/ui/coherence/coherence-impls-sized.re.stderr +++ b/src/test/ui/coherence/coherence-impls-sized.re.stderr @@ -40,7 +40,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Sized for (MyType, MyType) {} | ^^^^^^^^^^^^^^^---------------- | | | - | | `(MyType, MyType)` is not defined in the current crate because tuples are always foreign + | | this is not defined in the current crate because tuples are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead @@ -51,7 +51,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Sized for [MyType] {} | ^^^^^^^^^^^^^^^-------- | | | - | | `[MyType]` is not defined in the current crate because slices are always foreign + | | this is not defined in the current crate because slices are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead @@ -62,7 +62,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Sized for &'static [NotSync] {} | ^^^^^^^^^^^^^^^------------------ | | | - | | `[NotSync]` is not defined in the current crate because slices are always foreign + | | this is not defined in the current crate because slices are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence-orphan.old.stderr b/src/test/ui/coherence/coherence-orphan.old.stderr index 8d3605983179e..a353acf0679dc 100644 --- a/src/test/ui/coherence/coherence-orphan.old.stderr +++ b/src/test/ui/coherence/coherence-orphan.old.stderr @@ -16,7 +16,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl !Send for Vec { } | ^^^^^^^^^^^^^^^---------- | | | - | | `std::vec::Vec` is not defined in the current crate + | | `std::vec::Vec` is not defined in the current crate | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence-orphan.re.stderr b/src/test/ui/coherence/coherence-orphan.re.stderr index 8d3605983179e..a353acf0679dc 100644 --- a/src/test/ui/coherence/coherence-orphan.re.stderr +++ b/src/test/ui/coherence/coherence-orphan.re.stderr @@ -16,7 +16,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl !Send for Vec { } | ^^^^^^^^^^^^^^^---------- | | | - | | `std::vec::Vec` is not defined in the current crate + | | `std::vec::Vec` is not defined in the current crate | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence-overlapping-pairs.re.stderr b/src/test/ui/coherence/coherence-overlapping-pairs.re.stderr index 3b40137064f10..2277b33fcebee 100644 --- a/src/test/ui/coherence/coherence-overlapping-pairs.re.stderr +++ b/src/test/ui/coherence/coherence-overlapping-pairs.re.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Remote for lib::Pair { } | ^^^^^^^^^^^^^^^^^^^---------------- | | | - | | `lib::Pair` is not defined in the current crate + | | `lib::Pair` is not defined in the current crate | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence-pair-covered-uncovered-1.re.stderr b/src/test/ui/coherence/coherence-pair-covered-uncovered-1.re.stderr index db9989c666490..f6e755b666249 100644 --- a/src/test/ui/coherence/coherence-pair-covered-uncovered-1.re.stderr +++ b/src/test/ui/coherence/coherence-pair-covered-uncovered-1.re.stderr @@ -5,7 +5,7 @@ LL | impl Remote1>> for i32 { } | ^^^^^^^^^^^--------------------------^^^^^--- | | | | | | | `i32` is not defined in the current crate - | | `lib::Pair>` is not defined in the current crate + | | `lib::Pair` is not defined in the current crate | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence-pair-covered-uncovered.re.stderr b/src/test/ui/coherence/coherence-pair-covered-uncovered.re.stderr index 44c829669515f..9fa860cb584a1 100644 --- a/src/test/ui/coherence/coherence-pair-covered-uncovered.re.stderr +++ b/src/test/ui/coherence/coherence-pair-covered-uncovered.re.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Remote for Pair> { } | ^^^^^^^^^^^^^^^^^^^^^---------------- | | | - | | `lib::Pair>` is not defined in the current crate + | | `lib::Pair` is not defined in the current crate | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence-vec-local-2.re.stderr b/src/test/ui/coherence/coherence-vec-local-2.re.stderr index 640eb11ee636a..48a2848c55f1b 100644 --- a/src/test/ui/coherence/coherence-vec-local-2.re.stderr +++ b/src/test/ui/coherence/coherence-vec-local-2.re.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Remote for Vec> { } | ^^^^^^^^^^^^^^^^^^^------------- | | | - | | `std::vec::Vec>` is not defined in the current crate + | | `std::vec::Vec` is not defined in the current crate | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence-vec-local.old.stderr b/src/test/ui/coherence/coherence-vec-local.old.stderr index d441f9b25fa88..4b199dd914217 100644 --- a/src/test/ui/coherence/coherence-vec-local.old.stderr +++ b/src/test/ui/coherence/coherence-vec-local.old.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Remote for Vec { } | ^^^^^^^^^^^^^^^^---------- | | | - | | `std::vec::Vec` is not defined in the current crate + | | `std::vec::Vec` is not defined in the current crate | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence-vec-local.re.stderr b/src/test/ui/coherence/coherence-vec-local.re.stderr index d441f9b25fa88..4b199dd914217 100644 --- a/src/test/ui/coherence/coherence-vec-local.re.stderr +++ b/src/test/ui/coherence/coherence-vec-local.re.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Remote for Vec { } | ^^^^^^^^^^^^^^^^---------- | | | - | | `std::vec::Vec` is not defined in the current crate + | | `std::vec::Vec` is not defined in the current crate | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence_local_err_struct.old.stderr b/src/test/ui/coherence/coherence_local_err_struct.old.stderr index 2d94edcd95d7b..0782f82312872 100644 --- a/src/test/ui/coherence/coherence_local_err_struct.old.stderr +++ b/src/test/ui/coherence/coherence_local_err_struct.old.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl lib::MyCopy for lib::MyStruct { } | ^^^^^^^^^^^^^^^^^^^^^--------------------- | | | - | | `lib::MyStruct` is not defined in the current crate + | | `lib::MyStruct` is not defined in the current crate | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence_local_err_struct.re.stderr b/src/test/ui/coherence/coherence_local_err_struct.re.stderr index 2d94edcd95d7b..0782f82312872 100644 --- a/src/test/ui/coherence/coherence_local_err_struct.re.stderr +++ b/src/test/ui/coherence/coherence_local_err_struct.re.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl lib::MyCopy for lib::MyStruct { } | ^^^^^^^^^^^^^^^^^^^^^--------------------- | | | - | | `lib::MyStruct` is not defined in the current crate + | | `lib::MyStruct` is not defined in the current crate | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence_local_err_tuple.old.stderr b/src/test/ui/coherence/coherence_local_err_tuple.old.stderr index 0bc55eff3d218..f01623f76217e 100644 --- a/src/test/ui/coherence/coherence_local_err_tuple.old.stderr +++ b/src/test/ui/coherence/coherence_local_err_tuple.old.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl lib::MyCopy for (MyType,) { } | ^^^^^^^^^^^^^^^^^^^^^--------- | | | - | | `(MyType,)` is not defined in the current crate because tuples are always foreign + | | this is not defined in the current crate because tuples are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/coherence_local_err_tuple.re.stderr b/src/test/ui/coherence/coherence_local_err_tuple.re.stderr index 0bc55eff3d218..f01623f76217e 100644 --- a/src/test/ui/coherence/coherence_local_err_tuple.re.stderr +++ b/src/test/ui/coherence/coherence_local_err_tuple.re.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl lib::MyCopy for (MyType,) { } | ^^^^^^^^^^^^^^^^^^^^^--------- | | | - | | `(MyType,)` is not defined in the current crate because tuples are always foreign + | | this is not defined in the current crate because tuples are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/coherence/impl-foreign-for-foreign.stderr b/src/test/ui/coherence/impl-foreign-for-foreign.stderr index b03a75a77c346..4d7757799e7cd 100644 --- a/src/test/ui/coherence/impl-foreign-for-foreign.stderr +++ b/src/test/ui/coherence/impl-foreign-for-foreign.stderr @@ -2,9 +2,11 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/impl-foreign-for-foreign.rs:12:1 | LL | impl Remote for i32 { - | ^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^--- + | | | + | | `i32` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: the impl does not reference only types defined in this crate = note: define and implement a trait or new type instead error: aborting due to previous error diff --git a/src/test/ui/coherence/impl-foreign-for-foreign[foreign].stderr b/src/test/ui/coherence/impl-foreign-for-foreign[foreign].stderr index bfaec790b20a6..4d15f0db65ffb 100644 --- a/src/test/ui/coherence/impl-foreign-for-foreign[foreign].stderr +++ b/src/test/ui/coherence/impl-foreign-for-foreign[foreign].stderr @@ -2,27 +2,36 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/impl-foreign-for-foreign[foreign].rs:12:1 | LL | impl Remote1> for i32 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^----------------^^^^^--- + | | | | + | | | `i32` is not defined in the current crate + | | `std::rc::Rc` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: the impl does not reference only types defined in this crate = 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/impl-foreign-for-foreign[foreign].rs:16:1 | LL | impl Remote1> for f64 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^------------------^^^^^--- + | | | | + | | | `f64` is not defined in the current crate + | | `std::rc::Rc` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: the impl does not reference only types defined in this crate = 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/impl-foreign-for-foreign[foreign].rs:20:1 | LL | impl Remote1> for f32 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^--------------^^^^^--- + | | | | + | | | `f32` is not defined in the current crate + | | `std::rc::Rc` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: the impl does not reference only types defined in this crate = note: define and implement a trait or new type instead error: aborting due to 3 previous errors diff --git a/src/test/ui/coherence/impl-foreign-for-fundamental[foreign].stderr b/src/test/ui/coherence/impl-foreign-for-fundamental[foreign].stderr index 2ce4921cf938f..d1f4d9849ac31 100644 --- a/src/test/ui/coherence/impl-foreign-for-fundamental[foreign].stderr +++ b/src/test/ui/coherence/impl-foreign-for-fundamental[foreign].stderr @@ -2,18 +2,22 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/impl-foreign-for-fundamental[foreign].rs:12:1 | LL | impl Remote for Box { - | ^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^-------- + | | | + | | `i32` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: the impl does not reference only types defined in this crate = 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/impl-foreign-for-fundamental[foreign].rs:16:1 | LL | impl Remote for Box> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^---------- + | | | + | | `std::rc::Rc` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: the impl does not reference only types defined in this crate = note: define and implement a trait or new type instead error: aborting due to 2 previous errors diff --git a/src/test/ui/coherence/impl-foreign[fundemental[foreign]]-for-foreign.stderr b/src/test/ui/coherence/impl-foreign[fundemental[foreign]]-for-foreign.stderr index bf2361a1718af..8dcac05c0ccb6 100644 --- a/src/test/ui/coherence/impl-foreign[fundemental[foreign]]-for-foreign.stderr +++ b/src/test/ui/coherence/impl-foreign[fundemental[foreign]]-for-foreign.stderr @@ -2,27 +2,36 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/impl-foreign[fundemental[foreign]]-for-foreign.rs:13:1 | LL | impl Remote1> for i32 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^--------------------^^^^^--- + | | | | + | | | `i32` is not defined in the current crate + | | `std::string::String` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: the impl does not reference only types defined in this crate = 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/impl-foreign[fundemental[foreign]]-for-foreign.rs:17:1 | LL | impl Remote1>> for f64 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^---------------------^^^^^--- + | | | | + | | | `f64` is not defined in the current crate + | | `std::rc::Rc` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: the impl does not reference only types defined in this crate = 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/impl-foreign[fundemental[foreign]]-for-foreign.rs:21:1 | LL | impl Remote1>> for f32 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^-------------------^^^^^--- + | | | | + | | | `f32` is not defined in the current crate + | | `std::rc::Rc` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: the impl does not reference only types defined in this crate = note: define and implement a trait or new type instead error: aborting due to 3 previous errors diff --git a/src/test/ui/coherence/impl[t]-foreign-for-foreign[t].stderr b/src/test/ui/coherence/impl[t]-foreign-for-foreign[t].stderr index d7ffcaf76f9a2..7e9d3c6e72927 100644 --- a/src/test/ui/coherence/impl[t]-foreign-for-foreign[t].stderr +++ b/src/test/ui/coherence/impl[t]-foreign-for-foreign[t].stderr @@ -2,18 +2,22 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/impl[t]-foreign-for-foreign[t].rs:13:1 | LL | impl Remote for Rc { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^--------- + | | | + | | `std::rc::Rc` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: the impl does not reference only types defined in this crate = 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/impl[t]-foreign-for-foreign[t].rs:18:1 | LL | impl Remote for Arc { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^------ + | | | + | | `std::sync::Arc` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: the impl does not reference only types defined in this crate = note: define and implement a trait or new type instead error: aborting due to 2 previous errors diff --git a/src/test/ui/coherence/impl[t]-foreign-for-fundamental[t].stderr b/src/test/ui/coherence/impl[t]-foreign-for-fundamental[t].stderr index 20ce11ef9759e..a26b87a326211 100644 --- a/src/test/ui/coherence/impl[t]-foreign-for-fundamental[t].stderr +++ b/src/test/ui/coherence/impl[t]-foreign-for-fundamental[t].stderr @@ -1,8 +1,8 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/impl[t]-foreign-for-fundamental[t].rs:12:1 + --> $DIR/impl[t]-foreign-for-fundamental[t].rs:12:6 | LL | impl Remote for Box { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | ^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/error-codes/E0206.stderr b/src/test/ui/error-codes/E0206.stderr index 7d7336cdff260..e4ad4ffb45fee 100644 --- a/src/test/ui/error-codes/E0206.stderr +++ b/src/test/ui/error-codes/E0206.stderr @@ -16,7 +16,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl Copy for Foo { } | ^^^^^^^^^^^^^^--- | | | - | | `[u8; _]` is not defined in the current crate because arrays are always foreign + | | this is not defined in the current crate because arrays are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/src/test/ui/typeck/typeck-default-trait-impl-cross-crate-coherence.stderr b/src/test/ui/typeck/typeck-default-trait-impl-cross-crate-coherence.stderr index 4773ac7f7dbe9..a54826787da46 100644 --- a/src/test/ui/typeck/typeck-default-trait-impl-cross-crate-coherence.stderr +++ b/src/test/ui/typeck/typeck-default-trait-impl-cross-crate-coherence.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl DefaultedTrait for (A,) { } | ^^^^^^^^^^^^^^^^^^^^^^^^---- | | | - | | `(A,)` is not defined in the current crate because tuples are always foreign + | | this is not defined in the current crate because tuples are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead @@ -15,7 +15,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl !DefaultedTrait for (B,) { } | ^^^^^^^^^^^^^^^^^^^^^^^^^---- | | | - | | `(B,)` is not defined in the current crate because tuples are always foreign + | | this is not defined in the current crate because tuples are always foreign | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead @@ -32,7 +32,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl DefaultedTrait for lib::Something { } | ^^^^^^^^^^^^^^^^^^^^^^^^----------------- | | | - | | `lib::Something` is not defined in the current crate + | | `lib::Something` is not defined in the current crate | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead From 2cd28c15eefba7aaee1541f5325ce2436ceccb13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 27 Oct 2019 10:22:22 -0700 Subject: [PATCH 7/8] add comment --- src/librustc/traits/coherence.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc/traits/coherence.rs b/src/librustc/traits/coherence.rs index edf95bf76125d..ff09c8784fd53 100644 --- a/src/librustc/traits/coherence.rs +++ b/src/librustc/traits/coherence.rs @@ -237,7 +237,7 @@ pub fn trait_ref_is_local_or_fundamental<'tcx>( } pub enum OrphanCheckErr<'tcx> { - NonLocalInputType(Vec<(Ty<'tcx>, bool)>), + NonLocalInputType(Vec<(Ty<'tcx>, bool /* Is this the first input type? */)>), UncoveredTy(Ty<'tcx>), } From 627691f13861b42e3187ad291fcb122053084e2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 28 Oct 2019 10:43:17 -0700 Subject: [PATCH 8/8] Fix rebase --- src/librustc/traits/coherence.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/librustc/traits/coherence.rs b/src/librustc/traits/coherence.rs index ff09c8784fd53..49a4d17d88d03 100644 --- a/src/librustc/traits/coherence.rs +++ b/src/librustc/traits/coherence.rs @@ -378,12 +378,12 @@ fn orphan_check_trait_ref<'tcx>( // Let Ti be the first such type. // - No uncovered type parameters P1..=Pn may appear in T0..Ti (excluding Ti) // - fn uncover_fundamental_ty<'a>( - tcx: TyCtxt<'_>, - ty: Ty<'a>, + fn uncover_fundamental_ty<'tcx>( + tcx: TyCtxt<'tcx>, + ty: Ty<'tcx>, in_crate: InCrate, - ) -> Vec> { - if fundamental_ty(ty) && !ty_is_local(tcx, ty, in_crate) { + ) -> Vec> { + if fundamental_ty(ty) && ty_is_non_local(tcx, ty, in_crate).is_some() { ty.walk_shallow().flat_map(|ty| uncover_fundamental_ty(tcx, ty, in_crate)).collect() } else { vec![ty]