]> git.proxmox.com Git - rustc.git/blame - src/test/ui/borrowck/borrowck-migrate-to-nll.rs
New upstream version 1.38.0+dfsg1
[rustc.git] / src / test / ui / borrowck / borrowck-migrate-to-nll.rs
CommitLineData
416331ca 1// This is a test of the borrowck migrate mode. It leverages #38899, a
8faf50e0
XL
2// bug that is fixed by NLL: this code is (unsoundly) accepted by
3// AST-borrowck, but is correctly rejected by the NLL borrowck.
4//
5// Therefore, for backwards-compatiblity, under borrowck=migrate the
6// NLL checks will be emitted as *warnings*.
7
8// NLL mode makes this compile-fail; we cannot currently encode a
9// test that is run-pass or compile-fail based on compare-mode. So
10// just ignore it instead:
11
12// ignore-compare-mode-nll
416331ca 13// ignore-compare-mode-polonius
8faf50e0
XL
14
15// revisions: zflag edition
16//[zflag]compile-flags: -Z borrowck=migrate
b7449926 17//[edition]edition:2018
8faf50e0
XL
18//[zflag] run-pass
19//[edition] run-pass
20
416331ca
XL
21pub struct Block<'a> {
22 current: &'a u8,
23 unrelated: &'a u8,
8faf50e0 24}
416331ca
XL
25
26fn bump<'a>(mut block: &mut Block<'a>) {
27 let x = &mut block;
28 let p: &'a u8 = &*block.current;
29 // (use `x` and `p` so enabling NLL doesn't assign overly short lifetimes)
30 drop(x);
31 drop(p);
32}
33
34fn main() {}