Skip to content

Commit 057098a

Browse files
Even more dead code -- we don't HIR regionck anymore
1 parent 64bcae0 commit 057098a

File tree

4 files changed

+5
-55
lines changed

4 files changed

+5
-55
lines changed

compiler/rustc_trait_selection/messages.ftl

-8
Original file line numberDiff line numberDiff line change
@@ -225,14 +225,6 @@ trait_selection_mismatched_static_lifetime = incompatible lifetime on type
225225
trait_selection_missing_options_for_on_unimplemented_attr = missing options for `on_unimplemented` attribute
226226
.help = at least one of the `message`, `note` and `label` options are expected
227227
228-
trait_selection_more_targeted = {$has_param_name ->
229-
[true] `{$param_name}`
230-
*[false] `fn` parameter
231-
} has {$has_lifetime ->
232-
[true] lifetime `{$lifetime}`
233-
*[false] an anonymous lifetime `'_`
234-
} but calling `{$ident}` introduces an implicit `'static` lifetime requirement
235-
236228
trait_selection_msl_introduces_static = introduces a `'static` lifetime requirement
237229
trait_selection_msl_unmet_req = because this has an unmet lifetime requirement
238230

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

+1-5
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
3333
};
3434
// If we added a "points at argument expression" obligation, we remove it here, we care
3535
// about the original obligation only.
36-
let code = match cause.code() {
37-
ObligationCauseCode::FunctionArg { parent_code, .. } => &*parent_code,
38-
code => code,
39-
};
40-
let ObligationCauseCode::MatchImpl(parent, impl_def_id) = code else {
36+
let ObligationCauseCode::MatchImpl(parent, impl_def_id) = cause.code() else {
4137
return None;
4238
};
4339
let (ObligationCauseCode::WhereClause(_, binding_span)

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

+4-39
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
//! Error Reporting for static impl Traits.
22
33
use rustc_data_structures::fx::FxIndexSet;
4-
use rustc_errors::{Applicability, Diag, ErrorGuaranteed, MultiSpan};
4+
use rustc_errors::{Applicability, Diag, ErrorGuaranteed};
55
use rustc_hir::def_id::DefId;
66
use rustc_hir::intravisit::{Visitor, VisitorExt, walk_ty};
77
use rustc_hir::{
88
self as hir, AmbigArg, GenericBound, GenericParam, GenericParamKind, Item, ItemKind, Lifetime,
99
LifetimeName, LifetimeParamKind, MissingLifetimeKind, Node, TyKind,
1010
};
11-
use rustc_middle::ty::{self, StaticLifetimeVisitor, Ty, TyCtxt, TypeSuperVisitable, TypeVisitor};
11+
use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitor};
1212
use rustc_span::def_id::LocalDefId;
1313
use rustc_span::{Ident, Span};
1414
use tracing::debug;
1515

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

2120
impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
2221
/// Print the error message for lifetime errors when the return type is a static `impl Trait`,
@@ -89,39 +88,6 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
8988
None
9089
};
9190

92-
let mut subdiag = None;
93-
94-
if let SubregionOrigin::Subtype(box TypeTrace { cause, .. }) = sub_origin {
95-
if let ObligationCauseCode::ReturnValue(hir_id)
96-
| ObligationCauseCode::BlockTailExpression(hir_id, ..) = cause.code()
97-
{
98-
let parent_id = tcx.hir().get_parent_item(*hir_id);
99-
if let Some(fn_decl) = tcx.hir_fn_decl_by_hir_id(parent_id.into()) {
100-
let mut span: MultiSpan = fn_decl.output.span().into();
101-
let mut spans = Vec::new();
102-
let mut add_label = true;
103-
if let hir::FnRetTy::Return(ty) = fn_decl.output {
104-
let mut v = StaticLifetimeVisitor(vec![], tcx.hir());
105-
v.visit_ty_unambig(ty);
106-
if !v.0.is_empty() {
107-
span = v.0.clone().into();
108-
spans = v.0;
109-
add_label = false;
110-
}
111-
}
112-
let fn_decl_span = fn_decl.output.span();
113-
114-
subdiag = Some(ReqIntroducedLocations {
115-
span,
116-
spans,
117-
fn_decl_span,
118-
cause_span: cause.span,
119-
add_label,
120-
});
121-
}
122-
}
123-
}
124-
12591
let diag = ButNeedsToSatisfy {
12692
sp,
12793
influencer_point,
@@ -132,7 +98,6 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
13298
require_span_as_note: require_as_note.then_some(require_span),
13399
// We don't need a note, it's already at the end, it can be shown as a `span_label`.
134100
require_span_as_label: (!require_as_note).then_some(require_span),
135-
req_introduces_loc: subdiag,
136101

137102
has_lifetime: sup_r.has_name(),
138103
lifetime: lifetime_name.clone(),

compiler/rustc_trait_selection/src/errors.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1135,9 +1135,6 @@ pub struct ButNeedsToSatisfy {
11351135
#[note(trait_selection_introduced_by_bound)]
11361136
pub bound: Option<Span>,
11371137

1138-
#[subdiagnostic]
1139-
pub req_introduces_loc: Option<ReqIntroducedLocations>,
1140-
11411138
pub has_param_name: bool,
11421139
pub param_name: String,
11431140
pub spans_empty: bool,

0 commit comments

Comments
 (0)