rustc: don't store a lifetime in hir::TyKind::CVarArgs.

This commit is contained in:
Eduard-Mihai Burtescu 2019-08-11 18:34:31 +03:00
parent 8a9d775888
commit 7683d1c3aa
8 changed files with 18 additions and 30 deletions

View File

@ -633,9 +633,7 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) {
TyKind::Typeof(ref expression) => {
visitor.visit_anon_const(expression)
}
TyKind::CVarArgs(ref lt) => {
visitor.visit_lifetime(lt)
}
TyKind::CVarArgs |
TyKind::Infer | TyKind::Err => {}
}
}

View File

@ -1336,12 +1336,7 @@ impl<'a> LoweringContext<'a> {
}
}
TyKind::Mac(_) => bug!("`TyMac` should have been expanded by now"),
TyKind::CVarArgs => {
// Create the implicit lifetime of the "spoofed" `VaListImpl`.
let span = self.sess.source_map().next_point(t.span.shrink_to_lo());
let lt = self.new_implicit_lifetime(span);
hir::TyKind::CVarArgs(lt)
},
TyKind::CVarArgs => hir::TyKind::CVarArgs,
};
hir::Ty {

View File

@ -2018,7 +2018,7 @@ pub enum TyKind {
Err,
/// Placeholder for C-variadic arguments. We "spoof" the `VaListImpl` created
/// from the variadic arguments. This type is only valid up to typeck.
CVarArgs(Lifetime),
CVarArgs,
}
#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Debug, HashStable)]

View File

@ -361,7 +361,7 @@ impl<'a> State<'a> {
self.s.word("/*ERROR*/");
self.pclose();
}
hir::TyKind::CVarArgs(_) => {
hir::TyKind::CVarArgs => {
self.s.word("...");
}
}

View File

@ -764,13 +764,6 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
});
}
}
hir::TyKind::CVarArgs(ref lt) => {
// Resolve the generated lifetime for the C-variadic arguments.
// The lifetime is generated in AST -> HIR lowering.
if lt.name.is_elided() {
self.resolve_elided_lifetimes(vec![lt])
}
}
_ => intravisit::walk_ty(self, ty),
}
}
@ -2378,7 +2371,6 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
self.visit_lifetime(lifetime);
}
}
hir::TyKind::CVarArgs(_) => {}
_ => {
intravisit::walk_ty(self, ty);
}

View File

@ -2148,13 +2148,16 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
// handled specially and will not descend into this routine.
self.ty_infer(None, ast_ty.span)
}
hir::TyKind::CVarArgs(lt) => {
hir::TyKind::CVarArgs => {
let va_list_did = match tcx.lang_items().va_list() {
Some(did) => did,
None => span_bug!(ast_ty.span,
"`va_list` lang item required for variadics"),
};
let region = self.ast_region_to_region(&lt, None);
// FIXME(eddyb) compute this in the body and don't let it reach the signature.
// HACK(eddyb) the `123` anon index is only temporary, to keep tests passing.
// Ideally this would use `ReScope` or similar.
let region = tcx.mk_region(ty::ReLateBound(ty::INNERMOST, ty::BrAnon(123)));
tcx.type_of(va_list_did).subst(tcx, &[region.into()])
}
hir::TyKind::Err => {

View File

@ -3032,7 +3032,7 @@ impl Clean<Type> for hir::Ty {
TyKind::BareFn(ref barefn) => BareFunction(box barefn.clean(cx)),
TyKind::Infer | TyKind::Err => Infer,
TyKind::Typeof(..) => panic!("unimplemented type {:?}", self.kind),
TyKind::CVarArgs(_) => CVarArgs,
TyKind::CVarArgs => CVarArgs,
}
}
}

View File

@ -47,7 +47,7 @@ LL | *ap0 = ap1;
|
= note: expected type `core::ffi::VaListImpl<'_>`
found type `core::ffi::VaListImpl<'_>`
note: the anonymous lifetime #3 defined on the function body at 19:1...
note: the anonymous lifetime #124 defined on the function body at 19:1...
--> $DIR/variadic-ffi-4.rs:19:1
|
LL | / pub unsafe extern "C" fn no_escape3(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {
@ -80,7 +80,7 @@ LL | | *ap0 = ap1;
LL | |
LL | | }
| |_^
note: ...does not necessarily outlive the anonymous lifetime #3 defined on the function body at 19:1
note: ...does not necessarily outlive the anonymous lifetime #124 defined on the function body at 19:1
--> $DIR/variadic-ffi-4.rs:19:1
|
LL | / pub unsafe extern "C" fn no_escape3(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {
@ -106,7 +106,7 @@ LL | |
LL | |
LL | | }
| |_^
note: but the borrow lasts for the anonymous lifetime #3 defined on the function body at 24:1
note: but the borrow lasts for the anonymous lifetime #124 defined on the function body at 24:1
--> $DIR/variadic-ffi-4.rs:24:1
|
LL | / pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaListImpl, mut ap1: ...) {
@ -126,7 +126,7 @@ LL | ap0 = &mut ap1;
|
= note: expected type `&mut core::ffi::VaListImpl<'_>`
found type `&mut core::ffi::VaListImpl<'_>`
note: the anonymous lifetime #3 defined on the function body at 24:1...
note: the anonymous lifetime #124 defined on the function body at 24:1...
--> $DIR/variadic-ffi-4.rs:24:1
|
LL | / pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaListImpl, mut ap1: ...) {
@ -168,7 +168,7 @@ LL | |
LL | |
LL | | }
| |_^
note: ...does not necessarily outlive the anonymous lifetime #3 defined on the function body at 24:1
note: ...does not necessarily outlive the anonymous lifetime #124 defined on the function body at 24:1
--> $DIR/variadic-ffi-4.rs:24:1
|
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
LL | ap0 = &mut ap1;
| ^^^^^^^^
|
note: first, the lifetime cannot outlive the anonymous lifetime #3 defined on the function body at 24:1...
note: first, the lifetime cannot outlive the anonymous lifetime #124 defined on the function body at 24:1...
--> $DIR/variadic-ffi-4.rs:24:1
|
LL | / pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaListImpl, mut ap1: ...) {
@ -227,7 +227,7 @@ LL | *ap0 = ap1.clone();
|
= note: expected type `core::ffi::VaListImpl<'_>`
found type `core::ffi::VaListImpl<'_>`
note: the anonymous lifetime #3 defined on the function body at 32:1...
note: the anonymous lifetime #124 defined on the function body at 32:1...
--> $DIR/variadic-ffi-4.rs:32:1
|
LL | / pub unsafe extern "C" fn no_escape5(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {
@ -260,7 +260,7 @@ LL | | *ap0 = ap1.clone();
LL | |
LL | | }
| |_^
note: ...does not necessarily outlive the anonymous lifetime #3 defined on the function body at 32:1
note: ...does not necessarily outlive the anonymous lifetime #124 defined on the function body at 32:1
--> $DIR/variadic-ffi-4.rs:32:1
|
LL | / pub unsafe extern "C" fn no_escape5(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {