Skip to content

Commit 8522997

Browse files
committed
rustc: don't store a lifetime in hir::TyKind::CVarArgs.
1 parent 1154374 commit 8522997

File tree

8 files changed

+18
-30
lines changed

8 files changed

+18
-30
lines changed

src/librustc/hir/intravisit.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -633,9 +633,7 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) {
633633
TyKind::Typeof(ref expression) => {
634634
visitor.visit_anon_const(expression)
635635
}
636-
TyKind::CVarArgs(ref lt) => {
637-
visitor.visit_lifetime(lt)
638-
}
636+
TyKind::CVarArgs |
639637
TyKind::Infer | TyKind::Err => {}
640638
}
641639
}

src/librustc/hir/lowering.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,12 +1336,7 @@ impl<'a> LoweringContext<'a> {
13361336
}
13371337
}
13381338
TyKind::Mac(_) => bug!("`TyMac` should have been expanded by now"),
1339-
TyKind::CVarArgs => {
1340-
// Create the implicit lifetime of the "spoofed" `VaListImpl`.
1341-
let span = self.sess.source_map().next_point(t.span.shrink_to_lo());
1342-
let lt = self.new_implicit_lifetime(span);
1343-
hir::TyKind::CVarArgs(lt)
1344-
},
1339+
TyKind::CVarArgs => hir::TyKind::CVarArgs,
13451340
};
13461341

13471342
hir::Ty {

src/librustc/hir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2029,7 +2029,7 @@ pub enum TyKind {
20292029
Err,
20302030
/// Placeholder for C-variadic arguments. We "spoof" the `VaListImpl` created
20312031
/// from the variadic arguments. This type is only valid up to typeck.
2032-
CVarArgs(Lifetime),
2032+
CVarArgs,
20332033
}
20342034

20352035
#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Debug, HashStable)]

src/librustc/hir/print.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ impl<'a> State<'a> {
361361
self.s.word("/*ERROR*/");
362362
self.pclose();
363363
}
364-
hir::TyKind::CVarArgs(_) => {
364+
hir::TyKind::CVarArgs => {
365365
self.s.word("...");
366366
}
367367
}

src/librustc/middle/resolve_lifetime.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -764,13 +764,6 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
764764
});
765765
}
766766
}
767-
hir::TyKind::CVarArgs(ref lt) => {
768-
// Resolve the generated lifetime for the C-variadic arguments.
769-
// The lifetime is generated in AST -> HIR lowering.
770-
if lt.name.is_elided() {
771-
self.resolve_elided_lifetimes(vec![lt])
772-
}
773-
}
774767
_ => intravisit::walk_ty(self, ty),
775768
}
776769
}
@@ -2378,7 +2371,6 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
23782371
self.visit_lifetime(lifetime);
23792372
}
23802373
}
2381-
hir::TyKind::CVarArgs(_) => {}
23822374
_ => {
23832375
intravisit::walk_ty(self, ty);
23842376
}

src/librustc_typeck/astconv.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2151,13 +2151,16 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
21512151
// handled specially and will not descend into this routine.
21522152
self.ty_infer(None, ast_ty.span)
21532153
}
2154-
hir::TyKind::CVarArgs(lt) => {
2154+
hir::TyKind::CVarArgs => {
21552155
let va_list_did = match tcx.lang_items().va_list() {
21562156
Some(did) => did,
21572157
None => span_bug!(ast_ty.span,
21582158
"`va_list` lang item required for variadics"),
21592159
};
2160-
let region = self.ast_region_to_region(&lt, None);
2160+
// FIXME(eddyb) compute this in the body and don't let it reach the signature.
2161+
// HACK(eddyb) the `123` anon index is only temporary, to keep tests passing.
2162+
// Ideally this would use `ReScope` or similar.
2163+
let region = tcx.mk_region(ty::ReLateBound(ty::INNERMOST, ty::BrAnon(123)));
21612164
tcx.type_of(va_list_did).subst(tcx, &[region.into()])
21622165
}
21632166
hir::TyKind::Err => {

src/librustdoc/clean/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3032,7 +3032,7 @@ impl Clean<Type> for hir::Ty {
30323032
TyKind::BareFn(ref barefn) => BareFunction(box barefn.clean(cx)),
30333033
TyKind::Infer | TyKind::Err => Infer,
30343034
TyKind::Typeof(..) => panic!("unimplemented type {:?}", self.kind),
3035-
TyKind::CVarArgs(_) => CVarArgs,
3035+
TyKind::CVarArgs => CVarArgs,
30363036
}
30373037
}
30383038
}

src/test/ui/c-variadic/variadic-ffi-4.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ LL | *ap0 = ap1;
4747
|
4848
= note: expected type `core::ffi::VaListImpl<'_>`
4949
found type `core::ffi::VaListImpl<'_>`
50-
note: the anonymous lifetime #3 defined on the function body at 19:1...
50+
note: the anonymous lifetime #124 defined on the function body at 19:1...
5151
--> $DIR/variadic-ffi-4.rs:19:1
5252
|
5353
LL | / pub unsafe extern "C" fn no_escape3(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {
@@ -80,7 +80,7 @@ LL | | *ap0 = ap1;
8080
LL | |
8181
LL | | }
8282
| |_^
83-
note: ...does not necessarily outlive the anonymous lifetime #3 defined on the function body at 19:1
83+
note: ...does not necessarily outlive the anonymous lifetime #124 defined on the function body at 19:1
8484
--> $DIR/variadic-ffi-4.rs:19:1
8585
|
8686
LL | / pub unsafe extern "C" fn no_escape3(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {
@@ -106,7 +106,7 @@ LL | |
106106
LL | |
107107
LL | | }
108108
| |_^
109-
note: but the borrow lasts for the anonymous lifetime #3 defined on the function body at 24:1
109+
note: but the borrow lasts for the anonymous lifetime #124 defined on the function body at 24:1
110110
--> $DIR/variadic-ffi-4.rs:24:1
111111
|
112112
LL | / pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaListImpl, mut ap1: ...) {
@@ -126,7 +126,7 @@ LL | ap0 = &mut ap1;
126126
|
127127
= note: expected type `&mut core::ffi::VaListImpl<'_>`
128128
found type `&mut core::ffi::VaListImpl<'_>`
129-
note: the anonymous lifetime #3 defined on the function body at 24:1...
129+
note: the anonymous lifetime #124 defined on the function body at 24:1...
130130
--> $DIR/variadic-ffi-4.rs:24:1
131131
|
132132
LL | / pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaListImpl, mut ap1: ...) {
@@ -168,7 +168,7 @@ LL | |
168168
LL | |
169169
LL | | }
170170
| |_^
171-
note: ...does not necessarily outlive the anonymous lifetime #3 defined on the function body at 24:1
171+
note: ...does not necessarily outlive the anonymous lifetime #124 defined on the function body at 24:1
172172
--> $DIR/variadic-ffi-4.rs:24:1
173173
|
174174
LL | / pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaListImpl, mut ap1: ...) {
@@ -186,7 +186,7 @@ error[E0495]: cannot infer an appropriate lifetime for borrow expression due to
186186
LL | ap0 = &mut ap1;
187187
| ^^^^^^^^
188188
|
189-
note: first, the lifetime cannot outlive the anonymous lifetime #3 defined on the function body at 24:1...
189+
note: first, the lifetime cannot outlive the anonymous lifetime #124 defined on the function body at 24:1...
190190
--> $DIR/variadic-ffi-4.rs:24:1
191191
|
192192
LL | / pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaListImpl, mut ap1: ...) {
@@ -227,7 +227,7 @@ LL | *ap0 = ap1.clone();
227227
|
228228
= note: expected type `core::ffi::VaListImpl<'_>`
229229
found type `core::ffi::VaListImpl<'_>`
230-
note: the anonymous lifetime #3 defined on the function body at 32:1...
230+
note: the anonymous lifetime #124 defined on the function body at 32:1...
231231
--> $DIR/variadic-ffi-4.rs:32:1
232232
|
233233
LL | / pub unsafe extern "C" fn no_escape5(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {
@@ -260,7 +260,7 @@ LL | | *ap0 = ap1.clone();
260260
LL | |
261261
LL | | }
262262
| |_^
263-
note: ...does not necessarily outlive the anonymous lifetime #3 defined on the function body at 32:1
263+
note: ...does not necessarily outlive the anonymous lifetime #124 defined on the function body at 32:1
264264
--> $DIR/variadic-ffi-4.rs:32:1
265265
|
266266
LL | / pub unsafe extern "C" fn no_escape5(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {

0 commit comments

Comments
 (0)