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).
This commit is contained in:
Mark Rousskov 2021-09-18 17:37:24 -04:00
parent 5e1a614b53
commit 45b989a033
12 changed files with 52 additions and 34 deletions

View file

@ -906,8 +906,11 @@ impl ThinLTOKeysMap {
) -> Self { ) -> Self {
let keys = iter::zip(modules, names) let keys = iter::zip(modules, names)
.map(|(module, name)| { .map(|(module, name)| {
let key = build_string(|rust_str| unsafe { let key = build_string(|rust_str| {
let _ = &data;
unsafe {
llvm::LLVMRustComputeLTOCacheKey(rust_str, module.identifier, data.0); llvm::LLVMRustComputeLTOCacheKey(rust_str, module.identifier, data.0);
}
}) })
.expect("Invalid ThinLTO module key"); .expect("Invalid ThinLTO module key");
(name.clone().into_string().unwrap(), key) (name.clone().into_string().unwrap(), key)

View file

@ -77,7 +77,7 @@ macro_rules! throw_validation_failure {
/// ///
macro_rules! try_validation { macro_rules! try_validation {
($e:expr, $where:expr, ($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 { match $e {
Ok(x) => x, Ok(x) => x,

View file

@ -195,10 +195,10 @@ impl<'a, 'tcx> Trace<'a, 'tcx> {
let Trace { at, trace, a_is_expected } = self; let Trace { at, trace, a_is_expected } = self;
at.infcx.commit_if_ok(|_| { at.infcx.commit_if_ok(|_| {
let mut fields = at.infcx.combine_fields(trace, at.param_env); let mut fields = at.infcx.combine_fields(trace, at.param_env);
fields fields.sub(a_is_expected).relate(a, b).map(move |_| {
.sub(a_is_expected) let _ = &fields;
.relate(a, b) InferOk { value: (), obligations: fields.obligations }
.map(move |_| InferOk { value: (), obligations: fields.obligations }) })
}) })
} }
@ -212,10 +212,10 @@ impl<'a, 'tcx> Trace<'a, 'tcx> {
let Trace { at, trace, a_is_expected } = self; let Trace { at, trace, a_is_expected } = self;
at.infcx.commit_if_ok(|_| { at.infcx.commit_if_ok(|_| {
let mut fields = at.infcx.combine_fields(trace, at.param_env); let mut fields = at.infcx.combine_fields(trace, at.param_env);
fields fields.equate(a_is_expected).relate(a, b).map(move |_| {
.equate(a_is_expected) let _ = &fields;
.relate(a, b) InferOk { value: (), obligations: fields.obligations }
.map(move |_| InferOk { value: (), obligations: fields.obligations }) })
}) })
} }
@ -227,10 +227,10 @@ impl<'a, 'tcx> Trace<'a, 'tcx> {
let Trace { at, trace, a_is_expected } = self; let Trace { at, trace, a_is_expected } = self;
at.infcx.commit_if_ok(|_| { at.infcx.commit_if_ok(|_| {
let mut fields = at.infcx.combine_fields(trace, at.param_env); let mut fields = at.infcx.combine_fields(trace, at.param_env);
fields fields.lub(a_is_expected).relate(a, b).map(move |t| {
.lub(a_is_expected) let _ = &fields;
.relate(a, b) InferOk { value: t, obligations: fields.obligations }
.map(move |t| InferOk { value: t, obligations: fields.obligations }) })
}) })
} }
@ -242,10 +242,10 @@ impl<'a, 'tcx> Trace<'a, 'tcx> {
let Trace { at, trace, a_is_expected } = self; let Trace { at, trace, a_is_expected } = self;
at.infcx.commit_if_ok(|_| { at.infcx.commit_if_ok(|_| {
let mut fields = at.infcx.combine_fields(trace, at.param_env); let mut fields = at.infcx.combine_fields(trace, at.param_env);
fields fields.glb(a_is_expected).relate(a, b).map(move |t| {
.glb(a_is_expected) let _ = &fields;
.relate(a, b) InferOk { value: t, obligations: fields.obligations }
.map(move |t| InferOk { value: t, obligations: fields.obligations }) })
}) })
} }
} }

View file

@ -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 result_ptr = Ptr(&mut result as *mut _ as *mut ());
let thread = cfg.spawn(move || { let thread = cfg.spawn(move || {
let _ = (&run, &result_ptr);
let run = unsafe { (*(run.0 as *mut Option<F>)).take().unwrap() }; let run = unsafe { (*(run.0 as *mut Option<F>)).take().unwrap() };
let result = unsafe { &mut *(result_ptr.0 as *mut Option<R>) }; let result = unsafe { &mut *(result_ptr.0 as *mut Option<R>) };
*result = Some(run()); *result = Some(run());

View file

@ -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 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)); 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| { tcx.struct_span_lint_hir(UNCONDITIONAL_RECURSION, hir_id, sp, |lint| {
let _ = &vis;
let mut db = lint.build("function cannot return without recursing"); let mut db = lint.build("function cannot return without recursing");
db.span_label(sp, "cannot return without recursing"); db.span_label(sp, "cannot return without recursing");
// offer some help to the programmer. // offer some help to the programmer.

View file

@ -40,7 +40,10 @@ where
info!("fully_perform({:?})", self); info!("fully_perform({:?})", self);
} }
scrape_region_constraints(infcx, || (self.closure)(infcx)) scrape_region_constraints(infcx, || {
let _ = &self;
(self.closure)(infcx)
})
} }
} }

View file

@ -394,6 +394,7 @@ fn report_conflicting_impls(
// now because the struct_lint methods don't return back the DiagnosticBuilder // now because the struct_lint methods don't return back the DiagnosticBuilder
// that's passed in. // that's passed in.
let decorate = |err: LintDiagnosticBuilder<'_>| { let decorate = |err: LintDiagnosticBuilder<'_>| {
let _ = &overlap;
let msg = format!( let msg = format!(
"conflicting implementations of trait `{}`{}{}", "conflicting implementations of trait `{}`{}{}",
overlap.trait_desc, overlap.trait_desc,

View file

@ -104,7 +104,9 @@ impl ChildrenExt for Children {
let self_ty = trait_ref.self_ty(); let self_ty = trait_ref.self_ty();
// FIXME: should postpone string formatting until we decide to actually emit. // FIXME: should postpone string formatting until we decide to actually emit.
with_no_trimmed_paths(|| OverlapError { with_no_trimmed_paths(|| {
let _ = &overlap;
OverlapError {
with_impl: possible_sibling, with_impl: possible_sibling,
trait_desc: trait_ref.print_only_trait_path().to_string(), trait_desc: trait_ref.print_only_trait_path().to_string(),
// Only report the `Self` type if it has at least // Only report the `Self` type if it has at least
@ -117,6 +119,7 @@ impl ChildrenExt for Children {
}, },
intercrate_ambiguity_causes: overlap.intercrate_ambiguity_causes, intercrate_ambiguity_causes: overlap.intercrate_ambiguity_causes,
involves_placeholder: overlap.involves_placeholder, involves_placeholder: overlap.involves_placeholder,
}
}) })
}; };

View file

@ -1192,6 +1192,7 @@ fn compare_type_predicate_entailment<'tcx>(
normalize_cause.clone(), normalize_cause.clone(),
); );
tcx.infer_ctxt().enter(|infcx| { tcx.infer_ctxt().enter(|infcx| {
let _ = &impl_ty_own_bounds;
let inh = Inherited::new(infcx, impl_ty.def_id.expect_local()); let inh = Inherited::new(infcx, impl_ty.def_id.expect_local());
let infcx = &inh.infcx; let infcx = &inh.infcx;

View file

@ -441,6 +441,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// this creates one big transaction so that all type variables etc // this creates one big transaction so that all type variables etc
// that we create during the probe process are removed later // that we create during the probe process are removed later
self.probe(|_| { self.probe(|_| {
let _ = &steps;
let mut probe_cx = ProbeContext::new( let mut probe_cx = ProbeContext::new(
self, self,
span, span,

View file

@ -964,6 +964,7 @@ impl Tester for Collector {
test_type: test::TestType::DocTest, test_type: test::TestType::DocTest,
}, },
testfn: test::DynTestFn(Box::new(move || { testfn: test::DynTestFn(Box::new(move || {
let _ = &config;
let report_unused_externs = |uext| { let report_unused_externs = |uext| {
unused_externs.lock().unwrap().push(uext); unused_externs.lock().unwrap().push(uext);
}; };

View file

@ -990,7 +990,10 @@ pub fn can_move_expr_to_closure(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) ->
captures: HirIdMap::default(), captures: HirIdMap::default(),
}; };
v.visit_expr(expr); 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 /// Returns the method names and argument list of nested method call expressions that make up