Skip to content

Commit 15cefe4

Browse files
committed
Make sure feature gate errors are recoverable
1 parent b99fb2f commit 15cefe4

20 files changed

+32
-58
lines changed

src/librustc/lint/levels.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,24 +222,22 @@ impl<'a> LintLevelsBuilder<'a> {
222222
match item.node {
223223
ast::MetaItemKind::Word => {} // actual lint names handled later
224224
ast::MetaItemKind::NameValue(ref name_value) => {
225-
let gate_reasons = !self.sess.features_untracked().lint_reasons;
226225
if item.ident == "reason" {
227226
// found reason, reslice meta list to exclude it
228227
metas = &metas[0..metas.len()-1];
229228
// FIXME (#55112): issue unused-attributes lint if we thereby
230229
// don't have any lint names (`#[level(reason = "foo")]`)
231230
if let ast::LitKind::Str(rationale, _) = name_value.node {
232-
if gate_reasons {
231+
if !self.sess.features_untracked().lint_reasons {
233232
feature_gate::emit_feature_err(
234233
&self.sess.parse_sess,
235234
"lint_reasons",
236235
item.span,
237236
feature_gate::GateIssue::Language,
238237
"lint reasons are experimental"
239238
);
240-
} else {
241-
reason = Some(rationale);
242239
}
240+
reason = Some(rationale);
243241
} else {
244242
let mut err = bad_attr(name_value.span);
245243
err.help("reason must be a string literal");

src/librustc_typeck/collect.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2210,7 +2210,6 @@ fn from_target_feature(
22102210
feature_gate::GateIssue::Language,
22112211
&format!("the target feature `{}` is currently unstable", feature),
22122212
);
2213-
return None;
22142213
}
22152214
Some(Symbol::intern(feature))
22162215
}));

src/libsyntax/ext/expand.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,6 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
722722
emit_feature_err(this.cx.parse_sess, &*feature.as_str(), span,
723723
GateIssue::Library(Some(issue)), &explain);
724724
this.cx.trace_macros_diag();
725-
return Err(kind.dummy(span));
726725
}
727726
}
728727

src/libsyntax_ext/asm.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt,
4949
sp,
5050
feature_gate::GateIssue::Language,
5151
feature_gate::EXPLAIN_ASM);
52-
return DummyResult::expr(sp);
5352
}
5453

5554
// Split the tts before the first colon, to avoid `asm!("x": y)` being

src/libsyntax_ext/concat_idents.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ pub fn expand_syntax_ext<'cx>(cx: &'cx mut ExtCtxt,
2020
sp,
2121
feature_gate::GateIssue::Language,
2222
feature_gate::EXPLAIN_CONCAT_IDENTS);
23-
return base::DummyResult::expr(sp);
2423
}
2524

2625
if tts.is_empty() {

src/libsyntax_ext/format.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,6 @@ pub fn expand_format_args_nl<'cx>(
713713
sp,
714714
feature_gate::GateIssue::Language,
715715
feature_gate::EXPLAIN_FORMAT_ARGS_NL);
716-
return DummyResult::expr(sp);
717716
}
718717
sp = sp.apply_mark(ecx.current_expansion.mark);
719718
match parse_args(ecx, sp, tts) {

src/libsyntax_ext/global_asm.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ pub fn expand_global_asm<'cx>(cx: &'cx mut ExtCtxt,
2929
sp,
3030
feature_gate::GateIssue::Language,
3131
feature_gate::EXPLAIN_GLOBAL_ASM);
32-
return DummyResult::any(sp);
3332
}
3433

3534
let mut p = cx.new_parser_from_tts(tts);

src/libsyntax_ext/log_syntax.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ pub fn expand_syntax_ext<'cx>(cx: &'cx mut base::ExtCtxt,
1414
sp,
1515
feature_gate::GateIssue::Language,
1616
feature_gate::EXPLAIN_LOG_SYNTAX);
17-
return base::DummyResult::any(sp);
1817
}
1918

2019
println!("{}", print::pprust::tts_to_string(tts));

src/libsyntax_ext/test_case.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ pub fn expand(
3131
attr_sp,
3232
feature_gate::GateIssue::Language,
3333
feature_gate::EXPLAIN_CUSTOM_TEST_FRAMEWORKS);
34-
35-
return vec![anno_item];
3634
}
3735

3836
if !ecx.ecfg.should_test { return vec![]; }

src/libsyntax_ext/trace_macros.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ pub fn expand_trace_macros(cx: &mut ExtCtxt,
1515
sp,
1616
feature_gate::GateIssue::Language,
1717
feature_gate::EXPLAIN_TRACE_MACROS);
18-
return base::DummyResult::any(sp);
1918
}
2019

2120
match (tt.len(), tt.first()) {

0 commit comments

Comments
 (0)