Skip to content

Commit ed8d059

Browse files
committed
Adjust tests for feature gate, and add tests for the gate itself
1 parent e816910 commit ed8d059

20 files changed

+76
-0
lines changed

src/test/auxiliary/go_trait.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(specialization)]
12+
1113
// Common code used for tests that model the Fn/FnMut/FnOnce hierarchy.
1214

1315
pub trait Go {

src/test/auxiliary/specialization_cross_crate.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(specialization)]
12+
1113
pub trait Foo {
1214
fn foo(&self) -> &'static str;
1315
}

src/test/compile-fail/specialization-default-projection.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(specialization)]
12+
1113
// Make sure we can't project defaulted associated types
1214

1315
trait Foo {

src/test/compile-fail/specialization-default-types.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
// associated type in the impl defining it -- otherwise, what happens
1313
// if it's overridden?
1414

15+
#![feature(specialization)]
16+
1517
trait Example {
1618
type Output;
1719
fn generate(self) -> Self::Output;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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 Foo {
12+
fn foo(&self);
13+
}
14+
15+
impl<T> Foo for T {
16+
default fn foo(&self) {} //~ ERROR
17+
}
18+
19+
fn main() {}
Lines changed: 23 additions & 0 deletions
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+
trait Foo {
12+
fn foo(&self);
13+
}
14+
15+
impl<T> Foo for T {
16+
fn foo(&self) {}
17+
}
18+
19+
impl Foo for u8 { //~ ERROR
20+
fn foo(&self) {}
21+
}
22+
23+
fn main() {}

src/test/compile-fail/specialization-negative-impl.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
#![feature(optin_builtin_traits)]
12+
#![feature(specialization)]
1213

1314
struct TestType<T>(T);
1415

src/test/compile-fail/specialization-no-default.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(specialization)]
12+
1113
trait Foo {
1214
fn foo(&self);
1315
fn bar(&self);

src/test/compile-fail/specialization-overlap-negative.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
#![feature(optin_builtin_traits)]
12+
#![feature(specialization)]
1213

1314
trait MyTrait {}
1415

src/test/compile-fail/specialization-overlap.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(specialization)]
12+
1113
trait Foo {}
1214
impl<T: Clone> Foo for T {}
1315
impl<T> Foo for Vec<T> {} //~ ERROR E0119

src/test/run-pass/specialization-allowed-cross-crate.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
// aux-build:go_trait.rs
1212

13+
#![feature(specialization)]
14+
1315
extern crate go_trait;
1416

1517
use go_trait::{Go,GoMut};

src/test/run-pass/specialization-assoc-fns.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(specialization)]
12+
1113
trait Foo {
1214
fn mk() -> Self;
1315
}

src/test/run-pass/specialization-basics.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(specialization)]
12+
1113
// Tests a variety of basic specialization scenarios and method
1214
// dispatch for them.
1315

src/test/run-pass/specialization-cross-crate.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
// aux-build:specialization_cross_crate.rs
1212

13+
#![feature(specialization)]
14+
1315
extern crate specialization_cross_crate;
1416

1517
use specialization_cross_crate::*;

src/test/run-pass/specialization-default-methods.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(specialization)]
12+
1113
// First, test only use of explicit `default` items:
1214

1315
trait Foo {

src/test/run-pass/specialization-on-projection.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(specialization)]
12+
1113
trait Foo<T> {}
1214

1315
trait Assoc {

src/test/run-pass/specialization-projection.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(specialization)]
12+
1113
// Make sure we *can* project non-defaulted associated types
1214
// cf compile-fail/specialization-default-projection.rs
1315

src/test/run-pass/specialization-super-traits.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(specialization)]
12+
1113
// Test that you can specialize via an explicit trait hierarchy
1214

1315
// FIXME: this doesn't work yet...

src/test/run-pass/specialization-translate-projections-with-params.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(specialization)]
12+
1113
trait Trait<T> {
1214
fn convert(&self) -> T;
1315
}

src/test/run-pass/specialization-translate-projections.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(specialization)]
12+
1113
use std::convert::Into;
1214

1315
trait Trait {

0 commit comments

Comments
 (0)