]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/nll/get_default.rs
1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // Basic test for free regions in the NLL code. This test ought to
12 // report an error due to a reborrowing constraint. Right now, we get
13 // a variety of errors from the older, AST-based machinery (notably
14 // borrowck), and then we get the NLL error at the end.
16 // compile-flags:-Zborrowck=compare
22 fn get(&self) -> Option
<&String
> { None }
23 fn set(&mut self, v
: String
) { }
26 fn ok(map
: &mut Map
) -> &String
{
33 map
.set(String
::new()); // Ideally, this would not error.
34 //~^ ERROR borrowed as immutable (Ast)
35 //~| ERROR borrowed as immutable (Mir)
41 fn err(map
: &mut Map
) -> &String
{
45 map
.set(String
::new()); // Both AST and MIR error here
46 //~^ ERROR borrowed as immutable (Mir)
47 //~| ERROR borrowed as immutable (Ast)
51 map
.set(String
::new()); // Ideally, just AST would error here
52 //~^ ERROR borrowed as immutable (Ast)
53 //~| ERROR borrowed as immutable (Mir)