Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit fc81e36

Browse files
committedSep 7, 2018
Auto merge of #53327 - wesleywiser:wip_optimize_nll, r=nikomatsakis
[nll] teach SCC about `'static` r? @nikomatsakis I think this is right? I am seeing better performance on the `html5ever` benchmark but I'd like a perf run to quantify the exact speedup. There's a few ui tests failing due to changes in the error messages. The main issue seems to be that returns aren't being detected correctly? `mir_check_cast_unsize.rs` before: ``` error: unsatisfied lifetime constraints --> mir_check_cast_unsize.rs:17:46 | 17 | fn bar<'a>(x: &'a u32) -> &'static dyn Debug { | ________--____________________________________^ | | | | | lifetime `'a` defined here 18 | | //~^ ERROR unsatisfied lifetime constraints 19 | | x 20 | | //~^ WARNING not reporting region error due to nll 21 | | } | |_^ return requires that `'a` must outlive `'static` ``` `mir_check_cast_unsize.rs` after: ``` error: unsatisfied lifetime constraints --> mir_check_cast_unsize.rs:19:5 | 17 | fn bar<'a>(x: &'a u32) -> &'static dyn Debug { | -- lifetime `'a` defined here 18 | //~^ ERROR unsatisfied lifetime constraints 19 | x | ^ cast requires that `'a` must outlive `'static` ```
2 parents 24ef47b + b1211e8 commit fc81e36

File tree

39 files changed

+376
-190
lines changed

39 files changed

+376
-190
lines changed
 

‎src/librustc/middle/resolve_lifetime.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2567,6 +2567,13 @@ fn insert_late_bound_lifetimes(
25672567
// - do not appear in the where-clauses
25682568
// - are not implicitly captured by `impl Trait`
25692569
for param in &generics.params {
2570+
match param.kind {
2571+
hir::GenericParamKind::Lifetime { .. } => { /* fall through */ }
2572+
2573+
// Types are not late-bound.
2574+
hir::GenericParamKind::Type { .. } => continue,
2575+
}
2576+
25702577
let lt_name = hir::LifetimeName::Param(param.name.modern());
25712578
// appears in the where clauses? early-bound.
25722579
if appears_in_where_clause.regions.contains(&lt_name) {

‎src/librustc_mir/borrow_check/nll/constraints/graph.rs

Lines changed: 70 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
use borrow_check::nll::type_check::Locations;
1112
use borrow_check::nll::constraints::{ConstraintIndex, ConstraintSet, OutlivesConstraint};
1213
use rustc::ty::RegionVid;
1314
use rustc_data_structures::graph;
@@ -31,6 +32,7 @@ crate type ReverseConstraintGraph = ConstraintGraph<Reverse>;
3132
crate trait ConstraintGraphDirecton: Copy + 'static {
3233
fn start_region(c: &OutlivesConstraint) -> RegionVid;
3334
fn end_region(c: &OutlivesConstraint) -> RegionVid;
35+
fn is_normal() -> bool;
3436
}
3537

3638
/// In normal mode, a `R1: R2` constraint results in an edge `R1 ->
@@ -48,6 +50,10 @@ impl ConstraintGraphDirecton for Normal {
4850
fn end_region(c: &OutlivesConstraint) -> RegionVid {
4951
c.sub
5052
}
53+
54+
fn is_normal() -> bool {
55+
true
56+
}
5157
}
5258

5359
/// In reverse mode, a `R1: R2` constraint results in an edge `R2 ->
@@ -65,6 +71,10 @@ impl ConstraintGraphDirecton for Reverse {
6571
fn end_region(c: &OutlivesConstraint) -> RegionVid {
6672
c.sup
6773
}
74+
75+
fn is_normal() -> bool {
76+
false
77+
}
6878
}
6979

7080
impl<D: ConstraintGraphDirecton> ConstraintGraph<D> {
@@ -98,32 +108,74 @@ impl<D: ConstraintGraphDirecton> ConstraintGraph<D> {
98108
/// Given the constraint set from which this graph was built
99109
/// creates a region graph so that you can iterate over *regions*
100110
/// and not constraints.
101-
crate fn region_graph<'rg>(&'rg self, set: &'rg ConstraintSet) -> RegionGraph<'rg, D> {
102-
RegionGraph::new(set, self)
111+
crate fn region_graph<'rg>(
112+
&'rg self,
113+
set: &'rg ConstraintSet,
114+
static_region: RegionVid,
115+
) -> RegionGraph<'rg, D> {
116+
RegionGraph::new(set, self, static_region)
103117
}
104118

105119
/// Given a region `R`, iterate over all constraints `R: R1`.
106-
crate fn outgoing_edges(&self, region_sup: RegionVid) -> Edges<'_, D> {
107-
let first = self.first_constraints[region_sup];
108-
Edges {
109-
graph: self,
110-
pointer: first,
120+
crate fn outgoing_edges<'a>(
121+
&'a self,
122+
region_sup: RegionVid,
123+
constraints: &'a ConstraintSet,
124+
static_region: RegionVid,
125+
) -> Edges<'a, D> {
126+
//if this is the `'static` region and the graph's direction is normal,
127+
//then setup the Edges iterator to return all regions #53178
128+
if region_sup == static_region && D::is_normal() {
129+
Edges {
130+
graph: self,
131+
constraints,
132+
pointer: None,
133+
next_static_idx: Some(0),
134+
static_region,
135+
}
136+
} else {
137+
//otherwise, just setup the iterator as normal
138+
let first = self.first_constraints[region_sup];
139+
Edges {
140+
graph: self,
141+
constraints,
142+
pointer: first,
143+
next_static_idx: None,
144+
static_region,
145+
}
111146
}
112147
}
113148
}
114149

115150
crate struct Edges<'s, D: ConstraintGraphDirecton> {
116151
graph: &'s ConstraintGraph<D>,
152+
constraints: &'s ConstraintSet,
117153
pointer: Option<ConstraintIndex>,
154+
next_static_idx: Option<usize>,
155+
static_region: RegionVid,
118156
}
119157

120158
impl<'s, D: ConstraintGraphDirecton> Iterator for Edges<'s, D> {
121-
type Item = ConstraintIndex;
159+
type Item = OutlivesConstraint;
122160

123161
fn next(&mut self) -> Option<Self::Item> {
124162
if let Some(p) = self.pointer {
125163
self.pointer = self.graph.next_constraints[p];
126-
Some(p)
164+
165+
Some(self.constraints[p])
166+
} else if let Some(next_static_idx) = self.next_static_idx {
167+
self.next_static_idx =
168+
if next_static_idx == (self.graph.first_constraints.len() - 1) {
169+
None
170+
} else {
171+
Some(next_static_idx + 1)
172+
};
173+
174+
Some(OutlivesConstraint {
175+
sup: self.static_region,
176+
sub: next_static_idx.into(),
177+
locations: Locations::All,
178+
})
127179
} else {
128180
None
129181
}
@@ -136,40 +188,44 @@ impl<'s, D: ConstraintGraphDirecton> Iterator for Edges<'s, D> {
136188
crate struct RegionGraph<'s, D: ConstraintGraphDirecton> {
137189
set: &'s ConstraintSet,
138190
constraint_graph: &'s ConstraintGraph<D>,
191+
static_region: RegionVid,
139192
}
140193

141194
impl<'s, D: ConstraintGraphDirecton> RegionGraph<'s, D> {
142195
/// Create a "dependency graph" where each region constraint `R1:
143196
/// R2` is treated as an edge `R1 -> R2`. We use this graph to
144197
/// construct SCCs for region inference but also for error
145198
/// reporting.
146-
crate fn new(set: &'s ConstraintSet, constraint_graph: &'s ConstraintGraph<D>) -> Self {
199+
crate fn new(
200+
set: &'s ConstraintSet,
201+
constraint_graph: &'s ConstraintGraph<D>,
202+
static_region: RegionVid,
203+
) -> Self {
147204
Self {
148205
set,
149206
constraint_graph,
207+
static_region,
150208
}
151209
}
152210

153211
/// Given a region `R`, iterate over all regions `R1` such that
154212
/// there exists a constraint `R: R1`.
155213
crate fn outgoing_regions(&self, region_sup: RegionVid) -> Successors<'_, D> {
156214
Successors {
157-
set: self.set,
158-
edges: self.constraint_graph.outgoing_edges(region_sup),
215+
edges: self.constraint_graph.outgoing_edges(region_sup, self.set, self.static_region),
159216
}
160217
}
161218
}
162219

163220
crate struct Successors<'s, D: ConstraintGraphDirecton> {
164-
set: &'s ConstraintSet,
165221
edges: Edges<'s, D>,
166222
}
167223

168224
impl<'s, D: ConstraintGraphDirecton> Iterator for Successors<'s, D> {
169225
type Item = RegionVid;
170226

171227
fn next(&mut self) -> Option<Self::Item> {
172-
self.edges.next().map(|c| D::end_region(&self.set[c]))
228+
self.edges.next().map(|c| D::end_region(&c))
173229
}
174230
}
175231

‎src/librustc_mir/borrow_check/nll/constraints/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ impl ConstraintSet {
5858
crate fn compute_sccs(
5959
&self,
6060
constraint_graph: &graph::NormalConstraintGraph,
61+
static_region: RegionVid,
6162
) -> Sccs<RegionVid, ConstraintSccIndex> {
62-
let region_graph = &constraint_graph.region_graph(self);
63+
let region_graph = &constraint_graph.region_graph(self, static_region);
6364
Sccs::new(region_graph)
6465
}
6566
}

‎src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use borrow_check::nll::region_infer::{ConstraintIndex, RegionInferenceContext};
11+
use borrow_check::nll::constraints::OutlivesConstraint;
12+
use borrow_check::nll::region_infer::RegionInferenceContext;
1213
use borrow_check::nll::type_check::Locations;
1314
use rustc::hir::def_id::DefId;
1415
use rustc::infer::error_reporting::nice_region_error::NiceRegionError;
@@ -53,7 +54,7 @@ impl fmt::Display for ConstraintCategory {
5354
#[derive(Copy, Clone, PartialEq, Eq)]
5455
enum Trace {
5556
StartRegion,
56-
FromConstraint(ConstraintIndex),
57+
FromOutlivesConstraint(OutlivesConstraint),
5758
NotVisited,
5859
}
5960

@@ -80,12 +81,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
8081
debug!(
8182
"best_blame_constraint: path={:#?}",
8283
path.iter()
83-
.map(|&ci| format!(
84-
"{:?}: {:?} ({:?}: {:?})",
85-
ci,
86-
&self.constraints[ci],
87-
self.constraint_sccs.scc(self.constraints[ci].sup),
88-
self.constraint_sccs.scc(self.constraints[ci].sub),
84+
.map(|&c| format!(
85+
"{:?} ({:?}: {:?})",
86+
c,
87+
self.constraint_sccs.scc(c.sup),
88+
self.constraint_sccs.scc(c.sub),
8989
))
9090
.collect::<Vec<_>>()
9191
);
@@ -121,7 +121,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
121121
// highlight (e.g., a call site or something).
122122
let target_scc = self.constraint_sccs.scc(target_region);
123123
let best_choice = (0..path.len()).rev().find(|&i| {
124-
let constraint = &self.constraints[path[i]];
124+
let constraint = path[i];
125125

126126
let constraint_sup_scc = self.constraint_sccs.scc(constraint.sup);
127127

@@ -164,7 +164,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
164164
&self,
165165
from_region: RegionVid,
166166
target_test: impl Fn(RegionVid) -> bool,
167-
) -> Option<(Vec<ConstraintIndex>, RegionVid)> {
167+
) -> Option<(Vec<OutlivesConstraint>, RegionVid)> {
168168
let mut context = IndexVec::from_elem(Trace::NotVisited, &self.definitions);
169169
context[from_region] = Trace::StartRegion;
170170

@@ -185,9 +185,9 @@ impl<'tcx> RegionInferenceContext<'tcx> {
185185
Trace::NotVisited => {
186186
bug!("found unvisited region {:?} on path to {:?}", p, r)
187187
}
188-
Trace::FromConstraint(c) => {
188+
Trace::FromOutlivesConstraint(c) => {
189189
result.push(c);
190-
p = self.constraints[c].sup;
190+
p = c.sup;
191191
}
192192

193193
Trace::StartRegion => {
@@ -201,11 +201,14 @@ impl<'tcx> RegionInferenceContext<'tcx> {
201201
// Otherwise, walk over the outgoing constraints and
202202
// enqueue any regions we find, keeping track of how we
203203
// reached them.
204-
for constraint in self.constraint_graph.outgoing_edges(r) {
205-
assert_eq!(self.constraints[constraint].sup, r);
206-
let sub_region = self.constraints[constraint].sub;
204+
let fr_static = self.universal_regions.fr_static;
205+
for constraint in self.constraint_graph.outgoing_edges(r,
206+
&self.constraints,
207+
fr_static) {
208+
assert_eq!(constraint.sup, r);
209+
let sub_region = constraint.sub;
207210
if let Trace::NotVisited = context[sub_region] {
208-
context[sub_region] = Trace::FromConstraint(constraint);
211+
context[sub_region] = Trace::FromOutlivesConstraint(constraint);
209212
deque.push_back(sub_region);
210213
}
211214
}
@@ -216,8 +219,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
216219

217220
/// This function will return true if a constraint is interesting and false if a constraint
218221
/// is not. It is useful in filtering constraint paths to only interesting points.
219-
fn constraint_is_interesting(&self, index: ConstraintIndex) -> bool {
220-
let constraint = self.constraints[index];
222+
fn constraint_is_interesting(&self, constraint: OutlivesConstraint) -> bool {
221223
debug!(
222224
"constraint_is_interesting: locations={:?} constraint={:?}",
223225
constraint.locations, constraint
@@ -232,19 +234,18 @@ impl<'tcx> RegionInferenceContext<'tcx> {
232234
/// This function classifies a constraint from a location.
233235
fn classify_constraint(
234236
&self,
235-
index: ConstraintIndex,
237+
constraint: OutlivesConstraint,
236238
mir: &Mir<'tcx>,
237239
tcx: TyCtxt<'_, '_, 'tcx>,
238240
) -> (ConstraintCategory, Span) {
239-
let constraint = self.constraints[index];
240241
debug!("classify_constraint: constraint={:?}", constraint);
241242
let span = constraint.locations.span(mir);
242243
let location = constraint
243244
.locations
244245
.from_location()
245246
.unwrap_or(Location::START);
246247

247-
if !self.constraint_is_interesting(index) {
248+
if !self.constraint_is_interesting(constraint) {
248249
return (ConstraintCategory::Boring, span);
249250
}
250251

‎src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs

Lines changed: 53 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
// except according to those terms.
1010

1111
use borrow_check::nll::region_infer::RegionInferenceContext;
12-
use borrow_check::nll::ToRegionVid;
1312
use borrow_check::nll::universal_regions::DefiningTy;
13+
use borrow_check::nll::ToRegionVid;
1414
use rustc::hir;
1515
use rustc::hir::def_id::DefId;
1616
use rustc::infer::InferCtxt;
@@ -62,20 +62,26 @@ impl<'tcx> RegionInferenceContext<'tcx> {
6262

6363
assert!(self.universal_regions.is_universal_region(fr));
6464

65-
self.give_name_from_error_region(infcx.tcx, mir_def_id, fr, counter, diag)
65+
let value = self.give_name_from_error_region(infcx.tcx, mir_def_id, fr, counter, diag)
6666
.or_else(|| {
6767
self.give_name_if_anonymous_region_appears_in_arguments(
68-
infcx, mir, mir_def_id, fr, counter, diag)
68+
infcx, mir, mir_def_id, fr, counter, diag,
69+
)
6970
})
7071
.or_else(|| {
7172
self.give_name_if_anonymous_region_appears_in_upvars(
72-
infcx.tcx, mir, fr, counter, diag)
73+
infcx.tcx, mir, fr, counter, diag,
74+
)
7375
})
7476
.or_else(|| {
7577
self.give_name_if_anonymous_region_appears_in_output(
76-
infcx, mir, mir_def_id, fr, counter, diag)
78+
infcx, mir, mir_def_id, fr, counter, diag,
79+
)
7780
})
78-
.unwrap_or_else(|| span_bug!(mir.span, "can't make a name for free region {:?}", fr))
81+
.unwrap_or_else(|| span_bug!(mir.span, "can't make a name for free region {:?}", fr));
82+
83+
debug!("give_region_a_name: gave name {:?}", value);
84+
value
7985
}
8086

8187
/// Check for the case where `fr` maps to something that the
@@ -101,23 +107,23 @@ impl<'tcx> RegionInferenceContext<'tcx> {
101107
} else {
102108
None
103109
}
104-
},
110+
}
105111

106112
ty::ReStatic => Some(keywords::StaticLifetime.name().as_interned_str()),
107113

108114
ty::ReFree(free_region) => match free_region.bound_region {
109115
ty::BoundRegion::BrNamed(_, name) => {
110116
self.highlight_named_span(tcx, error_region, &name, diag);
111117
Some(name)
112-
},
118+
}
113119

114120
ty::BoundRegion::BrEnv => {
115121
let mir_node_id = tcx.hir.as_local_node_id(mir_def_id).expect("non-local mir");
116122
let def_ty = self.universal_regions.defining_ty;
117123

118124
if let DefiningTy::Closure(def_id, substs) = def_ty {
119-
let args_span = if let hir::ExprKind::Closure(_, _, _, span, _)
120-
= tcx.hir.expect_expr(mir_node_id).node
125+
let args_span = if let hir::ExprKind::Closure(_, _, _, span, _) =
126+
tcx.hir.expect_expr(mir_node_id).node
121127
{
122128
span
123129
} else {
@@ -195,16 +201,14 @@ impl<'tcx> RegionInferenceContext<'tcx> {
195201
let node = tcx.hir.as_local_node_id(scope).unwrap_or(DUMMY_NODE_ID);
196202

197203
let mut sp = cm.def_span(tcx.hir.span(node));
198-
if let Some(param) = tcx.hir.get_generics(scope).and_then(|generics| {
199-
generics.get_named(name)
200-
}) {
204+
if let Some(param) = tcx.hir
205+
.get_generics(scope)
206+
.and_then(|generics| generics.get_named(name))
207+
{
201208
sp = param.span;
202209
}
203210

204-
diag.span_label(
205-
sp,
206-
format!("lifetime `{}` defined here", name),
207-
);
211+
diag.span_label(sp, format!("lifetime `{}` defined here", name));
208212
}
209213

210214
/// Find an argument that contains `fr` and label it with a fully
@@ -242,14 +246,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
242246
return Some(region_name);
243247
}
244248

245-
self.give_name_if_we_cannot_match_hir_ty(
246-
infcx,
247-
mir,
248-
fr,
249-
arg_ty,
250-
counter,
251-
diag,
252-
)
249+
self.give_name_if_we_cannot_match_hir_ty(infcx, mir, fr, arg_ty, counter, diag)
253250
}
254251

255252
fn give_name_if_we_can_match_hir_ty_from_argument(
@@ -314,8 +311,10 @@ impl<'tcx> RegionInferenceContext<'tcx> {
314311
infcx.extract_type_name(&argument_ty)
315312
});
316313

317-
debug!("give_name_if_we_cannot_match_hir_ty: type_name={:?} needle_fr={:?}",
318-
type_name, needle_fr);
314+
debug!(
315+
"give_name_if_we_cannot_match_hir_ty: type_name={:?} needle_fr={:?}",
316+
type_name, needle_fr
317+
);
319318
let assigned_region_name = if type_name.find(&format!("'{}", counter)).is_some() {
320319
// Only add a label if we can confirm that a region was labelled.
321320
let argument_index = self.get_argument_index_for_region(infcx.tcx, needle_fr)?;
@@ -547,13 +546,16 @@ impl<'tcx> RegionInferenceContext<'tcx> {
547546
diag: &mut DiagnosticBuilder<'_>,
548547
) -> Option<InternedString> {
549548
let upvar_index = self.get_upvar_index_for_region(tcx, fr)?;
550-
let (upvar_name, upvar_span) = self.get_upvar_name_and_span_for_region(tcx, mir,
551-
upvar_index);
549+
let (upvar_name, upvar_span) =
550+
self.get_upvar_name_and_span_for_region(tcx, mir, upvar_index);
552551
let region_name = self.synthesize_region_name(counter);
553552

554553
diag.span_label(
555554
upvar_span,
556-
format!("lifetime `{}` appears in the type of `{}`", region_name, upvar_name),
555+
format!(
556+
"lifetime `{}` appears in the type of `{}`",
557+
region_name, upvar_name
558+
),
557559
);
558560

559561
Some(region_name)
@@ -579,27 +581,33 @@ impl<'tcx> RegionInferenceContext<'tcx> {
579581
"give_name_if_anonymous_region_appears_in_output: return_ty = {:?}",
580582
return_ty
581583
);
582-
if !infcx.tcx.any_free_region_meets(&return_ty, |r| r.to_region_vid() == fr) {
584+
if !infcx
585+
.tcx
586+
.any_free_region_meets(&return_ty, |r| r.to_region_vid() == fr)
587+
{
583588
return None;
584589
}
585590

586-
let type_name = with_highlight_region(fr, *counter, || {
587-
infcx.extract_type_name(&return_ty)
588-
});
591+
let type_name = with_highlight_region(fr, *counter, || infcx.extract_type_name(&return_ty));
589592

590593
let mir_node_id = tcx.hir.as_local_node_id(mir_def_id).expect("non-local mir");
591594

592-
let (return_span, mir_description) = if let hir::ExprKind::Closure(_, _, _, span, gen_move)
593-
= tcx.hir.expect_expr(mir_node_id).node
594-
{
595-
(
596-
tcx.sess.source_map().end_point(span),
597-
if gen_move.is_some() { " of generator" } else { " of closure" }
598-
)
599-
} else {
600-
// unreachable?
601-
(mir.span, "")
602-
};
595+
let (return_span, mir_description) =
596+
if let hir::ExprKind::Closure(_, _, _, span, gen_move) =
597+
tcx.hir.expect_expr(mir_node_id).node
598+
{
599+
(
600+
tcx.sess.source_map().end_point(span),
601+
if gen_move.is_some() {
602+
" of generator"
603+
} else {
604+
" of closure"
605+
},
606+
)
607+
} else {
608+
// unreachable?
609+
(mir.span, "")
610+
};
603611

604612
diag.span_label(
605613
return_span,

‎src/librustc_mir/borrow_check/nll/region_infer/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use super::universal_regions::UniversalRegions;
1212
use borrow_check::nll::constraints::graph::NormalConstraintGraph;
1313
use borrow_check::nll::constraints::{
14-
ConstraintIndex, ConstraintSccIndex, ConstraintSet, OutlivesConstraint,
14+
ConstraintSccIndex, ConstraintSet, OutlivesConstraint,
1515
};
1616
use borrow_check::nll::region_infer::values::{RegionElement, ToElementIndex};
1717
use borrow_check::nll::type_check::free_region_relations::UniversalRegionRelations;
@@ -234,7 +234,8 @@ impl<'tcx> RegionInferenceContext<'tcx> {
234234

235235
let constraints = Rc::new(outlives_constraints); // freeze constraints
236236
let constraint_graph = Rc::new(constraints.graph(definitions.len()));
237-
let constraint_sccs = Rc::new(constraints.compute_sccs(&constraint_graph));
237+
let fr_static = universal_regions.fr_static;
238+
let constraint_sccs = Rc::new(constraints.compute_sccs(&constraint_graph, fr_static));
238239

239240
let mut scc_values = RegionValues::new(elements, universal_regions.len(), max_universe);
240241

‎src/librustc_mir/borrow_check/nll/type_check/liveness/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ fn regions_that_outlive_free_regions(
6969
// reachable from each free region, we will have all the
7070
// regions that are forced to outlive some free region.
7171
let rev_constraint_graph = constraint_set.reverse_graph(num_region_vars);
72-
let rev_region_graph = rev_constraint_graph.region_graph(constraint_set);
72+
let fr_static = universal_regions.fr_static;
73+
let rev_region_graph = rev_constraint_graph.region_graph(constraint_set, fr_static);
7374

7475
// Stack for the depth-first search. Start out with all the free regions.
7576
let mut stack: Vec<_> = universal_regions.universal_regions().collect();

‎src/librustc_mir/borrow_check/nll/universal_regions.rs

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,9 @@ impl<'tcx> UniversalRegions<'tcx> {
241241
region_mapping.push(fr);
242242
});
243243

244-
for_each_late_bound_region_defined_on(
245-
tcx, closure_base_def_id, |r| { region_mapping.push(r); });
244+
for_each_late_bound_region_defined_on(tcx, closure_base_def_id, |r| {
245+
region_mapping.push(r);
246+
});
246247

247248
assert_eq!(
248249
region_mapping.len(),
@@ -352,9 +353,8 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> {
352353
// let c = || { let x: &'a u32 = ...; }
353354
// }
354355
if self.mir_def_id != closure_base_def_id {
355-
self.infcx.replace_late_bound_regions_with_nll_infer_vars(
356-
self.mir_def_id,
357-
&mut indices)
356+
self.infcx
357+
.replace_late_bound_regions_with_nll_infer_vars(self.mir_def_id, &mut indices)
358358
}
359359

360360
let bound_inputs_and_output = self.compute_inputs_and_output(&indices, defining_ty);
@@ -371,9 +371,8 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> {
371371
// Converse of above, if this is a function then the late-bound regions declared on its
372372
// signature are local to the fn.
373373
if self.mir_def_id == closure_base_def_id {
374-
self.infcx.replace_late_bound_regions_with_nll_infer_vars(
375-
self.mir_def_id,
376-
&mut indices);
374+
self.infcx
375+
.replace_late_bound_regions_with_nll_infer_vars(self.mir_def_id, &mut indices);
377376
}
378377

379378
let fr_fn_body = self.infcx.next_nll_region_var(FR).to_region_vid();
@@ -582,11 +581,10 @@ trait InferCtxtExt<'tcx> {
582581
where
583582
T: TypeFoldable<'tcx>;
584583

585-
586584
fn replace_late_bound_regions_with_nll_infer_vars(
587585
&self,
588586
mir_def_id: DefId,
589-
indices: &mut UniversalRegionIndices<'tcx>
587+
indices: &mut UniversalRegionIndices<'tcx>,
590588
);
591589
}
592590

@@ -619,14 +617,15 @@ impl<'cx, 'gcx, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'cx, 'gcx, 'tcx> {
619617
value, all_outlive_scope,
620618
);
621619
let (value, _map) = self.tcx.replace_late_bound_regions(value, |br| {
620+
debug!("replace_bound_regions_with_nll_infer_vars: br={:?}", br);
622621
let liberated_region = self.tcx.mk_region(ty::ReFree(ty::FreeRegion {
623622
scope: all_outlive_scope,
624623
bound_region: br,
625624
}));
626625
let region_vid = self.next_nll_region_var(origin);
627626
indices.insert_late_bound_region(liberated_region, region_vid.to_region_vid());
628627
debug!(
629-
"liberated_region={:?} => {:?}",
628+
"replace_bound_regions_with_nll_infer_vars: liberated_region={:?} => {:?}",
630629
liberated_region, region_vid
631630
);
632631
region_vid
@@ -648,12 +647,18 @@ impl<'cx, 'gcx, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'cx, 'gcx, 'tcx> {
648647
mir_def_id: DefId,
649648
indices: &mut UniversalRegionIndices<'tcx>,
650649
) {
650+
debug!(
651+
"replace_late_bound_regions_with_nll_infer_vars(mir_def_id={:?})",
652+
mir_def_id
653+
);
651654
let closure_base_def_id = self.tcx.closure_base_def_id(mir_def_id);
652655
for_each_late_bound_region_defined_on(self.tcx, closure_base_def_id, |r| {
656+
debug!("replace_late_bound_regions_with_nll_infer_vars: r={:?}", r);
653657
if !indices.indices.contains_key(&r) {
654658
let region_vid = self.next_nll_region_var(FR);
655659
indices.insert_late_bound_region(r, region_vid.to_region_vid());
656-
}});
660+
}
661+
});
657662
}
658663
}
659664

@@ -703,11 +708,14 @@ impl<'tcx> UniversalRegionIndices<'tcx> {
703708
fn for_each_late_bound_region_defined_on<'tcx>(
704709
tcx: TyCtxt<'_, '_, 'tcx>,
705710
fn_def_id: DefId,
706-
mut f: impl FnMut(ty::Region<'tcx>)
707-
) {
711+
mut f: impl FnMut(ty::Region<'tcx>),
712+
) {
708713
if let Some(late_bounds) = tcx.is_late_bound_map(fn_def_id.index) {
709714
for late_bound in late_bounds.iter() {
710-
let hir_id = HirId{ owner: fn_def_id.index, local_id: *late_bound };
715+
let hir_id = HirId {
716+
owner: fn_def_id.index,
717+
local_id: *late_bound,
718+
};
711719
let region_node_id = tcx.hir.hir_to_node_id(hir_id);
712720
let name = tcx.hir.name(region_node_id).as_interned_str();
713721
let region_def_id = tcx.hir.local_def_id(region_node_id);

‎src/test/mir-opt/nll/named-lifetimes-basic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn main() {
3434
// | '_#4r | Local | ['_#4r]
3535
// |
3636
// | Inferred Region Values
37-
// | '_#0r | U0 | {bb0[0..=1], '_#0r}
37+
// | '_#0r | U0 | {bb0[0..=1], '_#0r, '_#1r, '_#2r, '_#3r, '_#4r}
3838
// | '_#1r | U0 | {bb0[0..=1], '_#1r}
3939
// | '_#2r | U0 | {bb0[0..=1], '_#2r}
4040
// | '_#3r | U0 | {bb0[0..=1], '_#3r}

‎src/test/ui/associated-types/cache/project-fn-ret-contravariant.transmute.nll.stderr

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,15 @@ LL | fn baz<'a,'b>(x: &'a u32) -> &'static u32 {
66
LL | bar(foo, x) //[transmute]~ ERROR E0495
77
| ^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
88

9-
error: aborting due to previous error
9+
error: unsatisfied lifetime constraints
10+
--> $DIR/project-fn-ret-contravariant.rs:48:4
11+
|
12+
LL | fn baz<'a,'b>(x: &'a u32) -> &'static u32 {
13+
| -- -- lifetime `'b` defined here
14+
| |
15+
| lifetime `'a` defined here
16+
LL | bar(foo, x) //[transmute]~ ERROR E0495
17+
| ^^^^^^^^^^^ requires that `'a` must outlive `'b`
18+
19+
error: aborting due to 2 previous errors
1020

‎src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.nll.stderr

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,16 @@ LL | fn baz<'a,'b>(x: Type<'a>) -> Type<'static> {
77
LL | bar(foo, x) //[transmute]~ ERROR E0495
88
| ^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
99

10-
error: aborting due to previous error
10+
error: unsatisfied lifetime constraints
11+
--> $DIR/project-fn-ret-invariant.rs:58:13
12+
|
13+
LL | fn baz<'a,'b>(x: Type<'a>) -> Type<'static> {
14+
| -- -- lifetime `'b` defined here
15+
| |
16+
| lifetime `'a` defined here
17+
...
18+
LL | bar(foo, x) //[transmute]~ ERROR E0495
19+
| ^ requires that `'a` must outlive `'b`
20+
21+
error: aborting due to 2 previous errors
1122

‎src/test/ui/impl-trait/static-return-lifetime-infered.nll.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ error: unsatisfied lifetime constraints
44
LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> {
55
| - let's call the lifetime of this reference `'1`
66
LL | self.x.iter().map(|a| a.0)
7-
| ^^^^^^^^^^^^^ requires that `'1` must outlive `'static`
7+
| ^^^^^^ cast requires that `'1` must outlive `'static`
88

99
error: unsatisfied lifetime constraints
1010
--> $DIR/static-return-lifetime-infered.rs:21:9
1111
|
1212
LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> {
1313
| -- lifetime `'a` defined here
1414
LL | self.x.iter().map(|a| a.0)
15-
| ^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
15+
| ^^^^^^ cast requires that `'a` must outlive `'static`
1616

1717
error: aborting due to 2 previous errors
1818

‎src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ fn demand_y<'x, 'y>(_cell_x: &Cell<&'x u32>, _cell_y: &Cell<&'y u32>, _y: &'y u3
4343
#[rustc_regions]
4444
fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
4545
establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
46-
//~^ ERROR
46+
//~^ ERROR borrowed data escapes outside of function
47+
//~| ERROR unsatisfied lifetime constraints
4748

4849
// Only works if 'x: 'y:
4950
demand_y(x, y, x.get())

‎src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ note: External requirements
33
|
44
LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
55
| _______________________________________________^
6-
LL | | //~^ ERROR
6+
LL | | //~^ ERROR borrowed data escapes outside of function
7+
LL | | //~| ERROR unsatisfied lifetime constraints
78
LL | |
89
LL | | // Only works if 'x: 'y:
910
LL | | demand_y(x, y, x.get())
@@ -22,8 +23,8 @@ note: No external requirements
2223
|
2324
LL | / fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
2425
LL | | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
25-
LL | | //~^ ERROR
26-
LL | |
26+
LL | | //~^ ERROR borrowed data escapes outside of function
27+
LL | | //~| ERROR unsatisfied lifetime constraints
2728
... |
2829
LL | | });
2930
LL | | }
@@ -37,12 +38,23 @@ error: borrowed data escapes outside of function
3738
LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
3839
| ------ `cell_a` is a reference that is only valid in the function body
3940
LL | / establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
40-
LL | | //~^ ERROR
41+
LL | | //~^ ERROR borrowed data escapes outside of function
42+
LL | | //~| ERROR unsatisfied lifetime constraints
4143
LL | |
4244
LL | | // Only works if 'x: 'y:
4345
LL | | demand_y(x, y, x.get())
4446
LL | | });
4547
| |______^ `cell_a` escapes the function body here
4648

47-
error: aborting due to previous error
49+
error: unsatisfied lifetime constraints
50+
--> $DIR/propagate-approximated-shorter-to-static-no-bound.rs:45:29
51+
|
52+
LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
53+
| -- -- lifetime `'b` defined here
54+
| |
55+
| lifetime `'a` defined here
56+
LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
57+
| ^^^^^^^ requires that `'a` must outlive `'b`
58+
59+
error: aborting due to 2 previous errors
4860

‎src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ fn demand_y<'x, 'y>(_cell_x: &Cell<&'x u32>, _cell_y: &Cell<&'y u32>, _y: &'y u3
4646
#[rustc_regions]
4747
fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
4848
establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
49-
//~^ ERROR
49+
//~^ ERROR borrowed data escapes outside of function
50+
//~| ERROR unsatisfied lifetime constraints
5051
// Only works if 'x: 'y:
5152
demand_y(x, y, x.get())
5253
});

‎src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ note: External requirements
33
|
44
LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
55
| _______________________________________________^
6-
LL | | //~^ ERROR
6+
LL | | //~^ ERROR borrowed data escapes outside of function
7+
LL | | //~| ERROR unsatisfied lifetime constraints
78
LL | | // Only works if 'x: 'y:
89
LL | | demand_y(x, y, x.get())
910
LL | | });
@@ -21,9 +22,9 @@ note: No external requirements
2122
|
2223
LL | / fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
2324
LL | | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
24-
LL | | //~^ ERROR
25-
LL | | // Only works if 'x: 'y:
26-
LL | | demand_y(x, y, x.get())
25+
LL | | //~^ ERROR borrowed data escapes outside of function
26+
LL | | //~| ERROR unsatisfied lifetime constraints
27+
... |
2728
LL | | });
2829
LL | | }
2930
| |_^
@@ -36,11 +37,22 @@ error: borrowed data escapes outside of function
3637
LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
3738
| ------ `cell_a` is a reference that is only valid in the function body
3839
LL | / establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
39-
LL | | //~^ ERROR
40+
LL | | //~^ ERROR borrowed data escapes outside of function
41+
LL | | //~| ERROR unsatisfied lifetime constraints
4042
LL | | // Only works if 'x: 'y:
4143
LL | | demand_y(x, y, x.get())
4244
LL | | });
4345
| |______^ `cell_a` escapes the function body here
4446

45-
error: aborting due to previous error
47+
error: unsatisfied lifetime constraints
48+
--> $DIR/propagate-approximated-shorter-to-static-wrong-bound.rs:48:29
49+
|
50+
LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
51+
| -- -- lifetime `'b` defined here
52+
| |
53+
| lifetime `'a` defined here
54+
LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
55+
| ^^^^^^^ requires that `'a` must outlive `'b`
56+
57+
error: aborting due to 2 previous errors
4658

‎src/test/ui/nll/closure-requirements/propagate-from-trait-match.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ LL | | });
1717
i32,
1818
extern "rust-call" fn((T,))
1919
]
20-
= note: number of external vids: 3
20+
= note: number of external vids: 2
2121
= note: where T: '_#1r
2222

2323
note: No external requirements

‎src/test/ui/nll/mir_check_cast_reify.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ fn bar<'a>(x: &'a u32) -> &'static u32 {
4444
// The MIR type checker must therefore relate `'?0` to `'?1` and `'?2`
4545
// as part of checking the `ReifyFnPointer`.
4646
let f: fn(_) -> _ = foo;
47+
//~^ ERROR unsatisfied lifetime constraints
4748
f(x)
48-
//~^ ERROR
4949
}
5050

5151
fn main() {}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error: unsatisfied lifetime constraints
2-
--> $DIR/mir_check_cast_reify.rs:47:5
2+
--> $DIR/mir_check_cast_reify.rs:46:25
33
|
44
LL | fn bar<'a>(x: &'a u32) -> &'static u32 {
55
| -- lifetime `'a` defined here
66
...
7-
LL | f(x)
8-
| ^^^^ returning this value requires that `'a` must outlive `'static`
7+
LL | let f: fn(_) -> _ = foo;
8+
| ^^^ cast requires that `'a` must outlive `'static`
99

1010
error: aborting due to previous error
1111

‎src/test/ui/nll/mir_check_cast_unsafe_fn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ fn bar<'a>(input: &'a u32, f: fn(&'a u32) -> &'a u32) -> &'static u32 {
1616
// Here the NLL checker must relate the types in `f` to the types
1717
// in `g`. These are related via the `UnsafeFnPointer` cast.
1818
let g: unsafe fn(_) -> _ = f;
19+
//~^ ERROR unsatisfied lifetime constraints
1920
unsafe { g(input) }
20-
//~^ ERROR
2121
}
2222

2323
fn main() {}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error: unsatisfied lifetime constraints
2-
--> $DIR/mir_check_cast_unsafe_fn.rs:19:14
2+
--> $DIR/mir_check_cast_unsafe_fn.rs:18:32
33
|
44
LL | fn bar<'a>(input: &'a u32, f: fn(&'a u32) -> &'a u32) -> &'static u32 {
55
| -- lifetime `'a` defined here
66
...
7-
LL | unsafe { g(input) }
8-
| ^^^^^^^^ returning this value requires that `'a` must outlive `'static`
7+
LL | let g: unsafe fn(_) -> _ = f;
8+
| ^ cast requires that `'a` must outlive `'static`
99

1010
error: aborting due to previous error
1111

‎src/test/ui/nll/mir_check_cast_unsize.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: unsatisfied lifetime constraints
44
LL | fn bar<'a>(x: &'a u32) -> &'static dyn Debug {
55
| -- lifetime `'a` defined here
66
LL | x
7-
| ^ returning this value requires that `'a` must outlive `'static`
7+
| ^ cast requires that `'a` must outlive `'static`
88

99
error: aborting due to previous error
1010

‎src/test/ui/nll/ty-outlives/projection-no-regions-closure.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ LL | with_signature(x, |mut y| Box::new(y.next()))
1010
i32,
1111
extern "rust-call" fn((std::boxed::Box<T>,)) -> std::boxed::Box<(dyn Anything + '_#2r)>
1212
]
13-
= note: number of external vids: 4
13+
= note: number of external vids: 3
1414
= note: where <T as std::iter::Iterator>::Item: '_#2r
1515

1616
note: No external requirements
@@ -50,7 +50,7 @@ LL | with_signature(x, |mut y| Box::new(y.next()))
5050
i32,
5151
extern "rust-call" fn((std::boxed::Box<T>,)) -> std::boxed::Box<(dyn Anything + '_#2r)>
5252
]
53-
= note: number of external vids: 4
53+
= note: number of external vids: 3
5454
= note: where <T as std::iter::Iterator>::Item: '_#2r
5555

5656
note: No external requirements
@@ -82,7 +82,7 @@ LL | with_signature(x, |mut y| Box::new(y.next()))
8282
i32,
8383
extern "rust-call" fn((std::boxed::Box<T>,)) -> std::boxed::Box<(dyn Anything + '_#3r)>
8484
]
85-
= note: number of external vids: 5
85+
= note: number of external vids: 4
8686
= note: where <T as std::iter::Iterator>::Item: '_#3r
8787

8888
note: No external requirements
@@ -124,7 +124,7 @@ LL | with_signature(x, |mut y| Box::new(y.next()))
124124
i32,
125125
extern "rust-call" fn((std::boxed::Box<T>,)) -> std::boxed::Box<(dyn Anything + '_#3r)>
126126
]
127-
= note: number of external vids: 5
127+
= note: number of external vids: 4
128128
= note: where <T as std::iter::Iterator>::Item: '_#3r
129129

130130
note: No external requirements

‎src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t));
1010
i32,
1111
extern "rust-call" fn((std::cell::Cell<&'_#2r ()>, T))
1212
]
13-
= note: number of external vids: 5
13+
= note: number of external vids: 4
1414
= note: where T: '_#2r
1515
= note: where '_#1r: '_#2r
1616

@@ -63,7 +63,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t));
6363
i32,
6464
extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T))
6565
]
66-
= note: number of external vids: 5
66+
= note: number of external vids: 4
6767
= note: where T: '_#3r
6868
= note: where '_#2r: '_#3r
6969

@@ -117,7 +117,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t));
117117
i32,
118118
extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T))
119119
]
120-
= note: number of external vids: 5
120+
= note: number of external vids: 4
121121
= note: where T: '_#3r
122122
= note: where '_#2r: '_#3r
123123

@@ -171,7 +171,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t));
171171
i32,
172172
extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T))
173173
]
174-
= note: number of external vids: 5
174+
= note: number of external vids: 4
175175
= note: where T: '_#3r
176176
= note: where '_#2r: '_#3r
177177

‎src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t));
1010
i32,
1111
extern "rust-call" fn((std::cell::Cell<&'_#2r ()>, T))
1212
]
13-
= note: number of external vids: 5
13+
= note: number of external vids: 4
1414
= note: where '_#1r: '_#2r
1515

1616
note: No external requirements
@@ -54,7 +54,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t));
5454
i32,
5555
extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T))
5656
]
57-
= note: number of external vids: 5
57+
= note: number of external vids: 4
5858
= note: where '_#2r: '_#3r
5959

6060
note: No external requirements
@@ -99,7 +99,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t));
9999
i32,
100100
extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T))
101101
]
102-
= note: number of external vids: 5
102+
= note: number of external vids: 4
103103
= note: where '_#2r: '_#3r
104104

105105
note: No external requirements
@@ -144,7 +144,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t));
144144
i32,
145145
extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T))
146146
]
147-
= note: number of external vids: 5
147+
= note: number of external vids: 4
148148
= note: where '_#2r: '_#3r
149149

150150
note: No external requirements
@@ -177,7 +177,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t));
177177
i32,
178178
extern "rust-call" fn((std::cell::Cell<&'_#2r ()>, T))
179179
]
180-
= note: number of external vids: 4
180+
= note: number of external vids: 3
181181
= note: where '_#1r: '_#2r
182182

183183
note: No external requirements

‎src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ where
4646
T: Anything<'b, 'c>,
4747
{
4848
with_signature(cell, t, |cell, t| require(cell, t));
49-
//~^ ERROR associated type `<T as Anything<'_#6r, '_#7r>>::AssocType` may not live long enough
49+
//~^ ERROR associated type `<T as Anything<'_#5r, '_#6r>>::AssocType` may not live long enough
5050
}
5151

5252
#[rustc_regions]
@@ -56,7 +56,7 @@ where
5656
'a: 'a,
5757
{
5858
with_signature(cell, t, |cell, t| require(cell, t));
59-
//~^ ERROR associated type `<T as Anything<'_#7r, '_#8r>>::AssocType` may not live long enough
59+
//~^ ERROR associated type `<T as Anything<'_#6r, '_#7r>>::AssocType` may not live long enough
6060
}
6161

6262
#[rustc_regions]
@@ -76,7 +76,7 @@ where
7676
// can do better here with a more involved verification step.
7777

7878
with_signature(cell, t, |cell, t| require(cell, t));
79-
//~^ ERROR associated type `<T as Anything<'_#7r, '_#8r>>::AssocType` may not live long enough
79+
//~^ ERROR associated type `<T as Anything<'_#6r, '_#7r>>::AssocType` may not live long enough
8080
}
8181

8282
#[rustc_regions]
@@ -103,7 +103,7 @@ where
103103
T: Anything<'b, 'b>,
104104
{
105105
with_signature(cell, t, |cell, t| require(cell, t));
106-
//~^ ERROR
106+
//~^ ERROR unsatisfied lifetime constraints
107107
}
108108

109109
#[rustc_regions]

‎src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t));
1111
i32,
1212
extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T))
1313
]
14-
= note: number of external vids: 6
14+
= note: number of external vids: 5
1515
= note: where <T as Anything<ReClosureBound('_#1r), ReClosureBound('_#2r)>>::AssocType: '_#3r
1616

1717
note: No external requirements
@@ -22,7 +22,7 @@ LL | | where
2222
LL | | T: Anything<'b, 'c>,
2323
LL | | {
2424
LL | | with_signature(cell, t, |cell, t| require(cell, t));
25-
LL | | //~^ ERROR associated type `<T as Anything<'_#6r, '_#7r>>::AssocType` may not live long enough
25+
LL | | //~^ ERROR associated type `<T as Anything<'_#5r, '_#6r>>::AssocType` may not live long enough
2626
LL | | }
2727
| |_^
2828
|
@@ -32,13 +32,13 @@ LL | | }
3232
T
3333
]
3434

35-
error[E0309]: the associated type `<T as Anything<'_#6r, '_#7r>>::AssocType` may not live long enough
35+
error[E0309]: the associated type `<T as Anything<'_#5r, '_#6r>>::AssocType` may not live long enough
3636
--> $DIR/projection-two-region-trait-bound-closure.rs:48:29
3737
|
3838
LL | with_signature(cell, t, |cell, t| require(cell, t));
3939
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
4040
|
41-
= help: consider adding an explicit lifetime bound `<T as Anything<'_#6r, '_#7r>>::AssocType: ReFree(DefId(0/0:8 ~ projection_two_region_trait_bound_closure[317d]::no_relationships_late[0]), BrNamed(crate0:DefIndex(1:18), 'a))`...
41+
= help: consider adding an explicit lifetime bound `<T as Anything<'_#5r, '_#6r>>::AssocType: ReFree(DefId(0/0:8 ~ projection_two_region_trait_bound_closure[317d]::no_relationships_late[0]), BrNamed(crate0:DefIndex(1:18), 'a))`...
4242

4343
note: External requirements
4444
--> $DIR/projection-two-region-trait-bound-closure.rs:58:29
@@ -54,7 +54,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t));
5454
i32,
5555
extern "rust-call" fn((std::cell::Cell<&'_#4r ()>, T))
5656
]
57-
= note: number of external vids: 6
57+
= note: number of external vids: 5
5858
= note: where <T as Anything<ReClosureBound('_#2r), ReClosureBound('_#3r)>>::AssocType: '_#4r
5959

6060
note: No external requirements
@@ -65,7 +65,7 @@ LL | | where
6565
LL | | T: Anything<'b, 'c>,
6666
LL | | 'a: 'a,
6767
... |
68-
LL | | //~^ ERROR associated type `<T as Anything<'_#7r, '_#8r>>::AssocType` may not live long enough
68+
LL | | //~^ ERROR associated type `<T as Anything<'_#6r, '_#7r>>::AssocType` may not live long enough
6969
LL | | }
7070
| |_^
7171
|
@@ -76,13 +76,13 @@ LL | | }
7676
T
7777
]
7878

79-
error[E0309]: the associated type `<T as Anything<'_#7r, '_#8r>>::AssocType` may not live long enough
79+
error[E0309]: the associated type `<T as Anything<'_#6r, '_#7r>>::AssocType` may not live long enough
8080
--> $DIR/projection-two-region-trait-bound-closure.rs:58:29
8181
|
8282
LL | with_signature(cell, t, |cell, t| require(cell, t));
8383
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
8484
|
85-
= help: consider adding an explicit lifetime bound `<T as Anything<'_#7r, '_#8r>>::AssocType: ReEarlyBound(0, 'a)`...
85+
= help: consider adding an explicit lifetime bound `<T as Anything<'_#6r, '_#7r>>::AssocType: ReEarlyBound(0, 'a)`...
8686

8787
note: External requirements
8888
--> $DIR/projection-two-region-trait-bound-closure.rs:78:29
@@ -98,7 +98,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t));
9898
i32,
9999
extern "rust-call" fn((std::cell::Cell<&'_#4r ()>, T))
100100
]
101-
= note: number of external vids: 6
101+
= note: number of external vids: 5
102102
= note: where <T as Anything<ReClosureBound('_#2r), ReClosureBound('_#3r)>>::AssocType: '_#4r
103103

104104
note: No external requirements
@@ -109,7 +109,7 @@ LL | | where
109109
LL | | T: Anything<'b, 'c>,
110110
LL | | T::AssocType: 'a,
111111
... |
112-
LL | | //~^ ERROR associated type `<T as Anything<'_#7r, '_#8r>>::AssocType` may not live long enough
112+
LL | | //~^ ERROR associated type `<T as Anything<'_#6r, '_#7r>>::AssocType` may not live long enough
113113
LL | | }
114114
| |_^
115115
|
@@ -120,13 +120,13 @@ LL | | }
120120
T
121121
]
122122

123-
error[E0309]: the associated type `<T as Anything<'_#7r, '_#8r>>::AssocType` may not live long enough
123+
error[E0309]: the associated type `<T as Anything<'_#6r, '_#7r>>::AssocType` may not live long enough
124124
--> $DIR/projection-two-region-trait-bound-closure.rs:78:29
125125
|
126126
LL | with_signature(cell, t, |cell, t| require(cell, t));
127127
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
128128
|
129-
= help: consider adding an explicit lifetime bound `<T as Anything<'_#7r, '_#8r>>::AssocType: ReEarlyBound(0, 'a)`...
129+
= help: consider adding an explicit lifetime bound `<T as Anything<'_#6r, '_#7r>>::AssocType: ReEarlyBound(0, 'a)`...
130130

131131
note: External requirements
132132
--> $DIR/projection-two-region-trait-bound-closure.rs:88:29
@@ -142,7 +142,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t));
142142
i32,
143143
extern "rust-call" fn((std::cell::Cell<&'_#4r ()>, T))
144144
]
145-
= note: number of external vids: 6
145+
= note: number of external vids: 5
146146
= note: where <T as Anything<ReClosureBound('_#2r), ReClosureBound('_#3r)>>::AssocType: '_#4r
147147

148148
note: No external requirements
@@ -178,7 +178,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t));
178178
i32,
179179
extern "rust-call" fn((std::cell::Cell<&'_#4r ()>, T))
180180
]
181-
= note: number of external vids: 6
181+
= note: number of external vids: 5
182182
= note: where <T as Anything<ReClosureBound('_#2r), ReClosureBound('_#3r)>>::AssocType: '_#4r
183183

184184
note: No external requirements
@@ -212,7 +212,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t));
212212
i32,
213213
extern "rust-call" fn((std::cell::Cell<&'_#2r ()>, T))
214214
]
215-
= note: number of external vids: 5
215+
= note: number of external vids: 4
216216
= note: where <T as Anything<ReClosureBound('_#1r), ReClosureBound('_#1r)>>::AssocType: '_#2r
217217

218218
note: No external requirements
@@ -223,7 +223,7 @@ LL | | where
223223
LL | | T: Anything<'b, 'b>,
224224
LL | | {
225225
LL | | with_signature(cell, t, |cell, t| require(cell, t));
226-
LL | | //~^ ERROR
226+
LL | | //~^ ERROR unsatisfied lifetime constraints
227227
LL | | }
228228
| |_^
229229
|
@@ -256,7 +256,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t));
256256
i32,
257257
extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T))
258258
]
259-
= note: number of external vids: 5
259+
= note: number of external vids: 4
260260
= note: where <T as Anything<ReClosureBound('_#2r), ReClosureBound('_#2r)>>::AssocType: '_#3r
261261

262262
note: No external requirements
@@ -289,7 +289,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t));
289289
i32,
290290
extern "rust-call" fn((std::cell::Cell<&'_#2r ()>, T))
291291
]
292-
= note: number of external vids: 4
292+
= note: number of external vids: 3
293293
= note: where <T as Anything<ReClosureBound('_#1r), ReClosureBound('_#1r)>>::AssocType: '_#2r
294294

295295
note: No external requirements

‎src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LL | twice(cell, value, |a, b| invoke(a, b));
99
i16,
1010
for<'r, 's> extern "rust-call" fn((std::option::Option<std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BrNamed(crate0:DefIndex(0:0), 'r)) ()>>, &ReLateBound(DebruijnIndex(0), BrNamed(crate0:DefIndex(0:0), 's)) T))
1111
]
12-
= note: number of external vids: 3
12+
= note: number of external vids: 2
1313
= note: where T: '_#1r
1414

1515
note: No external requirements
@@ -36,7 +36,7 @@ LL | twice(cell, value, |a, b| invoke(a, b));
3636
i16,
3737
for<'r, 's> extern "rust-call" fn((std::option::Option<std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BrNamed(crate0:DefIndex(0:0), 'r)) ()>>, &ReLateBound(DebruijnIndex(0), BrNamed(crate0:DefIndex(0:0), 's)) T))
3838
]
39-
= note: number of external vids: 4
39+
= note: number of external vids: 3
4040
= note: where T: '_#1r
4141

4242
note: No external requirements

‎src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ LL | with_signature(x, |y| y)
1010
i32,
1111
extern "rust-call" fn((std::boxed::Box<T>,)) -> std::boxed::Box<(dyn std::fmt::Debug + '_#2r)>
1212
]
13-
= note: number of external vids: 4
13+
= note: number of external vids: 3
1414
= note: where T: '_#2r
1515

1616
note: No external requirements

‎src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ LL | | })
1616
i32,
1717
extern "rust-call" fn((std::cell::Cell<&'_#1r ()>, T))
1818
]
19-
= note: number of external vids: 4
19+
= note: number of external vids: 3
2020
= note: where T: '_#1r
2121

2222
note: No external requirements
@@ -69,7 +69,7 @@ LL | | })
6969
i32,
7070
extern "rust-call" fn((std::cell::Cell<&'_#2r ()>, T))
7171
]
72-
= note: number of external vids: 4
72+
= note: number of external vids: 3
7373
= note: where T: '_#2r
7474

7575
note: No external requirements
@@ -106,7 +106,7 @@ LL | | })
106106
i32,
107107
extern "rust-call" fn((std::cell::Cell<&'_#2r ()>, T))
108108
]
109-
= note: number of external vids: 5
109+
= note: number of external vids: 4
110110
= note: where T: '_#2r
111111

112112
note: No external requirements
@@ -156,7 +156,7 @@ LL | | })
156156
i32,
157157
extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T))
158158
]
159-
= note: number of external vids: 5
159+
= note: number of external vids: 4
160160
= note: where T: '_#3r
161161

162162
note: No external requirements
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
error: unsatisfied lifetime constraints
2-
--> $DIR/regions-addr-of-self.rs:17:37
2+
--> $DIR/regions-addr-of-self.rs:17:13
33
|
44
LL | pub fn chase_cat(&mut self) {
55
| - let's call the lifetime of this reference `'1`
66
LL | let p: &'static mut usize = &mut self.cats_chased; //~ ERROR cannot infer
7-
| ^^^^^^^^^^^^^^^^^^^^^ requires that `'1` must outlive `'static`
7+
| ^ requires that `'1` must outlive `'static`
88

99
error: aborting due to previous error
1010

‎src/test/ui/regions/regions-addr-of-upvar-self.nll.stderr

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
error: unsatisfied lifetime constraints
2-
--> $DIR/regions-addr-of-upvar-self.rs:20:41
2+
--> $DIR/regions-addr-of-upvar-self.rs:20:17
33
|
44
LL | let _f = || {
55
| -- lifetime `'1` represents this closure's body
66
LL | let p: &'static mut usize = &mut self.food; //~ ERROR cannot infer
7-
| ^^^^^^^^^^^^^^ requires that `'1` must outlive `'static`
7+
| ^ requires that `'1` must outlive `'static`
8+
|
9+
= note: closure implements `FnMut`, so references to captured variables can't escape the closure
10+
11+
error: unsatisfied lifetime constraints
12+
--> $DIR/regions-addr-of-upvar-self.rs:20:17
13+
|
14+
LL | pub fn chase_cat(&mut self) {
15+
| --------- lifetime `'2` appears in the type of `self`
16+
LL | let _f = || {
17+
| -- lifetime `'1` represents this closure's body
18+
LL | let p: &'static mut usize = &mut self.food; //~ ERROR cannot infer
19+
| ^ requires that `'1` must outlive `'2`
820
|
921
= note: closure implements `FnMut`, so references to captured variables can't escape the closure
1022

@@ -29,6 +41,6 @@ LL | }
2941
|
3042
= note: borrowed value must be valid for the static lifetime...
3143

32-
error: aborting due to 3 previous errors
44+
error: aborting due to 4 previous errors
3345

3446
For more information about this error, try `rustc --explain E0597`.

‎src/test/ui/regions/regions-close-object-into-object-2.nll.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
error: unsatisfied lifetime constraints
2-
--> $DIR/regions-close-object-into-object-2.rs:20:5
2+
--> $DIR/regions-close-object-into-object-2.rs:20:11
33
|
44
LL | fn g<'a, T: 'static>(v: Box<A<T>+'a>) -> Box<X+'static> {
55
| -- lifetime `'a` defined here
66
LL | box B(&*v) as Box<X> //~ ERROR cannot infer
7-
| ^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
7+
| ^^^ cast requires that `'a` must outlive `'static`
88

99
error[E0597]: `*v` does not live long enough
1010
--> $DIR/regions-close-object-into-object-2.rs:20:11

‎src/test/ui/regions/regions-close-object-into-object-4.nll.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@ LL | box B(&*v) as Box<X> //~ ERROR cannot infer
66
|
77
= help: consider adding an explicit lifetime bound `U: 'static`...
88

9-
error: unsatisfied lifetime constraints
10-
--> $DIR/regions-close-object-into-object-4.rs:20:5
11-
|
12-
LL | fn i<'a, T, U>(v: Box<A<U>+'a>) -> Box<X+'static> {
13-
| -- lifetime `'a` defined here
14-
LL | box B(&*v) as Box<X> //~ ERROR cannot infer
15-
| ^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
16-
179
error[E0310]: the parameter type `U` may not live long enough
1810
--> $DIR/regions-close-object-into-object-4.rs:20:9
1911
|
@@ -22,6 +14,14 @@ LL | box B(&*v) as Box<X> //~ ERROR cannot infer
2214
|
2315
= help: consider adding an explicit lifetime bound `U: 'static`...
2416

17+
error: unsatisfied lifetime constraints
18+
--> $DIR/regions-close-object-into-object-4.rs:20:11
19+
|
20+
LL | fn i<'a, T, U>(v: Box<A<U>+'a>) -> Box<X+'static> {
21+
| -- lifetime `'a` defined here
22+
LL | box B(&*v) as Box<X> //~ ERROR cannot infer
23+
| ^^^ cast requires that `'a` must outlive `'static`
24+
2525
error[E0597]: `*v` does not live long enough
2626
--> $DIR/regions-close-object-into-object-4.rs:20:11
2727
|

‎src/test/ui/regions/regions-static-bound.ll.nll.stderr

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,35 @@ LL | static_id(&u); //[ll]~ ERROR explicit lifetime required in the type of
1515
| ^^^^^^^^^^^^^ lifetime `'static` required
1616

1717
error[E0621]: explicit lifetime required in the type of `v`
18-
--> $DIR/regions-static-bound.rs:26:5
18+
--> $DIR/regions-static-bound.rs:27:5
1919
|
2020
LL | fn error(u: &(), v: &()) {
2121
| --- help: add explicit lifetime `'static` to the type of `v`: `&'static ()`
2222
...
2323
LL | static_id_indirect(&v); //[ll]~ ERROR explicit lifetime required in the type of `v` [E0621]
2424
| ^^^^^^^^^^^^^^^^^^^^^^ lifetime `'static` required
2525

26-
error: aborting due to 3 previous errors
26+
error: unsatisfied lifetime constraints
27+
--> $DIR/regions-static-bound.rs:24:5
28+
|
29+
LL | fn error(u: &(), v: &()) {
30+
| - - let's call the lifetime of this reference `'2`
31+
| |
32+
| let's call the lifetime of this reference `'1`
33+
LL | static_id(&u); //[ll]~ ERROR explicit lifetime required in the type of `u` [E0621]
34+
| ^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2`
35+
36+
error: unsatisfied lifetime constraints
37+
--> $DIR/regions-static-bound.rs:27:5
38+
|
39+
LL | fn error(u: &(), v: &()) {
40+
| - - let's call the lifetime of this reference `'1`
41+
| |
42+
| let's call the lifetime of this reference `'2`
43+
...
44+
LL | static_id_indirect(&v); //[ll]~ ERROR explicit lifetime required in the type of `v` [E0621]
45+
| ^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2`
46+
47+
error: aborting due to 5 previous errors
2748

2849
For more information about this error, try `rustc --explain E0621`.

‎src/test/ui/regions/regions-static-bound.ll.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ LL | static_id(&u); //[ll]~ ERROR explicit lifetime required in the type of
2020
| ^^^^^^^^^ lifetime `'static` required
2121

2222
error[E0621]: explicit lifetime required in the type of `v`
23-
--> $DIR/regions-static-bound.rs:26:5
23+
--> $DIR/regions-static-bound.rs:27:5
2424
|
2525
LL | fn error(u: &(), v: &()) {
2626
| --- help: add explicit lifetime `'static` to the type of `v`: `&'static ()`

‎src/test/ui/regions/regions-static-bound.nll.stderr

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,35 @@ LL | static_id(&u); //[ll]~ ERROR explicit lifetime required in the type of
1515
| ^^^^^^^^^^^^^ lifetime `'static` required
1616

1717
error[E0621]: explicit lifetime required in the type of `v`
18-
--> $DIR/regions-static-bound.rs:26:5
18+
--> $DIR/regions-static-bound.rs:27:5
1919
|
2020
LL | fn error(u: &(), v: &()) {
2121
| --- help: add explicit lifetime `'static` to the type of `v`: `&'static ()`
2222
...
2323
LL | static_id_indirect(&v); //[ll]~ ERROR explicit lifetime required in the type of `v` [E0621]
2424
| ^^^^^^^^^^^^^^^^^^^^^^ lifetime `'static` required
2525

26-
error: aborting due to 3 previous errors
26+
error: unsatisfied lifetime constraints
27+
--> $DIR/regions-static-bound.rs:24:5
28+
|
29+
LL | fn error(u: &(), v: &()) {
30+
| - - let's call the lifetime of this reference `'2`
31+
| |
32+
| let's call the lifetime of this reference `'1`
33+
LL | static_id(&u); //[ll]~ ERROR explicit lifetime required in the type of `u` [E0621]
34+
| ^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2`
35+
36+
error: unsatisfied lifetime constraints
37+
--> $DIR/regions-static-bound.rs:27:5
38+
|
39+
LL | fn error(u: &(), v: &()) {
40+
| - - let's call the lifetime of this reference `'1`
41+
| |
42+
| let's call the lifetime of this reference `'2`
43+
...
44+
LL | static_id_indirect(&v); //[ll]~ ERROR explicit lifetime required in the type of `v` [E0621]
45+
| ^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2`
46+
47+
error: aborting due to 5 previous errors
2748

2849
For more information about this error, try `rustc --explain E0621`.

‎src/test/ui/regions/regions-static-bound.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ fn static_id_wrong_way<'a>(t: &'a ()) -> &'static () where 'static: 'a {
2323
fn error(u: &(), v: &()) {
2424
static_id(&u); //[ll]~ ERROR explicit lifetime required in the type of `u` [E0621]
2525
//[nll]~^ ERROR explicit lifetime required in the type of `u` [E0621]
26+
//[nll]~| ERROR unsatisfied lifetime constraints
2627
static_id_indirect(&v); //[ll]~ ERROR explicit lifetime required in the type of `v` [E0621]
2728
//[nll]~^ ERROR explicit lifetime required in the type of `v` [E0621]
29+
//[nll]~| ERROR unsatisfied lifetime constraints
2830
}
2931

3032
fn main() {}

‎src/test/ui/underscore-lifetime/dyn-trait-underscore.nll.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
55
| - let's call the lifetime of this reference `'1`
66
LL | // ^^^^^^^^^^^^^^^^^^^^^ bound *here* defaults to `'static`
77
LL | Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime
8-
| ^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'static`
8+
| ^^^^^^^^^^^^^^^^^^^^^^ cast requires that `'1` must outlive `'static`
99

1010
error: aborting due to previous error
1111

0 commit comments

Comments
 (0)
Please sign in to comment.