Skip to content

Rustup #6338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 17, 2020
Merged

Rustup #6338

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clippy_lints/src/eval_order_dependence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> {
match typ.kind() {
ty::FnDef(..) | ty::FnPtr(_) => {
let sig = typ.fn_sig(self.cx.tcx);
if let ty::Never = self.cx.tcx.erase_late_bound_regions(&sig).output().kind() {
if let ty::Never = self.cx.tcx.erase_late_bound_regions(sig).output().kind() {
self.report_diverging_sub_expr(e);
}
},
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/methods/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1615,7 +1615,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {

let method_def_id = cx.tcx.hir().local_def_id(impl_item.hir_id);
let method_sig = cx.tcx.fn_sig(method_def_id);
let method_sig = cx.tcx.erase_late_bound_regions(&method_sig);
let method_sig = cx.tcx.erase_late_bound_regions(method_sig);

let first_arg_ty = &method_sig.inputs().iter().next();

Expand Down Expand Up @@ -2681,7 +2681,7 @@ fn lint_map_flatten<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>, map
ty::Closure(_, substs) => substs.as_closure().sig(),
_ => map_closure_ty.fn_sig(cx.tcx),
};
let map_closure_return_ty = cx.tcx.erase_late_bound_regions(&map_closure_sig.output());
let map_closure_return_ty = cx.tcx.erase_late_bound_regions(map_closure_sig.output());
is_type_diagnostic_item(cx, map_closure_return_ty, sym::option_type)
},
_ => false,
Expand Down
6 changes: 1 addition & 5 deletions clippy_lints/src/mut_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,7 @@ fn check_sig<'tcx>(cx: &LateContext<'tcx>, item_hir_id: hir::HirId, decl: &hir::
for (hir_ty, ty) in decl.inputs.iter().zip(fn_sig.inputs().skip_binder().iter()) {
check_ty(cx, hir_ty.span, ty);
}
check_ty(
cx,
decl.output.span(),
cx.tcx.erase_late_bound_regions(&fn_sig.output()),
);
check_ty(cx, decl.output.span(), cx.tcx.erase_late_bound_regions(fn_sig.output()));
}

// We want to lint 1. sets or maps with 2. not immutable key types and 3. no unerased
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/needless_pass_by_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
};

let fn_sig = cx.tcx.fn_sig(fn_def_id);
let fn_sig = cx.tcx.erase_late_bound_regions(&fn_sig);
let fn_sig = cx.tcx.erase_late_bound_regions(fn_sig);

for (idx, ((input, &ty), arg)) in decl.inputs.iter().zip(fn_sig.inputs()).zip(body.params).enumerate() {
// All spans generated from a proc-macro invocation are the same...
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/pass_by_ref_or_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ impl<'tcx> PassByRefOrValue {
let fn_def_id = cx.tcx.hir().local_def_id(hir_id);

let fn_sig = cx.tcx.fn_sig(fn_def_id);
let fn_sig = cx.tcx.erase_late_bound_regions(&fn_sig);
let fn_sig = cx.tcx.erase_late_bound_regions(fn_sig);

let fn_body = cx.enclosing_body.map(|id| cx.tcx.hir().body(id));

Expand Down
4 changes: 3 additions & 1 deletion clippy_lints/src/redundant_clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,9 @@ impl<'a, 'tcx> mir::visit::Visitor<'tcx> for PossibleBorrowerVisitor<'a, 'tcx> {
struct ContainsRegion;

impl TypeVisitor<'_> for ContainsRegion {
fn visit_region(&mut self, _: ty::Region<'_>) -> ControlFlow<()> {
type BreakTy = ();

fn visit_region(&mut self, _: ty::Region<'_>) -> ControlFlow<Self::BreakTy> {
ControlFlow::BREAK
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/transmute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ impl<'tcx> LateLintPass<'tcx> for Transmute {
Applicability::Unspecified,
);
} else {
if (cx.tcx.erase_regions(&from_ty) != cx.tcx.erase_regions(&to_ty))
if (cx.tcx.erase_regions(from_ty) != cx.tcx.erase_regions(to_ty))
&& !const_context {
span_lint_and_then(
cx,
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/unit_return_expecting_ord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn get_trait_predicates_for_trait_id<'tcx>(
for (pred, _) in generics.predicates {
if_chain! {
if let PredicateAtom::Trait(poly_trait_pred, _) = pred.skip_binders();
let trait_pred = cx.tcx.erase_late_bound_regions(&ty::Binder::bind(poly_trait_pred));
let trait_pred = cx.tcx.erase_late_bound_regions(ty::Binder::bind(poly_trait_pred));
if let Some(trait_def_id) = trait_id;
if trait_def_id == trait_pred.trait_ref.def_id;
then {
Expand All @@ -61,7 +61,7 @@ fn get_projection_pred<'tcx>(
) -> Option<ProjectionPredicate<'tcx>> {
generics.predicates.iter().find_map(|(proj_pred, _)| {
if let ty::PredicateAtom::Projection(proj_pred) = proj_pred.skip_binders() {
let projection_pred = cx.tcx.erase_late_bound_regions(&ty::Binder::bind(proj_pred));
let projection_pred = cx.tcx.erase_late_bound_regions(ty::Binder::bind(proj_pred));
if projection_pred.projection_ty.substs == pred.trait_ref.substs {
return Some(projection_pred);
}
Expand All @@ -81,7 +81,7 @@ fn get_args_to_check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> Ve
get_trait_predicates_for_trait_id(cx, generics, cx.tcx.lang_items().partial_ord_trait());
// Trying to call erase_late_bound_regions on fn_sig.inputs() gives the following error
// The trait `rustc::ty::TypeFoldable<'_>` is not implemented for `&[&rustc::ty::TyS<'_>]`
let inputs_output = cx.tcx.erase_late_bound_regions(&fn_sig.inputs_and_output());
let inputs_output = cx.tcx.erase_late_bound_regions(fn_sig.inputs_and_output());
inputs_output
.iter()
.rev()
Expand Down Expand Up @@ -112,7 +112,7 @@ fn check_arg<'tcx>(cx: &LateContext<'tcx>, arg: &'tcx Expr<'tcx>) -> Option<(Spa
if let ExprKind::Closure(_, _fn_decl, body_id, span, _) = arg.kind;
if let ty::Closure(_def_id, substs) = &cx.typeck_results().node_type(arg.hir_id).kind();
let ret_ty = substs.as_closure().sig().output();
let ty = cx.tcx.erase_late_bound_regions(&ret_ty);
let ty = cx.tcx.erase_late_bound_regions(ret_ty);
if ty.is_unit();
then {
if_chain! {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/use_self.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ fn check_trait_method_impl_decl<'tcx>(
.expect("impl method matches a trait method");

let trait_method_sig = cx.tcx.fn_sig(trait_method.def_id);
let trait_method_sig = cx.tcx.erase_late_bound_regions(&trait_method_sig);
let trait_method_sig = cx.tcx.erase_late_bound_regions(trait_method_sig);

let output_hir_ty = if let FnRetTy::Return(ty) = &impl_decl.output {
Some(&**ty)
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ pub fn implements_trait<'tcx>(
if ty.has_infer_types() {
return false;
}
let ty = cx.tcx.erase_regions(&ty);
let ty = cx.tcx.erase_regions(ty);
let ty_params = cx.tcx.mk_substs(ty_params.iter());
cx.tcx.type_implements_trait((trait_id, ty, ty_params, cx.param_env))
}
Expand Down Expand Up @@ -887,7 +887,7 @@ pub fn is_direct_expn_of(span: Span, name: &str) -> Option<Span> {
pub fn return_ty<'tcx>(cx: &LateContext<'tcx>, fn_item: hir::HirId) -> Ty<'tcx> {
let fn_def_id = cx.tcx.hir().local_def_id(fn_item);
let ret_ty = cx.tcx.fn_sig(fn_def_id).output();
cx.tcx.erase_late_bound_regions(&ret_ty)
cx.tcx.erase_late_bound_regions(ret_ty)
}

/// Walks into `ty` and returns `true` if any inner type is the same as `other_ty`
Expand Down Expand Up @@ -1220,7 +1220,7 @@ pub fn match_function_call<'tcx>(
pub fn is_normalizable<'tcx>(cx: &LateContext<'tcx>, param_env: ty::ParamEnv<'tcx>, ty: Ty<'tcx>) -> bool {
cx.tcx.infer_ctxt().enter(|infcx| {
let cause = rustc_middle::traits::ObligationCause::dummy();
infcx.at(&cause, param_env).normalize(&ty).is_ok()
infcx.at(&cause, param_env).normalize(ty).is_ok()
})
}

Expand Down