rust/tests/ui/suggestions/issue-84973-negative.rs
2023-01-11 09:32:08 +00:00

13 lines
335 B
Rust

// Checks that we only suggest borrowing if &T actually implements the trait.
trait Tr {}
impl Tr for &f32 {}
fn bar<T: Tr>(t: T) {}
fn main() {
let a = 0i32;
let b = 0.0f32;
bar(a); //~ ERROR: the trait bound `i32: Tr` is not satisfied [E0277]
bar(b); //~ ERROR: the trait bound `f32: Tr` is not satisfied [E0277]
}