Skip to content

Commit eaa5bf3

Browse files
committed
Auto merge of #28299 - apasel422:tests, r=alexcrichton
Closes #17001 Closes #21449 Closes #22992 Closes #23208 Closes #23442
2 parents 5d9dc1d + 04fff50 commit eaa5bf3

File tree

6 files changed

+208
-0
lines changed

6 files changed

+208
-0
lines changed

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

+15
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+
mod foo {}
12+
13+
fn main() {
14+
let p = foo { x: () }; //~ ERROR `foo` does not name a structure
15+
}

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

+15
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+
mod MyMod {}
12+
13+
fn main() {
14+
let myVar = MyMod { T: 0 }; //~ ERROR `MyMod` does not name a structure
15+
}

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

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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(B);
12+
struct B;
13+
14+
use std::ops::Deref;
15+
16+
impl Deref for A {
17+
type Target = B;
18+
fn deref(&self) -> &B { &self.0 }
19+
}
20+
21+
impl B {
22+
fn foo(&self) {}
23+
}
24+
25+
fn main() {
26+
A(B).foo();
27+
}

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

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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+
// ignore-pretty
12+
13+
struct X { val: i32 }
14+
impl std::ops::Deref for X {
15+
type Target = i32;
16+
fn deref(&self) -> &i32 { &self.val }
17+
}
18+
19+
20+
trait M { fn m(self); }
21+
impl M for i32 { fn m(self) { println!("i32::m()"); } }
22+
impl M for X { fn m(self) { println!("X::m()"); } }
23+
impl<'a> M for &'a X { fn m(self) { println!("&X::m()"); } }
24+
impl<'a, 'b> M for &'a &'b X { fn m(self) { println!("&&X::m()"); } }
25+
impl<'a, 'b, 'c> M for &'a &'b &'c X { fn m(self) { println!("&&&X::m()"); } }
26+
27+
trait RefM { fn refm(&self); }
28+
impl RefM for i32 { fn refm(&self) { println!("i32::refm()"); } }
29+
impl RefM for X { fn refm(&self) { println!("X::refm()"); } }
30+
impl<'a> RefM for &'a X { fn refm(&self) { println!("&X::refm()"); } }
31+
impl<'a, 'b> RefM for &'a &'b X { fn refm(&self) { println!("&&X::refm()"); } }
32+
impl<'a, 'b, 'c> RefM for &'a &'b &'c X { fn refm(&self) { println!("&&&X::refm()"); } }
33+
34+
struct Y { val: i32 }
35+
impl std::ops::Deref for Y {
36+
type Target = i32;
37+
fn deref(&self) -> &i32 { &self.val }
38+
}
39+
40+
struct Z { val: Y }
41+
impl std::ops::Deref for Z {
42+
type Target = Y;
43+
fn deref(&self) -> &Y { &self.val }
44+
}
45+
46+
struct A;
47+
impl std::marker::Copy for A {}
48+
impl Clone for A { fn clone(&self) -> Self { *self } }
49+
impl M for A { fn m(self) { println!("A::m()"); } }
50+
impl<'a, 'b, 'c> M for &'a &'b &'c A { fn m(self) { println!("&&&A::m()"); } }
51+
impl RefM for A { fn refm(&self) { println!("A::refm()"); } }
52+
impl<'a, 'b, 'c> RefM for &'a &'b &'c A { fn refm(&self) { println!("&&&A::refm()"); } }
53+
54+
fn main() {
55+
// I'll use @ to denote left side of the dot operator
56+
(*X{val:42}).m(); // i32::refm() , self == @
57+
X{val:42}.m(); // X::m() , self == @
58+
(&X{val:42}).m(); // &X::m() , self == @
59+
(&&X{val:42}).m(); // &&X::m() , self == @
60+
(&&&X{val:42}).m(); // &&&X:m() , self == @
61+
(&&&&X{val:42}).m(); // &&&X::m() , self == *@
62+
(&&&&&X{val:42}).m(); // &&&X::m() , self == **@
63+
64+
(*X{val:42}).refm(); // i32::refm() , self == @
65+
X{val:42}.refm(); // X::refm() , self == @
66+
(&X{val:42}).refm(); // X::refm() , self == *@
67+
(&&X{val:42}).refm(); // &X::refm() , self == *@
68+
(&&&X{val:42}).refm(); // &&X::refm() , self == *@
69+
(&&&&X{val:42}).refm(); // &&&X::refm(), self == *@
70+
(&&&&&X{val:42}).refm(); // &&&X::refm(), self == **@
71+
72+
Y{val:42}.refm(); // i32::refm() , self == *@
73+
Z{val:Y{val:42}}.refm(); // i32::refm() , self == **@
74+
75+
A.m(); // A::m() , self == @
76+
// without the Copy trait, (&A).m() would be a compilation error:
77+
// cannot move out of borrowed content
78+
(&A).m(); // A::m() , self == *@
79+
(&&A).m(); // &&&A::m() , self == &@
80+
(&&&A).m(); // &&&A::m() , self == @
81+
A.refm(); // A::refm() , self == @
82+
(&A).refm(); // A::refm() , self == *@
83+
(&&A).refm(); // A::refm() , self == **@
84+
(&&&A).refm(); // &&&A::refm(), self == @
85+
}

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

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
trait TheTrait : TheSuperTrait<<Self as TheTrait>::Item> {
12+
type Item;
13+
}
14+
15+
trait TheSuperTrait<T> {
16+
fn get(&self) -> T;
17+
}
18+
19+
impl TheTrait for i32 {
20+
type Item = u32;
21+
}
22+
23+
impl TheSuperTrait<u32> for i32 {
24+
fn get(&self) -> u32 {
25+
*self as u32
26+
}
27+
}
28+
29+
fn foo<T:TheTrait<Item=u32>>(t: &T) -> u32 {
30+
t.get()
31+
}
32+
33+
fn main() {
34+
foo::<i32>(&22);
35+
}

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

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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::marker::PhantomData;
12+
13+
pub struct UnionedKeys<'a,K>
14+
where K: UnifyKey + 'a
15+
{
16+
table: &'a mut UnificationTable<K>,
17+
root_key: K,
18+
stack: Vec<K>,
19+
}
20+
21+
pub trait UnifyKey {
22+
type Value;
23+
}
24+
25+
pub struct UnificationTable<K:UnifyKey> {
26+
values: Delegate<K>,
27+
}
28+
29+
pub struct Delegate<K>(PhantomData<K>);
30+
31+
fn main() {}

0 commit comments

Comments
 (0)