rust/tests/ui/dyn-compatibility/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

140 lines
3.1 KiB
Rust
Raw Normal View History

2024-07-13 10:49:14 -05:00
//@ edition:2021
trait Trait {}
struct IceCream;
impl IceCream {
fn foo(_: &Trait) {}
//~^ ERROR: expected a type, found a trait
2024-07-13 10:49:14 -05:00
fn bar(self, _: &'a Trait) {}
//~^ ERROR: expected a type, found a trait
2024-07-13 10:49:14 -05:00
//~| ERROR: use of undeclared lifetime name
fn alice<'a>(&self, _: &Trait) {}
//~^ ERROR: expected a type, found a trait
2024-07-13 10:49:14 -05:00
fn bob<'a>(_: &'a Trait) {}
//~^ ERROR: expected a type, found a trait
2024-07-13 10:49:14 -05:00
fn cat() -> &Trait {
//~^ ERROR: missing lifetime specifier
//~| ERROR: expected a type, found a trait
2024-07-13 10:49:14 -05:00
&Type
}
fn dog<'a>() -> &Trait {
//~^ ERROR: missing lifetime specifier
//~| ERROR: expected a type, found a trait
2024-07-13 10:49:14 -05:00
&Type
}
fn kitten() -> &'a Trait {
//~^ ERROR: use of undeclared lifetime name
//~| ERROR: expected a type, found a trait
2024-07-13 10:49:14 -05:00
&Type
}
fn puppy<'a>() -> &'a Trait {
//~^ ERROR: expected a type, found a trait
2024-07-13 10:49:14 -05:00
&Type
}
fn parrot() -> &mut Trait {
//~^ ERROR: missing lifetime specifier
//~| ERROR: expected a type, found a trait
2024-07-13 10:49:14 -05:00
&mut Type
}
}
trait Sing {
fn foo(_: &Trait);
//~^ ERROR: expected a type, found a trait
2024-07-13 10:49:14 -05:00
fn bar(_: &'a Trait);
//~^ ERROR: expected a type, found a trait
2024-07-13 10:49:14 -05:00
//~| ERROR: use of undeclared lifetime name
fn alice<'a>(_: &Trait);
//~^ ERROR: expected a type, found a trait
2024-07-13 10:49:14 -05:00
fn bob<'a>(_: &'a Trait);
//~^ ERROR: expected a type, found a trait
2024-07-13 10:49:14 -05:00
fn cat() -> &Trait;
//~^ ERROR: missing lifetime specifier
//~| ERROR: expected a type, found a trait
2024-07-13 10:49:14 -05:00
fn dog<'a>() -> &Trait {
//~^ ERROR: missing lifetime specifier
//~| ERROR: expected a type, found a trait
2024-07-13 10:49:14 -05:00
&Type
}
fn kitten() -> &'a Trait {
//~^ ERROR: use of undeclared lifetime name
//~| ERROR: expected a type, found a trait
2024-07-13 10:49:14 -05:00
&Type
}
fn puppy<'a>() -> &'a Trait {
//~^ ERROR: expected a type, found a trait
2024-07-13 10:49:14 -05:00
&Type
}
fn parrot() -> &mut Trait {
//~^ ERROR: missing lifetime specifier
//~| ERROR: expected a type, found a trait
2024-07-13 10:49:14 -05:00
&mut Type
}
}
2024-07-13 10:49:14 -05:00
fn foo(_: &Trait) {}
//~^ ERROR: expected a type, found a trait
2024-07-13 10:49:14 -05:00
fn bar(_: &'a Trait) {}
//~^ ERROR: expected a type, found a trait
2024-07-13 10:49:14 -05:00
//~| ERROR: use of undeclared lifetime name
fn alice<'a>(_: &Trait) {}
//~^ ERROR: expected a type, found a trait
2024-07-13 10:49:14 -05:00
fn bob<'a>(_: &'a Trait) {}
//~^ ERROR: expected a type, found a trait
2024-07-13 10:49:14 -05:00
struct Type;
impl Trait for Type {}
fn cat() -> &Trait {
//~^ ERROR: missing lifetime specifier
//~| ERROR: expected a type, found a trait
2024-07-13 10:49:14 -05:00
&Type
}
fn dog<'a>() -> &Trait {
//~^ ERROR: missing lifetime specifier
//~| ERROR: expected a type, found a trait
2024-07-13 10:49:14 -05:00
&Type
}
fn kitten() -> &'a Trait {
//~^ ERROR: use of undeclared lifetime name
//~| ERROR: expected a type, found a trait
2024-07-13 10:49:14 -05:00
&Type
}
fn puppy<'a>() -> &'a Trait {
//~^ ERROR: expected a type, found a trait
2024-07-13 10:49:14 -05:00
&Type
}
fn parrot() -> &mut Trait {
//~^ ERROR: missing lifetime specifier
//~| ERROR: expected a type, found a trait
2024-07-13 10:49:14 -05:00
&mut Type
}
fn main() {}