We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 073c03b commit 12128e6Copy full SHA for 12128e6
tests/ui/codegen/sret-aliasing-rules.rs
@@ -1,3 +1,11 @@
1
+//! Check that functions with sret results don't violate aliasing rules.
2
+//!
3
+//! When `foo = func(&mut foo)` is called, the compiler must avoid creating
4
+//! two mutable references to the same variable simultaneously (one for the
5
+//! parameter and one for the hidden sret out-pointer).
6
7
+//! Regression test for <https://github.com/rust-lang/rust/pull/18250>.
8
+
9
//@ run-pass
10
11
#[derive(Copy, Clone)]
@@ -14,10 +22,7 @@ pub fn foo(f: &mut Foo) -> Foo {
14
22
}
15
23
16
24
pub fn main() {
17
- let mut f = Foo {
18
- f1: 8,
19
- _f2: 9,
20
- };
25
+ let mut f = Foo { f1: 8, _f2: 9 };
21
26
f = foo(&mut f);
27
assert_eq!(f.f1, 8);
28
0 commit comments