]> git.lizzy.rs Git - rust.git/blob - tests/ui/consts/issue-66345.rs
Rollup merge of #107004 - compiler-errors:new-solver-new-candidates-2, r=lcnr
[rust.git] / tests / ui / consts / issue-66345.rs
1 // run-pass
2 // compile-flags: -Z mir-opt-level=4
3
4 // Checks that the compiler does not ICE when passing references to field of by-value struct
5 // with -Z mir-opt-level=4
6
7 fn do_nothing(_: &()) {}
8
9 pub struct Foo {
10     bar: (),
11 }
12
13 pub fn by_value_1(foo: Foo) {
14     do_nothing(&foo.bar);
15 }
16
17 pub fn by_value_2<T>(foo: Foo) {
18     do_nothing(&foo.bar);
19 }
20
21 fn main() {
22     by_value_1(Foo { bar: () });
23     by_value_2::<()>(Foo { bar: () });
24 }