Skip to content

Commit 80cf3f9

Browse files
committed
Cleanup some remains of hr_lifetime_in_assoc_type compatibility lint
1 parent ad36f8f commit 80cf3f9

File tree

17 files changed

+113
-278
lines changed

17 files changed

+113
-278
lines changed

Diff for: src/librustc/ich/impls_ty.rs

-1
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,6 @@ for ty::RegionParameterDef {
368368
name,
369369
def_id,
370370
index,
371-
issue_32330: _,
372371
pure_wrt_drop
373372
} = *self;
374373

Diff for: src/librustc/infer/error_reporting/mod.rs

+2-33
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ use hir::map as hir_map;
6666
use hir::def_id::DefId;
6767
use middle::region;
6868
use traits::{ObligationCause, ObligationCauseCode};
69-
use ty::{self, TyCtxt, TypeFoldable};
70-
use ty::{Region, Issue32330};
69+
use ty::{self, Region, TyCtxt, TypeFoldable};
7170
use ty::error::TypeError;
7271
use syntax::ast::DUMMY_NODE_ID;
7372
use syntax_pos::{Pos, Span};
@@ -713,35 +712,6 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
713712
self.tcx.note_and_explain_type_err(diag, terr, span);
714713
}
715714

716-
pub fn note_issue_32330(&self,
717-
diag: &mut DiagnosticBuilder<'tcx>,
718-
terr: &TypeError<'tcx>)
719-
{
720-
debug!("note_issue_32330: terr={:?}", terr);
721-
match *terr {
722-
TypeError::RegionsInsufficientlyPolymorphic(_, _, Some(box Issue32330 {
723-
fn_def_id, region_name
724-
})) |
725-
TypeError::RegionsOverlyPolymorphic(_, _, Some(box Issue32330 {
726-
fn_def_id, region_name
727-
})) => {
728-
diag.note(
729-
&format!("lifetime parameter `{0}` declared on fn `{1}` \
730-
appears only in the return type, \
731-
but here is required to be higher-ranked, \
732-
which means that `{0}` must appear in both \
733-
argument and return types",
734-
region_name,
735-
self.tcx.item_path_str(fn_def_id)));
736-
diag.note(
737-
&format!("this error is the result of a recent bug fix; \
738-
for more information, see issue #33685 \
739-
<https://github.com/rust-lang/rust/issues/33685>"));
740-
}
741-
_ => {}
742-
}
743-
}
744-
745715
pub fn report_and_explain_type_error(&self,
746716
trace: TypeTrace<'tcx>,
747717
terr: &TypeError<'tcx>)
@@ -761,7 +731,6 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
761731
}
762732
};
763733
self.note_type_err(&mut diag, &trace.cause, None, Some(trace.values), terr);
764-
self.note_issue_32330(&mut diag, terr);
765734
diag
766735
}
767736

@@ -934,7 +903,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
934903
format!(" for lifetime parameter {}in trait containing associated type `{}`",
935904
br_string(br), type_name)
936905
}
937-
infer::EarlyBoundRegion(_, name, _) => {
906+
infer::EarlyBoundRegion(_, name) => {
938907
format!(" for lifetime parameter `{}`",
939908
name)
940909
}

Diff for: src/librustc/infer/higher_ranked/mod.rs

+7-49
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
1414
use super::{CombinedSnapshot,
1515
InferCtxt,
16-
LateBoundRegion,
1716
HigherRankedType,
18-
RegionVariableOrigin,
1917
SubregionOrigin,
2018
SkolemizationMap};
2119
use super::combine::CombineFields;
@@ -29,15 +27,6 @@ use util::nodemap::{FxHashMap, FxHashSet};
2927

3028
pub struct HrMatchResult<U> {
3129
pub value: U,
32-
33-
/// Normally, when we do a higher-ranked match operation, we
34-
/// expect all higher-ranked regions to be constrained as part of
35-
/// the match operation. However, in the transition period for
36-
/// #32330, it can happen that we sometimes have unconstrained
37-
/// regions that get instantiated with fresh variables. In that
38-
/// case, we collect the set of unconstrained bound regions here
39-
/// and replace them with fresh variables.
40-
pub unconstrained_regions: Vec<ty::BoundRegion>,
4130
}
4231

4332
impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
@@ -108,7 +97,6 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
10897
/// that do not appear in `T`. If that happens, those regions are
10998
/// unconstrained, and this routine replaces them with `'static`.
11099
pub fn higher_ranked_match<T, U>(&mut self,
111-
span: Span,
112100
a_pair: &Binder<(T, U)>,
113101
b_match: &T,
114102
a_is_expected: bool)
@@ -158,28 +146,16 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
158146
// be any region from the sets above, except for other members of
159147
// `skol_map`. There should always be a representative if things
160148
// are properly well-formed.
161-
let mut unconstrained_regions = vec![];
162149
let skol_representatives: FxHashMap<_, _> =
163150
skol_resolution_map
164151
.iter()
165-
.map(|(&skol, &(br, ref regions))| {
152+
.map(|(&skol, &(_, ref regions))| {
166153
let representative =
167154
regions.iter()
168155
.filter(|&&r| !skol_resolution_map.contains_key(r))
169156
.cloned()
170157
.next()
171-
.unwrap_or_else(|| { // [1]
172-
unconstrained_regions.push(br);
173-
self.infcx.next_region_var(
174-
LateBoundRegion(span, br, HigherRankedType))
175-
});
176-
177-
// [1] There should always be a representative,
178-
// unless the higher-ranked region did not appear
179-
// in the values being matched. We should reject
180-
// as ill-formed cases that can lead to this, but
181-
// right now we sometimes issue warnings (see
182-
// #32330).
158+
.expect("no representative region");
183159

184160
(skol, representative)
185161
})
@@ -216,10 +192,7 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
216192
// We are now done with these skolemized variables.
217193
self.infcx.pop_skolemized(skol_map, snapshot);
218194

219-
Ok(HrMatchResult {
220-
value: a_value,
221-
unconstrained_regions,
222-
})
195+
Ok(HrMatchResult { value: a_value })
223196
});
224197
}
225198

@@ -657,28 +630,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
657630
skol_br,
658631
tainted_region);
659632

660-
let issue_32330 = if let &ty::ReVar(vid) = tainted_region {
661-
match self.region_vars.var_origin(vid) {
662-
RegionVariableOrigin::EarlyBoundRegion(_, _, issue_32330) => {
663-
issue_32330.map(Box::new)
664-
}
665-
_ => None
666-
}
667-
} else {
668-
None
669-
};
670-
671-
if overly_polymorphic {
633+
return Err(if overly_polymorphic {
672634
debug!("Overly polymorphic!");
673-
return Err(TypeError::RegionsOverlyPolymorphic(skol_br,
674-
tainted_region,
675-
issue_32330));
635+
TypeError::RegionsOverlyPolymorphic(skol_br, tainted_region)
676636
} else {
677637
debug!("Not as polymorphic!");
678-
return Err(TypeError::RegionsInsufficientlyPolymorphic(skol_br,
679-
tainted_region,
680-
issue_32330));
681-
}
638+
TypeError::RegionsInsufficientlyPolymorphic(skol_br, tainted_region)
639+
})
682640
}
683641
}
684642

Diff for: src/librustc/infer/mod.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ pub enum RegionVariableOrigin {
299299
Coercion(Span),
300300

301301
// Region variables created as the values for early-bound regions
302-
EarlyBoundRegion(Span, ast::Name, Option<ty::Issue32330>),
302+
EarlyBoundRegion(Span, ast::Name),
303303

304304
// Region variables created for bound regions
305305
// in a function or method that is called
@@ -989,7 +989,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
989989
span: Span,
990990
def: &ty::RegionParameterDef)
991991
-> ty::Region<'tcx> {
992-
self.next_region_var(EarlyBoundRegion(span, def.name, def.issue_32330))
992+
self.next_region_var(EarlyBoundRegion(span, def.name))
993993
}
994994

995995
/// Create a type inference variable for the given
@@ -1278,14 +1278,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
12781278
-> InferResult<'tcx, HrMatchResult<Ty<'tcx>>>
12791279
{
12801280
let match_pair = match_a.map_bound(|p| (p.projection_ty.trait_ref(self.tcx), p.ty));
1281-
let span = cause.span;
12821281
let trace = TypeTrace {
12831282
cause,
12841283
values: TraitRefs(ExpectedFound::new(true, match_pair.skip_binder().0, match_b))
12851284
};
12861285

12871286
let mut combine = self.combine_fields(trace, param_env);
1288-
let result = combine.higher_ranked_match(span, &match_pair, &match_b, true)?;
1287+
let result = combine.higher_ranked_match(&match_pair, &match_b, true)?;
12891288
Ok(InferOk { value: result, obligations: combine.obligations })
12901289
}
12911290

Diff for: src/librustc/middle/resolve_lifetime.rs

+6-32
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,6 @@ pub struct NamedRegionMap {
153153
// (b) it DOES appear in the arguments.
154154
pub late_bound: NodeSet,
155155

156-
// Contains the node-ids for lifetimes that were (incorrectly) categorized
157-
// as late-bound, until #32330 was fixed.
158-
pub issue_32330: NodeMap<ty::Issue32330>,
159-
160156
// For each type and trait definition, maps type parameters
161157
// to the trait object lifetime defaults computed from them.
162158
pub object_lifetime_defaults: NodeMap<Vec<ObjectLifetimeDefault>>,
@@ -261,7 +257,6 @@ pub fn krate(sess: &Session,
261257
let mut map = NamedRegionMap {
262258
defs: NodeMap(),
263259
late_bound: NodeSet(),
264-
issue_32330: NodeMap(),
265260
object_lifetime_defaults: compute_object_lifetime_defaults(sess, hir_map),
266261
};
267262
sess.track_errors(|| {
@@ -303,7 +298,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
303298
fn visit_item(&mut self, item: &'tcx hir::Item) {
304299
match item.node {
305300
hir::ItemFn(ref decl, _, _, _, ref generics, _) => {
306-
self.visit_early_late(item.id, None, decl, generics, |this| {
301+
self.visit_early_late(None, decl, generics, |this| {
307302
intravisit::walk_item(this, item);
308303
});
309304
}
@@ -355,7 +350,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
355350
fn visit_foreign_item(&mut self, item: &'tcx hir::ForeignItem) {
356351
match item.node {
357352
hir::ForeignItemFn(ref decl, _, ref generics) => {
358-
self.visit_early_late(item.id, None, decl, generics, |this| {
353+
self.visit_early_late(None, decl, generics, |this| {
359354
intravisit::walk_foreign_item(this, item);
360355
})
361356
}
@@ -406,7 +401,6 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
406401
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) {
407402
if let hir::TraitItemKind::Method(ref sig, _) = trait_item.node {
408403
self.visit_early_late(
409-
trait_item.id,
410404
Some(self.hir_map.get_parent(trait_item.id)),
411405
&sig.decl, &sig.generics,
412406
|this| intravisit::walk_trait_item(this, trait_item))
@@ -418,7 +412,6 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
418412
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
419413
if let hir::ImplItemKind::Method(ref sig, _) = impl_item.node {
420414
self.visit_early_late(
421-
impl_item.id,
422415
Some(self.hir_map.get_parent(impl_item.id)),
423416
&sig.decl, &sig.generics,
424417
|this| intravisit::walk_impl_item(this, impl_item))
@@ -811,18 +804,13 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
811804
/// bound lifetimes are resolved by name and associated with a binder id (`binder_id`), so the
812805
/// ordering is not important there.
813806
fn visit_early_late<F>(&mut self,
814-
fn_id: ast::NodeId,
815807
parent_id: Option<ast::NodeId>,
816808
decl: &'tcx hir::FnDecl,
817809
generics: &'tcx hir::Generics,
818810
walk: F) where
819811
F: for<'b, 'c> FnOnce(&'b mut LifetimeContext<'c, 'tcx>),
820812
{
821-
let fn_def_id = self.hir_map.local_def_id(fn_id);
822-
insert_late_bound_lifetimes(self.map,
823-
fn_def_id,
824-
decl,
825-
generics);
813+
insert_late_bound_lifetimes(self.map, decl, generics);
826814

827815
// Find the start of nested early scopes, e.g. in methods.
828816
let mut index = 0;
@@ -1549,7 +1537,6 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
15491537
/// not amongst the inputs to a projection. In other words, `<&'a
15501538
/// T as Trait<''b>>::Foo` does not constrain `'a` or `'b`.
15511539
fn insert_late_bound_lifetimes(map: &mut NamedRegionMap,
1552-
fn_def_id: DefId,
15531540
decl: &hir::FnDecl,
15541541
generics: &hir::Generics) {
15551542
debug!("insert_late_bound_lifetimes(decl={:?}, generics={:?})", decl, generics);
@@ -1607,22 +1594,9 @@ fn insert_late_bound_lifetimes(map: &mut NamedRegionMap,
16071594
// any `impl Trait` in the return type? early-bound.
16081595
if appears_in_output.impl_trait { continue; }
16091596

1610-
// does not appear in the inputs, but appears in the return
1611-
// type? eventually this will be early-bound, but for now we
1612-
// just mark it so we can issue warnings.
1613-
let constrained_by_input = constrained_by_input.regions.contains(&name);
1614-
let appears_in_output = appears_in_output.regions.contains(&name);
1615-
if !constrained_by_input && appears_in_output {
1616-
debug!("inserting issue_32330 entry for {:?}, {:?} on {:?}",
1617-
lifetime.lifetime.id,
1618-
name,
1619-
fn_def_id);
1620-
map.issue_32330.insert(
1621-
lifetime.lifetime.id,
1622-
ty::Issue32330 {
1623-
fn_def_id,
1624-
region_name: name,
1625-
});
1597+
// does not appear in the inputs, but appears in the return type? early-bound.
1598+
if !constrained_by_input.regions.contains(&name) &&
1599+
appears_in_output.regions.contains(&name) {
16261600
continue;
16271601
}
16281602

0 commit comments

Comments
 (0)