rust/tests/ui/impl-trait/precise-capturing/foreign-2021.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

16 lines
396 B
Rust
Raw Normal View History

//@ aux-build: foreign.rs
extern crate foreign;
fn main() {
let mut x = vec![];
let h = foreign::hello(&x);
//~^ NOTE this call may capture more lifetimes than intended
//~| NOTE immutable borrow occurs here
x.push(0);
//~^ ERROR cannot borrow `x` as mutable
//~| NOTE mutable borrow occurs here
println!("{h}");
//~^ NOTE immutable borrow later used here
}