Adjust tests for feature gate, and add tests for the gate itself
This commit is contained in:
parent
e816910398
commit
ed8d059d8d
20 changed files with 76 additions and 0 deletions
|
@ -8,6 +8,8 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(specialization)]
|
||||||
|
|
||||||
// Common code used for tests that model the Fn/FnMut/FnOnce hierarchy.
|
// Common code used for tests that model the Fn/FnMut/FnOnce hierarchy.
|
||||||
|
|
||||||
pub trait Go {
|
pub trait Go {
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(specialization)]
|
||||||
|
|
||||||
pub trait Foo {
|
pub trait Foo {
|
||||||
fn foo(&self) -> &'static str;
|
fn foo(&self) -> &'static str;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(specialization)]
|
||||||
|
|
||||||
// Make sure we can't project defaulted associated types
|
// Make sure we can't project defaulted associated types
|
||||||
|
|
||||||
trait Foo {
|
trait Foo {
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
// associated type in the impl defining it -- otherwise, what happens
|
// associated type in the impl defining it -- otherwise, what happens
|
||||||
// if it's overridden?
|
// if it's overridden?
|
||||||
|
|
||||||
|
#![feature(specialization)]
|
||||||
|
|
||||||
trait Example {
|
trait Example {
|
||||||
type Output;
|
type Output;
|
||||||
fn generate(self) -> Self::Output;
|
fn generate(self) -> Self::Output;
|
||||||
|
|
19
src/test/compile-fail/specialization-feature-gate-default.rs
Normal file
19
src/test/compile-fail/specialization-feature-gate-default.rs
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
trait Foo {
|
||||||
|
fn foo(&self);
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> Foo for T {
|
||||||
|
default fn foo(&self) {} //~ ERROR
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
23
src/test/compile-fail/specialization-feature-gate-overlap.rs
Normal file
23
src/test/compile-fail/specialization-feature-gate-overlap.rs
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
trait Foo {
|
||||||
|
fn foo(&self);
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> Foo for T {
|
||||||
|
fn foo(&self) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Foo for u8 { //~ ERROR
|
||||||
|
fn foo(&self) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -9,6 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
#![feature(optin_builtin_traits)]
|
#![feature(optin_builtin_traits)]
|
||||||
|
#![feature(specialization)]
|
||||||
|
|
||||||
struct TestType<T>(T);
|
struct TestType<T>(T);
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(specialization)]
|
||||||
|
|
||||||
trait Foo {
|
trait Foo {
|
||||||
fn foo(&self);
|
fn foo(&self);
|
||||||
fn bar(&self);
|
fn bar(&self);
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
#![feature(optin_builtin_traits)]
|
#![feature(optin_builtin_traits)]
|
||||||
|
#![feature(specialization)]
|
||||||
|
|
||||||
trait MyTrait {}
|
trait MyTrait {}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(specialization)]
|
||||||
|
|
||||||
trait Foo {}
|
trait Foo {}
|
||||||
impl<T: Clone> Foo for T {}
|
impl<T: Clone> Foo for T {}
|
||||||
impl<T> Foo for Vec<T> {} //~ ERROR E0119
|
impl<T> Foo for Vec<T> {} //~ ERROR E0119
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
|
|
||||||
// aux-build:go_trait.rs
|
// aux-build:go_trait.rs
|
||||||
|
|
||||||
|
#![feature(specialization)]
|
||||||
|
|
||||||
extern crate go_trait;
|
extern crate go_trait;
|
||||||
|
|
||||||
use go_trait::{Go,GoMut};
|
use go_trait::{Go,GoMut};
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(specialization)]
|
||||||
|
|
||||||
trait Foo {
|
trait Foo {
|
||||||
fn mk() -> Self;
|
fn mk() -> Self;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(specialization)]
|
||||||
|
|
||||||
// Tests a variety of basic specialization scenarios and method
|
// Tests a variety of basic specialization scenarios and method
|
||||||
// dispatch for them.
|
// dispatch for them.
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
|
|
||||||
// aux-build:specialization_cross_crate.rs
|
// aux-build:specialization_cross_crate.rs
|
||||||
|
|
||||||
|
#![feature(specialization)]
|
||||||
|
|
||||||
extern crate specialization_cross_crate;
|
extern crate specialization_cross_crate;
|
||||||
|
|
||||||
use specialization_cross_crate::*;
|
use specialization_cross_crate::*;
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(specialization)]
|
||||||
|
|
||||||
// First, test only use of explicit `default` items:
|
// First, test only use of explicit `default` items:
|
||||||
|
|
||||||
trait Foo {
|
trait Foo {
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(specialization)]
|
||||||
|
|
||||||
trait Foo<T> {}
|
trait Foo<T> {}
|
||||||
|
|
||||||
trait Assoc {
|
trait Assoc {
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(specialization)]
|
||||||
|
|
||||||
// Make sure we *can* project non-defaulted associated types
|
// Make sure we *can* project non-defaulted associated types
|
||||||
// cf compile-fail/specialization-default-projection.rs
|
// cf compile-fail/specialization-default-projection.rs
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(specialization)]
|
||||||
|
|
||||||
// Test that you can specialize via an explicit trait hierarchy
|
// Test that you can specialize via an explicit trait hierarchy
|
||||||
|
|
||||||
// FIXME: this doesn't work yet...
|
// FIXME: this doesn't work yet...
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(specialization)]
|
||||||
|
|
||||||
trait Trait<T> {
|
trait Trait<T> {
|
||||||
fn convert(&self) -> T;
|
fn convert(&self) -> T;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(specialization)]
|
||||||
|
|
||||||
use std::convert::Into;
|
use std::convert::Into;
|
||||||
|
|
||||||
trait Trait {
|
trait Trait {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue