Skip to content

Commit cba96eb

Browse files
committed
Fix 2018 idiom lints
This lint is allow by default, which is why this wasn't spotted earlier. It's denied by rust-lang/rust, so it's good to warn about it here so it can be fixed more quickly.
1 parent 15babf5 commit cba96eb

File tree

7 files changed

+12
-9
lines changed

7 files changed

+12
-9
lines changed

crates/assert-instr-macro/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//! The procedural macro here is relatively simple, it simply appends a
88
//! `#[test]` function to the original token stream which asserts that the
99
//! function itself contains the relevant instruction.
10+
#![deny(rust_2018_idioms)]
1011

1112
extern crate proc_macro;
1213
extern crate proc_macro2;
@@ -177,7 +178,7 @@ struct Invoc {
177178
}
178179

179180
impl syn::parse::Parse for Invoc {
180-
fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {
181+
fn parse(input: syn::parse::ParseStream<'_>) -> syn::Result<Self> {
181182
use syn::{ext::IdentExt, Token};
182183

183184
let mut instr = String::new();

crates/core_arch/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#![allow(improper_ctypes_definitions)]
33
#![allow(dead_code)]
44
#![allow(unused_features)]
5+
#![deny(rust_2018_idioms)]
56
#![feature(
67
asm,
78
const_fn,

crates/simd-test-macro/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//!
33
//! This macro expands to a `#[test]` function which tests the local machine
44
//! for the appropriate cfg before calling the inner test function.
5+
#![deny(rust_2018_idioms)]
56

67
extern crate proc_macro;
78
extern crate proc_macro2;

crates/std_detect/src/detect/os/linux/cpuinfo.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ impl CpuInfo {
1717
})
1818
}
1919
/// Returns the value of the cpuinfo `field`.
20-
pub(crate) fn field(&self, field: &str) -> CpuInfoField {
20+
pub(crate) fn field(&self, field: &str) -> CpuInfoField<'_> {
2121
for l in self.raw.lines() {
2222
if l.trim().starts_with(field) {
2323
return CpuInfoField::new(l.split(": ").nth(1));

crates/std_detect/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@
1313
1414
#![unstable(feature = "stdsimd", issue = "27731")]
1515
#![feature(const_fn, staged_api, stdsimd, doc_cfg, allow_internal_unstable)]
16+
#![deny(rust_2018_idioms)]
1617
#![allow(clippy::shadow_reuse)]
1718
#![deny(clippy::missing_inline_in_public_items)]
1819
#![cfg_attr(all(target_os = "freebsd", target_arch = "aarch64"), feature(asm))]
1920
#![cfg_attr(test, allow(unused_imports))]
2021
#![cfg_attr(feature = "std_detect_file_io", feature(vec_spare_capacity))]
2122
#![no_std]
2223

23-
#[cfg_attr(feature = "rustc-dep-of-std", allow(unused_extern_crates))]
24+
// rust-lang/rust#83888: removing `extern crate` gives an error that `vec_spare_capacity` is unknown
25+
#[cfg_attr(feature = "std_detect_file_io", allow(unused_extern_crates))]
2426
#[cfg(feature = "std_detect_file_io")]
2527
extern crate alloc;
2628

crates/stdarch-test/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
//! output once globally and then provides the `assert` function which makes
55
//! assertions about the disassembly of a function.
66
#![feature(test)] // For black_box
7+
#![deny(rust_2018_idioms)]
78
#![allow(clippy::missing_docs_in_private_items, clippy::print_stdout)]
89

910
extern crate assert_instr_macro;
10-
extern crate cc;
1111
#[macro_use]
1212
extern crate lazy_static;
13-
extern crate rustc_demangle;
1413
extern crate simd_test_macro;
1514
#[macro_use]
1615
extern crate cfg_if;

crates/stdarch-verify/src/lib.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
extern crate proc_macro;
2-
extern crate proc_macro2;
1+
#![deny(rust_2018_idioms)]
32
#[macro_use]
43
extern crate quote;
54
#[macro_use]
@@ -357,7 +356,7 @@ fn find_instrs(attrs: &[syn::Attribute]) -> Vec<String> {
357356
// TODO: should probably just reuse `Invoc` from the `assert-instr-macro`
358357
// crate.
359358
impl syn::parse::Parse for AssertInstr {
360-
fn parse(content: syn::parse::ParseStream) -> syn::Result<Self> {
359+
fn parse(content: syn::parse::ParseStream<'_>) -> syn::Result<Self> {
361360
let input;
362361
parenthesized!(input in content);
363362
let _ = input.parse::<syn::Meta>()?;
@@ -443,7 +442,7 @@ struct RustcArgsRequiredConst {
443442
}
444443

445444
impl syn::parse::Parse for RustcArgsRequiredConst {
446-
fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {
445+
fn parse(input: syn::parse::ParseStream<'_>) -> syn::Result<Self> {
447446
let content;
448447
parenthesized!(content in input);
449448
let list =

0 commit comments

Comments
 (0)