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 4c4fc75

Browse files
committedJun 18, 2019
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>,

‎src/librustc_mir/interpret/visitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Value<'mir, 'tcx, M> for MPlaceTy<'tcx,
122122
macro_rules! make_value_visitor {
123123
($visitor_trait_name:ident, $($mutability:ident)?) => {
124124
// How to traverse a value and what to do when we are at the leaves.
125-
pub trait $visitor_trait_name<'mir, 'tcx, M: Machine<'mir, 'tcx>>: Sized {
125+
pub trait $visitor_trait_name<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>>: Sized {
126126
type V: Value<'mir, 'tcx, M>;
127127

128128
/// The visitor must have an `InterpretCx` in it.

‎src/librustc_mir/monomorphize/partitioning.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -766,9 +766,10 @@ fn numbered_codegen_unit_name(
766766
name_builder.build_cgu_name_no_mangle(LOCAL_CRATE, &["cgu"], Some(index))
767767
}
768768

769-
fn debug_dump<'a, 'b, 'tcx, I>(tcx: TyCtxt<'tcx>, label: &str, cgus: I)
769+
fn debug_dump<'a, 'tcx, I>(tcx: TyCtxt<'tcx>, label: &str, cgus: I)
770770
where
771-
I: Iterator<Item = &'b CodegenUnit<'tcx>>,
771+
I: Iterator<Item = &'a CodegenUnit<'tcx>>,
772+
'tcx: 'a,
772773
{
773774
if cfg!(debug_assertions) {
774775
debug!("{}", label);
@@ -796,6 +797,7 @@ where
796797
fn assert_symbols_are_distinct<'a, 'tcx, I>(tcx: TyCtxt<'tcx>, mono_items: I)
797798
where
798799
I: Iterator<Item = &'a MonoItem<'tcx>>,
800+
'tcx: 'a,
799801
{
800802
let mut symbols: Vec<_> = mono_items.map(|mono_item| {
801803
(mono_item, mono_item.symbol_name(tcx))

‎src/librustc_mir/util/elaborate_drops.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ pub fn elaborate_drop<'b, 'tcx, D>(
111111
succ: BasicBlock,
112112
unwind: Unwind,
113113
bb: BasicBlock)
114-
where D: DropElaborator<'b, 'tcx>
114+
where D: DropElaborator<'b, 'tcx>,
115+
'tcx: 'b,
115116
{
116117
DropCtxt {
117118
elaborator, source_info, place, path, succ, unwind
@@ -121,6 +122,7 @@ pub fn elaborate_drop<'b, 'tcx, D>(
121122
impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D>
122123
where
123124
D: DropElaborator<'b, 'tcx>,
125+
'tcx: 'b,
124126
{
125127
fn place_ty(&self, place: &Place<'tcx>) -> Ty<'tcx> {
126128
place.ty(self.elaborator.body(), self.tcx()).ty

‎src/librustc_save_analysis/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -960,8 +960,8 @@ impl<'l> PathCollector<'l> {
960960
}
961961
}
962962

963-
impl<'l, 'a> Visitor<'a> for PathCollector<'l> {
964-
fn visit_pat(&mut self, p: &'a ast::Pat) {
963+
impl<'l> Visitor<'l> for PathCollector<'l> {
964+
fn visit_pat(&mut self, p: &'l ast::Pat) {
965965
match p.node {
966966
PatKind::Struct(ref path, ..) => {
967967
self.collected_paths.push((p.id, path));

‎src/librustc_typeck/collect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1786,7 +1786,7 @@ fn impl_polarity<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> hir::ImplPolarity {
17861786
/// the lifetimes that are declared. For fns or methods, we have to
17871787
/// screen out those that do not appear in any where-clauses etc using
17881788
/// `resolve_lifetime::early_bound_lifetimes`.
1789-
fn early_bound_lifetimes_from_generics<'a, 'tcx>(
1789+
fn early_bound_lifetimes_from_generics<'a, 'tcx: 'a>(
17901790
tcx: TyCtxt<'tcx>,
17911791
generics: &'a hir::Generics,
17921792
) -> impl Iterator<Item = &'a hir::GenericParam> + Captures<'tcx> {

0 commit comments

Comments
 (0)
Please sign in to comment.