Skip to content

Commit ded1a8b

Browse files
committed
Remove dead code.
1 parent 551c718 commit ded1a8b

File tree

1 file changed

+8
-66
lines changed
  • compiler/rustc_trait_selection/src/traits/error_reporting

1 file changed

+8
-66
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+8-66
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ use rustc_middle::ty::print::{with_forced_trimmed_paths, with_no_trimmed_paths};
4949
#[derive(Debug)]
5050
pub enum GeneratorInteriorOrUpvar {
5151
// span of interior type
52-
Interior(Span, Option<(Option<Span>, Span, Option<hir::HirId>, Option<Span>)>),
52+
Interior(Span, Option<(Span, Option<Span>)>),
5353
// span of upvar
5454
Upvar(Span),
5555
}
@@ -249,7 +249,6 @@ pub trait TypeErrCtxtExt<'tcx> {
249249
outer_generator: Option<DefId>,
250250
trait_pred: ty::TraitPredicate<'tcx>,
251251
target_ty: Ty<'tcx>,
252-
typeck_results: &ty::TypeckResults<'tcx>,
253252
obligation: &PredicateObligation<'tcx>,
254253
next_code: Option<&ObligationCauseCode<'tcx>>,
255254
);
@@ -2316,7 +2315,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
23162315
if ty_matches(ty::Binder::dummy(decl.ty)) && !decl.ignore_for_traits {
23172316
interior_or_upvar_span = Some(GeneratorInteriorOrUpvar::Interior(
23182317
decl.source_info.span,
2319-
Some((None, source_info.span, None, from_awaited_ty)),
2318+
Some((source_info.span, from_awaited_ty)),
23202319
));
23212320
break 'find_source;
23222321
}
@@ -2336,15 +2335,13 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
23362335
debug!(?interior_or_upvar_span);
23372336
if let Some(interior_or_upvar_span) = interior_or_upvar_span {
23382337
let is_async = self.tcx.generator_is_async(generator_did);
2339-
let typeck_results = generator_data.0;
23402338
self.note_obligation_cause_for_async_await(
23412339
err,
23422340
interior_or_upvar_span,
23432341
is_async,
23442342
outer_generator,
23452343
trait_ref,
23462344
target_ty,
2347-
typeck_results,
23482345
obligation,
23492346
next_code,
23502347
);
@@ -2365,7 +2362,6 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
23652362
outer_generator: Option<DefId>,
23662363
trait_pred: ty::TraitPredicate<'tcx>,
23672364
target_ty: Ty<'tcx>,
2368-
typeck_results: &ty::TypeckResults<'tcx>,
23692365
obligation: &PredicateObligation<'tcx>,
23702366
next_code: Option<&ObligationCauseCode<'tcx>>,
23712367
) {
@@ -2423,9 +2419,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
24232419
format!("does not implement `{}`", trait_pred.print_modifiers_and_trait_path())
24242420
};
24252421

2426-
let mut explain_yield = |interior_span: Span,
2427-
yield_span: Span,
2428-
scope_span: Option<Span>| {
2422+
let mut explain_yield = |interior_span: Span, yield_span: Span| {
24292423
let mut span = MultiSpan::from_span(yield_span);
24302424
let snippet = match source_map.span_to_snippet(interior_span) {
24312425
// #70935: If snippet contains newlines, display "the value" instead
@@ -2457,22 +2451,14 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
24572451
interior_span,
24582452
format!("has type `{target_ty}` which {trait_explanation}"),
24592453
);
2460-
if let Some(scope_span) = scope_span {
2461-
let scope_span = source_map.end_point(scope_span);
2462-
2463-
let msg = format!("{snippet} is later dropped here");
2464-
span.push_span_label(scope_span, msg);
2465-
}
24662454
err.span_note(
2467-
span,
2468-
format!(
2469-
"{future_or_generator} {trait_explanation} as this value is used across {an_await_or_yield}"
2470-
),
2471-
);
2455+
span,
2456+
format!("{future_or_generator} {trait_explanation} as this value is used across {an_await_or_yield}"),
2457+
);
24722458
};
24732459
match interior_or_upvar_span {
24742460
GeneratorInteriorOrUpvar::Interior(interior_span, interior_extra_info) => {
2475-
if let Some((scope_span, yield_span, expr, from_awaited_ty)) = interior_extra_info {
2461+
if let Some((yield_span, from_awaited_ty)) = interior_extra_info {
24762462
if let Some(await_span) = from_awaited_ty {
24772463
// The type causing this obligation is one being awaited at await_span.
24782464
let mut span = MultiSpan::from_span(await_span);
@@ -2490,51 +2476,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
24902476
);
24912477
} else {
24922478
// Look at the last interior type to get a span for the `.await`.
2493-
explain_yield(interior_span, yield_span, scope_span);
2494-
}
2495-
2496-
if let Some(expr_id) = expr {
2497-
let expr = hir.expect_expr(expr_id);
2498-
debug!("target_ty evaluated from {:?}", expr);
2499-
2500-
let parent = hir.parent_id(expr_id);
2501-
if let Some(hir::Node::Expr(e)) = hir.find(parent) {
2502-
let parent_span = hir.span(parent);
2503-
let parent_did = parent.owner.to_def_id();
2504-
// ```rust
2505-
// impl T {
2506-
// fn foo(&self) -> i32 {}
2507-
// }
2508-
// T.foo();
2509-
// ^^^^^^^ a temporary `&T` created inside this method call due to `&self`
2510-
// ```
2511-
//
2512-
let is_region_borrow = typeck_results
2513-
.expr_adjustments(expr)
2514-
.iter()
2515-
.any(|adj| adj.is_region_borrow());
2516-
2517-
// ```rust
2518-
// struct Foo(*const u8);
2519-
// bar(Foo(std::ptr::null())).await;
2520-
// ^^^^^^^^^^^^^^^^^^^^^ raw-ptr `*T` created inside this struct ctor.
2521-
// ```
2522-
debug!(parent_def_kind = ?self.tcx.def_kind(parent_did));
2523-
let is_raw_borrow_inside_fn_like_call =
2524-
match self.tcx.def_kind(parent_did) {
2525-
DefKind::Fn | DefKind::Ctor(..) => target_ty.is_unsafe_ptr(),
2526-
_ => false,
2527-
};
2528-
if (typeck_results.is_method_call(e) && is_region_borrow)
2529-
|| is_raw_borrow_inside_fn_like_call
2530-
{
2531-
err.span_help(
2532-
parent_span,
2533-
"consider moving this into a `let` \
2534-
binding to create a shorter lived borrow",
2535-
);
2536-
}
2537-
}
2479+
explain_yield(interior_span, yield_span);
25382480
}
25392481
}
25402482
}

0 commit comments

Comments
 (0)