Skip to content

Commit ad7e33e

Browse files
committed
Feature gate #[rustc_on_unimplemented]
1 parent dd074ab commit ad7e33e

File tree

5 files changed

+13
-4
lines changed

5 files changed

+13
-4
lines changed

src/libcore/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
#![feature(simd, unsafe_destructor, slicing_syntax)]
6464
#![feature(unboxed_closures)]
6565
#![allow(unknown_features)] #![feature(int_uint)]
66+
#![feature(on_unimplemented)]
6667
#![deny(missing_docs)]
6768

6869
#[macro_use]

src/librustc/middle/traits/error_reporting.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,8 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
181181
let custom_note = report_on_unimplemented(infcx, &*trait_ref.0,
182182
obligation.cause.span);
183183
if let Some(s) = custom_note {
184-
infcx.tcx.sess.span_note(
185-
obligation.cause.span,
186-
s.as_slice());
184+
infcx.tcx.sess.span_note(obligation.cause.span,
185+
s.as_slice());
187186
}
188187
}
189188
}

src/libsyntax/feature_gate.rs

+5
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[
7171
("visible_private_types", Active),
7272
("slicing_syntax", Active),
7373
("box_syntax", Active),
74+
("on_unimplemented", Active),
7475

7576
("if_let", Accepted),
7677
("while_let", Accepted),
@@ -249,6 +250,10 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
249250
self.gate_feature("linkage", i.span,
250251
"the `linkage` attribute is experimental \
251252
and not portable across platforms")
253+
} else if attr.name() == "rustc_on_unimplemented" {
254+
self.gate_feature("on_unimplemented", i.span,
255+
"the `#[rustc_on_unimplemented]` attribute \
256+
is an experimental feature")
252257
}
253258
}
254259
match i.node {

src/test/compile-fail/on-unimplemented-bad-anno.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
// except according to those terms.
1010
// ignore-tidy-linelength
1111

12-
#[allow(unused)]
12+
#![feature(on_unimplemented)]
13+
14+
#![allow(unused)]
1315

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

src/test/compile-fail/on-unimplemented.rs

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
// except according to those terms.
1010
// ignore-tidy-linelength
1111

12+
#![feature(on_unimplemented)]
13+
1214
#[rustc_on_unimplemented = "test error `{Self}` with `{Bar}` `{Baz}` `{Quux}`"]
1315
trait Foo<Bar, Baz, Quux>{}
1416

0 commit comments

Comments
 (0)