]> git.proxmox.com Git - rustc.git/blame - src/test/ui/nll/guarantor-issue-46974.rs
New upstream version 1.63.0+dfsg1
[rustc.git] / src / test / ui / nll / guarantor-issue-46974.rs
CommitLineData
2c00a5a8
XL
1// Test that NLL analysis propagates lifetimes correctly through
2// field accesses, Box accesses, etc.
3
2c00a5a8
XL
4fn foo(s: &mut (i32,)) -> i32 {
5 let t = &mut *s; // this borrow should last for the entire function
6 let x = &t.0;
7 *s = (2,); //~ ERROR cannot assign to `*s`
8 *x
9}
10
11fn bar(s: &Box<(i32,)>) -> &'static i32 {
12 // FIXME(#46983): error message should be better
3c0e092e 13 &s.0 //~ ERROR lifetime may not live long enough
2c00a5a8
XL
14}
15
16fn main() {
17 foo(&mut (0,));
18 bar(&Box::new((1,)));
19}