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 {
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)

View File

@ -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,

View File

@ -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 }
})
})
}
}

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 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());

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 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.

View File

@ -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)
})
}
}

View File

@ -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,

View File

@ -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,
}
})
};

View File

@ -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;

View File

@ -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,

View File

@ -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);
};

View File

@ -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