Skip to content

Commit

Permalink
Put negative trait implemtations behind a feature gate
Browse files Browse the repository at this point in the history
  • Loading branch information
flaper87 committed Jan 4, 2015
1 parent 8b883ab commit c062fac
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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",
Expand Down
20 changes: 20 additions & 0 deletions src/test/compile-fail/syntax-trait-polarity-feature-gate.rs
Original file line number Diff line number Diff line change
@@ -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() {}
2 changes: 2 additions & 0 deletions src/test/compile-fail/syntax-trait-polarity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/test/pretty/trait-polarity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions src/test/run-pass/syntax-trait-polarity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

7 comments on commit c062fac

@bors
Copy link
Contributor

@bors bors commented on c062fac Jan 5, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from nikomatsakis
at flaper87@c062fac

@bors
Copy link
Contributor

@bors bors commented on c062fac Jan 5, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging FlaPer87/rust/oibit-send-and-friends = c062fac into auto

@bors
Copy link
Contributor

@bors bors commented on c062fac Jan 5, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FlaPer87/rust/oibit-send-and-friends = c062fac merged ok, testing candidate = ed22606

@bors
Copy link
Contributor

@bors bors commented on c062fac Jan 5, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

status: {"merge_sha": "ed22606c8382822efc555f72f895c560289a5c70"}

@bors
Copy link
Contributor

@bors bors commented on c062fac Jan 5, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = ed22606

@bors
Copy link
Contributor

@bors bors commented on c062fac Jan 5, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = ed22606

Please sign in to comment.