Skip to content

Commit 25aca44

Browse files
authored
Rollup merge of #53349 - memoryruins:nll-tests, r=nikomatsakis
[nll] add tests for #48697 and #30104 Adds tests for the following issues: - #48697 ``[NLL] ICE: unexpected region for local data with reference to closure`` - #30104 ``Destructuring boxes into multiple mutable references seems broken`` r? @nikomatsakis
2 parents 3de02d3 + f4bed39 commit 25aca44

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed

src/test/ui/nll/issue-30104.rs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright 2018 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.
4+
//
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.
10+
11+
// Regression test for #30104
12+
13+
// compile-pass
14+
15+
#![feature(nll)]
16+
17+
use std::ops::{Deref, DerefMut};
18+
19+
fn box_two_field(v: &mut Box<(i32, i32)>) {
20+
let _a = &mut v.0;
21+
let _b = &mut v.1;
22+
}
23+
24+
fn box_destructure(v: &mut Box<(i32, i32)>) {
25+
let (ref mut _head, ref mut _tail) = **v;
26+
}
27+
28+
struct Wrap<T>(T);
29+
30+
impl<T> Deref for Wrap<T> {
31+
type Target = T;
32+
fn deref(&self) -> &T {
33+
&self.0
34+
}
35+
}
36+
37+
impl<T> DerefMut for Wrap<T> {
38+
fn deref_mut(&mut self) -> &mut T {
39+
&mut self.0
40+
}
41+
}
42+
43+
fn smart_two_field(v: &mut Wrap<(i32, i32)>) {
44+
let _a = &mut v.0;
45+
let _b = &mut v.1;
46+
}
47+
48+
fn smart_destructure(v: &mut Wrap<(i32, i32)>) {
49+
let (ref mut _head, ref mut _tail) = **v;
50+
}
51+
52+
fn main() {}

src/test/ui/nll/issue-48697.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2018 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.
4+
//
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.
10+
11+
// Regression test for #48697
12+
13+
// compile-pass
14+
15+
#![feature(nll)]
16+
17+
fn foo(x: &i32) -> &i32 {
18+
let z = 4;
19+
let f = &|y| y;
20+
let k = f(&z);
21+
f(x)
22+
}
23+
24+
fn main() {}

0 commit comments

Comments
 (0)