Auto merge of #6338 - flip1995:rustup, r=flip1995
Rustup r? `@ghost` changelog: none
This commit is contained in:
commit
a8cafc6196
@ -141,7 +141,7 @@ fn visit_expr(&mut self, e: &'tcx Expr<'_>) {
|
||||
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);
|
||||
}
|
||||
},
|
||||
|
@ -1615,7 +1615,7 @@ fn check_impl_item(&mut self, cx: &LateContext<'tcx>, impl_item: &'tcx hir::Impl
|
||||
|
||||
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();
|
||||
|
||||
@ -2674,7 +2674,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,
|
||||
|
@ -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
|
||||
|
@ -141,7 +141,7 @@ fn check_fn(
|
||||
};
|
||||
|
||||
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...
|
||||
|
@ -115,7 +115,7 @@ fn check_poly_fn(&mut self, cx: &LateContext<'tcx>, hir_id: HirId, decl: &FnDecl
|
||||
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));
|
||||
|
||||
|
@ -563,7 +563,9 @@ fn visit_terminator(&mut self, terminator: &mir::Terminator<'_>, _loc: mir::Loca
|
||||
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
|
||||
}
|
||||
}
|
||||
|
@ -491,7 +491,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) {
|
||||
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,
|
||||
|
@ -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 {
|
||||
@ -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);
|
||||
}
|
||||
@ -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()
|
||||
@ -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! {
|
||||
|
@ -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)
|
||||
|
@ -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))
|
||||
}
|
||||
@ -923,7 +923,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`
|
||||
@ -1256,7 +1256,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()
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user