diff --git a/crates/assert-instr-macro/src/lib.rs b/crates/assert-instr-macro/src/lib.rs index 7f2c9902e2..0b3d5b725d 100644 --- a/crates/assert-instr-macro/src/lib.rs +++ b/crates/assert-instr-macro/src/lib.rs @@ -7,6 +7,7 @@ //! The procedural macro here is relatively simple, it simply appends a //! `#[test]` function to the original token stream which asserts that the //! function itself contains the relevant instruction. +#![deny(rust_2018_idioms)] extern crate proc_macro; extern crate proc_macro2; @@ -162,7 +163,7 @@ struct Invoc { } impl syn::parse::Parse for Invoc { - fn parse(input: syn::parse::ParseStream) -> syn::Result { + fn parse(input: syn::parse::ParseStream<'_>) -> syn::Result { use syn::{ext::IdentExt, Token}; let mut instr = String::new(); diff --git a/crates/core_arch/src/lib.rs b/crates/core_arch/src/lib.rs index 57fa44bd8b..a8f1875781 100644 --- a/crates/core_arch/src/lib.rs +++ b/crates/core_arch/src/lib.rs @@ -2,6 +2,7 @@ #![allow(improper_ctypes_definitions)] #![allow(dead_code)] #![allow(unused_features)] +#![deny(rust_2018_idioms)] #![feature( asm, const_fn, @@ -69,9 +70,6 @@ extern crate std; #[cfg(test)] #[macro_use] extern crate std_detect; -#[cfg(test)] -extern crate stdarch_test; - #[path = "mod.rs"] mod core_arch; diff --git a/crates/core_arch/src/x86/avx512vpclmulqdq.rs b/crates/core_arch/src/x86/avx512vpclmulqdq.rs index 831ab7f642..860fea46fc 100644 --- a/crates/core_arch/src/x86/avx512vpclmulqdq.rs +++ b/crates/core_arch/src/x86/avx512vpclmulqdq.rs @@ -9,7 +9,7 @@ use crate::core_arch::x86::__m256i; use crate::core_arch::x86::__m512i; #[cfg(test)] -use crate::stdarch_test::assert_instr; +use stdarch_test::assert_instr; #[allow(improper_ctypes)] extern "C" { diff --git a/crates/core_arch/src/x86/fxsr.rs b/crates/core_arch/src/x86/fxsr.rs index b1bac1a0ac..4a39bb8de9 100644 --- a/crates/core_arch/src/x86/fxsr.rs +++ b/crates/core_arch/src/x86/fxsr.rs @@ -87,7 +87,7 @@ mod tests { } impl fmt::Debug for FxsaveArea { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "[")?; for i in 0..self.data.len() { write!(f, "{}", self.data[i])?; diff --git a/crates/core_arch/src/x86/pclmulqdq.rs b/crates/core_arch/src/x86/pclmulqdq.rs index 0e1bebae9e..a9d5167b91 100644 --- a/crates/core_arch/src/x86/pclmulqdq.rs +++ b/crates/core_arch/src/x86/pclmulqdq.rs @@ -8,7 +8,7 @@ use crate::core_arch::x86::__m128i; #[cfg(test)] -use crate::stdarch_test::assert_instr; +use stdarch_test::assert_instr; #[allow(improper_ctypes)] extern "C" { diff --git a/crates/core_arch/src/x86/xsave.rs b/crates/core_arch/src/x86/xsave.rs index 5e2148840b..30f807e447 100644 --- a/crates/core_arch/src/x86/xsave.rs +++ b/crates/core_arch/src/x86/xsave.rs @@ -196,7 +196,7 @@ mod tests { } impl fmt::Debug for XsaveArea { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "[")?; for i in 0..self.data.len() { write!(f, "{}", self.data[i])?; diff --git a/crates/core_arch/src/x86_64/fxsr.rs b/crates/core_arch/src/x86_64/fxsr.rs index ef7e311cfc..4274b4c476 100644 --- a/crates/core_arch/src/x86_64/fxsr.rs +++ b/crates/core_arch/src/x86_64/fxsr.rs @@ -87,7 +87,7 @@ mod tests { } impl fmt::Debug for FxsaveArea { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "[")?; for i in 0..self.data.len() { write!(f, "{}", self.data[i])?; diff --git a/crates/core_arch/src/x86_64/xsave.rs b/crates/core_arch/src/x86_64/xsave.rs index 215e5a541e..2afd3e433a 100644 --- a/crates/core_arch/src/x86_64/xsave.rs +++ b/crates/core_arch/src/x86_64/xsave.rs @@ -164,7 +164,7 @@ mod tests { } impl fmt::Debug for XsaveArea { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "[")?; for i in 0..self.data.len() { write!(f, "{}", self.data[i])?; diff --git a/crates/simd-test-macro/src/lib.rs b/crates/simd-test-macro/src/lib.rs index 8e65c43992..4c863ae701 100644 --- a/crates/simd-test-macro/src/lib.rs +++ b/crates/simd-test-macro/src/lib.rs @@ -2,6 +2,7 @@ //! //! This macro expands to a `#[test]` function which tests the local machine //! for the appropriate cfg before calling the inner test function. +#![deny(rust_2018_idioms)] extern crate proc_macro; extern crate proc_macro2; diff --git a/crates/std_detect/src/detect/os/linux/cpuinfo.rs b/crates/std_detect/src/detect/os/linux/cpuinfo.rs index 1f403df01f..91279b9ed7 100644 --- a/crates/std_detect/src/detect/os/linux/cpuinfo.rs +++ b/crates/std_detect/src/detect/os/linux/cpuinfo.rs @@ -17,7 +17,7 @@ impl CpuInfo { }) } /// Returns the value of the cpuinfo `field`. - pub(crate) fn field(&self, field: &str) -> CpuInfoField { + pub(crate) fn field(&self, field: &str) -> CpuInfoField<'_> { for l in self.raw.lines() { if l.trim().starts_with(field) { return CpuInfoField::new(l.split(": ").nth(1)); diff --git a/crates/std_detect/src/lib.rs b/crates/std_detect/src/lib.rs index a5e09f74ee..782833cbb6 100644 --- a/crates/std_detect/src/lib.rs +++ b/crates/std_detect/src/lib.rs @@ -13,6 +13,7 @@ #![unstable(feature = "stdsimd", issue = "27731")] #![feature(const_fn, staged_api, stdsimd, doc_cfg, allow_internal_unstable)] +#![deny(rust_2018_idioms)] #![allow(clippy::shadow_reuse)] #![deny(clippy::missing_inline_in_public_items)] #![cfg_attr(all(target_os = "freebsd", target_arch = "aarch64"), feature(llvm_asm))] @@ -20,7 +21,8 @@ #![cfg_attr(feature = "std_detect_file_io", feature(vec_spare_capacity))] #![no_std] -#[cfg_attr(feature = "rustc-dep-of-std", allow(unused_extern_crates))] +// rust-lang/rust#83888: removing `extern crate` gives an error that `vec_spare_capacity` is unknown +#[cfg_attr(feature = "std_detect_file_io", allow(unused_extern_crates))] #[cfg(feature = "std_detect_file_io")] extern crate alloc; diff --git a/crates/stdarch-test/src/lib.rs b/crates/stdarch-test/src/lib.rs index 88409f5dd4..25852c9479 100644 --- a/crates/stdarch-test/src/lib.rs +++ b/crates/stdarch-test/src/lib.rs @@ -4,13 +4,12 @@ //! output once globally and then provides the `assert` function which makes //! assertions about the disassembly of a function. #![feature(test)] // For black_box +#![deny(rust_2018_idioms)] #![allow(clippy::missing_docs_in_private_items, clippy::print_stdout)] extern crate assert_instr_macro; -extern crate cc; #[macro_use] extern crate lazy_static; -extern crate rustc_demangle; extern crate simd_test_macro; #[macro_use] extern crate cfg_if; diff --git a/crates/stdarch-verify/src/lib.rs b/crates/stdarch-verify/src/lib.rs index 4aa969ba51..44e6fdc1fd 100644 --- a/crates/stdarch-verify/src/lib.rs +++ b/crates/stdarch-verify/src/lib.rs @@ -1,5 +1,4 @@ -extern crate proc_macro; -extern crate proc_macro2; +#![deny(rust_2018_idioms)] #[macro_use] extern crate quote; #[macro_use] @@ -324,7 +323,7 @@ fn find_instrs(attrs: &[syn::Attribute]) -> Vec { // TODO: should probably just reuse `Invoc` from the `assert-instr-macro` // crate. impl syn::parse::Parse for AssertInstr { - fn parse(content: syn::parse::ParseStream) -> syn::Result { + fn parse(content: syn::parse::ParseStream<'_>) -> syn::Result { let input; parenthesized!(input in content); let _ = input.parse::()?; @@ -410,7 +409,7 @@ struct RustcArgsRequiredConst { } impl syn::parse::Parse for RustcArgsRequiredConst { - fn parse(input: syn::parse::ParseStream) -> syn::Result { + fn parse(input: syn::parse::ParseStream<'_>) -> syn::Result { let content; parenthesized!(content in input); let list =