Skip to content

Commit f7bde94

Browse files
committed
Auto merge of #29284 - apasel422:tests, r=alexcrichton
Closes #22781. Closes #23891. Closes #24956. Closes #25145. Closes #25693. Closes #26095. Closes #26459. Closes #27320. Closes #27895.
2 parents 2a41821 + 671602c commit f7bde94

File tree

9 files changed

+203
-0
lines changed

9 files changed

+203
-0
lines changed

src/test/compile-fail/issue-25145.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
#![feature(associated_consts)]
12+
13+
struct S;
14+
15+
impl S {
16+
const N: usize = 3;
17+
}
18+
19+
static STUFF: [u8; S::N] = [0; S::N];
20+
//~^ ERROR array length constant evaluation error: unresolved path in constant expression
21+
22+
fn main() {}

src/test/compile-fail/issue-26459.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
match 'a' {
13+
char{ch} => true
14+
//~^ ERROR `char` does not name a struct or a struct variant
15+
};
16+
}

src/test/compile-fail/issue-27895.rs

+21
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+
fn main() {
12+
let i = 5;
13+
let index = 6;
14+
15+
match i {
16+
0...index => println!("winner"),
17+
//~^ ERROR paths in constants may only refer to constants or functions
18+
//~| ERROR non-constant path in constant expression
19+
_ => println!("hello"),
20+
}
21+
}

src/test/run-pass/issue-22781.rs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
use std::collections::HashMap;
12+
use std::collections::hash_map::Entry::Vacant;
13+
14+
pub fn foo() {
15+
type F = Box<Fn(&()) + 'static>;
16+
let mut map: HashMap<(), F> = HashMap::new();
17+
let x: &mut F = match map.entry(()) {
18+
Vacant(_) => unimplemented!(),
19+
_ => unimplemented!()
20+
};
21+
}
22+
23+
fn main() {}

src/test/run-pass/issue-23891.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
macro_rules! id {
12+
($s: pat) => ($s);
13+
}
14+
15+
fn main() {
16+
match (Some(123), Some(456)) {
17+
(id!(Some(a)), _) | (_, id!(Some(a))) => println!("{}", a),
18+
_ => (),
19+
}
20+
}

src/test/run-pass/issue-24956.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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 Foo(bool);
12+
const NEW_FALSE: bool = false;
13+
const STATIC_FOO: Foo = Foo(NEW_FALSE);
14+
15+
pub fn main() {
16+
match (Foo(false)) {
17+
STATIC_FOO => 3,
18+
_ => 11
19+
};
20+
}

src/test/run-pass/issue-25693.rs

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
pub trait Paramters { type SelfRef; }
12+
13+
struct RP<'a> { _marker: std::marker::PhantomData<&'a ()> }
14+
struct BP;
15+
16+
impl<'a> Paramters for RP<'a> { type SelfRef = &'a X<RP<'a>>; }
17+
impl Paramters for BP { type SelfRef = Box<X<BP>>; }
18+
19+
pub struct Y;
20+
pub enum X<P: Paramters> {
21+
Nothing,
22+
SameAgain(P::SelfRef, Y)
23+
}
24+
25+
fn main() {
26+
let bnil: Box<X<BP>> = Box::new(X::Nothing);
27+
let bx: Box<X<BP>> = Box::new(X::SameAgain(bnil, Y));
28+
let rnil: X<RP> = X::Nothing;
29+
let rx: X<RP> = X::SameAgain(&rnil, Y);
30+
}

src/test/run-pass/issue-26095.rs

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
#![feature(associated_consts)]
12+
13+
trait HasNumber<T> {
14+
const Number: usize;
15+
}
16+
17+
enum One {}
18+
enum Two {}
19+
20+
enum Foo {}
21+
22+
impl<T> HasNumber<T> for One {
23+
const Number: usize = 1;
24+
}
25+
26+
impl<T> HasNumber<T> for Two {
27+
const Number: usize = 2;
28+
}
29+
30+
fn main() {}

src/test/run-pass/issue-27320.rs

+21
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+
macro_rules! piece(
12+
($piece:pat) => ($piece);
13+
);
14+
15+
enum Piece {A, B}
16+
17+
fn main() {
18+
match Piece::A {
19+
piece!(pt@ Piece::A) | piece!(pt@ Piece::B) => {}
20+
}
21+
}

0 commit comments

Comments
 (0)