Skip to content

Commit 4c4fc75

Browse files
committed
rustc: reintroduce lifetime bounds where necessary.
1 parent 356a37d commit 4c4fc75

File tree

15 files changed

+36
-30
lines changed

15 files changed

+36
-30
lines changed

src/librustc/infer/lattice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub trait LatticeDir<'f, 'tcx>: TypeRelation<'tcx> {
4141
fn relate_bound(&mut self, v: Ty<'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, ()>;
4242
}
4343

44-
pub fn super_lattice_tys<'a, 'tcx, L>(
44+
pub fn super_lattice_tys<'a, 'tcx: 'a, L>(
4545
this: &mut L,
4646
a: Ty<'tcx>,
4747
b: Ty<'tcx>,

src/librustc/traits/select.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3788,9 +3788,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
37883788
matcher.relate(previous, current).is_ok()
37893789
}
37903790

3791-
fn push_stack<'o, 's>(
3791+
fn push_stack<'o>(
37923792
&mut self,
3793-
previous_stack: TraitObligationStackList<'s, 'tcx>,
3793+
previous_stack: TraitObligationStackList<'o, 'tcx>,
37943794
obligation: &'o TraitObligation<'tcx>,
37953795
) -> TraitObligationStack<'o, 'tcx> {
37963796
let fresh_trait_ref = obligation

src/librustc_codegen_ssa/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ pub fn memcpy_ty<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
366366
bx.memcpy(dst, dst_align, src, src_align, bx.cx().const_usize(size), flags);
367367
}
368368

369-
pub fn codegen_instance<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
369+
pub fn codegen_instance<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
370370
cx: &'a Bx::CodegenCx,
371371
instance: Instance<'tcx>,
372372
) {

src/librustc_codegen_ssa/mono_item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub trait MonoItemExt<'a, 'tcx> {
1717
fn to_raw_string(&self) -> String;
1818
}
1919

20-
impl<'a, 'tcx> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> {
20+
impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> {
2121
fn define<Bx: BuilderMethods<'a, 'tcx>>(&self, cx: &'a Bx::CodegenCx) {
2222
debug!("BEGIN IMPLEMENTING '{} ({})' in cgu {}",
2323
self.to_string(cx.tcx(), true),

src/librustc_metadata/creader.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,14 @@ impl<'a> CrateLoader<'a> {
289289
(cnum, cmeta)
290290
}
291291

292-
fn load_proc_macro<'b> (
292+
fn load_proc_macro<'b>(
293293
&mut self,
294294
locate_ctxt: &mut locator::Context<'b>,
295295
path_kind: PathKind,
296-
) -> Option<(LoadResult, Option<Library>)> {
296+
) -> Option<(LoadResult, Option<Library>)>
297+
where
298+
'a: 'b,
299+
{
297300
// Use a new locator Context so trying to load a proc macro doesn't affect the error
298301
// message we emit
299302
let mut proc_macro_locator = locate_ctxt.clone();

src/librustc_metadata/decoder.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use log::debug;
3838
pub struct DecodeContext<'a, 'tcx> {
3939
opaque: opaque::Decoder<'a>,
4040
cdata: Option<&'a CrateMetadata>,
41-
sess: Option<&'a Session>,
41+
sess: Option<&'tcx Session>,
4242
tcx: Option<TyCtxt<'tcx>>,
4343

4444
// Cache the last used source_file for translating spans as an optimization.
@@ -54,10 +54,8 @@ pub struct DecodeContext<'a, 'tcx> {
5454
pub trait Metadata<'a, 'tcx>: Copy {
5555
fn raw_bytes(self) -> &'a [u8];
5656
fn cdata(self) -> Option<&'a CrateMetadata> { None }
57-
fn sess(self) -> Option<&'a Session> { None }
58-
fn tcx(self) -> Option<TyCtxt<'tcx>> {
59-
None
60-
}
57+
fn sess(self) -> Option<&'tcx Session> { None }
58+
fn tcx(self) -> Option<TyCtxt<'tcx>> { None }
6159

6260
fn decoder(self, pos: usize) -> DecodeContext<'a, 'tcx> {
6361
let tcx = self.tcx();
@@ -82,13 +80,13 @@ impl<'a, 'tcx> Metadata<'a, 'tcx> for &'a MetadataBlob {
8280
}
8381

8482

85-
impl<'a, 'tcx> Metadata<'a, 'tcx> for (&'a MetadataBlob, &'a Session) {
83+
impl<'a, 'tcx> Metadata<'a, 'tcx> for (&'a MetadataBlob, &'tcx Session) {
8684
fn raw_bytes(self) -> &'a [u8] {
8785
let (blob, _) = self;
8886
&blob.0
8987
}
9088

91-
fn sess(self) -> Option<&'a Session> {
89+
fn sess(self) -> Option<&'tcx Session> {
9290
let (_, sess) = self;
9391
Some(sess)
9492
}
@@ -104,14 +102,14 @@ impl<'a, 'tcx> Metadata<'a, 'tcx> for &'a CrateMetadata {
104102
}
105103
}
106104

107-
impl<'a, 'tcx> Metadata<'a, 'tcx> for (&'a CrateMetadata, &'a Session) {
105+
impl<'a, 'tcx> Metadata<'a, 'tcx> for (&'a CrateMetadata, &'tcx Session) {
108106
fn raw_bytes(self) -> &'a [u8] {
109107
self.0.raw_bytes()
110108
}
111109
fn cdata(self) -> Option<&'a CrateMetadata> {
112110
Some(self.0)
113111
}
114-
fn sess(self) -> Option<&'a Session> {
112+
fn sess(self) -> Option<&'tcx Session> {
115113
Some(&self.1)
116114
}
117115
}
@@ -136,11 +134,11 @@ impl<'a, 'tcx, T: Decodable> Lazy<T> {
136134
}
137135
}
138136

139-
impl<'a, 'tcx, T: Decodable> LazySeq<T> {
137+
impl<'a: 'x, 'tcx: 'x, 'x, T: Decodable> LazySeq<T> {
140138
pub fn decode<M: Metadata<'a, 'tcx>>(
141139
self,
142140
meta: M,
143-
) -> impl Iterator<Item = T> + Captures<'tcx> + 'a {
141+
) -> impl Iterator<Item = T> + Captures<'a> + Captures<'tcx> + 'x {
144142
let mut dcx = meta.decoder(self.position);
145143
dcx.lazy_state = LazyState::NodeStart(self.position);
146144
(0..self.len).map(move |_| T::decode(&mut dcx).unwrap())

src/librustc_mir/borrow_check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1693,7 +1693,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
16931693
fn move_path_closest_to<'a>(
16941694
&mut self,
16951695
place: &'a Place<'tcx>,
1696-
) -> Result<(&'a Place<'tcx>, MovePathIndex), NoMovePathFound> {
1696+
) -> Result<(&'a Place<'tcx>, MovePathIndex), NoMovePathFound> where 'cx: 'a {
16971697
let mut last_prefix = place;
16981698
for prefix in self.prefixes(place, PrefixSet::All) {
16991699
if let Some(mpi) = self.move_path_for_place(prefix) {

src/librustc_mir/build/matches/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1691,7 +1691,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
16911691
&mut self,
16921692
block: BasicBlock,
16931693
bindings: impl IntoIterator<Item = &'b Binding<'tcx>>,
1694-
) {
1694+
) where 'tcx: 'b {
16951695
debug!("bind_matched_candidate_for_arm_body(block={:?})", block);
16961696

16971697
let re_erased = self.hir.tcx().lifetimes.re_erased;

src/librustc_mir/dataflow/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ impl<'a, 'tcx, BD> DataflowBuilder<'a, 'tcx, BD> where BD: BitDenotation<'tcx>
297297
/// underlying flow analysis results, because it needs to handle cases
298298
/// where we are combining the results of *multiple* flow analyses
299299
/// (e.g., borrows + inits + uninits).
300-
pub(crate) trait DataflowResultsConsumer<'a, 'tcx> {
300+
pub(crate) trait DataflowResultsConsumer<'a, 'tcx: 'a> {
301301
type FlowState: FlowsAtLocation;
302302

303303
// Observation Hooks: override (at least one of) these to get analysis feedback.

src/librustc_mir/hair/pattern/_match.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,8 @@ fn all_constructors<'a, 'tcx>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
709709
fn max_slice_length<'p, 'a, 'tcx, I>(
710710
cx: &mut MatchCheckCtxt<'a, 'tcx>,
711711
patterns: I) -> u64
712-
where I: Iterator<Item=&'p Pattern<'tcx>>
712+
where I: Iterator<Item=&'p Pattern<'tcx>>,
713+
'tcx: 'p,
713714
{
714715
// The exhaustiveness-checking paper does not include any details on
715716
// checking variable-length slice patterns. However, they are matched
@@ -1709,7 +1710,7 @@ fn patterns_for_variant<'p, 'tcx>(
17091710
/// different patterns.
17101711
/// Structure patterns with a partial wild pattern (Foo { a: 42, .. }) have their missing
17111712
/// fields filled with wild patterns.
1712-
fn specialize<'p, 'a, 'tcx>(
1713+
fn specialize<'p, 'a: 'p, 'tcx>(
17131714
cx: &mut MatchCheckCtxt<'a, 'tcx>,
17141715
r: &[&'p Pattern<'tcx>],
17151716
constructor: &Constructor<'tcx>,

0 commit comments

Comments
 (0)