Skip to content

Commit 4fbb71f

Browse files
committed
Add regression tests for #29859. However #29859 is not fully fixed.
1 parent 8c14649 commit 4fbb71f

3 files changed

+84
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
// OIBIT-based version of #29859, supertrait version. Test that using
12+
// a simple OIBIT `..` impl alone still doesn't allow arbitary bounds
13+
// to be synthesized.
14+
15+
#![feature(optin_builtin_traits)]
16+
17+
trait Magic: Copy {}
18+
impl Magic for .. {}
19+
20+
fn copy<T: Magic>(x: T) -> (T, T) { (x, x) }
21+
22+
#[derive(Debug)]
23+
struct NoClone;
24+
25+
fn main() {
26+
let (a, b) = copy(NoClone); //~ ERROR E0277
27+
println!("{:?} {:?}", a, b);
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
// Regression test for #29859, supertrait version. This example
12+
// allowed arbitrary trait bounds to be synthesized.
13+
14+
trait Magic: Copy {}
15+
impl<T: Magic> Magic for T {}
16+
17+
fn copy<T: Magic>(x: T) -> (T, T) { (x, x) }
18+
19+
#[derive(Debug)]
20+
struct NoClone;
21+
22+
fn main() {
23+
let (a, b) = copy(NoClone); //~ ERROR E0275
24+
println!("{:?} {:?}", a, b);
25+
}
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+
// Regression test for #29859, initial version. This example allowed
12+
// arbitrary trait bounds to be synthesized.
13+
14+
// Trait that you want all types to implement.
15+
use std::marker::{Sync as Trait};
16+
17+
pub trait Magic {
18+
type X: Trait;
19+
}
20+
impl<T: Magic> Magic for T {
21+
type X = Self;
22+
}
23+
24+
fn check<T: Trait>() {}
25+
26+
fn wizard<T: Magic>() { check::<<T as Magic>::X>(); }
27+
28+
fn main() {
29+
wizard::<*mut ()>(); //~ ERROR E0275
30+
// check::<*mut ()>();
31+
}

0 commit comments

Comments
 (0)