From c6549681008a09b9a267f1470fe959b428d69736 Mon Sep 17 00:00:00 2001 From: Oliver Middleton Date: Thu, 17 Jan 2019 09:22:52 +0000 Subject: [PATCH 01/11] Deny the `overflowing_literals` lint for all editions --- .../src/lints/listing/deny-by-default.md | 20 +++++++++++++++++++ .../src/lints/listing/warn-by-default.md | 20 ------------------- src/librustc_lint/types.rs | 6 ++---- .../deny-overflowing-literals.rs} | 2 -- .../deny-overflowing-literals.stderr} | 2 +- src/test/ui/lint/lint-type-limits2.rs | 1 + src/test/ui/lint/lint-type-limits2.stderr | 10 +++++++--- src/test/ui/lint/lint-type-limits3.rs | 1 + src/test/ui/lint/lint-type-limits3.stderr | 10 +++++++--- src/test/ui/lint/type-overflow.rs | 1 + src/test/ui/lint/type-overflow.stderr | 20 +++++++++++-------- 11 files changed, 52 insertions(+), 41 deletions(-) rename src/test/ui/{editions/edition-deny-overflowing-literals-2018.rs => lint/deny-overflowing-literals.rs} (82%) rename src/test/ui/{editions/edition-deny-overflowing-literals-2018.stderr => lint/deny-overflowing-literals.stderr} (76%) diff --git a/src/doc/rustc/src/lints/listing/deny-by-default.md b/src/doc/rustc/src/lints/listing/deny-by-default.md index ff9e0235a0435..fa62d1a03f53b 100644 --- a/src/doc/rustc/src/lints/listing/deny-by-default.md +++ b/src/doc/rustc/src/lints/listing/deny-by-default.md @@ -149,6 +149,26 @@ error: const items should never be #[no_mangle] | ``` +## overflowing-literals + +This lint detects literal out of range for its type. Some +example code that triggers this lint: + +```rust,compile_fail +let x: u8 = 1000; +``` + +This will produce: + +```text +error: literal out of range for u8 + --> src/main.rs:2:17 + | +2 | let x: u8 = 1000; + | ^^^^ + | +``` + ## parenthesized-params-in-types-and-modules This lint detects incorrect parentheses. Some example code that triggers this diff --git a/src/doc/rustc/src/lints/listing/warn-by-default.md b/src/doc/rustc/src/lints/listing/warn-by-default.md index 7fbbe686b5bd0..ba927b1ef3b57 100644 --- a/src/doc/rustc/src/lints/listing/warn-by-default.md +++ b/src/doc/rustc/src/lints/listing/warn-by-default.md @@ -285,26 +285,6 @@ warning: functions generic over types must be mangled | ``` -## overflowing-literals - -This lint detects literal out of range for its type. Some -example code that triggers this lint: - -```rust -let x: u8 = 1000; -``` - -This will produce: - -```text -warning: literal out of range for u8 - --> src/main.rs:2:17 - | -2 | let x: u8 = 1000; - | ^^^^ - | -``` - ## path-statements This lint detects path statements with no effect. Some example code that diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 642681a73a8a0..6d391814414fd 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -15,7 +15,6 @@ use std::{i8, i16, i32, i64, u8, u16, u32, u64, f32, f64}; use syntax::{ast, attr}; use syntax::errors::Applicability; use rustc_target::spec::abi::Abi; -use syntax::edition::Edition; use syntax_pos::Span; use syntax::source_map; @@ -29,9 +28,8 @@ declare_lint! { declare_lint! { OVERFLOWING_LITERALS, - Warn, - "literal out of range for its type", - Edition::Edition2018 => Deny + Deny, + "literal out of range for its type" } declare_lint! { diff --git a/src/test/ui/editions/edition-deny-overflowing-literals-2018.rs b/src/test/ui/lint/deny-overflowing-literals.rs similarity index 82% rename from src/test/ui/editions/edition-deny-overflowing-literals-2018.rs rename to src/test/ui/lint/deny-overflowing-literals.rs index 0527d75214a57..ebd6654d39b1f 100644 --- a/src/test/ui/editions/edition-deny-overflowing-literals-2018.rs +++ b/src/test/ui/lint/deny-overflowing-literals.rs @@ -1,5 +1,3 @@ -// edition:2018 - fn main() { let x: u8 = 256; //~^ error: literal out of range for u8 diff --git a/src/test/ui/editions/edition-deny-overflowing-literals-2018.stderr b/src/test/ui/lint/deny-overflowing-literals.stderr similarity index 76% rename from src/test/ui/editions/edition-deny-overflowing-literals-2018.stderr rename to src/test/ui/lint/deny-overflowing-literals.stderr index 6d1d8568bcf8f..7313dd0bfb5a7 100644 --- a/src/test/ui/editions/edition-deny-overflowing-literals-2018.stderr +++ b/src/test/ui/lint/deny-overflowing-literals.stderr @@ -1,5 +1,5 @@ error: literal out of range for u8 - --> $DIR/edition-deny-overflowing-literals-2018.rs:4:17 + --> $DIR/deny-overflowing-literals.rs:2:17 | LL | let x: u8 = 256; | ^^^ diff --git a/src/test/ui/lint/lint-type-limits2.rs b/src/test/ui/lint/lint-type-limits2.rs index 9c69ba12cf79e..c4486e0676887 100644 --- a/src/test/ui/lint/lint-type-limits2.rs +++ b/src/test/ui/lint/lint-type-limits2.rs @@ -1,4 +1,5 @@ #![allow(dead_code)] +#![warn(overflowing_literals)] // compile-flags: -D unused-comparisons fn main() { } diff --git a/src/test/ui/lint/lint-type-limits2.stderr b/src/test/ui/lint/lint-type-limits2.stderr index 3118bcec05e85..f88fff62e21fc 100644 --- a/src/test/ui/lint/lint-type-limits2.stderr +++ b/src/test/ui/lint/lint-type-limits2.stderr @@ -1,5 +1,5 @@ error: comparison is useless due to type limits - --> $DIR/lint-type-limits2.rs:12:5 + --> $DIR/lint-type-limits2.rs:13:5 | LL | 128 > bar() //~ ERROR comparison is useless due to type limits | ^^^^^^^^^^^ @@ -7,12 +7,16 @@ LL | 128 > bar() //~ ERROR comparison is useless due to type limits = note: requested on the command line with `-D unused-comparisons` warning: literal out of range for i8 - --> $DIR/lint-type-limits2.rs:12:5 + --> $DIR/lint-type-limits2.rs:13:5 | LL | 128 > bar() //~ ERROR comparison is useless due to type limits | ^^^ | - = note: #[warn(overflowing_literals)] on by default +note: lint level defined here + --> $DIR/lint-type-limits2.rs:2:9 + | +LL | #![warn(overflowing_literals)] + | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/lint/lint-type-limits3.rs b/src/test/ui/lint/lint-type-limits3.rs index 3e95ad212eb16..a715c69f7849e 100644 --- a/src/test/ui/lint/lint-type-limits3.rs +++ b/src/test/ui/lint/lint-type-limits3.rs @@ -1,4 +1,5 @@ #![allow(dead_code)] +#![warn(overflowing_literals)] // compile-flags: -D unused-comparisons fn main() { } diff --git a/src/test/ui/lint/lint-type-limits3.stderr b/src/test/ui/lint/lint-type-limits3.stderr index 5e30b1646a755..4f47a7ce31665 100644 --- a/src/test/ui/lint/lint-type-limits3.stderr +++ b/src/test/ui/lint/lint-type-limits3.stderr @@ -1,5 +1,5 @@ error: comparison is useless due to type limits - --> $DIR/lint-type-limits3.rs:8:11 + --> $DIR/lint-type-limits3.rs:9:11 | LL | while 200 != i { //~ ERROR comparison is useless due to type limits | ^^^^^^^^ @@ -7,12 +7,16 @@ LL | while 200 != i { //~ ERROR comparison is useless due to type limits = note: requested on the command line with `-D unused-comparisons` warning: literal out of range for i8 - --> $DIR/lint-type-limits3.rs:8:11 + --> $DIR/lint-type-limits3.rs:9:11 | LL | while 200 != i { //~ ERROR comparison is useless due to type limits | ^^^ | - = note: #[warn(overflowing_literals)] on by default +note: lint level defined here + --> $DIR/lint-type-limits3.rs:2:9 + | +LL | #![warn(overflowing_literals)] + | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/lint/type-overflow.rs b/src/test/ui/lint/type-overflow.rs index 2ccc52a0413e0..64e5951207379 100644 --- a/src/test/ui/lint/type-overflow.rs +++ b/src/test/ui/lint/type-overflow.rs @@ -1,4 +1,5 @@ // compile-pass +#![warn(overflowing_literals)] fn main() { let error = 255i8; //~WARNING literal out of range for i8 diff --git a/src/test/ui/lint/type-overflow.stderr b/src/test/ui/lint/type-overflow.stderr index 3c4a37c4adf56..349d0be016497 100644 --- a/src/test/ui/lint/type-overflow.stderr +++ b/src/test/ui/lint/type-overflow.stderr @@ -1,13 +1,17 @@ warning: literal out of range for i8 - --> $DIR/type-overflow.rs:4:17 + --> $DIR/type-overflow.rs:5:17 | LL | let error = 255i8; //~WARNING literal out of range for i8 | ^^^^^ | - = note: #[warn(overflowing_literals)] on by default +note: lint level defined here + --> $DIR/type-overflow.rs:2:9 + | +LL | #![warn(overflowing_literals)] + | ^^^^^^^^^^^^^^^^^^^^ warning: literal out of range for i8 - --> $DIR/type-overflow.rs:9:16 + --> $DIR/type-overflow.rs:10:16 | LL | let fail = 0b1000_0001i8; //~WARNING literal out of range for i8 | ^^^^^^^^^^^^^ help: consider using `u8` instead: `0b1000_0001u8` @@ -15,7 +19,7 @@ LL | let fail = 0b1000_0001i8; //~WARNING literal out of range for i8 = note: the literal `0b1000_0001i8` (decimal `129`) does not fit into an `i8` and will become `-127i8` warning: literal out of range for i64 - --> $DIR/type-overflow.rs:11:16 + --> $DIR/type-overflow.rs:12:16 | LL | let fail = 0x8000_0000_0000_0000i64; //~WARNING literal out of range for i64 | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `u64` instead: `0x8000_0000_0000_0000u64` @@ -23,7 +27,7 @@ LL | let fail = 0x8000_0000_0000_0000i64; //~WARNING literal out of range fo = note: the literal `0x8000_0000_0000_0000i64` (decimal `9223372036854775808`) does not fit into an `i64` and will become `-9223372036854775808i64` warning: literal out of range for u32 - --> $DIR/type-overflow.rs:13:16 + --> $DIR/type-overflow.rs:14:16 | LL | let fail = 0x1_FFFF_FFFFu32; //~WARNING literal out of range for u32 | ^^^^^^^^^^^^^^^^ help: consider using `u64` instead: `0x1_FFFF_FFFFu64` @@ -31,7 +35,7 @@ LL | let fail = 0x1_FFFF_FFFFu32; //~WARNING literal out of range for u32 = note: the literal `0x1_FFFF_FFFFu32` (decimal `8589934591`) does not fit into an `u32` and will become `4294967295u32` warning: literal out of range for i128 - --> $DIR/type-overflow.rs:15:22 + --> $DIR/type-overflow.rs:16:22 | LL | let fail: i128 = 0x8000_0000_0000_0000_0000_0000_0000_0000; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -40,7 +44,7 @@ LL | let fail: i128 = 0x8000_0000_0000_0000_0000_0000_0000_0000; = help: consider using `u128` instead warning: literal out of range for i32 - --> $DIR/type-overflow.rs:18:16 + --> $DIR/type-overflow.rs:19:16 | LL | let fail = 0x8FFF_FFFF_FFFF_FFFE; //~WARNING literal out of range for i32 | ^^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +53,7 @@ LL | let fail = 0x8FFF_FFFF_FFFF_FFFE; //~WARNING literal out of range for i = help: consider using `i128` instead warning: literal out of range for i8 - --> $DIR/type-overflow.rs:20:17 + --> $DIR/type-overflow.rs:21:17 | LL | let fail = -0b1111_1111i8; //~WARNING literal out of range for i8 | ^^^^^^^^^^^^^ help: consider using `i16` instead: `0b1111_1111i16` From 46f1cc69db895704100197d43ce853bb29674f11 Mon Sep 17 00:00:00 2001 From: kenta7777 Date: Sun, 24 Feb 2019 08:57:24 +0900 Subject: [PATCH 02/11] reduce miri code repetition like (n << amt) >> amt --- src/librustc_mir/hair/constant.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/librustc_mir/hair/constant.rs b/src/librustc_mir/hair/constant.rs index 21c471d49ee66..caadc6055b5c6 100644 --- a/src/librustc_mir/hair/constant.rs +++ b/src/librustc_mir/hair/constant.rs @@ -21,8 +21,7 @@ crate fn lit_to_const<'a, 'gcx, 'tcx>( let param_ty = ParamEnv::reveal_all().and(tcx.lift_to_global(&ty).unwrap()); let width = tcx.layout_of(param_ty).map_err(|_| LitToConstError::Reported)?.size; trace!("trunc {} with size {} and shift {}", n, width.bits(), 128 - width.bits()); - let shift = 128 - width.bits(); - let result = (n << shift) >> shift; + let result = truncate(n, width); trace!("trunc result: {}", result); Ok(ConstValue::Scalar(Scalar::Bits { bits: result, From e7296fd1c486e6837ebf0e318a1bd44aa6a31fcf Mon Sep 17 00:00:00 2001 From: Oliver Middleton Date: Sun, 24 Feb 2019 01:24:31 +0000 Subject: [PATCH 03/11] Fix error index E0370 doctests on 32 bit platforms --- src/librustc_typeck/diagnostics.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 387dabe747ab8..8b06772412244 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -2865,8 +2865,8 @@ E0370: r##" The maximum value of an enum was reached, so it cannot be automatically set in the next enum value. Erroneous code example: -```compile_fail -#[deny(overflowing_literals)] +```compile_fail,E0370 +#[repr(i64)] enum Foo { X = 0x7fffffffffffffff, Y, // error: enum discriminant overflowed on value after @@ -2879,6 +2879,7 @@ To fix this, please set manually the next enum value or put the enum variant with the maximum value at the end of the enum. Examples: ``` +#[repr(i64)] enum Foo { X = 0x7fffffffffffffff, Y = 0, // ok! @@ -2888,6 +2889,7 @@ enum Foo { Or: ``` +#[repr(i64)] enum Foo { Y = 0, // ok! X = 0x7fffffffffffffff, From 423ae56943a7a91957c7f6f9c011afeead4933cb Mon Sep 17 00:00:00 2001 From: kenta7777 Date: Sun, 24 Feb 2019 12:55:14 +0900 Subject: [PATCH 04/11] reduce a code repetition like (n << amt) >> amt --- src/librustc/ty/sty.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index 350bc45026322..dd382ec006bd7 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -3,7 +3,7 @@ use crate::hir; use crate::hir::def_id::DefId; use crate::infer::canonical::Canonical; -use crate::mir::interpret::ConstValue; +use crate::mir::interpret::{ConstValue, truncate}; use crate::middle::region; use polonius_engine::Atom; use rustc_data_structures::indexed_vec::Idx; @@ -2118,8 +2118,7 @@ impl<'tcx> Const<'tcx> { let size = tcx.layout_of(ty).unwrap_or_else(|e| { panic!("could not compute layout for {:?}: {:?}", ty, e) }).size; - let shift = 128 - size.bits(); - let truncated = (bits << shift) >> shift; + let truncated = truncate(bits, size); assert_eq!(truncated, bits, "from_bits called with untruncated value"); Self::from_scalar(Scalar::Bits { bits, size: size.bytes() as u8 }, ty.value) } From 4ca865e92934f003dd477f1801ae0f2096e272e5 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Mon, 25 Feb 2019 08:01:35 +0100 Subject: [PATCH 05/11] heading # Unsafety => # Safety in stdlib docs. --- src/libcore/alloc.rs | 4 ++-- src/libcore/mem.rs | 6 +++--- src/libcore/slice/mod.rs | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libcore/alloc.rs b/src/libcore/alloc.rs index f49e226a5cb68..e842020561d35 100644 --- a/src/libcore/alloc.rs +++ b/src/libcore/alloc.rs @@ -420,7 +420,7 @@ impl fmt::Display for CannotReallocInPlace { /// } /// ``` /// -/// # Unsafety +/// # Safety /// /// The `GlobalAlloc` trait is an `unsafe` trait for a number of reasons, and /// implementors must ensure that they adhere to these contracts: @@ -643,7 +643,7 @@ pub unsafe trait GlobalAlloc { /// currently allocated via an allocator `a`, then it is legal to /// use that layout to deallocate it, i.e., `a.dealloc(ptr, k);`. /// -/// # Unsafety +/// # Safety /// /// The `Alloc` trait is an `unsafe` trait for a number of reasons, and /// implementors must ensure that they adhere to these contracts: diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index 43afc9a522a30..f41d293e80ad3 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -1173,7 +1173,7 @@ impl MaybeUninit { /// to ensure that the data will get dropped, because the resulting `T` is /// subject to the usual drop handling. /// - /// # Unsafety + /// # Safety /// /// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized /// state. Calling this when the content is not yet fully initialized causes undefined @@ -1187,7 +1187,7 @@ impl MaybeUninit { /// Gets a reference to the contained value. /// - /// # Unsafety + /// # Safety /// /// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized /// state. Calling this when the content is not yet fully initialized causes undefined @@ -1200,7 +1200,7 @@ impl MaybeUninit { /// Gets a mutable reference to the contained value. /// - /// # Unsafety + /// # Safety /// /// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized /// state. Calling this when the content is not yet fully initialized causes undefined diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index d89443662df87..2063f8ffaf65a 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -2158,7 +2158,7 @@ impl [T] { /// This method has no purpose when either input element `T` or output element `U` are /// zero-sized and will return the original slice without splitting anything. /// - /// # Unsafety + /// # Safety /// /// This method is essentially a `transmute` with respect to the elements in the returned /// middle slice, so all the usual caveats pertaining to `transmute::` also apply here. @@ -2211,7 +2211,7 @@ impl [T] { /// This method has no purpose when either input element `T` or output element `U` are /// zero-sized and will return the original slice without splitting anything. /// - /// # Unsafety + /// # Safety /// /// This method is essentially a `transmute` with respect to the elements in the returned /// middle slice, so all the usual caveats pertaining to `transmute::` also apply here. From 9661a819688443b19dad91b85a4898a01a7b0858 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Mon, 25 Feb 2019 08:40:18 +0100 Subject: [PATCH 06/11] librustc_codegen_llvm: deny(elided_lifetimes_in_paths) --- src/librustc_codegen_llvm/allocator.rs | 2 +- src/librustc_codegen_llvm/attributes.rs | 6 ++-- src/librustc_codegen_llvm/back/archive.rs | 2 +- src/librustc_codegen_llvm/back/link.rs | 2 +- src/librustc_codegen_llvm/back/rpath.rs | 12 ++++---- src/librustc_codegen_llvm/back/wasm.rs | 4 +-- src/librustc_codegen_llvm/back/write.rs | 2 +- src/librustc_codegen_llvm/base.rs | 6 ++-- src/librustc_codegen_llvm/builder.rs | 2 +- src/librustc_codegen_llvm/context.rs | 2 +- .../debuginfo/create_scope_map.rs | 4 +-- src/librustc_codegen_llvm/debuginfo/gdb.rs | 4 +-- .../debuginfo/metadata.rs | 10 +++---- src/librustc_codegen_llvm/debuginfo/mod.rs | 8 ++--- .../debuginfo/type_names.rs | 2 +- src/librustc_codegen_llvm/debuginfo/utils.rs | 4 +-- src/librustc_codegen_llvm/intrinsic.rs | 18 +++++------ src/librustc_codegen_llvm/lib.rs | 16 ++++++---- src/librustc_codegen_llvm/llvm/archive_ro.rs | 2 +- src/librustc_codegen_llvm/llvm/ffi.rs | 30 +++++++++---------- src/librustc_codegen_llvm/type_.rs | 2 +- src/librustc_codegen_llvm/value.rs | 2 +- 22 files changed, 73 insertions(+), 69 deletions(-) diff --git a/src/librustc_codegen_llvm/allocator.rs b/src/librustc_codegen_llvm/allocator.rs index 9787b07ef8cc2..1fe020561dde1 100644 --- a/src/librustc_codegen_llvm/allocator.rs +++ b/src/librustc_codegen_llvm/allocator.rs @@ -9,7 +9,7 @@ use rustc_allocator::{ALLOCATOR_METHODS, AllocatorTy}; use crate::ModuleLlvm; use crate::llvm::{self, False, True}; -pub(crate) unsafe fn codegen(tcx: TyCtxt, mods: &mut ModuleLlvm, kind: AllocatorKind) { +pub(crate) unsafe fn codegen(tcx: TyCtxt<'_, '_, '_>, mods: &mut ModuleLlvm, kind: AllocatorKind) { let llcx = &*mods.llcx; let llmod = mods.llmod(); let usize = match &tcx.sess.target.target.target_pointer_width[..] { diff --git a/src/librustc_codegen_llvm/attributes.rs b/src/librustc_codegen_llvm/attributes.rs index dab5cab65cd02..71e7535313f77 100644 --- a/src/librustc_codegen_llvm/attributes.rs +++ b/src/librustc_codegen_llvm/attributes.rs @@ -308,7 +308,7 @@ pub fn from_fn_attrs( } } -pub fn provide(providers: &mut Providers) { +pub fn provide(providers: &mut Providers<'_>) { providers.target_features_whitelist = |tcx, cnum| { assert_eq!(cnum, LOCAL_CRATE); if tcx.sess.opts.actually_rustdoc { @@ -328,7 +328,7 @@ pub fn provide(providers: &mut Providers) { provide_extern(providers); } -pub fn provide_extern(providers: &mut Providers) { +pub fn provide_extern(providers: &mut Providers<'_>) { providers.wasm_import_module_map = |tcx, cnum| { // Build up a map from DefId to a `NativeLibrary` structure, where // `NativeLibrary` internally contains information about @@ -362,7 +362,7 @@ pub fn provide_extern(providers: &mut Providers) { }; } -fn wasm_import_module(tcx: TyCtxt, id: DefId) -> Option { +fn wasm_import_module(tcx: TyCtxt<'_, '_, '_>, id: DefId) -> Option { tcx.wasm_import_module_map(id.krate) .get(&id) .map(|s| CString::new(&s[..]).unwrap()) diff --git a/src/librustc_codegen_llvm/back/archive.rs b/src/librustc_codegen_llvm/back/archive.rs index 1c090f1446965..3fb9d4b5b776b 100644 --- a/src/librustc_codegen_llvm/back/archive.rs +++ b/src/librustc_codegen_llvm/back/archive.rs @@ -42,7 +42,7 @@ enum Addition { }, } -fn is_relevant_child(c: &Child) -> bool { +fn is_relevant_child(c: &Child<'_>) -> bool { match c.name() { Some(name) => !name.contains("SYMDEF"), None => false, diff --git a/src/librustc_codegen_llvm/back/link.rs b/src/librustc_codegen_llvm/back/link.rs index a3b34485715a7..819f7f9410257 100644 --- a/src/librustc_codegen_llvm/back/link.rs +++ b/src/librustc_codegen_llvm/back/link.rs @@ -808,7 +808,7 @@ fn exec_linker(sess: &Session, cmd: &mut Command, out_filename: &Path, tmpdir: & } impl<'a> fmt::Display for Escape<'a> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if self.is_like_msvc { // This is "documented" at // https://msdn.microsoft.com/en-us/library/4xdcbak7.aspx diff --git a/src/librustc_codegen_llvm/back/rpath.rs b/src/librustc_codegen_llvm/back/rpath.rs index a5c828e089f39..2b7abcb52bef8 100644 --- a/src/librustc_codegen_llvm/back/rpath.rs +++ b/src/librustc_codegen_llvm/back/rpath.rs @@ -15,7 +15,7 @@ pub struct RPathConfig<'a> { pub get_install_prefix_lib_path: &'a mut dyn FnMut() -> PathBuf, } -pub fn get_rpath_flags(config: &mut RPathConfig) -> Vec { +pub fn get_rpath_flags(config: &mut RPathConfig<'_>) -> Vec { // No rpath on windows if !config.has_rpath { return Vec::new(); @@ -52,7 +52,7 @@ fn rpaths_to_flags(rpaths: &[String]) -> Vec { ret } -fn get_rpaths(config: &mut RPathConfig, libs: &[PathBuf]) -> Vec { +fn get_rpaths(config: &mut RPathConfig<'_>, libs: &[PathBuf]) -> Vec { debug!("output: {:?}", config.out_filename.display()); debug!("libs:"); for libpath in libs { @@ -86,12 +86,12 @@ fn get_rpaths(config: &mut RPathConfig, libs: &[PathBuf]) -> Vec { rpaths } -fn get_rpaths_relative_to_output(config: &mut RPathConfig, +fn get_rpaths_relative_to_output(config: &mut RPathConfig<'_>, libs: &[PathBuf]) -> Vec { libs.iter().map(|a| get_rpath_relative_to_output(config, a)).collect() } -fn get_rpath_relative_to_output(config: &mut RPathConfig, lib: &Path) -> String { +fn get_rpath_relative_to_output(config: &mut RPathConfig<'_>, lib: &Path) -> String { // Mac doesn't appear to support $ORIGIN let prefix = if config.is_like_osx { "@loader_path" @@ -127,7 +127,7 @@ fn path_relative_from(path: &Path, base: &Path) -> Option { } else { let mut ita = path.components(); let mut itb = base.components(); - let mut comps: Vec = vec![]; + let mut comps: Vec> = vec![]; loop { match (ita.next(), itb.next()) { (None, None) => break, @@ -154,7 +154,7 @@ fn path_relative_from(path: &Path, base: &Path) -> Option { } -fn get_install_prefix_rpath(config: &mut RPathConfig) -> String { +fn get_install_prefix_rpath(config: &mut RPathConfig<'_>) -> String { let path = (config.get_install_prefix_lib_path)(); let path = env::current_dir().unwrap().join(&path); // FIXME (#9639): This needs to handle non-utf8 paths diff --git a/src/librustc_codegen_llvm/back/wasm.rs b/src/librustc_codegen_llvm/back/wasm.rs index b403660fa512d..e1d3351d3deca 100644 --- a/src/librustc_codegen_llvm/back/wasm.rs +++ b/src/librustc_codegen_llvm/back/wasm.rs @@ -60,7 +60,7 @@ pub fn rewrite_imports(path: &Path, import_map: &FxHashMap) { fs::write(path, &ret.data).expect("failed to write wasm output"); fn rewrite_import_section( - wasm: &mut WasmDecoder, + wasm: &mut WasmDecoder<'_>, import_map: &FxHashMap, ) -> Vec @@ -75,7 +75,7 @@ pub fn rewrite_imports(path: &Path, import_map: &FxHashMap) { return dst.data } - fn rewrite_import_entry(wasm: &mut WasmDecoder, + fn rewrite_import_entry(wasm: &mut WasmDecoder<'_>, dst: &mut WasmEncoder, import_map: &FxHashMap) { // More info about the binary format here is available at: diff --git a/src/librustc_codegen_llvm/back/write.rs b/src/librustc_codegen_llvm/back/write.rs index 1b16080515235..db5430a4219a0 100644 --- a/src/librustc_codegen_llvm/back/write.rs +++ b/src/librustc_codegen_llvm/back/write.rs @@ -83,7 +83,7 @@ pub fn write_output_file( } pub fn create_target_machine( - tcx: TyCtxt, + tcx: TyCtxt<'_, '_, '_>, find_features: bool, ) -> &'static mut llvm::TargetMachine { target_machine_factory(tcx.sess, tcx.backend_optimization_level(LOCAL_CRATE), find_features)() diff --git a/src/librustc_codegen_llvm/base.rs b/src/librustc_codegen_llvm/base.rs index 7b2e8ec3df6bb..1dac1557707c9 100644 --- a/src/librustc_codegen_llvm/base.rs +++ b/src/librustc_codegen_llvm/base.rs @@ -172,17 +172,17 @@ pub fn compile_codegen_unit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let mono_items = cx.codegen_unit .items_in_deterministic_order(cx.tcx); for &(mono_item, (linkage, visibility)) in &mono_items { - mono_item.predefine::(&cx, linkage, visibility); + mono_item.predefine::>(&cx, linkage, visibility); } // ... and now that we have everything pre-defined, fill out those definitions. for &(mono_item, _) in &mono_items { - mono_item.define::(&cx); + mono_item.define::>(&cx); } // If this codegen unit contains the main function, also create the // wrapper here - maybe_create_entry_wrapper::(&cx); + maybe_create_entry_wrapper::>(&cx); // Run replace-all-uses-with for statics that need it for &(old_g, new_g) in cx.statics_to_rauw().borrow().iter() { diff --git a/src/librustc_codegen_llvm/builder.rs b/src/librustc_codegen_llvm/builder.rs index 39c8f8a09400b..d4d38a464576d 100644 --- a/src/librustc_codegen_llvm/builder.rs +++ b/src/librustc_codegen_llvm/builder.rs @@ -456,7 +456,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { fn checked_binop( &mut self, oop: OverflowOp, - ty: Ty, + ty: Ty<'_>, lhs: Self::Value, rhs: Self::Value, ) -> (Self::Value, Self::Value) { diff --git a/src/librustc_codegen_llvm/context.rs b/src/librustc_codegen_llvm/context.rs index edeef23bdca91..23e3a8425d370 100644 --- a/src/librustc_codegen_llvm/context.rs +++ b/src/librustc_codegen_llvm/context.rs @@ -144,7 +144,7 @@ pub fn is_pie_binary(sess: &Session) -> bool { } pub unsafe fn create_module( - tcx: TyCtxt, + tcx: TyCtxt<'_, '_, '_>, llcx: &'ll llvm::Context, mod_name: &str, ) -> &'ll llvm::Module { diff --git a/src/librustc_codegen_llvm/debuginfo/create_scope_map.rs b/src/librustc_codegen_llvm/debuginfo/create_scope_map.rs index 3ba05bf1b5c91..c8ddf733ecf1f 100644 --- a/src/librustc_codegen_llvm/debuginfo/create_scope_map.rs +++ b/src/librustc_codegen_llvm/debuginfo/create_scope_map.rs @@ -20,7 +20,7 @@ use syntax_pos::BytePos; /// If debuginfo is disabled, the returned vector is empty. pub fn create_mir_scopes( cx: &CodegenCx<'ll, '_>, - mir: &Mir, + mir: &Mir<'_>, debug_context: &FunctionDebugContext<&'ll DISubprogram>, ) -> IndexVec> { let null_scope = MirDebugScope { @@ -55,7 +55,7 @@ pub fn create_mir_scopes( } fn make_mir_scope(cx: &CodegenCx<'ll, '_>, - mir: &Mir, + mir: &Mir<'_>, has_variables: &BitSet, debug_context: &FunctionDebugContextData<&'ll DISubprogram>, scope: SourceScope, diff --git a/src/librustc_codegen_llvm/debuginfo/gdb.rs b/src/librustc_codegen_llvm/debuginfo/gdb.rs index 2555c92fb7c32..91496ffbe557a 100644 --- a/src/librustc_codegen_llvm/debuginfo/gdb.rs +++ b/src/librustc_codegen_llvm/debuginfo/gdb.rs @@ -13,7 +13,7 @@ use syntax::attr; /// Inserts a side-effect free instruction sequence that makes sure that the /// .debug_gdb_scripts global is referenced, so it isn't removed by the linker. -pub fn insert_reference_to_gdb_debug_scripts_section_global(bx: &mut Builder) { +pub fn insert_reference_to_gdb_debug_scripts_section_global(bx: &mut Builder<'_, '_, '_>) { if needs_gdb_debug_scripts_section(bx) { let gdb_debug_scripts_section = get_or_insert_gdb_debug_scripts_section_global(bx); // Load just the first byte as that's all that's necessary to force @@ -64,7 +64,7 @@ pub fn get_or_insert_gdb_debug_scripts_section_global(cx: &CodegenCx<'ll, '_>) }) } -pub fn needs_gdb_debug_scripts_section(cx: &CodegenCx) -> bool { +pub fn needs_gdb_debug_scripts_section(cx: &CodegenCx<'_, '_>) -> bool { let omit_gdb_pretty_printer_section = attr::contains_name(&cx.tcx.hir().krate_attrs(), "omit_gdb_pretty_printer_section"); diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs index da9ff54b0626c..ddcbf29da832b 100644 --- a/src/librustc_codegen_llvm/debuginfo/metadata.rs +++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs @@ -60,7 +60,7 @@ impl Hash for llvm::Metadata { } impl fmt::Debug for llvm::Metadata { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { (self as *const Self).fmt(f) } } @@ -817,7 +817,7 @@ fn pointer_type_metadata( } } -pub fn compile_unit_metadata(tcx: TyCtxt, +pub fn compile_unit_metadata(tcx: TyCtxt<'_, '_, '_>, codegen_unit_name: &str, debug_context: &CrateDebugContext<'ll, '_>) -> &'ll DIDescriptor { @@ -1162,7 +1162,7 @@ fn prepare_union_metadata( // sometimes emit the old style rather than emit something completely // useless when rust is compiled against LLVM 6 or older. This // function decides which representation will be emitted. -fn use_enum_fallback(cx: &CodegenCx) -> bool { +fn use_enum_fallback(cx: &CodegenCx<'_, '_>) -> bool { // On MSVC we have to use the fallback mode, because LLVM doesn't // lower variant parts to PDB. return cx.sess().target.target.options.is_like_msvc @@ -1736,7 +1736,7 @@ fn prepare_enum_metadata( }), ); - fn get_enum_discriminant_name(cx: &CodegenCx, + fn get_enum_discriminant_name(cx: &CodegenCx<'_, '_>, def_id: DefId) -> InternedString { cx.tcx.item_name(def_id) @@ -1863,7 +1863,7 @@ fn compute_type_parameters(cx: &CodegenCx<'ll, 'tcx>, ty: Ty<'tcx>) -> Option<&' } return Some(create_DIArray(DIB(cx), &[])); - fn get_parameter_names(cx: &CodegenCx, + fn get_parameter_names(cx: &CodegenCx<'_, '_>, generics: &ty::Generics) -> Vec { let mut names = generics.parent.map_or(vec![], |def_id| { diff --git a/src/librustc_codegen_llvm/debuginfo/mod.rs b/src/librustc_codegen_llvm/debuginfo/mod.rs index 664ca2533878d..ae6e16b31e7aa 100644 --- a/src/librustc_codegen_llvm/debuginfo/mod.rs +++ b/src/librustc_codegen_llvm/debuginfo/mod.rs @@ -103,7 +103,7 @@ impl<'a, 'tcx> CrateDebugContext<'a, 'tcx> { } /// Creates any deferred debug metadata nodes -pub fn finalize(cx: &CodegenCx) { +pub fn finalize(cx: &CodegenCx<'_, '_>) { if cx.dbg_cx.is_none() { return; } @@ -233,7 +233,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { instance: Instance<'tcx>, sig: ty::FnSig<'tcx>, llfn: &'ll Value, - mir: &mir::Mir, + mir: &mir::Mir<'_>, ) -> FunctionDebugContext<&'ll DISubprogram> { if self.sess().opts.debuginfo == DebugInfo::None { return FunctionDebugContext::DebugInfoDisabled; @@ -455,7 +455,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { return create_DIArray(DIB(cx), &template_params[..]); } - fn get_parameter_names(cx: &CodegenCx, + fn get_parameter_names(cx: &CodegenCx<'_, '_>, generics: &ty::Generics) -> Vec { let mut names = generics.parent.map_or(vec![], |def_id| { @@ -518,7 +518,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { fn create_mir_scopes( &self, - mir: &mir::Mir, + mir: &mir::Mir<'_>, debug_context: &FunctionDebugContext<&'ll DISubprogram>, ) -> IndexVec> { create_scope_map::create_mir_scopes(self, mir, debug_context) diff --git a/src/librustc_codegen_llvm/debuginfo/type_names.rs b/src/librustc_codegen_llvm/debuginfo/type_names.rs index 1697bb7b52dbd..32e930ac44c85 100644 --- a/src/librustc_codegen_llvm/debuginfo/type_names.rs +++ b/src/librustc_codegen_llvm/debuginfo/type_names.rs @@ -178,7 +178,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, } } - fn push_item_name(cx: &CodegenCx, + fn push_item_name(cx: &CodegenCx<'_, '_>, def_id: DefId, qualified: bool, output: &mut String) { diff --git a/src/librustc_codegen_llvm/debuginfo/utils.rs b/src/librustc_codegen_llvm/debuginfo/utils.rs index e1b299df6c312..c64e0d9806b29 100644 --- a/src/librustc_codegen_llvm/debuginfo/utils.rs +++ b/src/librustc_codegen_llvm/debuginfo/utils.rs @@ -13,7 +13,7 @@ use rustc_codegen_ssa::traits::*; use syntax_pos::Span; -pub fn is_node_local_to_unit(cx: &CodegenCx, def_id: DefId) -> bool +pub fn is_node_local_to_unit(cx: &CodegenCx<'_, '_>, def_id: DefId) -> bool { // The is_local_to_unit flag indicates whether a function is local to the // current compilation unit (i.e., if it is *static* in the C-sense). The @@ -37,7 +37,7 @@ pub fn create_DIArray( } /// Returns syntax_pos::Loc corresponding to the beginning of the span -pub fn span_start(cx: &CodegenCx, span: Span) -> syntax_pos::Loc { +pub fn span_start(cx: &CodegenCx<'_, '_>, span: Span) -> syntax_pos::Loc { cx.sess().source_map().lookup_char_pos(span.lo()) } diff --git a/src/librustc_codegen_llvm/intrinsic.rs b/src/librustc_codegen_llvm/intrinsic.rs index d12ee7649bda0..d1cbe1d4dd686 100644 --- a/src/librustc_codegen_llvm/intrinsic.rs +++ b/src/librustc_codegen_llvm/intrinsic.rs @@ -1251,8 +1251,8 @@ fn generic_simd_intrinsic( fn simd_simple_float_intrinsic( name: &str, - in_elem: &::rustc::ty::TyS, - in_ty: &::rustc::ty::TyS, + in_elem: &::rustc::ty::TyS<'_>, + in_ty: &::rustc::ty::TyS<'_>, in_len: usize, bx: &mut Builder<'a, 'll, 'tcx>, span: Span, @@ -1362,7 +1362,7 @@ fn generic_simd_intrinsic( // FIXME: use: // https://github.com/llvm-mirror/llvm/blob/master/include/llvm/IR/Function.h#L182 // https://github.com/llvm-mirror/llvm/blob/master/include/llvm/IR/Intrinsics.h#L81 - fn llvm_vector_str(elem_ty: ty::Ty, vec_len: usize, no_pointers: usize) -> String { + fn llvm_vector_str(elem_ty: ty::Ty<'_>, vec_len: usize, no_pointers: usize) -> String { let p0s: String = "p0".repeat(no_pointers); match elem_ty.sty { ty::Int(v) => format!("v{}{}i{}", vec_len, p0s, v.bit_width().unwrap()), @@ -1372,7 +1372,7 @@ fn generic_simd_intrinsic( } } - fn llvm_vector_ty(cx: &CodegenCx<'ll, '_>, elem_ty: ty::Ty, vec_len: usize, + fn llvm_vector_ty(cx: &CodegenCx<'ll, '_>, elem_ty: ty::Ty<'_>, vec_len: usize, mut no_pointers: usize) -> &'ll Type { // FIXME: use cx.layout_of(ty).llvm_type() ? let mut elem_ty = match elem_ty.sty { @@ -1418,7 +1418,7 @@ fn generic_simd_intrinsic( in_ty, ret_ty); // This counts how many pointers - fn ptr_count(t: ty::Ty) -> usize { + fn ptr_count(t: ty::Ty<'_>) -> usize { match t.sty { ty::RawPtr(p) => 1 + ptr_count(p.ty), _ => 0, @@ -1426,7 +1426,7 @@ fn generic_simd_intrinsic( } // Non-ptr type - fn non_ptr(t: ty::Ty) -> ty::Ty { + fn non_ptr(t: ty::Ty<'_>) -> ty::Ty<'_> { match t.sty { ty::RawPtr(p) => non_ptr(p.ty), _ => t, @@ -1517,7 +1517,7 @@ fn generic_simd_intrinsic( arg_tys[2].simd_size(tcx)); // This counts how many pointers - fn ptr_count(t: ty::Ty) -> usize { + fn ptr_count(t: ty::Ty<'_>) -> usize { match t.sty { ty::RawPtr(p) => 1 + ptr_count(p.ty), _ => 0, @@ -1525,7 +1525,7 @@ fn generic_simd_intrinsic( } // Non-ptr type - fn non_ptr(t: ty::Ty) -> ty::Ty { + fn non_ptr(t: ty::Ty<'_>) -> ty::Ty<'_> { match t.sty { ty::RawPtr(p) => non_ptr(p.ty), _ => t, @@ -1901,7 +1901,7 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#, // Returns None if the type is not an integer // FIXME: there’s multiple of this functions, investigate using some of the already existing // stuffs. -fn int_type_width_signed(ty: Ty, cx: &CodegenCx) -> Option<(u64, bool)> { +fn int_type_width_signed(ty: Ty<'_>, cx: &CodegenCx<'_, '_>) -> Option<(u64, bool)> { match ty.sty { ty::Int(t) => Some((match t { ast::IntTy::Isize => cx.tcx.sess.target.isize_ty.bit_width().unwrap() as u64, diff --git a/src/librustc_codegen_llvm/lib.rs b/src/librustc_codegen_llvm/lib.rs index 9a75b8495ded3..5b8c7461bcb60 100644 --- a/src/librustc_codegen_llvm/lib.rs +++ b/src/librustc_codegen_llvm/lib.rs @@ -23,7 +23,6 @@ #![feature(static_nobundle)] #![deny(rust_2018_idioms)] #![allow(explicit_outlives_requirements)] -#![allow(elided_lifetimes_in_paths)] use back::write::create_target_machine; use syntax_pos::symbol::Symbol; @@ -114,7 +113,7 @@ mod va_arg; pub struct LlvmCodegenBackend(()); impl ExtraBackendMethods for LlvmCodegenBackend { - fn new_metadata(&self, tcx: TyCtxt, mod_name: &str) -> ModuleLlvm { + fn new_metadata(&self, tcx: TyCtxt<'_, '_, '_>, mod_name: &str) -> ModuleLlvm { ModuleLlvm::new(tcx, mod_name) } fn write_metadata<'b, 'gcx>( @@ -124,7 +123,12 @@ impl ExtraBackendMethods for LlvmCodegenBackend { ) -> EncodedMetadata { base::write_metadata(tcx, metadata) } - fn codegen_allocator(&self, tcx: TyCtxt, mods: &mut ModuleLlvm, kind: AllocatorKind) { + fn codegen_allocator( + &self, + tcx: TyCtxt<'_, '_, '_>, + mods: &mut ModuleLlvm, + kind: AllocatorKind + ) { unsafe { allocator::codegen(tcx, mods, kind) } } fn compile_codegen_unit<'a, 'tcx: 'a>( @@ -280,14 +284,14 @@ impl CodegenBackend for LlvmCodegenBackend { box metadata::LlvmMetadataLoader } - fn provide(&self, providers: &mut ty::query::Providers) { + fn provide(&self, providers: &mut ty::query::Providers<'_>) { rustc_codegen_utils::symbol_names::provide(providers); rustc_codegen_ssa::back::symbol_export::provide(providers); rustc_codegen_ssa::base::provide_both(providers); attributes::provide(providers); } - fn provide_extern(&self, providers: &mut ty::query::Providers) { + fn provide_extern(&self, providers: &mut ty::query::Providers<'_>) { rustc_codegen_ssa::back::symbol_export::provide_extern(providers); rustc_codegen_ssa::base::provide_both(providers); attributes::provide_extern(providers); @@ -362,7 +366,7 @@ unsafe impl Send for ModuleLlvm { } unsafe impl Sync for ModuleLlvm { } impl ModuleLlvm { - fn new(tcx: TyCtxt, mod_name: &str) -> Self { + fn new(tcx: TyCtxt<'_, '_, '_>, mod_name: &str) -> Self { unsafe { let llcx = llvm::LLVMRustContextCreate(tcx.sess.fewer_names()); let llmod_raw = context::create_module(tcx, llcx, mod_name) as *const _; diff --git a/src/librustc_codegen_llvm/llvm/archive_ro.rs b/src/librustc_codegen_llvm/llvm/archive_ro.rs index 548fffe0ecb9d..0a8bb3250c5d5 100644 --- a/src/librustc_codegen_llvm/llvm/archive_ro.rs +++ b/src/librustc_codegen_llvm/llvm/archive_ro.rs @@ -36,7 +36,7 @@ impl ArchiveRO { }; } - pub fn iter(&self) -> Iter { + pub fn iter(&self) -> Iter<'_> { unsafe { Iter { raw: super::LLVMRustArchiveIteratorNew(self.raw), diff --git a/src/librustc_codegen_llvm/llvm/ffi.rs b/src/librustc_codegen_llvm/llvm/ffi.rs index fe2664118f798..2ad6d9c053a20 100644 --- a/src/librustc_codegen_llvm/llvm/ffi.rs +++ b/src/librustc_codegen_llvm/llvm/ffi.rs @@ -1283,7 +1283,7 @@ extern "C" { SingleThreaded: Bool) -> &'a Value; - pub fn LLVMRustBuildAtomicFence(B: &Builder, + pub fn LLVMRustBuildAtomicFence(B: &Builder<'_>, Order: AtomicOrdering, Scope: SynchronizationScope); @@ -1311,17 +1311,17 @@ extern "C" { pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(PMB: &PassManagerBuilder, threshold: c_uint); pub fn LLVMPassManagerBuilderPopulateModulePassManager(PMB: &PassManagerBuilder, - PM: &PassManager); + PM: &PassManager<'_>); pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(PMB: &PassManagerBuilder, - PM: &PassManager); + PM: &PassManager<'_>); pub fn LLVMPassManagerBuilderPopulateLTOPassManager(PMB: &PassManagerBuilder, - PM: &PassManager, + PM: &PassManager<'_>, Internalize: Bool, RunInliner: Bool); pub fn LLVMRustPassManagerBuilderPopulateThinLTOPassManager( PMB: &PassManagerBuilder, - PM: &PassManager); + PM: &PassManager<'_>); // Stuff that's in rustllvm/ because it's not upstream yet. @@ -1340,11 +1340,11 @@ extern "C" { /// list: pub fn LLVMIsSectionIteratorAtEnd(ObjFile: &'a ObjectFile, SI: &SectionIterator<'a>) -> Bool; /// Moves the section iterator to point to the next section. - pub fn LLVMMoveToNextSection(SI: &SectionIterator); + pub fn LLVMMoveToNextSection(SI: &SectionIterator<'_>); /// Returns the current section size. - pub fn LLVMGetSectionSize(SI: &SectionIterator) -> c_ulonglong; + pub fn LLVMGetSectionSize(SI: &SectionIterator<'_>) -> c_ulonglong; /// Returns the current section contents as a string buffer. - pub fn LLVMGetSectionContents(SI: &SectionIterator) -> *const c_char; + pub fn LLVMGetSectionContents(SI: &SectionIterator<'_>) -> *const c_char; /// Reads the given file and returns it as a memory buffer. Use /// LLVMDisposeMemoryBuffer() to get rid of it. @@ -1392,7 +1392,7 @@ extern "C" { pub fn LLVMRustDIBuilderDispose(Builder: &'a mut DIBuilder<'a>); - pub fn LLVMRustDIBuilderFinalize(Builder: &DIBuilder); + pub fn LLVMRustDIBuilderFinalize(Builder: &DIBuilder<'_>); pub fn LLVMRustDIBuilderCreateCompileUnit(Builder: &DIBuilder<'a>, Lang: c_uint, @@ -1635,7 +1635,7 @@ extern "C" { pub fn LLVMRustPassKind(Pass: &Pass) -> PassKind; pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> Option<&'static mut Pass>; - pub fn LLVMRustAddPass(PM: &PassManager, Pass: &'static mut Pass); + pub fn LLVMRustAddPass(PM: &PassManager<'_>, Pass: &'static mut Pass); pub fn LLVMRustHasFeature(T: &TargetMachine, s: *const c_char) -> bool; @@ -1700,13 +1700,13 @@ extern "C" { pub fn LLVMRustArchiveIteratorNext( AIR: &ArchiveIterator<'a>, ) -> Option<&'a mut ArchiveChild<'a>>; - pub fn LLVMRustArchiveChildName(ACR: &ArchiveChild, size: &mut size_t) -> *const c_char; - pub fn LLVMRustArchiveChildData(ACR: &ArchiveChild, size: &mut size_t) -> *const c_char; + pub fn LLVMRustArchiveChildName(ACR: &ArchiveChild<'_>, size: &mut size_t) -> *const c_char; + pub fn LLVMRustArchiveChildData(ACR: &ArchiveChild<'_>, size: &mut size_t) -> *const c_char; pub fn LLVMRustArchiveChildFree(ACR: &'a mut ArchiveChild<'a>); pub fn LLVMRustArchiveIteratorFree(AIR: &'a mut ArchiveIterator<'a>); pub fn LLVMRustDestroyArchive(AR: &'static mut Archive); - pub fn LLVMRustGetSectionName(SI: &SectionIterator, data: &mut *const c_char) -> size_t; + pub fn LLVMRustGetSectionName(SI: &SectionIterator<'_>, data: &mut *const c_char) -> size_t; #[allow(improper_ctypes)] pub fn LLVMRustWriteTwineToString(T: &Twine, s: &RustString); @@ -1742,7 +1742,7 @@ extern "C" { pub fn LLVMRustWriteArchive(Dst: *const c_char, NumMembers: size_t, - Members: *const &RustArchiveMember, + Members: *const &RustArchiveMember<'_>, WriteSymbtab: bool, Kind: ArchiveKind) -> LLVMRustResult; @@ -1815,7 +1815,7 @@ extern "C" { pub fn LLVMRustThinLTOPatchDICompileUnit(M: &Module, CU: *mut c_void); pub fn LLVMRustLinkerNew(M: &'a Module) -> &'a mut Linker<'a>; - pub fn LLVMRustLinkerAdd(linker: &Linker, + pub fn LLVMRustLinkerAdd(linker: &Linker<'_>, bytecode: *const c_char, bytecode_len: usize) -> bool; pub fn LLVMRustLinkerFree(linker: &'a mut Linker<'a>); diff --git a/src/librustc_codegen_llvm/type_.rs b/src/librustc_codegen_llvm/type_.rs index ca61987e12f7a..d5424fa459166 100644 --- a/src/librustc_codegen_llvm/type_.rs +++ b/src/librustc_codegen_llvm/type_.rs @@ -31,7 +31,7 @@ impl PartialEq for Type { } impl fmt::Debug for Type { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(&llvm::build_string(|s| unsafe { llvm::LLVMRustWriteTypeToString(self, s); }).expect("non-UTF8 type description from LLVM")) diff --git a/src/librustc_codegen_llvm/value.rs b/src/librustc_codegen_llvm/value.rs index 68809284bb726..eadbe754e8e41 100644 --- a/src/librustc_codegen_llvm/value.rs +++ b/src/librustc_codegen_llvm/value.rs @@ -22,7 +22,7 @@ impl Hash for Value { impl fmt::Debug for Value { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(&llvm::build_string(|s| unsafe { llvm::LLVMRustWriteValueToString(self, s); }).expect("non-UTF8 value description from LLVM")) From 1d34f2c22879886fcd452da096317861f8a0c9e6 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Mon, 25 Feb 2019 08:52:46 +0100 Subject: [PATCH 07/11] librustc_codegen_ssa: deny(elided_lifetimes_in_paths) --- src/librustc_codegen_ssa/back/command.rs | 2 +- src/librustc_codegen_ssa/back/linker.rs | 4 ++-- src/librustc_codegen_ssa/back/symbol_export.rs | 10 +++++----- src/librustc_codegen_ssa/back/write.rs | 18 +++++++++--------- src/librustc_codegen_ssa/base.rs | 10 +++++----- src/librustc_codegen_ssa/common.rs | 2 +- src/librustc_codegen_ssa/lib.rs | 1 - src/librustc_codegen_ssa/mir/operand.rs | 2 +- src/librustc_codegen_ssa/traits/backend.rs | 9 +++++++-- src/librustc_codegen_ssa/traits/builder.rs | 2 +- src/librustc_codegen_ssa/traits/debuginfo.rs | 4 ++-- 11 files changed, 34 insertions(+), 30 deletions(-) diff --git a/src/librustc_codegen_ssa/back/command.rs b/src/librustc_codegen_ssa/back/command.rs index bc484ace58463..78570cce57dd9 100644 --- a/src/librustc_codegen_ssa/back/command.rs +++ b/src/librustc_codegen_ssa/back/command.rs @@ -159,7 +159,7 @@ impl Command { } impl fmt::Debug for Command { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.command().fmt(f) } } diff --git a/src/librustc_codegen_ssa/back/linker.rs b/src/librustc_codegen_ssa/back/linker.rs index 356bb8d50ad0d..1f4c5543fa9aa 100644 --- a/src/librustc_codegen_ssa/back/linker.rs +++ b/src/librustc_codegen_ssa/back/linker.rs @@ -25,7 +25,7 @@ pub struct LinkerInfo { } impl LinkerInfo { - pub fn new(tcx: TyCtxt) -> LinkerInfo { + pub fn new(tcx: TyCtxt<'_, '_, '_>) -> LinkerInfo { LinkerInfo { exports: tcx.sess.crate_types.borrow().iter().map(|&c| { (c, exported_symbols(tcx, c)) @@ -1052,7 +1052,7 @@ impl<'a> Linker for WasmLd<'a> { } } -fn exported_symbols(tcx: TyCtxt, crate_type: CrateType) -> Vec { +fn exported_symbols(tcx: TyCtxt<'_, '_, '_>, crate_type: CrateType) -> Vec { if let Some(ref exports) = tcx.sess.target.target.options.override_export_symbols { return exports.clone() } diff --git a/src/librustc_codegen_ssa/back/symbol_export.rs b/src/librustc_codegen_ssa/back/symbol_export.rs index c372892c521be..16f5880b13f5b 100644 --- a/src/librustc_codegen_ssa/back/symbol_export.rs +++ b/src/librustc_codegen_ssa/back/symbol_export.rs @@ -22,7 +22,7 @@ pub type ExportedSymbols = FxHashMap< Arc>, >; -pub fn threshold(tcx: TyCtxt) -> SymbolExportLevel { +pub fn threshold(tcx: TyCtxt<'_, '_, '_>) -> SymbolExportLevel { crates_export_threshold(&tcx.sess.crate_types.borrow()) } @@ -342,7 +342,7 @@ fn upstream_monomorphizations_for_provider<'a, 'tcx>( .cloned() } -fn is_unreachable_local_definition_provider(tcx: TyCtxt, def_id: DefId) -> bool { +fn is_unreachable_local_definition_provider(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> bool { if let Some(node_id) = tcx.hir().as_local_node_id(def_id) { !tcx.reachable_set(LOCAL_CRATE).0.contains(&node_id) } else { @@ -351,7 +351,7 @@ fn is_unreachable_local_definition_provider(tcx: TyCtxt, def_id: DefId) -> bool } } -pub fn provide(providers: &mut Providers) { +pub fn provide(providers: &mut Providers<'_>) { providers.reachable_non_generics = reachable_non_generics_provider; providers.is_reachable_non_generic = is_reachable_non_generic_provider_local; providers.exported_symbols = exported_symbols_provider_local; @@ -359,12 +359,12 @@ pub fn provide(providers: &mut Providers) { providers.is_unreachable_local_definition = is_unreachable_local_definition_provider; } -pub fn provide_extern(providers: &mut Providers) { +pub fn provide_extern(providers: &mut Providers<'_>) { providers.is_reachable_non_generic = is_reachable_non_generic_provider_extern; providers.upstream_monomorphizations_for = upstream_monomorphizations_for_provider; } -fn symbol_export_level(tcx: TyCtxt, sym_def_id: DefId) -> SymbolExportLevel { +fn symbol_export_level(tcx: TyCtxt<'_, '_, '_>, sym_def_id: DefId) -> SymbolExportLevel { // We export anything that's not mangled at the "C" layer as it probably has // to do with ABI concerns. We do not, however, apply such treatment to // special symbols in the standard library for various plumbing between diff --git a/src/librustc_codegen_ssa/back/write.rs b/src/librustc_codegen_ssa/back/write.rs index 20842553c2666..908ee95efcba3 100644 --- a/src/librustc_codegen_ssa/back/write.rs +++ b/src/librustc_codegen_ssa/back/write.rs @@ -321,7 +321,7 @@ fn need_pre_lto_bitcode_for_incr_comp(sess: &Session) -> bool { pub fn start_async_codegen( backend: B, - tcx: TyCtxt, + tcx: TyCtxt<'_, '_, '_>, time_graph: Option, metadata: EncodedMetadata, coordinator_receive: Receiver>, @@ -947,7 +947,7 @@ enum MainThreadWorkerState { fn start_executing_work( backend: B, - tcx: TyCtxt, + tcx: TyCtxt<'_, '_, '_>, crate_info: &CrateInfo, shared_emitter: SharedEmitter, codegen_worker_send: Sender>, @@ -1683,7 +1683,7 @@ impl SharedEmitter { } impl Emitter for SharedEmitter { - fn emit(&mut self, db: &DiagnosticBuilder) { + fn emit(&mut self, db: &DiagnosticBuilder<'_>) { drop(self.sender.send(SharedEmitterMessage::Diagnostic(Diagnostic { msg: db.message(), code: db.code.clone(), @@ -1822,7 +1822,7 @@ impl OngoingCodegen { } pub fn submit_pre_codegened_module_to_llvm(&self, - tcx: TyCtxt, + tcx: TyCtxt<'_, '_, '_>, module: ModuleCodegen) { self.wait_for_signal_to_codegen_item(); self.check_for_errors(tcx.sess); @@ -1832,7 +1832,7 @@ impl OngoingCodegen { submit_codegened_module_to_llvm(&self.backend, tcx, module, cost); } - pub fn codegen_finished(&self, tcx: TyCtxt) { + pub fn codegen_finished(&self, tcx: TyCtxt<'_, '_, '_>) { self.wait_for_signal_to_codegen_item(); self.check_for_errors(tcx.sess); drop(self.coordinator_send.send(Box::new(Message::CodegenComplete::))); @@ -1871,7 +1871,7 @@ impl OngoingCodegen { pub fn submit_codegened_module_to_llvm( _backend: &B, - tcx: TyCtxt, + tcx: TyCtxt<'_, '_, '_>, module: ModuleCodegen, cost: u64 ) { @@ -1884,7 +1884,7 @@ pub fn submit_codegened_module_to_llvm( pub fn submit_post_lto_module_to_llvm( _backend: &B, - tcx: TyCtxt, + tcx: TyCtxt<'_, '_, '_>, module: CachedModuleCodegen ) { let llvm_work_item = WorkItem::CopyPostLtoArtifacts(module); @@ -1896,7 +1896,7 @@ pub fn submit_post_lto_module_to_llvm( pub fn submit_pre_lto_module_to_llvm( _backend: &B, - tcx: TyCtxt, + tcx: TyCtxt<'_, '_, '_>, module: CachedModuleCodegen ) { let filename = pre_lto_bitcode_filename(&module.name); @@ -1921,7 +1921,7 @@ pub fn pre_lto_bitcode_filename(module_name: &str) -> String { format!("{}.{}", module_name, PRE_LTO_BC_EXT) } -fn msvc_imps_needed(tcx: TyCtxt) -> bool { +fn msvc_imps_needed(tcx: TyCtxt<'_, '_, '_>) -> bool { // This should never be true (because it's not supported). If it is true, // something is wrong with commandline arg validation. assert!(!(tcx.sess.opts.cg.linker_plugin_lto.enabled() && diff --git a/src/librustc_codegen_ssa/base.rs b/src/librustc_codegen_ssa/base.rs index 92f5c39fe5a18..fad41a11a82ba 100644 --- a/src/librustc_codegen_ssa/base.rs +++ b/src/librustc_codegen_ssa/base.rs @@ -370,7 +370,7 @@ pub fn from_immediate<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( pub fn to_immediate<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( bx: &mut Bx, val: Bx::Value, - layout: layout::TyLayout, + layout: layout::TyLayout<'_>, ) -> Bx::Value { if let layout::Abi::Scalar(ref scalar) = layout.abi { return to_immediate_scalar(bx, val, scalar); @@ -802,7 +802,7 @@ fn assert_and_save_dep_graph<'ll, 'tcx>(tcx: TyCtxt<'ll, 'tcx, 'tcx>) { } impl CrateInfo { - pub fn new(tcx: TyCtxt) -> CrateInfo { + pub fn new(tcx: TyCtxt<'_, '_, '_>) -> CrateInfo { let mut info = CrateInfo { panic_runtime: None, compiler_builtins: None, @@ -880,7 +880,7 @@ impl CrateInfo { return info } - fn load_wasm_imports(&mut self, tcx: TyCtxt, cnum: CrateNum) { + fn load_wasm_imports(&mut self, tcx: TyCtxt<'_, '_, '_>, cnum: CrateNum) { self.wasm_imports.extend(tcx.wasm_import_module_map(cnum).iter().map(|(&id, module)| { let instance = Instance::mono(tcx, id); let import_name = tcx.symbol_name(instance); @@ -890,13 +890,13 @@ impl CrateInfo { } } -fn is_codegened_item(tcx: TyCtxt, id: DefId) -> bool { +fn is_codegened_item(tcx: TyCtxt<'_, '_, '_>, id: DefId) -> bool { let (all_mono_items, _) = tcx.collect_and_partition_mono_items(LOCAL_CRATE); all_mono_items.contains(&id) } -pub fn provide_both(providers: &mut Providers) { +pub fn provide_both(providers: &mut Providers<'_>) { providers.backend_optimization_level = |tcx, cratenum| { let for_speed = match tcx.sess.opts.optimize { // If globally no optimisation is done, #[optimize] has no effect. diff --git a/src/librustc_codegen_ssa/common.rs b/src/librustc_codegen_ssa/common.rs index 1b87f160cc35d..db77074deef94 100644 --- a/src/librustc_codegen_ssa/common.rs +++ b/src/librustc_codegen_ssa/common.rs @@ -134,7 +134,7 @@ mod temp_stable_hash_impls { } } -pub fn langcall(tcx: TyCtxt, +pub fn langcall(tcx: TyCtxt<'_, '_, '_>, span: Option, msg: &str, li: LangItem) diff --git a/src/librustc_codegen_ssa/lib.rs b/src/librustc_codegen_ssa/lib.rs index 9e1744451465d..92fa2766f8727 100644 --- a/src/librustc_codegen_ssa/lib.rs +++ b/src/librustc_codegen_ssa/lib.rs @@ -11,7 +11,6 @@ #![allow(dead_code)] #![deny(rust_2018_idioms)] #![allow(explicit_outlives_requirements)] -#![allow(elided_lifetimes_in_paths)] #![recursion_limit="256"] diff --git a/src/librustc_codegen_ssa/mir/operand.rs b/src/librustc_codegen_ssa/mir/operand.rs index 3cac1befaf4ef..0e8cdc83b486e 100644 --- a/src/librustc_codegen_ssa/mir/operand.rs +++ b/src/librustc_codegen_ssa/mir/operand.rs @@ -48,7 +48,7 @@ pub struct OperandRef<'tcx, V> { } impl fmt::Debug for OperandRef<'tcx, V> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "OperandRef({:?} @ {:?})", self.val, self.layout) } } diff --git a/src/librustc_codegen_ssa/traits/backend.rs b/src/librustc_codegen_ssa/traits/backend.rs index 6f92024ea8af3..00eae9098e74f 100644 --- a/src/librustc_codegen_ssa/traits/backend.rs +++ b/src/librustc_codegen_ssa/traits/backend.rs @@ -32,13 +32,18 @@ impl<'tcx, T> Backend<'tcx> for T where } pub trait ExtraBackendMethods: CodegenBackend + WriteBackendMethods + Sized + Send { - fn new_metadata(&self, sess: TyCtxt, mod_name: &str) -> Self::Module; + fn new_metadata(&self, sess: TyCtxt<'_, '_, '_>, mod_name: &str) -> Self::Module; fn write_metadata<'b, 'gcx>( &self, tcx: TyCtxt<'b, 'gcx, 'gcx>, metadata: &mut Self::Module, ) -> EncodedMetadata; - fn codegen_allocator(&self, tcx: TyCtxt, mods: &mut Self::Module, kind: AllocatorKind); + fn codegen_allocator( + &self, + tcx: TyCtxt<'_, '_, '_>, + mods: &mut Self::Module, + kind: AllocatorKind + ); fn compile_codegen_unit<'a, 'tcx: 'a>( &self, tcx: TyCtxt<'a, 'tcx, 'tcx>, diff --git a/src/librustc_codegen_ssa/traits/builder.rs b/src/librustc_codegen_ssa/traits/builder.rs index bda0f3dc77966..5099107a39303 100644 --- a/src/librustc_codegen_ssa/traits/builder.rs +++ b/src/librustc_codegen_ssa/traits/builder.rs @@ -100,7 +100,7 @@ pub trait BuilderMethods<'a, 'tcx: 'a>: fn checked_binop( &mut self, oop: OverflowOp, - ty: Ty, + ty: Ty<'_>, lhs: Self::Value, rhs: Self::Value, ) -> (Self::Value, Self::Value); diff --git a/src/librustc_codegen_ssa/traits/debuginfo.rs b/src/librustc_codegen_ssa/traits/debuginfo.rs index 0e606e744c629..135188e98c71c 100644 --- a/src/librustc_codegen_ssa/traits/debuginfo.rs +++ b/src/librustc_codegen_ssa/traits/debuginfo.rs @@ -22,12 +22,12 @@ pub trait DebugInfoMethods<'tcx>: BackendTypes { instance: Instance<'tcx>, sig: ty::FnSig<'tcx>, llfn: Self::Value, - mir: &mir::Mir, + mir: &mir::Mir<'_>, ) -> FunctionDebugContext; fn create_mir_scopes( &self, - mir: &mir::Mir, + mir: &mir::Mir<'_>, debug_context: &FunctionDebugContext, ) -> IndexVec>; fn extend_scope_to_file( From e8ce56f1263b63daf0196e974ef9af373ef90f99 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Mon, 25 Feb 2019 09:09:02 +0100 Subject: [PATCH 08/11] librustc_typeck: deny(elided_lifetimes_in_paths) --- src/librustc_typeck/astconv.rs | 8 ++++---- src/librustc_typeck/check/_match.rs | 2 +- src/librustc_typeck/check/callee.rs | 2 +- src/librustc_typeck/check/closure.rs | 4 ++-- src/librustc_typeck/check/coercion.rs | 6 +++--- src/librustc_typeck/check/compare_method.rs | 2 +- src/librustc_typeck/check/demand.rs | 2 +- src/librustc_typeck/check/method/confirm.rs | 2 +- src/librustc_typeck/check/method/probe.rs | 4 ++-- src/librustc_typeck/check/method/suggest.rs | 17 +++++++++-------- src/librustc_typeck/check/mod.rs | 10 +++++----- src/librustc_typeck/check/op.rs | 4 ++-- src/librustc_typeck/check/upvar.rs | 2 +- src/librustc_typeck/check/wfcheck.rs | 4 ++-- src/librustc_typeck/check/writeback.rs | 10 +++++----- .../coherence/inherent_impls_overlap.rs | 2 +- src/librustc_typeck/coherence/mod.rs | 14 +++++++++++--- src/librustc_typeck/collect.rs | 6 +++--- src/librustc_typeck/lib.rs | 2 -- src/librustc_typeck/variance/mod.rs | 3 +-- src/librustc_typeck/variance/solve.rs | 2 +- src/librustc_typeck/variance/terms.rs | 4 ++-- 22 files changed, 59 insertions(+), 53 deletions(-) diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index cde6eb22bb8ae..71368927a801d 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -196,7 +196,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { /// Report error if there is an explicit type parameter when using `impl Trait`. fn check_impl_trait( - tcx: TyCtxt, + tcx: TyCtxt<'_, '_, '_>, span: Span, seg: &hir::PathSegment, generics: &ty::Generics, @@ -227,7 +227,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { /// Checks that the correct number of generic arguments have been provided. /// Used specifically for function calls. pub fn check_generic_arg_count_for_call( - tcx: TyCtxt, + tcx: TyCtxt<'_, '_, '_>, span: Span, def: &ty::Generics, seg: &hir::PathSegment, @@ -259,7 +259,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { /// Checks that the correct number of generic arguments have been provided. /// This is used both for datatypes and function calls. fn check_generic_arg_count( - tcx: TyCtxt, + tcx: TyCtxt<'_, '_, '_>, span: Span, def: &ty::Generics, args: &hir::GenericArgs, @@ -1502,7 +1502,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { has_err } - pub fn prohibit_assoc_ty_binding(tcx: TyCtxt, span: Span) { + pub fn prohibit_assoc_ty_binding(tcx: TyCtxt<'_, '_, '_>, span: Span) { let mut err = struct_span_err!(tcx.sess, span, E0229, "associated type bindings are not allowed here"); err.span_label(span, "associated type not allowed here").emit(); diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index 0e6ab5b1eb3b2..13469f1696631 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -183,7 +183,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let rhs_ty = self.check_expr(end); // Check that both end-points are of numeric or char type. - let numeric_or_char = |ty: Ty| ty.is_numeric() || ty.is_char(); + let numeric_or_char = |ty: Ty<'_>| ty.is_numeric() || ty.is_char(); let lhs_compat = numeric_or_char(lhs_ty); let rhs_compat = numeric_or_char(rhs_ty); diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index 1bbb93b4e461d..84d3c203afbe4 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -18,7 +18,7 @@ use rustc::hir; /// Checks that it is legal to call methods of the trait corresponding /// to `trait_id` (this only cares about the trait, not the specific /// method that is called). -pub fn check_legal_trait_for_method_call(tcx: TyCtxt, span: Span, trait_id: DefId) { +pub fn check_legal_trait_for_method_call(tcx: TyCtxt<'_, '_, '_>, span: Span, trait_id: DefId) { if tcx.lang_items().drop_trait() == Some(trait_id) { struct_span_err!(tcx.sess, span, E0040, "explicit use of destructor method") .span_label(span, "explicit destructor calls not allowed") diff --git a/src/librustc_typeck/check/closure.rs b/src/librustc_typeck/check/closure.rs index 722af8f0e778d..5f76524518390 100644 --- a/src/librustc_typeck/check/closure.rs +++ b/src/librustc_typeck/check/closure.rs @@ -574,7 +574,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { expr_def_id: DefId, decl: &hir::FnDecl, ) -> ty::PolyFnSig<'tcx> { - let astconv: &dyn AstConv = self; + let astconv: &dyn AstConv<'_, '_> = self; // First, convert the types that the user supplied (if any). let supplied_arguments = decl.inputs.iter().map(|a| astconv.ast_ty_to_ty(a)); @@ -606,7 +606,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { /// so should yield an error, but returns back a signature where /// all parameters are of type `TyErr`. fn error_sig_of_closure(&self, decl: &hir::FnDecl) -> ty::PolyFnSig<'tcx> { - let astconv: &dyn AstConv = self; + let astconv: &dyn AstConv<'_, '_> = self; let supplied_arguments = decl.inputs.iter().map(|a| { // Convert the types that the user supplied (if any), but ignore them. diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index 90071e3f3634a..8841f6b268419 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -101,7 +101,7 @@ fn coerce_mutbls<'tcx>(from_mutbl: hir::Mutability, } } -fn identity(_: Ty) -> Vec { vec![] } +fn identity(_: Ty<'_>) -> Vec> { vec![] } fn simple<'tcx>(kind: Adjust<'tcx>) -> impl FnOnce(Ty<'tcx>) -> Vec> { move |target| vec![Adjustment { kind, target }] @@ -1084,7 +1084,7 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E> pub fn coerce_forced_unit<'a>(&mut self, fcx: &FnCtxt<'a, 'gcx, 'tcx>, cause: &ObligationCause<'tcx>, - augment_error: &mut dyn FnMut(&mut DiagnosticBuilder), + augment_error: &mut dyn FnMut(&mut DiagnosticBuilder<'_>), label_unit_as_expected: bool) { self.coerce_inner(fcx, @@ -1103,7 +1103,7 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E> cause: &ObligationCause<'tcx>, expression: Option<&'gcx hir::Expr>, mut expression_ty: Ty<'tcx>, - augment_error: Option<&mut dyn FnMut(&mut DiagnosticBuilder)>, + augment_error: Option<&mut dyn FnMut(&mut DiagnosticBuilder<'_>)>, label_expression_as_expected: bool) { // Incorporate whatever type inference information we have diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index 5f1c2efb6a457..c6b34672e6b4c 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -408,7 +408,7 @@ fn check_region_bounds_on_impl_method<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn extract_spans_for_error_reporting<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a, 'gcx, 'tcx>, param_env: ty::ParamEnv<'tcx>, - terr: &TypeError, + terr: &TypeError<'_>, cause: &ObligationCause<'tcx>, impl_m: &ty::AssociatedItem, impl_sig: ty::FnSig<'tcx>, diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index 8b80fba4d19d0..adff5f2f9b9c8 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -544,7 +544,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { }; let into_sugg = into_suggestion.clone(); - let suggest_to_change_suffix_or_into = |err: &mut DiagnosticBuilder, + let suggest_to_change_suffix_or_into = |err: &mut DiagnosticBuilder<'_>, note: Option<&str>| { let suggest_msg = if literal_is_ty_suffixed(expr) { format!( diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index 34b248a106cb0..1eaa8b17d09f7 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -598,7 +598,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> { }) } - fn enforce_illegal_method_limitations(&self, pick: &probe::Pick) { + fn enforce_illegal_method_limitations(&self, pick: &probe::Pick<'_>) { // Disallow calls to the method `drop` defined in the `Drop` trait. match pick.item.container { ty::TraitContainer(trait_def_id) => { diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index 709177212ada7..04352626190f3 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -388,7 +388,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } } -pub fn provide(providers: &mut ty::query::Providers) { +pub fn provide(providers: &mut ty::query::Providers<'_>) { providers.method_autoderef_steps = method_autoderef_steps; } @@ -1180,7 +1180,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { fn emit_unstable_name_collision_hint( &self, - stable_pick: &Pick, + stable_pick: &Pick<'_>, unstable_candidates: &[(&Candidate<'tcx>, Symbol)], ) { let mut diag = self.tcx.struct_span_lint_hir( diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index ebbde4b581805..c15cb1e5bb151 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -72,7 +72,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { return; } - let report_candidates = |err: &mut DiagnosticBuilder, mut sources: Vec| { + let report_candidates = |err: &mut DiagnosticBuilder<'_>, + mut sources: Vec| { sources.sort(); sources.dedup(); // Dynamic limit to avoid hiding just one candidate, which is silly. @@ -497,7 +498,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } fn suggest_use_candidates(&self, - err: &mut DiagnosticBuilder, + err: &mut DiagnosticBuilder<'_>, mut msg: String, candidates: Vec) { let module_did = self.tcx.hir().get_module_parent_by_hir_id(self.body_id); @@ -549,7 +550,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } fn suggest_valid_traits(&self, - err: &mut DiagnosticBuilder, + err: &mut DiagnosticBuilder<'_>, valid_out_of_scope_traits: Vec) -> bool { if !valid_out_of_scope_traits.is_empty() { let mut candidates = valid_out_of_scope_traits; @@ -577,7 +578,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } fn suggest_traits_to_import<'b>(&self, - err: &mut DiagnosticBuilder, + err: &mut DiagnosticBuilder<'_>, span: Span, rcvr_ty: Ty<'tcx>, item_name: ast::Ident, @@ -648,8 +649,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { fn type_derefs_to_local(&self, span: Span, rcvr_ty: Ty<'tcx>, - source: SelfSource) -> bool { - fn is_local(ty: Ty) -> bool { + source: SelfSource<'_>) -> bool { + fn is_local(ty: Ty<'_>) -> bool { match ty.sty { ty::Adt(def, _) => def.did.is_local(), ty::Foreign(did) => did.is_local(), @@ -749,7 +750,7 @@ fn compute_all_traits<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Vec // Cross-crate: let mut external_mods = FxHashSet::default(); - fn handle_external_def(tcx: TyCtxt, + fn handle_external_def(tcx: TyCtxt<'_, '_, '_>, traits: &mut Vec, external_mods: &mut FxHashSet, def: Def) { @@ -779,7 +780,7 @@ fn compute_all_traits<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Vec traits } -pub fn provide(providers: &mut ty::query::Providers) { +pub fn provide(providers: &mut ty::query::Providers<'_>) { providers.all_traits = |tcx, cnum| { assert_eq!(cnum, LOCAL_CRATE); Lrc::new(compute_all_traits(tcx)) diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 3fe73e78bba83..2128466515123 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -738,7 +738,7 @@ fn check_impl_item_well_formed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: De wfcheck::check_impl_item(tcx, def_id); } -pub fn provide(providers: &mut Providers) { +pub fn provide(providers: &mut Providers<'_>) { method::provide(providers); *providers = Providers { typeck_item_bodies, @@ -1437,7 +1437,7 @@ pub fn check_item_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Ite } } -fn maybe_check_static_with_link_section(tcx: TyCtxt, id: DefId, span: Span) { +fn maybe_check_static_with_link_section(tcx: TyCtxt<'_, '_, '_>, id: DefId, span: Span) { // Only restricted on wasm32 target for now if !tcx.sess.opts.target_triple.triple().starts_with("wasm32") { return @@ -2122,7 +2122,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } pub fn tag(&self) -> String { - let self_ptr: *const FnCtxt = self; + let self_ptr: *const FnCtxt<'_, '_, '_> = self; format!("{:?}", self_ptr) } @@ -3369,7 +3369,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // (`only_has_type`); otherwise, we just go with a // fresh type variable. let coerce_to_ty = expected.coercion_target_type(self, sp); - let mut coerce: DynamicCoerceMany = CoerceMany::new(coerce_to_ty); + let mut coerce: DynamicCoerceMany<'_, '_> = CoerceMany::new(coerce_to_ty); coerce.coerce(self, &self.misc(sp), then_expr, then_ty); @@ -5043,7 +5043,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } /// Given a function `Node`, return its `FnDecl` if it exists, or `None` otherwise. - fn get_node_fn_decl(&self, node: Node) -> Option<(hir::FnDecl, ast::Ident, bool)> { + fn get_node_fn_decl(&self, node: Node<'_>) -> Option<(hir::FnDecl, ast::Ident, bool)> { match node { Node::Item(&hir::Item { ident, node: hir::ItemKind::Fn(ref decl, ..), .. diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index 9b1a656b1bc98..e6b4523f9e7cc 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -416,7 +416,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { rhs_expr: &'gcx hir::Expr, lhs_ty: Ty<'tcx>, rhs_ty: Ty<'tcx>, - err: &mut errors::DiagnosticBuilder, + err: &mut errors::DiagnosticBuilder<'_>, is_assign: bool, ) -> bool { let source_map = self.tcx.sess.source_map(); @@ -688,7 +688,7 @@ enum Op { /// Reason #2 is the killer. I tried for a while to always use /// overloaded logic and just check the types in constants/codegen after /// the fact, and it worked fine, except for SIMD types. -nmatsakis -fn is_builtin_binop(lhs: Ty, rhs: Ty, op: hir::BinOp) -> bool { +fn is_builtin_binop(lhs: Ty<'_>, rhs: Ty<'_>, op: hir::BinOp) -> bool { match BinOpCategory::from(op) { BinOpCategory::Shortcircuit => { true diff --git a/src/librustc_typeck/check/upvar.rs b/src/librustc_typeck/check/upvar.rs index 1816b7454dd2d..1a165e6ff1eb8 100644 --- a/src/librustc_typeck/check/upvar.rs +++ b/src/librustc_typeck/check/upvar.rs @@ -649,6 +649,6 @@ impl<'a, 'gcx, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'gcx, 'tcx> { } } -fn var_name(tcx: TyCtxt, var_hir_id: hir::HirId) -> ast::Name { +fn var_name(tcx: TyCtxt<'_, '_, '_>, var_hir_id: hir::HirId) -> ast::Name { tcx.hir().name_by_hir_id(var_hir_id) } diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 86b2e0bfe8aef..9217484f3a7af 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -938,7 +938,7 @@ fn report_bivariance<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, err.emit(); } -fn reject_shadowing_parameters(tcx: TyCtxt, def_id: DefId) { +fn reject_shadowing_parameters(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) { let generics = tcx.generics_of(def_id); let parent = tcx.generics_of(generics.parent.unwrap()); let impl_params: FxHashMap<_, _> = parent.params.iter().flat_map(|param| match param.kind { @@ -1093,7 +1093,7 @@ fn error_392<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, span: Span, param_name: ast: err } -fn error_194(tcx: TyCtxt, span: Span, trait_decl_span: Span, name: &str) { +fn error_194(tcx: TyCtxt<'_, '_, '_>, span: Span, trait_decl_span: Span, name: &str) { struct_span_err!(tcx.sess, span, E0194, "type parameter `{}` shadows another type parameter of the same name", name) diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index e4c0e3bd54d5d..c4575e6b01ee5 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -729,30 +729,30 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> { } trait Locatable { - fn to_span(&self, tcx: &TyCtxt) -> Span; + fn to_span(&self, tcx: &TyCtxt<'_, '_, '_>) -> Span; } impl Locatable for Span { - fn to_span(&self, _: &TyCtxt) -> Span { + fn to_span(&self, _: &TyCtxt<'_, '_, '_>) -> Span { *self } } impl Locatable for ast::NodeId { - fn to_span(&self, tcx: &TyCtxt) -> Span { + fn to_span(&self, tcx: &TyCtxt<'_, '_, '_>) -> Span { tcx.hir().span(*self) } } impl Locatable for DefIndex { - fn to_span(&self, tcx: &TyCtxt) -> Span { + fn to_span(&self, tcx: &TyCtxt<'_, '_, '_>) -> Span { let hir_id = tcx.hir().def_index_to_hir_id(*self); tcx.hir().span_by_hir_id(hir_id) } } impl Locatable for hir::HirId { - fn to_span(&self, tcx: &TyCtxt) -> Span { + fn to_span(&self, tcx: &TyCtxt<'_, '_, '_>) -> Span { tcx.hir().span_by_hir_id(*self) } } diff --git a/src/librustc_typeck/coherence/inherent_impls_overlap.rs b/src/librustc_typeck/coherence/inherent_impls_overlap.rs index 138c598a7bbf0..282f1bad172dc 100644 --- a/src/librustc_typeck/coherence/inherent_impls_overlap.rs +++ b/src/librustc_typeck/coherence/inherent_impls_overlap.rs @@ -20,7 +20,7 @@ struct InherentOverlapChecker<'a, 'tcx: 'a> { impl<'a, 'tcx> InherentOverlapChecker<'a, 'tcx> { fn check_for_common_items_in_impls(&self, impl1: DefId, impl2: DefId, - overlap: traits::OverlapResult, + overlap: traits::OverlapResult<'_>, used_to_be_allowed: bool) { let name_and_namespace = |def_id| { diff --git a/src/librustc_typeck/coherence/mod.rs b/src/librustc_typeck/coherence/mod.rs index 24e5ca989c4b2..01aba658850bf 100644 --- a/src/librustc_typeck/coherence/mod.rs +++ b/src/librustc_typeck/coherence/mod.rs @@ -41,7 +41,11 @@ fn check_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, node_id: ast::NodeId) { } } -fn enforce_trait_manually_implementable(tcx: TyCtxt, impl_def_id: DefId, trait_def_id: DefId) { +fn enforce_trait_manually_implementable( + tcx: TyCtxt<'_, '_, '_>, + impl_def_id: DefId, + trait_def_id: DefId +) { let did = Some(trait_def_id); let li = tcx.lang_items(); let span = tcx.sess.source_map().def_span(tcx.span_of_impl(impl_def_id).unwrap()); @@ -93,7 +97,11 @@ fn enforce_trait_manually_implementable(tcx: TyCtxt, impl_def_id: DefId, trait_d /// We allow impls of marker traits to overlap, so they can't override impls /// as that could make it ambiguous which associated item to use. -fn enforce_empty_impls_for_marker_traits(tcx: TyCtxt, impl_def_id: DefId, trait_def_id: DefId) { +fn enforce_empty_impls_for_marker_traits( + tcx: TyCtxt<'_, '_, '_>, + impl_def_id: DefId, + trait_def_id: DefId +) { if !tcx.trait_def(trait_def_id).is_marker { return; } @@ -110,7 +118,7 @@ fn enforce_empty_impls_for_marker_traits(tcx: TyCtxt, impl_def_id: DefId, trait_ .emit(); } -pub fn provide(providers: &mut Providers) { +pub fn provide(providers: &mut Providers<'_>) { use self::builtin::coerce_unsized_info; use self::inherent_impls::{crate_inherent_impls, inherent_impls}; use self::inherent_impls_overlap::crate_inherent_impls_overlap_check; diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index ba3df76050a8b..5af66969477ca 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -1406,7 +1406,7 @@ fn find_existential_constraints<'a, 'tcx>( ty::Param(p) => Some(*index_map.get(p).unwrap()), _ => None, }).collect(); - let is_param = |ty: ty::Ty| match ty.sty { + let is_param = |ty: ty::Ty<'_>| match ty.sty { ty::Param(_) => true, _ => false, }; @@ -2216,7 +2216,7 @@ fn compute_sig_of_foreign_fn_decl<'a, 'tcx>( && abi != abi::Abi::PlatformIntrinsic && !tcx.features().simd_ffi { - let check = |ast_ty: &hir::Ty, ty: Ty| { + let check = |ast_ty: &hir::Ty, ty: Ty<'_>| { if ty.is_simd() { tcx.sess .struct_span_err( @@ -2251,7 +2251,7 @@ fn is_foreign_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> bool } fn from_target_feature( - tcx: TyCtxt, + tcx: TyCtxt<'_, '_, '_>, id: DefId, attr: &ast::Attribute, whitelist: &FxHashMap>, diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 2dcb48692f6bd..3682acd3c62c1 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -74,8 +74,6 @@ This API is completely unstable and subject to change. #![deny(rust_2018_idioms)] #![allow(explicit_outlives_requirements)] -#![allow(elided_lifetimes_in_paths)] // WIP - #[macro_use] extern crate log; #[macro_use] extern crate syntax; diff --git a/src/librustc_typeck/variance/mod.rs b/src/librustc_typeck/variance/mod.rs index 347422780d516..c2f79207a5624 100644 --- a/src/librustc_typeck/variance/mod.rs +++ b/src/librustc_typeck/variance/mod.rs @@ -27,7 +27,7 @@ pub mod test; /// Code for transforming variances. mod xform; -pub fn provide(providers: &mut Providers) { +pub fn provide(providers: &mut Providers<'_>) { *providers = Providers { variances_of, crate_variances, @@ -91,4 +91,3 @@ fn variances_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_def_id: DefId) .unwrap_or(&crate_map.empty_variance) .clone() } - diff --git a/src/librustc_typeck/variance/solve.rs b/src/librustc_typeck/variance/solve.rs index 550c1b1d68bd3..f962c1313a923 100644 --- a/src/librustc_typeck/variance/solve.rs +++ b/src/librustc_typeck/variance/solve.rs @@ -23,7 +23,7 @@ struct SolveContext<'a, 'tcx: 'a> { solutions: Vec, } -pub fn solve_constraints(constraints_cx: ConstraintContext) -> ty::CrateVariancesMap { +pub fn solve_constraints(constraints_cx: ConstraintContext<'_, '_>) -> ty::CrateVariancesMap { let ConstraintContext { terms_cx, constraints, .. } = constraints_cx; let mut solutions = vec![ty::Bivariant; terms_cx.inferred_terms.len()]; diff --git a/src/librustc_typeck/variance/terms.rs b/src/librustc_typeck/variance/terms.rs index ec0acfb63a89a..4e562992e8cf9 100644 --- a/src/librustc_typeck/variance/terms.rs +++ b/src/librustc_typeck/variance/terms.rs @@ -32,7 +32,7 @@ pub enum VarianceTerm<'a> { } impl<'a> fmt::Debug for VarianceTerm<'a> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { ConstantTerm(c1) => write!(f, "{:?}", c1), TransformTerm(v1, v2) => write!(f, "({:?} \u{00D7} {:?})", v1, v2), @@ -86,7 +86,7 @@ pub fn determine_parameters_to_be_inferred<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx> terms_cx } -fn lang_items(tcx: TyCtxt) -> Vec<(ast::NodeId, Vec)> { +fn lang_items(tcx: TyCtxt<'_, '_, '_>) -> Vec<(ast::NodeId, Vec)> { let lang_items = tcx.lang_items(); let all = vec![ (lang_items.phantom_data(), vec![ty::Covariant]), From 235d3ed083d31b43c0c0ebf3ca125764d495aa4a Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Mon, 25 Feb 2019 09:19:20 +0100 Subject: [PATCH 09/11] librustc: deny(elided_lifetimes_in_paths) --- src/librustc/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 3d79b6777fa8b..205ea6126fc59 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -62,8 +62,6 @@ #![recursion_limit="512"] -#![warn(elided_lifetimes_in_paths)] - #[macro_use] extern crate bitflags; extern crate getopts; #[macro_use] extern crate lazy_static; From 70290947355188be67db4f721be636b0695a4c80 Mon Sep 17 00:00:00 2001 From: Jamie Turner Date: Mon, 25 Feb 2019 00:33:44 -0800 Subject: [PATCH 10/11] Test that binop subtyping in rustc_typeck fixes #27949 --- src/test/run-pass/issues/issue-27949.rs | 41 +++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/test/run-pass/issues/issue-27949.rs diff --git a/src/test/run-pass/issues/issue-27949.rs b/src/test/run-pass/issues/issue-27949.rs new file mode 100644 index 0000000000000..e905da72aad70 --- /dev/null +++ b/src/test/run-pass/issues/issue-27949.rs @@ -0,0 +1,41 @@ +// run-pass +// +// At one time, the `==` operator (and other binary operators) did not +// support subtyping during type checking, and would therefore require +// LHS and RHS to be exactly identical--i.e. to have the same lifetimes. +// +// This was fixed in 1a7fb7dc78439a704f024609ce3dc0beb1386552. + +#[derive(Copy, Clone)] +struct Input<'a> { + foo: &'a u32 +} + +impl <'a> std::cmp::PartialEq> for Input<'a> { + fn eq(&self, other: &Input<'a>) -> bool { + self.foo == other.foo + } + + fn ne(&self, other: &Input<'a>) -> bool { + self.foo != other.foo + } +} + + +fn check_equal<'a, 'b>(x: Input<'a>, y: Input<'b>) -> bool { + // Type checking error due to 'a != 'b prior to 1a7fb7dc78 + x == y +} + +fn main() { + let i = 1u32; + let j = 1u32; + let k = 2u32; + + let input_i = Input { foo: &i }; + let input_j = Input { foo: &j }; + let input_k = Input { foo: &k }; + assert!(check_equal(input_i, input_i)); + assert!(check_equal(input_i, input_j)); + assert!(!check_equal(input_i, input_k)); +} From 6343d6bc0da7ebeadb008f9184f9171fa6d8b900 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Mon, 25 Feb 2019 19:30:32 +0900 Subject: [PATCH 11/11] bootstrap: deny(rust_2018_idioms) --- src/bootstrap/builder.rs | 24 +++--- src/bootstrap/cache.rs | 6 +- src/bootstrap/cc_detect.rs | 3 +- src/bootstrap/check.rs | 56 +++++++++----- src/bootstrap/compile.rs | 113 ++++++++++++++++------------ src/bootstrap/dist.rs | 126 +++++++++++++++---------------- src/bootstrap/doc.rs | 89 +++++++++++----------- src/bootstrap/install.rs | 36 ++++----- src/bootstrap/lib.rs | 4 +- src/bootstrap/native.rs | 22 +++--- src/bootstrap/test.rs | 150 ++++++++++++++++++------------------- src/bootstrap/tool.rs | 36 ++++----- src/bootstrap/util.rs | 2 +- 13 files changed, 352 insertions(+), 315 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index c94d6cb4c1f5a..7e6c0a9f52aa2 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -62,13 +62,13 @@ pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash { /// Primary function to execute this rule. Can call `builder.ensure()` /// with other steps to run those. - fn run(self, builder: &Builder) -> Self::Output; + fn run(self, builder: &Builder<'_>) -> Self::Output; /// When bootstrap is passed a set of paths, this controls whether this rule /// will execute. However, it does not get called in a "default" context /// when we are not passed any paths; in that case, `make_run` is called /// directly. - fn should_run(run: ShouldRun) -> ShouldRun; + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_>; /// Builds up a "root" rule, either as a default rule or from a path passed /// to us. @@ -76,7 +76,7 @@ pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash { /// When path is `None`, we are executing in a context where no paths were /// passed. When `./x.py build` is run, for example, this rule could get /// called if it is in the correct list below with a path of `None`. - fn make_run(_run: RunConfig) { + fn make_run(_run: RunConfig<'_>) { // It is reasonable to not have an implementation of make_run for rules // who do not want to get called from the root context. This means that // they are likely dependencies (e.g., sysroot creation) or similar, and @@ -95,8 +95,8 @@ pub struct RunConfig<'a> { struct StepDescription { default: bool, only_hosts: bool, - should_run: fn(ShouldRun) -> ShouldRun, - make_run: fn(RunConfig), + should_run: fn(ShouldRun<'_>) -> ShouldRun<'_>, + make_run: fn(RunConfig<'_>), name: &'static str, } @@ -124,7 +124,7 @@ impl PathSet { } } - fn path(&self, builder: &Builder) -> PathBuf { + fn path(&self, builder: &Builder<'_>) -> PathBuf { match self { PathSet::Set(set) => set .iter() @@ -147,7 +147,7 @@ impl StepDescription { } } - fn maybe_run(&self, builder: &Builder, pathset: &PathSet) { + fn maybe_run(&self, builder: &Builder<'_>, pathset: &PathSet) { if builder.config.exclude.iter().any(|e| pathset.has(e)) { eprintln!("Skipping {:?} because it is excluded", pathset); return; @@ -183,7 +183,7 @@ impl StepDescription { } } - fn run(v: &[StepDescription], builder: &Builder, paths: &[PathBuf]) { + fn run(v: &[StepDescription], builder: &Builder<'_>, paths: &[PathBuf]) { let should_runs = v .iter() .map(|desc| (desc.should_run)(ShouldRun::new(builder))) @@ -245,7 +245,7 @@ pub struct ShouldRun<'a> { } impl<'a> ShouldRun<'a> { - fn new(builder: &'a Builder) -> ShouldRun<'a> { + fn new(builder: &'a Builder<'_>) -> ShouldRun<'a> { ShouldRun { builder, paths: BTreeSet::new(), @@ -511,7 +511,7 @@ impl<'a> Builder<'a> { Some(help) } - pub fn new(build: &Build) -> Builder { + pub fn new(build: &Build) -> Builder<'_> { let (kind, paths) = match build.config.cmd { Subcommand::Build { ref paths } => (Kind::Build, &paths[..]), Subcommand::Check { ref paths } => (Kind::Check, &paths[..]), @@ -591,11 +591,11 @@ impl<'a> Builder<'a> { impl Step for Libdir { type Output = Interned; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.never() } - fn run(self, builder: &Builder) -> Interned { + fn run(self, builder: &Builder<'_>) -> Interned { let compiler = self.compiler; let config = &builder.build.config; let lib = if compiler.stage >= 1 && config.libdir_relative().is_some() { diff --git a/src/bootstrap/cache.rs b/src/bootstrap/cache.rs index 5f84816789a68..239959682cb00 100644 --- a/src/bootstrap/cache.rs +++ b/src/bootstrap/cache.rs @@ -68,20 +68,20 @@ unsafe impl Send for Interned {} unsafe impl Sync for Interned {} impl fmt::Display for Interned { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let s: &str = &*self; f.write_str(s) } } impl fmt::Debug for Interned { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let s: &str = &*self; f.write_fmt(format_args!("{:?}", s)) } } impl fmt::Debug for Interned { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let s: &Path = &*self; f.write_fmt(format_args!("{:?}", s)) } diff --git a/src/bootstrap/cc_detect.rs b/src/bootstrap/cc_detect.rs index 37844759c7b9a..dfc243b7054ab 100644 --- a/src/bootstrap/cc_detect.rs +++ b/src/bootstrap/cc_detect.rs @@ -27,7 +27,6 @@ use std::path::{Path, PathBuf}; use std::process::Command; use build_helper::output; -use cc; use crate::{Build, GitRepo}; use crate::config::Target; @@ -157,7 +156,7 @@ fn set_compiler(cfg: &mut cc::Build, None => return, }; match output[i + 3..].chars().next().unwrap() { - '0' ... '6' => {} + '0' ..= '6' => {} _ => return, } let alternative = format!("e{}", gnu_compiler); diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index 2a2533a3c1407..20370372082b9 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -17,17 +17,17 @@ impl Step for Std { type Output = (); const DEFAULT: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.all_krates("std") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Std { target: run.target, }); } - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let target = self.target; let compiler = builder.compiler(0, builder.config.build); @@ -56,11 +56,11 @@ impl Step for Rustc { const ONLY_HOSTS: bool = true; const DEFAULT: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.all_krates("rustc-main") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Rustc { target: run.target, }); @@ -71,7 +71,7 @@ impl Step for Rustc { /// This will build the compiler for a particular stage of the build using /// the `compiler` targeting the `target` architecture. The artifacts /// created will also be linked into the sysroot directory. - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let compiler = builder.compiler(0, builder.config.build); let target = self.target; @@ -103,11 +103,11 @@ impl Step for CodegenBackend { const ONLY_HOSTS: bool = true; const DEFAULT: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.all_krates("rustc_codegen_llvm") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { let backend = run.builder.config.rust_codegen_backends.get(0); let backend = backend.cloned().unwrap_or_else(|| { INTERNER.intern_str("llvm") @@ -118,7 +118,7 @@ impl Step for CodegenBackend { }); } - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let compiler = builder.compiler(0, builder.config.build); let target = self.target; let backend = self.backend; @@ -148,17 +148,17 @@ impl Step for Test { type Output = (); const DEFAULT: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.all_krates("test") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Test { target: run.target, }); } - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let compiler = builder.compiler(0, builder.config.build); let target = self.target; @@ -189,17 +189,17 @@ impl Step for Rustdoc { const ONLY_HOSTS: bool = true; const DEFAULT: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/tools/rustdoc") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Rustdoc { target: run.target, }); } - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let compiler = builder.compiler(0, builder.config.build); let target = self.target; @@ -229,25 +229,37 @@ impl Step for Rustdoc { /// Cargo's output path for the standard library in a given stage, compiled /// by a particular compiler for the specified target. -pub fn libstd_stamp(builder: &Builder, compiler: Compiler, target: Interned) -> PathBuf { +pub fn libstd_stamp( + builder: &Builder<'_>, + compiler: Compiler, + target: Interned, +) -> PathBuf { builder.cargo_out(compiler, Mode::Std, target).join(".libstd-check.stamp") } /// Cargo's output path for libtest in a given stage, compiled by a particular /// compiler for the specified target. -pub fn libtest_stamp(builder: &Builder, compiler: Compiler, target: Interned) -> PathBuf { +pub fn libtest_stamp( + builder: &Builder<'_>, + compiler: Compiler, + target: Interned, +) -> PathBuf { builder.cargo_out(compiler, Mode::Test, target).join(".libtest-check.stamp") } /// Cargo's output path for librustc in a given stage, compiled by a particular /// compiler for the specified target. -pub fn librustc_stamp(builder: &Builder, compiler: Compiler, target: Interned) -> PathBuf { +pub fn librustc_stamp( + builder: &Builder<'_>, + compiler: Compiler, + target: Interned, +) -> PathBuf { builder.cargo_out(compiler, Mode::Rustc, target).join(".librustc-check.stamp") } /// Cargo's output path for librustc_codegen_llvm in a given stage, compiled by a particular /// compiler for the specified target and backend. -fn codegen_backend_stamp(builder: &Builder, +fn codegen_backend_stamp(builder: &Builder<'_>, compiler: Compiler, target: Interned, backend: Interned) -> PathBuf { @@ -257,7 +269,11 @@ fn codegen_backend_stamp(builder: &Builder, /// Cargo's output path for rustdoc in a given stage, compiled by a particular /// compiler for the specified target. -pub fn rustdoc_stamp(builder: &Builder, compiler: Compiler, target: Interned) -> PathBuf { +pub fn rustdoc_stamp( + builder: &Builder<'_>, + compiler: Compiler, + target: Interned, +) -> PathBuf { builder.cargo_out(compiler, Mode::ToolRustc, target) .join(".rustdoc-check.stamp") } diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 8fabb8c3fd08f..249a183189048 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -37,11 +37,11 @@ impl Step for Std { type Output = (); const DEFAULT: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.all_krates("std") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Std { compiler: run.builder.compiler(run.builder.top_stage, run.host), target: run.target, @@ -53,7 +53,7 @@ impl Step for Std { /// This will build the standard library for a particular stage of the build /// using the `compiler` targeting the `target` architecture. The artifacts /// created will also be linked into the sysroot directory. - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let target = self.target; let compiler = self.compiler; @@ -111,7 +111,7 @@ impl Step for Std { } /// Copies third pary objects needed by various targets. -fn copy_third_party_objects(builder: &Builder, compiler: &Compiler, target: Interned) { +fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target: Interned) { let libdir = builder.sysroot_libdir(*compiler, target); // Copies the crt(1,i,n).o startup objects @@ -145,7 +145,7 @@ fn copy_third_party_objects(builder: &Builder, compiler: &Compiler, target: Inte /// Configure cargo to compile the standard library, adding appropriate env vars /// and such. -pub fn std_cargo(builder: &Builder, +pub fn std_cargo(builder: &Builder<'_>, compiler: &Compiler, target: Interned, cargo: &mut Command) { @@ -201,7 +201,7 @@ struct StdLink { impl Step for StdLink { type Output = (); - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.never() } @@ -213,7 +213,7 @@ impl Step for StdLink { /// Note that this assumes that `compiler` has already generated the libstd /// libraries for `target`, and this method will find them in the relevant /// output directory. - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let compiler = self.compiler; let target_compiler = self.target_compiler; let target = self.target; @@ -237,7 +237,12 @@ impl Step for StdLink { } } -fn copy_apple_sanitizer_dylibs(builder: &Builder, native_dir: &Path, platform: &str, into: &Path) { +fn copy_apple_sanitizer_dylibs( + builder: &Builder<'_>, + native_dir: &Path, + platform: &str, + into: &Path, +) { for &sanitizer in &["asan", "tsan"] { let filename = format!("lib__rustc__clang_rt.{}_{}_dynamic.dylib", sanitizer, platform); let mut src_path = native_dir.join(sanitizer); @@ -258,11 +263,11 @@ pub struct StartupObjects { impl Step for StartupObjects { type Output = (); - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/rtstartup") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(StartupObjects { compiler: run.builder.compiler(run.builder.top_stage, run.host), target: run.target, @@ -275,7 +280,7 @@ impl Step for StartupObjects { /// They don't require any library support as they're just plain old object /// files, so we just use the nightly snapshot compiler to always build them (as /// no other compilers are guaranteed to be available). - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let for_compiler = self.compiler; let target = self.target; if !target.contains("pc-windows-gnu") { @@ -323,11 +328,11 @@ impl Step for Test { type Output = (); const DEFAULT: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.all_krates("test") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Test { compiler: run.builder.compiler(run.builder.top_stage, run.host), target: run.target, @@ -339,7 +344,7 @@ impl Step for Test { /// This will build libtest and supporting libraries for a particular stage of /// the build using the `compiler` targeting the `target` architecture. The /// artifacts created will also be linked into the sysroot directory. - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let target = self.target; let compiler = self.compiler; @@ -390,7 +395,7 @@ impl Step for Test { } /// Same as `std_cargo`, but for libtest -pub fn test_cargo(builder: &Builder, +pub fn test_cargo(builder: &Builder<'_>, _compiler: &Compiler, _target: Interned, cargo: &mut Command) { @@ -411,12 +416,12 @@ pub struct TestLink { impl Step for TestLink { type Output = (); - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.never() } /// Same as `std_link`, only for libtest - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let compiler = self.compiler; let target_compiler = self.target_compiler; let target = self.target; @@ -444,11 +449,11 @@ impl Step for Rustc { const ONLY_HOSTS: bool = true; const DEFAULT: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.all_krates("rustc-main") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Rustc { compiler: run.builder.compiler(run.builder.top_stage, run.host), target: run.target, @@ -460,7 +465,7 @@ impl Step for Rustc { /// This will build the compiler for a particular stage of the build using /// the `compiler` targeting the `target` architecture. The artifacts /// created will also be linked into the sysroot directory. - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let compiler = self.compiler; let target = self.target; @@ -516,14 +521,14 @@ impl Step for Rustc { } } -pub fn rustc_cargo(builder: &Builder, cargo: &mut Command) { +pub fn rustc_cargo(builder: &Builder<'_>, cargo: &mut Command) { cargo.arg("--features").arg(builder.rustc_features()) .arg("--manifest-path") .arg(builder.src.join("src/rustc/Cargo.toml")); rustc_cargo_env(builder, cargo); } -pub fn rustc_cargo_env(builder: &Builder, cargo: &mut Command) { +pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Command) { // Set some configuration variables picked up by build scripts and // the compiler alike cargo.env("CFG_RELEASE", builder.rust_release()) @@ -572,12 +577,12 @@ struct RustcLink { impl Step for RustcLink { type Output = (); - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.never() } /// Same as `std_link`, only for librustc - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let compiler = self.compiler; let target_compiler = self.target_compiler; let target = self.target; @@ -605,11 +610,11 @@ impl Step for CodegenBackend { const ONLY_HOSTS: bool = true; const DEFAULT: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.all_krates("rustc_codegen_llvm") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { let backend = run.builder.config.rust_codegen_backends.get(0); let backend = backend.cloned().unwrap_or_else(|| { INTERNER.intern_str("llvm") @@ -621,7 +626,7 @@ impl Step for CodegenBackend { }); } - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let compiler = self.compiler; let target = self.target; let backend = self.backend; @@ -684,7 +689,7 @@ impl Step for CodegenBackend { } } -pub fn build_codegen_backend(builder: &Builder, +pub fn build_codegen_backend(builder: &Builder<'_>, cargo: &mut Command, compiler: &Compiler, target: Interned, @@ -753,7 +758,7 @@ pub fn build_codegen_backend(builder: &Builder, /// This will take the codegen artifacts produced by `compiler` and link them /// into an appropriate location for `target_compiler` to be a functional /// compiler. -fn copy_codegen_backends_to_sysroot(builder: &Builder, +fn copy_codegen_backends_to_sysroot(builder: &Builder<'_>, compiler: Compiler, target_compiler: Compiler) { let target = target_compiler.host; @@ -791,7 +796,7 @@ fn copy_codegen_backends_to_sysroot(builder: &Builder, } } -fn copy_lld_to_sysroot(builder: &Builder, +fn copy_lld_to_sysroot(builder: &Builder<'_>, target_compiler: Compiler, lld_install_root: &Path) { let target = target_compiler.host; @@ -811,25 +816,37 @@ fn copy_lld_to_sysroot(builder: &Builder, /// Cargo's output path for the standard library in a given stage, compiled /// by a particular compiler for the specified target. -pub fn libstd_stamp(builder: &Builder, compiler: Compiler, target: Interned) -> PathBuf { +pub fn libstd_stamp( + builder: &Builder<'_>, + compiler: Compiler, + target: Interned, +) -> PathBuf { builder.cargo_out(compiler, Mode::Std, target).join(".libstd.stamp") } /// Cargo's output path for libtest in a given stage, compiled by a particular /// compiler for the specified target. -pub fn libtest_stamp(builder: &Builder, compiler: Compiler, target: Interned) -> PathBuf { +pub fn libtest_stamp( + builder: &Builder<'_>, + compiler: Compiler, + target: Interned, +) -> PathBuf { builder.cargo_out(compiler, Mode::Test, target).join(".libtest.stamp") } /// Cargo's output path for librustc in a given stage, compiled by a particular /// compiler for the specified target. -pub fn librustc_stamp(builder: &Builder, compiler: Compiler, target: Interned) -> PathBuf { +pub fn librustc_stamp( + builder: &Builder<'_>, + compiler: Compiler, + target: Interned, +) -> PathBuf { builder.cargo_out(compiler, Mode::Rustc, target).join(".librustc.stamp") } /// Cargo's output path for librustc_codegen_llvm in a given stage, compiled by a particular /// compiler for the specified target and backend. -fn codegen_backend_stamp(builder: &Builder, +fn codegen_backend_stamp(builder: &Builder<'_>, compiler: Compiler, target: Interned, backend: Interned) -> PathBuf { @@ -837,10 +854,12 @@ fn codegen_backend_stamp(builder: &Builder, .join(format!(".librustc_codegen_llvm-{}.stamp", backend)) } -pub fn compiler_file(builder: &Builder, - compiler: &Path, - target: Interned, - file: &str) -> PathBuf { +pub fn compiler_file( + builder: &Builder<'_>, + compiler: &Path, + target: Interned, + file: &str, +) -> PathBuf { let mut cmd = Command::new(compiler); cmd.args(builder.cflags(target, GitRepo::Rustc)); cmd.arg(format!("-print-file-name={}", file)); @@ -856,7 +875,7 @@ pub struct Sysroot { impl Step for Sysroot { type Output = Interned; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.never() } @@ -866,7 +885,7 @@ impl Step for Sysroot { /// That is, the sysroot for the stage0 compiler is not what the compiler /// thinks it is by default, but it's the same as the default for stages /// 1-3. - fn run(self, builder: &Builder) -> Interned { + fn run(self, builder: &Builder<'_>) -> Interned { let compiler = self.compiler; let sysroot = if compiler.stage == 0 { builder.out.join(&compiler.host).join("stage0-sysroot") @@ -891,7 +910,7 @@ pub struct Assemble { impl Step for Assemble { type Output = Compiler; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.never() } @@ -900,7 +919,7 @@ impl Step for Assemble { /// This will assemble a compiler in `build/$host/stage$stage`. The compiler /// must have been previously produced by the `stage - 1` builder.build /// compiler. - fn run(self, builder: &Builder) -> Compiler { + fn run(self, builder: &Builder<'_>) -> Compiler { let target_compiler = self.target_compiler; if target_compiler.stage == 0 { @@ -996,14 +1015,14 @@ impl Step for Assemble { /// /// For a particular stage this will link the file listed in `stamp` into the /// `sysroot_dst` provided. -pub fn add_to_sysroot(builder: &Builder, sysroot_dst: &Path, stamp: &Path) { +pub fn add_to_sysroot(builder: &Builder<'_>, sysroot_dst: &Path, stamp: &Path) { t!(fs::create_dir_all(&sysroot_dst)); for path in builder.read_stamp_file(stamp) { builder.copy(&path, &sysroot_dst.join(path.file_name().unwrap())); } } -pub fn run_cargo(builder: &Builder, +pub fn run_cargo(builder: &Builder<'_>, cargo: &mut Command, stamp: &Path, is_check: bool) @@ -1150,9 +1169,9 @@ pub fn run_cargo(builder: &Builder, } pub fn stream_cargo( - builder: &Builder, + builder: &Builder<'_>, cargo: &mut Command, - cb: &mut dyn FnMut(CargoMessage), + cb: &mut dyn FnMut(CargoMessage<'_>), ) -> bool { if builder.config.dry_run { return true; @@ -1174,7 +1193,7 @@ pub fn stream_cargo( let stdout = BufReader::new(child.stdout.take().unwrap()); for line in stdout.lines() { let line = t!(line); - match serde_json::from_str::(&line) { + match serde_json::from_str::>(&line) { Ok(msg) => cb(msg), // If this was informational, just print it out and continue Err(_) => println!("{}", line) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index bc1fdad356be3..2dae3f9135d84 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -25,7 +25,7 @@ use crate::tool::{self, Tool}; use crate::cache::{INTERNER, Interned}; use time::{self, Timespec}; -pub fn pkgname(builder: &Builder, component: &str) -> String { +pub fn pkgname(builder: &Builder<'_>, component: &str) -> String { if component == "cargo" { format!("{}-{}", component, builder.cargo_package_vers()) } else if component == "rls" { @@ -46,15 +46,15 @@ pub fn pkgname(builder: &Builder, component: &str) -> String { } } -fn distdir(builder: &Builder) -> PathBuf { +fn distdir(builder: &Builder<'_>) -> PathBuf { builder.out.join("dist") } -pub fn tmpdir(builder: &Builder) -> PathBuf { +pub fn tmpdir(builder: &Builder<'_>) -> PathBuf { builder.out.join("tmp/dist") } -fn rust_installer(builder: &Builder) -> Command { +fn rust_installer(builder: &Builder<'_>) -> Command { builder.tool_cmd(Tool::RustInstaller) } @@ -76,11 +76,11 @@ impl Step for Docs { type Output = PathBuf; const DEFAULT: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/doc") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Docs { stage: run.builder.top_stage, host: run.target, @@ -88,7 +88,7 @@ impl Step for Docs { } /// Builds the `rust-docs` installer component. - fn run(self, builder: &Builder) -> PathBuf { + fn run(self, builder: &Builder<'_>) -> PathBuf { let host = self.host; let name = pkgname(builder, "rust-docs"); @@ -138,11 +138,11 @@ impl Step for RustcDocs { type Output = PathBuf; const DEFAULT: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/librustc") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(RustcDocs { stage: run.builder.top_stage, host: run.target, @@ -150,7 +150,7 @@ impl Step for RustcDocs { } /// Builds the `rustc-docs` installer component. - fn run(self, builder: &Builder) -> PathBuf { + fn run(self, builder: &Builder<'_>) -> PathBuf { let host = self.host; let name = pkgname(builder, "rustc-docs"); @@ -210,7 +210,7 @@ fn find_files(files: &[&str], path: &[PathBuf]) -> Vec { } fn make_win_dist( - rust_root: &Path, plat_root: &Path, target_triple: Interned, builder: &Builder + rust_root: &Path, plat_root: &Path, target_triple: Interned, builder: &Builder<'_> ) { //Ask gcc where it keeps its stuff let mut cmd = Command::new(builder.cc(target_triple)); @@ -334,11 +334,11 @@ impl Step for Mingw { type Output = Option; const DEFAULT: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.never() } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Mingw { host: run.target }); } @@ -346,7 +346,7 @@ impl Step for Mingw { /// /// This contains all the bits and pieces to run the MinGW Windows targets /// without any extra installed software (e.g., we bundle gcc, libraries, etc). - fn run(self, builder: &Builder) -> Option { + fn run(self, builder: &Builder<'_>) -> Option { let host = self.host; if !host.contains("pc-windows-gnu") { @@ -392,18 +392,18 @@ impl Step for Rustc { const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/librustc") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Rustc { compiler: run.builder.compiler(run.builder.top_stage, run.target), }); } /// Creates the `rustc` installer component. - fn run(self, builder: &Builder) -> PathBuf { + fn run(self, builder: &Builder<'_>) -> PathBuf { let compiler = self.compiler; let host = self.compiler.host; @@ -470,7 +470,7 @@ impl Step for Rustc { return distdir(builder).join(format!("{}-{}.tar.gz", name, host)); - fn prepare_image(builder: &Builder, compiler: Compiler, image: &Path) { + fn prepare_image(builder: &Builder<'_>, compiler: Compiler, image: &Path) { let host = compiler.host; let src = builder.sysroot(compiler); let libdir = libdir(&host); @@ -580,11 +580,11 @@ pub struct DebuggerScripts { impl Step for DebuggerScripts { type Output = (); - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/lldb_batchmode.py") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(DebuggerScripts { sysroot: run.builder.sysroot(run.builder.compiler(run.builder.top_stage, run.host)), host: run.target, @@ -592,7 +592,7 @@ impl Step for DebuggerScripts { } /// Copies debugger scripts for `target` into the `sysroot` specified. - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let host = self.host; let sysroot = self.sysroot; let dst = sysroot.join("lib/rustlib/etc"); @@ -639,18 +639,18 @@ impl Step for Std { type Output = PathBuf; const DEFAULT: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/libstd") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Std { compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build), target: run.target, }); } - fn run(self, builder: &Builder) -> PathBuf { + fn run(self, builder: &Builder<'_>) -> PathBuf { let compiler = self.compiler; let target = self.target; @@ -728,12 +728,12 @@ impl Step for Analysis { type Output = PathBuf; const DEFAULT: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { let builder = run.builder; run.path("analysis").default_condition(builder.config.extended) } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Analysis { compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build), target: run.target, @@ -741,7 +741,7 @@ impl Step for Analysis { } /// Creates a tarball of save-analysis metadata, if available. - fn run(self, builder: &Builder) -> PathBuf { + fn run(self, builder: &Builder<'_>) -> PathBuf { let compiler = self.compiler; let target = self.target; assert!(builder.config.extended); @@ -791,7 +791,7 @@ impl Step for Analysis { } } -fn copy_src_dirs(builder: &Builder, src_dirs: &[&str], exclude_dirs: &[&str], dst_dir: &Path) { +fn copy_src_dirs(builder: &Builder<'_>, src_dirs: &[&str], exclude_dirs: &[&str], dst_dir: &Path) { fn filter_fn(exclude_dirs: &[&str], dir: &str, path: &Path) -> bool { let spath = match path.to_str() { Some(path) => path, @@ -861,16 +861,16 @@ impl Step for Src { const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Src); } /// Creates the `rust-src` installer component - fn run(self, builder: &Builder) -> PathBuf { + fn run(self, builder: &Builder<'_>) -> PathBuf { builder.info("Dist src"); let name = pkgname(builder, "rust-src"); @@ -941,17 +941,17 @@ impl Step for PlainSourceTarball { const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { let builder = run.builder; run.path("src").default_condition(builder.config.rust_dist_src) } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(PlainSourceTarball); } /// Creates the plain source tarball - fn run(self, builder: &Builder) -> PathBuf { + fn run(self, builder: &Builder<'_>) -> PathBuf { builder.info("Create plain source tarball"); // Make sure that the root folder of tarball has the correct name @@ -1069,18 +1069,18 @@ impl Step for Cargo { type Output = PathBuf; const ONLY_HOSTS: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("cargo") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Cargo { stage: run.builder.top_stage, target: run.target, }); } - fn run(self, builder: &Builder) -> PathBuf { + fn run(self, builder: &Builder<'_>) -> PathBuf { let stage = self.stage; let target = self.target; @@ -1155,18 +1155,18 @@ impl Step for Rls { type Output = Option; const ONLY_HOSTS: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("rls") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Rls { stage: run.builder.top_stage, target: run.target, }); } - fn run(self, builder: &Builder) -> Option { + fn run(self, builder: &Builder<'_>) -> Option { let stage = self.stage; let target = self.target; assert!(builder.config.extended); @@ -1234,18 +1234,18 @@ impl Step for Clippy { type Output = Option; const ONLY_HOSTS: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("clippy") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Clippy { stage: run.builder.top_stage, target: run.target, }); } - fn run(self, builder: &Builder) -> Option { + fn run(self, builder: &Builder<'_>) -> Option { let stage = self.stage; let target = self.target; assert!(builder.config.extended); @@ -1318,18 +1318,18 @@ impl Step for Miri { type Output = Option; const ONLY_HOSTS: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("miri") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Miri { stage: run.builder.top_stage, target: run.target, }); } - fn run(self, builder: &Builder) -> Option { + fn run(self, builder: &Builder<'_>) -> Option { let stage = self.stage; let target = self.target; assert!(builder.config.extended); @@ -1402,18 +1402,18 @@ impl Step for Rustfmt { type Output = Option; const ONLY_HOSTS: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("rustfmt") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Rustfmt { stage: run.builder.top_stage, target: run.target, }); } - fn run(self, builder: &Builder) -> Option { + fn run(self, builder: &Builder<'_>) -> Option { let stage = self.stage; let target = self.target; @@ -1485,12 +1485,12 @@ impl Step for Extended { const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { let builder = run.builder; run.path("extended").default_condition(builder.config.extended) } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Extended { stage: run.builder.top_stage, host: run.builder.config.build, @@ -1499,7 +1499,7 @@ impl Step for Extended { } /// Creates a combined installer for the specified target in the provided stage. - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let stage = self.stage; let target = self.target; @@ -1949,7 +1949,7 @@ impl Step for Extended { } } -fn add_env(builder: &Builder, cmd: &mut Command, target: Interned) { +fn add_env(builder: &Builder<'_>, cmd: &mut Command, target: Interned) { let mut parts = channel::CFG_RELEASE_NUM.split('.'); cmd.env("CFG_RELEASE_INFO", builder.rust_version()) .env("CFG_RELEASE_NUM", channel::CFG_RELEASE_NUM) @@ -1985,15 +1985,15 @@ impl Step for HashSign { type Output = (); const ONLY_HOSTS: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("hash-and-sign") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(HashSign); } - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let mut cmd = builder.tool_cmd(Tool::BuildManifest); if builder.config.dry_run { return; @@ -2037,7 +2037,7 @@ impl Step for HashSign { // LLVM tools are linked dynamically. // Note: This function does no yet support Windows but we also don't support // linking LLVM tools dynamically on Windows yet. -pub fn maybe_install_llvm_dylib(builder: &Builder, +pub fn maybe_install_llvm_dylib(builder: &Builder<'_>, target: Interned, sysroot: &Path) { let src_libdir = builder @@ -2079,18 +2079,18 @@ impl Step for LlvmTools { type Output = Option; const ONLY_HOSTS: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("llvm-tools") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(LlvmTools { stage: run.builder.top_stage, target: run.target, }); } - fn run(self, builder: &Builder) -> Option { + fn run(self, builder: &Builder<'_>) -> Option { let stage = self.stage; let target = self.target; assert!(builder.config.extended); @@ -2163,17 +2163,17 @@ impl Step for Lldb { const ONLY_HOSTS: bool = true; const DEFAULT: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/llvm-project/lldb").path("src/tools/lldb") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Lldb { target: run.target, }); } - fn run(self, builder: &Builder) -> Option { + fn run(self, builder: &Builder<'_>) -> Option { let target = self.target; if builder.config.dry_run { diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 660f9b9ef578a..40f0e5ede8bd7 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -34,18 +34,18 @@ macro_rules! book { type Output = (); const DEFAULT: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { let builder = run.builder; run.path($path).default_condition(builder.config.docs) } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure($name { target: run.target, }); } - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { builder.ensure(Rustbook { target: self.target, name: INTERNER.intern_str($book_name), @@ -87,7 +87,7 @@ impl Step for Rustbook { // rustbook is never directly called, and only serves as a shim for the nomicon and the // reference. - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.never() } @@ -95,7 +95,7 @@ impl Step for Rustbook { /// /// This will not actually generate any documentation if the documentation has /// already been generated. - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let src = builder.src.join("src/doc"); builder.ensure(RustbookSrc { target: self.target, @@ -115,18 +115,18 @@ impl Step for UnstableBook { type Output = (); const DEFAULT: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { let builder = run.builder; run.path("src/doc/unstable-book").default_condition(builder.config.docs) } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(UnstableBook { target: run.target, }); } - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { builder.ensure(UnstableBookGen { target: self.target, }); @@ -149,19 +149,19 @@ impl Step for CargoBook { type Output = (); const DEFAULT: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { let builder = run.builder; run.path("src/tools/cargo/src/doc/book").default_condition(builder.config.docs) } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(CargoBook { target: run.target, name: INTERNER.intern_str("cargo"), }); } - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let target = self.target; let name = self.name; let src = builder.src.join("src/tools/cargo/src/doc"); @@ -194,7 +194,7 @@ struct RustbookSrc { impl Step for RustbookSrc { type Output = (); - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.never() } @@ -202,7 +202,7 @@ impl Step for RustbookSrc { /// /// This will not actually generate any documentation if the documentation has /// already been generated. - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let target = self.target; let name = self.name; let src = self.src; @@ -246,12 +246,12 @@ impl Step for TheBook { type Output = (); const DEFAULT: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { let builder = run.builder; run.path("src/doc/book").default_condition(builder.config.docs) } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(TheBook { compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build), target: run.target, @@ -268,7 +268,7 @@ impl Step for TheBook { /// * Version info and CSS /// * Index page /// * Redirect pages - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let compiler = self.compiler; let target = self.target; let name = self.name; @@ -321,7 +321,12 @@ impl Step for TheBook { } } -fn invoke_rustdoc(builder: &Builder, compiler: Compiler, target: Interned, markdown: &str) { +fn invoke_rustdoc( + builder: &Builder<'_>, + compiler: Compiler, + target: Interned, + markdown: &str, +) { let out = builder.doc_out(target); let path = builder.src.join("src/doc").join(markdown); @@ -358,12 +363,12 @@ impl Step for Standalone { type Output = (); const DEFAULT: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { let builder = run.builder; run.path("src/doc").default_condition(builder.config.docs) } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Standalone { compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build), target: run.target, @@ -378,7 +383,7 @@ impl Step for Standalone { /// `STAMP` along with providing the various header/footer HTML we've customized. /// /// In the end, this is just a glorified wrapper around rustdoc! - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let target = self.target; let compiler = self.compiler; builder.info(&format!("Documenting standalone ({})", target)); @@ -452,12 +457,12 @@ impl Step for Std { type Output = (); const DEFAULT: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { let builder = run.builder; run.all_krates("std").default_condition(builder.config.docs) } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Std { stage: run.builder.top_stage, target: run.target @@ -468,7 +473,7 @@ impl Step for Std { /// /// This will generate all documentation for the standard library and its /// dependencies. This is largely just a wrapper around `cargo doc`. - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let stage = self.stage; let target = self.target; builder.info(&format!("Documenting stage{} std ({})", stage, target)); @@ -539,12 +544,12 @@ impl Step for Test { type Output = (); const DEFAULT: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { let builder = run.builder; run.krate("test").default_condition(builder.config.docs) } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Test { stage: run.builder.top_stage, target: run.target, @@ -555,7 +560,7 @@ impl Step for Test { /// /// This will generate all documentation for libtest and its dependencies. This /// is largely just a wrapper around `cargo doc`. - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let stage = self.stage; let target = self.target; builder.info(&format!("Documenting stage{} test ({})", stage, target)); @@ -602,12 +607,12 @@ impl Step for WhitelistedRustc { const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { let builder = run.builder; run.krate("rustc-main").default_condition(builder.config.docs) } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(WhitelistedRustc { stage: run.builder.top_stage, target: run.target, @@ -623,7 +628,7 @@ impl Step for WhitelistedRustc { /// documentation. We don't build other compiler documentation /// here as we want to be able to keep it separate from the standard /// documentation. This is largely just a wrapper around `cargo doc`. - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let stage = self.stage; let target = self.target; builder.info(&format!("Documenting stage{} whitelisted compiler ({})", stage, target)); @@ -674,12 +679,12 @@ impl Step for Rustc { const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { let builder = run.builder; run.krate("rustc-main").default_condition(builder.config.docs) } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Rustc { stage: run.builder.top_stage, target: run.target, @@ -692,7 +697,7 @@ impl Step for Rustc { /// Compiler documentation is distributed separately, so we make sure /// we do not merge it with the other documentation from std, test and /// proc_macros. This is largely just a wrapper around `cargo doc`. - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let stage = self.stage; let target = self.target; builder.info(&format!("Documenting stage{} compiler ({})", stage, target)); @@ -750,7 +755,7 @@ impl Step for Rustc { } fn find_compiler_crates( - builder: &Builder, + builder: &Builder<'_>, name: &Interned, crates: &mut HashSet> ) { @@ -776,11 +781,11 @@ impl Step for Rustdoc { const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.krate("rustdoc-tool") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Rustdoc { stage: run.builder.top_stage, target: run.target, @@ -793,7 +798,7 @@ impl Step for Rustdoc { /// Compiler documentation is distributed separately, so we make sure /// we do not merge it with the other documentation from std, test and /// proc_macros. This is largely just a wrapper around `cargo doc`. - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let stage = self.stage; let target = self.target; builder.info(&format!("Documenting stage{} rustdoc ({})", stage, target)); @@ -859,12 +864,12 @@ impl Step for ErrorIndex { const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { let builder = run.builder; run.path("src/tools/error_index_generator").default_condition(builder.config.docs) } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(ErrorIndex { target: run.target, }); @@ -872,7 +877,7 @@ impl Step for ErrorIndex { /// Generates the HTML rendered error-index by running the /// `error_index_generator` tool. - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let target = self.target; builder.info(&format!("Documenting error index ({})", target)); @@ -900,18 +905,18 @@ impl Step for UnstableBookGen { const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { let builder = run.builder; run.path("src/tools/unstable-book-gen").default_condition(builder.config.docs) } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(UnstableBookGen { target: run.target, }); } - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let target = self.target; builder.ensure(compile::Std { diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs index 1265fa9eff45b..2d040d60e5fd7 100644 --- a/src/bootstrap/install.rs +++ b/src/bootstrap/install.rs @@ -14,45 +14,45 @@ use crate::builder::{Builder, RunConfig, ShouldRun, Step}; use crate::cache::Interned; use crate::config::Config; -pub fn install_docs(builder: &Builder, stage: u32, host: Interned) { +pub fn install_docs(builder: &Builder<'_>, stage: u32, host: Interned) { install_sh(builder, "docs", "rust-docs", stage, Some(host)); } -pub fn install_std(builder: &Builder, stage: u32, target: Interned) { +pub fn install_std(builder: &Builder<'_>, stage: u32, target: Interned) { install_sh(builder, "std", "rust-std", stage, Some(target)); } -pub fn install_cargo(builder: &Builder, stage: u32, host: Interned) { +pub fn install_cargo(builder: &Builder<'_>, stage: u32, host: Interned) { install_sh(builder, "cargo", "cargo", stage, Some(host)); } -pub fn install_rls(builder: &Builder, stage: u32, host: Interned) { +pub fn install_rls(builder: &Builder<'_>, stage: u32, host: Interned) { install_sh(builder, "rls", "rls", stage, Some(host)); } -pub fn install_clippy(builder: &Builder, stage: u32, host: Interned) { +pub fn install_clippy(builder: &Builder<'_>, stage: u32, host: Interned) { install_sh(builder, "clippy", "clippy", stage, Some(host)); } -pub fn install_miri(builder: &Builder, stage: u32, host: Interned) { +pub fn install_miri(builder: &Builder<'_>, stage: u32, host: Interned) { install_sh(builder, "miri", "miri", stage, Some(host)); } -pub fn install_rustfmt(builder: &Builder, stage: u32, host: Interned) { +pub fn install_rustfmt(builder: &Builder<'_>, stage: u32, host: Interned) { install_sh(builder, "rustfmt", "rustfmt", stage, Some(host)); } -pub fn install_analysis(builder: &Builder, stage: u32, host: Interned) { +pub fn install_analysis(builder: &Builder<'_>, stage: u32, host: Interned) { install_sh(builder, "analysis", "rust-analysis", stage, Some(host)); } -pub fn install_src(builder: &Builder, stage: u32) { +pub fn install_src(builder: &Builder<'_>, stage: u32) { install_sh(builder, "src", "rust-src", stage, None); } -pub fn install_rustc(builder: &Builder, stage: u32, host: Interned) { +pub fn install_rustc(builder: &Builder<'_>, stage: u32, host: Interned) { install_sh(builder, "rustc", "rustc", stage, Some(host)); } fn install_sh( - builder: &Builder, + builder: &Builder<'_>, package: &str, name: &str, stage: u32, @@ -155,7 +155,7 @@ macro_rules! install { } #[allow(dead_code)] - fn should_install(builder: &Builder) -> bool { + fn should_install(builder: &Builder<'_>) -> bool { builder.config.tools.as_ref().map_or(false, |t| t.contains($path)) } } @@ -166,12 +166,12 @@ macro_rules! install { const ONLY_HOSTS: bool = $only_hosts; $(const $c: bool = true;)* - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { let $_config = &run.builder.config; run.path($path).default_condition($default_cond) } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure($name { stage: run.builder.top_stage, target: run.target, @@ -179,7 +179,7 @@ macro_rules! install { }); } - fn run($sel, $builder: &Builder) { + fn run($sel, $builder: &Builder<'_>) { $run_item } })+ @@ -262,20 +262,20 @@ impl Step for Src { const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { let config = &run.builder.config; let cond = config.extended && config.tools.as_ref().map_or(true, |t| t.contains("src")); run.path("src").default_condition(cond) } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Src { stage: run.builder.top_stage, }); } - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { builder.ensure(dist::Src); install_src(builder, self.stage); } diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 2dceb30c4ad7d..84e2c5aab54a3 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -103,7 +103,7 @@ //! More documentation can be found in each respective module below, and you can //! also check out the `src/bootstrap/README.md` file for more information. -#![deny(bare_trait_objects)] +#![deny(rust_2018_idioms)] #![deny(warnings)] #![feature(core_intrinsics)] #![feature(drain_filter)] @@ -164,8 +164,6 @@ mod job; #[cfg(all(unix, not(target_os = "haiku")))] mod job { - use libc; - pub unsafe fn setup(build: &mut crate::Build) { if build.config.low_priority { libc::setpriority(libc::PRIO_PGRP as _, 0, 10); diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index f48f9ee752e93..192b1cd1fbb75 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -35,14 +35,14 @@ impl Step for Llvm { const ONLY_HOSTS: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/llvm-project") .path("src/llvm-project/llvm") .path("src/llvm") .path("src/llvm-emscripten") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { let emscripten = run.path.ends_with("llvm-emscripten"); run.builder.ensure(Llvm { target: run.target, @@ -51,7 +51,7 @@ impl Step for Llvm { } /// Compile LLVM for `target`. - fn run(self, builder: &Builder) -> PathBuf { + fn run(self, builder: &Builder<'_>) -> PathBuf { let target = self.target; let emscripten = self.emscripten; @@ -261,7 +261,7 @@ impl Step for Llvm { } } -fn check_llvm_version(builder: &Builder, llvm_config: &Path) { +fn check_llvm_version(builder: &Builder<'_>, llvm_config: &Path) { if !builder.config.llvm_version_check { return } @@ -282,7 +282,7 @@ fn check_llvm_version(builder: &Builder, llvm_config: &Path) { panic!("\n\nbad LLVM version: {}, need >=6.0\n\n", version) } -fn configure_cmake(builder: &Builder, +fn configure_cmake(builder: &Builder<'_>, target: Interned, cfg: &mut cmake::Config) { if builder.config.ninja { @@ -417,16 +417,16 @@ impl Step for Lld { type Output = PathBuf; const ONLY_HOSTS: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/llvm-project/lld").path("src/tools/lld") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Lld { target: run.target }); } /// Compile LLVM for `target`. - fn run(self, builder: &Builder) -> PathBuf { + fn run(self, builder: &Builder<'_>) -> PathBuf { if builder.config.dry_run { return PathBuf::from("lld-out-dir-test-gen"); } @@ -489,17 +489,17 @@ pub struct TestHelpers { impl Step for TestHelpers { type Output = (); - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/test/auxiliary/rust_test_helpers.c") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(TestHelpers { target: run.target }) } /// Compiles the `rust_test_helpers.c` library which we used in various /// `run-pass` test suites for ABI testing. - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { if builder.config.dry_run { return; } diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index a882550f734f4..51412f79c3d0c 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -57,7 +57,7 @@ impl TestKind { } impl fmt::Display for TestKind { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(match *self { TestKind::Test => "Testing", TestKind::Bench => "Benchmarking", @@ -65,7 +65,7 @@ impl fmt::Display for TestKind { } } -fn try_run(builder: &Builder, cmd: &mut Command) -> bool { +fn try_run(builder: &Builder<'_>, cmd: &mut Command) -> bool { if !builder.fail_fast { if !builder.try_run(cmd) { let mut failures = builder.delayed_failures.borrow_mut(); @@ -78,7 +78,7 @@ fn try_run(builder: &Builder, cmd: &mut Command) -> bool { true } -fn try_run_quiet(builder: &Builder, cmd: &mut Command) -> bool { +fn try_run_quiet(builder: &Builder<'_>, cmd: &mut Command) -> bool { if !builder.fail_fast { if !builder.try_run_quiet(cmd) { let mut failures = builder.delayed_failures.borrow_mut(); @@ -105,7 +105,7 @@ impl Step for Linkcheck { /// /// This tool in `src/tools` will verify the validity of all our links in the /// documentation to ensure we don't have a bunch of dead ones. - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let host = self.host; builder.info(&format!("Linkcheck ({})", host)); @@ -121,13 +121,13 @@ impl Step for Linkcheck { ); } - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { let builder = run.builder; run.path("src/tools/linkchecker") .default_condition(builder.config.docs) } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Linkcheck { host: run.target }); } } @@ -142,11 +142,11 @@ impl Step for Cargotest { type Output = (); const ONLY_HOSTS: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/tools/cargotest") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Cargotest { stage: run.builder.top_stage, host: run.target, @@ -157,7 +157,7 @@ impl Step for Cargotest { /// /// This tool in `src/tools` will check out a few Rust projects and run `cargo /// test` to ensure that we don't regress the test suites there. - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let compiler = builder.compiler(self.stage, self.host); builder.ensure(compile::Rustc { compiler, @@ -192,11 +192,11 @@ impl Step for Cargo { type Output = (); const ONLY_HOSTS: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/tools/cargo") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Cargo { stage: run.builder.top_stage, host: run.target, @@ -204,7 +204,7 @@ impl Step for Cargo { } /// Runs `cargo test` for `cargo` packaged with Rust. - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let compiler = builder.compiler(self.stage, self.host); builder.ensure(tool::Cargo { @@ -247,11 +247,11 @@ impl Step for Rls { type Output = (); const ONLY_HOSTS: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/tools/rls") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Rls { stage: run.builder.top_stage, host: run.target, @@ -259,7 +259,7 @@ impl Step for Rls { } /// Runs `cargo test` for the rls. - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let stage = self.stage; let host = self.host; let compiler = builder.compiler(stage, host); @@ -303,11 +303,11 @@ impl Step for Rustfmt { type Output = (); const ONLY_HOSTS: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/tools/rustfmt") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Rustfmt { stage: run.builder.top_stage, host: run.target, @@ -315,7 +315,7 @@ impl Step for Rustfmt { } /// Runs `cargo test` for rustfmt. - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let stage = self.stage; let host = self.host; let compiler = builder.compiler(stage, host); @@ -362,12 +362,12 @@ impl Step for Miri { const ONLY_HOSTS: bool = true; const DEFAULT: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { let test_miri = run.builder.config.test_miri; run.path("src/tools/miri").default_condition(test_miri) } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Miri { stage: run.builder.top_stage, host: run.target, @@ -375,7 +375,7 @@ impl Step for Miri { } /// Runs `cargo test` for miri. - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let stage = self.stage; let host = self.host; let compiler = builder.compiler(stage, host); @@ -421,11 +421,11 @@ pub struct CompiletestTest { impl Step for CompiletestTest { type Output = (); - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/tools/compiletest") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(CompiletestTest { stage: run.builder.top_stage, host: run.target, @@ -433,7 +433,7 @@ impl Step for CompiletestTest { } /// Runs `cargo test` for compiletest. - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let stage = self.stage; let host = self.host; let compiler = builder.compiler(stage, host); @@ -462,11 +462,11 @@ impl Step for Clippy { const ONLY_HOSTS: bool = true; const DEFAULT: bool = false; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/tools/clippy") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Clippy { stage: run.builder.top_stage, host: run.target, @@ -474,7 +474,7 @@ impl Step for Clippy { } /// Runs `cargo test` for clippy. - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let stage = self.stage; let host = self.host; let compiler = builder.compiler(stage, host); @@ -516,7 +516,7 @@ impl Step for Clippy { } } -fn path_for_cargo(builder: &Builder, compiler: Compiler) -> OsString { +fn path_for_cargo(builder: &Builder<'_>, compiler: Compiler) -> OsString { // Configure PATH to find the right rustc. NB. we have to use PATH // and not RUSTC because the Cargo test suite has tests that will // fail if rustc is not spelled `rustc`. @@ -535,17 +535,17 @@ impl Step for RustdocTheme { const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/tools/rustdoc-themes") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { let compiler = run.builder.compiler(run.builder.top_stage, run.host); run.builder.ensure(RustdocTheme { compiler }); } - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let rustdoc = builder.out.join("bootstrap/debug/rustdoc"); let mut cmd = builder.tool_cmd(Tool::RustdocTheme); cmd.arg(rustdoc.to_str().unwrap()) @@ -584,18 +584,18 @@ impl Step for RustdocJS { const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/test/rustdoc-js") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(RustdocJS { host: run.host, target: run.target, }); } - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { if let Some(ref nodejs) = builder.config.nodejs { let mut command = Command::new(nodejs); command.args(&["src/tools/rustdoc-js/tester.js", &*self.host]); @@ -624,11 +624,11 @@ impl Step for RustdocUi { const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/test/rustdoc-ui") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { let compiler = run.builder.compiler(run.builder.top_stage, run.host); run.builder.ensure(RustdocUi { host: run.host, @@ -637,7 +637,7 @@ impl Step for RustdocUi { }); } - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { builder.ensure(Compiletest { compiler: self.compiler, target: self.target, @@ -662,7 +662,7 @@ impl Step for Tidy { /// This tool in `src/tools` checks up on various bits and pieces of style and /// otherwise just implements a few lint-like checks that are specific to the /// compiler itself. - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let mut cmd = builder.tool_cmd(Tool::Tidy); cmd.arg(builder.src.join("src")); cmd.arg(&builder.initial_cargo); @@ -678,16 +678,16 @@ impl Step for Tidy { try_run(builder, &mut cmd); } - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/tools/tidy") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Tidy); } } -fn testdir(builder: &Builder, host: Interned) -> PathBuf { +fn testdir(builder: &Builder<'_>, host: Interned) -> PathBuf { builder.out.join(host).join("test") } @@ -747,11 +747,11 @@ macro_rules! test_definitions { const DEFAULT: bool = $default; const ONLY_HOSTS: bool = $host; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.suite_path($path) } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { let compiler = run.builder.compiler(run.builder.top_stage, run.host); run.builder.ensure($name { @@ -760,7 +760,7 @@ macro_rules! test_definitions { }); } - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { builder.ensure(Compiletest { compiler: self.compiler, target: self.target, @@ -908,7 +908,7 @@ struct Compiletest { impl Step for Compiletest { type Output = (); - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.never() } @@ -917,7 +917,7 @@ impl Step for Compiletest { /// Compiles all tests with `compiler` for `target` with the specified /// compiletest `mode` and `suite` arguments. For example `mode` can be /// "run-pass" or `suite` can be something like `debuginfo`. - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let compiler = self.compiler; let target = self.target; let mode = self.mode; @@ -1284,7 +1284,7 @@ impl Step for DocTest { type Output = (); const ONLY_HOSTS: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.never() } @@ -1293,7 +1293,7 @@ impl Step for DocTest { /// This will run all tests in our markdown documentation (e.g., the book) /// located in `src/doc`. The `rustdoc` that's run is the one that sits next to /// `compiler`. - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let compiler = self.compiler; builder.ensure(compile::Test { @@ -1354,17 +1354,17 @@ macro_rules! test_book { const DEFAULT: bool = $default; const ONLY_HOSTS: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path($path) } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure($name { compiler: run.builder.compiler(run.builder.top_stage, run.host), }); } - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { builder.ensure(DocTest { compiler: self.compiler, path: $path, @@ -1398,11 +1398,11 @@ impl Step for ErrorIndex { const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/tools/error_index_generator") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(ErrorIndex { compiler: run.builder.compiler(run.builder.top_stage, run.host), }); @@ -1414,7 +1414,7 @@ impl Step for ErrorIndex { /// The `error_index_generator` tool lives in `src/tools` and is used to /// generate a markdown file from the error indexes of the code base which is /// then passed to `rustdoc --test`. - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let compiler = self.compiler; builder.ensure(compile::Std { @@ -1440,7 +1440,7 @@ impl Step for ErrorIndex { } } -fn markdown_test(builder: &Builder, compiler: Compiler, markdown: &Path) -> bool { +fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) -> bool { match fs::read_to_string(markdown) { Ok(contents) => { if !contents.contains("```") { @@ -1480,11 +1480,11 @@ impl Step for CrateLibrustc { const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.krate("rustc-main") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { let builder = run.builder; let compiler = builder.compiler(builder.top_stage, run.host); @@ -1502,7 +1502,7 @@ impl Step for CrateLibrustc { } } - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { builder.ensure(Crate { compiler: self.compiler, target: self.target, @@ -1524,14 +1524,14 @@ pub struct CrateNotDefault { impl Step for CrateNotDefault { type Output = (); - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/librustc_asan") .path("src/librustc_lsan") .path("src/librustc_msan") .path("src/librustc_tsan") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { let builder = run.builder; let compiler = builder.compiler(builder.top_stage, run.host); @@ -1551,7 +1551,7 @@ impl Step for CrateNotDefault { }); } - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { builder.ensure(Crate { compiler: self.compiler, target: self.target, @@ -1575,7 +1575,7 @@ impl Step for Crate { type Output = (); const DEFAULT: bool = true; - fn should_run(mut run: ShouldRun) -> ShouldRun { + fn should_run(mut run: ShouldRun<'_>) -> ShouldRun<'_> { let builder = run.builder; run = run.krate("test"); for krate in run.builder.in_tree_crates("std") { @@ -1586,7 +1586,7 @@ impl Step for Crate { run } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { let builder = run.builder; let compiler = builder.compiler(builder.top_stage, run.host); @@ -1622,7 +1622,7 @@ impl Step for Crate { /// /// Currently this runs all tests for a DAG by passing a bunch of `-p foo` /// arguments, and those arguments are discovered from `cargo metadata`. - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let compiler = self.compiler; let target = self.target; let mode = self.mode; @@ -1763,11 +1763,11 @@ impl Step for CrateRustdoc { const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.paths(&["src/librustdoc", "src/tools/rustdoc"]) } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { let builder = run.builder; let test_kind = builder.kind.into(); @@ -1778,7 +1778,7 @@ impl Step for CrateRustdoc { }); } - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let test_kind = self.test_kind; let compiler = builder.compiler(builder.top_stage, self.host); @@ -1846,11 +1846,11 @@ pub struct RemoteCopyLibs { impl Step for RemoteCopyLibs { type Output = (); - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.never() } - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let compiler = self.compiler; let target = self.target; if !builder.remote_tested(target) { @@ -1896,16 +1896,16 @@ pub struct Distcheck; impl Step for Distcheck { type Output = (); - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("distcheck") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Distcheck); } /// Runs "distcheck", a 'make check' from a tarball - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { builder.info("Distcheck"); let dir = builder.out.join("tmp").join("distcheck"); let _ = fs::remove_dir_all(&dir); @@ -1966,7 +1966,7 @@ impl Step for Bootstrap { const ONLY_HOSTS: bool = true; /// Tests the build system itself. - fn run(self, builder: &Builder) { + fn run(self, builder: &Builder<'_>) { let mut cmd = Command::new(&builder.initial_cargo); cmd.arg("test") .current_dir(builder.src.join("src/bootstrap")) @@ -1990,11 +1990,11 @@ impl Step for Bootstrap { try_run(builder, &mut cmd); } - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/bootstrap") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Bootstrap); } } diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index 6383a2ecc7583..fc1a17d546675 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -36,7 +36,7 @@ struct ToolBuild { impl Step for ToolBuild { type Output = Option; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.never() } @@ -44,7 +44,7 @@ impl Step for ToolBuild { /// /// This will build the specified tool with the specified `host` compiler in /// `stage` into the normal cargo output directory. - fn run(self, builder: &Builder) -> Option { + fn run(self, builder: &Builder<'_>) -> Option { let compiler = self.compiler; let target = self.target; let tool = self.tool; @@ -192,7 +192,7 @@ impl Step for ToolBuild { } pub fn prepare_tool_cargo( - builder: &Builder, + builder: &Builder<'_>, compiler: Compiler, mode: Mode, target: Interned, @@ -315,18 +315,18 @@ macro_rules! tool { impl Step for $name { type Output = PathBuf; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path($path) } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure($name { compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build), target: run.target, }); } - fn run(self, builder: &Builder) -> PathBuf { + fn run(self, builder: &Builder<'_>) -> PathBuf { builder.ensure(ToolBuild { compiler: self.compiler, target: self.target, @@ -371,18 +371,18 @@ pub struct RemoteTestServer { impl Step for RemoteTestServer { type Output = PathBuf; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/tools/remote-test-server") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(RemoteTestServer { compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build), target: run.target, }); } - fn run(self, builder: &Builder) -> PathBuf { + fn run(self, builder: &Builder<'_>) -> PathBuf { builder.ensure(ToolBuild { compiler: self.compiler, target: self.target, @@ -406,17 +406,17 @@ impl Step for Rustdoc { const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/tools/rustdoc") } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Rustdoc { host: run.host, }); } - fn run(self, builder: &Builder) -> PathBuf { + fn run(self, builder: &Builder<'_>) -> PathBuf { let target_compiler = builder.compiler(builder.top_stage, self.host); if target_compiler.stage == 0 { if !target_compiler.is_snapshot(builder) { @@ -490,19 +490,19 @@ impl Step for Cargo { const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { let builder = run.builder; run.path("src/tools/cargo").default_condition(builder.config.extended) } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Cargo { compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build), target: run.target, }); } - fn run(self, builder: &Builder) -> PathBuf { + fn run(self, builder: &Builder<'_>) -> PathBuf { // Cargo depends on procedural macros, which requires a full host // compiler to be available, so we need to depend on that. builder.ensure(compile::Rustc { @@ -542,12 +542,12 @@ macro_rules! tool_extended { const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; - fn should_run(run: ShouldRun) -> ShouldRun { + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { let builder = run.builder; run.path($path).default_condition(builder.config.extended) } - fn make_run(run: RunConfig) { + fn make_run(run: RunConfig<'_>) { run.builder.ensure($name { compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build), target: run.target, @@ -556,7 +556,7 @@ macro_rules! tool_extended { } #[allow(unused_mut)] - fn run(mut $sel, $builder: &Builder) -> Option { + fn run(mut $sel, $builder: &Builder<'_>) -> Option { $extra_deps $builder.ensure(ToolBuild { compiler: $sel.compiler, diff --git a/src/bootstrap/util.rs b/src/bootstrap/util.rs index 29aa98971fb56..bda1e56e1e73b 100644 --- a/src/bootstrap/util.rs +++ b/src/bootstrap/util.rs @@ -95,7 +95,7 @@ pub fn push_exe_path(mut buf: PathBuf, components: &[&str]) -> PathBuf { pub struct TimeIt(bool, Instant); /// Returns an RAII structure that prints out how long it took to drop. -pub fn timeit(builder: &Builder) -> TimeIt { +pub fn timeit(builder: &Builder<'_>) -> TimeIt { TimeIt(builder.config.dry_run, Instant::now()) }