Skip to content

Commit

Permalink
Feature gate #[rustc_on_unimplemented]
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed Jan 11, 2015
1 parent dd074ab commit ad7e33e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/libcore/lib.rs
Expand Up @@ -63,6 +63,7 @@
#![feature(simd, unsafe_destructor, slicing_syntax)]
#![feature(unboxed_closures)]
#![allow(unknown_features)] #![feature(int_uint)]
#![feature(on_unimplemented)]
#![deny(missing_docs)]

#[macro_use]
Expand Down
5 changes: 2 additions & 3 deletions src/librustc/middle/traits/error_reporting.rs
Expand Up @@ -181,9 +181,8 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
let custom_note = report_on_unimplemented(infcx, &*trait_ref.0,
obligation.cause.span);
if let Some(s) = custom_note {
infcx.tcx.sess.span_note(
obligation.cause.span,
s.as_slice());
infcx.tcx.sess.span_note(obligation.cause.span,
s.as_slice());
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/libsyntax/feature_gate.rs
Expand Up @@ -71,6 +71,7 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[
("visible_private_types", Active),
("slicing_syntax", Active),
("box_syntax", Active),
("on_unimplemented", Active),

("if_let", Accepted),
("while_let", Accepted),
Expand Down Expand Up @@ -249,6 +250,10 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
self.gate_feature("linkage", i.span,
"the `linkage` attribute is experimental \
and not portable across platforms")
} else if attr.name() == "rustc_on_unimplemented" {
self.gate_feature("on_unimplemented", i.span,
"the `#[rustc_on_unimplemented]` attribute \
is an experimental feature")
}
}
match i.node {
Expand Down
4 changes: 3 additions & 1 deletion src/test/compile-fail/on-unimplemented-bad-anno.rs
Expand Up @@ -9,7 +9,9 @@
// except according to those terms.
// ignore-tidy-linelength

#[allow(unused)]
#![feature(on_unimplemented)]

#![allow(unused)]

#[rustc_on_unimplemented = "test error `{Self}` with `{Bar}` `{Baz}` `{Quux}`"]
trait Foo<Bar, Baz, Quux>{}
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/on-unimplemented.rs
Expand Up @@ -9,6 +9,8 @@
// except according to those terms.
// ignore-tidy-linelength

#![feature(on_unimplemented)]

#[rustc_on_unimplemented = "test error `{Self}` with `{Bar}` `{Baz}` `{Quux}`"]
trait Foo<Bar, Baz, Quux>{}

Expand Down

0 comments on commit ad7e33e

Please sign in to comment.