Last active
February 24, 2019 17:05
-
-
Save dlrobertson/8e487c83210a56a59a45d3368bba3147 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 208307bdf0b9c56f549f277e5f4560dc938dc55b | |
Author: Dan Robertson <[email protected]> | |
Date: Sun Feb 24 16:52:02 2019 +0000 | |
Rebase me!!!! | |
diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs | |
index 8dd662c1e0..069726bb0d 100644 | |
--- a/src/librustc/middle/resolve_lifetime.rs | |
+++ b/src/librustc/middle/resolve_lifetime.rs | |
@@ -2230,18 +2230,22 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { | |
if let hir::TyKind::BareFn(_) = ty.node { | |
self.outer_index.shift_in(1); | |
} | |
- if let hir::TyKind::TraitObject(ref bounds, ref lifetime) = ty.node { | |
- for bound in bounds { | |
- self.visit_poly_trait_ref(bound, hir::TraitBoundModifier::None); | |
- } | |
+ match ty.node { | |
+ hir::TyKind::TraitObject(ref bounds, ref lifetime) => { | |
+ for bound in bounds { | |
+ self.visit_poly_trait_ref(bound, hir::TraitBoundModifier::None); | |
+ } | |
- // Stay on the safe side and don't include the object | |
- // lifetime default (which may not end up being used). | |
- if !lifetime.is_elided() { | |
- self.visit_lifetime(lifetime); | |
+ // Stay on the safe side and don't include the object | |
+ // lifetime default (which may not end up being used). | |
+ if !lifetime.is_elided() { | |
+ self.visit_lifetime(lifetime); | |
+ } | |
+ } | |
+ hir::TyKind::CVarArgs(_) => {} | |
+ _ => { | |
+ intravisit::walk_ty(self, ty); | |
} | |
- } else { | |
- intravisit::walk_ty(self, ty); | |
} | |
if let hir::TyKind::BareFn(_) = ty.node { | |
self.outer_index.shift_out(1); | |
diff --git a/src/test/codegen/c-variadic.rs b/src/test/codegen/c-variadic.rs | |
index cc76e151b4..297070fbc7 100644 | |
--- a/src/test/codegen/c-variadic.rs | |
+++ b/src/test/codegen/c-variadic.rs | |
@@ -25,21 +25,21 @@ pub unsafe extern "C" fn use_foreign_c_variadic_simple() { | |
// Ensure that we do not remove the `va_list` passed to the foreign function when | |
// removing the "spoofed" `VaList` that is used by Rust defined C-variadics. | |
pub unsafe extern "C" fn use_foreign_c_variadic_va_list_0(ap: VaList) { | |
- // CHECK: invoke void (i64*, ...) @foreign_c_variadic_va_list({{.*}} %ap) | |
+ // CHECK: invoke void ({{.*}}*, ...) @foreign_c_variadic_va_list({{.*}} %ap) | |
foreign_c_variadic_va_list(ap); | |
} | |
pub unsafe extern "C" fn use_foreign_c_variadic_va_list_1(ap: VaList) { | |
- // CHECK: invoke void (i64*, ...) @foreign_c_variadic_va_list({{.*}} %ap, i32 42) | |
+ // CHECK: invoke void ({{.*}}*, ...) @foreign_c_variadic_va_list({{.*}} %ap, i32 42) | |
foreign_c_variadic_va_list(ap, 42i32); | |
} | |
pub unsafe extern "C" fn use_foreign_c_variadic_va_list_2(ap: VaList) { | |
- // CHECK: invoke void (i64*, ...) @foreign_c_variadic_va_list({{.*}} %ap, i32 2, i32 42) | |
+ // CHECK: invoke void ({{.*}}*, ...) @foreign_c_variadic_va_list({{.*}} %ap, i32 2, i32 42) | |
foreign_c_variadic_va_list(ap, 2i32, 42i32); | |
} | |
pub unsafe extern "C" fn use_foreign_c_variadic_va_list_3(ap: VaList) { | |
- // CHECK: invoke void (i64*, ...) @foreign_c_variadic_va_list({{.*}} %ap, i32 2, i32 42, i32 0) | |
+ // CHECK: invoke void ({{.*}}*, ...) @foreign_c_variadic_va_list({{.*}} %ap, i32 2, i32 42, i32 0) | |
foreign_c_variadic_va_list(ap, 2i32, 42i32, 0i32); | |
} | |
diff --git a/src/test/ui/c-variadic/variadic-ffi-6.rs b/src/test/ui/c-variadic/variadic-ffi-6.rs | |
new file mode 100644 | |
index 0000000000..7664c23fe0 | |
--- /dev/null | |
+++ b/src/test/ui/c-variadic/variadic-ffi-6.rs | |
@@ -0,0 +1,9 @@ | |
+#![crate_type="lib"] | |
+ | |
+pub unsafe extern "C" fn use_vararg_lifetime(x: usize, y: ...) -> &usize { //~ ERROR missing lifetime specifier | |
+ &0 | |
+} | |
+ | |
+pub unsafe extern "C" fn use_normal_arg_lifetime(x: &usize, y: ...) -> &usize { // OK | |
+ x | |
+} | |
diff --git a/src/test/ui/c-variadic/variadic-ffi-6.stderr b/src/test/ui/c-variadic/variadic-ffi-6.stderr | |
new file mode 100644 | |
index 0000000000..b09f9edc89 | |
--- /dev/null | |
+++ b/src/test/ui/c-variadic/variadic-ffi-6.stderr | |
@@ -0,0 +1,11 @@ | |
+error[E0106]: missing lifetime specifier | |
+ --> $DIR/variadic-ffi-6.rs:3:67 | |
+ | | |
+LL | pub unsafe extern "C" fn use_vararg_lifetime(x: usize, y: ...) -> &usize { //~ ERROR missing lifetime specifier | |
+ | ^ help: consider giving it an explicit bounded or 'static lifetime: `&'static` | |
+ | | |
+ = help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments | |
+ | |
+error: aborting due to previous error | |
+ | |
+For more information about this error, try `rustc --explain E0106`. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment