summaryrefslogtreecommitdiffstats
path: root/src/test/ui/traits/object/vs-lifetime.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/traits/object/vs-lifetime.rs')
-rw-r--r--src/test/ui/traits/object/vs-lifetime.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/test/ui/traits/object/vs-lifetime.rs b/src/test/ui/traits/object/vs-lifetime.rs
new file mode 100644
index 000000000..14ae67cff
--- /dev/null
+++ b/src/test/ui/traits/object/vs-lifetime.rs
@@ -0,0 +1,17 @@
+// A few contrived examples where lifetime should (or should not) be parsed as an object type.
+// Lifetimes parsed as types are still rejected later by semantic checks.
+
+struct S<'a, T>(&'a u8, T);
+
+fn main() {
+ // `'static` is a lifetime argument, `'static +` is a type argument
+ let _: S<'static, u8>;
+ let _: S<'static, dyn 'static +>;
+ //~^ at least one trait is required for an object type
+ let _: S<'static, 'static>;
+ //~^ ERROR this struct takes 1 lifetime argument but 2 lifetime arguments were supplied
+ //~| ERROR this struct takes 1 generic argument but 0 generic arguments were supplied
+ let _: S<dyn 'static +, 'static>;
+ //~^ ERROR type provided when a lifetime was expected
+ //~| ERROR at least one trait is required for an object type
+}