Skip to content

Commit 64bcae0

Browse files
More dead code
1 parent a714cee commit 64bcae0

File tree

2 files changed

+2
-71
lines changed

2 files changed

+2
-71
lines changed

compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/static_impl_trait.rs

+2-55
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Error Reporting for static impl Traits.
22
33
use rustc_data_structures::fx::FxIndexSet;
4-
use rustc_errors::{Applicability, Diag, ErrorGuaranteed, MultiSpan, Subdiagnostic};
4+
use rustc_errors::{Applicability, Diag, ErrorGuaranteed, MultiSpan};
55
use rustc_hir::def_id::DefId;
66
use rustc_hir::intravisit::{Visitor, VisitorExt, walk_ty};
77
use rustc_hir::{
@@ -14,9 +14,7 @@ use rustc_span::{Ident, Span};
1414
use tracing::debug;
1515

1616
use crate::error_reporting::infer::nice_region_error::NiceRegionError;
17-
use crate::errors::{
18-
ButNeedsToSatisfy, DynTraitConstraintSuggestion, MoreTargeted, ReqIntroducedLocations,
19-
};
17+
use crate::errors::{ButNeedsToSatisfy, ReqIntroducedLocations};
2018
use crate::infer::{RegionResolutionError, SubregionOrigin, TypeTrace};
2119
use crate::traits::ObligationCauseCode;
2220

@@ -148,36 +146,6 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
148146

149147
let fn_returns = tcx.return_type_impl_or_dyn_traits(anon_reg_sup.scope);
150148

151-
let mut override_error_code = None;
152-
153-
if let SubregionOrigin::Subtype(box TypeTrace { cause, .. }) = &sub_origin
154-
&& let code = match cause.code() {
155-
ObligationCauseCode::MatchImpl(parent, ..) => parent.code(),
156-
_ => cause.code(),
157-
}
158-
&& let &ObligationCauseCode::WhereClause(item_def_id, _)
159-
| &ObligationCauseCode::WhereClauseInExpr(item_def_id, ..) = code
160-
{
161-
// Same case of `impl Foo for dyn Bar { fn qux(&self) {} }` introducing a `'static`
162-
// lifetime as above, but called using a fully-qualified path to the method:
163-
// `Foo::qux(bar)`.
164-
let mut v = TraitObjectVisitor(FxIndexSet::default());
165-
v.visit_ty(param.param_ty);
166-
if let Some((ident, self_ty)) =
167-
NiceRegionError::get_impl_ident_and_self_ty_from_trait(tcx, item_def_id, &v.0)
168-
&& self.suggest_constrain_dyn_trait_in_impl(&mut err, &v.0, ident, self_ty)
169-
{
170-
override_error_code = Some(ident.name);
171-
}
172-
}
173-
if let Some(ident) = override_error_code
174-
&& fn_returns.is_empty()
175-
{
176-
// Provide a more targeted error code and description.
177-
let retarget_subdiag = MoreTargeted { ident };
178-
retarget_subdiag.add_to_diag(&mut err);
179-
}
180-
181149
let arg = match param.param.pat.simple_ident() {
182150
Some(simple_ident) => format!("argument `{simple_ident}`"),
183151
None => "the argument".to_string(),
@@ -457,27 +425,6 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
457425
_ => None,
458426
}
459427
}
460-
461-
fn suggest_constrain_dyn_trait_in_impl(
462-
&self,
463-
err: &mut Diag<'_>,
464-
found_dids: &FxIndexSet<DefId>,
465-
ident: Ident,
466-
self_ty: &hir::Ty<'_>,
467-
) -> bool {
468-
let mut suggested = false;
469-
for found_did in found_dids {
470-
let mut traits = vec![];
471-
let mut hir_v = HirTraitObjectVisitor(&mut traits, *found_did);
472-
hir_v.visit_ty_unambig(self_ty);
473-
for &span in &traits {
474-
let subdiag = DynTraitConstraintSuggestion { span, ident };
475-
subdiag.add_to_diag(err);
476-
suggested = true;
477-
}
478-
}
479-
suggested
480-
}
481428
}
482429

483430
/// Collect all the trait objects in a type that could have received an implicit `'static` lifetime.

compiler/rustc_trait_selection/src/errors.rs

-16
Original file line numberDiff line numberDiff line change
@@ -1119,22 +1119,6 @@ impl Subdiagnostic for ReqIntroducedLocations {
11191119
}
11201120
}
11211121

1122-
pub struct MoreTargeted {
1123-
pub ident: Symbol,
1124-
}
1125-
1126-
impl Subdiagnostic for MoreTargeted {
1127-
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
1128-
self,
1129-
diag: &mut Diag<'_, G>,
1130-
_f: &F,
1131-
) {
1132-
diag.code(E0772);
1133-
diag.primary_message(fluent::trait_selection_more_targeted);
1134-
diag.arg("ident", self.ident);
1135-
}
1136-
}
1137-
11381122
#[derive(Diagnostic)]
11391123
#[diag(trait_selection_but_needs_to_satisfy, code = E0759)]
11401124
pub struct ButNeedsToSatisfy {

0 commit comments

Comments
 (0)