Put negative trait implemtations behind a feature gate

This commit is contained in:
Flavio Percoco 2014-12-29 13:52:43 +01:00
parent 8b883ab268
commit c062fac835
5 changed files with 40 additions and 1 deletions

View file

@ -84,6 +84,9 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[
// A way to temporarily opt out of the new orphan rules. This will *never* be accepted.
("old_orphan_check", Deprecated),
// OIBIT specific features
("optin_builtin_traits", Active),
// These are used to test this portion of the compiler, they don't actually
// mean anything
("test_accepted_feature", Accepted),
@ -291,7 +294,17 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
}
}
ast::ItemImpl(_, _, _, _, _, ref items) => {
ast::ItemImpl(_, polarity, _, _, _, ref items) => {
match polarity {
ast::ImplPolarity::Negative => {
self.gate_feature("optin_builtin_traits",
i.span,
"negative trait bounds are not yet fully implemented; \
use marker types for now");
},
_ => {}
}
if attr::contains_name(i.attrs[],
"unsafe_destructor") {
self.gate_feature("unsafe_destructor",

View file

@ -0,0 +1,20 @@
// Copyright 2014 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.
use std::kinds::Send;
struct TestType;
trait TestTrait {}
unsafe impl !Send for TestType {}
//~^ ERROR negative trait bounds
fn main() {}

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(optin_builtin_traits)]
use std::kinds::Send;
struct TestType;

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(optin_builtin_traits)]
// pp-exact
trait UnsafeTrait {

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(optin_builtin_traits)]
use std::kinds::Send;
struct TestType;