From 093ec70b1e4da3d814a137f5aea6f4ff75ad3399 Mon Sep 17 00:00:00 2001 From: roblabla <unfiltered@roblab.la> Date: Thu, 24 Oct 2019 15:29:29 +0000 Subject: [PATCH 01/30] Add new EFIAPI ABI Adds a new ABI for the EFIAPI calls. This ABI should reflect the latest version of the UEFI specification at the time of commit (UEFI spec 2.8, URL below). The specification says that for x86_64, we should follow the win64 ABI, while on all other supported platforms (ia32, itanium, arm, arm64 and risc-v), we should follow the C ABI. To simplify the implementation, we will simply follow the C ABI on all platforms except x86_64, even those technically unsupported by the UEFI specification. https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf --- src/librustc/ich/impls_syntax.rs | 1 + src/librustc/ty/layout.rs | 1 + src/librustc_target/spec/abi.rs | 2 + src/librustc_target/spec/mod.rs | 7 + src/libsyntax/feature_gate/active.rs | 3 + src/libsyntax/feature_gate/check.rs | 4 + src/libsyntax_pos/symbol.rs | 1 + src/test/codegen/abi-efiapi.rs | 20 ++ src/test/ui/codemap_tests/unicode.stderr | 2 +- src/test/ui/feature-gates/feature-gate-abi.rs | 8 + .../ui/feature-gates/feature-gate-abi.stderr | 203 ++++++++++++------ src/test/ui/parser/issue-8537.stderr | 2 +- 12 files changed, 182 insertions(+), 72 deletions(-) create mode 100644 src/test/codegen/abi-efiapi.rs diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs index dc1f6fd3131bd..aad3cd95506b5 100644 --- a/src/librustc/ich/impls_syntax.rs +++ b/src/librustc/ich/impls_syntax.rs @@ -80,6 +80,7 @@ impl_stable_hash_for!(enum ::rustc_target::spec::abi::Abi { Msp430Interrupt, X86Interrupt, AmdGpuKernel, + EfiApi, Rust, C, System, diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index aed9e87a168ce..e82232ac10f7b 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -2596,6 +2596,7 @@ where // It's the ABI's job to select this, not ours. System => bug!("system abi should be selected elsewhere"), + EfiApi => bug!("eficall abi should be selected elsewhere"), Stdcall => Conv::X86Stdcall, Fastcall => Conv::X86Fastcall, diff --git a/src/librustc_target/spec/abi.rs b/src/librustc_target/spec/abi.rs index 909f0fc53fcea..3a24d30966f63 100644 --- a/src/librustc_target/spec/abi.rs +++ b/src/librustc_target/spec/abi.rs @@ -21,6 +21,7 @@ pub enum Abi { Msp430Interrupt, X86Interrupt, AmdGpuKernel, + EfiApi, // Multiplatform / generic ABIs Rust, @@ -58,6 +59,7 @@ const AbiDatas: &[AbiData] = &[ AbiData {abi: Abi::Msp430Interrupt, name: "msp430-interrupt", generic: false }, AbiData {abi: Abi::X86Interrupt, name: "x86-interrupt", generic: false }, AbiData {abi: Abi::AmdGpuKernel, name: "amdgpu-kernel", generic: false }, + AbiData {abi: Abi::EfiApi, name: "efiapi", generic: false }, // Cross-platform ABIs AbiData {abi: Abi::Rust, name: "Rust", generic: true }, diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index d91588db1834f..e27220cc2f8a4 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -905,6 +905,13 @@ impl Target { abi } }, + Abi::EfiApi => { + if self.arch != "x86_64" { + Abi::Win64 + } else { + Abi::C + } + }, abi => abi } } diff --git a/src/libsyntax/feature_gate/active.rs b/src/libsyntax/feature_gate/active.rs index 1386eac48dae2..5ca2695fe35ad 100644 --- a/src/libsyntax/feature_gate/active.rs +++ b/src/libsyntax/feature_gate/active.rs @@ -531,6 +531,9 @@ declare_features! ( /// Non-object safe trait objects safe to use but cannot be created in safe rust (active, object_safe_for_dispatch, "1.40.0", Some(43561), None), + /// Allows using the `efiapi` ABI. + (active, abi_efiapi, "1.40.0", Some(1), None), + // ------------------------------------------------------------------------- // feature-group-end: actual feature gates // ------------------------------------------------------------------------- diff --git a/src/libsyntax/feature_gate/check.rs b/src/libsyntax/feature_gate/check.rs index 172511f0f099b..e68675a9b8e93 100644 --- a/src/libsyntax/feature_gate/check.rs +++ b/src/libsyntax/feature_gate/check.rs @@ -234,6 +234,10 @@ impl<'a> PostExpansionVisitor<'a> { gate_feature_post!(&self, abi_amdgpu_kernel, span, "amdgpu-kernel ABI is experimental and subject to change"); }, + Abi::EfiApi => { + gate_feature_post!(&self, abi_efiapi, span, + "efiapi ABI is experimental and subject to change"); + }, // Stable Abi::Cdecl | Abi::Stdcall | diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs index 377d2f877b3ad..8ba161f55c1ff 100644 --- a/src/libsyntax_pos/symbol.rs +++ b/src/libsyntax_pos/symbol.rs @@ -110,6 +110,7 @@ symbols! { aarch64_target_feature, abi, abi_amdgpu_kernel, + abi_efiapi, abi_msp430_interrupt, abi_ptx, abi_sysv64, diff --git a/src/test/codegen/abi-efiapi.rs b/src/test/codegen/abi-efiapi.rs new file mode 100644 index 0000000000000..471f572375abc --- /dev/null +++ b/src/test/codegen/abi-efiapi.rs @@ -0,0 +1,20 @@ +// Checks if the correct annotation for the efiapi ABI is passed to llvm. + +// compile-flags: -C no-prepopulate-passes + +#![crate_type = "lib"] +#![feature(abi_efiapi)] + +// CHECK: define win64 i64 @has_efiapi +#[no_mangle] +#[cfg(target_arch = "x86_64")] +pub extern "efiapi" fn has_efiapi(a: i64) -> i64 { + a * 2 +} + +// CHECK: define c i64 @has_efiapi +#[no_mangle] +#[cfg(not(target_arch = "x86_64"))] +pub extern "efiapi" fn has_efiapi(a: i64) -> i64 { + a * 2 +} diff --git a/src/test/ui/codemap_tests/unicode.stderr b/src/test/ui/codemap_tests/unicode.stderr index 1ba578b0c04d3..fc2a0b5950e7d 100644 --- a/src/test/ui/codemap_tests/unicode.stderr +++ b/src/test/ui/codemap_tests/unicode.stderr @@ -4,7 +4,7 @@ error[E0703]: invalid ABI: found `路濫狼á́́` LL | extern "路濫狼á́́" fn foo() {} | ^^^^^^^^^ invalid ABI | - = help: valid ABIs: cdecl, stdcall, fastcall, vectorcall, thiscall, aapcs, win64, sysv64, ptx-kernel, msp430-interrupt, x86-interrupt, amdgpu-kernel, Rust, C, system, rust-intrinsic, rust-call, platform-intrinsic, unadjusted + = help: valid ABIs: cdecl, stdcall, fastcall, vectorcall, thiscall, aapcs, win64, sysv64, ptx-kernel, msp430-interrupt, x86-interrupt, amdgpu-kernel, efiapi, Rust, C, system, rust-intrinsic, rust-call, platform-intrinsic, unadjusted error: aborting due to previous error diff --git a/src/test/ui/feature-gates/feature-gate-abi.rs b/src/test/ui/feature-gates/feature-gate-abi.rs index 61da38eea74b3..e89dc4d5a05a5 100644 --- a/src/test/ui/feature-gates/feature-gate-abi.rs +++ b/src/test/ui/feature-gates/feature-gate-abi.rs @@ -7,6 +7,7 @@ // gate-test-abi_ptx // gate-test-abi_x86_interrupt // gate-test-abi_amdgpu_kernel +// gate-test-abi_efiapi // Functions extern "rust-intrinsic" fn f1() {} //~ ERROR intrinsics are subject to change @@ -20,6 +21,7 @@ extern "ptx-kernel" fn f6() {} //~ ERROR PTX ABIs are experimental and subject t extern "x86-interrupt" fn f7() {} //~ ERROR x86-interrupt ABI is experimental extern "thiscall" fn f8() {} //~ ERROR thiscall is experimental and subject to change extern "amdgpu-kernel" fn f9() {} //~ ERROR amdgpu-kernel ABI is experimental and subject to change +extern "efiapi" fn f10() {} //~ ERROR efiapi ABI is experimental and subject to change // Methods in trait definition trait Tr { @@ -34,6 +36,7 @@ trait Tr { extern "x86-interrupt" fn m7(); //~ ERROR x86-interrupt ABI is experimental extern "thiscall" fn m8(); //~ ERROR thiscall is experimental and subject to change extern "amdgpu-kernel" fn m9(); //~ ERROR amdgpu-kernel ABI is experimental and subject to change + extern "efiapi" fn m10(); //~ ERROR efiapi ABI is experimental and subject to change extern "vectorcall" fn dm3() {} //~ ERROR vectorcall is experimental and subject to change extern "rust-call" fn dm4() {} //~ ERROR rust-call ABI is subject to change @@ -42,6 +45,7 @@ trait Tr { extern "x86-interrupt" fn dm7() {} //~ ERROR x86-interrupt ABI is experimental extern "thiscall" fn dm8() {} //~ ERROR thiscall is experimental and subject to change extern "amdgpu-kernel" fn dm9() {} //~ ERROR amdgpu-kernel ABI is experimental and subject to change + extern "efiapi" fn dm10() {} //~ ERROR efiapi ABI is experimental and subject to change } struct S; @@ -59,6 +63,7 @@ impl Tr for S { extern "x86-interrupt" fn m7() {} //~ ERROR x86-interrupt ABI is experimental extern "thiscall" fn m8() {} //~ ERROR thiscall is experimental and subject to change extern "amdgpu-kernel" fn m9() {} //~ ERROR amdgpu-kernel ABI is experimental and subject to change + extern "efiapi" fn m10() {} //~ ERROR efiapi ABI is experimental and subject to change } // Methods in inherent impl @@ -74,6 +79,7 @@ impl S { extern "x86-interrupt" fn im7() {} //~ ERROR x86-interrupt ABI is experimental extern "thiscall" fn im8() {} //~ ERROR thiscall is experimental and subject to change extern "amdgpu-kernel" fn im9() {} //~ ERROR amdgpu-kernel ABI is experimental and subject to change + extern "efiapi" fn im10() {} //~ ERROR efiapi ABI is experimental and subject to change } // Function pointer types @@ -86,6 +92,7 @@ type A6 = extern "ptx-kernel" fn (); //~ ERROR PTX ABIs are experimental and sub type A7 = extern "x86-interrupt" fn(); //~ ERROR x86-interrupt ABI is experimental type A8 = extern "thiscall" fn(); //~ ERROR thiscall is experimental and subject to change type A9 = extern "amdgpu-kernel" fn(); //~ ERROR amdgpu-kernel ABI is experimental and subject to change +type A10 = extern "efiapi" fn(); //~ ERROR efiapi ABI is experimental and subject to change // Foreign modules extern "rust-intrinsic" {} //~ ERROR intrinsics are subject to change @@ -97,5 +104,6 @@ extern "ptx-kernel" {} //~ ERROR PTX ABIs are experimental and subject to change extern "x86-interrupt" {} //~ ERROR x86-interrupt ABI is experimental extern "thiscall" {} //~ ERROR thiscall is experimental and subject to change extern "amdgpu-kernel" {} //~ ERROR amdgpu-kernel ABI is experimental and subject to change +extern "efiapi" {} //~ ERROR efiapi ABI is experimental and subject to change fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-abi.stderr b/src/test/ui/feature-gates/feature-gate-abi.stderr index afda76dc2b0aa..22b6ee4cd1504 100644 --- a/src/test/ui/feature-gates/feature-gate-abi.stderr +++ b/src/test/ui/feature-gates/feature-gate-abi.stderr @@ -1,5 +1,5 @@ error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-abi.rs:12:1 + --> $DIR/feature-gate-abi.rs:13:1 | LL | extern "rust-intrinsic" fn f1() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | extern "rust-intrinsic" fn f1() {} = help: add `#![feature(intrinsics)]` to the crate attributes to enable error[E0658]: platform intrinsics are experimental and possibly buggy - --> $DIR/feature-gate-abi.rs:14:1 + --> $DIR/feature-gate-abi.rs:15:1 | LL | extern "platform-intrinsic" fn f2() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -16,7 +16,7 @@ LL | extern "platform-intrinsic" fn f2() {} = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable error[E0658]: vectorcall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:16:1 + --> $DIR/feature-gate-abi.rs:17:1 | LL | extern "vectorcall" fn f3() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -24,7 +24,7 @@ LL | extern "vectorcall" fn f3() {} = help: add `#![feature(abi_vectorcall)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:17:1 + --> $DIR/feature-gate-abi.rs:18:1 | LL | extern "rust-call" fn f4() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | extern "rust-call" fn f4() {} = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable error[E0658]: msp430-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:18:1 + --> $DIR/feature-gate-abi.rs:19:1 | LL | extern "msp430-interrupt" fn f5() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -42,7 +42,7 @@ LL | extern "msp430-interrupt" fn f5() {} = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable error[E0658]: PTX ABIs are experimental and subject to change - --> $DIR/feature-gate-abi.rs:19:1 + --> $DIR/feature-gate-abi.rs:20:1 | LL | extern "ptx-kernel" fn f6() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -51,7 +51,7 @@ LL | extern "ptx-kernel" fn f6() {} = help: add `#![feature(abi_ptx)]` to the crate attributes to enable error[E0658]: x86-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:20:1 + --> $DIR/feature-gate-abi.rs:21:1 | LL | extern "x86-interrupt" fn f7() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -60,7 +60,7 @@ LL | extern "x86-interrupt" fn f7() {} = help: add `#![feature(abi_x86_interrupt)]` to the crate attributes to enable error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:21:1 + --> $DIR/feature-gate-abi.rs:22:1 | LL | extern "thiscall" fn f8() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -68,7 +68,7 @@ LL | extern "thiscall" fn f8() {} = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: amdgpu-kernel ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:22:1 + --> $DIR/feature-gate-abi.rs:23:1 | LL | extern "amdgpu-kernel" fn f9() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -76,8 +76,17 @@ LL | extern "amdgpu-kernel" fn f9() {} = note: for more information, see https://github.com/rust-lang/rust/issues/51575 = help: add `#![feature(abi_amdgpu_kernel)]` to the crate attributes to enable +error[E0658]: efiapi ABI is experimental and subject to change + --> $DIR/feature-gate-abi.rs:24:1 + | +LL | extern "efiapi" fn f10() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/1 + = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable + error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-abi.rs:26:5 + --> $DIR/feature-gate-abi.rs:28:5 | LL | extern "rust-intrinsic" fn m1(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -85,7 +94,7 @@ LL | extern "rust-intrinsic" fn m1(); = help: add `#![feature(intrinsics)]` to the crate attributes to enable error[E0658]: platform intrinsics are experimental and possibly buggy - --> $DIR/feature-gate-abi.rs:28:5 + --> $DIR/feature-gate-abi.rs:30:5 | LL | extern "platform-intrinsic" fn m2(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -94,7 +103,7 @@ LL | extern "platform-intrinsic" fn m2(); = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable error[E0658]: vectorcall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:30:5 + --> $DIR/feature-gate-abi.rs:32:5 | LL | extern "vectorcall" fn m3(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -102,7 +111,7 @@ LL | extern "vectorcall" fn m3(); = help: add `#![feature(abi_vectorcall)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:31:5 + --> $DIR/feature-gate-abi.rs:33:5 | LL | extern "rust-call" fn m4(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -111,7 +120,7 @@ LL | extern "rust-call" fn m4(); = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable error[E0658]: msp430-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:32:5 + --> $DIR/feature-gate-abi.rs:34:5 | LL | extern "msp430-interrupt" fn m5(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -120,7 +129,7 @@ LL | extern "msp430-interrupt" fn m5(); = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable error[E0658]: PTX ABIs are experimental and subject to change - --> $DIR/feature-gate-abi.rs:33:5 + --> $DIR/feature-gate-abi.rs:35:5 | LL | extern "ptx-kernel" fn m6(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -129,7 +138,7 @@ LL | extern "ptx-kernel" fn m6(); = help: add `#![feature(abi_ptx)]` to the crate attributes to enable error[E0658]: x86-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:34:5 + --> $DIR/feature-gate-abi.rs:36:5 | LL | extern "x86-interrupt" fn m7(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -138,7 +147,7 @@ LL | extern "x86-interrupt" fn m7(); = help: add `#![feature(abi_x86_interrupt)]` to the crate attributes to enable error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:35:5 + --> $DIR/feature-gate-abi.rs:37:5 | LL | extern "thiscall" fn m8(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -146,7 +155,7 @@ LL | extern "thiscall" fn m8(); = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: amdgpu-kernel ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:36:5 + --> $DIR/feature-gate-abi.rs:38:5 | LL | extern "amdgpu-kernel" fn m9(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -154,8 +163,17 @@ LL | extern "amdgpu-kernel" fn m9(); = note: for more information, see https://github.com/rust-lang/rust/issues/51575 = help: add `#![feature(abi_amdgpu_kernel)]` to the crate attributes to enable +error[E0658]: efiapi ABI is experimental and subject to change + --> $DIR/feature-gate-abi.rs:39:5 + | +LL | extern "efiapi" fn m10(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/1 + = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable + error[E0658]: vectorcall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:38:5 + --> $DIR/feature-gate-abi.rs:41:5 | LL | extern "vectorcall" fn dm3() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -163,7 +181,7 @@ LL | extern "vectorcall" fn dm3() {} = help: add `#![feature(abi_vectorcall)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:39:5 + --> $DIR/feature-gate-abi.rs:42:5 | LL | extern "rust-call" fn dm4() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -172,7 +190,7 @@ LL | extern "rust-call" fn dm4() {} = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable error[E0658]: msp430-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:40:5 + --> $DIR/feature-gate-abi.rs:43:5 | LL | extern "msp430-interrupt" fn dm5() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -181,7 +199,7 @@ LL | extern "msp430-interrupt" fn dm5() {} = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable error[E0658]: PTX ABIs are experimental and subject to change - --> $DIR/feature-gate-abi.rs:41:5 + --> $DIR/feature-gate-abi.rs:44:5 | LL | extern "ptx-kernel" fn dm6() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -190,7 +208,7 @@ LL | extern "ptx-kernel" fn dm6() {} = help: add `#![feature(abi_ptx)]` to the crate attributes to enable error[E0658]: x86-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:42:5 + --> $DIR/feature-gate-abi.rs:45:5 | LL | extern "x86-interrupt" fn dm7() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -199,7 +217,7 @@ LL | extern "x86-interrupt" fn dm7() {} = help: add `#![feature(abi_x86_interrupt)]` to the crate attributes to enable error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:43:5 + --> $DIR/feature-gate-abi.rs:46:5 | LL | extern "thiscall" fn dm8() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -207,7 +225,7 @@ LL | extern "thiscall" fn dm8() {} = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: amdgpu-kernel ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:44:5 + --> $DIR/feature-gate-abi.rs:47:5 | LL | extern "amdgpu-kernel" fn dm9() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -215,8 +233,17 @@ LL | extern "amdgpu-kernel" fn dm9() {} = note: for more information, see https://github.com/rust-lang/rust/issues/51575 = help: add `#![feature(abi_amdgpu_kernel)]` to the crate attributes to enable +error[E0658]: efiapi ABI is experimental and subject to change + --> $DIR/feature-gate-abi.rs:48:5 + | +LL | extern "efiapi" fn dm10() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/1 + = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable + error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-abi.rs:51:5 + --> $DIR/feature-gate-abi.rs:55:5 | LL | extern "rust-intrinsic" fn m1() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -224,7 +251,7 @@ LL | extern "rust-intrinsic" fn m1() {} = help: add `#![feature(intrinsics)]` to the crate attributes to enable error[E0658]: platform intrinsics are experimental and possibly buggy - --> $DIR/feature-gate-abi.rs:53:5 + --> $DIR/feature-gate-abi.rs:57:5 | LL | extern "platform-intrinsic" fn m2() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -233,7 +260,7 @@ LL | extern "platform-intrinsic" fn m2() {} = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable error[E0658]: vectorcall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:55:5 + --> $DIR/feature-gate-abi.rs:59:5 | LL | extern "vectorcall" fn m3() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -241,7 +268,7 @@ LL | extern "vectorcall" fn m3() {} = help: add `#![feature(abi_vectorcall)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:56:5 + --> $DIR/feature-gate-abi.rs:60:5 | LL | extern "rust-call" fn m4() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -250,7 +277,7 @@ LL | extern "rust-call" fn m4() {} = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable error[E0658]: msp430-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:57:5 + --> $DIR/feature-gate-abi.rs:61:5 | LL | extern "msp430-interrupt" fn m5() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -259,7 +286,7 @@ LL | extern "msp430-interrupt" fn m5() {} = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable error[E0658]: PTX ABIs are experimental and subject to change - --> $DIR/feature-gate-abi.rs:58:5 + --> $DIR/feature-gate-abi.rs:62:5 | LL | extern "ptx-kernel" fn m6() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -268,7 +295,7 @@ LL | extern "ptx-kernel" fn m6() {} = help: add `#![feature(abi_ptx)]` to the crate attributes to enable error[E0658]: x86-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:59:5 + --> $DIR/feature-gate-abi.rs:63:5 | LL | extern "x86-interrupt" fn m7() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -277,7 +304,7 @@ LL | extern "x86-interrupt" fn m7() {} = help: add `#![feature(abi_x86_interrupt)]` to the crate attributes to enable error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:60:5 + --> $DIR/feature-gate-abi.rs:64:5 | LL | extern "thiscall" fn m8() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -285,7 +312,7 @@ LL | extern "thiscall" fn m8() {} = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: amdgpu-kernel ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:61:5 + --> $DIR/feature-gate-abi.rs:65:5 | LL | extern "amdgpu-kernel" fn m9() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -293,16 +320,25 @@ LL | extern "amdgpu-kernel" fn m9() {} = note: for more information, see https://github.com/rust-lang/rust/issues/51575 = help: add `#![feature(abi_amdgpu_kernel)]` to the crate attributes to enable -error[E0658]: intrinsics are subject to change +error[E0658]: efiapi ABI is experimental and subject to change --> $DIR/feature-gate-abi.rs:66:5 | +LL | extern "efiapi" fn m10() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/1 + = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable + +error[E0658]: intrinsics are subject to change + --> $DIR/feature-gate-abi.rs:71:5 + | LL | extern "rust-intrinsic" fn im1() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: add `#![feature(intrinsics)]` to the crate attributes to enable error[E0658]: platform intrinsics are experimental and possibly buggy - --> $DIR/feature-gate-abi.rs:68:5 + --> $DIR/feature-gate-abi.rs:73:5 | LL | extern "platform-intrinsic" fn im2() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -311,7 +347,7 @@ LL | extern "platform-intrinsic" fn im2() {} = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable error[E0658]: vectorcall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:70:5 + --> $DIR/feature-gate-abi.rs:75:5 | LL | extern "vectorcall" fn im3() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -319,7 +355,7 @@ LL | extern "vectorcall" fn im3() {} = help: add `#![feature(abi_vectorcall)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:71:5 + --> $DIR/feature-gate-abi.rs:76:5 | LL | extern "rust-call" fn im4() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -328,7 +364,7 @@ LL | extern "rust-call" fn im4() {} = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable error[E0658]: msp430-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:72:5 + --> $DIR/feature-gate-abi.rs:77:5 | LL | extern "msp430-interrupt" fn im5() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -337,7 +373,7 @@ LL | extern "msp430-interrupt" fn im5() {} = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable error[E0658]: PTX ABIs are experimental and subject to change - --> $DIR/feature-gate-abi.rs:73:5 + --> $DIR/feature-gate-abi.rs:78:5 | LL | extern "ptx-kernel" fn im6() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -346,7 +382,7 @@ LL | extern "ptx-kernel" fn im6() {} = help: add `#![feature(abi_ptx)]` to the crate attributes to enable error[E0658]: x86-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:74:5 + --> $DIR/feature-gate-abi.rs:79:5 | LL | extern "x86-interrupt" fn im7() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -355,7 +391,7 @@ LL | extern "x86-interrupt" fn im7() {} = help: add `#![feature(abi_x86_interrupt)]` to the crate attributes to enable error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:75:5 + --> $DIR/feature-gate-abi.rs:80:5 | LL | extern "thiscall" fn im8() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -363,7 +399,7 @@ LL | extern "thiscall" fn im8() {} = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: amdgpu-kernel ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:76:5 + --> $DIR/feature-gate-abi.rs:81:5 | LL | extern "amdgpu-kernel" fn im9() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -371,8 +407,17 @@ LL | extern "amdgpu-kernel" fn im9() {} = note: for more information, see https://github.com/rust-lang/rust/issues/51575 = help: add `#![feature(abi_amdgpu_kernel)]` to the crate attributes to enable +error[E0658]: efiapi ABI is experimental and subject to change + --> $DIR/feature-gate-abi.rs:82:5 + | +LL | extern "efiapi" fn im10() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/1 + = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable + error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-abi.rs:80:11 + --> $DIR/feature-gate-abi.rs:86:11 | LL | type A1 = extern "rust-intrinsic" fn(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -380,7 +425,7 @@ LL | type A1 = extern "rust-intrinsic" fn(); = help: add `#![feature(intrinsics)]` to the crate attributes to enable error[E0658]: platform intrinsics are experimental and possibly buggy - --> $DIR/feature-gate-abi.rs:81:11 + --> $DIR/feature-gate-abi.rs:87:11 | LL | type A2 = extern "platform-intrinsic" fn(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -389,7 +434,7 @@ LL | type A2 = extern "platform-intrinsic" fn(); = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable error[E0658]: vectorcall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:82:11 + --> $DIR/feature-gate-abi.rs:88:11 | LL | type A3 = extern "vectorcall" fn(); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -397,7 +442,7 @@ LL | type A3 = extern "vectorcall" fn(); = help: add `#![feature(abi_vectorcall)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:83:11 + --> $DIR/feature-gate-abi.rs:89:11 | LL | type A4 = extern "rust-call" fn(); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -406,7 +451,7 @@ LL | type A4 = extern "rust-call" fn(); = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable error[E0658]: msp430-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:84:11 + --> $DIR/feature-gate-abi.rs:90:11 | LL | type A5 = extern "msp430-interrupt" fn(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -415,7 +460,7 @@ LL | type A5 = extern "msp430-interrupt" fn(); = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable error[E0658]: PTX ABIs are experimental and subject to change - --> $DIR/feature-gate-abi.rs:85:11 + --> $DIR/feature-gate-abi.rs:91:11 | LL | type A6 = extern "ptx-kernel" fn (); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -424,7 +469,7 @@ LL | type A6 = extern "ptx-kernel" fn (); = help: add `#![feature(abi_ptx)]` to the crate attributes to enable error[E0658]: x86-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:86:11 + --> $DIR/feature-gate-abi.rs:92:11 | LL | type A7 = extern "x86-interrupt" fn(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -433,7 +478,7 @@ LL | type A7 = extern "x86-interrupt" fn(); = help: add `#![feature(abi_x86_interrupt)]` to the crate attributes to enable error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:87:11 + --> $DIR/feature-gate-abi.rs:93:11 | LL | type A8 = extern "thiscall" fn(); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -441,7 +486,7 @@ LL | type A8 = extern "thiscall" fn(); = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: amdgpu-kernel ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:88:11 + --> $DIR/feature-gate-abi.rs:94:11 | LL | type A9 = extern "amdgpu-kernel" fn(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -449,8 +494,17 @@ LL | type A9 = extern "amdgpu-kernel" fn(); = note: for more information, see https://github.com/rust-lang/rust/issues/51575 = help: add `#![feature(abi_amdgpu_kernel)]` to the crate attributes to enable +error[E0658]: efiapi ABI is experimental and subject to change + --> $DIR/feature-gate-abi.rs:95:12 + | +LL | type A10 = extern "efiapi" fn(); + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/1 + = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable + error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-abi.rs:91:1 + --> $DIR/feature-gate-abi.rs:98:1 | LL | extern "rust-intrinsic" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -458,7 +512,7 @@ LL | extern "rust-intrinsic" {} = help: add `#![feature(intrinsics)]` to the crate attributes to enable error[E0658]: platform intrinsics are experimental and possibly buggy - --> $DIR/feature-gate-abi.rs:92:1 + --> $DIR/feature-gate-abi.rs:99:1 | LL | extern "platform-intrinsic" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -467,7 +521,7 @@ LL | extern "platform-intrinsic" {} = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable error[E0658]: vectorcall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:93:1 + --> $DIR/feature-gate-abi.rs:100:1 | LL | extern "vectorcall" {} | ^^^^^^^^^^^^^^^^^^^^^^ @@ -475,7 +529,7 @@ LL | extern "vectorcall" {} = help: add `#![feature(abi_vectorcall)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:94:1 + --> $DIR/feature-gate-abi.rs:101:1 | LL | extern "rust-call" {} | ^^^^^^^^^^^^^^^^^^^^^ @@ -484,7 +538,7 @@ LL | extern "rust-call" {} = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable error[E0658]: msp430-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:95:1 + --> $DIR/feature-gate-abi.rs:102:1 | LL | extern "msp430-interrupt" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -493,7 +547,7 @@ LL | extern "msp430-interrupt" {} = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable error[E0658]: PTX ABIs are experimental and subject to change - --> $DIR/feature-gate-abi.rs:96:1 + --> $DIR/feature-gate-abi.rs:103:1 | LL | extern "ptx-kernel" {} | ^^^^^^^^^^^^^^^^^^^^^^ @@ -502,7 +556,7 @@ LL | extern "ptx-kernel" {} = help: add `#![feature(abi_ptx)]` to the crate attributes to enable error[E0658]: x86-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:97:1 + --> $DIR/feature-gate-abi.rs:104:1 | LL | extern "x86-interrupt" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -511,7 +565,7 @@ LL | extern "x86-interrupt" {} = help: add `#![feature(abi_x86_interrupt)]` to the crate attributes to enable error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:98:1 + --> $DIR/feature-gate-abi.rs:105:1 | LL | extern "thiscall" {} | ^^^^^^^^^^^^^^^^^^^^ @@ -519,7 +573,7 @@ LL | extern "thiscall" {} = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: amdgpu-kernel ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:99:1 + --> $DIR/feature-gate-abi.rs:106:1 | LL | extern "amdgpu-kernel" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -527,54 +581,63 @@ LL | extern "amdgpu-kernel" {} = note: for more information, see https://github.com/rust-lang/rust/issues/51575 = help: add `#![feature(abi_amdgpu_kernel)]` to the crate attributes to enable +error[E0658]: efiapi ABI is experimental and subject to change + --> $DIR/feature-gate-abi.rs:107:1 + | +LL | extern "efiapi" {} + | ^^^^^^^^^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/1 + = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable + error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:26:32 + --> $DIR/feature-gate-abi.rs:28:32 | LL | extern "rust-intrinsic" fn m1(); | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:28:36 + --> $DIR/feature-gate-abi.rs:30:36 | LL | extern "platform-intrinsic" fn m2(); | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:12:33 + --> $DIR/feature-gate-abi.rs:13:33 | LL | extern "rust-intrinsic" fn f1() {} | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:14:37 + --> $DIR/feature-gate-abi.rs:15:37 | LL | extern "platform-intrinsic" fn f2() {} | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:51:37 + --> $DIR/feature-gate-abi.rs:55:37 | LL | extern "rust-intrinsic" fn m1() {} | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:53:41 + --> $DIR/feature-gate-abi.rs:57:41 | LL | extern "platform-intrinsic" fn m2() {} | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:66:38 + --> $DIR/feature-gate-abi.rs:71:38 | LL | extern "rust-intrinsic" fn im1() {} | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:68:42 + --> $DIR/feature-gate-abi.rs:73:42 | LL | extern "platform-intrinsic" fn im2() {} | ^^ -error: aborting due to 69 previous errors +error: aborting due to 76 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/parser/issue-8537.stderr b/src/test/ui/parser/issue-8537.stderr index 29a68c9e1c375..b20226f87e8f8 100644 --- a/src/test/ui/parser/issue-8537.stderr +++ b/src/test/ui/parser/issue-8537.stderr @@ -4,7 +4,7 @@ error[E0703]: invalid ABI: found `invalid-ab_isize` LL | "invalid-ab_isize" | ^^^^^^^^^^^^^^^^^^ invalid ABI | - = help: valid ABIs: cdecl, stdcall, fastcall, vectorcall, thiscall, aapcs, win64, sysv64, ptx-kernel, msp430-interrupt, x86-interrupt, amdgpu-kernel, Rust, C, system, rust-intrinsic, rust-call, platform-intrinsic, unadjusted + = help: valid ABIs: cdecl, stdcall, fastcall, vectorcall, thiscall, aapcs, win64, sysv64, ptx-kernel, msp430-interrupt, x86-interrupt, amdgpu-kernel, efiapi, Rust, C, system, rust-intrinsic, rust-call, platform-intrinsic, unadjusted error: aborting due to previous error From 61732804e215d251f12802445edc43861c1f55e7 Mon Sep 17 00:00:00 2001 From: roblabla <unfiltered@roblab.la> Date: Fri, 25 Oct 2019 14:44:21 +0000 Subject: [PATCH 02/30] Fix EFIABI test Use revisions to run the EFIABI in multiple configurations, compiling for each supported UEFI platform, and checking the ABI generated in the LLVM IR is correct. Use no_core to make it easier to test. --- src/test/codegen/abi-efiapi.rs | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/test/codegen/abi-efiapi.rs b/src/test/codegen/abi-efiapi.rs index 471f572375abc..cfd31ef1a31fd 100644 --- a/src/test/codegen/abi-efiapi.rs +++ b/src/test/codegen/abi-efiapi.rs @@ -1,20 +1,29 @@ // Checks if the correct annotation for the efiapi ABI is passed to llvm. +// revisions:x86_64 i686 aarch64 arm riscv + +//[x86_64] compile-flags: --target x86_64-unknown-uefi +//[i686] compile-flags: --target i686-unknown-linux-musl +//[aarch64] compile-flags: --target aarch64-unknown-none +//[arm] compile-flags: --target armv7r-none-eabi +//[riscv] compile-flags: --target riscv64gc-unknown-none-elf // compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] -#![feature(abi_efiapi)] +#![feature(no_core, lang_items, abi_efiapi)] +#![no_core] -// CHECK: define win64 i64 @has_efiapi -#[no_mangle] -#[cfg(target_arch = "x86_64")] -pub extern "efiapi" fn has_efiapi(a: i64) -> i64 { - a * 2 -} +#[lang="sized"] +trait Sized { } +#[lang="freeze"] +trait Freeze { } +#[lang="copy"] +trait Copy { } -// CHECK: define c i64 @has_efiapi +//x86_64: define win64cc void @has_efiapi +//i686: define void @has_efiapi +//aarch64: define void @has_efiapi +//arm: define void @has_efiapi +//riscv: define void @has_efiapi #[no_mangle] -#[cfg(not(target_arch = "x86_64"))] -pub extern "efiapi" fn has_efiapi(a: i64) -> i64 { - a * 2 -} +pub extern "efiapi" fn has_efiapi() {} From 13d27aff11f6e261bba4a8f5168e1cc7aa737764 Mon Sep 17 00:00:00 2001 From: roblabla <unfiltered@roblab.la> Date: Fri, 25 Oct 2019 14:50:51 +0000 Subject: [PATCH 03/30] Fix inverted check in EFIAPI --- src/librustc_target/spec/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index e27220cc2f8a4..6033d52c44112 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -906,7 +906,7 @@ impl Target { } }, Abi::EfiApi => { - if self.arch != "x86_64" { + if self.arch == "x86_64" { Abi::Win64 } else { Abi::C From e54ae5126c669853465178c98745e23a5d87d0a9 Mon Sep 17 00:00:00 2001 From: roblabla <unfiltered@roblab.la> Date: Fri, 25 Oct 2019 15:08:28 +0000 Subject: [PATCH 04/30] Add proper tracking issue for EFIAPI --- src/libsyntax/feature_gate/active.rs | 2 +- src/test/ui/feature-gates/feature-gate-abi.stderr | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libsyntax/feature_gate/active.rs b/src/libsyntax/feature_gate/active.rs index 5ca2695fe35ad..586b1b42fcdff 100644 --- a/src/libsyntax/feature_gate/active.rs +++ b/src/libsyntax/feature_gate/active.rs @@ -532,7 +532,7 @@ declare_features! ( (active, object_safe_for_dispatch, "1.40.0", Some(43561), None), /// Allows using the `efiapi` ABI. - (active, abi_efiapi, "1.40.0", Some(1), None), + (active, abi_efiapi, "1.40.0", Some(65815), None), // ------------------------------------------------------------------------- // feature-group-end: actual feature gates diff --git a/src/test/ui/feature-gates/feature-gate-abi.stderr b/src/test/ui/feature-gates/feature-gate-abi.stderr index 22b6ee4cd1504..0f2622f106595 100644 --- a/src/test/ui/feature-gates/feature-gate-abi.stderr +++ b/src/test/ui/feature-gates/feature-gate-abi.stderr @@ -82,7 +82,7 @@ error[E0658]: efiapi ABI is experimental and subject to change LL | extern "efiapi" fn f10() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: for more information, see https://github.com/rust-lang/rust/issues/1 + = note: for more information, see https://github.com/rust-lang/rust/issues/65815 = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable error[E0658]: intrinsics are subject to change @@ -169,7 +169,7 @@ error[E0658]: efiapi ABI is experimental and subject to change LL | extern "efiapi" fn m10(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: for more information, see https://github.com/rust-lang/rust/issues/1 + = note: for more information, see https://github.com/rust-lang/rust/issues/65815 = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable error[E0658]: vectorcall is experimental and subject to change @@ -239,7 +239,7 @@ error[E0658]: efiapi ABI is experimental and subject to change LL | extern "efiapi" fn dm10() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: for more information, see https://github.com/rust-lang/rust/issues/1 + = note: for more information, see https://github.com/rust-lang/rust/issues/65815 = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable error[E0658]: intrinsics are subject to change @@ -326,7 +326,7 @@ error[E0658]: efiapi ABI is experimental and subject to change LL | extern "efiapi" fn m10() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: for more information, see https://github.com/rust-lang/rust/issues/1 + = note: for more information, see https://github.com/rust-lang/rust/issues/65815 = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable error[E0658]: intrinsics are subject to change @@ -413,7 +413,7 @@ error[E0658]: efiapi ABI is experimental and subject to change LL | extern "efiapi" fn im10() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: for more information, see https://github.com/rust-lang/rust/issues/1 + = note: for more information, see https://github.com/rust-lang/rust/issues/65815 = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable error[E0658]: intrinsics are subject to change @@ -500,7 +500,7 @@ error[E0658]: efiapi ABI is experimental and subject to change LL | type A10 = extern "efiapi" fn(); | ^^^^^^^^^^^^^^^^^^^^ | - = note: for more information, see https://github.com/rust-lang/rust/issues/1 + = note: for more information, see https://github.com/rust-lang/rust/issues/65815 = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable error[E0658]: intrinsics are subject to change @@ -587,7 +587,7 @@ error[E0658]: efiapi ABI is experimental and subject to change LL | extern "efiapi" {} | ^^^^^^^^^^^^^^^^^^ | - = note: for more information, see https://github.com/rust-lang/rust/issues/1 + = note: for more information, see https://github.com/rust-lang/rust/issues/65815 = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable error: intrinsic must be in `extern "rust-intrinsic" { ... }` block From 174d4f9caf6d935feb631264e96444131dffca17 Mon Sep 17 00:00:00 2001 From: roblabla <unfiltered@roblab.la> Date: Fri, 25 Oct 2019 18:49:55 +0000 Subject: [PATCH 05/30] EFIAPI: Fix symbolname tests --- src/test/ui/symbol-names/basic.legacy.stderr | 4 ++-- src/test/ui/symbol-names/impl1.legacy.stderr | 12 ++++++------ src/test/ui/symbol-names/issue-60925.legacy.stderr | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/test/ui/symbol-names/basic.legacy.stderr b/src/test/ui/symbol-names/basic.legacy.stderr index e26168dcfc488..52e777285eb30 100644 --- a/src/test/ui/symbol-names/basic.legacy.stderr +++ b/src/test/ui/symbol-names/basic.legacy.stderr @@ -1,10 +1,10 @@ -error: symbol-name(_ZN5basic4main17hd72940ef9669d526E) +error: symbol-name(_ZN5basic4main17h81759b0695851718E) --> $DIR/basic.rs:7:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling(basic::main::hd72940ef9669d526) +error: demangling(basic::main::h81759b0695851718) --> $DIR/basic.rs:7:1 | LL | #[rustc_symbol_name] diff --git a/src/test/ui/symbol-names/impl1.legacy.stderr b/src/test/ui/symbol-names/impl1.legacy.stderr index 610937739c194..b27df10e7503b 100644 --- a/src/test/ui/symbol-names/impl1.legacy.stderr +++ b/src/test/ui/symbol-names/impl1.legacy.stderr @@ -1,10 +1,10 @@ -error: symbol-name(_ZN5impl13foo3Foo3bar17he53b9bee7600ed8dE) +error: symbol-name(_ZN5impl13foo3Foo3bar17h92cf46db76791039E) --> $DIR/impl1.rs:13:9 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling(impl1::foo::Foo::bar::he53b9bee7600ed8d) +error: demangling(impl1::foo::Foo::bar::h92cf46db76791039) --> $DIR/impl1.rs:13:9 | LL | #[rustc_symbol_name] @@ -22,13 +22,13 @@ error: def-path(foo::Foo::bar) LL | #[rustc_def_path] | ^^^^^^^^^^^^^^^^^ -error: symbol-name(_ZN5impl13bar33_$LT$impl$u20$impl1..foo..Foo$GT$3baz17h86c41f0462d901d4E) +error: symbol-name(_ZN5impl13bar33_$LT$impl$u20$impl1..foo..Foo$GT$3baz17h90c4a800b1aa0df0E) --> $DIR/impl1.rs:31:9 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling(impl1::bar::<impl impl1::foo::Foo>::baz::h86c41f0462d901d4) +error: demangling(impl1::bar::<impl impl1::foo::Foo>::baz::h90c4a800b1aa0df0) --> $DIR/impl1.rs:31:9 | LL | #[rustc_symbol_name] @@ -46,13 +46,13 @@ error: def-path(bar::<impl foo::Foo>::baz) LL | #[rustc_def_path] | ^^^^^^^^^^^^^^^^^ -error: symbol-name(_ZN209_$LT$$u5b$$RF$dyn$u20$impl1..Foo$u2b$Assoc$u20$$u3d$$u20$extern$u20$$u22$C$u22$$u20$fn$LP$$RF$u8$C$$u20$...$RP$$u2b$impl1..AutoTrait$u3b$$u20$_$u5d$$u20$as$u20$impl1..main..$u7b$$u7b$closure$u7d$$u7d$..Bar$GT$6method17h636bc933fc62ee2fE) +error: symbol-name(_ZN209_$LT$$u5b$$RF$dyn$u20$impl1..Foo$u2b$Assoc$u20$$u3d$$u20$extern$u20$$u22$C$u22$$u20$fn$LP$$RF$u8$C$$u20$...$RP$$u2b$impl1..AutoTrait$u3b$$u20$_$u5d$$u20$as$u20$impl1..main..$u7b$$u7b$closure$u7d$$u7d$..Bar$GT$6method17h61b0fcb05ebeeb79E) --> $DIR/impl1.rs:61:13 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling(<[&dyn impl1::Foo+Assoc = extern "C" fn(&u8, ::.)+impl1::AutoTrait; _] as impl1::main::{{closure}}::Bar>::method::h636bc933fc62ee2f) +error: demangling(<[&dyn impl1::Foo+Assoc = extern "C" fn(&u8, ::.)+impl1::AutoTrait; _] as impl1::main::{{closure}}::Bar>::method::h61b0fcb05ebeeb79) --> $DIR/impl1.rs:61:13 | LL | #[rustc_symbol_name] diff --git a/src/test/ui/symbol-names/issue-60925.legacy.stderr b/src/test/ui/symbol-names/issue-60925.legacy.stderr index de8efdde737f0..19d9740fb16be 100644 --- a/src/test/ui/symbol-names/issue-60925.legacy.stderr +++ b/src/test/ui/symbol-names/issue-60925.legacy.stderr @@ -1,10 +1,10 @@ -error: symbol-name(_ZN11issue_609253foo37Foo$LT$issue_60925..llv$u6d$..Foo$GT$3foo17h059a991a004536adE) +error: symbol-name(_ZN11issue_609253foo37Foo$LT$issue_60925..llv$u6d$..Foo$GT$3foo17hc86312d25b60f6eeE) --> $DIR/issue-60925.rs:21:9 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling(issue_60925::foo::Foo<issue_60925::llvm::Foo>::foo::h059a991a004536ad) +error: demangling(issue_60925::foo::Foo<issue_60925::llvm::Foo>::foo::hc86312d25b60f6ee) --> $DIR/issue-60925.rs:21:9 | LL | #[rustc_symbol_name] From 7f3c8438e04461e05d71a784a2f582dadf14e5d6 Mon Sep 17 00:00:00 2001 From: varkor <github@varkor.com> Date: Fri, 11 Oct 2019 02:33:16 +0100 Subject: [PATCH 06/30] Refactor check_attr --- src/librustc/hir/check_attr.rs | 138 ++++++++++++++++++--------------- 1 file changed, 75 insertions(+), 63 deletions(-) diff --git a/src/librustc/hir/check_attr.rs b/src/librustc/hir/check_attr.rs index c37fec982b116..ee5318153dadf 100644 --- a/src/librustc/hir/check_attr.rs +++ b/src/librustc/hir/check_attr.rs @@ -4,7 +4,8 @@ //! conflicts between multiple such attributes attached to the same //! item. -use crate::hir; +use crate::hir::{self, HirId, HirVec, Attribute, Item, ItemKind, TraitItem, TraitItemKind}; +use crate::hir::DUMMY_HIR_ID; use crate::hir::def_id::DefId; use crate::hir::intravisit::{self, Visitor, NestedVisitorMap}; use crate::ty::TyCtxt; @@ -64,24 +65,26 @@ impl Display for Target { } impl Target { - pub(crate) fn from_item(item: &hir::Item) -> Target { + pub(crate) fn from_item(item: &Item) -> Target { match item.kind { - hir::ItemKind::ExternCrate(..) => Target::ExternCrate, - hir::ItemKind::Use(..) => Target::Use, - hir::ItemKind::Static(..) => Target::Static, - hir::ItemKind::Const(..) => Target::Const, - hir::ItemKind::Fn(..) => Target::Fn, - hir::ItemKind::Mod(..) => Target::Mod, - hir::ItemKind::ForeignMod(..) => Target::ForeignMod, - hir::ItemKind::GlobalAsm(..) => Target::GlobalAsm, - hir::ItemKind::TyAlias(..) => Target::TyAlias, - hir::ItemKind::OpaqueTy(..) => Target::OpaqueTy, - hir::ItemKind::Enum(..) => Target::Enum, - hir::ItemKind::Struct(..) => Target::Struct, - hir::ItemKind::Union(..) => Target::Union, - hir::ItemKind::Trait(..) => Target::Trait, - hir::ItemKind::TraitAlias(..) => Target::TraitAlias, - hir::ItemKind::Impl(..) => Target::Impl, + ItemKind::ExternCrate(..) => Target::ExternCrate, + ItemKind::Use(..) => Target::Use, + ItemKind::Static(..) => Target::Static, + ItemKind::Const(..) => Target::Const, + ItemKind::Fn(..) => Target::Fn, + ItemKind::Mod(..) => Target::Mod, + ItemKind::ForeignMod(..) => Target::ForeignMod, + ItemKind::GlobalAsm(..) => Target::GlobalAsm, + ItemKind::TyAlias(..) => Target::TyAlias, + ItemKind::OpaqueTy(..) => Target::OpaqueTy, + ItemKind::Enum(..) => Target::Enum, + ItemKind::Struct(..) => Target::Struct, + ItemKind::Union(..) => Target::Union, + ItemKind::Trait(..) => Target::Trait, + ItemKind::TraitAlias(..) => Target::TraitAlias, + ItemKind::Impl(..) => Target::Impl, + } + } } } } @@ -92,17 +95,24 @@ struct CheckAttrVisitor<'tcx> { impl CheckAttrVisitor<'tcx> { /// Checks any attribute. - fn check_attributes(&self, item: &hir::Item, target: Target) { + fn check_attributes( + &self, + hir_id: HirId, + attrs: &HirVec<Attribute>, + span: &Span, + target: Target, + item: Option<&Item>, + ) { let mut is_valid = true; - for attr in &item.attrs { + for attr in attrs { is_valid &= if attr.check_name(sym::inline) { - self.check_inline(attr, &item.span, target) + self.check_inline(hir_id, attr, span, target) } else if attr.check_name(sym::non_exhaustive) { - self.check_non_exhaustive(attr, item, target) + self.check_non_exhaustive(attr, span, target) } else if attr.check_name(sym::marker) { - self.check_marker(attr, item, target) + self.check_marker(attr, span, target) } else if attr.check_name(sym::target_feature) { - self.check_target_feature(attr, item, target) + self.check_target_feature(attr, span, target) } else if attr.check_name(sym::track_caller) { self.check_track_caller(attr, &item, target) } else { @@ -115,25 +125,26 @@ impl CheckAttrVisitor<'tcx> { } if target == Target::Fn { - self.tcx.codegen_fn_attrs(self.tcx.hir().local_def_id(item.hir_id)); + self.tcx.codegen_fn_attrs(self.tcx.hir().local_def_id(hir_id)); } - self.check_repr(item, target); - self.check_used(item, target); + self.check_repr(attrs, span, target, item); + self.check_used(attrs, target); } /// Checks if an `#[inline]` is applied to a function or a closure. Returns `true` if valid. - fn check_inline(&self, attr: &hir::Attribute, span: &Span, target: Target) -> bool { - if target != Target::Fn && target != Target::Closure { - struct_span_err!(self.tcx.sess, - attr.span, - E0518, - "attribute should be applied to function or closure") - .span_label(*span, "not a function or closure") - .emit(); - false - } else { - true + fn check_inline(&self, hir_id: HirId, attr: &Attribute, span: &Span, target: Target) -> bool { + match target { + Target::Fn | Target::Closure | Target::Method { body: true } => true, + _ => { + struct_span_err!(self.tcx.sess, + attr.span, + E0518, + "attribute should be applied to function or closure") + .span_label(*span, "not a function or closure") + .emit(); + false + } } } @@ -166,8 +177,8 @@ impl CheckAttrVisitor<'tcx> { /// Checks if the `#[non_exhaustive]` attribute on an `item` is valid. Returns `true` if valid. fn check_non_exhaustive( &self, - attr: &hir::Attribute, - item: &hir::Item, + attr: &Attribute, + span: &Span, target: Target, ) -> bool { match target { @@ -177,7 +188,7 @@ impl CheckAttrVisitor<'tcx> { attr.span, E0701, "attribute can only be applied to a struct or enum") - .span_label(item.span, "not a struct or enum") + .span_label(*span, "not a struct or enum") .emit(); false } @@ -185,13 +196,13 @@ impl CheckAttrVisitor<'tcx> { } /// Checks if the `#[marker]` attribute on an `item` is valid. Returns `true` if valid. - fn check_marker(&self, attr: &hir::Attribute, item: &hir::Item, target: Target) -> bool { + fn check_marker(&self, attr: &Attribute, span: &Span, target: Target) -> bool { match target { Target::Trait => true, _ => { self.tcx.sess .struct_span_err(attr.span, "attribute can only be applied to a trait") - .span_label(item.span, "not a trait") + .span_label(*span, "not a trait") .emit(); false } @@ -199,18 +210,13 @@ impl CheckAttrVisitor<'tcx> { } /// Checks if the `#[target_feature]` attribute on `item` is valid. Returns `true` if valid. - fn check_target_feature( - &self, - attr: &hir::Attribute, - item: &hir::Item, - target: Target, - ) -> bool { + fn check_target_feature(&self, attr: &Attribute, span: &Span, target: Target) -> bool { match target { Target::Fn => true, _ => { self.tcx.sess .struct_span_err(attr.span, "attribute should be applied to a function") - .span_label(item.span, "not a function") + .span_label(*span, "not a function") .emit(); false }, @@ -218,13 +224,19 @@ impl CheckAttrVisitor<'tcx> { } /// Checks if the `#[repr]` attributes on `item` are valid. - fn check_repr(&self, item: &hir::Item, target: Target) { + fn check_repr( + &self, + attrs: &HirVec<Attribute>, + span: &Span, + target: Target, + item: Option<&Item>, + ) { // Extract the names of all repr hints, e.g., [foo, bar, align] for: // ``` // #[repr(foo)] // #[repr(bar, align(8))] // ``` - let hints: Vec<_> = item.attrs + let hints: Vec<_> = attrs .iter() .filter(|attr| attr.check_name(sym::repr)) .filter_map(|attr| attr.meta_item_list()) @@ -282,7 +294,7 @@ impl CheckAttrVisitor<'tcx> { }; self.emit_repr_error( hint.span(), - item.span, + *span, &format!("attribute should be applied to {}", allowed_targets), &format!("not {} {}", article, allowed_targets), ) @@ -301,7 +313,7 @@ impl CheckAttrVisitor<'tcx> { // Warn on repr(u8, u16), repr(C, simd), and c-like-enum-repr(C, u8) if (int_reprs > 1) || (is_simd && is_c) - || (int_reprs == 1 && is_c && is_c_like_enum(item)) { + || (int_reprs == 1 && is_c && item.map(|item| is_c_like_enum(item)).unwrap_or(false)) { let hint_spans: Vec<_> = hint_spans.collect(); span_warn!(self.tcx.sess, hint_spans, E0566, "conflicting representation hints"); @@ -325,7 +337,7 @@ impl CheckAttrVisitor<'tcx> { if let hir::StmtKind::Local(ref l) = stmt.kind { for attr in l.attrs.iter() { if attr.check_name(sym::inline) { - self.check_inline(attr, &stmt.span, Target::Statement); + self.check_inline(DUMMY_HIR_ID, attr, &stmt.span, Target::Statement); } if attr.check_name(sym::repr) { self.emit_repr_error( @@ -346,7 +358,7 @@ impl CheckAttrVisitor<'tcx> { }; for attr in expr.attrs.iter() { if attr.check_name(sym::inline) { - self.check_inline(attr, &expr.span, target); + self.check_inline(DUMMY_HIR_ID, attr, &expr.span, target); } if attr.check_name(sym::repr) { self.emit_repr_error( @@ -359,8 +371,8 @@ impl CheckAttrVisitor<'tcx> { } } - fn check_used(&self, item: &hir::Item, target: Target) { - for attr in &item.attrs { + fn check_used(&self, attrs: &HirVec<Attribute>, target: Target) { + for attr in attrs { if attr.check_name(sym::used) && target != Target::Static { self.tcx.sess .span_err(attr.span, "attribute must be applied to a `static` variable"); @@ -374,9 +386,9 @@ impl Visitor<'tcx> for CheckAttrVisitor<'tcx> { NestedVisitorMap::OnlyBodies(&self.tcx.hir()) } - fn visit_item(&mut self, item: &'tcx hir::Item) { + fn visit_item(&mut self, item: &'tcx Item) { let target = Target::from_item(item); - self.check_attributes(item, target); + self.check_attributes(item.hir_id, &item.attrs, &item.span, target, Some(item)); intravisit::walk_item(self, item) } @@ -392,12 +404,12 @@ impl Visitor<'tcx> for CheckAttrVisitor<'tcx> { } } -fn is_c_like_enum(item: &hir::Item) -> bool { - if let hir::ItemKind::Enum(ref def, _) = item.kind { +fn is_c_like_enum(item: &Item) -> bool { + if let ItemKind::Enum(ref def, _) = item.kind { for variant in &def.variants { match variant.data { hir::VariantData::Unit(..) => { /* continue */ } - _ => { return false; } + _ => return false, } } true From 94c4dd990296df030f0decffc9a4751105f3e603 Mon Sep 17 00:00:00 2001 From: varkor <github@varkor.com> Date: Fri, 11 Oct 2019 02:35:22 +0100 Subject: [PATCH 07/30] Emit warning for ignored #[inline] on trait method prototypes --- src/librustc/hir/check_attr.rs | 34 +++++++++++++++++++ src/librustc/lint/builtin.rs | 6 ++++ src/librustc_lint/unused.rs | 7 +--- src/test/ui/issues/issue-52057.stderr | 8 +++++ .../warn-unused-inline-on-fn-prototypes.rs | 8 +++++ ...warn-unused-inline-on-fn-prototypes.stderr | 14 ++++++++ 6 files changed, 71 insertions(+), 6 deletions(-) create mode 100644 src/test/ui/issues/issue-52057.stderr create mode 100644 src/test/ui/lint/warn-unused-inline-on-fn-prototypes.rs create mode 100644 src/test/ui/lint/warn-unused-inline-on-fn-prototypes.stderr diff --git a/src/librustc/hir/check_attr.rs b/src/librustc/hir/check_attr.rs index ee5318153dadf..c0fe712adc758 100644 --- a/src/librustc/hir/check_attr.rs +++ b/src/librustc/hir/check_attr.rs @@ -8,6 +8,7 @@ use crate::hir::{self, HirId, HirVec, Attribute, Item, ItemKind, TraitItem, Trai use crate::hir::DUMMY_HIR_ID; use crate::hir::def_id::DefId; use crate::hir::intravisit::{self, Visitor, NestedVisitorMap}; +use crate::lint::builtin::UNUSED_ATTRIBUTES; use crate::ty::TyCtxt; use crate::ty::query::Providers; @@ -36,6 +37,9 @@ pub(crate) enum Target { Impl, Expression, Statement, + AssocConst, + Method { body: bool }, + AssocTy, } impl Display for Target { @@ -60,6 +64,9 @@ impl Display for Target { Target::Impl => "item", Target::Expression => "expression", Target::Statement => "statement", + Target::AssocConst => "associated const", + Target::Method { .. } => "method", + Target::AssocTy => "associated type", }) } } @@ -85,6 +92,19 @@ impl Target { ItemKind::Impl(..) => Target::Impl, } } + + fn from_trait_item(trait_item: &TraitItem) -> Target { + match trait_item.kind { + TraitItemKind::Const(..) => Target::AssocConst, + TraitItemKind::Method(_, hir::TraitMethod::Required(_)) => { + Target::Method { body: false } + } + TraitItemKind::Method(_, hir::TraitMethod::Provided(_)) => { + Target::Method { body: true } + } + TraitItemKind::Type(..) => Target::AssocTy, + } + } } } } @@ -136,6 +156,15 @@ impl CheckAttrVisitor<'tcx> { fn check_inline(&self, hir_id: HirId, attr: &Attribute, span: &Span, target: Target) -> bool { match target { Target::Fn | Target::Closure | Target::Method { body: true } => true, + Target::Method { body: false } | Target::ForeignFn => { + self.tcx.struct_span_lint_hir( + UNUSED_ATTRIBUTES, + hir_id, + attr.span, + "`#[inline]` is ignored on function prototypes", + ).emit(); + true + } _ => { struct_span_err!(self.tcx.sess, attr.span, @@ -392,6 +421,11 @@ impl Visitor<'tcx> for CheckAttrVisitor<'tcx> { intravisit::walk_item(self, item) } + fn visit_trait_item(&mut self, trait_item: &'tcx TraitItem) { + let target = Target::from_trait_item(trait_item); + self.check_attributes(trait_item.hir_id, &trait_item.attrs, &trait_item.span, target, None); + intravisit::walk_trait_item(self, trait_item) + } fn visit_stmt(&mut self, stmt: &'tcx hir::Stmt) { self.check_stmt_attributes(stmt); diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 15598b60f5c0b..5c871bb6b6988 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -68,6 +68,12 @@ declare_lint! { "detect unused, unexported items" } +declare_lint! { + pub UNUSED_ATTRIBUTES, + Warn, + "detects attributes that were not used by the compiler" +} + declare_lint! { pub UNREACHABLE_CODE, Warn, diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index 61b8cbe369aab..9a826de4b6eaf 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -1,6 +1,7 @@ use rustc::hir::def::{Res, DefKind}; use rustc::hir::def_id::DefId; use rustc::lint; +use rustc::lint::builtin::UNUSED_ATTRIBUTES; use rustc::ty::{self, Ty}; use rustc::ty::adjustment; use rustc_data_structures::fx::FxHashMap; @@ -277,12 +278,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PathStatements { } } -declare_lint! { - pub UNUSED_ATTRIBUTES, - Warn, - "detects attributes that were not used by the compiler" -} - #[derive(Copy, Clone)] pub struct UnusedAttributes { builtin_attributes: &'static FxHashMap<Symbol, &'static BuiltinAttribute>, diff --git a/src/test/ui/issues/issue-52057.stderr b/src/test/ui/issues/issue-52057.stderr new file mode 100644 index 0000000000000..33b79dba73e0e --- /dev/null +++ b/src/test/ui/issues/issue-52057.stderr @@ -0,0 +1,8 @@ +warning: `#[inline]` is ignored on function prototypes + --> $DIR/issue-52057.rs:10:5 + | +LL | #[inline(always)] + | ^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(unused_attributes)]` on by default + diff --git a/src/test/ui/lint/warn-unused-inline-on-fn-prototypes.rs b/src/test/ui/lint/warn-unused-inline-on-fn-prototypes.rs new file mode 100644 index 0000000000000..f7fc28cbc7d1c --- /dev/null +++ b/src/test/ui/lint/warn-unused-inline-on-fn-prototypes.rs @@ -0,0 +1,8 @@ +#![deny(unused_attributes)] + +trait Trait { + #[inline] //~ ERROR `#[inline]` is ignored on function prototypes + fn foo(); +} + +fn main() {} diff --git a/src/test/ui/lint/warn-unused-inline-on-fn-prototypes.stderr b/src/test/ui/lint/warn-unused-inline-on-fn-prototypes.stderr new file mode 100644 index 0000000000000..a13de8e09c51a --- /dev/null +++ b/src/test/ui/lint/warn-unused-inline-on-fn-prototypes.stderr @@ -0,0 +1,14 @@ +error: `#[inline]` is ignored on function prototypes + --> $DIR/warn-unused-inline-on-fn-prototypes.rs:9:5 + | +LL | #[inline] + | ^^^^^^^^^ + | +note: lint level defined here + --> $DIR/warn-unused-inline-on-fn-prototypes.rs:1:9 + | +LL | #![deny(unused_attributes)] + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + From 66d7ef077a23138553c92ab8053416da51ab3b4f Mon Sep 17 00:00:00 2001 From: varkor <github@varkor.com> Date: Fri, 11 Oct 2019 02:35:49 +0100 Subject: [PATCH 08/30] Emit warning for ignored #[inline] on foreign function prototypes --- src/librustc/hir/check_attr.rs | 18 ++++++++++++++++++ .../warn-unused-inline-on-fn-prototypes.rs | 5 +++++ .../warn-unused-inline-on-fn-prototypes.stderr | 6 ++++++ 3 files changed, 29 insertions(+) diff --git a/src/librustc/hir/check_attr.rs b/src/librustc/hir/check_attr.rs index c0fe712adc758..8777785859cd5 100644 --- a/src/librustc/hir/check_attr.rs +++ b/src/librustc/hir/check_attr.rs @@ -40,6 +40,9 @@ pub(crate) enum Target { AssocConst, Method { body: bool }, AssocTy, + ForeignFn, + ForeignStatic, + ForeignTy, } impl Display for Target { @@ -67,6 +70,9 @@ impl Display for Target { Target::AssocConst => "associated const", Target::Method { .. } => "method", Target::AssocTy => "associated type", + Target::ForeignFn => "foreign function", + Target::ForeignStatic => "foreign static item", + Target::ForeignTy => "foreign type", }) } } @@ -105,6 +111,12 @@ impl Target { TraitItemKind::Type(..) => Target::AssocTy, } } + + fn from_foreign_item(foreign_item: &hir::ForeignItem) -> Target { + match foreign_item.kind { + hir::ForeignItemKind::Fn(..) => Target::ForeignFn, + hir::ForeignItemKind::Static(..) => Target::ForeignStatic, + hir::ForeignItemKind::Type => Target::ForeignTy, } } } @@ -427,6 +439,12 @@ impl Visitor<'tcx> for CheckAttrVisitor<'tcx> { intravisit::walk_trait_item(self, trait_item) } + fn visit_foreign_item(&mut self, f_item: &'tcx hir::ForeignItem) { + let target = Target::from_foreign_item(f_item); + self.check_attributes(f_item.hir_id, &f_item.attrs, &f_item.span, target, None); + intravisit::walk_foreign_item(self, f_item) + } + fn visit_stmt(&mut self, stmt: &'tcx hir::Stmt) { self.check_stmt_attributes(stmt); intravisit::walk_stmt(self, stmt) diff --git a/src/test/ui/lint/warn-unused-inline-on-fn-prototypes.rs b/src/test/ui/lint/warn-unused-inline-on-fn-prototypes.rs index f7fc28cbc7d1c..21097197499dd 100644 --- a/src/test/ui/lint/warn-unused-inline-on-fn-prototypes.rs +++ b/src/test/ui/lint/warn-unused-inline-on-fn-prototypes.rs @@ -5,4 +5,9 @@ trait Trait { fn foo(); } +extern { + #[inline] //~ ERROR `#[inline]` is ignored on function prototypes + fn foo(); +} + fn main() {} diff --git a/src/test/ui/lint/warn-unused-inline-on-fn-prototypes.stderr b/src/test/ui/lint/warn-unused-inline-on-fn-prototypes.stderr index a13de8e09c51a..006cc6c80a64e 100644 --- a/src/test/ui/lint/warn-unused-inline-on-fn-prototypes.stderr +++ b/src/test/ui/lint/warn-unused-inline-on-fn-prototypes.stderr @@ -10,5 +10,11 @@ note: lint level defined here LL | #![deny(unused_attributes)] | ^^^^^^^^^^^^^^^^^ +error: `#[inline]` is ignored on function prototypes + --> $DIR/warn-unused-inline-on-fn-prototypes.rs:4:5 + | +LL | #[inline] + | ^^^^^^^^^ + error: aborting due to 2 previous errors From af2b49777659c014e8e0e6827c379635003cfd69 Mon Sep 17 00:00:00 2001 From: varkor <github@varkor.com> Date: Fri, 11 Oct 2019 02:36:01 +0100 Subject: [PATCH 09/30] Improve comments --- src/librustc/hir/intravisit.rs | 2 +- src/librustc/hir/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index 05bdd0887f0f6..920635d838738 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -203,7 +203,7 @@ pub trait Visitor<'v>: Sized { /// Invoked to visit the body of a function, method or closure. Like /// visit_nested_item, does nothing by default unless you override - /// `nested_visit_map` to return other htan `None`, in which case it will walk + /// `nested_visit_map` to return other than `None`, in which case it will walk /// the body. fn visit_nested_body(&mut self, id: BodyId) { let opt_body = self.nested_visit_map().intra().map(|map| map.body(id)); diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 38c84ad33478b..19959c11d0950 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -2512,7 +2512,7 @@ pub enum ItemKind { Fn(P<FnDecl>, FnHeader, Generics, BodyId), /// A module. Mod(Mod), - /// An external module. + /// An external module, e.g. `extern { .. }`. ForeignMod(ForeignMod), /// Module-level inline assembly (from `global_asm!`). GlobalAsm(P<GlobalAsm>), From 4552c8f2f7c20ff5bb7e23b31b4aa863b4502903 Mon Sep 17 00:00:00 2001 From: varkor <github@varkor.com> Date: Fri, 11 Oct 2019 02:36:20 +0100 Subject: [PATCH 10/30] Add test for attribute error checking on trait and foreign items --- .../ui/lint/inline-trait-and-foreign-items.rs | 19 ++++++++++ .../inline-trait-and-foreign-items.stderr | 35 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 src/test/ui/lint/inline-trait-and-foreign-items.rs create mode 100644 src/test/ui/lint/inline-trait-and-foreign-items.stderr diff --git a/src/test/ui/lint/inline-trait-and-foreign-items.rs b/src/test/ui/lint/inline-trait-and-foreign-items.rs new file mode 100644 index 0000000000000..30353d2683188 --- /dev/null +++ b/src/test/ui/lint/inline-trait-and-foreign-items.rs @@ -0,0 +1,19 @@ +#![feature(extern_types)] + +trait Trait { + #[inline] //~ ERROR attribute should be applied to function or closure + const X: u32; + + #[inline] //~ ERROR attribute should be applied to function or closure + type T; +} + +extern { + #[inline] //~ ERROR attribute should be applied to function or closure + static X: u32; + + #[inline] //~ ERROR attribute should be applied to function or closure + type T; +} + +fn main() {} diff --git a/src/test/ui/lint/inline-trait-and-foreign-items.stderr b/src/test/ui/lint/inline-trait-and-foreign-items.stderr new file mode 100644 index 0000000000000..510fe26d06175 --- /dev/null +++ b/src/test/ui/lint/inline-trait-and-foreign-items.stderr @@ -0,0 +1,35 @@ +error[E0518]: attribute should be applied to function or closure + --> $DIR/inline-trait-and-foreign-items.rs:12:5 + | +LL | #[inline] + | ^^^^^^^^^ +LL | static X: u32; + | -------------- not a function or closure + +error[E0518]: attribute should be applied to function or closure + --> $DIR/inline-trait-and-foreign-items.rs:15:5 + | +LL | #[inline] + | ^^^^^^^^^ +LL | type T; + | ------- not a function or closure + +error[E0518]: attribute should be applied to function or closure + --> $DIR/inline-trait-and-foreign-items.rs:4:5 + | +LL | #[inline] + | ^^^^^^^^^ +LL | const X: u32; + | ------------- not a function or closure + +error[E0518]: attribute should be applied to function or closure + --> $DIR/inline-trait-and-foreign-items.rs:7:5 + | +LL | #[inline] + | ^^^^^^^^^ +LL | type T; + | ------- not a function or closure + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0518`. From 41ee9eaee76fc38eebc0580e8361bced8edd7ccb Mon Sep 17 00:00:00 2001 From: varkor <github@varkor.com> Date: Fri, 11 Oct 2019 02:42:23 +0100 Subject: [PATCH 11/30] Refactor `check_track_caller` --- src/librustc/hir/check_attr.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/librustc/hir/check_attr.rs b/src/librustc/hir/check_attr.rs index 8777785859cd5..d366cd9b4c3fa 100644 --- a/src/librustc/hir/check_attr.rs +++ b/src/librustc/hir/check_attr.rs @@ -146,7 +146,7 @@ impl CheckAttrVisitor<'tcx> { } else if attr.check_name(sym::target_feature) { self.check_target_feature(attr, span, target) } else if attr.check_name(sym::track_caller) { - self.check_track_caller(attr, &item, target) + self.check_track_caller(&attr.span, attrs, span, target) } else { true }; @@ -190,21 +190,27 @@ impl CheckAttrVisitor<'tcx> { } /// Checks if a `#[track_caller]` is applied to a non-naked function. Returns `true` if valid. - fn check_track_caller(&self, attr: &hir::Attribute, item: &hir::Item, target: Target) -> bool { + fn check_track_caller( + &self, + attr_span: &Span, + attrs: &HirVec<Attribute>, + span: &Span, + target: Target, + ) -> bool { if target != Target::Fn { struct_span_err!( self.tcx.sess, - attr.span, + *attr_span, E0739, "attribute should be applied to function" ) - .span_label(item.span, "not a function") + .span_label(*span, "not a function") .emit(); false - } else if attr::contains_name(&item.attrs, sym::naked) { + } else if attr::contains_name(attrs, sym::naked) { struct_span_err!( self.tcx.sess, - attr.span, + *attr_span, E0736, "cannot use `#[track_caller]` with `#[naked]`", ) From 8042206657314dc5470fca8ce6ad82424034f40c Mon Sep 17 00:00:00 2001 From: varkor <github@varkor.com> Date: Sun, 13 Oct 2019 16:14:59 +0100 Subject: [PATCH 12/30] Handle `ImplItem` in `check_attr` --- src/librustc/hir/check_attr.rs | 17 +++++++- .../ui/lint/inline-trait-and-foreign-items.rs | 14 +++++++ .../inline-trait-and-foreign-items.stderr | 40 ++++++++++++++++--- 3 files changed, 65 insertions(+), 6 deletions(-) diff --git a/src/librustc/hir/check_attr.rs b/src/librustc/hir/check_attr.rs index d366cd9b4c3fa..a175bcafdc4a4 100644 --- a/src/librustc/hir/check_attr.rs +++ b/src/librustc/hir/check_attr.rs @@ -119,6 +119,15 @@ impl Target { hir::ForeignItemKind::Type => Target::ForeignTy, } } + + fn from_impl_item(impl_item: &hir::ImplItem) -> Target { + match impl_item.kind { + hir::ImplItemKind::Const(..) => Target::Const, + hir::ImplItemKind::Method(..) => Target::Method { body: true }, + hir::ImplItemKind::TyAlias(..) => Target::TyAlias, + hir::ImplItemKind::OpaqueTy(..) => Target::OpaqueTy, + } + } } struct CheckAttrVisitor<'tcx> { @@ -360,7 +369,7 @@ impl CheckAttrVisitor<'tcx> { // Warn on repr(u8, u16), repr(C, simd), and c-like-enum-repr(C, u8) if (int_reprs > 1) || (is_simd && is_c) - || (int_reprs == 1 && is_c && item.map(|item| is_c_like_enum(item)).unwrap_or(false)) { + || (int_reprs == 1 && is_c && item.map_or(false, |item| is_c_like_enum(item))) { let hint_spans: Vec<_> = hint_spans.collect(); span_warn!(self.tcx.sess, hint_spans, E0566, "conflicting representation hints"); @@ -451,6 +460,12 @@ impl Visitor<'tcx> for CheckAttrVisitor<'tcx> { intravisit::walk_foreign_item(self, f_item) } + fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) { + let target = Target::from_impl_item(impl_item); + self.check_attributes(impl_item.hir_id, &impl_item.attrs, &impl_item.span, target, None); + intravisit::walk_impl_item(self, impl_item) + } + fn visit_stmt(&mut self, stmt: &'tcx hir::Stmt) { self.check_stmt_attributes(stmt); intravisit::walk_stmt(self, stmt) diff --git a/src/test/ui/lint/inline-trait-and-foreign-items.rs b/src/test/ui/lint/inline-trait-and-foreign-items.rs index 30353d2683188..2beb5aaba6590 100644 --- a/src/test/ui/lint/inline-trait-and-foreign-items.rs +++ b/src/test/ui/lint/inline-trait-and-foreign-items.rs @@ -1,4 +1,5 @@ #![feature(extern_types)] +#![feature(type_alias_impl_trait)] trait Trait { #[inline] //~ ERROR attribute should be applied to function or closure @@ -6,6 +7,19 @@ trait Trait { #[inline] //~ ERROR attribute should be applied to function or closure type T; + + type U; +} + +impl Trait for () { + #[inline] //~ ERROR attribute should be applied to function or closure + const X: u32 = 0; + + #[inline] //~ ERROR attribute should be applied to function or closure + type T = Self; + + #[inline] //~ ERROR attribute should be applied to function or closure + type U = impl Trait; //~ ERROR could not find defining uses } extern { diff --git a/src/test/ui/lint/inline-trait-and-foreign-items.stderr b/src/test/ui/lint/inline-trait-and-foreign-items.stderr index 510fe26d06175..f67c7a6018ce4 100644 --- a/src/test/ui/lint/inline-trait-and-foreign-items.stderr +++ b/src/test/ui/lint/inline-trait-and-foreign-items.stderr @@ -1,5 +1,5 @@ error[E0518]: attribute should be applied to function or closure - --> $DIR/inline-trait-and-foreign-items.rs:12:5 + --> $DIR/inline-trait-and-foreign-items.rs:26:5 | LL | #[inline] | ^^^^^^^^^ @@ -7,7 +7,7 @@ LL | static X: u32; | -------------- not a function or closure error[E0518]: attribute should be applied to function or closure - --> $DIR/inline-trait-and-foreign-items.rs:15:5 + --> $DIR/inline-trait-and-foreign-items.rs:29:5 | LL | #[inline] | ^^^^^^^^^ @@ -15,7 +15,7 @@ LL | type T; | ------- not a function or closure error[E0518]: attribute should be applied to function or closure - --> $DIR/inline-trait-and-foreign-items.rs:4:5 + --> $DIR/inline-trait-and-foreign-items.rs:5:5 | LL | #[inline] | ^^^^^^^^^ @@ -23,13 +23,43 @@ LL | const X: u32; | ------------- not a function or closure error[E0518]: attribute should be applied to function or closure - --> $DIR/inline-trait-and-foreign-items.rs:7:5 + --> $DIR/inline-trait-and-foreign-items.rs:8:5 | LL | #[inline] | ^^^^^^^^^ LL | type T; | ------- not a function or closure -error: aborting due to 4 previous errors +error[E0518]: attribute should be applied to function or closure + --> $DIR/inline-trait-and-foreign-items.rs:15:5 + | +LL | #[inline] + | ^^^^^^^^^ +LL | const X: u32 = 0; + | ----------------- not a function or closure + +error[E0518]: attribute should be applied to function or closure + --> $DIR/inline-trait-and-foreign-items.rs:18:5 + | +LL | #[inline] + | ^^^^^^^^^ +LL | type T = Self; + | -------------- not a function or closure + +error[E0518]: attribute should be applied to function or closure + --> $DIR/inline-trait-and-foreign-items.rs:21:5 + | +LL | #[inline] + | ^^^^^^^^^ +LL | type U = impl Trait; + | -------------------- not a function or closure + +error: could not find defining uses + --> $DIR/inline-trait-and-foreign-items.rs:22:5 + | +LL | type U = impl Trait; + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 8 previous errors For more information about this error, try `rustc --explain E0518`. From b925eb5f42a70a481ae75495c25818c1cc4cea46 Mon Sep 17 00:00:00 2001 From: varkor <github@varkor.com> Date: Mon, 14 Oct 2019 00:37:55 +0100 Subject: [PATCH 13/30] Update bitflags --- Cargo.lock | 4 ++-- src/librustc/Cargo.toml | 2 +- src/librustc_apfloat/Cargo.toml | 2 +- src/librustc_codegen_ssa/Cargo.toml | 2 +- src/librustc_resolve/Cargo.toml | 2 +- src/librustc_target/Cargo.toml | 2 +- src/libsyntax/Cargo.toml | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fbac2c7879d12..eabbb51545ce6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -150,9 +150,9 @@ dependencies = [ [[package]] name = "bitflags" -version = "1.1.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "blake2-rfc" diff --git a/src/librustc/Cargo.toml b/src/librustc/Cargo.toml index 93274ef0c927c..5b59924c3535b 100644 --- a/src/librustc/Cargo.toml +++ b/src/librustc/Cargo.toml @@ -11,7 +11,7 @@ doctest = false [dependencies] arena = { path = "../libarena" } -bitflags = "1.0" +bitflags = "1.2.1" fmt_macros = { path = "../libfmt_macros" } graphviz = { path = "../libgraphviz" } jobserver = "0.1" diff --git a/src/librustc_apfloat/Cargo.toml b/src/librustc_apfloat/Cargo.toml index af6c2feed0072..4fc15f99e484e 100644 --- a/src/librustc_apfloat/Cargo.toml +++ b/src/librustc_apfloat/Cargo.toml @@ -9,5 +9,5 @@ name = "rustc_apfloat" path = "lib.rs" [dependencies] -bitflags = "1.0" +bitflags = "1.2.1" smallvec = { version = "0.6.7", features = ["union", "may_dangle"] } diff --git a/src/librustc_codegen_ssa/Cargo.toml b/src/librustc_codegen_ssa/Cargo.toml index 6992f93d99949..051b1e2523427 100644 --- a/src/librustc_codegen_ssa/Cargo.toml +++ b/src/librustc_codegen_ssa/Cargo.toml @@ -10,7 +10,7 @@ path = "lib.rs" test = false [dependencies] -bitflags = "1.0.4" +bitflags = "1.2.1" cc = "1.0.1" num_cpus = "1.0" memmap = "0.6" diff --git a/src/librustc_resolve/Cargo.toml b/src/librustc_resolve/Cargo.toml index 06bf30859898a..08ce7fd520e30 100644 --- a/src/librustc_resolve/Cargo.toml +++ b/src/librustc_resolve/Cargo.toml @@ -11,7 +11,7 @@ test = false doctest = false [dependencies] -bitflags = "1.0" +bitflags = "1.2.1" log = "0.4" syntax = { path = "../libsyntax" } syntax_expand = { path = "../libsyntax_expand" } diff --git a/src/librustc_target/Cargo.toml b/src/librustc_target/Cargo.toml index fba2ea02bb44a..c73d0adea38da 100644 --- a/src/librustc_target/Cargo.toml +++ b/src/librustc_target/Cargo.toml @@ -9,7 +9,7 @@ name = "rustc_target" path = "lib.rs" [dependencies] -bitflags = "1.0" +bitflags = "1.2.1" log = "0.4" rustc_data_structures = { path = "../librustc_data_structures" } rustc_serialize = { path = "../libserialize", package = "serialize" } diff --git a/src/libsyntax/Cargo.toml b/src/libsyntax/Cargo.toml index d8de21cc6778f..3ce47e6a7b8cd 100644 --- a/src/libsyntax/Cargo.toml +++ b/src/libsyntax/Cargo.toml @@ -10,7 +10,7 @@ path = "lib.rs" doctest = false [dependencies] -bitflags = "1.0" +bitflags = "1.2.1" rustc_serialize = { path = "../libserialize", package = "serialize" } log = "0.4" scoped-tls = "1.0" From e8566fba0e8b48ec2378301c34b5ecc91d331488 Mon Sep 17 00:00:00 2001 From: varkor <github@varkor.com> Date: Mon, 14 Oct 2019 15:07:16 +0100 Subject: [PATCH 14/30] Move handling of `#[track_caller]` to `check_attr` --- src/librustc/error_codes.rs | 53 ++++++++++++++++++- src/librustc/hir/check_attr.rs | 52 ++++++++++-------- src/librustc/hir/mod.rs | 4 +- src/librustc_typeck/check/wfcheck.rs | 35 ------------ src/librustc_typeck/collect.rs | 2 +- src/librustc_typeck/error_codes.rs | 53 +------------------ .../error-with-invalid-abi.rs | 3 +- .../error-with-invalid-abi.stderr | 2 +- .../error-with-trait-decl.rs | 3 +- .../error-with-trait-decl.stderr | 2 +- .../error-with-trait-default-impl.rs | 3 +- .../error-with-trait-default-impl.stderr | 2 +- .../error-with-trait-fn-impl.rs | 3 +- .../error-with-trait-fn-impl.stderr | 2 +- 14 files changed, 95 insertions(+), 124 deletions(-) diff --git a/src/librustc/error_codes.rs b/src/librustc/error_codes.rs index cf268078a2c5d..3e35add9616bd 100644 --- a/src/librustc/error_codes.rs +++ b/src/librustc/error_codes.rs @@ -2219,7 +2219,7 @@ rejected in your own crates. "##, E0736: r##" -#[track_caller] and #[naked] cannot be applied to the same function. +`#[track_caller]` and `#[naked]` cannot both be applied to the same function. Erroneous code example: @@ -2237,6 +2237,57 @@ See [RFC 2091] for details on this and other limitations. [RFC 2091]: https://github.com/rust-lang/rfcs/blob/master/text/2091-inline-semantic.md "##, +E0738: r##" +`#[track_caller]` cannot be used in traits yet. This is due to limitations in +the compiler which are likely to be temporary. See [RFC 2091] for details on +this and other restrictions. + +Erroneous example with a trait method implementation: + +```compile_fail,E0738 +#![feature(track_caller)] + +trait Foo { + fn bar(&self); +} + +impl Foo for u64 { + #[track_caller] + fn bar(&self) {} +} +``` + +Erroneous example with a blanket trait method implementation: + +```compile_fail,E0738 +#![feature(track_caller)] + +trait Foo { + #[track_caller] + fn bar(&self) {} + fn baz(&self); +} +``` + +Erroneous example with a trait method declaration: + +```compile_fail,E0738 +#![feature(track_caller)] + +trait Foo { + fn bar(&self) {} + + #[track_caller] + fn baz(&self); +} +``` + +Note that while the compiler may be able to support the attribute in traits in +the future, [RFC 2091] prohibits their implementation without a follow-up RFC. + +[RFC 2091]: https://github.com/rust-lang/rfcs/blob/master/text/2091-inline-semantic.md +"##, + ; // E0006, // merged with E0005 // E0101, // replaced with E0282 diff --git a/src/librustc/hir/check_attr.rs b/src/librustc/hir/check_attr.rs index a175bcafdc4a4..55ac95f4ac4b7 100644 --- a/src/librustc/hir/check_attr.rs +++ b/src/librustc/hir/check_attr.rs @@ -206,27 +206,37 @@ impl CheckAttrVisitor<'tcx> { span: &Span, target: Target, ) -> bool { - if target != Target::Fn { - struct_span_err!( - self.tcx.sess, - *attr_span, - E0739, - "attribute should be applied to function" - ) - .span_label(*span, "not a function") - .emit(); - false - } else if attr::contains_name(attrs, sym::naked) { - struct_span_err!( - self.tcx.sess, - *attr_span, - E0736, - "cannot use `#[track_caller]` with `#[naked]`", - ) - .emit(); - false - } else { - true + match target { + Target::Fn if attr::contains_name(attrs, sym::naked) => { + struct_span_err!( + self.tcx.sess, + *attr_span, + E0736, + "cannot use `#[track_caller]` with `#[naked]`", + ).emit(); + false + } + Target::Fn => true, + Target::Method { .. } => { + struct_span_err!( + self.tcx.sess, + *attr_span, + E0738, + "`#[track_caller]` may not be used on trait methods", + ).emit(); + false + } + _ => { + struct_span_err!( + self.tcx.sess, + *attr_span, + E0739, + "attribute should be applied to function" + ) + .span_label(*span, "not a function") + .emit(); + false + } } } diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 19959c11d0950..0edc41e6b4881 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -2756,10 +2756,10 @@ bitflags! { /// `#[used]`: indicates that LLVM can't eliminate this function (but the /// linker can!). const USED = 1 << 9; - /// #[ffi_returns_twice], indicates that an extern function can return + /// `#[ffi_returns_twice]`, indicates that an extern function can return /// multiple times const FFI_RETURNS_TWICE = 1 << 10; - /// #[track_caller]: allow access to the caller location + /// `#[track_caller]`: allow access to the caller location const TRACK_CALLER = 1 << 11; } } diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 18b103960c745..905655176d1e7 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -172,18 +172,6 @@ pub fn check_trait_item(tcx: TyCtxt<'_>, def_id: DefId) { _ => None }; check_associated_item(tcx, trait_item.hir_id, trait_item.span, method_sig); - - // Prohibits applying `#[track_caller]` to trait decls - for attr in &trait_item.attrs { - if attr.check_name(sym::track_caller) { - struct_span_err!( - tcx.sess, - attr.span, - E0738, - "`#[track_caller]` is not supported in trait declarations." - ).emit(); - } - } } pub fn check_impl_item(tcx: TyCtxt<'_>, def_id: DefId) { @@ -195,29 +183,6 @@ pub fn check_impl_item(tcx: TyCtxt<'_>, def_id: DefId) { _ => None }; - // Prohibits applying `#[track_caller]` to trait impls - if method_sig.is_some() { - let track_caller_attr = impl_item.attrs.iter() - .find(|a| a.check_name(sym::track_caller)); - if let Some(tc_attr) = track_caller_attr { - let parent_hir_id = tcx.hir().get_parent_item(hir_id); - let containing_item = tcx.hir().expect_item(parent_hir_id); - let containing_impl_is_for_trait = match &containing_item.kind { - hir::ItemKind::Impl(_, _, _, _, tr, _, _) => tr.is_some(), - _ => bug!("parent of an ImplItem must be an Impl"), - }; - - if containing_impl_is_for_trait { - struct_span_err!( - tcx.sess, - tc_attr.span, - E0738, - "`#[track_caller]` is not supported in traits yet." - ).emit(); - } - } - } - check_associated_item(tcx, impl_item.hir_id, impl_item.span, method_sig); } diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 00435d67184a3..026a3d0122d19 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -2640,7 +2640,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, id: DefId) -> CodegenFnAttrs { tcx.sess, attr.span, E0737, - "rust ABI is required to use `#[track_caller]`" + "Rust ABI is required to use `#[track_caller]`" ).emit(); } codegen_fn_attrs.flags |= CodegenFnAttrFlags::TRACK_CALLER; diff --git a/src/librustc_typeck/error_codes.rs b/src/librustc_typeck/error_codes.rs index 75b508a1bbf0f..8990ee2eaccc6 100644 --- a/src/librustc_typeck/error_codes.rs +++ b/src/librustc_typeck/error_codes.rs @@ -4938,7 +4938,7 @@ and the pin is required to keep it in the same place in memory. "##, E0737: r##" -#[track_caller] requires functions to have the "Rust" ABI for implicitly +`#[track_caller]` requires functions to have the `"Rust"` ABI for implicitly receiving caller location. See [RFC 2091] for details on this and other restrictions. @@ -4954,57 +4954,6 @@ extern "C" fn foo() {} [RFC 2091]: https://github.com/rust-lang/rfcs/blob/master/text/2091-inline-semantic.md "##, -E0738: r##" -#[track_caller] cannot be used in traits yet. This is due to limitations in the -compiler which are likely to be temporary. See [RFC 2091] for details on this -and other restrictions. - -Erroneous example with a trait method implementation: - -```compile_fail,E0738 -#![feature(track_caller)] - -trait Foo { - fn bar(&self); -} - -impl Foo for u64 { - #[track_caller] - fn bar(&self) {} -} -``` - -Erroneous example with a blanket trait method implementation: - -```compile_fail,E0738 -#![feature(track_caller)] - -trait Foo { - #[track_caller] - fn bar(&self) {} - fn baz(&self); -} -``` - -Erroneous example with a trait method declaration: - -```compile_fail,E0738 -#![feature(track_caller)] - -trait Foo { - fn bar(&self) {} - - #[track_caller] - fn baz(&self); -} -``` - -Note that while the compiler may be able to support the attribute in traits in -the future, [RFC 2091] prohibits their implementation without a follow-up RFC. - -[RFC 2091]: https://github.com/rust-lang/rfcs/blob/master/text/2091-inline-semantic.md -"##, - E0741: r##" Only `structural_match` types (that is, types that derive `PartialEq` and `Eq`) may be used as the types of const generic parameters. diff --git a/src/test/ui/rfc-2091-track-caller/error-with-invalid-abi.rs b/src/test/ui/rfc-2091-track-caller/error-with-invalid-abi.rs index 2994f3c06212f..162c6387088e7 100644 --- a/src/test/ui/rfc-2091-track-caller/error-with-invalid-abi.rs +++ b/src/test/ui/rfc-2091-track-caller/error-with-invalid-abi.rs @@ -1,7 +1,6 @@ #![feature(track_caller)] //~ WARN the feature `track_caller` is incomplete -#[track_caller] +#[track_caller] //~ ERROR Rust ABI is required to use `#[track_caller]` extern "C" fn f() {} -//~^^ ERROR rust ABI is required to use `#[track_caller]` fn main() {} diff --git a/src/test/ui/rfc-2091-track-caller/error-with-invalid-abi.stderr b/src/test/ui/rfc-2091-track-caller/error-with-invalid-abi.stderr index a34acf3fc6142..ad89b142f0ec8 100644 --- a/src/test/ui/rfc-2091-track-caller/error-with-invalid-abi.stderr +++ b/src/test/ui/rfc-2091-track-caller/error-with-invalid-abi.stderr @@ -6,7 +6,7 @@ LL | #![feature(track_caller)] | = note: `#[warn(incomplete_features)]` on by default -error[E0737]: rust ABI is required to use `#[track_caller]` +error[E0737]: Rust ABI is required to use `#[track_caller]` --> $DIR/error-with-invalid-abi.rs:3:1 | LL | #[track_caller] diff --git a/src/test/ui/rfc-2091-track-caller/error-with-trait-decl.rs b/src/test/ui/rfc-2091-track-caller/error-with-trait-decl.rs index 1cd45c8cdbc91..4fd768d640a55 100644 --- a/src/test/ui/rfc-2091-track-caller/error-with-trait-decl.rs +++ b/src/test/ui/rfc-2091-track-caller/error-with-trait-decl.rs @@ -1,9 +1,8 @@ #![feature(track_caller)] //~ WARN the feature `track_caller` is incomplete trait Trait { - #[track_caller] + #[track_caller] //~ ERROR: `#[track_caller]` may not be used on trait methods fn unwrap(&self); - //~^^ ERROR: `#[track_caller]` is not supported in trait declarations. } impl Trait for u64 { diff --git a/src/test/ui/rfc-2091-track-caller/error-with-trait-decl.stderr b/src/test/ui/rfc-2091-track-caller/error-with-trait-decl.stderr index fb3732b597083..72ed6f89faa96 100644 --- a/src/test/ui/rfc-2091-track-caller/error-with-trait-decl.stderr +++ b/src/test/ui/rfc-2091-track-caller/error-with-trait-decl.stderr @@ -6,7 +6,7 @@ LL | #![feature(track_caller)] | = note: `#[warn(incomplete_features)]` on by default -error[E0738]: `#[track_caller]` is not supported in trait declarations. +error[E0738]: `#[track_caller]` may not be used on trait methods --> $DIR/error-with-trait-decl.rs:4:5 | LL | #[track_caller] diff --git a/src/test/ui/rfc-2091-track-caller/error-with-trait-default-impl.rs b/src/test/ui/rfc-2091-track-caller/error-with-trait-default-impl.rs index 0f2020d6fb26b..2139ba5de10c3 100644 --- a/src/test/ui/rfc-2091-track-caller/error-with-trait-default-impl.rs +++ b/src/test/ui/rfc-2091-track-caller/error-with-trait-default-impl.rs @@ -1,9 +1,8 @@ #![feature(track_caller)] //~ WARN the feature `track_caller` is incomplete trait Trait { - #[track_caller] + #[track_caller] //~ ERROR: `#[track_caller]` may not be used on trait methods fn unwrap(&self) {} - //~^^ ERROR: `#[track_caller]` is not supported in trait declarations. } fn main() {} diff --git a/src/test/ui/rfc-2091-track-caller/error-with-trait-default-impl.stderr b/src/test/ui/rfc-2091-track-caller/error-with-trait-default-impl.stderr index c212a716c2024..05689c9468bec 100644 --- a/src/test/ui/rfc-2091-track-caller/error-with-trait-default-impl.stderr +++ b/src/test/ui/rfc-2091-track-caller/error-with-trait-default-impl.stderr @@ -6,7 +6,7 @@ LL | #![feature(track_caller)] | = note: `#[warn(incomplete_features)]` on by default -error[E0738]: `#[track_caller]` is not supported in trait declarations. +error[E0738]: `#[track_caller]` may not be used on trait methods --> $DIR/error-with-trait-default-impl.rs:4:5 | LL | #[track_caller] diff --git a/src/test/ui/rfc-2091-track-caller/error-with-trait-fn-impl.rs b/src/test/ui/rfc-2091-track-caller/error-with-trait-fn-impl.rs index 1378ebaa03ffa..9b97df2e4eb33 100644 --- a/src/test/ui/rfc-2091-track-caller/error-with-trait-fn-impl.rs +++ b/src/test/ui/rfc-2091-track-caller/error-with-trait-fn-impl.rs @@ -5,9 +5,8 @@ trait Trait { } impl Trait for u64 { - #[track_caller] + #[track_caller] //~ ERROR: `#[track_caller]` may not be used on trait methods fn unwrap(&self) {} - //~^^ ERROR: `#[track_caller]` is not supported in traits yet. } fn main() {} diff --git a/src/test/ui/rfc-2091-track-caller/error-with-trait-fn-impl.stderr b/src/test/ui/rfc-2091-track-caller/error-with-trait-fn-impl.stderr index 2662fbff7a2c2..9646cb1ac0b08 100644 --- a/src/test/ui/rfc-2091-track-caller/error-with-trait-fn-impl.stderr +++ b/src/test/ui/rfc-2091-track-caller/error-with-trait-fn-impl.stderr @@ -6,7 +6,7 @@ LL | #![feature(track_caller)] | = note: `#[warn(incomplete_features)]` on by default -error[E0738]: `#[track_caller]` is not supported in traits yet. +error[E0738]: `#[track_caller]` may not be used on trait methods --> $DIR/error-with-trait-fn-impl.rs:8:5 | LL | #[track_caller] From 6446f192c7aaf913fe32bbaf779b36d53936f867 Mon Sep 17 00:00:00 2001 From: varkor <github@varkor.com> Date: Mon, 14 Oct 2019 17:36:13 +0100 Subject: [PATCH 15/30] Permit `#[target_feature]` on method implementations --- src/librustc/hir/check_attr.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc/hir/check_attr.rs b/src/librustc/hir/check_attr.rs index 55ac95f4ac4b7..a67a4566615d1 100644 --- a/src/librustc/hir/check_attr.rs +++ b/src/librustc/hir/check_attr.rs @@ -278,7 +278,7 @@ impl CheckAttrVisitor<'tcx> { /// Checks if the `#[target_feature]` attribute on `item` is valid. Returns `true` if valid. fn check_target_feature(&self, attr: &Attribute, span: &Span, target: Target) -> bool { match target { - Target::Fn => true, + Target::Fn | Target::Method { body: true } => true, _ => { self.tcx.sess .struct_span_err(attr.span, "attribute should be applied to a function") From f8db8ffcf32199dd534768ed30233724dab1fc08 Mon Sep 17 00:00:00 2001 From: varkor <github@varkor.com> Date: Thu, 24 Oct 2019 22:21:30 +0100 Subject: [PATCH 16/30] Permit #[track_caller] on inherent methods --- src/librustc/hir/check_attr.rs | 44 ++++++++++++++----- .../error-with-trait-fn-impl.rs | 9 ++++ .../error-with-trait-fn-impl.stderr | 4 +- 3 files changed, 43 insertions(+), 14 deletions(-) diff --git a/src/librustc/hir/check_attr.rs b/src/librustc/hir/check_attr.rs index a67a4566615d1..7ee1d3448c4e9 100644 --- a/src/librustc/hir/check_attr.rs +++ b/src/librustc/hir/check_attr.rs @@ -16,6 +16,12 @@ use std::fmt::{self, Display}; use syntax::{attr, symbol::sym}; use syntax_pos::Span; +#[derive(Copy, Clone, PartialEq)] +pub(crate) enum MethodKind { + Trait { body: bool }, + Inherent, +} + #[derive(Copy, Clone, PartialEq)] pub(crate) enum Target { ExternCrate, @@ -38,7 +44,7 @@ pub(crate) enum Target { Expression, Statement, AssocConst, - Method { body: bool }, + Method(MethodKind), AssocTy, ForeignFn, ForeignStatic, @@ -68,7 +74,7 @@ impl Display for Target { Target::Expression => "expression", Target::Statement => "statement", Target::AssocConst => "associated const", - Target::Method { .. } => "method", + Target::Method(_) => "method", Target::AssocTy => "associated type", Target::ForeignFn => "foreign function", Target::ForeignStatic => "foreign static item", @@ -103,10 +109,10 @@ impl Target { match trait_item.kind { TraitItemKind::Const(..) => Target::AssocConst, TraitItemKind::Method(_, hir::TraitMethod::Required(_)) => { - Target::Method { body: false } + Target::Method(MethodKind::Trait { body: false }) } TraitItemKind::Method(_, hir::TraitMethod::Provided(_)) => { - Target::Method { body: true } + Target::Method(MethodKind::Trait { body: true }) } TraitItemKind::Type(..) => Target::AssocTy, } @@ -120,10 +126,22 @@ impl Target { } } - fn from_impl_item(impl_item: &hir::ImplItem) -> Target { + fn from_impl_item<'tcx>(tcx: TyCtxt<'tcx>, impl_item: &hir::ImplItem) -> Target { match impl_item.kind { hir::ImplItemKind::Const(..) => Target::Const, - hir::ImplItemKind::Method(..) => Target::Method { body: true }, + hir::ImplItemKind::Method(..) => { + let parent_hir_id = tcx.hir().get_parent_item(impl_item.hir_id); + let containing_item = tcx.hir().expect_item(parent_hir_id); + let containing_impl_is_for_trait = match &containing_item.kind { + hir::ItemKind::Impl(_, _, _, _, tr, _, _) => tr.is_some(), + _ => bug!("parent of an ImplItem must be an Impl"), + }; + if containing_impl_is_for_trait { + Target::Method(MethodKind::Trait { body: true }) + } else { + Target::Method(MethodKind::Inherent) + } + } hir::ImplItemKind::TyAlias(..) => Target::TyAlias, hir::ImplItemKind::OpaqueTy(..) => Target::OpaqueTy, } @@ -176,8 +194,9 @@ impl CheckAttrVisitor<'tcx> { /// Checks if an `#[inline]` is applied to a function or a closure. Returns `true` if valid. fn check_inline(&self, hir_id: HirId, attr: &Attribute, span: &Span, target: Target) -> bool { match target { - Target::Fn | Target::Closure | Target::Method { body: true } => true, - Target::Method { body: false } | Target::ForeignFn => { + Target::Fn | Target::Closure | Target::Method(MethodKind::Trait { body: true }) + | Target::Method(MethodKind::Inherent) => true, + Target::Method(MethodKind::Trait { body: false }) | Target::ForeignFn => { self.tcx.struct_span_lint_hir( UNUSED_ATTRIBUTES, hir_id, @@ -216,8 +235,8 @@ impl CheckAttrVisitor<'tcx> { ).emit(); false } - Target::Fn => true, - Target::Method { .. } => { + Target::Fn | Target::Method(MethodKind::Inherent) => true, + Target::Method(_) => { struct_span_err!( self.tcx.sess, *attr_span, @@ -278,7 +297,8 @@ impl CheckAttrVisitor<'tcx> { /// Checks if the `#[target_feature]` attribute on `item` is valid. Returns `true` if valid. fn check_target_feature(&self, attr: &Attribute, span: &Span, target: Target) -> bool { match target { - Target::Fn | Target::Method { body: true } => true, + Target::Fn | Target::Method(MethodKind::Trait { body: true }) + | Target::Method(MethodKind::Inherent) => true, _ => { self.tcx.sess .struct_span_err(attr.span, "attribute should be applied to a function") @@ -471,7 +491,7 @@ impl Visitor<'tcx> for CheckAttrVisitor<'tcx> { } fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) { - let target = Target::from_impl_item(impl_item); + let target = Target::from_impl_item(self.tcx, impl_item); self.check_attributes(impl_item.hir_id, &impl_item.attrs, &impl_item.span, target, None); intravisit::walk_impl_item(self, impl_item) } diff --git a/src/test/ui/rfc-2091-track-caller/error-with-trait-fn-impl.rs b/src/test/ui/rfc-2091-track-caller/error-with-trait-fn-impl.rs index 9b97df2e4eb33..b565e11f55b2a 100644 --- a/src/test/ui/rfc-2091-track-caller/error-with-trait-fn-impl.rs +++ b/src/test/ui/rfc-2091-track-caller/error-with-trait-fn-impl.rs @@ -1,3 +1,5 @@ +// check-fail + #![feature(track_caller)] //~ WARN the feature `track_caller` is incomplete trait Trait { @@ -9,4 +11,11 @@ impl Trait for u64 { fn unwrap(&self) {} } +struct S; + +impl S { + #[track_caller] // ok + fn foo() {} +} + fn main() {} diff --git a/src/test/ui/rfc-2091-track-caller/error-with-trait-fn-impl.stderr b/src/test/ui/rfc-2091-track-caller/error-with-trait-fn-impl.stderr index 9646cb1ac0b08..707b367484c2c 100644 --- a/src/test/ui/rfc-2091-track-caller/error-with-trait-fn-impl.stderr +++ b/src/test/ui/rfc-2091-track-caller/error-with-trait-fn-impl.stderr @@ -1,5 +1,5 @@ warning: the feature `track_caller` is incomplete and may cause the compiler to crash - --> $DIR/error-with-trait-fn-impl.rs:1:12 + --> $DIR/error-with-trait-fn-impl.rs:3:12 | LL | #![feature(track_caller)] | ^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | #![feature(track_caller)] = note: `#[warn(incomplete_features)]` on by default error[E0738]: `#[track_caller]` may not be used on trait methods - --> $DIR/error-with-trait-fn-impl.rs:8:5 + --> $DIR/error-with-trait-fn-impl.rs:10:5 | LL | #[track_caller] | ^^^^^^^^^^^^^^^ From f47f53078c7477d2a2f7739c8f0e295125dd6bd3 Mon Sep 17 00:00:00 2001 From: varkor <github@varkor.com> Date: Sat, 26 Oct 2019 00:46:07 +0100 Subject: [PATCH 17/30] Make inline associated constants a future compatibility warning --- src/librustc/hir/check_attr.rs | 34 +++++++++++++---- .../ui/lint/inline-trait-and-foreign-items.rs | 8 +++- .../inline-trait-and-foreign-items.stderr | 37 +++++++++++-------- 3 files changed, 54 insertions(+), 25 deletions(-) diff --git a/src/librustc/hir/check_attr.rs b/src/librustc/hir/check_attr.rs index 7ee1d3448c4e9..96562002aa070 100644 --- a/src/librustc/hir/check_attr.rs +++ b/src/librustc/hir/check_attr.rs @@ -128,7 +128,7 @@ impl Target { fn from_impl_item<'tcx>(tcx: TyCtxt<'tcx>, impl_item: &hir::ImplItem) -> Target { match impl_item.kind { - hir::ImplItemKind::Const(..) => Target::Const, + hir::ImplItemKind::Const(..) => Target::AssocConst, hir::ImplItemKind::Method(..) => { let parent_hir_id = tcx.hir().get_parent_item(impl_item.hir_id); let containing_item = tcx.hir().expect_item(parent_hir_id); @@ -142,8 +142,7 @@ impl Target { Target::Method(MethodKind::Inherent) } } - hir::ImplItemKind::TyAlias(..) => Target::TyAlias, - hir::ImplItemKind::OpaqueTy(..) => Target::OpaqueTy, + hir::ImplItemKind::TyAlias(..) | hir::ImplItemKind::OpaqueTy(..) => Target::AssocTy, } } } @@ -205,12 +204,31 @@ impl CheckAttrVisitor<'tcx> { ).emit(); true } + // FIXME(#65833): We permit associated consts to have an `#[inline]` attribute with + // just a lint, because we previously erroneously allowed it and some crates used it + // accidentally, to to be compatible with crates depending on them, we can't throw an + // error here. + Target::AssocConst => { + self.tcx.struct_span_lint_hir( + UNUSED_ATTRIBUTES, + hir_id, + attr.span, + "`#[inline]` is ignored on constants", + ).warn("this was previously accepted by the compiler but is \ + being phased out; it will become a hard error in \ + a future release!") + .note("for more information, see issue #65833 \ + <https://github.com/rust-lang/rust/issues/65833>") + .emit(); + true + } _ => { - struct_span_err!(self.tcx.sess, - attr.span, - E0518, - "attribute should be applied to function or closure") - .span_label(*span, "not a function or closure") + struct_span_err!( + self.tcx.sess, + attr.span, + E0518, + "attribute should be applied to function or closure", + ).span_label(*span, "not a function or closure") .emit(); false } diff --git a/src/test/ui/lint/inline-trait-and-foreign-items.rs b/src/test/ui/lint/inline-trait-and-foreign-items.rs index 2beb5aaba6590..8bdefbb36ae5f 100644 --- a/src/test/ui/lint/inline-trait-and-foreign-items.rs +++ b/src/test/ui/lint/inline-trait-and-foreign-items.rs @@ -1,8 +1,11 @@ #![feature(extern_types)] #![feature(type_alias_impl_trait)] +#![warn(unused_attributes)] + trait Trait { - #[inline] //~ ERROR attribute should be applied to function or closure + #[inline] //~ WARN `#[inline]` is ignored on constants + //~^ WARN this was previously accepted const X: u32; #[inline] //~ ERROR attribute should be applied to function or closure @@ -12,7 +15,8 @@ trait Trait { } impl Trait for () { - #[inline] //~ ERROR attribute should be applied to function or closure + #[inline] //~ WARN `#[inline]` is ignored on constants + //~^ WARN this was previously accepted const X: u32 = 0; #[inline] //~ ERROR attribute should be applied to function or closure diff --git a/src/test/ui/lint/inline-trait-and-foreign-items.stderr b/src/test/ui/lint/inline-trait-and-foreign-items.stderr index f67c7a6018ce4..6c94f88f13948 100644 --- a/src/test/ui/lint/inline-trait-and-foreign-items.stderr +++ b/src/test/ui/lint/inline-trait-and-foreign-items.stderr @@ -1,5 +1,5 @@ error[E0518]: attribute should be applied to function or closure - --> $DIR/inline-trait-and-foreign-items.rs:26:5 + --> $DIR/inline-trait-and-foreign-items.rs:30:5 | LL | #[inline] | ^^^^^^^^^ @@ -7,39 +7,46 @@ LL | static X: u32; | -------------- not a function or closure error[E0518]: attribute should be applied to function or closure - --> $DIR/inline-trait-and-foreign-items.rs:29:5 + --> $DIR/inline-trait-and-foreign-items.rs:33:5 | LL | #[inline] | ^^^^^^^^^ LL | type T; | ------- not a function or closure -error[E0518]: attribute should be applied to function or closure - --> $DIR/inline-trait-and-foreign-items.rs:5:5 +warning: `#[inline]` is ignored on constants + --> $DIR/inline-trait-and-foreign-items.rs:7:5 | LL | #[inline] | ^^^^^^^^^ -LL | const X: u32; - | ------------- not a function or closure + | +note: lint level defined here + --> $DIR/inline-trait-and-foreign-items.rs:4:9 + | +LL | #![warn(unused_attributes)] + | ^^^^^^^^^^^^^^^^^ + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #65833 <https://github.com/rust-lang/rust/issues/65833> error[E0518]: attribute should be applied to function or closure - --> $DIR/inline-trait-and-foreign-items.rs:8:5 + --> $DIR/inline-trait-and-foreign-items.rs:11:5 | LL | #[inline] | ^^^^^^^^^ LL | type T; | ------- not a function or closure -error[E0518]: attribute should be applied to function or closure - --> $DIR/inline-trait-and-foreign-items.rs:15:5 +warning: `#[inline]` is ignored on constants + --> $DIR/inline-trait-and-foreign-items.rs:18:5 | LL | #[inline] | ^^^^^^^^^ -LL | const X: u32 = 0; - | ----------------- not a function or closure + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #65833 <https://github.com/rust-lang/rust/issues/65833> error[E0518]: attribute should be applied to function or closure - --> $DIR/inline-trait-and-foreign-items.rs:18:5 + --> $DIR/inline-trait-and-foreign-items.rs:22:5 | LL | #[inline] | ^^^^^^^^^ @@ -47,7 +54,7 @@ LL | type T = Self; | -------------- not a function or closure error[E0518]: attribute should be applied to function or closure - --> $DIR/inline-trait-and-foreign-items.rs:21:5 + --> $DIR/inline-trait-and-foreign-items.rs:25:5 | LL | #[inline] | ^^^^^^^^^ @@ -55,11 +62,11 @@ LL | type U = impl Trait; | -------------------- not a function or closure error: could not find defining uses - --> $DIR/inline-trait-and-foreign-items.rs:22:5 + --> $DIR/inline-trait-and-foreign-items.rs:26:5 | LL | type U = impl Trait; | ^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 8 previous errors +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0518`. From 1099826efa725b5de7833d42f2b96a53881e2118 Mon Sep 17 00:00:00 2001 From: roblabla <unfiltered@roblab.la> Date: Sat, 26 Oct 2019 21:05:13 +0000 Subject: [PATCH 18/30] Only run efiapi test on llvm 9.0+ --- src/test/codegen/abi-efiapi.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/codegen/abi-efiapi.rs b/src/test/codegen/abi-efiapi.rs index cfd31ef1a31fd..72adb95e96af9 100644 --- a/src/test/codegen/abi-efiapi.rs +++ b/src/test/codegen/abi-efiapi.rs @@ -2,6 +2,8 @@ // revisions:x86_64 i686 aarch64 arm riscv +// min-llvm-version 9.0 + //[x86_64] compile-flags: --target x86_64-unknown-uefi //[i686] compile-flags: --target i686-unknown-linux-musl //[aarch64] compile-flags: --target aarch64-unknown-none From adfe9a45d60198316952baa5088ae77a8a5e919a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= <esteban@kuber.com.ar> Date: Fri, 11 Oct 2019 12:37:48 -0700 Subject: [PATCH 19/30] 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<Ty<'tcx>>), 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<T> Remote for Pair<T,Cover<T>> { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `lib::Pair<T, Cover<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_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<T> Remote for Pair<Cover<T>,T> { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `lib::Pair<Cover<T>, 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<T,U> Remote for Pair<Cover<T>,U> { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `lib::Pair<Cover<T>, 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<Local> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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<Local> + '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<Local> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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<Local> + '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<usize> 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<isize> { } | ^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `std::vec::Vec<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/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<usize> 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<isize> { } | ^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `std::vec::Vec<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/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<T> Remote for lib::Pair<T,Foo> { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `lib::Pair<T, Foo>` 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<T, U> Remote1<Pair<T, Local<U>>> 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<T, Local<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-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<T,U> Remote for Pair<T,Local<U>> { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `lib::Pair<T, Local<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-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<T> Remote for Vec<Local<T>> { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `std::vec::Vec<Local<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-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<Local> { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `std::vec::Vec<Local>` 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<Local> { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `std::vec::Vec<Local>` 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<MyType> { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `lib::MyStruct<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_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<MyType> { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `lib::MyStruct<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.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<u32> 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<C> { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | - = note: the impl does not reference only types defined in this crate + = note: `lib::Something<C>` 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?= <esteban@kuber.com.ar> Date: Sat, 12 Oct 2019 14:31:23 -0700 Subject: [PATCH 20/30] 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<Ty<'tcx>>), + 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<T>`) - --> $DIR/coherence-all-remote.rs:9:1 + --> $DIR/coherence-all-remote.rs:9:6 | LL | impl<T> Remote1<T> 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<T>`) - --> $DIR/coherence-all-remote.rs:9:1 + --> $DIR/coherence-all-remote.rs:9:6 | LL | impl<T> Remote1<T> 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<T>`) - --> $DIR/coherence-bigint-param.rs:11:1 + --> $DIR/coherence-bigint-param.rs:11:6 | LL | impl<T> Remote1<BigInt> 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<T>`) - --> $DIR/coherence-bigint-param.rs:11:1 + --> $DIR/coherence-bigint-param.rs:11:6 | LL | impl<T> Remote1<BigInt> 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<T>`) - --> $DIR/coherence-cow.rs:18:1 + --> $DIR/coherence-cow.rs:18:6 | LL | impl<T> Remote for Pair<T,Cover<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.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<T>`) - --> $DIR/coherence-cow.rs:23:1 + --> $DIR/coherence-cow.rs:23:6 | LL | impl<T> Remote for Pair<Cover<T>,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<T>`) - --> $DIR/coherence-cow.rs:28:1 + --> $DIR/coherence-cow.rs:28:6 | LL | impl<T,U> Remote for Pair<Cover<T>,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<T> Remote for Pair<T,Cover<T>> { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^---------------- + | | | + | | `lib::Pair<T, Cover<T>>` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `lib::Pair<T, Cover<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_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<T> Remote for Pair<Cover<T>,T> { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^---------------- + | | | + | | `lib::Pair<Cover<T>, T>` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `lib::Pair<Cover<T>, 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<T,U> Remote for Pair<Cover<T>,U> { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^^^---------------- + | | | + | | `lib::Pair<Cover<T>, U>` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `lib::Pair<Cover<T>, 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<A> 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<A>`) - --> $DIR/coherence-cross-crate-conflict.rs:12:1 + --> $DIR/coherence-cross-crate-conflict.rs:12:6 | LL | impl<A> 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<A> 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<A>`) - --> $DIR/coherence-cross-crate-conflict.rs:12:1 + --> $DIR/coherence-cross-crate-conflict.rs:12:6 | LL | impl<A> 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<Local> {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^---------------------- + | | | + | | `(dyn coherence_fundamental_trait_lib::Fundamental<Local> + '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<Local> + '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<Local> {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^---------------------- + | | | + | | `(dyn coherence_fundamental_trait_lib::Fundamental<Local> + '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<Local> + '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<T>`) - --> $DIR/coherence-lone-type-parameter.rs:9:1 + --> $DIR/coherence-lone-type-parameter.rs:9:6 | LL | impl<T> 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<T>`) - --> $DIR/coherence-lone-type-parameter.rs:9:1 + --> $DIR/coherence-lone-type-parameter.rs:9:6 | LL | impl<T> 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<usize> 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<isize> { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^---------- + | | | + | | `std::vec::Vec<isize>` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `std::vec::Vec<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/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<usize> 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<isize> { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^---------- + | | | + | | `std::vec::Vec<isize>` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `std::vec::Vec<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/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<T>`) - --> $DIR/coherence-overlapping-pairs.rs:11:1 + --> $DIR/coherence-overlapping-pairs.rs:11:6 | LL | impl<T> Remote for lib::Pair<T,Foo> { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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<T> Remote for lib::Pair<T,Foo> { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^---------------- + | | | + | | `lib::Pair<T, Foo>` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `lib::Pair<T, Foo>` 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<T>`) - --> $DIR/coherence-pair-covered-uncovered-1.rs:15:1 + --> $DIR/coherence-pair-covered-uncovered-1.rs:15:6 | LL | impl<T, U> Remote1<Pair<T, Local<U>>> 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<T, U> Remote1<Pair<T, Local<U>>> 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<T, Local<U>>` is not defined in the current create + = note: `lib::Pair<T, Local<U>>` 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<T>`) - --> $DIR/coherence-pair-covered-uncovered.rs:11:1 + --> $DIR/coherence-pair-covered-uncovered.rs:11:6 | LL | impl<T,U> Remote for Pair<T,Local<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-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<T,U> Remote for Pair<T,Local<U>> { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^^^---------------- + | | | + | | `lib::Pair<T, Local<U>>` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `lib::Pair<T, Local<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-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<T>`) - --> $DIR/coherence-vec-local-2.rs:14:1 + --> $DIR/coherence-vec-local-2.rs:14:6 | LL | impl<T> Remote for Vec<Local<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-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<T> Remote for Vec<Local<T>> { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^------------- + | | | + | | `std::vec::Vec<Local<T>>` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `std::vec::Vec<Local<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-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<Local> { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^---------- + | | | + | | `std::vec::Vec<Local>` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `std::vec::Vec<Local>` 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<Local> { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^---------- + | | | + | | `std::vec::Vec<Local>` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `std::vec::Vec<Local>` 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<MyType> { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^^^--------------------- + | | | + | | `lib::MyStruct<MyType>` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `lib::MyStruct<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_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<MyType> { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^^^--------------------- + | | | + | | `lib::MyStruct<MyType>` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `lib::MyStruct<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.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<u32> 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<T>`) - --> $DIR/impl[t]-foreign[foreign]-for-fundamental[t].rs:12:1 + --> $DIR/impl[t]-foreign[foreign]-for-fundamental[t].rs:12:6 | LL | impl<T> Remote1<u32> for Box<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<T>`) - --> $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<u32> 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<T>`) - --> $DIR/impl[t]-foreign[foreign]-for-t.rs:12:1 + --> $DIR/impl[t]-foreign[foreign]-for-t.rs:12:6 | LL | impl<T> Remote1<u32> 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<T>`) - --> $DIR/impl[t]-foreign[fundamental[t]]-for-foreign.rs:12:1 + --> $DIR/impl[t]-foreign[fundamental[t]]-for-foreign.rs:12:6 | LL | impl<T> Remote1<Box<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 error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`) - --> $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<T>`) - --> $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<Box<T>> 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<T>`) - --> $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<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-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<T>`) - --> $DIR/impl[t]-foreign[fundamental[t]]-for-t.rs:12:1 + --> $DIR/impl[t]-foreign[fundamental[t]]-for-t.rs:12:6 | LL | impl<T> Remote1<Box<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 error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`) - --> $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<T>`) - --> $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<T> Remote2<Box<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 error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`) - --> $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<T>`) - --> $DIR/impl[t]-foreign[local]-for-fundamental[t].rs:12:1 + --> $DIR/impl[t]-foreign[local]-for-fundamental[t].rs:12:6 | LL | impl<T> Remote1<Local> for Box<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<T>`) - --> $DIR/impl[t]-foreign[local]-for-fundamental[t].rs:16:1 + --> $DIR/impl[t]-foreign[local]-for-fundamental[t].rs:16:6 | LL | impl<T> Remote1<Local> 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<T>`) - --> $DIR/impl[t]-foreign[local]-for-t.rs:12:1 + --> $DIR/impl[t]-foreign[local]-for-t.rs:12:6 | LL | impl<T> Remote1<Local> 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<T>`) - --> $DIR/impl[t]-foreign[t]-for-foreign.rs:12:1 + --> $DIR/impl[t]-foreign[t]-for-foreign.rs:12:6 | LL | impl<T> Remote1<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[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<T>`) - --> $DIR/impl[t]-foreign[t]-for-fundamental.rs:12:1 + --> $DIR/impl[t]-foreign[t]-for-fundamental.rs:12:6 | LL | impl<T> Remote1<T> for Box<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 `B` must be used as the type parameter for some local type (e.g., `MyStruct<B>`) - --> $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<A> 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<T>`) - --> $DIR/impl[t]-foreign[t]-for-t.rs:12:1 + --> $DIR/impl[t]-foreign[t]-for-t.rs:12:6 | LL | impl<T> Remote1<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/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<R> External for (Q, R) {} where <U as std::ops::FnOnce<(T,)>>::Output == V, <V as std::iter::Iterator>::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, <W as 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<R>`) - --> $DIR/complex-impl.rs:9:1 + --> $DIR/complex-impl.rs:9:6 | LL | impl<R> 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<Foo> 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<Foo>`) - --> $DIR/issue-28981.rs:5:1 + --> $DIR/issue-28981.rs:5:6 | LL | impl<Foo> 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<T>`) - --> $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<Oracle> 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<T> 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<T>`) - --> $DIR/issue-41974.rs:7:1 + --> $DIR/issue-41974.rs:7:6 | LL | impl<T> 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<T>`) - --> $DIR/orphan-check-diagnostics.rs:11:1 + --> $DIR/orphan-check-diagnostics.rs:11:6 | LL | impl<T> 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<C> { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^^^^^^----------------- + | | | + | | `lib::Something<C>` is not defined in the current crate + | impl doesn't use only types from inside the current crate | - = note: `lib::Something<C>` 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?= <esteban@kuber.com.ar> Date: Sat, 12 Oct 2019 14:44:16 -0700 Subject: [PATCH 21/30] 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<usize> 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<usize> 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<T, U> Remote1<Pair<T, Local<U>>> for i32 { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- - | | | - | | `i32` is not defined in the current crate + | ^^^^^^^^^^^--------------------------^^^^^--- + | | | | + | | | `i32` is not defined in the current crate + | | `lib::Pair<T, Local<U>>` is not defined in the current crate | impl doesn't use only types from inside the current crate | - = note: `lib::Pair<T, Local<U>>` 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<u32> 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?= <esteban@kuber.com.ar> Date: Sun, 13 Oct 2019 11:25:30 -0700 Subject: [PATCH 22/30] 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<Ty<'tcx>> { - if ty_is_local_constructor(tcx, ty, in_crate) { +fn uncovered_tys<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, in_crate: InCrate) -> Vec<Ty<'tcx>> { + 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<Vec<Ty<'t>>> { + 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<Ty<'tcx>> { + 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<A>` in `impl<A, B> for C<B> in D<A>` err.span_label(impl_ty.span, &msg); } else { + // Point at `C<B>` in `impl<A, B> for C<B> in D<A>` 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<Local> {} | ^^^^^^^^^^^^^^---------------------- | | | - | | `(dyn coherence_fundamental_trait_lib::Fundamental<Local> + 'static)` is not defined in the current crate + | | `dyn coherence_fundamental_trait_lib::Fundamental<Local>` 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<Local> {} | ^^^^^^^^^^^^^^---------------------- | | | - | | `(dyn coherence_fundamental_trait_lib::Fundamental<Local> + 'static)` is not defined in the current crate + | | `dyn coherence_fundamental_trait_lib::Fundamental<Local>` 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?= <esteban@kuber.com.ar> Date: Sun, 13 Oct 2019 11:35:21 -0700 Subject: [PATCH 23/30] 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?= <esteban@kuber.com.ar> Date: Wed, 23 Oct 2019 17:06:01 -0700 Subject: [PATCH 24/30] 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<MyType>`, we will properly attribute the + // problem to `Vec<T>` 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<A>` in `impl<A, B> for C<B> in D<A>` 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<T> Remote for Pair<T,Cover<T>> { } | ^^^^^^^^^^^^^^^^^^^---------------- | | | - | | `lib::Pair<T, Cover<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_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<T> Remote for Pair<Cover<T>,T> { } | ^^^^^^^^^^^^^^^^^^^---------------- | | | - | | `lib::Pair<Cover<T>, 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<T,U> Remote for Pair<Cover<T>,U> { } | ^^^^^^^^^^^^^^^^^^^^^---------------- | | | - | | `lib::Pair<Cover<T>, 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<isize> { } | ^^^^^^^^^^^^^^^---------- | | | - | | `std::vec::Vec<isize>` 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<isize> { } | ^^^^^^^^^^^^^^^---------- | | | - | | `std::vec::Vec<isize>` 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<T> Remote for lib::Pair<T,Foo> { } | ^^^^^^^^^^^^^^^^^^^---------------- | | | - | | `lib::Pair<T, Foo>` 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<T, U> Remote1<Pair<T, Local<U>>> for i32 { } | ^^^^^^^^^^^--------------------------^^^^^--- | | | | | | | `i32` is not defined in the current crate - | | `lib::Pair<T, Local<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-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<T,U> Remote for Pair<T,Local<U>> { } | ^^^^^^^^^^^^^^^^^^^^^---------------- | | | - | | `lib::Pair<T, Local<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-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<T> Remote for Vec<Local<T>> { } | ^^^^^^^^^^^^^^^^^^^------------- | | | - | | `std::vec::Vec<Local<T>>` 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<Local> { } | ^^^^^^^^^^^^^^^^---------- | | | - | | `std::vec::Vec<Local>` 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<Local> { } | ^^^^^^^^^^^^^^^^---------- | | | - | | `std::vec::Vec<Local>` 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<MyType> { } | ^^^^^^^^^^^^^^^^^^^^^--------------------- | | | - | | `lib::MyStruct<MyType>` 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<MyType> { } | ^^^^^^^^^^^^^^^^^^^^^--------------------- | | | - | | `lib::MyStruct<MyType>` 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<Rc<i32>> 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<Rc<Local>> 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<T> Remote1<Rc<T>> 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<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[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<T> Remote for Box<Rc<T>> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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<Box<String>> 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<Box<Rc<i32>>> 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<T> Remote1<Box<Rc<T>>> 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<Local> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ 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<T> Remote for Arc<T> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ 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<T>`) - --> $DIR/impl[t]-foreign-for-fundamental[t].rs:12:1 + --> $DIR/impl[t]-foreign-for-fundamental[t].rs:12:6 | LL | impl<T> Remote for Box<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/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<C> { } | ^^^^^^^^^^^^^^^^^^^^^^^^----------------- | | | - | | `lib::Something<C>` 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?= <esteban@kuber.com.ar> Date: Sun, 27 Oct 2019 10:22:22 -0700 Subject: [PATCH 25/30] 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?= <esteban@kuber.com.ar> Date: Mon, 28 Oct 2019 10:43:17 -0700 Subject: [PATCH 26/30] 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<Ty<'a>> { - if fundamental_ty(ty) && !ty_is_local(tcx, ty, in_crate) { + ) -> Vec<Ty<'tcx>> { + 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] From 273ee611f08e4a788da5f3e137feb68ee310a5c8 Mon Sep 17 00:00:00 2001 From: Patryk Wychowaniec <wychowaniec.patryk@gmail.com> Date: Fri, 18 Oct 2019 18:05:54 +0200 Subject: [PATCH 27/30] Improve the "try using a variant of the expected type" hint. --- src/librustc/hir/print.rs | 2 -- src/librustc_typeck/check/demand.rs | 9 +++++++-- src/test/ui/did_you_mean/issue-42764.rs | 2 +- src/test/ui/did_you_mean/issue-42764.stderr | 2 +- src/test/ui/error-codes/E0164.stderr | 2 +- src/test/ui/fn-in-pat.stderr | 2 +- .../fully-qualified-type-name1.stderr | 2 +- src/test/ui/issues/issue-28992-empty.rs | 2 +- src/test/ui/issues/issue-28992-empty.stderr | 2 +- src/test/ui/issues/issue-46112.stderr | 2 +- src/test/ui/issues/issue-55587.stderr | 2 +- src/test/ui/match/match-fn-call.stderr | 4 ++-- src/test/ui/methods/method-path-in-pattern.rs | 12 ++++++------ .../ui/methods/method-path-in-pattern.stderr | 12 ++++++------ src/test/ui/qualified/qualified-path-params.rs | 2 +- .../ui/qualified/qualified-path-params.stderr | 2 +- ...ariant-form-through-Self-issue-58006.stderr | 2 +- ...orrect-variant-form-through-alias-caught.rs | 10 +++++----- ...ct-variant-form-through-alias-caught.stderr | 18 +++++++++--------- 19 files changed, 47 insertions(+), 44 deletions(-) diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs index b852098d4cef7..b6001c30cb030 100644 --- a/src/librustc/hir/print.rs +++ b/src/librustc/hir/print.rs @@ -1523,9 +1523,7 @@ impl<'a> State<'a> { colons_before_params) } hir::QPath::TypeRelative(ref qself, ref item_segment) => { - self.s.word("<"); self.print_type(qself); - self.s.word(">"); self.s.word("::"); self.print_ident(item_segment.ident); self.print_generic_args(item_segment.generic_args(), diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index 3509d6566ec93..b4e07e4a0dfb4 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -172,10 +172,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }).peekable(); if compatible_variants.peek().is_some() { - let expr_text = print::to_string(print::NO_ANN, |s| s.print_expr(expr)); + let expr_text = self.tcx.sess + .source_map() + .span_to_snippet(expr.span) + .unwrap_or_else(|_| { + print::to_string(print::NO_ANN, |s| s.print_expr(expr)) + }); let suggestions = compatible_variants .map(|v| format!("{}({})", v, expr_text)); - let msg = "try using a variant of the expected type"; + let msg = "try using a variant of the expected enum"; err.span_suggestions(expr.span, msg, suggestions, Applicability::MaybeIncorrect); } } diff --git a/src/test/ui/did_you_mean/issue-42764.rs b/src/test/ui/did_you_mean/issue-42764.rs index 5dd70aade67f5..700f8128a939a 100644 --- a/src/test/ui/did_you_mean/issue-42764.rs +++ b/src/test/ui/did_you_mean/issue-42764.rs @@ -10,7 +10,7 @@ fn main() { let n: usize = 42; this_function_expects_a_double_option(n); //~^ ERROR mismatched types - //~| HELP try using a variant of the expected type + //~| HELP try using a variant of the expected enum } diff --git a/src/test/ui/did_you_mean/issue-42764.stderr b/src/test/ui/did_you_mean/issue-42764.stderr index 64868c414efb7..0b3e44446aec2 100644 --- a/src/test/ui/did_you_mean/issue-42764.stderr +++ b/src/test/ui/did_you_mean/issue-42764.stderr @@ -6,7 +6,7 @@ LL | this_function_expects_a_double_option(n); | = note: expected type `DoubleOption<_>` found type `usize` -help: try using a variant of the expected type +help: try using a variant of the expected enum | LL | this_function_expects_a_double_option(DoubleOption::FirstSome(n)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/error-codes/E0164.stderr b/src/test/ui/error-codes/E0164.stderr index 4bbddb1978cc5..0db89dfec8408 100644 --- a/src/test/ui/error-codes/E0164.stderr +++ b/src/test/ui/error-codes/E0164.stderr @@ -1,4 +1,4 @@ -error[E0164]: expected tuple struct or tuple variant, found associated constant `<Foo>::B` +error[E0164]: expected tuple struct or tuple variant, found associated constant `Foo::B` --> $DIR/E0164.rs:9:9 | LL | Foo::B(i) => i, diff --git a/src/test/ui/fn-in-pat.stderr b/src/test/ui/fn-in-pat.stderr index 70f84993acfe7..5d6632f2fc2ec 100644 --- a/src/test/ui/fn-in-pat.stderr +++ b/src/test/ui/fn-in-pat.stderr @@ -1,4 +1,4 @@ -error[E0164]: expected tuple struct or tuple variant, found method `<A>::new` +error[E0164]: expected tuple struct or tuple variant, found method `A::new` --> $DIR/fn-in-pat.rs:11:9 | LL | A::new() => (), diff --git a/src/test/ui/fully-qualified-type/fully-qualified-type-name1.stderr b/src/test/ui/fully-qualified-type/fully-qualified-type-name1.stderr index 62ded3e255a44..e488b1f6b0cb6 100644 --- a/src/test/ui/fully-qualified-type/fully-qualified-type-name1.stderr +++ b/src/test/ui/fully-qualified-type/fully-qualified-type-name1.stderr @@ -5,7 +5,7 @@ LL | x = 5; | ^ | | | expected enum `std::option::Option`, found integer - | help: try using a variant of the expected type: `Some(5)` + | help: try using a variant of the expected enum: `Some(5)` | = note: expected type `std::option::Option<usize>` found type `{integer}` diff --git a/src/test/ui/issues/issue-28992-empty.rs b/src/test/ui/issues/issue-28992-empty.rs index f61daa94c5d72..74cfeb6db8e3b 100644 --- a/src/test/ui/issues/issue-28992-empty.rs +++ b/src/test/ui/issues/issue-28992-empty.rs @@ -12,5 +12,5 @@ impl S { fn main() { if let C1(..) = 0 {} //~ ERROR expected tuple struct or tuple variant, found constant `C1` if let S::C2(..) = 0 {} - //~^ ERROR expected tuple struct or tuple variant, found associated constant `<S>::C2` + //~^ ERROR expected tuple struct or tuple variant, found associated constant `S::C2` } diff --git a/src/test/ui/issues/issue-28992-empty.stderr b/src/test/ui/issues/issue-28992-empty.stderr index a4311880bcbe9..71f337278f29a 100644 --- a/src/test/ui/issues/issue-28992-empty.stderr +++ b/src/test/ui/issues/issue-28992-empty.stderr @@ -4,7 +4,7 @@ error[E0532]: expected tuple struct or tuple variant, found constant `C1` LL | if let C1(..) = 0 {} | ^^ not a tuple struct or tuple variant -error[E0164]: expected tuple struct or tuple variant, found associated constant `<S>::C2` +error[E0164]: expected tuple struct or tuple variant, found associated constant `S::C2` --> $DIR/issue-28992-empty.rs:14:12 | LL | if let S::C2(..) = 0 {} diff --git a/src/test/ui/issues/issue-46112.stderr b/src/test/ui/issues/issue-46112.stderr index 939d945c19133..07e90c567480f 100644 --- a/src/test/ui/issues/issue-46112.stderr +++ b/src/test/ui/issues/issue-46112.stderr @@ -5,7 +5,7 @@ LL | fn main() { test(Ok(())); } | ^^ | | | expected enum `std::option::Option`, found () - | help: try using a variant of the expected type: `Some(())` + | help: try using a variant of the expected enum: `Some(())` | = note: expected type `std::option::Option<()>` found type `()` diff --git a/src/test/ui/issues/issue-55587.stderr b/src/test/ui/issues/issue-55587.stderr index 307227e1c4d10..bb0d15a23d605 100644 --- a/src/test/ui/issues/issue-55587.stderr +++ b/src/test/ui/issues/issue-55587.stderr @@ -1,4 +1,4 @@ -error[E0164]: expected tuple struct or tuple variant, found method `<Path>::new` +error[E0164]: expected tuple struct or tuple variant, found method `Path::new` --> $DIR/issue-55587.rs:4:9 | LL | let Path::new(); diff --git a/src/test/ui/match/match-fn-call.stderr b/src/test/ui/match/match-fn-call.stderr index 611904e6e91a0..2d7a0f1614197 100644 --- a/src/test/ui/match/match-fn-call.stderr +++ b/src/test/ui/match/match-fn-call.stderr @@ -1,4 +1,4 @@ -error[E0164]: expected tuple struct or tuple variant, found method `<Path>::new` +error[E0164]: expected tuple struct or tuple variant, found method `Path::new` --> $DIR/match-fn-call.rs:6:9 | LL | Path::new("foo") => println!("foo"), @@ -6,7 +6,7 @@ LL | Path::new("foo") => println!("foo"), | = help: for more information, visit https://doc.rust-lang.org/book/ch18-00-patterns.html -error[E0164]: expected tuple struct or tuple variant, found method `<Path>::new` +error[E0164]: expected tuple struct or tuple variant, found method `Path::new` --> $DIR/match-fn-call.rs:8:9 | LL | Path::new("bar") => println!("bar"), diff --git a/src/test/ui/methods/method-path-in-pattern.rs b/src/test/ui/methods/method-path-in-pattern.rs index 49f5e09edf45a..f94be1734b7b1 100644 --- a/src/test/ui/methods/method-path-in-pattern.rs +++ b/src/test/ui/methods/method-path-in-pattern.rs @@ -13,20 +13,20 @@ impl MyTrait for Foo {} fn main() { match 0u32 { Foo::bar => {} - //~^ ERROR expected unit struct, unit variant or constant, found method `<Foo>::bar` + //~^ ERROR expected unit struct, unit variant or constant, found method `Foo::bar` } match 0u32 { <Foo>::bar => {} - //~^ ERROR expected unit struct, unit variant or constant, found method `<Foo>::bar` + //~^ ERROR expected unit struct, unit variant or constant, found method `Foo::bar` } match 0u32 { <Foo>::trait_bar => {} - //~^ ERROR expected unit struct, unit variant or constant, found method `<Foo>::trait_bar` + //~^ ERROR expected unit struct, unit variant or constant, found method `Foo::trait_bar` } if let Foo::bar = 0u32 {} - //~^ ERROR expected unit struct, unit variant or constant, found method `<Foo>::bar` + //~^ ERROR expected unit struct, unit variant or constant, found method `Foo::bar` if let <Foo>::bar = 0u32 {} - //~^ ERROR expected unit struct, unit variant or constant, found method `<Foo>::bar` + //~^ ERROR expected unit struct, unit variant or constant, found method `Foo::bar` if let Foo::trait_bar = 0u32 {} - //~^ ERROR expected unit struct, unit variant or constant, found method `<Foo>::trait_bar` + //~^ ERROR expected unit struct, unit variant or constant, found method `Foo::trait_bar` } diff --git a/src/test/ui/methods/method-path-in-pattern.stderr b/src/test/ui/methods/method-path-in-pattern.stderr index b290c34d52774..6b0c5946ff8d8 100644 --- a/src/test/ui/methods/method-path-in-pattern.stderr +++ b/src/test/ui/methods/method-path-in-pattern.stderr @@ -1,34 +1,34 @@ -error[E0533]: expected unit struct, unit variant or constant, found method `<Foo>::bar` +error[E0533]: expected unit struct, unit variant or constant, found method `Foo::bar` --> $DIR/method-path-in-pattern.rs:15:9 | LL | Foo::bar => {} | ^^^^^^^^ -error[E0533]: expected unit struct, unit variant or constant, found method `<Foo>::bar` +error[E0533]: expected unit struct, unit variant or constant, found method `Foo::bar` --> $DIR/method-path-in-pattern.rs:19:9 | LL | <Foo>::bar => {} | ^^^^^^^^^^ -error[E0533]: expected unit struct, unit variant or constant, found method `<Foo>::trait_bar` +error[E0533]: expected unit struct, unit variant or constant, found method `Foo::trait_bar` --> $DIR/method-path-in-pattern.rs:23:9 | LL | <Foo>::trait_bar => {} | ^^^^^^^^^^^^^^^^ -error[E0533]: expected unit struct, unit variant or constant, found method `<Foo>::bar` +error[E0533]: expected unit struct, unit variant or constant, found method `Foo::bar` --> $DIR/method-path-in-pattern.rs:26:12 | LL | if let Foo::bar = 0u32 {} | ^^^^^^^^ -error[E0533]: expected unit struct, unit variant or constant, found method `<Foo>::bar` +error[E0533]: expected unit struct, unit variant or constant, found method `Foo::bar` --> $DIR/method-path-in-pattern.rs:28:12 | LL | if let <Foo>::bar = 0u32 {} | ^^^^^^^^^^ -error[E0533]: expected unit struct, unit variant or constant, found method `<Foo>::trait_bar` +error[E0533]: expected unit struct, unit variant or constant, found method `Foo::trait_bar` --> $DIR/method-path-in-pattern.rs:30:12 | LL | if let Foo::trait_bar = 0u32 {} diff --git a/src/test/ui/qualified/qualified-path-params.rs b/src/test/ui/qualified/qualified-path-params.rs index b1b60b4b73fb9..27cad33b553d9 100644 --- a/src/test/ui/qualified/qualified-path-params.rs +++ b/src/test/ui/qualified/qualified-path-params.rs @@ -18,7 +18,7 @@ impl S { fn main() { match 10 { <S as Tr>::A::f::<u8> => {} - //~^ ERROR expected unit struct, unit variant or constant, found method `<<S as Tr>::A>::f<u8>` + //~^ ERROR expected unit struct, unit variant or constant, found method `<S as Tr>::A::f<u8>` 0 ..= <S as Tr>::A::f::<u8> => {} //~ ERROR only char and numeric types are allowed in range } } diff --git a/src/test/ui/qualified/qualified-path-params.stderr b/src/test/ui/qualified/qualified-path-params.stderr index 92792f2e86a83..54e34b5080614 100644 --- a/src/test/ui/qualified/qualified-path-params.stderr +++ b/src/test/ui/qualified/qualified-path-params.stderr @@ -1,4 +1,4 @@ -error[E0533]: expected unit struct, unit variant or constant, found method `<<S as Tr>::A>::f<u8>` +error[E0533]: expected unit struct, unit variant or constant, found method `<S as Tr>::A::f<u8>` --> $DIR/qualified-path-params.rs:20:9 | LL | <S as Tr>::A::f::<u8> => {} diff --git a/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-Self-issue-58006.stderr b/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-Self-issue-58006.stderr index cfe273b9dd255..15d15f2f40d98 100644 --- a/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-Self-issue-58006.stderr +++ b/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-Self-issue-58006.stderr @@ -1,4 +1,4 @@ -error[E0533]: expected unit struct, unit variant or constant, found tuple variant `<Self>::A` +error[E0533]: expected unit struct, unit variant or constant, found tuple variant `Self::A` --> $DIR/incorrect-variant-form-through-Self-issue-58006.rs:8:13 | LL | Self::A => (), diff --git a/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-alias-caught.rs b/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-alias-caught.rs index efdbebf266219..5772450477c1b 100644 --- a/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-alias-caught.rs +++ b/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-alias-caught.rs @@ -8,14 +8,14 @@ type Alias = Enum; fn main() { Alias::Braced; - //~^ ERROR expected unit struct, unit variant or constant, found struct variant `<Alias>::Braced` [E0533] + //~^ ERROR expected unit struct, unit variant or constant, found struct variant `Alias::Braced` [E0533] let Alias::Braced = panic!(); - //~^ ERROR expected unit struct, unit variant or constant, found struct variant `<Alias>::Braced` [E0533] + //~^ ERROR expected unit struct, unit variant or constant, found struct variant `Alias::Braced` [E0533] let Alias::Braced(..) = panic!(); - //~^ ERROR expected tuple struct or tuple variant, found struct variant `<Alias>::Braced` [E0164] + //~^ ERROR expected tuple struct or tuple variant, found struct variant `Alias::Braced` [E0164] Alias::Unit(); - //~^ ERROR expected function, found enum variant `<Alias>::Unit` + //~^ ERROR expected function, found enum variant `Alias::Unit` let Alias::Unit() = panic!(); - //~^ ERROR expected tuple struct or tuple variant, found unit variant `<Alias>::Unit` [E0164] + //~^ ERROR expected tuple struct or tuple variant, found unit variant `Alias::Unit` [E0164] } diff --git a/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-alias-caught.stderr b/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-alias-caught.stderr index 17efc08c6327f..b0de3ee42e339 100644 --- a/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-alias-caught.stderr +++ b/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-alias-caught.stderr @@ -1,38 +1,38 @@ -error[E0533]: expected unit struct, unit variant or constant, found struct variant `<Alias>::Braced` +error[E0533]: expected unit struct, unit variant or constant, found struct variant `Alias::Braced` --> $DIR/incorrect-variant-form-through-alias-caught.rs:10:5 | LL | Alias::Braced; | ^^^^^^^^^^^^^ -error[E0533]: expected unit struct, unit variant or constant, found struct variant `<Alias>::Braced` +error[E0533]: expected unit struct, unit variant or constant, found struct variant `Alias::Braced` --> $DIR/incorrect-variant-form-through-alias-caught.rs:12:9 | LL | let Alias::Braced = panic!(); | ^^^^^^^^^^^^^ -error[E0164]: expected tuple struct or tuple variant, found struct variant `<Alias>::Braced` +error[E0164]: expected tuple struct or tuple variant, found struct variant `Alias::Braced` --> $DIR/incorrect-variant-form-through-alias-caught.rs:14:9 | LL | let Alias::Braced(..) = panic!(); | ^^^^^^^^^^^^^^^^^ not a tuple variant or struct -error[E0618]: expected function, found enum variant `<Alias>::Unit` +error[E0618]: expected function, found enum variant `Alias::Unit` --> $DIR/incorrect-variant-form-through-alias-caught.rs:17:5 | LL | enum Enum { Braced {}, Unit, Tuple() } - | ---- `<Alias>::Unit` defined here + | ---- `Alias::Unit` defined here ... LL | Alias::Unit(); | ^^^^^^^^^^^-- | | | call expression requires function | -help: `<Alias>::Unit` is a unit variant, you need to write it without the parenthesis +help: `Alias::Unit` is a unit variant, you need to write it without the parenthesis | -LL | <Alias>::Unit; - | ^^^^^^^^^^^^^ +LL | Alias::Unit; + | ^^^^^^^^^^^ -error[E0164]: expected tuple struct or tuple variant, found unit variant `<Alias>::Unit` +error[E0164]: expected tuple struct or tuple variant, found unit variant `Alias::Unit` --> $DIR/incorrect-variant-form-through-alias-caught.rs:19:9 | LL | let Alias::Unit() = panic!(); From e188e2db8471aba78c912ef77e222beceb2ea532 Mon Sep 17 00:00:00 2001 From: Patryk Wychowaniec <wychowaniec.patryk@gmail.com> Date: Sat, 26 Oct 2019 15:48:27 +0200 Subject: [PATCH 28/30] Fix a previously forgotten pretty-printing test after a change to the pretty-printing mechanism. --- src/test/pretty/issue-4264.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/pretty/issue-4264.pp b/src/test/pretty/issue-4264.pp index 4cf2e90e635fd..b545146c9646e 100644 --- a/src/test/pretty/issue-4264.pp +++ b/src/test/pretty/issue-4264.pp @@ -30,7 +30,7 @@ ((::alloc::fmt::format as - for<'r> fn(std::fmt::Arguments<'r>) -> std::string::String {std::fmt::format})(((<::core::fmt::Arguments>::new_v1 + for<'r> fn(std::fmt::Arguments<'r>) -> std::string::String {std::fmt::format})(((::core::fmt::Arguments::new_v1 as fn(&[&str], &[std::fmt::ArgumentV1<'_>]) -> std::fmt::Arguments<'_> {std::fmt::Arguments::<'_>::new_v1})((&([("test" as From 5c023d68d8b54d651e1775a69e999503ae5b2b30 Mon Sep 17 00:00:00 2001 From: Patryk Wychowaniec <wychowaniec.patryk@gmail.com> Date: Sun, 27 Oct 2019 16:43:42 +0100 Subject: [PATCH 29/30] Improve pretty-printing for compound qualified paths. --- src/librustc/hir/print.rs | 12 +++++++++++- src/test/ui/qualified/qualified-path-params.rs | 2 +- src/test/ui/qualified/qualified-path-params.stderr | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs index b6001c30cb030..64b355f6ec9d1 100644 --- a/src/librustc/hir/print.rs +++ b/src/librustc/hir/print.rs @@ -1523,7 +1523,17 @@ impl<'a> State<'a> { colons_before_params) } hir::QPath::TypeRelative(ref qself, ref item_segment) => { - self.print_type(qself); + // If we've got a compound-qualified-path, let's push an additional pair of angle + // brackets, so that we pretty-print `<<A::B>::C>` as `<A::B>::C`, instead of just + // `A::B::C` (since the latter could be ambiguous to the user) + if let hir::TyKind::Path(hir::QPath::Resolved(None, _)) = &qself.kind { + self.print_type(qself); + } else { + self.s.word("<"); + self.print_type(qself); + self.s.word(">"); + } + self.s.word("::"); self.print_ident(item_segment.ident); self.print_generic_args(item_segment.generic_args(), diff --git a/src/test/ui/qualified/qualified-path-params.rs b/src/test/ui/qualified/qualified-path-params.rs index 27cad33b553d9..b1b60b4b73fb9 100644 --- a/src/test/ui/qualified/qualified-path-params.rs +++ b/src/test/ui/qualified/qualified-path-params.rs @@ -18,7 +18,7 @@ impl S { fn main() { match 10 { <S as Tr>::A::f::<u8> => {} - //~^ ERROR expected unit struct, unit variant or constant, found method `<S as Tr>::A::f<u8>` + //~^ ERROR expected unit struct, unit variant or constant, found method `<<S as Tr>::A>::f<u8>` 0 ..= <S as Tr>::A::f::<u8> => {} //~ ERROR only char and numeric types are allowed in range } } diff --git a/src/test/ui/qualified/qualified-path-params.stderr b/src/test/ui/qualified/qualified-path-params.stderr index 54e34b5080614..92792f2e86a83 100644 --- a/src/test/ui/qualified/qualified-path-params.stderr +++ b/src/test/ui/qualified/qualified-path-params.stderr @@ -1,4 +1,4 @@ -error[E0533]: expected unit struct, unit variant or constant, found method `<S as Tr>::A::f<u8>` +error[E0533]: expected unit struct, unit variant or constant, found method `<<S as Tr>::A>::f<u8>` --> $DIR/qualified-path-params.rs:20:9 | LL | <S as Tr>::A::f::<u8> => {} From d7f99dadd49e3fed8f4dee4b5a626d0298226d17 Mon Sep 17 00:00:00 2001 From: Tyler Mandry <tmandry@gmail.com> Date: Thu, 17 Oct 2019 15:58:48 -0700 Subject: [PATCH 30/30] Update backtrace to 0.3.40 --- Cargo.lock | 13 +++++++------ src/librustc/Cargo.toml | 6 +++++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4b264ef3f9faf..22997f990afed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -115,9 +115,9 @@ checksum = "b671c8fb71b457dd4ae18c4ba1e59aa81793daacc361d82fcd410cef0d491875" [[package]] name = "backtrace" -version = "0.3.37" +version = "0.3.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5180c5a20655b14a819b652fd2378fa5f1697b6c9ddad3e695c2f9cedf6df4e2" +checksum = "924c76597f0d9ca25d762c25a4d369d51267536465dc5064bdf0eb073ed477ea" dependencies = [ "backtrace-sys", "cfg-if", @@ -129,9 +129,9 @@ dependencies = [ [[package]] name = "backtrace-sys" -version = "0.1.30" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b3a000b9c543553af61bc01cbfc403b04b5caa9e421033866f2e98061eb3e61" +checksum = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491" dependencies = [ "cc", "compiler_builtins", @@ -391,9 +391,9 @@ version = "0.1.0" [[package]] name = "cc" -version = "1.0.35" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e5f3fee5eeb60324c2781f1e41286bdee933850fff9b3c672587fed5ec58c83" +checksum = "39f75544d7bbaf57560d2168f28fd649ff9c76153874db88bdbdfd839b1a7e7d" [[package]] name = "cfg-if" @@ -3113,6 +3113,7 @@ dependencies = [ "backtrace", "bitflags", "byteorder", + "cc", "chalk-engine", "fmt_macros", "graphviz", diff --git a/src/librustc/Cargo.toml b/src/librustc/Cargo.toml index 9d26ff6001767..b8594e96ce496 100644 --- a/src/librustc/Cargo.toml +++ b/src/librustc/Cargo.toml @@ -10,6 +10,10 @@ path = "lib.rs" doctest = false [dependencies] +# Prevent cc from upgrading all the way to 1.0.46, +# which fails the build (see e.g. #65445.) +cc = "=1.0.37" + arena = { path = "../libarena" } bitflags = "1.0" fmt_macros = { path = "../libfmt_macros" } @@ -30,7 +34,7 @@ errors = { path = "../librustc_errors", package = "rustc_errors" } rustc_serialize = { path = "../libserialize", package = "serialize" } syntax = { path = "../libsyntax" } syntax_pos = { path = "../libsyntax_pos" } -backtrace = "0.3.3" +backtrace = "0.3.40" parking_lot = "0.9" byteorder = { version = "1.3" } chalk-engine = { version = "0.9.0", default-features=false }