1
Fork 0

Make sure feature gate errors are recoverable

This commit is contained in:
Vadim Petrochenkov 2018-12-21 01:47:03 +03:00
parent b99fb2f544
commit 15cefe4b2a
20 changed files with 32 additions and 58 deletions

View file

@ -222,14 +222,13 @@ impl<'a> LintLevelsBuilder<'a> {
match item.node { match item.node {
ast::MetaItemKind::Word => {} // actual lint names handled later ast::MetaItemKind::Word => {} // actual lint names handled later
ast::MetaItemKind::NameValue(ref name_value) => { ast::MetaItemKind::NameValue(ref name_value) => {
let gate_reasons = !self.sess.features_untracked().lint_reasons;
if item.ident == "reason" { if item.ident == "reason" {
// found reason, reslice meta list to exclude it // found reason, reslice meta list to exclude it
metas = &metas[0..metas.len()-1]; metas = &metas[0..metas.len()-1];
// FIXME (#55112): issue unused-attributes lint if we thereby // FIXME (#55112): issue unused-attributes lint if we thereby
// don't have any lint names (`#[level(reason = "foo")]`) // don't have any lint names (`#[level(reason = "foo")]`)
if let ast::LitKind::Str(rationale, _) = name_value.node { if let ast::LitKind::Str(rationale, _) = name_value.node {
if gate_reasons { if !self.sess.features_untracked().lint_reasons {
feature_gate::emit_feature_err( feature_gate::emit_feature_err(
&self.sess.parse_sess, &self.sess.parse_sess,
"lint_reasons", "lint_reasons",
@ -237,9 +236,8 @@ impl<'a> LintLevelsBuilder<'a> {
feature_gate::GateIssue::Language, feature_gate::GateIssue::Language,
"lint reasons are experimental" "lint reasons are experimental"
); );
} else {
reason = Some(rationale);
} }
reason = Some(rationale);
} else { } else {
let mut err = bad_attr(name_value.span); let mut err = bad_attr(name_value.span);
err.help("reason must be a string literal"); err.help("reason must be a string literal");

View file

@ -2210,7 +2210,6 @@ fn from_target_feature(
feature_gate::GateIssue::Language, feature_gate::GateIssue::Language,
&format!("the target feature `{}` is currently unstable", feature), &format!("the target feature `{}` is currently unstable", feature),
); );
return None;
} }
Some(Symbol::intern(feature)) Some(Symbol::intern(feature))
})); }));

View file

@ -722,7 +722,6 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
emit_feature_err(this.cx.parse_sess, &*feature.as_str(), span, emit_feature_err(this.cx.parse_sess, &*feature.as_str(), span,
GateIssue::Library(Some(issue)), &explain); GateIssue::Library(Some(issue)), &explain);
this.cx.trace_macros_diag(); this.cx.trace_macros_diag();
return Err(kind.dummy(span));
} }
} }

View file

@ -49,7 +49,6 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt,
sp, sp,
feature_gate::GateIssue::Language, feature_gate::GateIssue::Language,
feature_gate::EXPLAIN_ASM); feature_gate::EXPLAIN_ASM);
return DummyResult::expr(sp);
} }
// Split the tts before the first colon, to avoid `asm!("x": y)` being // Split the tts before the first colon, to avoid `asm!("x": y)` being

View file

@ -20,7 +20,6 @@ pub fn expand_syntax_ext<'cx>(cx: &'cx mut ExtCtxt,
sp, sp,
feature_gate::GateIssue::Language, feature_gate::GateIssue::Language,
feature_gate::EXPLAIN_CONCAT_IDENTS); feature_gate::EXPLAIN_CONCAT_IDENTS);
return base::DummyResult::expr(sp);
} }
if tts.is_empty() { if tts.is_empty() {

View file

@ -713,7 +713,6 @@ pub fn expand_format_args_nl<'cx>(
sp, sp,
feature_gate::GateIssue::Language, feature_gate::GateIssue::Language,
feature_gate::EXPLAIN_FORMAT_ARGS_NL); feature_gate::EXPLAIN_FORMAT_ARGS_NL);
return DummyResult::expr(sp);
} }
sp = sp.apply_mark(ecx.current_expansion.mark); sp = sp.apply_mark(ecx.current_expansion.mark);
match parse_args(ecx, sp, tts) { match parse_args(ecx, sp, tts) {

View file

@ -29,7 +29,6 @@ pub fn expand_global_asm<'cx>(cx: &'cx mut ExtCtxt,
sp, sp,
feature_gate::GateIssue::Language, feature_gate::GateIssue::Language,
feature_gate::EXPLAIN_GLOBAL_ASM); feature_gate::EXPLAIN_GLOBAL_ASM);
return DummyResult::any(sp);
} }
let mut p = cx.new_parser_from_tts(tts); let mut p = cx.new_parser_from_tts(tts);

View file

@ -14,7 +14,6 @@ pub fn expand_syntax_ext<'cx>(cx: &'cx mut base::ExtCtxt,
sp, sp,
feature_gate::GateIssue::Language, feature_gate::GateIssue::Language,
feature_gate::EXPLAIN_LOG_SYNTAX); feature_gate::EXPLAIN_LOG_SYNTAX);
return base::DummyResult::any(sp);
} }
println!("{}", print::pprust::tts_to_string(tts)); println!("{}", print::pprust::tts_to_string(tts));

View file

@ -31,8 +31,6 @@ pub fn expand(
attr_sp, attr_sp,
feature_gate::GateIssue::Language, feature_gate::GateIssue::Language,
feature_gate::EXPLAIN_CUSTOM_TEST_FRAMEWORKS); feature_gate::EXPLAIN_CUSTOM_TEST_FRAMEWORKS);
return vec![anno_item];
} }
if !ecx.ecfg.should_test { return vec![]; } if !ecx.ecfg.should_test { return vec![]; }

View file

@ -15,7 +15,6 @@ pub fn expand_trace_macros(cx: &mut ExtCtxt,
sp, sp,
feature_gate::GateIssue::Language, feature_gate::GateIssue::Language,
feature_gate::EXPLAIN_TRACE_MACROS); feature_gate::EXPLAIN_TRACE_MACROS);
return base::DummyResult::any(sp);
} }
match (tt.len(), tt.first()) { match (tt.len(), tt.first()) {

View file

@ -2,6 +2,6 @@
fn main() { fn main() {
unsafe { unsafe {
println!("{}", asm!("")); //~ ERROR inline assembly is not stable println!("{:?}", asm!("")); //~ ERROR inline assembly is not stable
} }
} }

View file

@ -1,8 +1,8 @@
error[E0658]: inline assembly is not stable enough for use and is subject to change (see issue #29722) error[E0658]: inline assembly is not stable enough for use and is subject to change (see issue #29722)
--> $DIR/feature-gate-asm2.rs:5:24 --> $DIR/feature-gate-asm2.rs:5:24
| |
LL | println!("{}", asm!("")); //~ ERROR inline assembly is not stable LL | println!("{:?}", asm!("")); //~ ERROR inline assembly is not stable
| ^^^^^^^^ | ^^^^^^^^
| |
= help: add #![feature(asm)] to the crate attributes to enable = help: add #![feature(asm)] to the crate attributes to enable

View file

@ -2,4 +2,5 @@
fn main() { fn main() {
concat_idents!(a, b); //~ ERROR `concat_idents` is not stable enough concat_idents!(a, b); //~ ERROR `concat_idents` is not stable enough
//~| ERROR cannot find value `ab` in this scope
} }

View file

@ -6,6 +6,13 @@ LL | concat_idents!(a, b); //~ ERROR `concat_idents` is not stable enough
| |
= help: add #![feature(concat_idents)] to the crate attributes to enable = help: add #![feature(concat_idents)] to the crate attributes to enable
error: aborting due to previous error error[E0425]: cannot find value `ab` in this scope
--> $DIR/feature-gate-concat_idents2.rs:14:5
|
LL | concat_idents!(a, b); //~ ERROR `concat_idents` is not stable enough
| ^^^^^^^^^^^^^^^^^^^^^ not found in this scope
For more information about this error, try `rustc --explain E0658`. error: aborting due to 2 previous errors
Some errors occurred: E0425, E0658.
For more information about an error, try `rustc --explain E0425`.

View file

@ -0,0 +1 @@

View file

@ -1,5 +1,5 @@
// gate-test-log_syntax // gate-test-log_syntax
fn main() { fn main() {
println!("{}", log_syntax!()); //~ ERROR `log_syntax!` is not stable println!("{:?}", log_syntax!()); //~ ERROR `log_syntax!` is not stable
} }

View file

@ -1,8 +1,8 @@
error[E0658]: `log_syntax!` is not stable enough for use and is subject to change (see issue #29598) error[E0658]: `log_syntax!` is not stable enough for use and is subject to change (see issue #29598)
--> $DIR/feature-gate-log_syntax2.rs:4:20 --> $DIR/feature-gate-log_syntax2.rs:4:20
| |
LL | println!("{}", log_syntax!()); //~ ERROR `log_syntax!` is not stable LL | println!("{:?}", log_syntax!()); //~ ERROR `log_syntax!` is not stable
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
| |
= help: add #![feature(log_syntax)] to the crate attributes to enable = help: add #![feature(log_syntax)] to the crate attributes to enable

View file

@ -0,0 +1 @@

View file

@ -2,15 +2,9 @@
fn main() { fn main() {
trace_macros!(); //~ ERROR `trace_macros` is not stable trace_macros!(); //~ ERROR `trace_macros` is not stable
trace_macros!(1); //~ ERROR `trace_macros` is not stable //~| ERROR trace_macros! accepts only `true` or `false`
trace_macros!(ident); //~ ERROR `trace_macros` is not stable trace_macros!(true); //~ ERROR `trace_macros` is not stable
trace_macros!(for); //~ ERROR `trace_macros` is not stable trace_macros!(false); //~ ERROR `trace_macros` is not stable
trace_macros!(true,); //~ ERROR `trace_macros` is not stable
trace_macros!(false 1); //~ ERROR `trace_macros` is not stable
// Errors are signalled early for the above, before expansion.
// See trace_macros-gate2 and trace_macros-gate3. for examples
// of the below being caught.
macro_rules! expando { macro_rules! expando {
($x: ident) => { trace_macros!($x) } //~ ERROR `trace_macros` is not stable ($x: ident) => { trace_macros!($x) } //~ ERROR `trace_macros` is not stable

View file

@ -6,48 +6,30 @@ LL | trace_macros!(); //~ ERROR `trace_macros` is not stable
| |
= help: add #![feature(trace_macros)] to the crate attributes to enable = help: add #![feature(trace_macros)] to the crate attributes to enable
error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598) error: trace_macros! accepts only `true` or `false`
--> $DIR/trace_macros-gate.rs:5:5 --> $DIR/trace_macros-gate.rs:14:5
| |
LL | trace_macros!(1); //~ ERROR `trace_macros` is not stable LL | trace_macros!(); //~ ERROR `trace_macros` is not stable
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^
|
= help: add #![feature(trace_macros)] to the crate attributes to enable
error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598) error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598)
--> $DIR/trace_macros-gate.rs:6:5 --> $DIR/trace_macros-gate.rs:6:5
| |
LL | trace_macros!(ident); //~ ERROR `trace_macros` is not stable LL | trace_macros!(true); //~ ERROR `trace_macros` is not stable
| ^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^
| |
= help: add #![feature(trace_macros)] to the crate attributes to enable = help: add #![feature(trace_macros)] to the crate attributes to enable
error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598) error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598)
--> $DIR/trace_macros-gate.rs:7:5 --> $DIR/trace_macros-gate.rs:7:5
| |
LL | trace_macros!(for); //~ ERROR `trace_macros` is not stable LL | trace_macros!(false); //~ ERROR `trace_macros` is not stable
| ^^^^^^^^^^^^^^^^^^^
|
= help: add #![feature(trace_macros)] to the crate attributes to enable
error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598)
--> $DIR/trace_macros-gate.rs:8:5
|
LL | trace_macros!(true,); //~ ERROR `trace_macros` is not stable
| ^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^
| |
= help: add #![feature(trace_macros)] to the crate attributes to enable = help: add #![feature(trace_macros)] to the crate attributes to enable
error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598) error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598)
--> $DIR/trace_macros-gate.rs:9:5 --> $DIR/trace_macros-gate.rs:20:26
|
LL | trace_macros!(false 1); //~ ERROR `trace_macros` is not stable
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= help: add #![feature(trace_macros)] to the crate attributes to enable
error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598)
--> $DIR/trace_macros-gate.rs:16:26
| |
LL | ($x: ident) => { trace_macros!($x) } //~ ERROR `trace_macros` is not stable LL | ($x: ident) => { trace_macros!($x) } //~ ERROR `trace_macros` is not stable
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^
@ -57,6 +39,6 @@ LL | expando!(true);
| |
= help: add #![feature(trace_macros)] to the crate attributes to enable = help: add #![feature(trace_macros)] to the crate attributes to enable
error: aborting due to 7 previous errors error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0658`. For more information about this error, try `rustc --explain E0658`.