Skip to content

Commit 882185e

Browse files
committed
Rollup merge of #24321 - lstat:16602-needstest, r=pnkfelix
Closes #16602
2 parents 60add53 + 1175123 commit 882185e

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

src/test/run-pass/issue-16602-1.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2015 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+
fn main() {
12+
let mut t = [1; 2];
13+
t = [t[1] * 2, t[0] * 2];
14+
assert_eq!(&t[..], &[2, 2]);
15+
}

src/test/run-pass/issue-16602-2.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2015 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+
struct A {
12+
pub x: u32,
13+
pub y: u32,
14+
}
15+
16+
fn main() {
17+
let mut a = A { x: 1, y: 1 };
18+
a = A { x: a.y * 2, y: a.x * 2 };
19+
assert_eq!(a.x, 2);
20+
assert_eq!(a.y, 2);
21+
}

src/test/run-pass/issue-16602-3.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2015 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+
#[derive(Debug)]
12+
enum Foo {
13+
Bar(u32, u32),
14+
Baz(&'static u32, &'static u32)
15+
}
16+
17+
static NUM: u32 = 100;
18+
19+
fn main () {
20+
let mut b = Foo::Baz(&NUM, &NUM);
21+
b = Foo::Bar(f(&b), g(&b));
22+
}
23+
24+
static FNUM: u32 = 1;
25+
26+
fn f (b: &Foo) -> u32 {
27+
FNUM
28+
}
29+
30+
static GNUM: u32 = 2;
31+
32+
fn g (b: &Foo) -> u32 {
33+
GNUM
34+
}

0 commit comments

Comments
 (0)