blob: 42468478ed9a24214ccbad6f3986a054b14dae79 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
// Checks whether borrowing is suggested when a trait bound is not satisfied
// for found type `T`, but is for `&/&mut T`.
fn main() {
let f = Fancy{};
let o = Other::new(f);
//~^ ERROR: the trait bound `Fancy: SomeTrait` is not satisfied [E0277]
}
struct Fancy {}
impl <'a> SomeTrait for &'a Fancy {
}
trait SomeTrait {}
struct Other<'a, G> {
a: &'a str,
g: G,
}
// Broadly copied from https://docs.rs/petgraph/0.5.1/src/petgraph/dot.rs.html#70
impl<'a, G> Other<'a, G>
where
G: SomeTrait,
{
pub fn new(g: G) -> Self {
Other {
a: "hi",
g: g,
}
}
}
|