Skip to content

Commit c062fac

Browse files
committed
Put negative trait implemtations behind a feature gate
1 parent 8b883ab commit c062fac

File tree

5 files changed

+40
-1
lines changed

5 files changed

+40
-1
lines changed

src/libsyntax/feature_gate.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[
8484
// A way to temporarily opt out of the new orphan rules. This will *never* be accepted.
8585
("old_orphan_check", Deprecated),
8686

87+
// OIBIT specific features
88+
("optin_builtin_traits", Active),
89+
8790
// These are used to test this portion of the compiler, they don't actually
8891
// mean anything
8992
("test_accepted_feature", Accepted),
@@ -291,7 +294,17 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
291294
}
292295
}
293296

294-
ast::ItemImpl(_, _, _, _, _, ref items) => {
297+
ast::ItemImpl(_, polarity, _, _, _, ref items) => {
298+
match polarity {
299+
ast::ImplPolarity::Negative => {
300+
self.gate_feature("optin_builtin_traits",
301+
i.span,
302+
"negative trait bounds are not yet fully implemented; \
303+
use marker types for now");
304+
},
305+
_ => {}
306+
}
307+
295308
if attr::contains_name(i.attrs[],
296309
"unsafe_destructor") {
297310
self.gate_feature("unsafe_destructor",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2014 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+
use std::kinds::Send;
12+
13+
struct TestType;
14+
15+
trait TestTrait {}
16+
17+
unsafe impl !Send for TestType {}
18+
//~^ ERROR negative trait bounds
19+
20+
fn main() {}

src/test/compile-fail/syntax-trait-polarity.rs

+2
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(optin_builtin_traits)]
12+
1113
use std::kinds::Send;
1214

1315
struct TestType;

src/test/pretty/trait-polarity.rs

+2
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(optin_builtin_traits)]
12+
1113
// pp-exact
1214

1315
trait UnsafeTrait {

src/test/run-pass/syntax-trait-polarity.rs

+2
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(optin_builtin_traits)]
12+
1113
use std::kinds::Send;
1214

1315
struct TestType;

0 commit comments

Comments
 (0)