diff --git a/Cargo.lock b/Cargo.lock index 54ad60e71506b..c9a542b98da92 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -98,12 +98,11 @@ dependencies = [ [[package]] name = "atty" -version = "0.2.11" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" +checksum = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" dependencies = [ "libc", - "termion", "winapi 0.3.8", ] @@ -405,9 +404,9 @@ dependencies = [ [[package]] name = "cfg-if" -version = "0.1.8" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89431bba4e6b7092fb5fcd00a6f6ca596c55cc26b2f1e6dcdd08a1f4933f66b2" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" dependencies = [ "compiler_builtins", "rustc-std-workspace-core", @@ -707,9 +706,9 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.1.2" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91d5240c6975ef33aeb5f148f35275c25eda8e8a5f95abe421978b05b8bf192" +checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" dependencies = [ "cfg-if", ] @@ -780,9 +779,9 @@ dependencies = [ [[package]] name = "crypto-hash" -version = "0.3.1" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09de9ee0fc255ace04c7fa0763c9395a945c37c8292bb554f8d48361d1dcf1b4" +checksum = "8a77162240fd97248d19a564a565eb563a3f592b386e4136fb300909e67dddca" dependencies = [ "commoncrypto", "hex 0.3.2", @@ -792,9 +791,9 @@ dependencies = [ [[package]] name = "curl" -version = "0.4.24" +version = "0.4.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d08ad3cb89d076a36b0ce5749eec2c9964f70c0c58480ab6b75a91ec4fc206d8" +checksum = "06aa71e9208a54def20792d877bc663d6aae0732b9852e612c4a933177c31283" dependencies = [ "curl-sys", "libc", @@ -807,9 +806,9 @@ dependencies = [ [[package]] name = "curl-sys" -version = "0.4.22" +version = "0.4.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e9a9a4e417722876332136a00cacf92c2ceb331fab4b52b6a1ad16c6cd79255" +checksum = "0c38ca47d60b86d0cc9d42caa90a0885669c2abc9791f871c81f58cdf39e979b" dependencies = [ "cc", "libc", @@ -1044,9 +1043,9 @@ dependencies = [ [[package]] name = "failure" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" +checksum = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9" dependencies = [ "backtrace", "failure_derive", @@ -1054,14 +1053,14 @@ dependencies = [ [[package]] name = "failure_derive" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" +checksum = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08" dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.12", - "syn 0.15.35", - "synstructure 0.10.2", + "proc-macro2 1.0.3", + "quote 1.0.2", + "syn 1.0.11", + "synstructure", ] [[package]] @@ -1072,20 +1071,21 @@ checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" [[package]] name = "filetime" -version = "0.2.4" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2df5c1a8c4be27e7707789dc42ae65976e60b394afd293d1419ab915833e646" +checksum = "1ff6d4dab0aa0c8e6346d46052e93b13a16cf847b54ed357087c35011048cc7d" dependencies = [ "cfg-if", "libc", "redox_syscall", + "winapi 0.3.8", ] [[package]] name = "flate2" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad3c5233c9a940c8719031b423d7e6c16af66e031cb0420b0896f5245bf181d3" +checksum = "6bd6d6f4752952feb71363cffc9ebac9411b75b87c6ab6058c40c8900cf43c0f" dependencies = [ "cfg-if", "crc32fast", @@ -1238,13 +1238,13 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.1.12" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "473a1265acc8ff1e808cd0a1af8cee3c2ee5200916058a2ca113c29f2d903571" +checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" dependencies = [ "cfg-if", "libc", - "wasi 0.7.0", + "wasi", ] [[package]] @@ -1387,11 +1387,10 @@ checksum = "023b39be39e3a2da62a94feb433e91e8bcd37676fbc8bea371daf52b7a769a3e" [[package]] name = "home" -version = "0.5.1" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3753954f7bd71f0e671afb8b5a992d1724cf43b7f95a563cd4a0bde94659ca8" +checksum = "2456aef2e6b6a9784192ae780c0f15bc57df0e918585282325e8c8ac27737654" dependencies = [ - "scopeguard", "winapi 0.3.8", ] @@ -1544,9 +1543,9 @@ dependencies = [ [[package]] name = "im-rc" -version = "14.0.0" +version = "14.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9ad726dce25993be6352b0bff048e4d2647440c0a673d32257c4fac49356d18" +checksum = "ed5135086ffe74654d797c02fd673c4046cdb7f552c98f1b1aa6851d6572f84f" dependencies = [ "bitmaps", "rand_core 0.5.1", @@ -2007,9 +2006,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.2.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39" +checksum = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" [[package]] name = "memmap" @@ -2232,9 +2231,9 @@ checksum = "c281318d992e4432cfa799969467003d05921582a7489a8325e37f8a450d5113" [[package]] name = "opener" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "998c59e83d9474c01127a96e023b7a04bb061dd286bf8bb939d31dc8d31a7448" +checksum = "13117407ca9d0caf3a0e74f97b490a7e64c0ae3aa90a8b7085544d0c37b6f3ae" dependencies = [ "winapi 0.3.8", ] @@ -2261,9 +2260,9 @@ checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" [[package]] name = "openssl-src" -version = "111.6.0+1.1.1d" +version = "111.6.1+1.1.1d" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9c2da1de8a7a3f860919c01540b03a6db16de042405a8a07a5e9d0b4b825d9c" +checksum = "c91b04cb43c1a8a90e934e0cd612e2a5715d976d2d6cff4490278a0cddf35005" dependencies = [ "cc", ] @@ -2301,6 +2300,7 @@ dependencies = [ name = "panic_abort" version = "0.0.0" dependencies = [ + "cfg-if", "compiler_builtins", "core", "libc", @@ -2838,15 +2838,6 @@ version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "679da7508e9a6390aeaf7fbd02a800fdc64b73fe2204dd2c8ae66d22d9d5ad5d" -[[package]] -name = "redox_termios" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" -dependencies = [ - "redox_syscall", -] - [[package]] name = "redox_users" version = "0.3.0" @@ -3187,7 +3178,7 @@ dependencies = [ "proc-macro2 1.0.3", "quote 1.0.2", "syn 1.0.11", - "synstructure 0.12.1", + "synstructure", ] [[package]] @@ -3663,6 +3654,7 @@ dependencies = [ "log", "rustc", "rustc_data_structures", + "rustc_error_codes", "rustc_errors", "rustc_feature", "rustc_hir", @@ -3691,7 +3683,7 @@ dependencies = [ "proc-macro2 1.0.3", "quote 1.0.2", "syn 1.0.11", - "synstructure 0.12.1", + "synstructure", ] [[package]] @@ -3788,6 +3780,7 @@ dependencies = [ "rustc_error_codes", "rustc_errors", "rustc_hir", + "rustc_lint", "rustc_metadata", "rustc_span", "syntax", @@ -4106,22 +4099,22 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.99" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fec2851eb56d010dc9a21b89ca53ee75e6528bab60c11e89d38390904982da9f" +checksum = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.81" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "477b13b646f5b5b56fc95bedfc3b550d12141ce84f466f6c44b9a17589923885" +checksum = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64" dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.12", - "syn 0.15.35", + "proc-macro2 1.0.3", + "quote 1.0.2", + "syn 1.0.11", ] [[package]] @@ -4217,9 +4210,9 @@ checksum = "0df90a788073e8d0235a67e50441d47db7c8ad9debd91cbf43736a2a92d36537" [[package]] name = "sized-chunks" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62db64dd92b3b54314b1e216c274634ca2b3fe8da8b3873be670cb1ac4dad30f" +checksum = "6f59f81ec9833a580d2448e958d16bd872637798f3ab300b693c48f136fb76ff" dependencies = [ "bitmaps", "typenum", @@ -4280,7 +4273,7 @@ dependencies = [ "profiler_builtins", "rand 0.7.0", "unwind", - "wasi 0.9.0+wasi-snapshot-preview1", + "wasi", ] [[package]] @@ -4404,18 +4397,6 @@ dependencies = [ "unicode-xid 0.2.0", ] -[[package]] -name = "synstructure" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.12", - "syn 0.15.35", - "unicode-xid 0.1.0", -] - [[package]] name = "synstructure" version = "0.12.1" @@ -4449,9 +4430,9 @@ dependencies = [ [[package]] name = "tar" -version = "0.4.20" +version = "0.4.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a303ba60a099fcd2aaa646b14d2724591a96a75283e4b7ed3d1a1658909d9ae2" +checksum = "7201214ded95b34e3bc00c9557b6dcec34fd1af428d343143f5db67c661762f0" dependencies = [ "filetime", "libc", @@ -4523,17 +4504,6 @@ dependencies = [ "wincolor", ] -[[package]] -name = "termion" -version = "1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" -dependencies = [ - "libc", - "redox_syscall", - "redox_termios", -] - [[package]] name = "test" version = "0.0.0" @@ -5110,9 +5080,9 @@ dependencies = [ [[package]] name = "walkdir" -version = "2.2.7" +version = "2.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d9d7ed3431229a144296213105a390676cc49c9b6a72bd19f3176c98e129fa1" +checksum = "9658c94fa8b940eab2250bd5a457f9c48b748420d71293b165c8cdbe2f55f71e" dependencies = [ "same-file", "winapi 0.3.8", @@ -5130,12 +5100,6 @@ dependencies = [ "try-lock", ] -[[package]] -name = "wasi" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d" - [[package]] name = "wasi" version = "0.9.0+wasi-snapshot-preview1" diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 6c4956663841c..17270544cd108 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -44,7 +44,7 @@ // Here we explicitly #[cfg]-out this whole crate when testing. If we don't do // this, both the generated test artifact and the linked libtest (which // transitively includes libcore) will both define the same set of lang items, -// and this will cause the E0152 "duplicate lang item found" error. See +// and this will cause the E0152 "found duplicate lang item" error. See // discussion in #50466 for details. // // This cfg won't affect doc tests. diff --git a/src/libpanic_abort/Cargo.toml b/src/libpanic_abort/Cargo.toml index 2bee0b716c750..8ebd95047ac23 100644 --- a/src/libpanic_abort/Cargo.toml +++ b/src/libpanic_abort/Cargo.toml @@ -14,3 +14,4 @@ doc = false core = { path = "../libcore" } libc = { version = "0.2", default-features = false } compiler_builtins = "0.1.0" +cfg-if = "0.1.8" diff --git a/src/libpanic_abort/lib.rs b/src/libpanic_abort/lib.rs index db7c250e21157..6ea818ecef827 100644 --- a/src/libpanic_abort/lib.rs +++ b/src/libpanic_abort/lib.rs @@ -18,17 +18,14 @@ #![feature(staged_api)] #![feature(rustc_attrs)] -// Rust's "try" function, but if we're aborting on panics we just call the -// function as there's nothing else we need to do here. +use core::any::Any; + +// We need the definition of TryPayload for __rust_panic_cleanup. +include!("../libpanic_unwind/payload.rs"); + #[rustc_std_internal_symbol] -pub unsafe extern "C" fn __rust_maybe_catch_panic( - f: fn(*mut u8), - data: *mut u8, - _data_ptr: *mut usize, - _vtable_ptr: *mut usize, -) -> u32 { - f(data); - 0 +pub unsafe extern "C" fn __rust_panic_cleanup(_: TryPayload) -> *mut (dyn Any + Send + 'static) { + unreachable!() } // "Leak" the payload and shim to the relevant abort on the platform in diff --git a/src/libpanic_unwind/dummy.rs b/src/libpanic_unwind/dummy.rs index 8675632638712..4667ede2baad5 100644 --- a/src/libpanic_unwind/dummy.rs +++ b/src/libpanic_unwind/dummy.rs @@ -6,10 +6,6 @@ use alloc::boxed::Box; use core::any::Any; use core::intrinsics; -pub fn payload() -> *mut u8 { - core::ptr::null_mut() -} - pub unsafe fn cleanup(_ptr: *mut u8) -> Box { intrinsics::abort() } diff --git a/src/libpanic_unwind/emcc.rs b/src/libpanic_unwind/emcc.rs index 9d3fe5254f8a9..7472038441f17 100644 --- a/src/libpanic_unwind/emcc.rs +++ b/src/libpanic_unwind/emcc.rs @@ -48,10 +48,6 @@ static EXCEPTION_TYPE_INFO: TypeInfo = TypeInfo { name: b"rust_panic\0".as_ptr(), }; -pub fn payload() -> *mut u8 { - ptr::null_mut() -} - pub unsafe fn cleanup(ptr: *mut u8) -> Box { assert!(!ptr.is_null()); let adjusted_ptr = __cxa_begin_catch(ptr as *mut libc::c_void); diff --git a/src/libpanic_unwind/gcc.rs b/src/libpanic_unwind/gcc.rs index 6a48fa05f8d08..e1a0655c8b37e 100644 --- a/src/libpanic_unwind/gcc.rs +++ b/src/libpanic_unwind/gcc.rs @@ -48,7 +48,6 @@ use alloc::boxed::Box; use core::any::Any; -use core::ptr; use crate::dwarf::eh::{self, EHAction, EHContext}; use libc::{c_int, uintptr_t}; @@ -82,10 +81,6 @@ pub unsafe fn panic(data: Box) -> u32 { } } -pub fn payload() -> *mut u8 { - ptr::null_mut() -} - pub unsafe fn cleanup(ptr: *mut u8) -> Box { let my_ep = ptr as *mut Exception; let cause = (*my_ep).cause.take(); diff --git a/src/libpanic_unwind/hermit.rs b/src/libpanic_unwind/hermit.rs index 2f53df2861d44..6bded4dd499bd 100644 --- a/src/libpanic_unwind/hermit.rs +++ b/src/libpanic_unwind/hermit.rs @@ -6,10 +6,6 @@ use alloc::boxed::Box; use core::any::Any; use core::ptr; -pub fn payload() -> *mut u8 { - ptr::null_mut() -} - pub unsafe fn cleanup(_ptr: *mut u8) -> Box { extern "C" { pub fn __rust_abort() -> !; diff --git a/src/libpanic_unwind/lib.rs b/src/libpanic_unwind/lib.rs index e721162edc067..adac6ce18e900 100644 --- a/src/libpanic_unwind/lib.rs +++ b/src/libpanic_unwind/lib.rs @@ -22,19 +22,20 @@ #![feature(libc)] #![feature(nll)] #![feature(panic_unwind)] -#![feature(raw)] #![feature(staged_api)] #![feature(std_internals)] #![feature(unwind_attributes)] +#![feature(rustc_attrs)] +#![feature(raw)] #![panic_runtime] #![feature(panic_runtime)] use alloc::boxed::Box; -use core::intrinsics; -use core::mem; +use core::any::Any; use core::panic::BoxMeUp; -use core::raw; +// If adding to this list, you should also look at the list of TryPayload types +// defined in payload.rs and likely add to there as well. cfg_if::cfg_if! { if #[cfg(target_os = "emscripten")] { #[path = "emcc.rs"] @@ -60,30 +61,15 @@ cfg_if::cfg_if! { } } +include!("payload.rs"); + mod dwarf; -// Entry point for catching an exception, implemented using the `try` intrinsic -// in the compiler. -// -// The interaction between the `payload` function and the compiler is pretty -// hairy and tightly coupled, for more information see the compiler's -// implementation of this. #[no_mangle] -pub unsafe extern "C" fn __rust_maybe_catch_panic( - f: fn(*mut u8), - data: *mut u8, - data_ptr: *mut usize, - vtable_ptr: *mut usize, -) -> u32 { - let mut payload = imp::payload(); - if intrinsics::r#try(f, data, &mut payload as *mut _ as *mut _) == 0 { - 0 - } else { - let obj = mem::transmute::<_, raw::TraitObject>(imp::cleanup(payload)); - *data_ptr = obj.data as usize; - *vtable_ptr = obj.vtable as usize; - 1 - } +pub unsafe extern "C" fn __rust_panic_cleanup( + payload: TryPayload, +) -> *mut (dyn Any + Send + 'static) { + Box::into_raw(imp::cleanup(payload)) } // Entry point for raising an exception, just delegates to the platform-specific diff --git a/src/libpanic_unwind/payload.rs b/src/libpanic_unwind/payload.rs new file mode 100644 index 0000000000000..1234db7da0f08 --- /dev/null +++ b/src/libpanic_unwind/payload.rs @@ -0,0 +1,21 @@ +// Type definition for the payload argument of the try intrinsic. +// +// This must be kept in sync with the implementations of the try intrinsic. +// +// This file is included by both panic runtimes and libstd. It is part of the +// panic runtime ABI. +cfg_if::cfg_if! { + if #[cfg(target_os = "emscripten")] { + type TryPayload = *mut u8; + } else if #[cfg(target_arch = "wasm32")] { + type TryPayload = *mut u8; + } else if #[cfg(target_os = "hermit")] { + type TryPayload = *mut u8; + } else if #[cfg(all(target_env = "msvc", target_arch = "aarch64"))] { + type TryPayload = *mut u8; + } else if #[cfg(target_env = "msvc")] { + type TryPayload = [u64; 2]; + } else { + type TryPayload = *mut u8; + } +} diff --git a/src/libpanic_unwind/seh.rs b/src/libpanic_unwind/seh.rs index e1907ec4e5f32..1a5456a93fa27 100644 --- a/src/libpanic_unwind/seh.rs +++ b/src/libpanic_unwind/seh.rs @@ -264,10 +264,6 @@ pub unsafe fn panic(data: Box) -> u32 { _CxxThrowException(throw_ptr, &mut THROW_INFO as *mut _ as *mut _); } -pub fn payload() -> [u64; 2] { - [0; 2] -} - pub unsafe fn cleanup(payload: [u64; 2]) -> Box { mem::transmute(raw::TraitObject { data: payload[0] as *mut _, vtable: payload[1] as *mut _ }) } diff --git a/src/librustc/hir/check_attr.rs b/src/librustc/hir/check_attr.rs index c6a996f84f461..5a99e7965538b 100644 --- a/src/librustc/hir/check_attr.rs +++ b/src/librustc/hir/check_attr.rs @@ -5,7 +5,6 @@ //! item. use crate::hir::map::Map; -use crate::lint::builtin::UNUSED_ATTRIBUTES; use crate::ty::query::Providers; use crate::ty::TyCtxt; @@ -16,6 +15,7 @@ use rustc_hir::def_id::DefId; use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_hir::DUMMY_HIR_ID; use rustc_hir::{self, HirId, Item, ItemKind, TraitItem, TraitItemKind}; +use rustc_session::lint::builtin::UNUSED_ATTRIBUTES; use rustc_span::symbol::sym; use rustc_span::Span; use syntax::ast::Attribute; diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 3c0160a04527e..6d587e9854016 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -71,8 +71,6 @@ extern crate rustc_data_structures; #[macro_use] extern crate log; #[macro_use] -extern crate syntax; -#[macro_use] extern crate smallvec; #[cfg(test)] diff --git a/src/librustc/lint.rs b/src/librustc/lint.rs new file mode 100644 index 0000000000000..2ed6cd5283b10 --- /dev/null +++ b/src/librustc/lint.rs @@ -0,0 +1,369 @@ +use std::cmp; + +use crate::ich::StableHashingContext; +use rustc_data_structures::fx::FxHashMap; +use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; +use rustc_errors::{pluralize, Applicability, DiagnosticBuilder, DiagnosticId}; +use rustc_hir::HirId; +pub use rustc_session::lint::{builtin, Level, Lint, LintId, LintPass}; +use rustc_session::{DiagnosticMessageId, Session}; +use rustc_span::hygiene::MacroKind; +use rustc_span::source_map::{DesugaringKind, ExpnKind, MultiSpan}; +use rustc_span::{Span, Symbol}; + +/// How a lint level was set. +#[derive(Clone, Copy, PartialEq, Eq, HashStable)] +pub enum LintSource { + /// Lint is at the default level as declared + /// in rustc or a plugin. + Default, + + /// Lint level was set by an attribute. + Node(Symbol, Span, Option /* RFC 2383 reason */), + + /// Lint level was set by a command-line flag. + CommandLine(Symbol), +} + +pub type LevelSource = (Level, LintSource); + +pub struct LintLevelSets { + pub list: Vec, + pub lint_cap: Level, +} + +pub enum LintSet { + CommandLine { + // -A,-W,-D flags, a `Symbol` for the flag itself and `Level` for which + // flag. + specs: FxHashMap, + }, + + Node { + specs: FxHashMap, + parent: u32, + }, +} + +impl LintLevelSets { + pub fn new() -> Self { + LintLevelSets { list: Vec::new(), lint_cap: Level::Forbid } + } + + pub fn get_lint_level( + &self, + lint: &'static Lint, + idx: u32, + aux: Option<&FxHashMap>, + sess: &Session, + ) -> LevelSource { + let (level, mut src) = self.get_lint_id_level(LintId::of(lint), idx, aux); + + // If `level` is none then we actually assume the default level for this + // lint. + let mut level = level.unwrap_or_else(|| lint.default_level(sess.edition())); + + // If we're about to issue a warning, check at the last minute for any + // directives against the warnings "lint". If, for example, there's an + // `allow(warnings)` in scope then we want to respect that instead. + if level == Level::Warn { + let (warnings_level, warnings_src) = + self.get_lint_id_level(LintId::of(builtin::WARNINGS), idx, aux); + if let Some(configured_warning_level) = warnings_level { + if configured_warning_level != Level::Warn { + level = configured_warning_level; + src = warnings_src; + } + } + } + + // Ensure that we never exceed the `--cap-lints` argument. + level = cmp::min(level, self.lint_cap); + + if let Some(driver_level) = sess.driver_lint_caps.get(&LintId::of(lint)) { + // Ensure that we never exceed driver level. + level = cmp::min(*driver_level, level); + } + + return (level, src); + } + + pub fn get_lint_id_level( + &self, + id: LintId, + mut idx: u32, + aux: Option<&FxHashMap>, + ) -> (Option, LintSource) { + if let Some(specs) = aux { + if let Some(&(level, src)) = specs.get(&id) { + return (Some(level), src); + } + } + loop { + match self.list[idx as usize] { + LintSet::CommandLine { ref specs } => { + if let Some(&(level, src)) = specs.get(&id) { + return (Some(level), src); + } + return (None, LintSource::Default); + } + LintSet::Node { ref specs, parent } => { + if let Some(&(level, src)) = specs.get(&id) { + return (Some(level), src); + } + idx = parent; + } + } + } + } +} + +pub struct LintLevelMap { + pub sets: LintLevelSets, + pub id_to_set: FxHashMap, +} + +impl LintLevelMap { + /// If the `id` was previously registered with `register_id` when building + /// this `LintLevelMap` this returns the corresponding lint level and source + /// of the lint level for the lint provided. + /// + /// If the `id` was not previously registered, returns `None`. If `None` is + /// returned then the parent of `id` should be acquired and this function + /// should be called again. + pub fn level_and_source( + &self, + lint: &'static Lint, + id: HirId, + session: &Session, + ) -> Option { + self.id_to_set.get(&id).map(|idx| self.sets.get_lint_level(lint, *idx, None, session)) + } +} + +impl<'a> HashStable> for LintLevelMap { + #[inline] + fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { + let LintLevelMap { ref sets, ref id_to_set } = *self; + + id_to_set.hash_stable(hcx, hasher); + + let LintLevelSets { ref list, lint_cap } = *sets; + + lint_cap.hash_stable(hcx, hasher); + + hcx.while_hashing_spans(true, |hcx| { + list.len().hash_stable(hcx, hasher); + + // We are working under the assumption here that the list of + // lint-sets is built in a deterministic order. + for lint_set in list { + ::std::mem::discriminant(lint_set).hash_stable(hcx, hasher); + + match *lint_set { + LintSet::CommandLine { ref specs } => { + specs.hash_stable(hcx, hasher); + } + LintSet::Node { ref specs, parent } => { + specs.hash_stable(hcx, hasher); + parent.hash_stable(hcx, hasher); + } + } + } + }) + } +} + +pub fn struct_lint_level<'a>( + sess: &'a Session, + lint: &'static Lint, + level: Level, + src: LintSource, + span: Option, + msg: &str, +) -> DiagnosticBuilder<'a> { + let mut err = match (level, span) { + (Level::Allow, _) => return sess.diagnostic().struct_dummy(), + (Level::Warn, Some(span)) => sess.struct_span_warn(span, msg), + (Level::Warn, None) => sess.struct_warn(msg), + (Level::Deny, Some(span)) | (Level::Forbid, Some(span)) => sess.struct_span_err(span, msg), + (Level::Deny, None) | (Level::Forbid, None) => sess.struct_err(msg), + }; + + // Check for future incompatibility lints and issue a stronger warning. + let lint_id = LintId::of(lint); + let future_incompatible = lint.future_incompatible; + + // If this code originates in a foreign macro, aka something that this crate + // did not itself author, then it's likely that there's nothing this crate + // can do about it. We probably want to skip the lint entirely. + if err.span.primary_spans().iter().any(|s| in_external_macro(sess, *s)) { + // Any suggestions made here are likely to be incorrect, so anything we + // emit shouldn't be automatically fixed by rustfix. + err.allow_suggestions(false); + + // If this is a future incompatible lint it'll become a hard error, so + // we have to emit *something*. Also allow lints to whitelist themselves + // on a case-by-case basis for emission in a foreign macro. + if future_incompatible.is_none() && !lint.report_in_external_macro { + err.cancel(); + // Don't continue further, since we don't want to have + // `diag_span_note_once` called for a diagnostic that isn't emitted. + return err; + } + } + + let name = lint.name_lower(); + match src { + LintSource::Default => { + sess.diag_note_once( + &mut err, + DiagnosticMessageId::from(lint), + &format!("`#[{}({})]` on by default", level.as_str(), name), + ); + } + LintSource::CommandLine(lint_flag_val) => { + let flag = match level { + Level::Warn => "-W", + Level::Deny => "-D", + Level::Forbid => "-F", + Level::Allow => panic!(), + }; + let hyphen_case_lint_name = name.replace("_", "-"); + if lint_flag_val.as_str() == name { + sess.diag_note_once( + &mut err, + DiagnosticMessageId::from(lint), + &format!( + "requested on the command line with `{} {}`", + flag, hyphen_case_lint_name + ), + ); + } else { + let hyphen_case_flag_val = lint_flag_val.as_str().replace("_", "-"); + sess.diag_note_once( + &mut err, + DiagnosticMessageId::from(lint), + &format!( + "`{} {}` implied by `{} {}`", + flag, hyphen_case_lint_name, flag, hyphen_case_flag_val + ), + ); + } + } + LintSource::Node(lint_attr_name, src, reason) => { + if let Some(rationale) = reason { + err.note(&rationale.as_str()); + } + sess.diag_span_note_once( + &mut err, + DiagnosticMessageId::from(lint), + src, + "lint level defined here", + ); + if lint_attr_name.as_str() != name { + let level_str = level.as_str(); + sess.diag_note_once( + &mut err, + DiagnosticMessageId::from(lint), + &format!( + "`#[{}({})]` implied by `#[{}({})]`", + level_str, name, level_str, lint_attr_name + ), + ); + } + } + } + + err.code(DiagnosticId::Lint(name)); + + if let Some(future_incompatible) = future_incompatible { + const STANDARD_MESSAGE: &str = "this was previously accepted by the compiler but is being phased out; \ + it will become a hard error"; + + let explanation = if lint_id == LintId::of(builtin::UNSTABLE_NAME_COLLISIONS) { + "once this method is added to the standard library, \ + the ambiguity may cause an error or change in behavior!" + .to_owned() + } else if lint_id == LintId::of(builtin::MUTABLE_BORROW_RESERVATION_CONFLICT) { + "this borrowing pattern was not meant to be accepted, \ + and may become a hard error in the future" + .to_owned() + } else if let Some(edition) = future_incompatible.edition { + format!("{} in the {} edition!", STANDARD_MESSAGE, edition) + } else { + format!("{} in a future release!", STANDARD_MESSAGE) + }; + let citation = format!("for more information, see {}", future_incompatible.reference); + err.warn(&explanation); + err.note(&citation); + } + + return err; +} + +/// Returns whether `span` originates in a foreign crate's external macro. +/// +/// This is used to test whether a lint should not even begin to figure out whether it should +/// be reported on the current node. +pub fn in_external_macro(sess: &Session, span: Span) -> bool { + let expn_data = span.ctxt().outer_expn_data(); + match expn_data.kind { + ExpnKind::Root | ExpnKind::Desugaring(DesugaringKind::ForLoop) => false, + ExpnKind::AstPass(_) | ExpnKind::Desugaring(_) => true, // well, it's "external" + ExpnKind::Macro(MacroKind::Bang, _) => { + if expn_data.def_site.is_dummy() { + // Dummy span for the `def_site` means it's an external macro. + return true; + } + match sess.source_map().span_to_snippet(expn_data.def_site) { + Ok(code) => !code.starts_with("macro_rules"), + // No snippet means external macro or compiler-builtin expansion. + Err(_) => true, + } + } + ExpnKind::Macro(..) => true, // definitely a plugin + } +} + +pub fn add_elided_lifetime_in_path_suggestion( + sess: &Session, + db: &mut DiagnosticBuilder<'_>, + n: usize, + path_span: Span, + incl_angl_brckt: bool, + insertion_span: Span, + anon_lts: String, +) { + let (replace_span, suggestion) = if incl_angl_brckt { + (insertion_span, anon_lts) + } else { + // When possible, prefer a suggestion that replaces the whole + // `Path` expression with `Path<'_, T>`, rather than inserting `'_, ` + // at a point (which makes for an ugly/confusing label) + if let Ok(snippet) = sess.source_map().span_to_snippet(path_span) { + // But our spans can get out of whack due to macros; if the place we think + // we want to insert `'_` isn't even within the path expression's span, we + // should bail out of making any suggestion rather than panicking on a + // subtract-with-overflow or string-slice-out-out-bounds (!) + // FIXME: can we do better? + if insertion_span.lo().0 < path_span.lo().0 { + return; + } + let insertion_index = (insertion_span.lo().0 - path_span.lo().0) as usize; + if insertion_index > snippet.len() { + return; + } + let (before, after) = snippet.split_at(insertion_index); + (path_span, format!("{}{}{}", before, anon_lts, after)) + } else { + (insertion_span, anon_lts) + } + }; + db.span_suggestion( + replace_span, + &format!("indicate the anonymous lifetime{}", pluralize!(n)), + suggestion, + Applicability::MachineApplicable, + ); +} diff --git a/src/librustc/lint/levels.rs b/src/librustc/lint/levels.rs deleted file mode 100644 index e586ad1836c73..0000000000000 --- a/src/librustc/lint/levels.rs +++ /dev/null @@ -1,550 +0,0 @@ -use std::cmp; - -use crate::ich::StableHashingContext; -use crate::lint::builtin; -use crate::lint::context::{CheckLintNameResult, LintStore}; -use crate::lint::{self, Level, Lint, LintId, LintSource}; -use crate::session::Session; -use rustc_data_structures::fx::FxHashMap; -use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; -use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder}; -use rustc_hir::HirId; -use rustc_span::source_map::MultiSpan; -use rustc_span::symbol::{sym, Symbol}; -use syntax::ast; -use syntax::attr; -use syntax::print::pprust; -use syntax::sess::feature_err; - -use rustc_error_codes::*; - -pub struct LintLevelSets { - list: Vec, - lint_cap: Level, -} - -enum LintSet { - CommandLine { - // -A,-W,-D flags, a `Symbol` for the flag itself and `Level` for which - // flag. - specs: FxHashMap, - }, - - Node { - specs: FxHashMap, - parent: u32, - }, -} - -impl LintLevelSets { - pub fn new(sess: &Session, lint_store: &LintStore) -> LintLevelSets { - let mut me = LintLevelSets { list: Vec::new(), lint_cap: Level::Forbid }; - me.process_command_line(sess, lint_store); - return me; - } - - pub fn builder<'a>( - sess: &'a Session, - warn_about_weird_lints: bool, - store: &LintStore, - ) -> LintLevelsBuilder<'a> { - LintLevelsBuilder::new(sess, warn_about_weird_lints, LintLevelSets::new(sess, store)) - } - - fn process_command_line(&mut self, sess: &Session, store: &LintStore) { - let mut specs = FxHashMap::default(); - self.lint_cap = sess.opts.lint_cap.unwrap_or(Level::Forbid); - - for &(ref lint_name, level) in &sess.opts.lint_opts { - store.check_lint_name_cmdline(sess, &lint_name, level); - - // If the cap is less than this specified level, e.g., if we've got - // `--cap-lints allow` but we've also got `-D foo` then we ignore - // this specification as the lint cap will set it to allow anyway. - let level = cmp::min(level, self.lint_cap); - - let lint_flag_val = Symbol::intern(lint_name); - let ids = match store.find_lints(&lint_name) { - Ok(ids) => ids, - Err(_) => continue, // errors handled in check_lint_name_cmdline above - }; - for id in ids { - let src = LintSource::CommandLine(lint_flag_val); - specs.insert(id, (level, src)); - } - } - - self.list.push(LintSet::CommandLine { specs: specs }); - } - - fn get_lint_level( - &self, - lint: &'static Lint, - idx: u32, - aux: Option<&FxHashMap>, - sess: &Session, - ) -> (Level, LintSource) { - let (level, mut src) = self.get_lint_id_level(LintId::of(lint), idx, aux); - - // If `level` is none then we actually assume the default level for this - // lint. - let mut level = level.unwrap_or_else(|| lint.default_level(sess.edition())); - - // If we're about to issue a warning, check at the last minute for any - // directives against the warnings "lint". If, for example, there's an - // `allow(warnings)` in scope then we want to respect that instead. - if level == Level::Warn { - let (warnings_level, warnings_src) = - self.get_lint_id_level(LintId::of(lint::builtin::WARNINGS), idx, aux); - if let Some(configured_warning_level) = warnings_level { - if configured_warning_level != Level::Warn { - level = configured_warning_level; - src = warnings_src; - } - } - } - - // Ensure that we never exceed the `--cap-lints` argument. - level = cmp::min(level, self.lint_cap); - - if let Some(driver_level) = sess.driver_lint_caps.get(&LintId::of(lint)) { - // Ensure that we never exceed driver level. - level = cmp::min(*driver_level, level); - } - - return (level, src); - } - - fn get_lint_id_level( - &self, - id: LintId, - mut idx: u32, - aux: Option<&FxHashMap>, - ) -> (Option, LintSource) { - if let Some(specs) = aux { - if let Some(&(level, src)) = specs.get(&id) { - return (Some(level), src); - } - } - loop { - match self.list[idx as usize] { - LintSet::CommandLine { ref specs } => { - if let Some(&(level, src)) = specs.get(&id) { - return (Some(level), src); - } - return (None, LintSource::Default); - } - LintSet::Node { ref specs, parent } => { - if let Some(&(level, src)) = specs.get(&id) { - return (Some(level), src); - } - idx = parent; - } - } - } - } -} - -pub struct LintLevelsBuilder<'a> { - sess: &'a Session, - sets: LintLevelSets, - id_to_set: FxHashMap, - cur: u32, - warn_about_weird_lints: bool, -} - -pub struct BuilderPush { - prev: u32, - pub changed: bool, -} - -impl<'a> LintLevelsBuilder<'a> { - pub fn new( - sess: &'a Session, - warn_about_weird_lints: bool, - sets: LintLevelSets, - ) -> LintLevelsBuilder<'a> { - assert_eq!(sets.list.len(), 1); - LintLevelsBuilder { - sess, - sets, - cur: 0, - id_to_set: Default::default(), - warn_about_weird_lints, - } - } - - /// Pushes a list of AST lint attributes onto this context. - /// - /// This function will return a `BuilderPush` object which should be passed - /// to `pop` when this scope for the attributes provided is exited. - /// - /// This function will perform a number of tasks: - /// - /// * It'll validate all lint-related attributes in `attrs` - /// * It'll mark all lint-related attributes as used - /// * Lint levels will be updated based on the attributes provided - /// * Lint attributes are validated, e.g., a #[forbid] can't be switched to - /// #[allow] - /// - /// Don't forget to call `pop`! - pub fn push(&mut self, attrs: &[ast::Attribute], store: &LintStore) -> BuilderPush { - let mut specs = FxHashMap::default(); - let sess = self.sess; - let bad_attr = |span| struct_span_err!(sess, span, E0452, "malformed lint attribute input"); - for attr in attrs { - let level = match Level::from_symbol(attr.name_or_empty()) { - None => continue, - Some(lvl) => lvl, - }; - - let meta = unwrap_or!(attr.meta(), continue); - attr::mark_used(attr); - - let mut metas = unwrap_or!(meta.meta_item_list(), continue); - - if metas.is_empty() { - // FIXME (#55112): issue unused-attributes lint for `#[level()]` - continue; - } - - // Before processing the lint names, look for a reason (RFC 2383) - // at the end. - let mut reason = None; - let tail_li = &metas[metas.len() - 1]; - if let Some(item) = tail_li.meta_item() { - match item.kind { - ast::MetaItemKind::Word => {} // actual lint names handled later - ast::MetaItemKind::NameValue(ref name_value) => { - if item.path == sym::reason { - // found reason, reslice meta list to exclude it - metas = &metas[0..metas.len() - 1]; - // FIXME (#55112): issue unused-attributes lint if we thereby - // don't have any lint names (`#[level(reason = "foo")]`) - if let ast::LitKind::Str(rationale, _) = name_value.kind { - if !self.sess.features_untracked().lint_reasons { - feature_err( - &self.sess.parse_sess, - sym::lint_reasons, - item.span, - "lint reasons are experimental", - ) - .emit(); - } - reason = Some(rationale); - } else { - bad_attr(name_value.span) - .span_label(name_value.span, "reason must be a string literal") - .emit(); - } - } else { - bad_attr(item.span) - .span_label(item.span, "bad attribute argument") - .emit(); - } - } - ast::MetaItemKind::List(_) => { - bad_attr(item.span).span_label(item.span, "bad attribute argument").emit(); - } - } - } - - for li in metas { - let meta_item = match li.meta_item() { - Some(meta_item) if meta_item.is_word() => meta_item, - _ => { - let sp = li.span(); - let mut err = bad_attr(sp); - let mut add_label = true; - if let Some(item) = li.meta_item() { - if let ast::MetaItemKind::NameValue(_) = item.kind { - if item.path == sym::reason { - err.span_label(sp, "reason in lint attribute must come last"); - add_label = false; - } - } - } - if add_label { - err.span_label(sp, "bad attribute argument"); - } - err.emit(); - continue; - } - }; - let tool_name = if meta_item.path.segments.len() > 1 { - let tool_ident = meta_item.path.segments[0].ident; - if !attr::is_known_lint_tool(tool_ident) { - struct_span_err!( - sess, - tool_ident.span, - E0710, - "an unknown tool name found in scoped lint: `{}`", - pprust::path_to_string(&meta_item.path), - ) - .emit(); - continue; - } - - Some(tool_ident.name) - } else { - None - }; - let name = meta_item.path.segments.last().expect("empty lint name").ident.name; - match store.check_lint_name(&name.as_str(), tool_name) { - CheckLintNameResult::Ok(ids) => { - let src = LintSource::Node(name, li.span(), reason); - for id in ids { - specs.insert(*id, (level, src)); - } - } - - CheckLintNameResult::Tool(result) => { - match result { - Ok(ids) => { - let complete_name = &format!("{}::{}", tool_name.unwrap(), name); - let src = LintSource::Node( - Symbol::intern(complete_name), - li.span(), - reason, - ); - for id in ids { - specs.insert(*id, (level, src)); - } - } - Err((Some(ids), new_lint_name)) => { - let lint = builtin::RENAMED_AND_REMOVED_LINTS; - let (lvl, src) = - self.sets.get_lint_level(lint, self.cur, Some(&specs), &sess); - let msg = format!( - "lint name `{}` is deprecated \ - and may not have an effect in the future. \ - Also `cfg_attr(cargo-clippy)` won't be necessary anymore", - name - ); - lint::struct_lint_level( - self.sess, - lint, - lvl, - src, - Some(li.span().into()), - &msg, - ) - .span_suggestion( - li.span(), - "change it to", - new_lint_name.to_string(), - Applicability::MachineApplicable, - ) - .emit(); - - let src = LintSource::Node( - Symbol::intern(&new_lint_name), - li.span(), - reason, - ); - for id in ids { - specs.insert(*id, (level, src)); - } - } - Err((None, _)) => { - // If Tool(Err(None, _)) is returned, then either the lint does not - // exist in the tool or the code was not compiled with the tool and - // therefore the lint was never added to the `LintStore`. To detect - // this is the responsibility of the lint tool. - } - } - } - - _ if !self.warn_about_weird_lints => {} - - CheckLintNameResult::Warning(msg, renamed) => { - let lint = builtin::RENAMED_AND_REMOVED_LINTS; - let (level, src) = - self.sets.get_lint_level(lint, self.cur, Some(&specs), &sess); - let mut err = lint::struct_lint_level( - self.sess, - lint, - level, - src, - Some(li.span().into()), - &msg, - ); - if let Some(new_name) = renamed { - err.span_suggestion( - li.span(), - "use the new name", - new_name, - Applicability::MachineApplicable, - ); - } - err.emit(); - } - CheckLintNameResult::NoLint(suggestion) => { - let lint = builtin::UNKNOWN_LINTS; - let (level, src) = - self.sets.get_lint_level(lint, self.cur, Some(&specs), self.sess); - let msg = format!("unknown lint: `{}`", name); - let mut db = lint::struct_lint_level( - self.sess, - lint, - level, - src, - Some(li.span().into()), - &msg, - ); - - if let Some(suggestion) = suggestion { - db.span_suggestion( - li.span(), - "did you mean", - suggestion.to_string(), - Applicability::MachineApplicable, - ); - } - - db.emit(); - } - } - } - } - - for (id, &(level, ref src)) in specs.iter() { - if level == Level::Forbid { - continue; - } - let forbid_src = match self.sets.get_lint_id_level(*id, self.cur, None) { - (Some(Level::Forbid), src) => src, - _ => continue, - }; - let forbidden_lint_name = match forbid_src { - LintSource::Default => id.to_string(), - LintSource::Node(name, _, _) => name.to_string(), - LintSource::CommandLine(name) => name.to_string(), - }; - let (lint_attr_name, lint_attr_span) = match *src { - LintSource::Node(name, span, _) => (name, span), - _ => continue, - }; - let mut diag_builder = struct_span_err!( - self.sess, - lint_attr_span, - E0453, - "{}({}) overruled by outer forbid({})", - level.as_str(), - lint_attr_name, - forbidden_lint_name - ); - diag_builder.span_label(lint_attr_span, "overruled by previous forbid"); - match forbid_src { - LintSource::Default => {} - LintSource::Node(_, forbid_source_span, reason) => { - diag_builder.span_label(forbid_source_span, "`forbid` level set here"); - if let Some(rationale) = reason { - diag_builder.note(&rationale.as_str()); - } - } - LintSource::CommandLine(_) => { - diag_builder.note("`forbid` lint level was set on command line"); - } - } - diag_builder.emit(); - // don't set a separate error for every lint in the group - break; - } - - let prev = self.cur; - if specs.len() > 0 { - self.cur = self.sets.list.len() as u32; - self.sets.list.push(LintSet::Node { specs: specs, parent: prev }); - } - - BuilderPush { prev: prev, changed: prev != self.cur } - } - - /// Called after `push` when the scope of a set of attributes are exited. - pub fn pop(&mut self, push: BuilderPush) { - self.cur = push.prev; - } - - /// Used to emit a lint-related diagnostic based on the current state of - /// this lint context. - pub fn struct_lint( - &self, - lint: &'static Lint, - span: Option, - msg: &str, - ) -> DiagnosticBuilder<'a> { - let (level, src) = self.sets.get_lint_level(lint, self.cur, None, self.sess); - lint::struct_lint_level(self.sess, lint, level, src, span, msg) - } - - /// Registers the ID provided with the current set of lints stored in - /// this context. - pub fn register_id(&mut self, id: HirId) { - self.id_to_set.insert(id, self.cur); - } - - pub fn build(self) -> LintLevelSets { - self.sets - } - - pub fn build_map(self) -> LintLevelMap { - LintLevelMap { sets: self.sets, id_to_set: self.id_to_set } - } -} - -pub struct LintLevelMap { - sets: LintLevelSets, - id_to_set: FxHashMap, -} - -impl LintLevelMap { - /// If the `id` was previously registered with `register_id` when building - /// this `LintLevelMap` this returns the corresponding lint level and source - /// of the lint level for the lint provided. - /// - /// If the `id` was not previously registered, returns `None`. If `None` is - /// returned then the parent of `id` should be acquired and this function - /// should be called again. - pub fn level_and_source( - &self, - lint: &'static Lint, - id: HirId, - session: &Session, - ) -> Option<(Level, LintSource)> { - self.id_to_set.get(&id).map(|idx| self.sets.get_lint_level(lint, *idx, None, session)) - } -} - -impl<'a> HashStable> for LintLevelMap { - #[inline] - fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { - let LintLevelMap { ref sets, ref id_to_set } = *self; - - id_to_set.hash_stable(hcx, hasher); - - let LintLevelSets { ref list, lint_cap } = *sets; - - lint_cap.hash_stable(hcx, hasher); - - hcx.while_hashing_spans(true, |hcx| { - list.len().hash_stable(hcx, hasher); - - // We are working under the assumption here that the list of - // lint-sets is built in a deterministic order. - for lint_set in list { - ::std::mem::discriminant(lint_set).hash_stable(hcx, hasher); - - match *lint_set { - LintSet::CommandLine { ref specs } => { - specs.hash_stable(hcx, hasher); - } - LintSet::Node { ref specs, parent } => { - specs.hash_stable(hcx, hasher); - parent.hash_stable(hcx, hasher); - } - } - } - }) - } -} diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index 42fc3e030e7bb..643359f098b4d 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -184,7 +184,7 @@ impl LanguageItemCollector<'tcx> { self.tcx.sess, span, E0152, - "duplicate lang item found: `{}`.", + "found duplicate lang item `{}`", name ), None => { @@ -206,12 +206,12 @@ impl LanguageItemCollector<'tcx> { }, }; if let Some(span) = self.tcx.hir().span_if_local(original_def_id) { - err.span_note(span, "first defined here."); + err.span_note(span, "first defined here"); } else { match self.tcx.extern_crate(original_def_id) { Some(ExternCrate {dependency_of, ..}) => { err.note(&format!( - "first defined in crate `{}` (which `{}` depends on).", + "first defined in crate `{}` (which `{}` depends on)", self.tcx.crate_name(original_def_id.krate), self.tcx.crate_name(*dependency_of))); }, diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index 17e84c24881c1..1176ffc79d26d 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -3,7 +3,6 @@ pub use self::StabilityLevel::*; -use crate::lint::{self, in_derive_expansion, Lint}; use crate::session::{DiagnosticMessageId, Session}; use crate::ty::{self, TyCtxt}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; @@ -13,7 +12,7 @@ use rustc_hir as hir; use rustc_hir::def::DefKind; use rustc_hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX}; use rustc_hir::{self, HirId}; -use rustc_session::lint::{BuiltinLintDiagnostics, LintBuffer}; +use rustc_session::lint::{self, BuiltinLintDiagnostics, Lint, LintBuffer}; use rustc_span::symbol::{sym, Symbol}; use rustc_span::{MultiSpan, Span}; use syntax::ast::CRATE_NODE_ID; @@ -201,7 +200,7 @@ pub fn early_report_deprecation( lint: &'static Lint, span: Span, ) { - if in_derive_expansion(span) { + if span.in_derive_expansion() { return; } @@ -218,7 +217,7 @@ fn late_report_deprecation( def_id: DefId, hir_id: HirId, ) { - if in_derive_expansion(span) { + if span.in_derive_expansion() { return; } diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs index ed61534d54519..8643bd63d8cba 100644 --- a/src/librustc/mir/interpret/error.rs +++ b/src/librustc/mir/interpret/error.rs @@ -154,7 +154,7 @@ impl<'tcx> ConstEvalErr<'tcx> { .next() .unwrap_or(lint_root); tcx.struct_span_lint_hir( - crate::rustc::lint::builtin::CONST_ERR, + rustc_session::lint::builtin::CONST_ERR, hir_id, tcx.span, message, diff --git a/src/librustc/query/mod.rs b/src/librustc/query/mod.rs index 9de46f86200e1..eca9df688c64f 100644 --- a/src/librustc/query/mod.rs +++ b/src/librustc/query/mod.rs @@ -82,7 +82,7 @@ rustc_queries! { desc { "looking up the native libraries of a linked crate" } } - query lint_levels(_: CrateNum) -> &'tcx lint::LintLevelMap { + query lint_levels(_: CrateNum) -> &'tcx LintLevelMap { eval_always desc { "computing the lint levels for items in this crate" } } diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 0c9a73d78a5eb..5440cb7bdf4e5 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -1156,7 +1156,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { err.span_help(impl_span, "trait impl with same name found"); let trait_crate = self.tcx.crate_name(trait_with_same_path.krate); let crate_msg = format!( - "Perhaps two different versions of crate `{}` are being used?", + "perhaps two different versions of crate `{}` are being used?", trait_crate ); err.note(&crate_msg); diff --git a/src/librustc/traits/object_safety.rs b/src/librustc/traits/object_safety.rs index bfbcb042e7a73..ce57fb8110496 100644 --- a/src/librustc/traits/object_safety.rs +++ b/src/librustc/traits/object_safety.rs @@ -10,17 +10,18 @@ use super::elaborate_predicates; -use crate::lint; use crate::traits::{self, Obligation, ObligationCause}; use crate::ty::subst::{InternalSubsts, Subst}; use crate::ty::{self, Predicate, ToPredicate, Ty, TyCtxt, TypeFoldable}; use rustc_hir as hir; use rustc_hir::def_id::DefId; +use rustc_session::lint::builtin::WHERE_CLAUSES_OBJECT_SAFETY; use rustc_span::symbol::Symbol; use rustc_span::{Span, DUMMY_SP}; +use syntax::ast; + use std::borrow::Cow; use std::iter::{self}; -use syntax::ast::{self}; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] pub enum ObjectSafetyViolation { @@ -178,16 +179,17 @@ fn object_safety_violations_for_trait( { // Using `CRATE_NODE_ID` is wrong, but it's hard to get a more precise id. // It's also hard to get a use site span, so we use the method definition span. - tcx.lint_node_note( - lint::builtin::WHERE_CLAUSES_OBJECT_SAFETY, + tcx.struct_span_lint_hir( + WHERE_CLAUSES_OBJECT_SAFETY, hir::CRATE_HIR_ID, *span, &format!( "the trait `{}` cannot be made into an object", tcx.def_path_str(trait_def_id) ), - &violation.error_msg(), - ); + ) + .note(&violation.error_msg()) + .emit(); false } else { true diff --git a/src/librustc/traits/specialize/mod.rs b/src/librustc/traits/specialize/mod.rs index 7b66341ef1c96..f5199dbdabb2f 100644 --- a/src/librustc/traits/specialize/mod.rs +++ b/src/librustc/traits/specialize/mod.rs @@ -12,7 +12,6 @@ pub mod specialization_graph; use crate::infer::{InferCtxt, InferOk}; -use crate::lint; use crate::traits::select::IntercrateAmbiguityCause; use crate::traits::{self, coherence, FutureCompatOverlapErrorKind, ObligationCause, TraitEngine}; use crate::ty::subst::{InternalSubsts, Subst, SubstsRef}; @@ -20,6 +19,7 @@ use crate::ty::{self, TyCtxt, TypeFoldable}; use rustc_data_structures::fx::FxHashSet; use rustc_errors::struct_span_err; use rustc_hir::def_id::DefId; +use rustc_session::lint::builtin::ORDER_DEPENDENT_TRAIT_OBJECTS; use rustc_span::DUMMY_SP; use super::util::impl_trait_ref_and_oblig; @@ -342,7 +342,7 @@ pub(super) fn specialization_graph_provider( unreachable!("converted to hard error above") } FutureCompatOverlapErrorKind::Issue33140 => { - lint::builtin::ORDER_DEPENDENT_TRAIT_OBJECTS + ORDER_DEPENDENT_TRAIT_OBJECTS } }; tcx.struct_span_lint_hir( diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index af079736db544..6b98fddb22ef9 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -8,7 +8,7 @@ use crate::hir::map as hir_map; use crate::hir::map::DefPathHash; use crate::ich::{NodeIdHashingMode, StableHashingContext}; use crate::infer::canonical::{Canonical, CanonicalVarInfo, CanonicalVarInfos}; -use crate::lint::{self, Lint}; +use crate::lint::{struct_lint_level, LintSource}; use crate::middle; use crate::middle::cstore::CrateStoreDyn; use crate::middle::cstore::EncodedMetadata; @@ -20,9 +20,6 @@ use crate::mir::interpret::{Allocation, ConstValue, Scalar}; use crate::mir::{ interpret, BodyAndCache, Field, Local, Place, PlaceElem, ProjectionKind, Promoted, }; -use crate::session::config::CrateType; -use crate::session::config::{BorrowckMode, OutputFilenames}; -use crate::session::Session; use crate::traits; use crate::traits::{Clause, Clauses, Goal, GoalKind, Goals}; use crate::ty::free_region_map::FreeRegionMap; @@ -44,11 +41,15 @@ use crate::ty::{ExistentialPredicate, InferTy, ParamTy, PolyFnSig, Predicate, Pr use crate::ty::{InferConst, ParamConst}; use crate::ty::{List, TyKind, TyS}; use crate::util::common::ErrorReported; +use rustc_data_structures::sync; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIdSet, DefIndex, LOCAL_CRATE}; use rustc_hir::{HirId, Node, TraitCandidate}; use rustc_hir::{ItemKind, ItemLocalId, ItemLocalMap, ItemLocalSet}; +use rustc_session::config::CrateType; +use rustc_session::config::{BorrowckMode, OutputFilenames}; +use rustc_session::Session; use arena::SyncDroplessArena; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; @@ -61,6 +62,7 @@ use rustc_data_structures::sync::{Lock, Lrc, WorkerLocal}; use rustc_errors::DiagnosticBuilder; use rustc_index::vec::{Idx, IndexVec}; use rustc_macros::HashStable; +use rustc_session::lint::{Level, Lint}; use rustc_session::node_id::NodeMap; use rustc_span::source_map::MultiSpan; use rustc_span::symbol::{kw, sym, Symbol}; @@ -946,7 +948,11 @@ pub struct GlobalCtxt<'tcx> { pub sess: &'tcx Session, - pub lint_store: Lrc, + /// This only ever stores a `LintStore` but we don't want a dependency on that type here. + /// + /// FIXME(Centril): consider `dyn LintStoreMarker` once + /// we can upcast to `Any` for some additional type safety. + pub lint_store: Lrc, pub dep_graph: DepGraph, @@ -1115,7 +1121,7 @@ impl<'tcx> TyCtxt<'tcx> { /// reference to the context, to allow formatting values that need it. pub fn create_global_ctxt( s: &'tcx Session, - lint_store: Lrc, + lint_store: Lrc, local_providers: ty::query::Providers<'tcx>, extern_providers: ty::query::Providers<'tcx>, arenas: &'tcx AllArenas, @@ -2551,57 +2557,29 @@ impl<'tcx> TyCtxt<'tcx> { iter.intern_with(|xs| self.intern_goals(xs)) } - pub fn lint_hir>( + pub fn lint_hir( self, lint: &'static Lint, hir_id: HirId, - span: S, + span: impl Into, msg: &str, ) { self.struct_span_lint_hir(lint, hir_id, span.into(), msg).emit() } - pub fn lint_hir_note>( - self, - lint: &'static Lint, - hir_id: HirId, - span: S, - msg: &str, - note: &str, - ) { - let mut err = self.struct_span_lint_hir(lint, hir_id, span.into(), msg); - err.note(note); - err.emit() - } - - pub fn lint_node_note>( - self, - lint: &'static Lint, - id: hir::HirId, - span: S, - msg: &str, - note: &str, - ) { - let mut err = self.struct_span_lint_hir(lint, id, span.into(), msg); - err.note(note); - err.emit() - } - /// Walks upwards from `id` to find a node which might change lint levels with attributes. /// It stops at `bound` and just returns it if reached. - pub fn maybe_lint_level_root_bounded( - self, - mut id: hir::HirId, - bound: hir::HirId, - ) -> hir::HirId { + pub fn maybe_lint_level_root_bounded(self, mut id: HirId, bound: HirId) -> HirId { + let hir = self.hir(); loop { if id == bound { return bound; } - if lint::maybe_lint_level_root(self, id) { + + if hir.attrs(id).iter().any(|attr| Level::from_symbol(attr.name_or_empty()).is_some()) { return id; } - let next = self.hir().get_parent_node(id); + let next = hir.get_parent_node(id); if next == id { bug!("lint traversal reached the root of the crate"); } @@ -2613,7 +2591,7 @@ impl<'tcx> TyCtxt<'tcx> { self, lint: &'static Lint, mut id: hir::HirId, - ) -> (lint::Level, lint::LintSource) { + ) -> (Level, LintSource) { let sets = self.lint_levels(LOCAL_CRATE); loop { if let Some(pair) = sets.level_and_source(lint, id, self.sess) { @@ -2627,15 +2605,15 @@ impl<'tcx> TyCtxt<'tcx> { } } - pub fn struct_span_lint_hir>( + pub fn struct_span_lint_hir( self, lint: &'static Lint, hir_id: HirId, - span: S, + span: impl Into, msg: &str, ) -> DiagnosticBuilder<'tcx> { let (level, src) = self.lint_level_at_node(lint, hir_id); - lint::struct_lint_level(self.sess, lint, level, src, Some(span.into()), msg) + struct_lint_level(self.sess, lint, level, src, Some(span.into()), msg) } pub fn struct_lint_node( @@ -2645,7 +2623,7 @@ impl<'tcx> TyCtxt<'tcx> { msg: &str, ) -> DiagnosticBuilder<'tcx> { let (level, src) = self.lint_level_at_node(lint, id); - lint::struct_lint_level(self.sess, lint, level, src, None, msg) + struct_lint_level(self.sess, lint, level, src, None, msg) } pub fn in_scope_traits(self, id: HirId) -> Option<&'tcx StableVec> { diff --git a/src/librustc/ty/query/mod.rs b/src/librustc/ty/query/mod.rs index 6b272ab3d4a9b..1d41871bb33a9 100644 --- a/src/librustc/ty/query/mod.rs +++ b/src/librustc/ty/query/mod.rs @@ -1,7 +1,7 @@ use crate::dep_graph::{self, DepNode}; use crate::hir::exports::Export; use crate::infer::canonical::{self, Canonical}; -use crate::lint; +use crate::lint::LintLevelMap; use crate::middle::codegen_fn_attrs::CodegenFnAttrs; use crate::middle::cstore::{CrateSource, DepKind, NativeLibraryKind}; use crate::middle::cstore::{ExternCrate, ForeignModule, LinkagePreference, NativeLibrary}; diff --git a/src/librustc_ast_lowering/lib.rs b/src/librustc_ast_lowering/lib.rs index 58b8e8a089ad3..d30d0bd8345ff 100644 --- a/src/librustc_ast_lowering/lib.rs +++ b/src/librustc_ast_lowering/lib.rs @@ -37,7 +37,6 @@ use rustc::arena::Arena; use rustc::dep_graph::DepGraph; use rustc::hir::map::definitions::{DefKey, DefPathData, Definitions}; use rustc::hir::map::Map; -use rustc::lint::builtin; use rustc::{bug, span_bug}; use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxHashSet; @@ -51,7 +50,7 @@ use rustc_hir::intravisit; use rustc_hir::{ConstArg, GenericArg, ParamName}; use rustc_index::vec::IndexVec; use rustc_session::config::nightly_options; -use rustc_session::lint::{BuiltinLintDiagnostics, LintBuffer}; +use rustc_session::lint::{builtin, BuiltinLintDiagnostics, LintBuffer}; use rustc_session::node_id::NodeMap; use rustc_session::Session; use rustc_span::hygiene::ExpnId; diff --git a/src/librustc_ast_passes/Cargo.toml b/src/librustc_ast_passes/Cargo.toml index dced4a0d15b0c..2d45e28044495 100644 --- a/src/librustc_ast_passes/Cargo.toml +++ b/src/librustc_ast_passes/Cargo.toml @@ -11,7 +11,7 @@ path = "lib.rs" [dependencies] log = "0.4" rustc_data_structures = { path = "../librustc_data_structures" } -rustc_errors = { path = "../librustc_errors", package = "rustc_errors" } +rustc_errors = { path = "../librustc_errors" } rustc_error_codes = { path = "../librustc_error_codes" } rustc_feature = { path = "../librustc_feature" } rustc_parse = { path = "../librustc_parse" } diff --git a/src/librustc_ast_passes/feature_gate.rs b/src/librustc_ast_passes/feature_gate.rs index e6f4535a38dba..1e4b1ae077762 100644 --- a/src/librustc_ast_passes/feature_gate.rs +++ b/src/librustc_ast_passes/feature_gate.rs @@ -413,7 +413,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { self.check_extern(bare_fn_ty.ext); } ast::TyKind::Never => { - gate_feature_post!(&self, never_type, ty.span, "The `!` type is experimental"); + gate_feature_post!(&self, never_type, ty.span, "the `!` type is experimental"); } _ => {} } diff --git a/src/librustc_builtin_macros/test.rs b/src/librustc_builtin_macros/test.rs index 0eee212108e85..07715cdbcb5e9 100644 --- a/src/librustc_builtin_macros/test.rs +++ b/src/librustc_builtin_macros/test.rs @@ -325,7 +325,7 @@ fn should_panic(cx: &ExtCtxt<'_>, i: &ast::Item) -> ShouldPanic { `expected = \"error message\"`", ) .note( - "Errors in this attribute were erroneously \ + "errors in this attribute were erroneously \ allowed and will become a hard error in a \ future release.", ) diff --git a/src/librustc_codegen_llvm/intrinsic.rs b/src/librustc_codegen_llvm/intrinsic.rs index 8ea50a972ece6..f6f8296de41ad 100644 --- a/src/librustc_codegen_llvm/intrinsic.rs +++ b/src/librustc_codegen_llvm/intrinsic.rs @@ -858,8 +858,10 @@ fn try_intrinsic( ) { if bx.sess().no_landing_pads() { bx.call(func, &[data], None); - let ptr_align = bx.tcx().data_layout.pointer_align.abi; - bx.store(bx.const_null(bx.type_i8p()), dest, ptr_align); + // Return 0 unconditionally from the intrinsic call; + // we can never unwind. + let ret_align = bx.tcx().data_layout.i32_align.abi; + bx.store(bx.const_i32(0), dest, ret_align); } else if wants_msvc_seh(bx.sess()) { codegen_msvc_try(bx, func, data, local_ptr, dest); } else { diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 3d31f240a34e0..072b85d716d74 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -23,9 +23,7 @@ extern crate lazy_static; pub extern crate rustc_plugin_impl as plugin; -//use rustc_resolve as resolve; -use rustc::lint; -use rustc::lint::Lint; +use rustc::lint::{Lint, LintId}; use rustc::middle::cstore::MetadataLoader; use rustc::session::config::nightly_options; use rustc::session::config::{ErrorOutputType, Input, OutputType, PrintRequest}; @@ -41,6 +39,7 @@ use rustc_feature::{find_gated_cfg, UnstableFeatures}; use rustc_hir::def_id::LOCAL_CRATE; use rustc_interface::util::get_builtin_codegen_backend; use rustc_interface::{interface, Queries}; +use rustc_lint::LintStore; use rustc_metadata::locator; use rustc_save_analysis as save; use rustc_save_analysis::DumpHandler; @@ -811,7 +810,7 @@ the command line flag directly. ); } -fn describe_lints(sess: &Session, lint_store: &lint::LintStore, loaded_plugins: bool) { +fn describe_lints(sess: &Session, lint_store: &LintStore, loaded_plugins: bool) { println!( " Available lint options: @@ -832,8 +831,8 @@ Available lint options: } fn sort_lint_groups( - lints: Vec<(&'static str, Vec, bool)>, - ) -> Vec<(&'static str, Vec)> { + lints: Vec<(&'static str, Vec, bool)>, + ) -> Vec<(&'static str, Vec)> { let mut lints: Vec<_> = lints.into_iter().map(|(x, y, _)| (x, y)).collect(); lints.sort_by_key(|l| l.0); lints @@ -892,7 +891,7 @@ Available lint options: println!(" {} {}", padded("----"), "---------"); println!(" {} {}", padded("warnings"), "all lints that are set to issue warnings"); - let print_lint_groups = |lints: Vec<(&'static str, Vec)>| { + let print_lint_groups = |lints: Vec<(&'static str, Vec)>| { for (name, to) in lints { let name = name.to_lowercase().replace("_", "-"); let desc = to diff --git a/src/librustc_interface/interface.rs b/src/librustc_interface/interface.rs index d00875f6fee88..9cd9eb66cf6c1 100644 --- a/src/librustc_interface/interface.rs +++ b/src/librustc_interface/interface.rs @@ -12,6 +12,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::sync::Lrc; use rustc_data_structures::OnDrop; use rustc_errors::registry::Registry; +use rustc_lint::LintStore; use rustc_parse::new_parser_from_source_str; use rustc_span::edition; use rustc_span::source_map::{FileLoader, FileName, SourceMap}; @@ -36,7 +37,7 @@ pub struct Compiler { pub(crate) output_dir: Option, pub(crate) output_file: Option, pub(crate) crate_name: Option, - pub(crate) register_lints: Option>, + pub(crate) register_lints: Option>, pub(crate) override_queries: Option, &mut ty::query::Providers<'_>)>, } @@ -136,7 +137,7 @@ pub struct Config { /// /// Note that if you find a Some here you probably want to call that function in the new /// function being registered. - pub register_lints: Option>, + pub register_lints: Option>, /// This is a callback from the driver that is called just after we have populated /// the list of queries. diff --git a/src/librustc_interface/passes.rs b/src/librustc_interface/passes.rs index 9119466cbc048..67f9819f3314d 100644 --- a/src/librustc_interface/passes.rs +++ b/src/librustc_interface/passes.rs @@ -27,6 +27,7 @@ use rustc_errors::PResult; use rustc_expand::base::ExtCtxt; use rustc_hir::def_id::{CrateNum, LOCAL_CRATE}; use rustc_incremental; +use rustc_lint::LintStore; use rustc_mir as mir; use rustc_parse::{parse_crate_from_file, parse_crate_from_source_str}; use rustc_passes::{self, hir_stats, layout_test}; @@ -100,7 +101,7 @@ declare_box_region_type!( /// Returns `None` if we're aborting after handling -W help. pub fn configure_and_expand( sess: Lrc, - lint_store: Lrc, + lint_store: Lrc, metadata_loader: Box, krate: ast::Crate, crate_name: &str, @@ -150,10 +151,10 @@ impl BoxedResolver { pub fn register_plugins<'a>( sess: &'a Session, metadata_loader: &'a dyn MetadataLoader, - register_lints: impl Fn(&Session, &mut lint::LintStore), + register_lints: impl Fn(&Session, &mut LintStore), mut krate: ast::Crate, crate_name: &str, -) -> Result<(ast::Crate, Lrc)> { +) -> Result<(ast::Crate, Lrc)> { krate = sess.time("attributes_injection", || { rustc_builtin_macros::cmdline_attrs::inject( krate, @@ -214,7 +215,7 @@ pub fn register_plugins<'a>( fn configure_and_expand_inner<'a>( sess: &'a Session, - lint_store: &'a lint::LintStore, + lint_store: &'a LintStore, mut krate: ast::Crate, crate_name: &str, resolver_arenas: &'a ResolverArenas<'a>, @@ -420,7 +421,7 @@ fn configure_and_expand_inner<'a>( pub fn lower_to_hir<'res, 'tcx>( sess: &'tcx Session, - lint_store: &lint::LintStore, + lint_store: &LintStore, resolver: &'res mut Resolver<'_>, dep_graph: &'res DepGraph, krate: &'res ast::Crate, @@ -705,7 +706,7 @@ impl<'tcx> QueryContext<'tcx> { pub fn create_global_ctxt<'tcx>( compiler: &'tcx Compiler, - lint_store: Lrc, + lint_store: Lrc, hir_forest: &'tcx map::Forest<'tcx>, mut resolver_outputs: ResolverOutputs, outputs: OutputFilenames, diff --git a/src/librustc_interface/queries.rs b/src/librustc_interface/queries.rs index 7de1c36ce4b2e..bd9717d3f3d02 100644 --- a/src/librustc_interface/queries.rs +++ b/src/librustc_interface/queries.rs @@ -4,8 +4,6 @@ use crate::passes::{self, BoxedResolver, QueryContext}; use rustc::arena::Arena; use rustc::dep_graph::DepGraph; use rustc::hir::map; -use rustc::lint; -use rustc::lint::LintStore; use rustc::session::config::{OutputFilenames, OutputType}; use rustc::session::Session; use rustc::ty::steal::Steal; @@ -15,6 +13,7 @@ use rustc_codegen_utils::codegen_backend::CodegenBackend; use rustc_data_structures::sync::{Lrc, Once, WorkerLocal}; use rustc_hir::def_id::LOCAL_CRATE; use rustc_incremental::DepGraphFuture; +use rustc_lint::LintStore; use std::any::Any; use std::cell::{Ref, RefCell, RefMut}; use std::mem; @@ -133,7 +132,7 @@ impl<'tcx> Queries<'tcx> { let crate_name = self.crate_name()?.peek().clone(); let krate = self.parse()?.take(); - let empty: &(dyn Fn(&Session, &mut lint::LintStore) + Sync + Send) = &|_, _| {}; + let empty: &(dyn Fn(&Session, &mut LintStore) + Sync + Send) = &|_, _| {}; let result = passes::register_plugins( self.session(), &*self.codegen_backend().metadata_loader(), diff --git a/src/librustc_interface/tests.rs b/src/librustc_interface/tests.rs index c2e9c35fcd4a7..ec75a1c6a3938 100644 --- a/src/librustc_interface/tests.rs +++ b/src/librustc_interface/tests.rs @@ -2,7 +2,7 @@ extern crate getopts; use crate::interface::parse_cfgspecs; -use rustc::lint; +use rustc::lint::Level; use rustc::middle::cstore; use rustc::session::config::{build_configuration, build_session_options, to_crate_config}; use rustc::session::config::{rustc_optgroups, ErrorOutputType, ExternLocation, Options, Passes}; @@ -186,24 +186,24 @@ fn test_lints_tracking_hash_different_values() { let mut v3 = Options::default(); v1.lint_opts = vec![ - (String::from("a"), lint::Allow), - (String::from("b"), lint::Warn), - (String::from("c"), lint::Deny), - (String::from("d"), lint::Forbid), + (String::from("a"), Level::Allow), + (String::from("b"), Level::Warn), + (String::from("c"), Level::Deny), + (String::from("d"), Level::Forbid), ]; v2.lint_opts = vec![ - (String::from("a"), lint::Allow), - (String::from("b"), lint::Warn), - (String::from("X"), lint::Deny), - (String::from("d"), lint::Forbid), + (String::from("a"), Level::Allow), + (String::from("b"), Level::Warn), + (String::from("X"), Level::Deny), + (String::from("d"), Level::Forbid), ]; v3.lint_opts = vec![ - (String::from("a"), lint::Allow), - (String::from("b"), lint::Warn), - (String::from("c"), lint::Forbid), - (String::from("d"), lint::Deny), + (String::from("a"), Level::Allow), + (String::from("b"), Level::Warn), + (String::from("c"), Level::Forbid), + (String::from("d"), Level::Deny), ]; assert!(v1.dep_tracking_hash() != v2.dep_tracking_hash()); @@ -222,17 +222,17 @@ fn test_lints_tracking_hash_different_construction_order() { let mut v2 = Options::default(); v1.lint_opts = vec![ - (String::from("a"), lint::Allow), - (String::from("b"), lint::Warn), - (String::from("c"), lint::Deny), - (String::from("d"), lint::Forbid), + (String::from("a"), Level::Allow), + (String::from("b"), Level::Warn), + (String::from("c"), Level::Deny), + (String::from("d"), Level::Forbid), ]; v2.lint_opts = vec![ - (String::from("a"), lint::Allow), - (String::from("c"), lint::Deny), - (String::from("b"), lint::Warn), - (String::from("d"), lint::Forbid), + (String::from("a"), Level::Allow), + (String::from("c"), Level::Deny), + (String::from("b"), Level::Warn), + (String::from("d"), Level::Forbid), ]; assert_eq!(v1.dep_tracking_hash(), v2.dep_tracking_hash()); diff --git a/src/librustc_lint/Cargo.toml b/src/librustc_lint/Cargo.toml index 7e23e70577975..abf9f96e6475b 100644 --- a/src/librustc_lint/Cargo.toml +++ b/src/librustc_lint/Cargo.toml @@ -13,6 +13,7 @@ log = "0.4" unicode-security = "0.0.2" rustc = { path = "../librustc" } rustc_errors = { path = "../librustc_errors" } +rustc_error_codes = { path = "../librustc_error_codes" } rustc_hir = { path = "../librustc_hir" } rustc_target = { path = "../librustc_target" } syntax = { path = "../libsyntax" } diff --git a/src/librustc_lint/array_into_iter.rs b/src/librustc_lint/array_into_iter.rs index 19d1052d1b243..fb11b6771e9ca 100644 --- a/src/librustc_lint/array_into_iter.rs +++ b/src/librustc_lint/array_into_iter.rs @@ -1,8 +1,9 @@ -use rustc::lint::{FutureIncompatibleInfo, LateContext, LateLintPass, LintContext}; +use crate::{LateContext, LateLintPass, LintContext}; use rustc::ty; use rustc::ty::adjustment::{Adjust, Adjustment}; use rustc_errors::Applicability; use rustc_hir as hir; +use rustc_session::lint::FutureIncompatibleInfo; use rustc_span::symbol::sym; declare_lint! { diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index befeb84e57c9c..fea0b012f91b3 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -21,8 +21,8 @@ //! If you define a new `LateLintPass`, you will also need to add it to the //! `late_lint_methods!` invocation in `lib.rs`. +use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext}; use rustc::hir::map::Map; -use rustc::lint::{self, EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext}; use rustc::traits::misc::can_type_implement_copy; use rustc::ty::{self, layout::VariantIdx, Ty, TyCtxt}; use rustc_data_structures::fx::FxHashSet; @@ -51,7 +51,7 @@ use log::debug; use std::fmt::Write; // hardwired lints from librustc -pub use lint::builtin::*; +pub use rustc_session::lint::builtin::*; declare_lint! { WHILE_TRUE, @@ -657,7 +657,7 @@ impl EarlyLintPass for AnonymousParameters { ) .span_suggestion( arg.pat.span, - "Try naming the parameter or explicitly \ + "try naming the parameter or explicitly \ ignoring it", format!("_: {}", ty_snip), appl, @@ -1934,21 +1934,21 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidValue { use rustc::ty::TyKind::*; match ty.kind { // Primitive types that don't like 0 as a value. - Ref(..) => Some((format!("References must be non-null"), None)), + Ref(..) => Some((format!("references must be non-null"), None)), Adt(..) if ty.is_box() => Some((format!("`Box` must be non-null"), None)), - FnPtr(..) => Some((format!("Function pointers must be non-null"), None)), - Never => Some((format!("The never type (`!`) has no valid value"), None)), + FnPtr(..) => Some((format!("function pointers must be non-null"), None)), + Never => Some((format!("the `!` type has no valid value"), None)), RawPtr(tm) if matches!(tm.ty.kind, Dynamic(..)) => // raw ptr to dyn Trait { - Some((format!("The vtable of a wide raw pointer must be non-null"), None)) + Some((format!("the vtable of a wide raw pointer must be non-null"), None)) } // Primitive types with other constraints. Bool if init == InitKind::Uninit => { - Some((format!("Booleans must be `true` or `false`"), None)) + Some((format!("booleans must be either `true` or `false`"), None)) } Char if init == InitKind::Uninit => { - Some((format!("Characters must be a valid unicode codepoint"), None)) + Some((format!("characters must be a valid Unicode codepoint"), None)) } // Recurse and checks for some compound types. Adt(adt_def, substs) if !adt_def.is_union() => { @@ -1959,13 +1959,16 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidValue { // return `Bound::Excluded`. (And we have tests checking that we // handle the attribute correctly.) (Bound::Included(lo), _) if lo > 0 => { - return Some((format!("{} must be non-null", ty), None)); + return Some((format!("`{}` must be non-null", ty), None)); } (Bound::Included(_), _) | (_, Bound::Included(_)) if init == InitKind::Uninit => { return Some(( - format!("{} must be initialized inside its custom valid range", ty), + format!( + "`{}` must be initialized inside its custom valid range", + ty, + ), None, )); } @@ -1973,7 +1976,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidValue { } // Now, recurse. match adt_def.variants.len() { - 0 => Some((format!("0-variant enums have no valid value"), None)), + 0 => Some((format!("enums with no variants have no valid value"), None)), 1 => { // Struct, or enum with exactly one variant. // Proceed recursively, check all fields. diff --git a/src/librustc/lint/context.rs b/src/librustc_lint/context.rs similarity index 93% rename from src/librustc/lint/context.rs rename to src/librustc_lint/context.rs index 3f18f4dbd1fe7..2b514c301f2a3 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc_lint/context.rs @@ -16,22 +16,23 @@ use self::TargetLint::*; -use crate::hir::map::{definitions::DisambiguatedDefPathData, DefPathData}; -use crate::lint::levels::{LintLevelSets, LintLevelsBuilder}; -use crate::lint::{EarlyLintPassObject, LateLintPassObject}; -use crate::middle::privacy::AccessLevels; -use crate::middle::stability; -use crate::session::Session; -use crate::ty::layout::{LayoutError, LayoutOf, TyLayout}; -use crate::ty::{self, print::Printer, subst::GenericArg, Ty, TyCtxt}; +use crate::levels::LintLevelsBuilder; +use crate::passes::{EarlyLintPassObject, LateLintPassObject}; +use rustc::hir::map::definitions::{DefPathData, DisambiguatedDefPathData}; +use rustc::lint::add_elided_lifetime_in_path_suggestion; +use rustc::middle::privacy::AccessLevels; +use rustc::middle::stability; +use rustc::ty::layout::{LayoutError, LayoutOf, TyLayout}; +use rustc::ty::{self, print::Printer, subst::GenericArg, Ty, TyCtxt}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sync; use rustc_error_codes::*; -use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder}; +use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder}; use rustc_hir as hir; use rustc_hir::def_id::{CrateNum, DefId}; use rustc_session::lint::BuiltinLintDiagnostics; use rustc_session::lint::{FutureIncompatibleInfo, Level, Lint, LintBuffer, LintId}; +use rustc_session::Session; use rustc_span::{symbol::Symbol, MultiSpan, Span, DUMMY_SP}; use syntax::ast; use syntax::util::lev_distance::find_best_match_for_name; @@ -467,48 +468,6 @@ impl LintPassObject for EarlyLintPassObject {} impl LintPassObject for LateLintPassObject {} -pub fn add_elided_lifetime_in_path_suggestion( - sess: &Session, - db: &mut DiagnosticBuilder<'_>, - n: usize, - path_span: Span, - incl_angl_brckt: bool, - insertion_span: Span, - anon_lts: String, -) { - let (replace_span, suggestion) = if incl_angl_brckt { - (insertion_span, anon_lts) - } else { - // When possible, prefer a suggestion that replaces the whole - // `Path` expression with `Path<'_, T>`, rather than inserting `'_, ` - // at a point (which makes for an ugly/confusing label) - if let Ok(snippet) = sess.source_map().span_to_snippet(path_span) { - // But our spans can get out of whack due to macros; if the place we think - // we want to insert `'_` isn't even within the path expression's span, we - // should bail out of making any suggestion rather than panicking on a - // subtract-with-overflow or string-slice-out-out-bounds (!) - // FIXME: can we do better? - if insertion_span.lo().0 < path_span.lo().0 { - return; - } - let insertion_index = (insertion_span.lo().0 - path_span.lo().0) as usize; - if insertion_index > snippet.len() { - return; - } - let (before, after) = snippet.split_at(insertion_index); - (path_span, format!("{}{}{}", before, anon_lts, after)) - } else { - (insertion_span, anon_lts) - } - }; - db.span_suggestion( - replace_span, - &format!("indicate the anonymous lifetime{}", pluralize!(n)), - suggestion, - Applicability::MachineApplicable, - ); -} - pub trait LintContext: Sized { type PassObject: LintPassObject; @@ -674,7 +633,7 @@ impl<'a> EarlyContext<'a> { sess, krate, lint_store, - builder: LintLevelSets::builder(sess, warn_about_weird_lints, lint_store), + builder: LintLevelsBuilder::new(sess, warn_about_weird_lints, lint_store), buffered, } } diff --git a/src/librustc_lint/early.rs b/src/librustc_lint/early.rs index 9a90171985158..490114b2d4d2a 100644 --- a/src/librustc_lint/early.rs +++ b/src/librustc_lint/early.rs @@ -14,10 +14,9 @@ //! upon. As the ast is traversed, this keeps track of the current lint level //! for all lint attributes. -use rustc::lint::{EarlyContext, LintStore}; -use rustc::lint::{EarlyLintPass, EarlyLintPassObject}; -use rustc::lint::{LintContext, LintPass}; -use rustc_session::lint::LintBuffer; +use crate::context::{EarlyContext, LintContext, LintStore}; +use crate::passes::{EarlyLintPass, EarlyLintPassObject}; +use rustc_session::lint::{LintBuffer, LintPass}; use rustc_session::Session; use rustc_span::Span; use syntax::ast; @@ -291,7 +290,7 @@ macro_rules! early_lint_pass_impl { ) } -early_lint_methods!(early_lint_pass_impl, []); +crate::early_lint_methods!(early_lint_pass_impl, []); fn early_lint_crate( sess: &Session, diff --git a/src/librustc/lint/internal.rs b/src/librustc_lint/internal.rs similarity index 98% rename from src/librustc/lint/internal.rs rename to src/librustc_lint/internal.rs index 30679226b9b71..2f8393bd906c0 100644 --- a/src/librustc/lint/internal.rs +++ b/src/librustc_lint/internal.rs @@ -1,7 +1,7 @@ //! Some lints that are only useful in the compiler or crates that use compiler internals, such as //! Clippy. -use crate::lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext}; +use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext}; use rustc_data_structures::fx::FxHashMap; use rustc_errors::Applicability; use rustc_hir::{GenericArg, HirId, MutTy, Mutability, Path, PathSegment, QPath, Ty, TyKind}; diff --git a/src/librustc_lint/late.rs b/src/librustc_lint/late.rs index d8e0274cf43b9..30a3788377508 100644 --- a/src/librustc_lint/late.rs +++ b/src/librustc_lint/late.rs @@ -14,9 +14,8 @@ //! upon. As the ast is traversed, this keeps track of the current lint level //! for all lint attributes. +use crate::{passes::LateLintPassObject, LateContext, LateLintPass, LintStore}; use rustc::hir::map::Map; -use rustc::lint::LateContext; -use rustc::lint::{LateLintPass, LateLintPassObject}; use rustc::ty::{self, TyCtxt}; use rustc_data_structures::sync::{join, par_iter, ParallelIterator}; use rustc_hir as hir; @@ -29,8 +28,16 @@ use syntax::ast; use syntax::walk_list; use log::debug; +use std::any::Any; use std::slice; +/// Extract the `LintStore` from the query context. +/// This function exists because we've erased `LintStore` as `dyn Any` in the context. +crate fn unerased_lint_store<'tcx>(tcx: TyCtxt<'tcx>) -> &'tcx LintStore { + let store: &dyn Any = &*tcx.lint_store; + store.downcast_ref().unwrap() +} + macro_rules! lint_callback { ($cx:expr, $f:ident, $($args:expr),*) => ({ $cx.pass.$f(&$cx.context, $($args),*); }) } @@ -342,7 +349,7 @@ macro_rules! late_lint_pass_impl { ) } -late_lint_methods!(late_lint_pass_impl, [], ['tcx]); +crate::late_lint_methods!(late_lint_pass_impl, [], ['tcx]); fn late_lint_mod_pass<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>( tcx: TyCtxt<'tcx>, @@ -356,7 +363,7 @@ fn late_lint_mod_pass<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>( tables: &ty::TypeckTables::empty(None), param_env: ty::ParamEnv::empty(), access_levels, - lint_store: &tcx.lint_store, + lint_store: unerased_lint_store(tcx), last_node_with_lint_attrs: tcx.hir().as_local_hir_id(module_def_id).unwrap(), generics: None, only_module: true, @@ -386,7 +393,7 @@ pub fn late_lint_mod<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>( late_lint_mod_pass(tcx, module_def_id, builtin_lints); let mut passes: Vec<_> = - tcx.lint_store.late_module_passes.iter().map(|pass| (pass)()).collect(); + unerased_lint_store(tcx).late_module_passes.iter().map(|pass| (pass)()).collect(); if !passes.is_empty() { late_lint_mod_pass(tcx, module_def_id, LateLintPassObjects { lints: &mut passes[..] }); @@ -403,7 +410,7 @@ fn late_lint_pass_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(tcx: TyCtxt<'tc tables: &ty::TypeckTables::empty(None), param_env: ty::ParamEnv::empty(), access_levels, - lint_store: &tcx.lint_store, + lint_store: unerased_lint_store(tcx), last_node_with_lint_attrs: hir::CRATE_HIR_ID, generics: None, only_module: false, @@ -424,7 +431,7 @@ fn late_lint_pass_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(tcx: TyCtxt<'tc } fn late_lint_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(tcx: TyCtxt<'tcx>, builtin_lints: T) { - let mut passes = tcx.lint_store.late_passes.iter().map(|p| (p)()).collect::>(); + let mut passes = unerased_lint_store(tcx).late_passes.iter().map(|p| (p)()).collect::>(); if !tcx.sess.opts.debugging_opts.no_interleave_lints { if !passes.is_empty() { @@ -443,7 +450,7 @@ fn late_lint_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(tcx: TyCtxt<'tcx>, b } let mut passes: Vec<_> = - tcx.lint_store.late_module_passes.iter().map(|pass| (pass)()).collect(); + unerased_lint_store(tcx).late_module_passes.iter().map(|pass| (pass)()).collect(); for pass in &mut passes { tcx.sess diff --git a/src/librustc_lint/levels.rs b/src/librustc_lint/levels.rs index 3d3e57fe2bae3..bbc3e57f5dd01 100644 --- a/src/librustc_lint/levels.rs +++ b/src/librustc_lint/levels.rs @@ -1,22 +1,33 @@ +use crate::context::{CheckLintNameResult, LintStore}; +use crate::late::unerased_lint_store; use rustc::hir::map::Map; -use rustc::lint::{LintLevelMap, LintLevelSets, LintLevelsBuilder, LintStore}; +use rustc::lint::struct_lint_level; +use rustc::lint::{LintLevelMap, LintLevelSets, LintSet, LintSource}; use rustc::ty::query::Providers; use rustc::ty::TyCtxt; +use rustc_data_structures::fx::FxHashMap; +use rustc_error_codes::*; +use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder}; use rustc_hir as hir; use rustc_hir::def_id::{CrateNum, LOCAL_CRATE}; +use rustc_hir::hir_id::HirId; use rustc_hir::intravisit; +use rustc_session::lint::{builtin, Level, Lint}; +use rustc_session::Session; +use rustc_span::{sym, MultiSpan, Symbol}; use syntax::ast; +use syntax::attr; +use syntax::print::pprust; +use syntax::sess::feature_err; +use syntax::unwrap_or; -pub use rustc_session::lint::{FutureIncompatibleInfo, Level, Lint, LintId}; +use std::cmp; fn lint_levels(tcx: TyCtxt<'_>, cnum: CrateNum) -> &LintLevelMap { assert_eq!(cnum, LOCAL_CRATE); - let store = &tcx.lint_store; - let mut builder = LintLevelMapBuilder { - levels: LintLevelSets::builder(tcx.sess, false, &store), - tcx: tcx, - store: store, - }; + let store = unerased_lint_store(tcx); + let levels = LintLevelsBuilder::new(tcx.sess, false, &store); + let mut builder = LintLevelMapBuilder { levels, tcx, store }; let krate = tcx.hir().krate(); let push = builder.levels.push(&krate.attrs, &store); @@ -30,6 +41,378 @@ fn lint_levels(tcx: TyCtxt<'_>, cnum: CrateNum) -> &LintLevelMap { tcx.arena.alloc(builder.levels.build_map()) } +pub struct LintLevelsBuilder<'a> { + sess: &'a Session, + sets: LintLevelSets, + id_to_set: FxHashMap, + cur: u32, + warn_about_weird_lints: bool, +} + +pub struct BuilderPush { + prev: u32, + pub changed: bool, +} + +impl<'a> LintLevelsBuilder<'a> { + pub fn new(sess: &'a Session, warn_about_weird_lints: bool, store: &LintStore) -> Self { + let mut builder = LintLevelsBuilder { + sess, + sets: LintLevelSets::new(), + cur: 0, + id_to_set: Default::default(), + warn_about_weird_lints, + }; + builder.process_command_line(sess, store); + assert_eq!(builder.sets.list.len(), 1); + builder + } + + fn process_command_line(&mut self, sess: &Session, store: &LintStore) { + let mut specs = FxHashMap::default(); + self.sets.lint_cap = sess.opts.lint_cap.unwrap_or(Level::Forbid); + + for &(ref lint_name, level) in &sess.opts.lint_opts { + store.check_lint_name_cmdline(sess, &lint_name, level); + + // If the cap is less than this specified level, e.g., if we've got + // `--cap-lints allow` but we've also got `-D foo` then we ignore + // this specification as the lint cap will set it to allow anyway. + let level = cmp::min(level, self.sets.lint_cap); + + let lint_flag_val = Symbol::intern(lint_name); + let ids = match store.find_lints(&lint_name) { + Ok(ids) => ids, + Err(_) => continue, // errors handled in check_lint_name_cmdline above + }; + for id in ids { + let src = LintSource::CommandLine(lint_flag_val); + specs.insert(id, (level, src)); + } + } + + self.sets.list.push(LintSet::CommandLine { specs }); + } + + /// Pushes a list of AST lint attributes onto this context. + /// + /// This function will return a `BuilderPush` object which should be passed + /// to `pop` when this scope for the attributes provided is exited. + /// + /// This function will perform a number of tasks: + /// + /// * It'll validate all lint-related attributes in `attrs` + /// * It'll mark all lint-related attributes as used + /// * Lint levels will be updated based on the attributes provided + /// * Lint attributes are validated, e.g., a #[forbid] can't be switched to + /// #[allow] + /// + /// Don't forget to call `pop`! + pub fn push(&mut self, attrs: &[ast::Attribute], store: &LintStore) -> BuilderPush { + let mut specs = FxHashMap::default(); + let sess = self.sess; + let bad_attr = |span| struct_span_err!(sess, span, E0452, "malformed lint attribute input"); + for attr in attrs { + let level = match Level::from_symbol(attr.name_or_empty()) { + None => continue, + Some(lvl) => lvl, + }; + + let meta = unwrap_or!(attr.meta(), continue); + attr::mark_used(attr); + + let mut metas = unwrap_or!(meta.meta_item_list(), continue); + + if metas.is_empty() { + // FIXME (#55112): issue unused-attributes lint for `#[level()]` + continue; + } + + // Before processing the lint names, look for a reason (RFC 2383) + // at the end. + let mut reason = None; + let tail_li = &metas[metas.len() - 1]; + if let Some(item) = tail_li.meta_item() { + match item.kind { + ast::MetaItemKind::Word => {} // actual lint names handled later + ast::MetaItemKind::NameValue(ref name_value) => { + if item.path == sym::reason { + // found reason, reslice meta list to exclude it + metas = &metas[0..metas.len() - 1]; + // FIXME (#55112): issue unused-attributes lint if we thereby + // don't have any lint names (`#[level(reason = "foo")]`) + if let ast::LitKind::Str(rationale, _) = name_value.kind { + if !self.sess.features_untracked().lint_reasons { + feature_err( + &self.sess.parse_sess, + sym::lint_reasons, + item.span, + "lint reasons are experimental", + ) + .emit(); + } + reason = Some(rationale); + } else { + bad_attr(name_value.span) + .span_label(name_value.span, "reason must be a string literal") + .emit(); + } + } else { + bad_attr(item.span) + .span_label(item.span, "bad attribute argument") + .emit(); + } + } + ast::MetaItemKind::List(_) => { + bad_attr(item.span).span_label(item.span, "bad attribute argument").emit(); + } + } + } + + for li in metas { + let meta_item = match li.meta_item() { + Some(meta_item) if meta_item.is_word() => meta_item, + _ => { + let sp = li.span(); + let mut err = bad_attr(sp); + let mut add_label = true; + if let Some(item) = li.meta_item() { + if let ast::MetaItemKind::NameValue(_) = item.kind { + if item.path == sym::reason { + err.span_label(sp, "reason in lint attribute must come last"); + add_label = false; + } + } + } + if add_label { + err.span_label(sp, "bad attribute argument"); + } + err.emit(); + continue; + } + }; + let tool_name = if meta_item.path.segments.len() > 1 { + let tool_ident = meta_item.path.segments[0].ident; + if !attr::is_known_lint_tool(tool_ident) { + struct_span_err!( + sess, + tool_ident.span, + E0710, + "an unknown tool name found in scoped lint: `{}`", + pprust::path_to_string(&meta_item.path), + ) + .emit(); + continue; + } + + Some(tool_ident.name) + } else { + None + }; + let name = meta_item.path.segments.last().expect("empty lint name").ident.name; + match store.check_lint_name(&name.as_str(), tool_name) { + CheckLintNameResult::Ok(ids) => { + let src = LintSource::Node(name, li.span(), reason); + for id in ids { + specs.insert(*id, (level, src)); + } + } + + CheckLintNameResult::Tool(result) => { + match result { + Ok(ids) => { + let complete_name = &format!("{}::{}", tool_name.unwrap(), name); + let src = LintSource::Node( + Symbol::intern(complete_name), + li.span(), + reason, + ); + for id in ids { + specs.insert(*id, (level, src)); + } + } + Err((Some(ids), new_lint_name)) => { + let lint = builtin::RENAMED_AND_REMOVED_LINTS; + let (lvl, src) = + self.sets.get_lint_level(lint, self.cur, Some(&specs), &sess); + let msg = format!( + "lint name `{}` is deprecated \ + and may not have an effect in the future. \ + Also `cfg_attr(cargo-clippy)` won't be necessary anymore", + name + ); + struct_lint_level( + self.sess, + lint, + lvl, + src, + Some(li.span().into()), + &msg, + ) + .span_suggestion( + li.span(), + "change it to", + new_lint_name.to_string(), + Applicability::MachineApplicable, + ) + .emit(); + + let src = LintSource::Node( + Symbol::intern(&new_lint_name), + li.span(), + reason, + ); + for id in ids { + specs.insert(*id, (level, src)); + } + } + Err((None, _)) => { + // If Tool(Err(None, _)) is returned, then either the lint does not + // exist in the tool or the code was not compiled with the tool and + // therefore the lint was never added to the `LintStore`. To detect + // this is the responsibility of the lint tool. + } + } + } + + _ if !self.warn_about_weird_lints => {} + + CheckLintNameResult::Warning(msg, renamed) => { + let lint = builtin::RENAMED_AND_REMOVED_LINTS; + let (level, src) = + self.sets.get_lint_level(lint, self.cur, Some(&specs), &sess); + let mut err = struct_lint_level( + self.sess, + lint, + level, + src, + Some(li.span().into()), + &msg, + ); + if let Some(new_name) = renamed { + err.span_suggestion( + li.span(), + "use the new name", + new_name, + Applicability::MachineApplicable, + ); + } + err.emit(); + } + CheckLintNameResult::NoLint(suggestion) => { + let lint = builtin::UNKNOWN_LINTS; + let (level, src) = + self.sets.get_lint_level(lint, self.cur, Some(&specs), self.sess); + let msg = format!("unknown lint: `{}`", name); + let mut db = struct_lint_level( + self.sess, + lint, + level, + src, + Some(li.span().into()), + &msg, + ); + + if let Some(suggestion) = suggestion { + db.span_suggestion( + li.span(), + "did you mean", + suggestion.to_string(), + Applicability::MachineApplicable, + ); + } + + db.emit(); + } + } + } + } + + for (id, &(level, ref src)) in specs.iter() { + if level == Level::Forbid { + continue; + } + let forbid_src = match self.sets.get_lint_id_level(*id, self.cur, None) { + (Some(Level::Forbid), src) => src, + _ => continue, + }; + let forbidden_lint_name = match forbid_src { + LintSource::Default => id.to_string(), + LintSource::Node(name, _, _) => name.to_string(), + LintSource::CommandLine(name) => name.to_string(), + }; + let (lint_attr_name, lint_attr_span) = match *src { + LintSource::Node(name, span, _) => (name, span), + _ => continue, + }; + let mut diag_builder = struct_span_err!( + self.sess, + lint_attr_span, + E0453, + "{}({}) overruled by outer forbid({})", + level.as_str(), + lint_attr_name, + forbidden_lint_name + ); + diag_builder.span_label(lint_attr_span, "overruled by previous forbid"); + match forbid_src { + LintSource::Default => {} + LintSource::Node(_, forbid_source_span, reason) => { + diag_builder.span_label(forbid_source_span, "`forbid` level set here"); + if let Some(rationale) = reason { + diag_builder.note(&rationale.as_str()); + } + } + LintSource::CommandLine(_) => { + diag_builder.note("`forbid` lint level was set on command line"); + } + } + diag_builder.emit(); + // don't set a separate error for every lint in the group + break; + } + + let prev = self.cur; + if specs.len() > 0 { + self.cur = self.sets.list.len() as u32; + self.sets.list.push(LintSet::Node { specs: specs, parent: prev }); + } + + BuilderPush { prev: prev, changed: prev != self.cur } + } + + /// Called after `push` when the scope of a set of attributes are exited. + pub fn pop(&mut self, push: BuilderPush) { + self.cur = push.prev; + } + + /// Used to emit a lint-related diagnostic based on the current state of + /// this lint context. + pub fn struct_lint( + &self, + lint: &'static Lint, + span: Option, + msg: &str, + ) -> DiagnosticBuilder<'a> { + let (level, src) = self.sets.get_lint_level(lint, self.cur, None, self.sess); + struct_lint_level(self.sess, lint, level, src, span, msg) + } + + /// Registers the ID provided with the current set of lints stored in + /// this context. + pub fn register_id(&mut self, id: HirId) { + self.id_to_set.insert(id, self.cur); + } + + pub fn build(self) -> LintLevelSets { + self.sets + } + + pub fn build_map(self) -> LintLevelMap { + LintLevelMap { sets: self.sets, id_to_set: self.id_to_set } + } +} + struct LintLevelMapBuilder<'a, 'tcx> { levels: LintLevelsBuilder<'tcx>, tcx: TyCtxt<'tcx>, diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index e708ded603b25..6e3382dee9aae 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -1,9 +1,25 @@ -//! # Lints in the Rust compiler +//! Lints, aka compiler warnings. //! -//! This currently only contains the definitions and implementations -//! of most of the lints that `rustc` supports directly, it does not -//! contain the infrastructure for defining/registering lints. That is -//! available in `rustc::lint` and `rustc_driver::plugin` respectively. +//! A 'lint' check is a kind of miscellaneous constraint that a user _might_ +//! want to enforce, but might reasonably want to permit as well, on a +//! module-by-module basis. They contrast with static constraints enforced by +//! other phases of the compiler, which are generally required to hold in order +//! to compile the program at all. +//! +//! Most lints can be written as `LintPass` instances. These run after +//! all other analyses. The `LintPass`es built into rustc are defined +//! within `rustc_session::lint::builtin`, +//! which has further comments on how to add such a lint. +//! rustc can also load user-defined lint plugins via the plugin mechanism. +//! +//! Some of rustc's lints are defined elsewhere in the compiler and work by +//! calling `add_lint()` on the overall `Session` object. This works when +//! it happens before the main lint pass, which emits the lints stored by +//! `add_lint()`. To emit lints after the main lint pass (from codegen, for +//! example) requires more effort. See `emit_lint` and `GatherNodeLevels` +//! in `context.rs`. +//! +//! Some code also exists in `rustc_session::lint`, `rustc::lint`. //! //! ## Note //! @@ -14,6 +30,8 @@ #![feature(bool_to_option)] #![feature(box_patterns)] #![feature(box_syntax)] +#![feature(crate_visibility_modifier)] +#![feature(never_type)] #![feature(nll)] #![recursion_limit = "256"] @@ -24,45 +42,47 @@ extern crate rustc_session; mod array_into_iter; pub mod builtin; +mod context; mod early; +mod internal; mod late; mod levels; mod non_ascii_idents; mod nonstandard_style; +mod passes; mod redundant_semicolon; mod types; mod unused; -use rustc::lint; -use rustc::lint::builtin::{ - BARE_TRAIT_OBJECTS, ELIDED_LIFETIMES_IN_PATHS, EXPLICIT_OUTLIVES_REQUIREMENTS, - INTRA_DOC_LINK_RESOLUTION_FAILURE, MISSING_DOC_CODE_EXAMPLES, PRIVATE_DOC_TESTS, -}; -use rustc::lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass}; use rustc::ty::query::Providers; use rustc::ty::TyCtxt; use rustc_hir as hir; use rustc_hir::def_id::DefId; -use rustc_session::lint::{LintArray, LintPass}; - +use rustc_session::lint::builtin::{ + BARE_TRAIT_OBJECTS, ELIDED_LIFETIMES_IN_PATHS, EXPLICIT_OUTLIVES_REQUIREMENTS, + INTRA_DOC_LINK_RESOLUTION_FAILURE, MISSING_DOC_CODE_EXAMPLES, PRIVATE_DOC_TESTS, +}; use rustc_span::Span; use syntax::ast; -use lint::LintId; - use array_into_iter::ArrayIntoIter; use builtin::*; +use internal::*; use non_ascii_idents::*; use nonstandard_style::*; use redundant_semicolon::*; -use rustc::lint::internal::*; use types::*; use unused::*; -/// Useful for other parts of the compiler. +/// Useful for other parts of the compiler / Clippy. pub use builtin::SoftLints; +pub use context::{EarlyContext, LateContext, LintContext, LintStore}; pub use early::check_ast_crate; pub use late::check_crate; +pub use passes::{EarlyLintPass, LateLintPass}; +pub use rustc_session::lint::Level::{self, *}; +pub use rustc_session::lint::{BufferedEarlyLint, FutureIncompatibleInfo, Lint, LintId}; +pub use rustc_session::lint::{LintArray, LintPass}; pub fn provide(providers: &mut Providers<'_>) { levels::provide(providers); @@ -179,8 +199,8 @@ late_lint_passes!(declare_combined_late_pass, [pub BuiltinCombinedLateLintPass]) late_lint_mod_passes!(declare_combined_late_pass, [BuiltinCombinedModuleLateLintPass]); -pub fn new_lint_store(no_interleave_lints: bool, internal_lints: bool) -> lint::LintStore { - let mut lint_store = lint::LintStore::new(); +pub fn new_lint_store(no_interleave_lints: bool, internal_lints: bool) -> LintStore { + let mut lint_store = LintStore::new(); register_builtins(&mut lint_store, no_interleave_lints); if internal_lints { @@ -193,7 +213,7 @@ pub fn new_lint_store(no_interleave_lints: bool, internal_lints: bool) -> lint:: /// Tell the `LintStore` about all the built-in lints (the ones /// defined in this crate and the ones defined in /// `rustc::lint::builtin`). -fn register_builtins(store: &mut lint::LintStore, no_interleave_lints: bool) { +fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) { macro_rules! add_lint_group { ($name:expr, $($lint:ident),*) => ( store.register_group(false, $name, None, vec![$(LintId::of($lint)),*]); @@ -390,7 +410,7 @@ fn register_builtins(store: &mut lint::LintStore, no_interleave_lints: bool) { store.register_removed("plugin_as_library", "plugins have been deprecated and retired"); } -fn register_internals(store: &mut lint::LintStore) { +fn register_internals(store: &mut LintStore) { store.register_lints(&DefaultHashTypes::get_lints()); store.register_early_pass(|| box DefaultHashTypes::new()); store.register_lints(&LintPassImpl::get_lints()); diff --git a/src/librustc_lint/non_ascii_idents.rs b/src/librustc_lint/non_ascii_idents.rs index 522aeb6b14420..3c85a1b31b244 100644 --- a/src/librustc_lint/non_ascii_idents.rs +++ b/src/librustc_lint/non_ascii_idents.rs @@ -1,4 +1,4 @@ -use rustc::lint::{EarlyContext, EarlyLintPass, LintContext}; +use crate::{EarlyContext, EarlyLintPass, LintContext}; use syntax::ast; declare_lint! { diff --git a/src/librustc_lint/nonstandard_style.rs b/src/librustc_lint/nonstandard_style.rs index f75bb9ba32c3d..a2b7884241ff7 100644 --- a/src/librustc_lint/nonstandard_style.rs +++ b/src/librustc_lint/nonstandard_style.rs @@ -1,4 +1,4 @@ -use rustc::lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext}; +use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext}; use rustc::ty; use rustc_errors::Applicability; use rustc_hir as hir; diff --git a/src/librustc/lint/mod.rs b/src/librustc_lint/passes.rs similarity index 54% rename from src/librustc/lint/mod.rs rename to src/librustc_lint/passes.rs index 4afeb14494850..7e5d670767ad8 100644 --- a/src/librustc/lint/mod.rs +++ b/src/librustc_lint/passes.rs @@ -1,47 +1,12 @@ -//! Lints, aka compiler warnings. -//! -//! A 'lint' check is a kind of miscellaneous constraint that a user _might_ -//! want to enforce, but might reasonably want to permit as well, on a -//! module-by-module basis. They contrast with static constraints enforced by -//! other phases of the compiler, which are generally required to hold in order -//! to compile the program at all. -//! -//! Most lints can be written as `LintPass` instances. These run after -//! all other analyses. The `LintPass`es built into rustc are defined -//! within `builtin.rs`, which has further comments on how to add such a lint. -//! rustc can also load user-defined lint plugins via the plugin mechanism. -//! -//! Some of rustc's lints are defined elsewhere in the compiler and work by -//! calling `add_lint()` on the overall `Session` object. This works when -//! it happens before the main lint pass, which emits the lints stored by -//! `add_lint()`. To emit lints after the main lint pass (from codegen, for -//! example) requires more effort. See `emit_lint` and `GatherNodeLevels` -//! in `context.rs`. +use crate::context::{EarlyContext, LateContext}; -pub use self::Level::*; -pub use self::LintSource::*; - -use crate::ty::TyCtxt; use rustc_data_structures::sync; -use rustc_errors::{DiagnosticBuilder, DiagnosticId}; use rustc_hir as hir; use rustc_session::lint::builtin::HardwiredLints; -use rustc_session::{DiagnosticMessageId, Session}; -use rustc_span::hygiene::MacroKind; -use rustc_span::source_map::{DesugaringKind, ExpnKind, MultiSpan}; -use rustc_span::symbol::Symbol; +use rustc_session::lint::LintPass; use rustc_span::Span; use syntax::ast; -pub use crate::lint::context::{ - add_elided_lifetime_in_path_suggestion, CheckLintNameResult, EarlyContext, LateContext, - LintContext, LintStore, -}; - -pub use rustc_session::lint::builtin; -pub use rustc_session::lint::{BufferedEarlyLint, FutureIncompatibleInfo, Level, Lint, LintId}; -pub use rustc_session::lint::{LintArray, LintPass}; - #[macro_export] macro_rules! late_lint_methods { ($macro:path, $args:tt, [$hir:tt]) => ( @@ -176,6 +141,7 @@ macro_rules! declare_combined_late_lint_pass { expand_combined_late_lint_pass_methods!([$($passes),*], $methods); } + #[allow(rustc::lint_pass_impl_without_macro)] impl LintPass for $name { fn name(&self) -> &'static str { panic!() @@ -303,6 +269,7 @@ macro_rules! declare_combined_early_lint_pass { expand_combined_early_lint_pass_methods!([$($passes),*], $methods); } + #[allow(rustc::lint_pass_impl_without_macro)] impl LintPass for $name { fn name(&self) -> &'static str { panic!() @@ -315,190 +282,3 @@ macro_rules! declare_combined_early_lint_pass { pub type EarlyLintPassObject = Box; pub type LateLintPassObject = Box LateLintPass<'a, 'tcx> + sync::Send + sync::Sync + 'static>; - -/// How a lint level was set. -#[derive(Clone, Copy, PartialEq, Eq, HashStable)] -pub enum LintSource { - /// Lint is at the default level as declared - /// in rustc or a plugin. - Default, - - /// Lint level was set by an attribute. - Node(ast::Name, Span, Option /* RFC 2383 reason */), - - /// Lint level was set by a command-line flag. - CommandLine(Symbol), -} - -pub type LevelSource = (Level, LintSource); - -mod context; -pub mod internal; -mod levels; - -pub use self::levels::{LintLevelMap, LintLevelSets, LintLevelsBuilder}; - -pub fn struct_lint_level<'a>( - sess: &'a Session, - lint: &'static Lint, - level: Level, - src: LintSource, - span: Option, - msg: &str, -) -> DiagnosticBuilder<'a> { - let mut err = match (level, span) { - (Level::Allow, _) => return sess.diagnostic().struct_dummy(), - (Level::Warn, Some(span)) => sess.struct_span_warn(span, msg), - (Level::Warn, None) => sess.struct_warn(msg), - (Level::Deny, Some(span)) | (Level::Forbid, Some(span)) => sess.struct_span_err(span, msg), - (Level::Deny, None) | (Level::Forbid, None) => sess.struct_err(msg), - }; - - // Check for future incompatibility lints and issue a stronger warning. - let lint_id = LintId::of(lint); - let future_incompatible = lint.future_incompatible; - - // If this code originates in a foreign macro, aka something that this crate - // did not itself author, then it's likely that there's nothing this crate - // can do about it. We probably want to skip the lint entirely. - if err.span.primary_spans().iter().any(|s| in_external_macro(sess, *s)) { - // Any suggestions made here are likely to be incorrect, so anything we - // emit shouldn't be automatically fixed by rustfix. - err.allow_suggestions(false); - - // If this is a future incompatible lint it'll become a hard error, so - // we have to emit *something*. Also allow lints to whitelist themselves - // on a case-by-case basis for emission in a foreign macro. - if future_incompatible.is_none() && !lint.report_in_external_macro { - err.cancel(); - // Don't continue further, since we don't want to have - // `diag_span_note_once` called for a diagnostic that isn't emitted. - return err; - } - } - - let name = lint.name_lower(); - match src { - LintSource::Default => { - sess.diag_note_once( - &mut err, - DiagnosticMessageId::from(lint), - &format!("`#[{}({})]` on by default", level.as_str(), name), - ); - } - LintSource::CommandLine(lint_flag_val) => { - let flag = match level { - Level::Warn => "-W", - Level::Deny => "-D", - Level::Forbid => "-F", - Level::Allow => panic!(), - }; - let hyphen_case_lint_name = name.replace("_", "-"); - if lint_flag_val.as_str() == name { - sess.diag_note_once( - &mut err, - DiagnosticMessageId::from(lint), - &format!( - "requested on the command line with `{} {}`", - flag, hyphen_case_lint_name - ), - ); - } else { - let hyphen_case_flag_val = lint_flag_val.as_str().replace("_", "-"); - sess.diag_note_once( - &mut err, - DiagnosticMessageId::from(lint), - &format!( - "`{} {}` implied by `{} {}`", - flag, hyphen_case_lint_name, flag, hyphen_case_flag_val - ), - ); - } - } - LintSource::Node(lint_attr_name, src, reason) => { - if let Some(rationale) = reason { - err.note(&rationale.as_str()); - } - sess.diag_span_note_once( - &mut err, - DiagnosticMessageId::from(lint), - src, - "lint level defined here", - ); - if lint_attr_name.as_str() != name { - let level_str = level.as_str(); - sess.diag_note_once( - &mut err, - DiagnosticMessageId::from(lint), - &format!( - "`#[{}({})]` implied by `#[{}({})]`", - level_str, name, level_str, lint_attr_name - ), - ); - } - } - } - - err.code(DiagnosticId::Lint(name)); - - if let Some(future_incompatible) = future_incompatible { - const STANDARD_MESSAGE: &str = "this was previously accepted by the compiler but is being phased out; \ - it will become a hard error"; - - let explanation = if lint_id == LintId::of(builtin::UNSTABLE_NAME_COLLISIONS) { - "once this method is added to the standard library, \ - the ambiguity may cause an error or change in behavior!" - .to_owned() - } else if lint_id == LintId::of(builtin::MUTABLE_BORROW_RESERVATION_CONFLICT) { - "this borrowing pattern was not meant to be accepted, \ - and may become a hard error in the future" - .to_owned() - } else if let Some(edition) = future_incompatible.edition { - format!("{} in the {} edition!", STANDARD_MESSAGE, edition) - } else { - format!("{} in a future release!", STANDARD_MESSAGE) - }; - let citation = format!("for more information, see {}", future_incompatible.reference); - err.warn(&explanation); - err.note(&citation); - } - - return err; -} - -pub fn maybe_lint_level_root(tcx: TyCtxt<'_>, id: hir::HirId) -> bool { - let attrs = tcx.hir().attrs(id); - attrs.iter().any(|attr| Level::from_symbol(attr.name_or_empty()).is_some()) -} - -/// Returns whether `span` originates in a foreign crate's external macro. -/// -/// This is used to test whether a lint should not even begin to figure out whether it should -/// be reported on the current node. -pub fn in_external_macro(sess: &Session, span: Span) -> bool { - let expn_data = span.ctxt().outer_expn_data(); - match expn_data.kind { - ExpnKind::Root | ExpnKind::Desugaring(DesugaringKind::ForLoop) => false, - ExpnKind::AstPass(_) | ExpnKind::Desugaring(_) => true, // well, it's "external" - ExpnKind::Macro(MacroKind::Bang, _) => { - if expn_data.def_site.is_dummy() { - // Dummy span for the `def_site` means it's an external macro. - return true; - } - match sess.source_map().span_to_snippet(expn_data.def_site) { - Ok(code) => !code.starts_with("macro_rules"), - // No snippet means external macro or compiler-builtin expansion. - Err(_) => true, - } - } - ExpnKind::Macro(..) => true, // definitely a plugin - } -} - -/// Returns `true` if `span` originates in a derive-macro's expansion. -pub fn in_derive_expansion(span: Span) -> bool { - if let ExpnKind::Macro(MacroKind::Derive, _) = span.ctxt().outer_expn_data().kind { - return true; - } - false -} diff --git a/src/librustc_lint/redundant_semicolon.rs b/src/librustc_lint/redundant_semicolon.rs index dc18f15fe40cb..21b244ad75d4e 100644 --- a/src/librustc_lint/redundant_semicolon.rs +++ b/src/librustc_lint/redundant_semicolon.rs @@ -1,4 +1,4 @@ -use rustc::lint::{EarlyContext, EarlyLintPass, LintContext}; +use crate::{EarlyContext, EarlyLintPass, LintContext}; use rustc_errors::Applicability; use syntax::ast::{ExprKind, Stmt, StmtKind}; diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index ab6841c0c09bc..674a82b61961c 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -1,6 +1,6 @@ #![allow(non_snake_case)] -use rustc::lint::{LateContext, LateLintPass, LintContext}; +use crate::{LateContext, LateLintPass, LintContext}; use rustc::mir::interpret::{sign_extend, truncate}; use rustc::ty::layout::{self, IntegerExt, LayoutOf, SizeSkeleton, VariantIdx}; use rustc::ty::subst::SubstsRef; diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index da8a23f041e58..26cbda3d97895 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -1,5 +1,4 @@ -use rustc::lint::builtin::UNUSED_ATTRIBUTES; -use rustc::lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext}; +use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext}; use rustc::ty::adjustment; use rustc::ty::{self, Ty}; use rustc_data_structures::fx::FxHashMap; @@ -8,6 +7,7 @@ use rustc_feature::{AttributeType, BuiltinAttribute, BUILTIN_ATTRIBUTE_MAP}; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::DefId; +use rustc_session::lint::builtin::UNUSED_ATTRIBUTES; use rustc_span::symbol::Symbol; use rustc_span::symbol::{kw, sym}; use rustc_span::{BytePos, Span}; diff --git a/src/librustc_mir/borrow_check/nll.rs b/src/librustc_mir/borrow_check/nll.rs index 151a2c4c19a7d..73718d58346f1 100644 --- a/src/librustc_mir/borrow_check/nll.rs +++ b/src/librustc_mir/borrow_check/nll.rs @@ -360,7 +360,7 @@ pub(super) fn dump_annotation<'a, 'tcx>( // better. if let Some(closure_region_requirements) = closure_region_requirements { - let mut err = tcx.sess.diagnostic().span_note_diag(body.span, "External requirements"); + let mut err = tcx.sess.diagnostic().span_note_diag(body.span, "external requirements"); regioncx.annotate(tcx, &mut err); @@ -379,7 +379,7 @@ pub(super) fn dump_annotation<'a, 'tcx>( err.buffer(errors_buffer); } else { - let mut err = tcx.sess.diagnostic().span_note_diag(body.span, "No external requirements"); + let mut err = tcx.sess.diagnostic().span_note_diag(body.span, "no external requirements"); regioncx.annotate(tcx, &mut err); err.buffer(errors_buffer); diff --git a/src/librustc_mir/transform/check_unsafety.rs b/src/librustc_mir/transform/check_unsafety.rs index 934b262c2f9cb..072cdf2ebba3a 100644 --- a/src/librustc_mir/transform/check_unsafety.rs +++ b/src/librustc_mir/transform/check_unsafety.rs @@ -637,17 +637,17 @@ pub fn check_unsafety(tcx: TyCtxt<'_>, def_id: DefId) { if let Some(impl_def_id) = builtin_derive_def_id(tcx, def_id) { tcx.unsafe_derive_on_repr_packed(impl_def_id); } else { - tcx.lint_node_note( + tcx.struct_span_lint_hir( SAFE_PACKED_BORROWS, lint_hir_id, source_info.span, &format!( - "{} is unsafe and requires unsafe function or block \ - (error E0133)", + "{} is unsafe and requires unsafe function or block (error E0133)", description ), - &details.as_str(), - ); + ) + .note(&details.as_str()) + .emit(); } } } diff --git a/src/librustc_parse/parser/attr.rs b/src/librustc_parse/parser/attr.rs index 81f31b2eda1d4..3d40b91a7bdc8 100644 --- a/src/librustc_parse/parser/attr.rs +++ b/src/librustc_parse/parser/attr.rs @@ -236,8 +236,8 @@ impl<'a> Parser<'a> { self.struct_span_err(lit.span, msg) .help( "instead of using a suffixed literal \ - (1u8, 1.0f32, etc.), use an unsuffixed version \ - (1, 1.0, etc.).", + (`1u8`, `1.0f32`, etc.), use an unsuffixed version \ + (`1`, `1.0`, etc.)", ) .emit() } diff --git a/src/librustc_parse/parser/diagnostics.rs b/src/librustc_parse/parser/diagnostics.rs index a5056c1665e30..6a18c63017ed6 100644 --- a/src/librustc_parse/parser/diagnostics.rs +++ b/src/librustc_parse/parser/diagnostics.rs @@ -4,6 +4,7 @@ use rustc_data_structures::fx::FxHashSet; use rustc_error_codes::*; use rustc_errors::{pluralize, struct_span_err}; use rustc_errors::{Applicability, DiagnosticBuilder, Handler, PResult}; +use rustc_span::source_map::Spanned; use rustc_span::symbol::kw; use rustc_span::{MultiSpan, Span, SpanSnippetError, DUMMY_SP}; use syntax::ast::{ @@ -491,6 +492,58 @@ impl<'a> Parser<'a> { } } + /// Check to see if a pair of chained operators looks like an attempt at chained comparison, + /// e.g. `1 < x <= 3`. If so, suggest either splitting the comparison into two, or + /// parenthesising the leftmost comparison. + fn attempt_chained_comparison_suggestion( + &mut self, + err: &mut DiagnosticBuilder<'_>, + inner_op: &Expr, + outer_op: &Spanned, + ) { + if let ExprKind::Binary(op, ref l1, ref r1) = inner_op.kind { + match (op.node, &outer_op.node) { + // `x < y < z` and friends. + (BinOpKind::Lt, AssocOp::Less) | (BinOpKind::Lt, AssocOp::LessEqual) | + (BinOpKind::Le, AssocOp::LessEqual) | (BinOpKind::Le, AssocOp::Less) | + // `x > y > z` and friends. + (BinOpKind::Gt, AssocOp::Greater) | (BinOpKind::Gt, AssocOp::GreaterEqual) | + (BinOpKind::Ge, AssocOp::GreaterEqual) | (BinOpKind::Ge, AssocOp::Greater) => { + let expr_to_str = |e: &Expr| { + self.span_to_snippet(e.span) + .unwrap_or_else(|_| pprust::expr_to_string(&e)) + }; + err.span_suggestion( + inner_op.span.to(outer_op.span), + "split the comparison into two...", + format!( + "{} {} {} && {} {}", + expr_to_str(&l1), + op.node.to_string(), + expr_to_str(&r1), + expr_to_str(&r1), + outer_op.node.to_ast_binop().unwrap().to_string(), + ), + Applicability::MaybeIncorrect, + ); + err.span_suggestion( + inner_op.span.to(outer_op.span), + "...or parenthesize one of the comparisons", + format!( + "({} {} {}) {}", + expr_to_str(&l1), + op.node.to_string(), + expr_to_str(&r1), + outer_op.node.to_ast_binop().unwrap().to_string(), + ), + Applicability::MaybeIncorrect, + ); + } + _ => {} + } + } + } + /// Produces an error if comparison operators are chained (RFC #558). /// We only need to check the LHS, not the RHS, because all comparison ops have same /// precedence (see `fn precedence`) and are left-associative (see `fn fixity`). @@ -506,27 +559,31 @@ impl<'a> Parser<'a> { /// / \ /// inner_op r2 /// / \ - /// l1 r1 + /// l1 r1 pub(super) fn check_no_chained_comparison( &mut self, - lhs: &Expr, - outer_op: &AssocOp, + inner_op: &Expr, + outer_op: &Spanned, ) -> PResult<'a, Option>> { debug_assert!( - outer_op.is_comparison(), + outer_op.node.is_comparison(), "check_no_chained_comparison: {:?} is not comparison", - outer_op, + outer_op.node, ); let mk_err_expr = |this: &Self, span| Ok(Some(this.mk_expr(span, ExprKind::Err, AttrVec::new()))); - match lhs.kind { + match inner_op.kind { ExprKind::Binary(op, _, _) if op.node.is_comparison() => { // Respan to include both operators. let op_span = op.span.to(self.prev_span); - let mut err = self - .struct_span_err(op_span, "chained comparison operators require parentheses"); + let mut err = + self.struct_span_err(op_span, "comparison operators cannot be chained"); + + // If it looks like a genuine attempt to chain operators (as opposed to a + // misformatted turbofish, for instance), suggest a correct form. + self.attempt_chained_comparison_suggestion(&mut err, inner_op, outer_op); let suggest = |err: &mut DiagnosticBuilder<'_>| { err.span_suggestion_verbose( @@ -538,12 +595,12 @@ impl<'a> Parser<'a> { }; if op.node == BinOpKind::Lt && - *outer_op == AssocOp::Less || // Include `<` to provide this recommendation - *outer_op == AssocOp::Greater + outer_op.node == AssocOp::Less || // Include `<` to provide this recommendation + outer_op.node == AssocOp::Greater // even in a case like the following: { // Foo>> - if *outer_op == AssocOp::Less { + if outer_op.node == AssocOp::Less { let snapshot = self.clone(); self.bump(); // So far we have parsed `foo Parser<'a> { // FIXME: actually check that the two expressions in the binop are // paths and resynthesize new fn call expression instead of using // `ExprKind::Err` placeholder. - mk_err_expr(self, lhs.span.to(self.prev_span)) + mk_err_expr(self, inner_op.span.to(self.prev_span)) } Err(mut expr_err) => { expr_err.cancel(); @@ -597,7 +654,7 @@ impl<'a> Parser<'a> { // FIXME: actually check that the two expressions in the binop are // paths and resynthesize new fn call expression instead of using // `ExprKind::Err` placeholder. - mk_err_expr(self, lhs.span.to(self.prev_span)) + mk_err_expr(self, inner_op.span.to(self.prev_span)) } } } else { diff --git a/src/librustc_parse/parser/expr.rs b/src/librustc_parse/parser/expr.rs index dd2b6ab997196..098c8355ab944 100644 --- a/src/librustc_parse/parser/expr.rs +++ b/src/librustc_parse/parser/expr.rs @@ -4,7 +4,7 @@ use super::{SemiColonMode, SeqSep, TokenExpectType}; use crate::maybe_recover_from_interpolated_ty_qpath; use rustc_errors::{Applicability, PResult}; -use rustc_span::source_map::{self, Span}; +use rustc_span::source_map::{self, Span, Spanned}; use rustc_span::symbol::{kw, sym, Symbol}; use std::mem; use syntax::ast::{self, AttrStyle, AttrVec, CaptureBy, Field, Ident, Lit, DUMMY_NODE_ID}; @@ -180,17 +180,17 @@ impl<'a> Parser<'a> { }; let cur_op_span = self.token.span; - let restrictions = if op.is_assign_like() { + let restrictions = if op.node.is_assign_like() { self.restrictions & Restrictions::NO_STRUCT_LITERAL } else { self.restrictions }; - let prec = op.precedence(); + let prec = op.node.precedence(); if prec < min_prec { break; } // Check for deprecated `...` syntax - if self.token == token::DotDotDot && op == AssocOp::DotDotEq { + if self.token == token::DotDotDot && op.node == AssocOp::DotDotEq { self.err_dotdotdot_syntax(self.token.span); } @@ -199,11 +199,12 @@ impl<'a> Parser<'a> { } self.bump(); - if op.is_comparison() { + if op.node.is_comparison() { if let Some(expr) = self.check_no_chained_comparison(&lhs, &op)? { return Ok(expr); } } + let op = op.node; // Special cases: if op == AssocOp::As { lhs = self.parse_assoc_op_cast(lhs, lhs_span, ExprKind::Cast)?; @@ -297,7 +298,7 @@ impl<'a> Parser<'a> { } fn should_continue_as_assoc_expr(&mut self, lhs: &Expr) -> bool { - match (self.expr_is_complete(lhs), self.check_assoc_op()) { + match (self.expr_is_complete(lhs), self.check_assoc_op().map(|op| op.node)) { // Semi-statement forms are odd: // See https://github.com/rust-lang/rust/issues/29071 (true, None) => false, @@ -342,19 +343,22 @@ impl<'a> Parser<'a> { /// The method does not advance the current token. /// /// Also performs recovery for `and` / `or` which are mistaken for `&&` and `||` respectively. - fn check_assoc_op(&self) -> Option { - match (AssocOp::from_token(&self.token), &self.token.kind) { - (op @ Some(_), _) => op, - (None, token::Ident(sym::and, false)) => { - self.error_bad_logical_op("and", "&&", "conjunction"); - Some(AssocOp::LAnd) - } - (None, token::Ident(sym::or, false)) => { - self.error_bad_logical_op("or", "||", "disjunction"); - Some(AssocOp::LOr) - } - _ => None, - } + fn check_assoc_op(&self) -> Option> { + Some(Spanned { + node: match (AssocOp::from_token(&self.token), &self.token.kind) { + (Some(op), _) => op, + (None, token::Ident(sym::and, false)) => { + self.error_bad_logical_op("and", "&&", "conjunction"); + AssocOp::LAnd + } + (None, token::Ident(sym::or, false)) => { + self.error_bad_logical_op("or", "||", "disjunction"); + AssocOp::LOr + } + _ => return None, + }, + span: self.token.span, + }) } /// Error on `and` and `or` suggesting `&&` and `||` respectively. diff --git a/src/librustc_parse/parser/pat.rs b/src/librustc_parse/parser/pat.rs index 0c2cfc20daf0f..549acf67d3824 100644 --- a/src/librustc_parse/parser/pat.rs +++ b/src/librustc_parse/parser/pat.rs @@ -209,13 +209,13 @@ impl<'a> Parser<'a> { if let Ok(seq_snippet) = self.span_to_snippet(seq_span) { err.span_suggestion( seq_span, - "try adding parentheses to match on a tuple..", + "try adding parentheses to match on a tuple...", format!("({})", seq_snippet), Applicability::MachineApplicable, ) .span_suggestion( seq_span, - "..or a vertical bar to match on multiple alternatives", + "...or a vertical bar to match on multiple alternatives", format!("{}", seq_snippet.replace(",", " |")), Applicability::MachineApplicable, ); diff --git a/src/librustc_passes/dead.rs b/src/librustc_passes/dead.rs index f626a5f8cb0d1..f2778b2aa6bcd 100644 --- a/src/librustc_passes/dead.rs +++ b/src/librustc_passes/dead.rs @@ -3,7 +3,6 @@ // from live codes are live, and everything else is dead. use rustc::hir::map::Map; -use rustc::lint; use rustc::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc::middle::privacy; use rustc::ty::{self, DefIdTree, TyCtxt}; @@ -14,6 +13,7 @@ use rustc_hir::def_id::{DefId, LOCAL_CRATE}; use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_hir::itemlikevisit::ItemLikeVisitor; use rustc_hir::{Node, PatKind, TyKind}; +use rustc_session::lint; use rustc_span; use rustc_span::symbol::sym; diff --git a/src/librustc_passes/diagnostic_items.rs b/src/librustc_passes/diagnostic_items.rs index c083830b730cc..8d220a3f695f2 100644 --- a/src/librustc_passes/diagnostic_items.rs +++ b/src/librustc_passes/diagnostic_items.rs @@ -73,7 +73,7 @@ fn collect_item( )), }; if let Some(span) = tcx.hir().span_if_local(original_def_id) { - err.span_note(span, "first defined here."); + err.span_note(span, "first defined here"); } else { err.note(&format!( "first defined in crate `{}`.", diff --git a/src/librustc_passes/liveness.rs b/src/librustc_passes/liveness.rs index 0426f3fbea236..7718139f6e924 100644 --- a/src/librustc_passes/liveness.rs +++ b/src/librustc_passes/liveness.rs @@ -1513,13 +1513,16 @@ impl<'tcx> Liveness<'_, 'tcx> { if ln == self.s.exit_ln { false } else { self.assigned_on_exit(ln, var).is_some() }; if is_assigned { - self.ir.tcx.lint_hir_note( - lint::builtin::UNUSED_VARIABLES, - hir_id, - spans, - &format!("variable `{}` is assigned to, but never used", name), - &format!("consider using `_{}` instead", name), - ); + self.ir + .tcx + .struct_span_lint_hir( + lint::builtin::UNUSED_VARIABLES, + hir_id, + spans, + &format!("variable `{}` is assigned to, but never used", name), + ) + .note(&format!("consider using `_{}` instead", name)) + .emit(); } else { let mut err = self.ir.tcx.struct_span_lint_hir( lint::builtin::UNUSED_VARIABLES, diff --git a/src/librustc_plugin_impl/Cargo.toml b/src/librustc_plugin_impl/Cargo.toml index d0b7accafd68b..41e6c699c340e 100644 --- a/src/librustc_plugin_impl/Cargo.toml +++ b/src/librustc_plugin_impl/Cargo.toml @@ -14,6 +14,7 @@ doctest = false rustc = { path = "../librustc" } rustc_errors = { path = "../librustc_errors" } rustc_hir = { path = "../librustc_hir" } +rustc_lint = { path = "../librustc_lint" } rustc_metadata = { path = "../librustc_metadata" } syntax = { path = "../libsyntax" } rustc_span = { path = "../librustc_span" } diff --git a/src/librustc_plugin_impl/lib.rs b/src/librustc_plugin_impl/lib.rs index 682d223f565de..10712eb60b9e3 100644 --- a/src/librustc_plugin_impl/lib.rs +++ b/src/librustc_plugin_impl/lib.rs @@ -9,7 +9,7 @@ #![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] #![feature(nll)] -use rustc::lint::LintStore; +use rustc_lint::LintStore; pub mod build; pub mod load; diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index 291386413d647..e8ed64a18702d 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -963,7 +963,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { .session .struct_span_err( attr.span, - "`macro_use` is not supported on `extern crate self`", + "`#[macro_use]` is not supported on `extern crate self`", ) .emit(); } @@ -1054,10 +1054,10 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { fn contains_macro_use(&mut self, attrs: &[ast::Attribute]) -> bool { for attr in attrs { if attr.check_name(sym::macro_escape) { - let msg = "macro_escape is a deprecated synonym for macro_use"; + let msg = "`#[macro_escape]` is a deprecated synonym for `#[macro_use]`"; let mut err = self.r.session.struct_span_warn(attr.span, msg); if let ast::AttrStyle::Inner = attr.style { - err.help("consider an outer attribute, `#[macro_use]` mod ...").emit(); + err.help("try an outer attribute: `#[macro_use]`").emit(); } else { err.emit(); } @@ -1066,7 +1066,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { } if !attr.is_word() { - self.r.session.span_err(attr.span, "arguments to macro_use are not allowed here"); + self.r.session.span_err(attr.span, "arguments to `macro_use` are not allowed here"); } return true; } diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 8e4630cf7d696..8d5afb194a175 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -2006,7 +2006,7 @@ impl<'a> Resolver<'a> { continue; } } - let msg = "there are too many initial `super`s.".to_string(); + let msg = "there are too many leading `super` keywords".to_string(); return PathResult::Failed { span: ident.span, label: msg, diff --git a/src/librustc_span/lib.rs b/src/librustc_span/lib.rs index 1dc7fc5aa3ad1..5779d17e3e51e 100644 --- a/src/librustc_span/lib.rs +++ b/src/librustc_span/lib.rs @@ -308,6 +308,11 @@ impl Span { self.ctxt() != SyntaxContext::root() } + /// Returns `true` if `span` originates in a derive-macro's expansion. + pub fn in_derive_expansion(self) -> bool { + matches!(self.ctxt().outer_expn_data().kind, ExpnKind::Macro(MacroKind::Derive, _)) + } + #[inline] pub fn with_root_ctxt(lo: BytePos, hi: BytePos) -> Span { Span::new(lo, hi, SyntaxContext::root()) diff --git a/src/librustc_typeck/check/cast.rs b/src/librustc_typeck/check/cast.rs index ba5e5fd8ac188..cbbfe2d627895 100644 --- a/src/librustc_typeck/check/cast.rs +++ b/src/librustc_typeck/check/cast.rs @@ -381,7 +381,7 @@ impl<'a, 'tcx> CastCheck<'tcx> { if unknown_cast_to { "to" } else { "from" } ); err.note( - "The type information given here is insufficient to check whether \ + "the type information given here is insufficient to check whether \ the pointer cast is valid", ); if unknown_cast_to { diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index b84e1d37b06ff..d6c0d9c77b495 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -479,7 +479,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { macro_rules! report_function { ($span:expr, $name:expr) => { err.note(&format!( - "{} is a function, perhaps you wish to call it", + "`{}` is a function, perhaps you wish to call it", $name )); }; diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 92a7e18a8600f..baf9ae1ac2911 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -1664,7 +1664,7 @@ fn check_opaque_for_cycles<'tcx>( if let hir::OpaqueTyOrigin::AsyncFn = origin { struct_span_err!(tcx.sess, span, E0733, "recursion in an `async fn` requires boxing",) .span_label(span, "recursive `async fn`") - .note("a recursive `async fn` must be rewritten to return a boxed `dyn Future`.") + .note("a recursive `async fn` must be rewritten to return a boxed `dyn Future`") .emit(); } else { let mut err = diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 3cda1b3be75f1..61a7bc765bcf2 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -1,4 +1,3 @@ -use rustc::lint; use rustc::middle::cstore::CrateStore; use rustc::middle::privacy::AccessLevels; use rustc::session::config::ErrorOutputType; @@ -14,6 +13,7 @@ use rustc_hir::HirId; use rustc_interface::interface; use rustc_lint; use rustc_resolve as resolve; +use rustc_session::lint; use rustc_errors::emitter::{Emitter, EmitterWriter}; use rustc_errors::json::JsonEmitter; diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 0fcbd4e0b58c6..894cfefafaf0c 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -35,6 +35,7 @@ extern crate rustc_metadata; extern crate rustc_mir; extern crate rustc_parse; extern crate rustc_resolve; +extern crate rustc_session; extern crate rustc_span as rustc_span; extern crate rustc_target; extern crate rustc_typeck; diff --git a/src/libstd/panicking.rs b/src/libstd/panicking.rs index 599ccc809be1f..bf6fd78182350 100644 --- a/src/libstd/panicking.rs +++ b/src/libstd/panicking.rs @@ -12,9 +12,8 @@ use core::panic::{BoxMeUp, Location, PanicInfo}; use crate::any::Any; use crate::fmt; use crate::intrinsics; -use crate::mem::{self, ManuallyDrop}; +use crate::mem::{self, ManuallyDrop, MaybeUninit}; use crate::process; -use crate::raw; use crate::sync::atomic::{AtomicBool, Ordering}; use crate::sys::stdio::panic_output; use crate::sys_common::backtrace::{self, RustBacktrace}; @@ -29,6 +28,9 @@ use crate::io::set_panic; #[cfg(test)] use realstd::io::set_panic; +// Include the definition of UnwindPayload from libpanic_unwind. +include!("../libpanic_unwind/payload.rs"); + // Binary interface to the panic runtime that the standard library depends on. // // The standard library is tagged with `#![needs_panic_runtime]` (introduced in @@ -41,12 +43,9 @@ use realstd::io::set_panic; // hook up these functions, but it is not this day! #[allow(improper_ctypes)] extern "C" { - fn __rust_maybe_catch_panic( - f: fn(*mut u8), - data: *mut u8, - data_ptr: *mut usize, - vtable_ptr: *mut usize, - ) -> u32; + /// The payload ptr here is actually the same as the payload ptr for the try + /// intrinsic (i.e., is really `*mut [u64; 2]` or `*mut *mut u8`). + fn __rust_panic_cleanup(payload: TryPayload) -> *mut (dyn Any + Send + 'static); /// `payload` is actually a `*mut &mut dyn BoxMeUp` but that would cause FFI warnings. /// It cannot be `Box` because the other end of this call does not depend @@ -199,7 +198,7 @@ fn default_hook(info: &PanicInfo<'_>) { let _ = writeln!( err, "note: run with `RUST_BACKTRACE=1` \ - environment variable to display a backtrace." + environment variable to display a backtrace" ); } } @@ -241,9 +240,9 @@ pub unsafe fn r#try R>(f: F) -> Result> } // We do some sketchy operations with ownership here for the sake of - // performance. We can only pass pointers down to - // `__rust_maybe_catch_panic` (can't pass objects by value), so we do all - // the ownership tracking here manually using a union. + // performance. We can only pass pointers down to `do_call` (can't pass + // objects by value), so we do all the ownership tracking here manually + // using a union. // // We go through a transition where: // @@ -254,7 +253,7 @@ pub unsafe fn r#try R>(f: F) -> Result> // * If the closure successfully returns, we write the return value into the // data's return slot. Note that `ptr::write` is used as it's overwriting // uninitialized data. - // * Finally, when we come back out of the `__rust_maybe_catch_panic` we're + // * Finally, when we come back out of the `try` intrinsic we're // in one of two states: // // 1. The closure didn't panic, in which case the return value was @@ -265,28 +264,30 @@ pub unsafe fn r#try R>(f: F) -> Result> // // Once we stack all that together we should have the "most efficient' // method of calling a catch panic whilst juggling ownership. - let mut any_data = 0; - let mut any_vtable = 0; let mut data = Data { f: ManuallyDrop::new(f) }; - let r = __rust_maybe_catch_panic( - do_call::, - &mut data as *mut _ as *mut u8, - &mut any_data, - &mut any_vtable, - ); + let mut payload: MaybeUninit = MaybeUninit::uninit(); - return if r == 0 { + let data_ptr = &mut data as *mut _ as *mut u8; + let payload_ptr = payload.as_mut_ptr() as *mut _; + return if intrinsics::r#try(do_call::, data_ptr, payload_ptr) == 0 { debug_assert!(update_panic_count(0) == 0); Ok(ManuallyDrop::into_inner(data.r)) } else { + Err(cleanup(payload.assume_init())) + }; + + // We consider unwinding to be rare, so mark this function as cold. However, + // do not mark it no-inline -- that decision is best to leave to the + // optimizer (in most cases this function is not inlined even as a normal, + // non-cold function, though, as of the writing of this comment). + #[cold] + unsafe fn cleanup(payload: TryPayload) -> Box { + let obj = Box::from_raw(__rust_panic_cleanup(payload)); update_panic_count(-1); debug_assert!(update_panic_count(0) == 0); - Err(mem::transmute(raw::TraitObject { - data: any_data as *mut _, - vtable: any_vtable as *mut _, - })) - }; + obj + } fn do_call R, R>(data: *mut u8) { unsafe { diff --git a/src/test/codegen/catch-unwind.rs b/src/test/codegen/catch-unwind.rs new file mode 100644 index 0000000000000..3c9bc35d1c8bd --- /dev/null +++ b/src/test/codegen/catch-unwind.rs @@ -0,0 +1,19 @@ +// compile-flags: -O + +#![crate_type = "lib"] + +extern "C" { + fn bar(); +} + +// CHECK-LABEL: @foo +#[no_mangle] +pub unsafe fn foo() -> i32 { + // CHECK: call void @bar + // CHECK: ret i32 0 + std::panic::catch_unwind(|| { + bar(); + 0 + }) + .unwrap() +} diff --git a/src/test/codegen/try-panic-abort.rs b/src/test/codegen/try-panic-abort.rs new file mode 100644 index 0000000000000..9bc89a321576c --- /dev/null +++ b/src/test/codegen/try-panic-abort.rs @@ -0,0 +1,17 @@ +// compile-flags: -C panic=abort -O + +#![crate_type = "lib"] +#![feature(unwind_attributes, core_intrinsics)] + +extern "C" { + #[unwind(allow)] + fn bar(data: *mut u8); +} + +// CHECK-LABEL: @foo +#[no_mangle] +pub unsafe fn foo() -> i32 { + // CHECK: call void @bar + // CHECK: ret i32 0 + std::intrinsics::r#try(|x| bar(x), 0 as *mut u8, 0 as *mut u8) +} diff --git a/src/test/compile-fail/panic-handler-twice.rs b/src/test/compile-fail/panic-handler-twice.rs index c0f2c51397ed9..0c5359b9bd8c6 100644 --- a/src/test/compile-fail/panic-handler-twice.rs +++ b/src/test/compile-fail/panic-handler-twice.rs @@ -10,7 +10,7 @@ use core::panic::PanicInfo; #[panic_handler] fn panic(info: &PanicInfo) -> ! { - //~^ error duplicate lang item found: `panic_impl` + //~^ ERROR found duplicate lang item `panic_impl` loop {} } diff --git a/src/test/run-make-fulldeps/libtest-json/output-default.json b/src/test/run-make-fulldeps/libtest-json/output-default.json index 8046d72221703..0cd9ab79e32f3 100644 --- a/src/test/run-make-fulldeps/libtest-json/output-default.json +++ b/src/test/run-make-fulldeps/libtest-json/output-default.json @@ -2,7 +2,7 @@ { "type": "test", "event": "started", "name": "a" } { "type": "test", "name": "a", "event": "ok" } { "type": "test", "event": "started", "name": "b" } -{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'main' panicked at 'assertion failed: false', f.rs:9:5\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.\n" } +{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'main' panicked at 'assertion failed: false', f.rs:9:5\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n" } { "type": "test", "event": "started", "name": "c" } { "type": "test", "name": "c", "event": "ok" } { "type": "test", "event": "started", "name": "d" } diff --git a/src/test/run-make-fulldeps/libtest-json/output-stdout-success.json b/src/test/run-make-fulldeps/libtest-json/output-stdout-success.json index 303316278d8ab..dfaf005052e55 100644 --- a/src/test/run-make-fulldeps/libtest-json/output-stdout-success.json +++ b/src/test/run-make-fulldeps/libtest-json/output-stdout-success.json @@ -2,7 +2,7 @@ { "type": "test", "event": "started", "name": "a" } { "type": "test", "name": "a", "event": "ok", "stdout": "print from successful test\n" } { "type": "test", "event": "started", "name": "b" } -{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'main' panicked at 'assertion failed: false', f.rs:9:5\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.\n" } +{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'main' panicked at 'assertion failed: false', f.rs:9:5\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n" } { "type": "test", "event": "started", "name": "c" } { "type": "test", "name": "c", "event": "ok", "stdout": "thread 'main' panicked at 'assertion failed: false', f.rs:15:5\n" } { "type": "test", "event": "started", "name": "d" } diff --git a/src/test/rustdoc-ui/failed-doctest-output.stdout b/src/test/rustdoc-ui/failed-doctest-output.stdout index 9887d07a3eb6e..ee79ae1a690ec 100644 --- a/src/test/rustdoc-ui/failed-doctest-output.stdout +++ b/src/test/rustdoc-ui/failed-doctest-output.stdout @@ -27,7 +27,7 @@ stderr: stderr 1 stderr 2 thread 'main' panicked at 'oh no', $DIR/failed-doctest-output.rs:7:1 -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/src/test/ui-fulldeps/auxiliary/issue-40001-plugin.rs b/src/test/ui-fulldeps/auxiliary/issue-40001-plugin.rs index abb2e93757ed3..725c350fe4e22 100644 --- a/src/test/ui-fulldeps/auxiliary/issue-40001-plugin.rs +++ b/src/test/ui-fulldeps/auxiliary/issue-40001-plugin.rs @@ -1,17 +1,17 @@ #![feature(box_syntax, plugin, plugin_registrar, rustc_private)] #![crate_type = "dylib"] -#[macro_use] extern crate rustc; -#[macro_use] extern crate rustc_session; extern crate rustc_driver; extern crate rustc_hir; +#[macro_use] extern crate rustc_lint; +#[macro_use] extern crate rustc_session; extern crate rustc_span; extern crate syntax; use rustc_hir::intravisit; use rustc_hir as hir; use rustc_hir::Node; -use rustc::lint::{LateContext, LintPass, LintArray, LateLintPass, LintContext}; +use rustc_lint::{LateContext, LintPass, LintArray, LateLintPass, LintContext}; use rustc_driver::plugin::Registry; use rustc_span::source_map; use syntax::print::pprust; diff --git a/src/test/ui-fulldeps/auxiliary/lint-for-crate-rpass.rs b/src/test/ui-fulldeps/auxiliary/lint-for-crate-rpass.rs index 4ccbe8a3c0eb0..98963a180c850 100644 --- a/src/test/ui-fulldeps/auxiliary/lint-for-crate-rpass.rs +++ b/src/test/ui-fulldeps/auxiliary/lint-for-crate-rpass.rs @@ -2,14 +2,14 @@ #![feature(plugin_registrar, rustc_private)] #![feature(box_syntax)] -#[macro_use] extern crate rustc; -#[macro_use] extern crate rustc_session; extern crate rustc_driver; extern crate rustc_hir; extern crate rustc_span; +#[macro_use] extern crate rustc_lint; +#[macro_use] extern crate rustc_session; extern crate syntax; -use rustc::lint::{LateContext, LintContext, LintPass, LateLintPass}; +use rustc_lint::{LateContext, LintContext, LintPass, LateLintPass}; use rustc_driver::plugin::Registry; use rustc_span::symbol::Symbol; use syntax::attr; diff --git a/src/test/ui-fulldeps/auxiliary/lint-for-crate.rs b/src/test/ui-fulldeps/auxiliary/lint-for-crate.rs index 360bffaa46f2b..589477da62527 100644 --- a/src/test/ui-fulldeps/auxiliary/lint-for-crate.rs +++ b/src/test/ui-fulldeps/auxiliary/lint-for-crate.rs @@ -3,14 +3,14 @@ #![feature(plugin_registrar, rustc_private)] #![feature(box_syntax)] -#[macro_use] extern crate rustc; -#[macro_use] extern crate rustc_session; extern crate rustc_driver; extern crate rustc_hir; +#[macro_use] extern crate rustc_lint; +#[macro_use] extern crate rustc_session; extern crate rustc_span; extern crate syntax; -use rustc::lint::{LateContext, LintContext, LintPass, LateLintPass, LintArray}; +use rustc_lint::{LateContext, LintContext, LintPass, LateLintPass, LintArray}; use rustc_driver::plugin::Registry; use rustc_span::symbol::Symbol; use syntax::attr; diff --git a/src/test/ui-fulldeps/auxiliary/lint-group-plugin-test.rs b/src/test/ui-fulldeps/auxiliary/lint-group-plugin-test.rs index 786c699947e47..2cc288c21e697 100644 --- a/src/test/ui-fulldeps/auxiliary/lint-group-plugin-test.rs +++ b/src/test/ui-fulldeps/auxiliary/lint-group-plugin-test.rs @@ -4,12 +4,12 @@ #![feature(box_syntax, rustc_private)] // Load rustc as a plugin to get macros. -#[macro_use] extern crate rustc; -#[macro_use] extern crate rustc_session; extern crate rustc_driver; extern crate rustc_hir; +#[macro_use] extern crate rustc_lint; +#[macro_use] extern crate rustc_session; -use rustc::lint::{LateContext, LintContext, LintPass, LateLintPass, LintArray, LintId}; +use rustc_lint::{LateContext, LintContext, LintPass, LateLintPass, LintArray, LintId}; use rustc_driver::plugin::Registry; declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'"); diff --git a/src/test/ui-fulldeps/auxiliary/lint-plugin-test.rs b/src/test/ui-fulldeps/auxiliary/lint-plugin-test.rs index bb96dba21fc2e..c704701cc480b 100644 --- a/src/test/ui-fulldeps/auxiliary/lint-plugin-test.rs +++ b/src/test/ui-fulldeps/auxiliary/lint-plugin-test.rs @@ -6,11 +6,11 @@ extern crate syntax; // Load rustc as a plugin to get macros -#[macro_use] extern crate rustc; -#[macro_use] extern crate rustc_session; extern crate rustc_driver; +#[macro_use] extern crate rustc_lint; +#[macro_use] extern crate rustc_session; -use rustc::lint::{EarlyContext, LintContext, LintPass, EarlyLintPass, LintArray}; +use rustc_lint::{EarlyContext, LintContext, LintPass, EarlyLintPass, LintArray}; use rustc_driver::plugin::Registry; use syntax::ast; declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'"); diff --git a/src/test/ui-fulldeps/auxiliary/lint-tool-test.rs b/src/test/ui-fulldeps/auxiliary/lint-tool-test.rs index 1704909813797..fa545ddc2bc6b 100644 --- a/src/test/ui-fulldeps/auxiliary/lint-tool-test.rs +++ b/src/test/ui-fulldeps/auxiliary/lint-tool-test.rs @@ -4,11 +4,11 @@ extern crate syntax; // Load rustc as a plugin to get macros -#[macro_use] extern crate rustc; -#[macro_use] extern crate rustc_session; extern crate rustc_driver; +#[macro_use] extern crate rustc_lint; +#[macro_use] extern crate rustc_session; -use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass, LintId}; +use rustc_lint::{EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass, LintId}; use rustc_driver::plugin::Registry; use syntax::ast; declare_tool_lint!(pub clippy::TEST_LINT, Warn, "Warn about stuff"); diff --git a/src/test/ui/anon-params-deprecated.stderr b/src/test/ui/anon-params-deprecated.stderr index e97dbc15f9cde..8e4fa70d342f2 100644 --- a/src/test/ui/anon-params-deprecated.stderr +++ b/src/test/ui/anon-params-deprecated.stderr @@ -2,7 +2,7 @@ warning: anonymous parameters are deprecated and will be removed in the next edi --> $DIR/anon-params-deprecated.rs:9:12 | LL | fn foo(i32); - | ^^^ help: Try naming the parameter or explicitly ignoring it: `_: i32` + | ^^^ help: try naming the parameter or explicitly ignoring it: `_: i32` | note: lint level defined here --> $DIR/anon-params-deprecated.rs:1:9 @@ -16,7 +16,7 @@ warning: anonymous parameters are deprecated and will be removed in the next edi --> $DIR/anon-params-deprecated.rs:12:30 | LL | fn bar_with_default_impl(String, String) {} - | ^^^^^^ help: Try naming the parameter or explicitly ignoring it: `_: String` + | ^^^^^^ help: try naming the parameter or explicitly ignoring it: `_: String` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! = note: for more information, see issue #41686 @@ -25,7 +25,7 @@ warning: anonymous parameters are deprecated and will be removed in the next edi --> $DIR/anon-params-deprecated.rs:12:38 | LL | fn bar_with_default_impl(String, String) {} - | ^^^^^^ help: Try naming the parameter or explicitly ignoring it: `_: String` + | ^^^^^^ help: try naming the parameter or explicitly ignoring it: `_: String` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! = note: for more information, see issue #41686 diff --git a/src/test/ui/async-await/mutually-recursive-async-impl-trait-type.stderr b/src/test/ui/async-await/mutually-recursive-async-impl-trait-type.stderr index 9249308936e54..f6e4c8be29260 100644 --- a/src/test/ui/async-await/mutually-recursive-async-impl-trait-type.stderr +++ b/src/test/ui/async-await/mutually-recursive-async-impl-trait-type.stderr @@ -4,7 +4,7 @@ error[E0733]: recursion in an `async fn` requires boxing LL | async fn rec_1() { | ^ recursive `async fn` | - = note: a recursive `async fn` must be rewritten to return a boxed `dyn Future`. + = note: a recursive `async fn` must be rewritten to return a boxed `dyn Future` error[E0733]: recursion in an `async fn` requires boxing --> $DIR/mutually-recursive-async-impl-trait-type.rs:9:18 @@ -12,7 +12,7 @@ error[E0733]: recursion in an `async fn` requires boxing LL | async fn rec_2() { | ^ recursive `async fn` | - = note: a recursive `async fn` must be rewritten to return a boxed `dyn Future`. + = note: a recursive `async fn` must be rewritten to return a boxed `dyn Future` error: aborting due to 2 previous errors diff --git a/src/test/ui/async-await/recursive-async-impl-trait-type.stderr b/src/test/ui/async-await/recursive-async-impl-trait-type.stderr index 9ee014021804e..892d91e3a4992 100644 --- a/src/test/ui/async-await/recursive-async-impl-trait-type.stderr +++ b/src/test/ui/async-await/recursive-async-impl-trait-type.stderr @@ -4,7 +4,7 @@ error[E0733]: recursion in an `async fn` requires boxing LL | async fn recursive_async_function() -> () { | ^^ recursive `async fn` | - = note: a recursive `async fn` must be rewritten to return a boxed `dyn Future`. + = note: a recursive `async fn` must be rewritten to return a boxed `dyn Future` error: aborting due to previous error diff --git a/src/test/ui/consts/const-eval/validate_uninhabited_zsts.stderr b/src/test/ui/consts/const-eval/validate_uninhabited_zsts.stderr index bde7f2536fac1..51e80bb8b118b 100644 --- a/src/test/ui/consts/const-eval/validate_uninhabited_zsts.stderr +++ b/src/test/ui/consts/const-eval/validate_uninhabited_zsts.stderr @@ -34,7 +34,7 @@ LL | unsafe { std::mem::transmute(()) } | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | = note: `#[warn(invalid_value)]` on by default - = note: The never type (`!`) has no valid value + = note: the `!` type has no valid value warning: the type `Empty` does not permit zero-initialization --> $DIR/validate_uninhabited_zsts.rs:17:35 @@ -45,7 +45,7 @@ LL | const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | - = note: 0-variant enums have no valid value + = note: enums with no variants have no valid value error: aborting due to previous error diff --git a/src/test/ui/consts/miri_unleashed/mutable_const2.stderr b/src/test/ui/consts/miri_unleashed/mutable_const2.stderr index 88418e57acdda..655c31763ef44 100644 --- a/src/test/ui/consts/miri_unleashed/mutable_const2.stderr +++ b/src/test/ui/consts/miri_unleashed/mutable_const2.stderr @@ -11,7 +11,7 @@ LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *m | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:346:17 -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace error: internal compiler error: unexpected panic diff --git a/src/test/ui/consts/miri_unleashed/mutable_references_ice.stderr b/src/test/ui/consts/miri_unleashed/mutable_references_ice.stderr index c148842bcbc66..c292fcef7f660 100644 --- a/src/test/ui/consts/miri_unleashed/mutable_references_ice.stderr +++ b/src/test/ui/consts/miri_unleashed/mutable_references_ice.stderr @@ -7,7 +7,7 @@ LL | x: &UnsafeCell::new(42), thread 'rustc' panicked at 'assertion failed: `(left != right)` left: `Const`, right: `Const`: UnsafeCells are not allowed behind references in constants. This should have been prevented statically by const qualification. If this were allowed one would be able to change a constant at one use site and other use sites could observe that mutation.', src/librustc_mir/interpret/intern.rs:LL:CC -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace error: internal compiler error: unexpected panic diff --git a/src/test/ui/deprecation/deprecated-macro_escape-inner.rs b/src/test/ui/deprecation/deprecated-macro_escape-inner.rs index 957e839013ec7..e2957c422f6d5 100644 --- a/src/test/ui/deprecation/deprecated-macro_escape-inner.rs +++ b/src/test/ui/deprecation/deprecated-macro_escape-inner.rs @@ -1,7 +1,7 @@ // run-pass mod foo { - #![macro_escape] //~ WARNING macro_escape is a deprecated synonym for macro_use + #![macro_escape] //~ WARN `#[macro_escape]` is a deprecated synonym for `#[macro_use]` } fn main() { diff --git a/src/test/ui/deprecation/deprecated-macro_escape-inner.stderr b/src/test/ui/deprecation/deprecated-macro_escape-inner.stderr index 1b69270d624f4..4b0fc07463a99 100644 --- a/src/test/ui/deprecation/deprecated-macro_escape-inner.stderr +++ b/src/test/ui/deprecation/deprecated-macro_escape-inner.stderr @@ -1,8 +1,8 @@ -warning: macro_escape is a deprecated synonym for macro_use +warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]` --> $DIR/deprecated-macro_escape-inner.rs:4:5 | LL | #![macro_escape] | ^^^^^^^^^^^^^^^^ | - = help: consider an outer attribute, `#[macro_use]` mod ... + = help: try an outer attribute: `#[macro_use]` diff --git a/src/test/ui/deprecation/deprecated-macro_escape.rs b/src/test/ui/deprecation/deprecated-macro_escape.rs index 1b82a99f42eab..4a89b40625e68 100644 --- a/src/test/ui/deprecation/deprecated-macro_escape.rs +++ b/src/test/ui/deprecation/deprecated-macro_escape.rs @@ -1,8 +1,6 @@ // run-pass -#[macro_escape] //~ WARNING macro_escape is a deprecated synonym for macro_use -mod foo { -} +#[macro_escape] //~ WARNING `#[macro_escape]` is a deprecated synonym for `#[macro_use]` +mod foo {} -fn main() { -} +fn main() {} diff --git a/src/test/ui/deprecation/deprecated-macro_escape.stderr b/src/test/ui/deprecation/deprecated-macro_escape.stderr index b76d6d73d972b..70094083d4b34 100644 --- a/src/test/ui/deprecation/deprecated-macro_escape.stderr +++ b/src/test/ui/deprecation/deprecated-macro_escape.stderr @@ -1,4 +1,4 @@ -warning: macro_escape is a deprecated synonym for macro_use +warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]` --> $DIR/deprecated-macro_escape.rs:3:1 | LL | #[macro_escape] diff --git a/src/test/ui/did_you_mean/issue-40396.rs b/src/test/ui/did_you_mean/issue-40396.rs index 1893355205433..e4e94bb949237 100644 --- a/src/test/ui/did_you_mean/issue-40396.rs +++ b/src/test/ui/did_you_mean/issue-40396.rs @@ -1,8 +1,8 @@ fn main() { (0..13).collect>(); - //~^ ERROR chained comparison + //~^ ERROR comparison operators cannot be chained Vec::new(); - //~^ ERROR chained comparison + //~^ ERROR comparison operators cannot be chained (0..13).collect(); - //~^ ERROR chained comparison + //~^ ERROR comparison operators cannot be chained } diff --git a/src/test/ui/did_you_mean/issue-40396.stderr b/src/test/ui/did_you_mean/issue-40396.stderr index 749d1093ccab8..f952136a7bfe3 100644 --- a/src/test/ui/did_you_mean/issue-40396.stderr +++ b/src/test/ui/did_you_mean/issue-40396.stderr @@ -1,15 +1,23 @@ -error: chained comparison operators require parentheses +error: comparison operators cannot be chained --> $DIR/issue-40396.rs:2:20 | LL | (0..13).collect>(); | ^^^^^ | +help: split the comparison into two... + | +LL | (0..13).collect < Vec && Vec >(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: ...or parenthesize one of the comparisons + | +LL | ((0..13).collect < Vec) >(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `::<...>` instead of `<...>` to specify type arguments | LL | (0..13).collect::>(); | ^^ -error: chained comparison operators require parentheses +error: comparison operators cannot be chained --> $DIR/issue-40396.rs:4:8 | LL | Vec::new(); @@ -20,12 +28,20 @@ help: use `::<...>` instead of `<...>` to specify type arguments LL | Vec::::new(); | ^^ -error: chained comparison operators require parentheses +error: comparison operators cannot be chained --> $DIR/issue-40396.rs:6:20 | LL | (0..13).collect(); | ^^^^^ | +help: split the comparison into two... + | +LL | (0..13).collect < Vec && Vec (); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: ...or parenthesize one of the comparisons + | +LL | ((0..13).collect < Vec) (); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `::<...>` instead of `<...>` to specify type arguments | LL | (0..13).collect::(); diff --git a/src/test/ui/did_you_mean/issue-48492-tuple-destructure-missing-parens.stderr b/src/test/ui/did_you_mean/issue-48492-tuple-destructure-missing-parens.stderr index 705c90985d547..d05d6d120b084 100644 --- a/src/test/ui/did_you_mean/issue-48492-tuple-destructure-missing-parens.stderr +++ b/src/test/ui/did_you_mean/issue-48492-tuple-destructure-missing-parens.stderr @@ -4,11 +4,11 @@ error: unexpected `,` in pattern LL | while let b1, b2, b3 = reading_frame.next().expect("there should be a start codon") { | ^ | -help: try adding parentheses to match on a tuple.. +help: try adding parentheses to match on a tuple... | LL | while let (b1, b2, b3) = reading_frame.next().expect("there should be a start codon") { | ^^^^^^^^^^^^ -help: ..or a vertical bar to match on multiple alternatives +help: ...or a vertical bar to match on multiple alternatives | LL | while let b1 | b2 | b3 = reading_frame.next().expect("there should be a start codon") { | ^^^^^^^^^^^^ @@ -19,11 +19,11 @@ error: unexpected `,` in pattern LL | if let b1, b2, b3 = reading_frame.next().unwrap() { | ^ | -help: try adding parentheses to match on a tuple.. +help: try adding parentheses to match on a tuple... | LL | if let (b1, b2, b3) = reading_frame.next().unwrap() { | ^^^^^^^^^^^^ -help: ..or a vertical bar to match on multiple alternatives +help: ...or a vertical bar to match on multiple alternatives | LL | if let b1 | b2 | b3 = reading_frame.next().unwrap() { | ^^^^^^^^^^^^ @@ -34,11 +34,11 @@ error: unexpected `,` in pattern LL | Nucleotide::Adenine, Nucleotide::Cytosine, _ => true | ^ | -help: try adding parentheses to match on a tuple.. +help: try adding parentheses to match on a tuple... | LL | (Nucleotide::Adenine, Nucleotide::Cytosine, _) => true | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: ..or a vertical bar to match on multiple alternatives +help: ...or a vertical bar to match on multiple alternatives | LL | Nucleotide::Adenine | Nucleotide::Cytosine | _ => true | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -49,11 +49,11 @@ error: unexpected `,` in pattern LL | for x, _barr_body in women.iter().map(|woman| woman.allosomes.clone()) { | ^ | -help: try adding parentheses to match on a tuple.. +help: try adding parentheses to match on a tuple... | LL | for (x, _barr_body) in women.iter().map(|woman| woman.allosomes.clone()) { | ^^^^^^^^^^^^^^^ -help: ..or a vertical bar to match on multiple alternatives +help: ...or a vertical bar to match on multiple alternatives | LL | for x | _barr_body in women.iter().map(|woman| woman.allosomes.clone()) { | ^^^^^^^^^^^^^^ @@ -64,11 +64,11 @@ error: unexpected `,` in pattern LL | for x, y @ Allosome::Y(_) in men.iter().map(|man| man.allosomes.clone()) { | ^ | -help: try adding parentheses to match on a tuple.. +help: try adding parentheses to match on a tuple... | LL | for (x, y @ Allosome::Y(_)) in men.iter().map(|man| man.allosomes.clone()) { | ^^^^^^^^^^^^^^^^^^^^^^^ -help: ..or a vertical bar to match on multiple alternatives +help: ...or a vertical bar to match on multiple alternatives | LL | for x | y @ Allosome::Y(_) in men.iter().map(|man| man.allosomes.clone()) { | ^^^^^^^^^^^^^^^^^^^^^^ @@ -79,11 +79,11 @@ error: unexpected `,` in pattern LL | let women, men: (Vec, Vec) = genomes.iter().cloned() | ^ | -help: try adding parentheses to match on a tuple.. +help: try adding parentheses to match on a tuple... | LL | let (women, men): (Vec, Vec) = genomes.iter().cloned() | ^^^^^^^^^^^^ -help: ..or a vertical bar to match on multiple alternatives +help: ...or a vertical bar to match on multiple alternatives | LL | let women | men: (Vec, Vec) = genomes.iter().cloned() | ^^^^^^^^^^^ diff --git a/src/test/ui/duplicate_entry_error.rs b/src/test/ui/duplicate_entry_error.rs index 62df42b1a6890..b8d98a8999b9d 100644 --- a/src/test/ui/duplicate_entry_error.rs +++ b/src/test/ui/duplicate_entry_error.rs @@ -8,7 +8,7 @@ use std::panic::PanicInfo; #[lang = "panic_impl"] fn panic_impl(info: &PanicInfo) -> ! { -//~^ ERROR: duplicate lang item found: `panic_impl`. +//~^ ERROR: found duplicate lang item `panic_impl` loop {} } diff --git a/src/test/ui/duplicate_entry_error.stderr b/src/test/ui/duplicate_entry_error.stderr index 02be11d1fd0e5..46b137b2cf9c0 100644 --- a/src/test/ui/duplicate_entry_error.stderr +++ b/src/test/ui/duplicate_entry_error.stderr @@ -1,4 +1,4 @@ -error[E0152]: duplicate lang item found: `panic_impl`. +error[E0152]: found duplicate lang item `panic_impl` --> $DIR/duplicate_entry_error.rs:10:1 | LL | / fn panic_impl(info: &PanicInfo) -> ! { @@ -7,7 +7,7 @@ LL | | loop {} LL | | } | |_^ | - = note: first defined in crate `std` (which `duplicate_entry_error` depends on). + = note: first defined in crate `std` (which `duplicate_entry_error` depends on) error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0152.stderr b/src/test/ui/error-codes/E0152.stderr index d4b59a1148e60..c41a0430150a4 100644 --- a/src/test/ui/error-codes/E0152.stderr +++ b/src/test/ui/error-codes/E0152.stderr @@ -1,10 +1,10 @@ -error[E0152]: duplicate lang item found: `arc`. +error[E0152]: found duplicate lang item `arc` --> $DIR/E0152.rs:4:1 | LL | struct Foo; | ^^^^^^^^^^^ | - = note: first defined in crate `alloc` (which `std` depends on). + = note: first defined in crate `alloc` (which `std` depends on) error: aborting due to previous error diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.rs b/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.rs index 0d804f012bcc3..8609108831e7c 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.rs +++ b/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.rs @@ -464,10 +464,10 @@ mod reexport_test_harness_main { // Cannot feed "2700" to `#[macro_escape]` without signaling an error. #[macro_escape] -//~^ WARN macro_escape is a deprecated synonym for macro_use +//~^ WARN `#[macro_escape]` is a deprecated synonym for `#[macro_use]` mod macro_escape { mod inner { #![macro_escape] } - //~^ WARN macro_escape is a deprecated synonym for macro_use + //~^ WARN `#[macro_escape]` is a deprecated synonym for `#[macro_use]` #[macro_escape] fn f() { } //~^ WARN unused attribute diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.stderr b/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.stderr index 9ce90d89d22d2..da7d8f9bee5c5 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.stderr +++ b/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.stderr @@ -172,19 +172,19 @@ warning: unknown lint: `x5100` LL | #[deny(x5100)] impl S { } | ^^^^^ -warning: macro_escape is a deprecated synonym for macro_use +warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:466:1 | LL | #[macro_escape] | ^^^^^^^^^^^^^^^ -warning: macro_escape is a deprecated synonym for macro_use +warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:469:17 | LL | mod inner { #![macro_escape] } | ^^^^^^^^^^^^^^^^ | - = help: consider an outer attribute, `#[macro_use]` mod ... + = help: try an outer attribute: `#[macro_use]` warning: use of deprecated attribute `plugin_registrar`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 --> $DIR/issue-43106-gating-of-builtin-attrs.rs:221:17 diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-macro_escape.rs b/src/test/ui/feature-gate/issue-43106-gating-of-macro_escape.rs index 75a3d9124ebae..de00bc4cbac07 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-macro_escape.rs +++ b/src/test/ui/feature-gate/issue-43106-gating-of-macro_escape.rs @@ -6,6 +6,6 @@ // check-pass #![macro_escape] -//~^ WARN macro_escape is a deprecated synonym for macro_use +//~^ WARN `#[macro_escape]` is a deprecated synonym for `#[macro_use]` fn main() {} diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-macro_escape.stderr b/src/test/ui/feature-gate/issue-43106-gating-of-macro_escape.stderr index 8575c1660c5a1..402dc4e540925 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-macro_escape.stderr +++ b/src/test/ui/feature-gate/issue-43106-gating-of-macro_escape.stderr @@ -1,8 +1,8 @@ -warning: macro_escape is a deprecated synonym for macro_use +warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]` --> $DIR/issue-43106-gating-of-macro_escape.rs:8:1 | LL | #![macro_escape] | ^^^^^^^^^^^^^^^^ | - = help: consider an outer attribute, `#[macro_use]` mod ... + = help: try an outer attribute: `#[macro_use]` diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-macro_use.rs b/src/test/ui/feature-gate/issue-43106-gating-of-macro_use.rs index 4ced941aad5d0..6a7ef793924a4 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-macro_use.rs +++ b/src/test/ui/feature-gate/issue-43106-gating-of-macro_use.rs @@ -4,13 +4,13 @@ // get that warning; see issue-43106-gating-of-builtin-attrs.rs #![macro_use(my_macro)] -//~^ ERROR arguments to macro_use are not allowed here +//~^ ERROR arguments to `macro_use` are not allowed here #[macro_use(my_macro)] -//~^ ERROR arguments to macro_use are not allowed here +//~^ ERROR arguments to `macro_use` are not allowed here mod macro_escape { mod inner { #![macro_use(my_macro)] } - //~^ ERROR arguments to macro_use are not allowed here + //~^ ERROR arguments to `macro_use` are not allowed here #[macro_use = "2700"] struct S; //~^ ERROR malformed `macro_use` attribute diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-macro_use.stderr b/src/test/ui/feature-gate/issue-43106-gating-of-macro_use.stderr index 3181d62298cad..52a682e4bfa87 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-macro_use.stderr +++ b/src/test/ui/feature-gate/issue-43106-gating-of-macro_use.stderr @@ -1,16 +1,16 @@ -error: arguments to macro_use are not allowed here +error: arguments to `macro_use` are not allowed here --> $DIR/issue-43106-gating-of-macro_use.rs:6:1 | LL | #![macro_use(my_macro)] | ^^^^^^^^^^^^^^^^^^^^^^^ -error: arguments to macro_use are not allowed here +error: arguments to `macro_use` are not allowed here --> $DIR/issue-43106-gating-of-macro_use.rs:9:1 | LL | #[macro_use(my_macro)] | ^^^^^^^^^^^^^^^^^^^^^^ -error: arguments to macro_use are not allowed here +error: arguments to `macro_use` are not allowed here --> $DIR/issue-43106-gating-of-macro_use.rs:12:17 | LL | mod inner { #![macro_use(my_macro)] } diff --git a/src/test/ui/feature-gates/feature-gate-never_type.stderr b/src/test/ui/feature-gates/feature-gate-never_type.stderr index d86ab99b82bd5..216615731e56f 100644 --- a/src/test/ui/feature-gates/feature-gate-never_type.stderr +++ b/src/test/ui/feature-gates/feature-gate-never_type.stderr @@ -1,4 +1,4 @@ -error[E0658]: The `!` type is experimental +error[E0658]: the `!` type is experimental --> $DIR/feature-gate-never_type.rs:7:17 | LL | type Ma = (u32, !, i32); @@ -7,7 +7,7 @@ LL | type Ma = (u32, !, i32); = note: for more information, see https://github.com/rust-lang/rust/issues/35121 = help: add `#![feature(never_type)]` to the crate attributes to enable -error[E0658]: The `!` type is experimental +error[E0658]: the `!` type is experimental --> $DIR/feature-gate-never_type.rs:8:20 | LL | type Meeshka = Vec; @@ -16,7 +16,7 @@ LL | type Meeshka = Vec; = note: for more information, see https://github.com/rust-lang/rust/issues/35121 = help: add `#![feature(never_type)]` to the crate attributes to enable -error[E0658]: The `!` type is experimental +error[E0658]: the `!` type is experimental --> $DIR/feature-gate-never_type.rs:9:24 | LL | type Mow = &'static fn(!) -> !; @@ -25,7 +25,7 @@ LL | type Mow = &'static fn(!) -> !; = note: for more information, see https://github.com/rust-lang/rust/issues/35121 = help: add `#![feature(never_type)]` to the crate attributes to enable -error[E0658]: The `!` type is experimental +error[E0658]: the `!` type is experimental --> $DIR/feature-gate-never_type.rs:10:27 | LL | type Skwoz = &'static mut !; @@ -34,7 +34,7 @@ LL | type Skwoz = &'static mut !; = note: for more information, see https://github.com/rust-lang/rust/issues/35121 = help: add `#![feature(never_type)]` to the crate attributes to enable -error[E0658]: The `!` type is experimental +error[E0658]: the `!` type is experimental --> $DIR/feature-gate-never_type.rs:13:16 | LL | type Wub = !; diff --git a/src/test/ui/future-incompatible-lint-group.stderr b/src/test/ui/future-incompatible-lint-group.stderr index 24e3a077ae6e3..1d958e5bfeb40 100644 --- a/src/test/ui/future-incompatible-lint-group.stderr +++ b/src/test/ui/future-incompatible-lint-group.stderr @@ -2,7 +2,7 @@ error: anonymous parameters are deprecated and will be removed in the next editi --> $DIR/future-incompatible-lint-group.rs:4:10 | LL | fn f(u8) {} - | ^^ help: Try naming the parameter or explicitly ignoring it: `_: u8` + | ^^ help: try naming the parameter or explicitly ignoring it: `_: u8` | note: lint level defined here --> $DIR/future-incompatible-lint-group.rs:1:9 diff --git a/src/test/ui/imports/extern-crate-self/extern-crate-self-fail.rs b/src/test/ui/imports/extern-crate-self/extern-crate-self-fail.rs index defa0e294bd74..1c0d3b4b964d6 100644 --- a/src/test/ui/imports/extern-crate-self/extern-crate-self-fail.rs +++ b/src/test/ui/imports/extern-crate-self/extern-crate-self-fail.rs @@ -1,6 +1,6 @@ extern crate self; //~ ERROR `extern crate self;` requires renaming -#[macro_use] //~ ERROR `macro_use` is not supported on `extern crate self` +#[macro_use] //~ ERROR `#[macro_use]` is not supported on `extern crate self` extern crate self as foo; fn main() {} diff --git a/src/test/ui/imports/extern-crate-self/extern-crate-self-fail.stderr b/src/test/ui/imports/extern-crate-self/extern-crate-self-fail.stderr index f26bb2f5a0ec4..8f369f1b03831 100644 --- a/src/test/ui/imports/extern-crate-self/extern-crate-self-fail.stderr +++ b/src/test/ui/imports/extern-crate-self/extern-crate-self-fail.stderr @@ -4,7 +4,7 @@ error: `extern crate self;` requires renaming LL | extern crate self; | ^^^^^^^^^^^^^^^^^^ help: try: `extern crate self as name;` -error: `macro_use` is not supported on `extern crate self` +error: `#[macro_use]` is not supported on `extern crate self` --> $DIR/extern-crate-self-fail.rs:3:1 | LL | #[macro_use] diff --git a/src/test/ui/issues/issue-29124.stderr b/src/test/ui/issues/issue-29124.stderr index fff20248b70d5..42d89cd01a48e 100644 --- a/src/test/ui/issues/issue-29124.stderr +++ b/src/test/ui/issues/issue-29124.stderr @@ -4,7 +4,7 @@ error[E0599]: no method named `x` found for fn item `fn() -> Ret {Obj::func}` in LL | Obj::func.x(); | ^ method not found in `fn() -> Ret {Obj::func}` | - = note: Obj::func is a function, perhaps you wish to call it + = note: `Obj::func` is a function, perhaps you wish to call it error[E0599]: no method named `x` found for fn item `fn() -> Ret {func}` in the current scope --> $DIR/issue-29124.rs:17:10 @@ -12,7 +12,7 @@ error[E0599]: no method named `x` found for fn item `fn() -> Ret {func}` in the LL | func.x(); | ^ method not found in `fn() -> Ret {func}` | - = note: func is a function, perhaps you wish to call it + = note: `func` is a function, perhaps you wish to call it error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-45730.stderr b/src/test/ui/issues/issue-45730.stderr index 3c400d6eefaa8..d4ddba52df14a 100644 --- a/src/test/ui/issues/issue-45730.stderr +++ b/src/test/ui/issues/issue-45730.stderr @@ -6,7 +6,7 @@ LL | let x: *const _ = 0 as _; | | | help: consider giving more type information | - = note: The type information given here is insufficient to check whether the pointer cast is valid + = note: the type information given here is insufficient to check whether the pointer cast is valid error[E0641]: cannot cast to a pointer of an unknown kind --> $DIR/issue-45730.rs:5:23 @@ -16,7 +16,7 @@ LL | let x: *const _ = 0 as *const _; | | | help: consider giving more type information | - = note: The type information given here is insufficient to check whether the pointer cast is valid + = note: the type information given here is insufficient to check whether the pointer cast is valid error[E0641]: cannot cast to a pointer of an unknown kind --> $DIR/issue-45730.rs:8:13 @@ -26,7 +26,7 @@ LL | let x = 0 as *const i32 as *const _ as *mut _; | | | help: consider giving more type information | - = note: The type information given here is insufficient to check whether the pointer cast is valid + = note: the type information given here is insufficient to check whether the pointer cast is valid error: aborting due to 3 previous errors diff --git a/src/test/ui/issues/issue-57362-1.stderr b/src/test/ui/issues/issue-57362-1.stderr index e762b7bc0c899..ad596db13ccfd 100644 --- a/src/test/ui/issues/issue-57362-1.stderr +++ b/src/test/ui/issues/issue-57362-1.stderr @@ -4,7 +4,7 @@ error[E0599]: no method named `f` found for fn pointer `fn(&u8)` in the current LL | a.f(); | ^ method not found in `fn(&u8)` | - = note: a is a function, perhaps you wish to call it + = note: `a` is a function, perhaps you wish to call it = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `f`, perhaps you need to implement it: candidate #1: `Trait` diff --git a/src/test/ui/keyword/keyword-super-as-identifier.rs b/src/test/ui/keyword/keyword-super-as-identifier.rs index d728b4fe3e241..02c1b27b08a96 100644 --- a/src/test/ui/keyword/keyword-super-as-identifier.rs +++ b/src/test/ui/keyword/keyword-super-as-identifier.rs @@ -1,3 +1,3 @@ fn main() { - let super = 22; //~ ERROR failed to resolve: there are too many initial `super`s + let super = 22; //~ ERROR failed to resolve: there are too many leading `super` keywords } diff --git a/src/test/ui/keyword/keyword-super-as-identifier.stderr b/src/test/ui/keyword/keyword-super-as-identifier.stderr index bbeaed9428795..1f64f3b73d6cd 100644 --- a/src/test/ui/keyword/keyword-super-as-identifier.stderr +++ b/src/test/ui/keyword/keyword-super-as-identifier.stderr @@ -1,8 +1,8 @@ -error[E0433]: failed to resolve: there are too many initial `super`s. +error[E0433]: failed to resolve: there are too many leading `super` keywords --> $DIR/keyword-super-as-identifier.rs:2:9 | LL | let super = 22; - | ^^^^^ there are too many initial `super`s. + | ^^^^^ there are too many leading `super` keywords error: aborting due to previous error diff --git a/src/test/ui/keyword/keyword-super.rs b/src/test/ui/keyword/keyword-super.rs index a43e1e39b6797..c121a6c1050ea 100644 --- a/src/test/ui/keyword/keyword-super.rs +++ b/src/test/ui/keyword/keyword-super.rs @@ -1,3 +1,3 @@ fn main() { - let super: isize; //~ ERROR failed to resolve: there are too many initial `super`s + let super: isize; //~ ERROR failed to resolve: there are too many leading `super` keywords } diff --git a/src/test/ui/keyword/keyword-super.stderr b/src/test/ui/keyword/keyword-super.stderr index 63394c7852a5d..0e0d67cb97b1f 100644 --- a/src/test/ui/keyword/keyword-super.stderr +++ b/src/test/ui/keyword/keyword-super.stderr @@ -1,8 +1,8 @@ -error[E0433]: failed to resolve: there are too many initial `super`s. +error[E0433]: failed to resolve: there are too many leading `super` keywords --> $DIR/keyword-super.rs:2:9 | LL | let super: isize; - | ^^^^^ there are too many initial `super`s. + | ^^^^^ there are too many leading `super` keywords error: aborting due to previous error diff --git a/src/test/ui/lint/uninitialized-zeroed.stderr b/src/test/ui/lint/uninitialized-zeroed.stderr index bdb5959953f50..169e77c8fa05d 100644 --- a/src/test/ui/lint/uninitialized-zeroed.stderr +++ b/src/test/ui/lint/uninitialized-zeroed.stderr @@ -12,7 +12,7 @@ note: lint level defined here | LL | #![deny(invalid_value)] | ^^^^^^^^^^^^^ - = note: References must be non-null + = note: references must be non-null error: the type `&'static T` does not permit being left uninitialized --> $DIR/uninitialized-zeroed.rs:30:32 @@ -23,7 +23,7 @@ LL | let _val: &'static T = mem::uninitialized(); | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | - = note: References must be non-null + = note: references must be non-null error: the type `Wrap<&'static T>` does not permit zero-initialization --> $DIR/uninitialized-zeroed.rs:32:38 @@ -34,7 +34,7 @@ LL | let _val: Wrap<&'static T> = mem::zeroed(); | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | -note: References must be non-null (in this struct field) +note: references must be non-null (in this struct field) --> $DIR/uninitialized-zeroed.rs:18:18 | LL | struct Wrap { wrapped: T } @@ -49,7 +49,7 @@ LL | let _val: Wrap<&'static T> = mem::uninitialized(); | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | -note: References must be non-null (in this struct field) +note: references must be non-null (in this struct field) --> $DIR/uninitialized-zeroed.rs:18:18 | LL | struct Wrap { wrapped: T } @@ -64,7 +64,7 @@ LL | let _val: ! = mem::zeroed(); | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | - = note: The never type (`!`) has no valid value + = note: the `!` type has no valid value error: the type `!` does not permit being left uninitialized --> $DIR/uninitialized-zeroed.rs:41:23 @@ -75,7 +75,7 @@ LL | let _val: ! = mem::uninitialized(); | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | - = note: The never type (`!`) has no valid value + = note: the `!` type has no valid value error: the type `(i32, !)` does not permit zero-initialization --> $DIR/uninitialized-zeroed.rs:43:30 @@ -86,7 +86,7 @@ LL | let _val: (i32, !) = mem::zeroed(); | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | - = note: The never type (`!`) has no valid value + = note: the `!` type has no valid value error: the type `(i32, !)` does not permit being left uninitialized --> $DIR/uninitialized-zeroed.rs:44:30 @@ -97,7 +97,7 @@ LL | let _val: (i32, !) = mem::uninitialized(); | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | - = note: The never type (`!`) has no valid value + = note: the `!` type has no valid value error: the type `Void` does not permit zero-initialization --> $DIR/uninitialized-zeroed.rs:46:26 @@ -108,7 +108,7 @@ LL | let _val: Void = mem::zeroed(); | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | - = note: 0-variant enums have no valid value + = note: enums with no variants have no valid value error: the type `Void` does not permit being left uninitialized --> $DIR/uninitialized-zeroed.rs:47:26 @@ -119,7 +119,7 @@ LL | let _val: Void = mem::uninitialized(); | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | - = note: 0-variant enums have no valid value + = note: enums with no variants have no valid value error: the type `&'static i32` does not permit zero-initialization --> $DIR/uninitialized-zeroed.rs:49:34 @@ -130,7 +130,7 @@ LL | let _val: &'static i32 = mem::zeroed(); | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | - = note: References must be non-null + = note: references must be non-null error: the type `&'static i32` does not permit being left uninitialized --> $DIR/uninitialized-zeroed.rs:50:34 @@ -141,7 +141,7 @@ LL | let _val: &'static i32 = mem::uninitialized(); | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | - = note: References must be non-null + = note: references must be non-null error: the type `Ref` does not permit zero-initialization --> $DIR/uninitialized-zeroed.rs:52:25 @@ -152,7 +152,7 @@ LL | let _val: Ref = mem::zeroed(); | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | -note: References must be non-null (in this struct field) +note: references must be non-null (in this struct field) --> $DIR/uninitialized-zeroed.rs:15:12 | LL | struct Ref(&'static i32); @@ -167,7 +167,7 @@ LL | let _val: Ref = mem::uninitialized(); | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | -note: References must be non-null (in this struct field) +note: references must be non-null (in this struct field) --> $DIR/uninitialized-zeroed.rs:15:12 | LL | struct Ref(&'static i32); @@ -182,7 +182,7 @@ LL | let _val: fn() = mem::zeroed(); | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | - = note: Function pointers must be non-null + = note: function pointers must be non-null error: the type `fn()` does not permit being left uninitialized --> $DIR/uninitialized-zeroed.rs:56:26 @@ -193,7 +193,7 @@ LL | let _val: fn() = mem::uninitialized(); | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | - = note: Function pointers must be non-null + = note: function pointers must be non-null error: the type `Wrap` does not permit zero-initialization --> $DIR/uninitialized-zeroed.rs:58:32 @@ -204,7 +204,7 @@ LL | let _val: Wrap = mem::zeroed(); | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | -note: Function pointers must be non-null (in this struct field) +note: function pointers must be non-null (in this struct field) --> $DIR/uninitialized-zeroed.rs:18:18 | LL | struct Wrap { wrapped: T } @@ -219,7 +219,7 @@ LL | let _val: Wrap = mem::uninitialized(); | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | -note: Function pointers must be non-null (in this struct field) +note: function pointers must be non-null (in this struct field) --> $DIR/uninitialized-zeroed.rs:18:18 | LL | struct Wrap { wrapped: T } @@ -234,7 +234,7 @@ LL | let _val: WrapEnum = mem::zeroed(); | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | -note: Function pointers must be non-null (in this enum field) +note: function pointers must be non-null (in this enum field) --> $DIR/uninitialized-zeroed.rs:19:28 | LL | enum WrapEnum { Wrapped(T) } @@ -249,7 +249,7 @@ LL | let _val: WrapEnum = mem::uninitialized(); | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | -note: Function pointers must be non-null (in this enum field) +note: function pointers must be non-null (in this enum field) --> $DIR/uninitialized-zeroed.rs:19:28 | LL | enum WrapEnum { Wrapped(T) } @@ -264,7 +264,7 @@ LL | let _val: Wrap<(RefPair, i32)> = mem::zeroed(); | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | -note: References must be non-null (in this struct field) +note: references must be non-null (in this struct field) --> $DIR/uninitialized-zeroed.rs:16:16 | LL | struct RefPair((&'static i32, i32)); @@ -279,7 +279,7 @@ LL | let _val: Wrap<(RefPair, i32)> = mem::uninitialized(); | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | -note: References must be non-null (in this struct field) +note: references must be non-null (in this struct field) --> $DIR/uninitialized-zeroed.rs:16:16 | LL | struct RefPair((&'static i32, i32)); @@ -294,7 +294,7 @@ LL | let _val: NonNull = mem::zeroed(); | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | - = note: std::ptr::NonNull must be non-null + = note: `std::ptr::NonNull` must be non-null error: the type `std::ptr::NonNull` does not permit being left uninitialized --> $DIR/uninitialized-zeroed.rs:68:34 @@ -305,7 +305,7 @@ LL | let _val: NonNull = mem::uninitialized(); | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | - = note: std::ptr::NonNull must be non-null + = note: `std::ptr::NonNull` must be non-null error: the type `*const dyn std::marker::Send` does not permit zero-initialization --> $DIR/uninitialized-zeroed.rs:70:37 @@ -316,7 +316,7 @@ LL | let _val: *const dyn Send = mem::zeroed(); | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | - = note: The vtable of a wide raw pointer must be non-null + = note: the vtable of a wide raw pointer must be non-null error: the type `*const dyn std::marker::Send` does not permit being left uninitialized --> $DIR/uninitialized-zeroed.rs:71:37 @@ -327,7 +327,7 @@ LL | let _val: *const dyn Send = mem::uninitialized(); | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | - = note: The vtable of a wide raw pointer must be non-null + = note: the vtable of a wide raw pointer must be non-null error: the type `bool` does not permit being left uninitialized --> $DIR/uninitialized-zeroed.rs:75:26 @@ -338,7 +338,7 @@ LL | let _val: bool = mem::uninitialized(); | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | - = note: Booleans must be `true` or `false` + = note: booleans must be either `true` or `false` error: the type `Wrap` does not permit being left uninitialized --> $DIR/uninitialized-zeroed.rs:78:32 @@ -349,7 +349,7 @@ LL | let _val: Wrap = mem::uninitialized(); | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | -note: Characters must be a valid unicode codepoint (in this struct field) +note: characters must be a valid Unicode codepoint (in this struct field) --> $DIR/uninitialized-zeroed.rs:18:18 | LL | struct Wrap { wrapped: T } @@ -364,7 +364,7 @@ LL | let _val: NonBig = mem::uninitialized(); | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | - = note: NonBig must be initialized inside its custom valid range + = note: `NonBig` must be initialized inside its custom valid range error: the type `&'static i32` does not permit zero-initialization --> $DIR/uninitialized-zeroed.rs:84:34 @@ -375,7 +375,7 @@ LL | let _val: &'static i32 = mem::transmute(0usize); | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | - = note: References must be non-null + = note: references must be non-null error: the type `&'static [i32]` does not permit zero-initialization --> $DIR/uninitialized-zeroed.rs:85:36 @@ -386,7 +386,7 @@ LL | let _val: &'static [i32] = mem::transmute((0usize, 0usize)); | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | - = note: References must be non-null + = note: references must be non-null error: the type `std::num::NonZeroU32` does not permit zero-initialization --> $DIR/uninitialized-zeroed.rs:86:32 @@ -397,7 +397,7 @@ LL | let _val: NonZeroU32 = mem::transmute(0); | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | - = note: std::num::NonZeroU32 must be non-null + = note: `std::num::NonZeroU32` must be non-null error: the type `std::ptr::NonNull` does not permit zero-initialization --> $DIR/uninitialized-zeroed.rs:89:34 @@ -408,7 +408,7 @@ LL | let _val: NonNull = MaybeUninit::zeroed().assume_init(); | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | - = note: std::ptr::NonNull must be non-null + = note: `std::ptr::NonNull` must be non-null error: the type `std::ptr::NonNull` does not permit being left uninitialized --> $DIR/uninitialized-zeroed.rs:90:34 @@ -419,7 +419,7 @@ LL | let _val: NonNull = MaybeUninit::uninit().assume_init(); | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | - = note: std::ptr::NonNull must be non-null + = note: `std::ptr::NonNull` must be non-null error: the type `bool` does not permit being left uninitialized --> $DIR/uninitialized-zeroed.rs:91:26 @@ -430,7 +430,7 @@ LL | let _val: bool = MaybeUninit::uninit().assume_init(); | this code causes undefined behavior when executed | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done | - = note: Booleans must be `true` or `false` + = note: booleans must be either `true` or `false` error: aborting due to 35 previous errors diff --git a/src/test/ui/malformed/malformed-interpolated.stderr b/src/test/ui/malformed/malformed-interpolated.stderr index bcd2ef545d815..6f6ad4508be01 100644 --- a/src/test/ui/malformed/malformed-interpolated.stderr +++ b/src/test/ui/malformed/malformed-interpolated.stderr @@ -4,7 +4,7 @@ error: suffixed literals are not allowed in attributes LL | check!(0u8); | ^^^ | - = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.) error: unexpected token: `-0` --> $DIR/malformed-interpolated.rs:5:25 diff --git a/src/test/ui/module-macro_use-arguments.rs b/src/test/ui/module-macro_use-arguments.rs index 6627b48eb6a2c..121b492e25437 100644 --- a/src/test/ui/module-macro_use-arguments.rs +++ b/src/test/ui/module-macro_use-arguments.rs @@ -1,4 +1,4 @@ -#[macro_use(foo, bar)] //~ ERROR arguments to macro_use are not allowed here +#[macro_use(foo, bar)] //~ ERROR arguments to `macro_use` are not allowed here mod foo { } diff --git a/src/test/ui/module-macro_use-arguments.stderr b/src/test/ui/module-macro_use-arguments.stderr index 2a75736a2c69f..af799cb6ddf3e 100644 --- a/src/test/ui/module-macro_use-arguments.stderr +++ b/src/test/ui/module-macro_use-arguments.stderr @@ -1,4 +1,4 @@ -error: arguments to macro_use are not allowed here +error: arguments to `macro_use` are not allowed here --> $DIR/module-macro_use-arguments.rs:1:1 | LL | #[macro_use(foo, bar)] diff --git a/src/test/ui/multi-panic.rs b/src/test/ui/multi-panic.rs index e4b41e4180664..0f8bddf27fe08 100644 --- a/src/test/ui/multi-panic.rs +++ b/src/test/ui/multi-panic.rs @@ -10,7 +10,7 @@ fn check_for_no_backtrace(test: std::process::Output) { assert_eq!(it.next().map(|l| l.starts_with("thread '' panicked at")), Some(true)); assert_eq!(it.next(), Some("note: run with `RUST_BACKTRACE=1` \ - environment variable to display a backtrace.")); + environment variable to display a backtrace")); assert_eq!(it.next().map(|l| l.starts_with("thread 'main' panicked at")), Some(true)); assert_eq!(it.next(), None); } diff --git a/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr b/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr index 3d79ff0b706f5..b4e18c229fdfd 100644 --- a/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr +++ b/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr @@ -1,4 +1,4 @@ -note: No external requirements +note: no external requirements --> $DIR/escape-argument-callee.rs:26:38 | LL | let mut closure = expect_sig(|p, y| *p = y); @@ -18,7 +18,7 @@ LL | let mut closure = expect_sig(|p, y| *p = y); | | has type `&'1 i32` | has type `&'_#2r mut &'2 i32` -note: No external requirements +note: no external requirements --> $DIR/escape-argument-callee.rs:20:1 | LL | / fn test() { diff --git a/src/test/ui/nll/closure-requirements/escape-argument.stderr b/src/test/ui/nll/closure-requirements/escape-argument.stderr index 37f04af6378d9..533a17bdd128b 100644 --- a/src/test/ui/nll/closure-requirements/escape-argument.stderr +++ b/src/test/ui/nll/closure-requirements/escape-argument.stderr @@ -1,4 +1,4 @@ -note: No external requirements +note: no external requirements --> $DIR/escape-argument.rs:26:38 | LL | let mut closure = expect_sig(|p, y| *p = y); @@ -9,7 +9,7 @@ LL | let mut closure = expect_sig(|p, y| *p = y); for<'r, 's> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BrNamed('r)) mut &ReLateBound(DebruijnIndex(0), BrNamed('s)) i32, &ReLateBound(DebruijnIndex(0), BrNamed('s)) i32)), ] -note: No external requirements +note: no external requirements --> $DIR/escape-argument.rs:20:1 | LL | / fn test() { diff --git a/src/test/ui/nll/closure-requirements/escape-upvar-nested.stderr b/src/test/ui/nll/closure-requirements/escape-upvar-nested.stderr index 810c0286cf218..60d02066e2676 100644 --- a/src/test/ui/nll/closure-requirements/escape-upvar-nested.stderr +++ b/src/test/ui/nll/closure-requirements/escape-upvar-nested.stderr @@ -1,4 +1,4 @@ -note: External requirements +note: external requirements --> $DIR/escape-upvar-nested.rs:21:32 | LL | let mut closure1 = || p = &y; @@ -13,7 +13,7 @@ LL | let mut closure1 = || p = &y; = note: number of external vids: 4 = note: where '_#1r: '_#3r -note: External requirements +note: external requirements --> $DIR/escape-upvar-nested.rs:20:27 | LL | let mut closure = || { @@ -32,7 +32,7 @@ LL | | }; = note: number of external vids: 4 = note: where '_#1r: '_#3r -note: No external requirements +note: no external requirements --> $DIR/escape-upvar-nested.rs:13:1 | LL | / fn test() { diff --git a/src/test/ui/nll/closure-requirements/escape-upvar-ref.stderr b/src/test/ui/nll/closure-requirements/escape-upvar-ref.stderr index bf042769a00e2..f64ccf14ac482 100644 --- a/src/test/ui/nll/closure-requirements/escape-upvar-ref.stderr +++ b/src/test/ui/nll/closure-requirements/escape-upvar-ref.stderr @@ -1,4 +1,4 @@ -note: External requirements +note: external requirements --> $DIR/escape-upvar-ref.rs:23:27 | LL | let mut closure = || p = &y; @@ -13,7 +13,7 @@ LL | let mut closure = || p = &y; = note: number of external vids: 4 = note: where '_#1r: '_#3r -note: No external requirements +note: no external requirements --> $DIR/escape-upvar-ref.rs:17:1 | LL | / fn test() { diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr index 4e3aa352fffdb..e1e0cdc153a6c 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr @@ -1,4 +1,4 @@ -note: No external requirements +note: no external requirements --> $DIR/propagate-approximated-fail-no-postdom.rs:43:9 | LL | / |_outlives1, _outlives2, _outlives3, x, y| { @@ -27,7 +27,7 @@ LL | |_outlives1, _outlives2, _outlives3, x, y| { LL | demand_y(x, y, p) | ^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2` -note: No external requirements +note: no external requirements --> $DIR/propagate-approximated-fail-no-postdom.rs:38:1 | LL | / fn supply<'a, 'b, 'c>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>, cell_c: Cell<&'c u32>) { diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr index cd61b8b5e555e..b6535024a4a76 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr @@ -1,4 +1,4 @@ -note: External requirements +note: external requirements --> $DIR/propagate-approximated-ref.rs:43:47 | LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { @@ -18,7 +18,7 @@ LL | | }); = note: number of external vids: 5 = note: where '_#1r: '_#2r -note: No external requirements +note: no external requirements --> $DIR/propagate-approximated-ref.rs:42:1 | LL | / fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr index 259140c2e5a3d..708e50de570db 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr @@ -1,4 +1,4 @@ -note: No external requirements +note: no external requirements --> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:21:15 | LL | foo(cell, |cell_a, cell_x| { @@ -23,7 +23,7 @@ LL | foo(cell, |cell_a, cell_x| { LL | cell_a.set(cell_x.get()); // forces 'x: 'a, error in closure | ^^^^^^^^^^^^^^^^^^^^^^^^ `cell_x` escapes the closure body here -note: No external requirements +note: no external requirements --> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:18:1 | LL | / fn case1() { @@ -37,7 +37,7 @@ LL | | } | = note: defining type: case1 -note: External requirements +note: external requirements --> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:35:15 | LL | foo(cell, |cell_a, cell_x| { @@ -53,7 +53,7 @@ LL | | }) = note: number of external vids: 2 = note: where '_#1r: '_#0r -note: No external requirements +note: no external requirements --> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:28:1 | LL | / fn case2() { diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr index b3dd682e4f0b7..17d33e82ba7e3 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr @@ -1,4 +1,4 @@ -note: External requirements +note: external requirements --> $DIR/propagate-approximated-shorter-to-static-no-bound.rs:32:47 | LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { @@ -19,7 +19,7 @@ LL | | }); = note: number of external vids: 4 = note: where '_#1r: '_#0r -note: No external requirements +note: no external requirements --> $DIR/propagate-approximated-shorter-to-static-no-bound.rs:31:1 | LL | / fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr index ab12d08f7b74e..5dce8d087d6cd 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr @@ -1,4 +1,4 @@ -note: External requirements +note: external requirements --> $DIR/propagate-approximated-shorter-to-static-wrong-bound.rs:35:47 | LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { @@ -19,7 +19,7 @@ LL | | }); = note: number of external vids: 5 = note: where '_#1r: '_#0r -note: No external requirements +note: no external requirements --> $DIR/propagate-approximated-shorter-to-static-wrong-bound.rs:34:1 | LL | / fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr index b2209e9cab0c9..5c5d510805bdf 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr @@ -1,4 +1,4 @@ -note: External requirements +note: external requirements --> $DIR/propagate-approximated-val.rs:36:45 | LL | establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| { @@ -18,7 +18,7 @@ LL | | }); = note: number of external vids: 5 = note: where '_#1r: '_#2r -note: No external requirements +note: no external requirements --> $DIR/propagate-approximated-val.rs:35:1 | LL | / fn test<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { diff --git a/src/test/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr b/src/test/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr index 55ee515a3a821..c111e651832ba 100644 --- a/src/test/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr @@ -1,4 +1,4 @@ -note: External requirements +note: external requirements --> $DIR/propagate-despite-same-free-region.rs:42:9 | LL | / |_outlives1, _outlives2, x, y| { @@ -16,7 +16,7 @@ LL | | }, = note: number of external vids: 4 = note: where '_#1r: '_#2r -note: No external requirements +note: no external requirements --> $DIR/propagate-despite-same-free-region.rs:39:1 | LL | / fn supply<'a>(cell_a: Cell<&'a u32>) { diff --git a/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr b/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr index 1c29af8c42210..52df46ed3453f 100644 --- a/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr @@ -1,4 +1,4 @@ -note: No external requirements +note: no external requirements --> $DIR/propagate-fail-to-approximate-longer-no-bounds.rs:35:47 | LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { @@ -27,7 +27,7 @@ LL | // Only works if 'x: 'y: LL | demand_y(x, y, x.get()) | ^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2` -note: No external requirements +note: no external requirements --> $DIR/propagate-fail-to-approximate-longer-no-bounds.rs:34:1 | LL | / fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { diff --git a/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr b/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr index afa0e9f619ddc..0270cc40de6fc 100644 --- a/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr @@ -1,4 +1,4 @@ -note: No external requirements +note: no external requirements --> $DIR/propagate-fail-to-approximate-longer-wrong-bounds.rs:39:47 | LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { @@ -27,7 +27,7 @@ LL | // Only works if 'x: 'y: LL | demand_y(x, y, x.get()) | ^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2` -note: No external requirements +note: no external requirements --> $DIR/propagate-fail-to-approximate-longer-wrong-bounds.rs:38:1 | LL | / fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { diff --git a/src/test/ui/nll/closure-requirements/propagate-from-trait-match.stderr b/src/test/ui/nll/closure-requirements/propagate-from-trait-match.stderr index 0dbb530e698bb..5317bb6a1b13e 100644 --- a/src/test/ui/nll/closure-requirements/propagate-from-trait-match.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-from-trait-match.stderr @@ -1,4 +1,4 @@ -note: External requirements +note: external requirements --> $DIR/propagate-from-trait-match.rs:32:36 | LL | establish_relationships(value, |value| { @@ -18,7 +18,7 @@ LL | | }); = note: number of external vids: 2 = note: where T: '_#1r -note: No external requirements +note: no external requirements --> $DIR/propagate-from-trait-match.rs:28:1 | LL | / fn supply<'a, T>(value: T) diff --git a/src/test/ui/nll/closure-requirements/return-wrong-bound-region.stderr b/src/test/ui/nll/closure-requirements/return-wrong-bound-region.stderr index ca794d92666f2..79ed1501524bd 100644 --- a/src/test/ui/nll/closure-requirements/return-wrong-bound-region.stderr +++ b/src/test/ui/nll/closure-requirements/return-wrong-bound-region.stderr @@ -1,4 +1,4 @@ -note: No external requirements +note: no external requirements --> $DIR/return-wrong-bound-region.rs:11:16 | LL | expect_sig(|a, b| b); // ought to return `a` @@ -18,7 +18,7 @@ LL | expect_sig(|a, b| b); // ought to return `a` | | has type `&'1 i32` | has type `&'2 i32` -note: No external requirements +note: no external requirements --> $DIR/return-wrong-bound-region.rs:10:1 | LL | / fn test() { diff --git a/src/test/ui/nll/ty-outlives/projection-no-regions-closure.stderr b/src/test/ui/nll/ty-outlives/projection-no-regions-closure.stderr index c825227cdad8e..bff8c662d0def 100644 --- a/src/test/ui/nll/ty-outlives/projection-no-regions-closure.stderr +++ b/src/test/ui/nll/ty-outlives/projection-no-regions-closure.stderr @@ -1,4 +1,4 @@ -note: External requirements +note: external requirements --> $DIR/projection-no-regions-closure.rs:25:23 | LL | with_signature(x, |mut y| Box::new(y.next())) @@ -11,7 +11,7 @@ LL | with_signature(x, |mut y| Box::new(y.next())) = note: number of external vids: 3 = note: where ::Item: '_#2r -note: No external requirements +note: no external requirements --> $DIR/projection-no-regions-closure.rs:21:1 | LL | / fn no_region<'a, T>(x: Box) -> Box @@ -33,7 +33,7 @@ LL | with_signature(x, |mut y| Box::new(y.next())) | = help: consider adding an explicit lifetime bound `::Item: ReEarlyBound(0, 'a)`... -note: External requirements +note: external requirements --> $DIR/projection-no-regions-closure.rs:34:23 | LL | with_signature(x, |mut y| Box::new(y.next())) @@ -46,7 +46,7 @@ LL | with_signature(x, |mut y| Box::new(y.next())) = note: number of external vids: 3 = note: where ::Item: '_#2r -note: No external requirements +note: no external requirements --> $DIR/projection-no-regions-closure.rs:30:1 | LL | / fn correct_region<'a, T>(x: Box) -> Box @@ -59,7 +59,7 @@ LL | | } | = note: defining type: correct_region::<'_#1r, T> -note: External requirements +note: external requirements --> $DIR/projection-no-regions-closure.rs:42:23 | LL | with_signature(x, |mut y| Box::new(y.next())) @@ -72,7 +72,7 @@ LL | with_signature(x, |mut y| Box::new(y.next())) = note: number of external vids: 4 = note: where ::Item: '_#3r -note: No external requirements +note: no external requirements --> $DIR/projection-no-regions-closure.rs:38:1 | LL | / fn wrong_region<'a, 'b, T>(x: Box) -> Box @@ -94,7 +94,7 @@ LL | with_signature(x, |mut y| Box::new(y.next())) | = help: consider adding an explicit lifetime bound `::Item: ReEarlyBound(0, 'a)`... -note: External requirements +note: external requirements --> $DIR/projection-no-regions-closure.rs:52:23 | LL | with_signature(x, |mut y| Box::new(y.next())) @@ -107,7 +107,7 @@ LL | with_signature(x, |mut y| Box::new(y.next())) = note: number of external vids: 4 = note: where ::Item: '_#3r -note: No external requirements +note: no external requirements --> $DIR/projection-no-regions-closure.rs:47:1 | LL | / fn outlives_region<'a, 'b, T>(x: Box) -> Box diff --git a/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr b/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr index 7226c520bf138..6d1fbcb8f5bfd 100644 --- a/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr +++ b/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr @@ -1,4 +1,4 @@ -note: External requirements +note: external requirements --> $DIR/projection-one-region-closure.rs:45:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); @@ -13,7 +13,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); = note: where T: '_#2r = note: where '_#1r: '_#2r -note: No external requirements +note: no external requirements --> $DIR/projection-one-region-closure.rs:41:1 | LL | / fn no_relationships_late<'a, 'b, T>(cell: Cell<&'a ()>, t: T) @@ -48,7 +48,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); | = help: consider adding the following bound: `'b: 'a` -note: External requirements +note: external requirements --> $DIR/projection-one-region-closure.rs:56:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); @@ -62,7 +62,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); = note: where T: '_#3r = note: where '_#2r: '_#3r -note: No external requirements +note: no external requirements --> $DIR/projection-one-region-closure.rs:51:1 | LL | / fn no_relationships_early<'a, 'b, T>(cell: Cell<&'a ()>, t: T) @@ -97,7 +97,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); | = help: consider adding the following bound: `'b: 'a` -note: External requirements +note: external requirements --> $DIR/projection-one-region-closure.rs:70:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); @@ -110,7 +110,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); = note: number of external vids: 4 = note: where >::AssocType: '_#3r -note: No external requirements +note: no external requirements --> $DIR/projection-one-region-closure.rs:62:1 | LL | / fn projection_outlives<'a, 'b, T>(cell: Cell<&'a ()>, t: T) @@ -124,7 +124,7 @@ LL | | } | = note: defining type: projection_outlives::<'_#1r, '_#2r, T> -note: External requirements +note: external requirements --> $DIR/projection-one-region-closure.rs:80:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); @@ -138,7 +138,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); = note: where T: '_#3r = note: where '_#2r: '_#3r -note: No external requirements +note: no external requirements --> $DIR/projection-one-region-closure.rs:74:1 | LL | / fn elements_outlive<'a, 'b, T>(cell: Cell<&'a ()>, t: T) diff --git a/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr b/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr index 655995c1b8029..59d8aa484bdac 100644 --- a/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr +++ b/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr @@ -1,4 +1,4 @@ -note: External requirements +note: external requirements --> $DIR/projection-one-region-trait-bound-closure.rs:37:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); @@ -12,7 +12,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); = note: number of external vids: 4 = note: where '_#1r: '_#2r -note: No external requirements +note: no external requirements --> $DIR/projection-one-region-trait-bound-closure.rs:33:1 | LL | / fn no_relationships_late<'a, 'b, T>(cell: Cell<&'a ()>, t: T) @@ -39,7 +39,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); | = help: consider adding the following bound: `'b: 'a` -note: External requirements +note: external requirements --> $DIR/projection-one-region-trait-bound-closure.rs:47:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); @@ -52,7 +52,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); = note: number of external vids: 4 = note: where '_#2r: '_#3r -note: No external requirements +note: no external requirements --> $DIR/projection-one-region-trait-bound-closure.rs:42:1 | LL | / fn no_relationships_early<'a, 'b, T>(cell: Cell<&'a ()>, t: T) @@ -79,7 +79,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); | = help: consider adding the following bound: `'b: 'a` -note: External requirements +note: external requirements --> $DIR/projection-one-region-trait-bound-closure.rs:60:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); @@ -92,7 +92,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); = note: number of external vids: 4 = note: where >::AssocType: '_#3r -note: No external requirements +note: no external requirements --> $DIR/projection-one-region-trait-bound-closure.rs:52:1 | LL | / fn projection_outlives<'a, 'b, T>(cell: Cell<&'a ()>, t: T) @@ -106,7 +106,7 @@ LL | | } | = note: defining type: projection_outlives::<'_#1r, '_#2r, T> -note: External requirements +note: external requirements --> $DIR/projection-one-region-trait-bound-closure.rs:69:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); @@ -119,7 +119,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); = note: number of external vids: 4 = note: where '_#2r: '_#3r -note: No external requirements +note: no external requirements --> $DIR/projection-one-region-trait-bound-closure.rs:64:1 | LL | / fn elements_outlive<'a, 'b, T>(cell: Cell<&'a ()>, t: T) @@ -133,7 +133,7 @@ LL | | } | = note: defining type: elements_outlive::<'_#1r, '_#2r, T> -note: External requirements +note: external requirements --> $DIR/projection-one-region-trait-bound-closure.rs:81:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); @@ -146,7 +146,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); = note: number of external vids: 3 = note: where '_#1r: '_#2r -note: No external requirements +note: no external requirements --> $DIR/projection-one-region-trait-bound-closure.rs:73:1 | LL | / fn one_region<'a, T>(cell: Cell<&'a ()>, t: T) diff --git a/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-static-closure.stderr b/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-static-closure.stderr index 2fb07b9279aa8..c3b924577ab47 100644 --- a/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-static-closure.stderr +++ b/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-static-closure.stderr @@ -1,4 +1,4 @@ -note: No external requirements +note: no external requirements --> $DIR/projection-one-region-trait-bound-static-closure.rs:36:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); @@ -10,7 +10,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); ] = note: late-bound region is '_#3r -note: No external requirements +note: no external requirements --> $DIR/projection-one-region-trait-bound-static-closure.rs:32:1 | LL | / fn no_relationships_late<'a, 'b, T>(cell: Cell<&'a ()>, t: T) @@ -23,7 +23,7 @@ LL | | } | = note: defining type: no_relationships_late::<'_#1r, T> -note: No external requirements +note: no external requirements --> $DIR/projection-one-region-trait-bound-static-closure.rs:45:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); @@ -34,7 +34,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T)), ] -note: No external requirements +note: no external requirements --> $DIR/projection-one-region-trait-bound-static-closure.rs:40:1 | LL | / fn no_relationships_early<'a, 'b, T>(cell: Cell<&'a ()>, t: T) @@ -48,7 +48,7 @@ LL | | } | = note: defining type: no_relationships_early::<'_#1r, '_#2r, T> -note: No external requirements +note: no external requirements --> $DIR/projection-one-region-trait-bound-static-closure.rs:64:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); @@ -59,7 +59,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T)), ] -note: No external requirements +note: no external requirements --> $DIR/projection-one-region-trait-bound-static-closure.rs:49:1 | LL | / fn projection_outlives<'a, 'b, T>(cell: Cell<&'a ()>, t: T) @@ -73,7 +73,7 @@ LL | | } | = note: defining type: projection_outlives::<'_#1r, '_#2r, T> -note: No external requirements +note: no external requirements --> $DIR/projection-one-region-trait-bound-static-closure.rs:73:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); @@ -84,7 +84,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T)), ] -note: No external requirements +note: no external requirements --> $DIR/projection-one-region-trait-bound-static-closure.rs:68:1 | LL | / fn elements_outlive<'a, 'b, T>(cell: Cell<&'a ()>, t: T) @@ -98,7 +98,7 @@ LL | | } | = note: defining type: elements_outlive::<'_#1r, '_#2r, T> -note: No external requirements +note: no external requirements --> $DIR/projection-one-region-trait-bound-static-closure.rs:85:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); @@ -109,7 +109,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); extern "rust-call" fn((std::cell::Cell<&'_#2r ()>, T)), ] -note: No external requirements +note: no external requirements --> $DIR/projection-one-region-trait-bound-static-closure.rs:77:1 | LL | / fn one_region<'a, T>(cell: Cell<&'a ()>, t: T) diff --git a/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr b/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr index 501a55e3105db..1bd97c1caa4ae 100644 --- a/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr +++ b/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr @@ -1,4 +1,4 @@ -note: External requirements +note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:38:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); @@ -12,7 +12,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); = note: number of external vids: 5 = note: where >::AssocType: '_#3r -note: No external requirements +note: no external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:34:1 | LL | / fn no_relationships_late<'a, 'b, 'c, T>(cell: Cell<&'a ()>, t: T) @@ -34,7 +34,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); | = help: consider adding an explicit lifetime bound `>::AssocType: ReFree(DefId(0:17 ~ projection_two_region_trait_bound_closure[317d]::no_relationships_late[0]), BrNamed(DefId(0:18 ~ projection_two_region_trait_bound_closure[317d]::no_relationships_late[0]::'a[0]), 'a))`... -note: External requirements +note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:48:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); @@ -47,7 +47,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); = note: number of external vids: 5 = note: where >::AssocType: '_#4r -note: No external requirements +note: no external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:43:1 | LL | / fn no_relationships_early<'a, 'b, 'c, T>(cell: Cell<&'a ()>, t: T) @@ -69,7 +69,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); | = help: consider adding an explicit lifetime bound `>::AssocType: ReEarlyBound(0, 'a)`... -note: External requirements +note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:61:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); @@ -82,7 +82,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); = note: number of external vids: 5 = note: where >::AssocType: '_#4r -note: No external requirements +note: no external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:53:1 | LL | / fn projection_outlives<'a, 'b, 'c, T>(cell: Cell<&'a ()>, t: T) @@ -96,7 +96,7 @@ LL | | } | = note: defining type: projection_outlives::<'_#1r, '_#2r, '_#3r, T> -note: External requirements +note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:70:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); @@ -109,7 +109,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); = note: number of external vids: 5 = note: where >::AssocType: '_#4r -note: No external requirements +note: no external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:65:1 | LL | / fn elements_outlive1<'a, 'b, 'c, T>(cell: Cell<&'a ()>, t: T) @@ -123,7 +123,7 @@ LL | | } | = note: defining type: elements_outlive1::<'_#1r, '_#2r, '_#3r, T> -note: External requirements +note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:79:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); @@ -136,7 +136,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); = note: number of external vids: 5 = note: where >::AssocType: '_#4r -note: No external requirements +note: no external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:74:1 | LL | / fn elements_outlive2<'a, 'b, 'c, T>(cell: Cell<&'a ()>, t: T) @@ -150,7 +150,7 @@ LL | | } | = note: defining type: elements_outlive2::<'_#1r, '_#2r, '_#3r, T> -note: External requirements +note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:87:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); @@ -164,7 +164,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); = note: number of external vids: 4 = note: where >::AssocType: '_#2r -note: No external requirements +note: no external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:83:1 | LL | / fn two_regions<'a, 'b, T>(cell: Cell<&'a ()>, t: T) @@ -191,7 +191,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); | = help: consider adding the following bound: `'b: 'a` -note: External requirements +note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:97:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); @@ -204,7 +204,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); = note: number of external vids: 4 = note: where >::AssocType: '_#3r -note: No external requirements +note: no external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:92:1 | LL | / fn two_regions_outlive<'a, 'b, T>(cell: Cell<&'a ()>, t: T) @@ -218,7 +218,7 @@ LL | | } | = note: defining type: two_regions_outlive::<'_#1r, '_#2r, T> -note: External requirements +note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:109:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); @@ -231,7 +231,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); = note: number of external vids: 3 = note: where >::AssocType: '_#2r -note: No external requirements +note: no external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:101:1 | LL | / fn one_region<'a, T>(cell: Cell<&'a ()>, t: T) diff --git a/src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr b/src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr index db0bca1dec6f5..a213f423e3c8d 100644 --- a/src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr +++ b/src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr @@ -1,4 +1,4 @@ -note: External requirements +note: external requirements --> $DIR/ty-param-closure-approximate-lower-bound.rs:24:24 | LL | twice(cell, value, |a, b| invoke(a, b)); @@ -11,7 +11,7 @@ LL | twice(cell, value, |a, b| invoke(a, b)); = note: number of external vids: 2 = note: where T: '_#1r -note: No external requirements +note: no external requirements --> $DIR/ty-param-closure-approximate-lower-bound.rs:22:1 | LL | / fn generic(value: T) { @@ -22,7 +22,7 @@ LL | | } | = note: defining type: generic:: -note: External requirements +note: external requirements --> $DIR/ty-param-closure-approximate-lower-bound.rs:29:24 | LL | twice(cell, value, |a, b| invoke(a, b)); @@ -36,7 +36,7 @@ LL | twice(cell, value, |a, b| invoke(a, b)); = note: number of external vids: 3 = note: where T: '_#1r -note: No external requirements +note: no external requirements --> $DIR/ty-param-closure-approximate-lower-bound.rs:28:1 | LL | / fn generic_fail<'a, T>(cell: Cell<&'a ()>, value: T) { diff --git a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr index 0021d730f85a1..a488637bbc5c2 100644 --- a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr +++ b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr @@ -1,4 +1,4 @@ -note: External requirements +note: external requirements --> $DIR/ty-param-closure-outlives-from-return-type.rs:26:23 | LL | with_signature(x, |y| y) @@ -11,7 +11,7 @@ LL | with_signature(x, |y| y) = note: number of external vids: 3 = note: where T: '_#2r -note: No external requirements +note: no external requirements --> $DIR/ty-param-closure-outlives-from-return-type.rs:15:1 | LL | / fn no_region<'a, T>(x: Box) -> Box diff --git a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr index 46fef8ee5067b..62dfe94e38493 100644 --- a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr +++ b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr @@ -1,4 +1,4 @@ -note: External requirements +note: external requirements --> $DIR/ty-param-closure-outlives-from-where-clause.rs:27:26 | LL | with_signature(a, b, |x, y| { @@ -19,7 +19,7 @@ LL | | }) = note: number of external vids: 3 = note: where T: '_#1r -note: No external requirements +note: no external requirements --> $DIR/ty-param-closure-outlives-from-where-clause.rs:26:1 | LL | / fn no_region<'a, T>(a: Cell<&'a ()>, b: T) { @@ -48,7 +48,7 @@ LL | | }) | = help: consider adding an explicit lifetime bound `T: ReFree(DefId(0:11 ~ ty_param_closure_outlives_from_where_clause[317d]::no_region[0]), BrNamed(DefId(0:12 ~ ty_param_closure_outlives_from_where_clause[317d]::no_region[0]::'a[0]), 'a))`... -note: External requirements +note: external requirements --> $DIR/ty-param-closure-outlives-from-where-clause.rs:43:26 | LL | with_signature(a, b, |x, y| { @@ -68,7 +68,7 @@ LL | | }) = note: number of external vids: 3 = note: where T: '_#2r -note: No external requirements +note: no external requirements --> $DIR/ty-param-closure-outlives-from-where-clause.rs:39:1 | LL | / fn correct_region<'a, T>(a: Cell<&'a ()>, b: T) @@ -82,7 +82,7 @@ LL | | } | = note: defining type: correct_region::<'_#1r, T> -note: External requirements +note: external requirements --> $DIR/ty-param-closure-outlives-from-where-clause.rs:64:26 | LL | with_signature(a, b, |x, y| { @@ -101,7 +101,7 @@ LL | | }) = note: number of external vids: 4 = note: where T: '_#2r -note: No external requirements +note: no external requirements --> $DIR/ty-param-closure-outlives-from-where-clause.rs:60:1 | LL | / fn wrong_region<'a, 'b, T>(a: Cell<&'a ()>, b: T) @@ -128,7 +128,7 @@ LL | | }) | = help: consider adding an explicit lifetime bound `T: ReFree(DefId(0:19 ~ ty_param_closure_outlives_from_where_clause[317d]::wrong_region[0]), BrNamed(DefId(0:20 ~ ty_param_closure_outlives_from_where_clause[317d]::wrong_region[0]::'a[0]), 'a))`... -note: External requirements +note: external requirements --> $DIR/ty-param-closure-outlives-from-where-clause.rs:77:26 | LL | with_signature(a, b, |x, y| { @@ -145,7 +145,7 @@ LL | | }) = note: number of external vids: 4 = note: where T: '_#3r -note: No external requirements +note: no external requirements --> $DIR/ty-param-closure-outlives-from-where-clause.rs:72:1 | LL | / fn outlives_region<'a, 'b, T>(a: Cell<&'a ()>, b: T) diff --git a/src/test/ui/no-landing-pads.rs b/src/test/ui/no-landing-pads.rs deleted file mode 100644 index d9d532106125a..0000000000000 --- a/src/test/ui/no-landing-pads.rs +++ /dev/null @@ -1,23 +0,0 @@ -// run-pass -// compile-flags: -Z no-landing-pads -C codegen-units=1 -// ignore-emscripten no threads support - -use std::thread; - -static mut HIT: bool = false; - -struct A; - -impl Drop for A { - fn drop(&mut self) { - unsafe { HIT = true; } - } -} - -fn main() { - thread::spawn(move|| -> () { - let _a = A; - panic!(); - }).join().unwrap_err(); - assert!(unsafe { !HIT }); -} diff --git a/src/test/ui/order-dependent-cast-inference.stderr b/src/test/ui/order-dependent-cast-inference.stderr index 081038c573acf..ad50b415869dd 100644 --- a/src/test/ui/order-dependent-cast-inference.stderr +++ b/src/test/ui/order-dependent-cast-inference.stderr @@ -6,7 +6,7 @@ LL | let mut y = 0 as *const _; | | | help: consider giving more type information | - = note: The type information given here is insufficient to check whether the pointer cast is valid + = note: the type information given here is insufficient to check whether the pointer cast is valid error: aborting due to previous error diff --git a/src/test/ui/panic-handler/panic-handler-duplicate.rs b/src/test/ui/panic-handler/panic-handler-duplicate.rs index caa130ef460f1..bd99af999c797 100644 --- a/src/test/ui/panic-handler/panic-handler-duplicate.rs +++ b/src/test/ui/panic-handler/panic-handler-duplicate.rs @@ -12,6 +12,6 @@ fn panic(info: &PanicInfo) -> ! { } #[lang = "panic_impl"] -fn panic2(info: &PanicInfo) -> ! { //~ ERROR duplicate lang item found: `panic_impl`. +fn panic2(info: &PanicInfo) -> ! { //~ ERROR found duplicate lang item `panic_impl` loop {} } diff --git a/src/test/ui/panic-handler/panic-handler-duplicate.stderr b/src/test/ui/panic-handler/panic-handler-duplicate.stderr index e9b1945364372..9999e3276469d 100644 --- a/src/test/ui/panic-handler/panic-handler-duplicate.stderr +++ b/src/test/ui/panic-handler/panic-handler-duplicate.stderr @@ -1,4 +1,4 @@ -error[E0152]: duplicate lang item found: `panic_impl`. +error[E0152]: found duplicate lang item `panic_impl` --> $DIR/panic-handler-duplicate.rs:15:1 | LL | / fn panic2(info: &PanicInfo) -> ! { @@ -6,7 +6,7 @@ LL | | loop {} LL | | } | |_^ | -note: first defined here. +note: first defined here --> $DIR/panic-handler-duplicate.rs:10:1 | LL | / fn panic(info: &PanicInfo) -> ! { diff --git a/src/test/ui/panic-handler/panic-handler-std.rs b/src/test/ui/panic-handler/panic-handler-std.rs index fffb5977871d8..0acc2722cb21f 100644 --- a/src/test/ui/panic-handler/panic-handler-std.rs +++ b/src/test/ui/panic-handler/panic-handler-std.rs @@ -1,4 +1,4 @@ -// error-pattern: duplicate lang item found: `panic_impl`. +// error-pattern: found duplicate lang item `panic_impl` use std::panic::PanicInfo; diff --git a/src/test/ui/panic-handler/panic-handler-std.stderr b/src/test/ui/panic-handler/panic-handler-std.stderr index e6d24348ca825..ac56513fd4706 100644 --- a/src/test/ui/panic-handler/panic-handler-std.stderr +++ b/src/test/ui/panic-handler/panic-handler-std.stderr @@ -1,4 +1,4 @@ -error[E0152]: duplicate lang item found: `panic_impl`. +error[E0152]: found duplicate lang item `panic_impl` --> $DIR/panic-handler-std.rs:7:1 | LL | / fn panic(info: PanicInfo) -> ! { @@ -6,7 +6,7 @@ LL | | loop {} LL | | } | |_^ | - = note: first defined in crate `std` (which `panic_handler_std` depends on). + = note: first defined in crate `std` (which `panic_handler_std` depends on) error: argument should be `&PanicInfo` --> $DIR/panic-handler-std.rs:7:16 diff --git a/src/test/ui/parser/chained-comparison-suggestion.rs b/src/test/ui/parser/chained-comparison-suggestion.rs new file mode 100644 index 0000000000000..0431196f1744e --- /dev/null +++ b/src/test/ui/parser/chained-comparison-suggestion.rs @@ -0,0 +1,40 @@ +// Check that we get nice suggestions when attempting a chained comparison. + +fn comp1() { + 1 < 2 <= 3; //~ ERROR comparison operators cannot be chained + //~^ ERROR mismatched types +} + +fn comp2() { + 1 < 2 < 3; //~ ERROR comparison operators cannot be chained +} + +fn comp3() { + 1 <= 2 < 3; //~ ERROR comparison operators cannot be chained + //~^ ERROR mismatched types +} + +fn comp4() { + 1 <= 2 <= 3; //~ ERROR comparison operators cannot be chained + //~^ ERROR mismatched types +} + +fn comp5() { + 1 > 2 >= 3; //~ ERROR comparison operators cannot be chained + //~^ ERROR mismatched types +} + +fn comp6() { + 1 > 2 > 3; //~ ERROR comparison operators cannot be chained +} + +fn comp7() { + 1 >= 2 > 3; //~ ERROR comparison operators cannot be chained +} + +fn comp8() { + 1 >= 2 >= 3; //~ ERROR comparison operators cannot be chained + //~^ ERROR mismatched types +} + +fn main() {} diff --git a/src/test/ui/parser/chained-comparison-suggestion.stderr b/src/test/ui/parser/chained-comparison-suggestion.stderr new file mode 100644 index 0000000000000..5c10a4599dd03 --- /dev/null +++ b/src/test/ui/parser/chained-comparison-suggestion.stderr @@ -0,0 +1,159 @@ +error: comparison operators cannot be chained + --> $DIR/chained-comparison-suggestion.rs:4:7 + | +LL | 1 < 2 <= 3; + | ^^^^^^ + | +help: split the comparison into two... + | +LL | 1 < 2 && 2 <= 3; + | ^^^^^^^^^^^^^ +help: ...or parenthesize one of the comparisons + | +LL | (1 < 2) <= 3; + | ^^^^^^^^^^ + +error: comparison operators cannot be chained + --> $DIR/chained-comparison-suggestion.rs:9:7 + | +LL | 1 < 2 < 3; + | ^^^^^ + | + = help: use `::<...>` instead of `<...>` to specify type arguments + = help: or use `(...)` if you meant to specify fn arguments +help: split the comparison into two... + | +LL | 1 < 2 && 2 < 3; + | ^^^^^^^^^^^^ +help: ...or parenthesize one of the comparisons + | +LL | (1 < 2) < 3; + | ^^^^^^^^^ + +error: comparison operators cannot be chained + --> $DIR/chained-comparison-suggestion.rs:13:7 + | +LL | 1 <= 2 < 3; + | ^^^^^^ + | +help: split the comparison into two... + | +LL | 1 <= 2 && 2 < 3; + | ^^^^^^^^^^^^^ +help: ...or parenthesize one of the comparisons + | +LL | (1 <= 2) < 3; + | ^^^^^^^^^^ + +error: comparison operators cannot be chained + --> $DIR/chained-comparison-suggestion.rs:18:7 + | +LL | 1 <= 2 <= 3; + | ^^^^^^^ + | +help: split the comparison into two... + | +LL | 1 <= 2 && 2 <= 3; + | ^^^^^^^^^^^^^^ +help: ...or parenthesize one of the comparisons + | +LL | (1 <= 2) <= 3; + | ^^^^^^^^^^^ + +error: comparison operators cannot be chained + --> $DIR/chained-comparison-suggestion.rs:23:7 + | +LL | 1 > 2 >= 3; + | ^^^^^^ + | +help: split the comparison into two... + | +LL | 1 > 2 && 2 >= 3; + | ^^^^^^^^^^^^^ +help: ...or parenthesize one of the comparisons + | +LL | (1 > 2) >= 3; + | ^^^^^^^^^^ + +error: comparison operators cannot be chained + --> $DIR/chained-comparison-suggestion.rs:28:7 + | +LL | 1 > 2 > 3; + | ^^^^^ + | + = help: use `::<...>` instead of `<...>` to specify type arguments + = help: or use `(...)` if you meant to specify fn arguments +help: split the comparison into two... + | +LL | 1 > 2 && 2 > 3; + | ^^^^^^^^^^^^ +help: ...or parenthesize one of the comparisons + | +LL | (1 > 2) > 3; + | ^^^^^^^^^ + +error: comparison operators cannot be chained + --> $DIR/chained-comparison-suggestion.rs:32:7 + | +LL | 1 >= 2 > 3; + | ^^^^^^ + | + = help: use `::<...>` instead of `<...>` to specify type arguments + = help: or use `(...)` if you meant to specify fn arguments +help: split the comparison into two... + | +LL | 1 >= 2 && 2 > 3; + | ^^^^^^^^^^^^^ +help: ...or parenthesize one of the comparisons + | +LL | (1 >= 2) > 3; + | ^^^^^^^^^^ + +error: comparison operators cannot be chained + --> $DIR/chained-comparison-suggestion.rs:36:7 + | +LL | 1 >= 2 >= 3; + | ^^^^^^^ + | +help: split the comparison into two... + | +LL | 1 >= 2 && 2 >= 3; + | ^^^^^^^^^^^^^^ +help: ...or parenthesize one of the comparisons + | +LL | (1 >= 2) >= 3; + | ^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/chained-comparison-suggestion.rs:4:14 + | +LL | 1 < 2 <= 3; + | ^ expected `bool`, found integer + +error[E0308]: mismatched types + --> $DIR/chained-comparison-suggestion.rs:13:14 + | +LL | 1 <= 2 < 3; + | ^ expected `bool`, found integer + +error[E0308]: mismatched types + --> $DIR/chained-comparison-suggestion.rs:18:15 + | +LL | 1 <= 2 <= 3; + | ^ expected `bool`, found integer + +error[E0308]: mismatched types + --> $DIR/chained-comparison-suggestion.rs:23:14 + | +LL | 1 > 2 >= 3; + | ^ expected `bool`, found integer + +error[E0308]: mismatched types + --> $DIR/chained-comparison-suggestion.rs:36:15 + | +LL | 1 >= 2 >= 3; + | ^ expected `bool`, found integer + +error: aborting due to 13 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/parser/require-parens-for-chained-comparison.rs b/src/test/ui/parser/require-parens-for-chained-comparison.rs index 9c7a25d589a1f..e27b03dddc5be 100644 --- a/src/test/ui/parser/require-parens-for-chained-comparison.rs +++ b/src/test/ui/parser/require-parens-for-chained-comparison.rs @@ -3,24 +3,26 @@ struct X; fn main() { false == false == false; - //~^ ERROR chained comparison operators require parentheses + //~^ ERROR comparison operators cannot be chained false == 0 < 2; - //~^ ERROR chained comparison operators require parentheses + //~^ ERROR comparison operators cannot be chained //~| ERROR mismatched types //~| ERROR mismatched types f(); - //~^ ERROR chained comparison operators require parentheses + //~^ ERROR comparison operators cannot be chained //~| HELP use `::<...>` instead of `<...>` to specify type arguments f, Option>>(1, 2); - //~^ ERROR chained comparison operators require parentheses + //~^ ERROR comparison operators cannot be chained + //~| HELP split the comparison into two... + //~| ...or parenthesize one of the comparisons //~| HELP use `::<...>` instead of `<...>` to specify type arguments use std::convert::identity; let _ = identity; - //~^ ERROR chained comparison operators require parentheses + //~^ ERROR comparison operators cannot be chained //~| HELP use `::<...>` instead of `<...>` to specify type arguments //~| HELP or use `(...)` if you meant to specify fn arguments } diff --git a/src/test/ui/parser/require-parens-for-chained-comparison.stderr b/src/test/ui/parser/require-parens-for-chained-comparison.stderr index bece9a388008c..44edf2de7f8de 100644 --- a/src/test/ui/parser/require-parens-for-chained-comparison.stderr +++ b/src/test/ui/parser/require-parens-for-chained-comparison.stderr @@ -1,16 +1,16 @@ -error: chained comparison operators require parentheses +error: comparison operators cannot be chained --> $DIR/require-parens-for-chained-comparison.rs:5:11 | LL | false == false == false; | ^^^^^^^^^^^ -error: chained comparison operators require parentheses +error: comparison operators cannot be chained --> $DIR/require-parens-for-chained-comparison.rs:8:11 | LL | false == 0 < 2; | ^^^^^^ -error: chained comparison operators require parentheses +error: comparison operators cannot be chained --> $DIR/require-parens-for-chained-comparison.rs:13:6 | LL | f(); @@ -21,19 +21,27 @@ help: use `::<...>` instead of `<...>` to specify type arguments LL | f::(); | ^^ -error: chained comparison operators require parentheses +error: comparison operators cannot be chained --> $DIR/require-parens-for-chained-comparison.rs:17:6 | LL | f, Option>>(1, 2); | ^^^^^^^^ | +help: split the comparison into two... + | +LL | f < Result && Result , Option>>(1, 2); + | ^^^^^^^^^^^^^^^^^^^^^^ +help: ...or parenthesize one of the comparisons + | +LL | (f < Result) , Option>>(1, 2); + | ^^^^^^^^^^^^^^ help: use `::<...>` instead of `<...>` to specify type arguments | LL | f::, Option>>(1, 2); | ^^ -error: chained comparison operators require parentheses - --> $DIR/require-parens-for-chained-comparison.rs:22:21 +error: comparison operators cannot be chained + --> $DIR/require-parens-for-chained-comparison.rs:24:21 | LL | let _ = identity; | ^^^^ diff --git a/src/test/ui/pattern/const-pat-ice.stderr b/src/test/ui/pattern/const-pat-ice.stderr index 7a0f14425b746..0661014c581fb 100644 --- a/src/test/ui/pattern/const-pat-ice.stderr +++ b/src/test/ui/pattern/const-pat-ice.stderr @@ -1,5 +1,5 @@ thread 'rustc' panicked at 'assertion failed: rows.iter().all(|r| r.len() == v.len())', src/librustc_mir/hair/pattern/_match.rs:LL:CC -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace error: internal compiler error: unexpected panic diff --git a/src/test/ui/resolve/impl-items-vis-unresolved.rs b/src/test/ui/resolve/impl-items-vis-unresolved.rs index 9b4fe498239b6..1494c1cf96800 100644 --- a/src/test/ui/resolve/impl-items-vis-unresolved.rs +++ b/src/test/ui/resolve/impl-items-vis-unresolved.rs @@ -18,7 +18,8 @@ mod state { pub struct RawFloatState; impl RawFloatState { perftools_inline! { - pub(super) fn new() {} //~ ERROR failed to resolve: there are too many initial `super`s + pub(super) fn new() {} + //~^ ERROR failed to resolve: there are too many leading `super` keywords } } diff --git a/src/test/ui/resolve/impl-items-vis-unresolved.stderr b/src/test/ui/resolve/impl-items-vis-unresolved.stderr index 8e285e5312400..f2293d28ea151 100644 --- a/src/test/ui/resolve/impl-items-vis-unresolved.stderr +++ b/src/test/ui/resolve/impl-items-vis-unresolved.stderr @@ -1,8 +1,8 @@ -error[E0433]: failed to resolve: there are too many initial `super`s. +error[E0433]: failed to resolve: there are too many leading `super` keywords --> $DIR/impl-items-vis-unresolved.rs:21:13 | LL | pub(super) fn new() {} - | ^^^^^ there are too many initial `super`s. + | ^^^^^ there are too many leading `super` keywords error: aborting due to previous error diff --git a/src/test/ui/suffixed-literal-meta.stderr b/src/test/ui/suffixed-literal-meta.stderr index ee35b53abe111..84fe91d662a8b 100644 --- a/src/test/ui/suffixed-literal-meta.stderr +++ b/src/test/ui/suffixed-literal-meta.stderr @@ -4,7 +4,7 @@ error: suffixed literals are not allowed in attributes LL | #[rustc_dummy = 1usize] | ^^^^^^ | - = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.) error: suffixed literals are not allowed in attributes --> $DIR/suffixed-literal-meta.rs:5:17 @@ -12,7 +12,7 @@ error: suffixed literals are not allowed in attributes LL | #[rustc_dummy = 1u8] | ^^^ | - = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.) error: suffixed literals are not allowed in attributes --> $DIR/suffixed-literal-meta.rs:7:17 @@ -20,7 +20,7 @@ error: suffixed literals are not allowed in attributes LL | #[rustc_dummy = 1u16] | ^^^^ | - = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.) error: suffixed literals are not allowed in attributes --> $DIR/suffixed-literal-meta.rs:9:17 @@ -28,7 +28,7 @@ error: suffixed literals are not allowed in attributes LL | #[rustc_dummy = 1u32] | ^^^^ | - = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.) error: suffixed literals are not allowed in attributes --> $DIR/suffixed-literal-meta.rs:11:17 @@ -36,7 +36,7 @@ error: suffixed literals are not allowed in attributes LL | #[rustc_dummy = 1u64] | ^^^^ | - = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.) error: suffixed literals are not allowed in attributes --> $DIR/suffixed-literal-meta.rs:13:17 @@ -44,7 +44,7 @@ error: suffixed literals are not allowed in attributes LL | #[rustc_dummy = 1isize] | ^^^^^^ | - = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.) error: suffixed literals are not allowed in attributes --> $DIR/suffixed-literal-meta.rs:15:17 @@ -52,7 +52,7 @@ error: suffixed literals are not allowed in attributes LL | #[rustc_dummy = 1i8] | ^^^ | - = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.) error: suffixed literals are not allowed in attributes --> $DIR/suffixed-literal-meta.rs:17:17 @@ -60,7 +60,7 @@ error: suffixed literals are not allowed in attributes LL | #[rustc_dummy = 1i16] | ^^^^ | - = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.) error: suffixed literals are not allowed in attributes --> $DIR/suffixed-literal-meta.rs:19:17 @@ -68,7 +68,7 @@ error: suffixed literals are not allowed in attributes LL | #[rustc_dummy = 1i32] | ^^^^ | - = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.) error: suffixed literals are not allowed in attributes --> $DIR/suffixed-literal-meta.rs:21:17 @@ -76,7 +76,7 @@ error: suffixed literals are not allowed in attributes LL | #[rustc_dummy = 1i64] | ^^^^ | - = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.) error: suffixed literals are not allowed in attributes --> $DIR/suffixed-literal-meta.rs:23:17 @@ -84,7 +84,7 @@ error: suffixed literals are not allowed in attributes LL | #[rustc_dummy = 1.0f32] | ^^^^^^ | - = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.) error: suffixed literals are not allowed in attributes --> $DIR/suffixed-literal-meta.rs:25:17 @@ -92,7 +92,7 @@ error: suffixed literals are not allowed in attributes LL | #[rustc_dummy = 1.0f64] | ^^^^^^ | - = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.) error: suffixed literals are not allowed in attributes --> $DIR/suffixed-literal-meta.rs:3:17 @@ -100,7 +100,7 @@ error: suffixed literals are not allowed in attributes LL | #[rustc_dummy = 1usize] | ^^^^^^ | - = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.) error: suffixed literals are not allowed in attributes --> $DIR/suffixed-literal-meta.rs:5:17 @@ -108,7 +108,7 @@ error: suffixed literals are not allowed in attributes LL | #[rustc_dummy = 1u8] | ^^^ | - = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.) error: suffixed literals are not allowed in attributes --> $DIR/suffixed-literal-meta.rs:7:17 @@ -116,7 +116,7 @@ error: suffixed literals are not allowed in attributes LL | #[rustc_dummy = 1u16] | ^^^^ | - = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.) error: suffixed literals are not allowed in attributes --> $DIR/suffixed-literal-meta.rs:9:17 @@ -124,7 +124,7 @@ error: suffixed literals are not allowed in attributes LL | #[rustc_dummy = 1u32] | ^^^^ | - = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.) error: suffixed literals are not allowed in attributes --> $DIR/suffixed-literal-meta.rs:11:17 @@ -132,7 +132,7 @@ error: suffixed literals are not allowed in attributes LL | #[rustc_dummy = 1u64] | ^^^^ | - = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.) error: suffixed literals are not allowed in attributes --> $DIR/suffixed-literal-meta.rs:13:17 @@ -140,7 +140,7 @@ error: suffixed literals are not allowed in attributes LL | #[rustc_dummy = 1isize] | ^^^^^^ | - = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.) error: suffixed literals are not allowed in attributes --> $DIR/suffixed-literal-meta.rs:15:17 @@ -148,7 +148,7 @@ error: suffixed literals are not allowed in attributes LL | #[rustc_dummy = 1i8] | ^^^ | - = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.) error: suffixed literals are not allowed in attributes --> $DIR/suffixed-literal-meta.rs:17:17 @@ -156,7 +156,7 @@ error: suffixed literals are not allowed in attributes LL | #[rustc_dummy = 1i16] | ^^^^ | - = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.) error: suffixed literals are not allowed in attributes --> $DIR/suffixed-literal-meta.rs:19:17 @@ -164,7 +164,7 @@ error: suffixed literals are not allowed in attributes LL | #[rustc_dummy = 1i32] | ^^^^ | - = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.) error: suffixed literals are not allowed in attributes --> $DIR/suffixed-literal-meta.rs:21:17 @@ -172,7 +172,7 @@ error: suffixed literals are not allowed in attributes LL | #[rustc_dummy = 1i64] | ^^^^ | - = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.) error: suffixed literals are not allowed in attributes --> $DIR/suffixed-literal-meta.rs:23:17 @@ -180,7 +180,7 @@ error: suffixed literals are not allowed in attributes LL | #[rustc_dummy = 1.0f32] | ^^^^^^ | - = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.) error: suffixed literals are not allowed in attributes --> $DIR/suffixed-literal-meta.rs:25:17 @@ -188,7 +188,7 @@ error: suffixed literals are not allowed in attributes LL | #[rustc_dummy = 1.0f64] | ^^^^^^ | - = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.) error: aborting due to 24 previous errors diff --git a/src/test/ui/super-at-top-level.rs b/src/test/ui/super-at-top-level.rs index 41360df77994e..e4d587bc9effa 100644 --- a/src/test/ui/super-at-top-level.rs +++ b/src/test/ui/super-at-top-level.rs @@ -1,4 +1,4 @@ -use super::f; //~ ERROR there are too many initial `super`s +use super::f; //~ ERROR there are too many leading `super` keywords fn main() { } diff --git a/src/test/ui/super-at-top-level.stderr b/src/test/ui/super-at-top-level.stderr index d04ce384fe886..23613df6752fb 100644 --- a/src/test/ui/super-at-top-level.stderr +++ b/src/test/ui/super-at-top-level.stderr @@ -1,8 +1,8 @@ -error[E0433]: failed to resolve: there are too many initial `super`s. +error[E0433]: failed to resolve: there are too many leading `super` keywords --> $DIR/super-at-top-level.rs:1:5 | LL | use super::f; - | ^^^^^ there are too many initial `super`s. + | ^^^^^ there are too many leading `super` keywords error: aborting due to previous error diff --git a/src/test/ui/test-attrs/test-should-panic-attr.stderr b/src/test/ui/test-attrs/test-should-panic-attr.stderr index 4b032eba5f8d5..d7d0d84432ce6 100644 --- a/src/test/ui/test-attrs/test-should-panic-attr.stderr +++ b/src/test/ui/test-attrs/test-should-panic-attr.stderr @@ -4,7 +4,7 @@ warning: argument must be of the form: `expected = "error message"` LL | #[should_panic(expected)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: Errors in this attribute were erroneously allowed and will become a hard error in a future release. + = note: errors in this attribute were erroneously allowed and will become a hard error in a future release. warning: argument must be of the form: `expected = "error message"` --> $DIR/test-should-panic-attr.rs:18:1 @@ -12,7 +12,7 @@ warning: argument must be of the form: `expected = "error message"` LL | #[should_panic(expect)] | ^^^^^^^^^^^^^^^^^^^^^^^ | - = note: Errors in this attribute were erroneously allowed and will become a hard error in a future release. + = note: errors in this attribute were erroneously allowed and will become a hard error in a future release. warning: argument must be of the form: `expected = "error message"` --> $DIR/test-should-panic-attr.rs:25:1 @@ -20,7 +20,7 @@ warning: argument must be of the form: `expected = "error message"` LL | #[should_panic(expected(foo, bar))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: Errors in this attribute were erroneously allowed and will become a hard error in a future release. + = note: errors in this attribute were erroneously allowed and will become a hard error in a future release. warning: argument must be of the form: `expected = "error message"` --> $DIR/test-should-panic-attr.rs:32:1 @@ -28,5 +28,5 @@ warning: argument must be of the form: `expected = "error message"` LL | #[should_panic(expected = "foo", bar)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: Errors in this attribute were erroneously allowed and will become a hard error in a future release. + = note: errors in this attribute were erroneously allowed and will become a hard error in a future release. diff --git a/src/test/ui/test-panic-abort.run.stdout b/src/test/ui/test-panic-abort.run.stdout index 0c8bc5020871b..46adcfbc2eb4a 100644 --- a/src/test/ui/test-panic-abort.run.stdout +++ b/src/test/ui/test-panic-abort.run.stdout @@ -18,7 +18,7 @@ testing321 thread 'main' panicked at 'assertion failed: `(left == right)` left: `2`, right: `5`', $DIR/test-panic-abort.rs:31:5 -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace failures: diff --git a/src/test/ui/traits/trait-bounds-same-crate-name.rs b/src/test/ui/traits/trait-bounds-same-crate-name.rs index af720ecfdc063..1012edb109336 100644 --- a/src/test/ui/traits/trait-bounds-same-crate-name.rs +++ b/src/test/ui/traits/trait-bounds-same-crate-name.rs @@ -31,7 +31,7 @@ fn main() { a::try_foo(foo); //~^ ERROR E0277 //~| trait impl with same name found - //~| Perhaps two different versions of crate `crate_a2` + //~| perhaps two different versions of crate `crate_a2` // We don't want to see the "version mismatch" help message here // because `implements_no_traits` has no impl for `Foo` diff --git a/src/test/ui/traits/trait-bounds-same-crate-name.stderr b/src/test/ui/traits/trait-bounds-same-crate-name.stderr index 8fd0bd13e54b3..8a6e059604d2b 100644 --- a/src/test/ui/traits/trait-bounds-same-crate-name.stderr +++ b/src/test/ui/traits/trait-bounds-same-crate-name.stderr @@ -14,7 +14,7 @@ help: trait impl with same name found | LL | impl Bar for Foo {} | ^^^^^^^^^^^^^^^^^^^ - = note: Perhaps two different versions of crate `crate_a2` are being used? + = note: perhaps two different versions of crate `crate_a2` are being used? error[E0277]: the trait bound `main::a::DoesNotImplementTrait: main::a::Bar` is not satisfied --> $DIR/trait-bounds-same-crate-name.rs:38:20 @@ -43,7 +43,7 @@ help: trait impl with same name found | LL | impl Bar for ImplementsWrongTraitConditionally {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: Perhaps two different versions of crate `crate_a2` are being used? + = note: perhaps two different versions of crate `crate_a2` are being used? error[E0277]: the trait bound `main::a::ImplementsTraitForUsize: main::a::Bar` is not satisfied --> $DIR/trait-bounds-same-crate-name.rs:51:20 diff --git a/src/test/ui/unboxed-closures/unboxed-closures-static-call-wrong-trait.stderr b/src/test/ui/unboxed-closures/unboxed-closures-static-call-wrong-trait.stderr index 2d058521e4ef6..0b6d94e71f0c7 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-static-call-wrong-trait.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-static-call-wrong-trait.stderr @@ -4,7 +4,7 @@ error[E0599]: no method named `call` found for closure `[closure@$DIR/unboxed-cl LL | mut_.call((0, )); | ^^^^ method not found in `[closure@$DIR/unboxed-closures-static-call-wrong-trait.rs:6:26: 6:31]` | - = note: mut_ is a function, perhaps you wish to call it + = note: `mut_` is a function, perhaps you wish to call it error: aborting due to previous error diff --git a/src/tools/tidy/src/pal.rs b/src/tools/tidy/src/pal.rs index dcd4c9e8ef7d9..31fc6f10e8296 100644 --- a/src/tools/tidy/src/pal.rs +++ b/src/tools/tidy/src/pal.rs @@ -59,6 +59,8 @@ const EXCEPTION_PATHS: &[&str] = &[ "src/libstd/sys_common/mod.rs", "src/libstd/sys_common/net.rs", "src/libstd/sys_common/backtrace.rs", + // panic_unwind shims + "src/libstd/panicking.rs", "src/libterm", // Not sure how to make this crate portable, but test crate needs it. "src/libtest", // Probably should defer to unstable `std::sys` APIs. "src/libstd/sync/mpsc", // some tests are only run on non-emscripten