]> git.proxmox.com Git - rustc.git/blame - src/test/compile-fail/trait-object-vs-lifetime.rs
New upstream version 1.29.0+dfsg1
[rustc.git] / src / test / compile-fail / trait-object-vs-lifetime.rs
CommitLineData
7cac9316
XL
1// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
11// A few contrived examples where lifetime should (or should not) be parsed as an object type.
12// Lifetimes parsed as types are still rejected later by semantic checks.
13
14// compile-flags: -Z continue-parse-after-error
15
16struct S<'a, T>(&'a u8, T);
17
18fn main() {
19 // `'static` is a lifetime argument, `'static +` is a type argument
20 let _: S<'static, u8>;
21 let _: S<'static, 'static +>;
22 //~^ at least one non-builtin trait is required for an object type
23 let _: S<'static, 'static>;
24 //~^ ERROR wrong number of lifetime parameters: expected 1, found 2
25 //~| ERROR wrong number of type arguments: expected 1, found 0
26 let _: S<'static +, 'static>;
27 //~^ ERROR lifetime parameters must be declared prior to type parameters
28 //~| ERROR at least one non-builtin trait is required for an object type
29}