diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2021-09-18 17:37:24 -0400 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2021-09-20 08:45:39 -0400 |
| commit | 45b989a03319c6a53bb726ec98dfe7d172035ac6 (patch) | |
| tree | 072c2bea54d0a91860739ab5aa5e3293a3d9c66a | |
| parent | 5e1a614b5369c430a383beaf1aec04f09740edbb (diff) | |
| download | rust-45b989a03319c6a53bb726ec98dfe7d172035ac6.tar.gz rust-45b989a03319c6a53bb726ec98dfe7d172035ac6.zip | |
Enable 2021 compatibility lints for all in-tree code
This just applies the suggested fixes from the compatibility warnings, leaving any that are in practice spurious in. This is primarily intended to provide a starting point to identify possible fixes to the migrations (e.g., by avoiding spurious warnings). A secondary commit cleans these up where they are false positives (as is true in many of the cases).
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/back/lto.rs | 7 | ||||
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/validity.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_infer/src/infer/at.rs | 32 | ||||
| -rw-r--r-- | compiler/rustc_interface/src/util.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/lints.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/specialize/mod.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs | 29 | ||||
| -rw-r--r-- | compiler/rustc_typeck/src/check/compare_method.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_typeck/src/check/method/probe.rs | 1 | ||||
| -rw-r--r-- | src/librustdoc/doctest.rs | 1 | ||||
| -rw-r--r-- | src/tools/clippy/clippy_utils/src/lib.rs | 5 |
12 files changed, 52 insertions, 34 deletions
diff --git a/compiler/rustc_codegen_llvm/src/back/lto.rs b/compiler/rustc_codegen_llvm/src/back/lto.rs index f612785e5a4..fcb79c8332c 100644 --- a/compiler/rustc_codegen_llvm/src/back/lto.rs +++ b/compiler/rustc_codegen_llvm/src/back/lto.rs @@ -906,8 +906,11 @@ impl ThinLTOKeysMap { ) -> Self { let keys = iter::zip(modules, names) .map(|(module, name)| { - let key = build_string(|rust_str| unsafe { - llvm::LLVMRustComputeLTOCacheKey(rust_str, module.identifier, data.0); + let key = build_string(|rust_str| { + let _ = &data; + unsafe { + llvm::LLVMRustComputeLTOCacheKey(rust_str, module.identifier, data.0); + } }) .expect("Invalid ThinLTO module key"); (name.clone().into_string().unwrap(), key) diff --git a/compiler/rustc_const_eval/src/interpret/validity.rs b/compiler/rustc_const_eval/src/interpret/validity.rs index a6375ad0e02..fc69770bf6a 100644 --- a/compiler/rustc_const_eval/src/interpret/validity.rs +++ b/compiler/rustc_const_eval/src/interpret/validity.rs @@ -77,7 +77,7 @@ macro_rules! throw_validation_failure { /// macro_rules! try_validation { ($e:expr, $where:expr, - $( $( $p:pat )|+ => { $( $what_fmt:expr ),+ } $( expected { $( $expected_fmt:expr ),+ } )? ),+ $(,)? + $( $( $p:pat_param )|+ => { $( $what_fmt:expr ),+ } $( expected { $( $expected_fmt:expr ),+ } )? ),+ $(,)? ) => {{ match $e { Ok(x) => x, diff --git a/compiler/rustc_infer/src/infer/at.rs b/compiler/rustc_infer/src/infer/at.rs index 11ee8fb17ad..33ce8f5f97f 100644 --- a/compiler/rustc_infer/src/infer/at.rs +++ b/compiler/rustc_infer/src/infer/at.rs @@ -195,10 +195,10 @@ impl<'a, 'tcx> Trace<'a, 'tcx> { let Trace { at, trace, a_is_expected } = self; at.infcx.commit_if_ok(|_| { let mut fields = at.infcx.combine_fields(trace, at.param_env); - fields - .sub(a_is_expected) - .relate(a, b) - .map(move |_| InferOk { value: (), obligations: fields.obligations }) + fields.sub(a_is_expected).relate(a, b).map(move |_| { + let _ = &fields; + InferOk { value: (), obligations: fields.obligations } + }) }) } @@ -212,10 +212,10 @@ impl<'a, 'tcx> Trace<'a, 'tcx> { let Trace { at, trace, a_is_expected } = self; at.infcx.commit_if_ok(|_| { let mut fields = at.infcx.combine_fields(trace, at.param_env); - fields - .equate(a_is_expected) - .relate(a, b) - .map(move |_| InferOk { value: (), obligations: fields.obligations }) + fields.equate(a_is_expected).relate(a, b).map(move |_| { + let _ = &fields; + InferOk { value: (), obligations: fields.obligations } + }) }) } @@ -227,10 +227,10 @@ impl<'a, 'tcx> Trace<'a, 'tcx> { let Trace { at, trace, a_is_expected } = self; at.infcx.commit_if_ok(|_| { let mut fields = at.infcx.combine_fields(trace, at.param_env); - fields - .lub(a_is_expected) - .relate(a, b) - .map(move |t| InferOk { value: t, obligations: fields.obligations }) + fields.lub(a_is_expected).relate(a, b).map(move |t| { + let _ = &fields; + InferOk { value: t, obligations: fields.obligations } + }) }) } @@ -242,10 +242,10 @@ impl<'a, 'tcx> Trace<'a, 'tcx> { let Trace { at, trace, a_is_expected } = self; at.infcx.commit_if_ok(|_| { let mut fields = at.infcx.combine_fields(trace, at.param_env); - fields - .glb(a_is_expected) - .relate(a, b) - .map(move |t| InferOk { value: t, obligations: fields.obligations }) + fields.glb(a_is_expected).relate(a, b).map(move |t| { + let _ = &fields; + InferOk { value: t, obligations: fields.obligations } + }) }) } } diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs index a5f0c014778..3d90a6c9345 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -125,6 +125,7 @@ pub fn scoped_thread<F: FnOnce() -> R + Send, R: Send>(cfg: thread::Builder, f: let result_ptr = Ptr(&mut result as *mut _ as *mut ()); let thread = cfg.spawn(move || { + let _ = (&run, &result_ptr); let run = unsafe { (*(run.0 as *mut Option<F>)).take().unwrap() }; let result = unsafe { &mut *(result_ptr.0 as *mut Option<R>) }; *result = Some(run()); diff --git a/compiler/rustc_mir_build/src/lints.rs b/compiler/rustc_mir_build/src/lints.rs index ef8bd20d510..2d408e577d1 100644 --- a/compiler/rustc_mir_build/src/lints.rs +++ b/compiler/rustc_mir_build/src/lints.rs @@ -41,6 +41,7 @@ crate fn check<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) { let hir_id = tcx.hir().local_def_id_to_hir_id(def_id); let sp = tcx.sess.source_map().guess_head_span(tcx.hir().span_with_body(hir_id)); tcx.struct_span_lint_hir(UNCONDITIONAL_RECURSION, hir_id, sp, |lint| { + let _ = &vis; let mut db = lint.build("function cannot return without recursing"); db.span_label(sp, "cannot return without recursing"); // offer some help to the programmer. diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs index b5398f8a435..8ee217655d9 100644 --- a/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs +++ b/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs @@ -40,7 +40,10 @@ where info!("fully_perform({:?})", self); } - scrape_region_constraints(infcx, || (self.closure)(infcx)) + scrape_region_constraints(infcx, || { + let _ = &self; + (self.closure)(infcx) + }) } } diff --git a/compiler/rustc_trait_selection/src/traits/specialize/mod.rs b/compiler/rustc_trait_selection/src/traits/specialize/mod.rs index 88aca794a6b..36fe0594983 100644 --- a/compiler/rustc_trait_selection/src/traits/specialize/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/specialize/mod.rs @@ -394,6 +394,7 @@ fn report_conflicting_impls( // now because the struct_lint methods don't return back the DiagnosticBuilder // that's passed in. let decorate = |err: LintDiagnosticBuilder<'_>| { + let _ = &overlap; let msg = format!( "conflicting implementations of trait `{}`{}{}", overlap.trait_desc, diff --git a/compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs b/compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs index c8bcab6efd7..c3e5b79c8f4 100644 --- a/compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs +++ b/compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs @@ -104,19 +104,22 @@ impl ChildrenExt for Children { let self_ty = trait_ref.self_ty(); // FIXME: should postpone string formatting until we decide to actually emit. - with_no_trimmed_paths(|| OverlapError { - with_impl: possible_sibling, - trait_desc: trait_ref.print_only_trait_path().to_string(), - // Only report the `Self` type if it has at least - // some outer concrete shell; otherwise, it's - // not adding much information. - self_desc: if self_ty.has_concrete_skeleton() { - Some(self_ty.to_string()) - } else { - None - }, - intercrate_ambiguity_causes: overlap.intercrate_ambiguity_causes, - involves_placeholder: overlap.involves_placeholder, + with_no_trimmed_paths(|| { + let _ = &overlap; + OverlapError { + with_impl: possible_sibling, + trait_desc: trait_ref.print_only_trait_path().to_string(), + // Only report the `Self` type if it has at least + // some outer concrete shell; otherwise, it's + // not adding much information. + self_desc: if self_ty.has_concrete_skeleton() { + Some(self_ty.to_string()) + } else { + None + }, + intercrate_ambiguity_causes: overlap.intercrate_ambiguity_causes, + involves_placeholder: overlap.involves_placeholder, + } }) }; diff --git a/compiler/rustc_typeck/src/check/compare_method.rs b/compiler/rustc_typeck/src/check/compare_method.rs index d5b631df058..b359e8b2ebe 100644 --- a/compiler/rustc_typeck/src/check/compare_method.rs +++ b/compiler/rustc_typeck/src/check/compare_method.rs @@ -1192,6 +1192,7 @@ fn compare_type_predicate_entailment<'tcx>( normalize_cause.clone(), ); tcx.infer_ctxt().enter(|infcx| { + let _ = &impl_ty_own_bounds; let inh = Inherited::new(infcx, impl_ty.def_id.expect_local()); let infcx = &inh.infcx; diff --git a/compiler/rustc_typeck/src/check/method/probe.rs b/compiler/rustc_typeck/src/check/method/probe.rs index cbfdce96bc5..56b15883013 100644 --- a/compiler/rustc_typeck/src/check/method/probe.rs +++ b/compiler/rustc_typeck/src/check/method/probe.rs @@ -441,6 +441,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // this creates one big transaction so that all type variables etc // that we create during the probe process are removed later self.probe(|_| { + let _ = &steps; let mut probe_cx = ProbeContext::new( self, span, diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index dbeea9cddf3..71bdfdd4ade 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -964,6 +964,7 @@ impl Tester for Collector { test_type: test::TestType::DocTest, }, testfn: test::DynTestFn(Box::new(move || { + let _ = &config; let report_unused_externs = |uext| { unused_externs.lock().unwrap().push(uext); }; diff --git a/src/tools/clippy/clippy_utils/src/lib.rs b/src/tools/clippy/clippy_utils/src/lib.rs index 3a94f472983..5c505f6851a 100644 --- a/src/tools/clippy/clippy_utils/src/lib.rs +++ b/src/tools/clippy/clippy_utils/src/lib.rs @@ -990,7 +990,10 @@ pub fn can_move_expr_to_closure(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> captures: HirIdMap::default(), }; v.visit_expr(expr); - v.allow_closure.then(|| v.captures) + v.allow_closure.then(|| { + let _ = &v; + v.captures + }) } /// Returns the method names and argument list of nested method call expressions that make up |
