mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
Adjust tests for feature gate, and add tests for the gate itself
This commit is contained in:
parent
e816910398
commit
ed8d059d8d
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(specialization)]
|
||||
|
||||
// Common code used for tests that model the Fn/FnMut/FnOnce hierarchy.
|
||||
|
||||
pub trait Go {
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(specialization)]
|
||||
|
||||
pub trait Foo {
|
||||
fn foo(&self) -> &'static str;
|
||||
}
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(specialization)]
|
||||
|
||||
// Make sure we can't project defaulted associated types
|
||||
|
||||
trait Foo {
|
||||
|
@ -12,6 +12,8 @@
|
||||
// associated type in the impl defining it -- otherwise, what happens
|
||||
// if it's overridden?
|
||||
|
||||
#![feature(specialization)]
|
||||
|
||||
trait Example {
|
||||
type 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.
|
||||
|
||||
#![feature(optin_builtin_traits)]
|
||||
#![feature(specialization)]
|
||||
|
||||
struct TestType<T>(T);
|
||||
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(specialization)]
|
||||
|
||||
trait Foo {
|
||||
fn foo(&self);
|
||||
fn bar(&self);
|
||||
|
@ -9,6 +9,7 @@
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(optin_builtin_traits)]
|
||||
#![feature(specialization)]
|
||||
|
||||
trait MyTrait {}
|
||||
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(specialization)]
|
||||
|
||||
trait Foo {}
|
||||
impl<T: Clone> Foo for T {}
|
||||
impl<T> Foo for Vec<T> {} //~ ERROR E0119
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
// aux-build:go_trait.rs
|
||||
|
||||
#![feature(specialization)]
|
||||
|
||||
extern crate go_trait;
|
||||
|
||||
use go_trait::{Go,GoMut};
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(specialization)]
|
||||
|
||||
trait Foo {
|
||||
fn mk() -> Self;
|
||||
}
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(specialization)]
|
||||
|
||||
// Tests a variety of basic specialization scenarios and method
|
||||
// dispatch for them.
|
||||
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
// aux-build:specialization_cross_crate.rs
|
||||
|
||||
#![feature(specialization)]
|
||||
|
||||
extern crate specialization_cross_crate;
|
||||
|
||||
use specialization_cross_crate::*;
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(specialization)]
|
||||
|
||||
// First, test only use of explicit `default` items:
|
||||
|
||||
trait Foo {
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(specialization)]
|
||||
|
||||
trait Foo<T> {}
|
||||
|
||||
trait Assoc {
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(specialization)]
|
||||
|
||||
// Make sure we *can* project non-defaulted associated types
|
||||
// cf compile-fail/specialization-default-projection.rs
|
||||
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(specialization)]
|
||||
|
||||
// Test that you can specialize via an explicit trait hierarchy
|
||||
|
||||
// FIXME: this doesn't work yet...
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(specialization)]
|
||||
|
||||
trait Trait<T> {
|
||||
fn convert(&self) -> T;
|
||||
}
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(specialization)]
|
||||
|
||||
use std::convert::Into;
|
||||
|
||||
trait Trait {
|
||||
|
Loading…
Reference in New Issue
Block a user