Skip to content

Commit 29f3d7b

Browse files
committed
Make sure feature gate errors are recoverable
1 parent a053ae2 commit 29f3d7b

20 files changed

+34
-60
lines changed

src/librustc/lint/levels.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,24 +232,22 @@ impl<'a> LintLevelsBuilder<'a> {
232232
match item.node {
233233
ast::MetaItemKind::Word => {} // actual lint names handled later
234234
ast::MetaItemKind::NameValue(ref name_value) => {
235-
let gate_reasons = !self.sess.features_untracked().lint_reasons;
236235
if item.ident == "reason" {
237236
// found reason, reslice meta list to exclude it
238237
metas = &metas[0..metas.len()-1];
239238
// FIXME (#55112): issue unused-attributes lint if we thereby
240239
// don't have any lint names (`#[level(reason = "foo")]`)
241240
if let ast::LitKind::Str(rationale, _) = name_value.node {
242-
if gate_reasons {
241+
if !self.sess.features_untracked().lint_reasons {
243242
feature_gate::emit_feature_err(
244243
&self.sess.parse_sess,
245244
"lint_reasons",
246245
item.span,
247246
feature_gate::GateIssue::Language,
248247
"lint reasons are experimental"
249248
);
250-
} else {
251-
reason = Some(rationale);
252249
}
250+
reason = Some(rationale);
253251
} else {
254252
let mut err = bad_attr(name_value.span);
255253
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
@@ -2220,7 +2220,6 @@ fn from_target_feature(
22202220
feature_gate::GateIssue::Language,
22212221
&format!("the target feature `{}` is currently unstable", feature),
22222222
);
2223-
return None;
22242223
}
22252224
Some(Symbol::intern(feature))
22262225
}));

src/libsyntax/ext/expand.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,6 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
732732
emit_feature_err(this.cx.parse_sess, &*feature.as_str(), span,
733733
GateIssue::Library(Some(issue)), &explain);
734734
this.cx.trace_macros_diag();
735-
return Err(kind.dummy(span));
736735
}
737736
}
738737

src/libsyntax_ext/asm.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt,
5959
sp,
6060
feature_gate::GateIssue::Language,
6161
feature_gate::EXPLAIN_ASM);
62-
return DummyResult::expr(sp);
6362
}
6463

6564
// 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
@@ -30,7 +30,6 @@ pub fn expand_syntax_ext<'cx>(cx: &'cx mut ExtCtxt,
3030
sp,
3131
feature_gate::GateIssue::Language,
3232
feature_gate::EXPLAIN_CONCAT_IDENTS);
33-
return base::DummyResult::expr(sp);
3433
}
3534

3635
if tts.is_empty() {

src/libsyntax_ext/format.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,6 @@ pub fn expand_format_args_nl<'cx>(
723723
sp,
724724
feature_gate::GateIssue::Language,
725725
feature_gate::EXPLAIN_FORMAT_ARGS_NL);
726-
return DummyResult::expr(sp);
727726
}
728727
sp = sp.apply_mark(ecx.current_expansion.mark);
729728
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
@@ -39,7 +39,6 @@ pub fn expand_global_asm<'cx>(cx: &'cx mut ExtCtxt,
3939
sp,
4040
feature_gate::GateIssue::Language,
4141
feature_gate::EXPLAIN_GLOBAL_ASM);
42-
return DummyResult::any(sp);
4342
}
4443

4544
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
@@ -24,7 +24,6 @@ pub fn expand_syntax_ext<'cx>(cx: &'cx mut base::ExtCtxt,
2424
sp,
2525
feature_gate::GateIssue::Language,
2626
feature_gate::EXPLAIN_LOG_SYNTAX);
27-
return base::DummyResult::any(sp);
2827
}
2928

3029
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
@@ -39,8 +39,6 @@ pub fn expand(
3939
attr_sp,
4040
feature_gate::GateIssue::Language,
4141
feature_gate::EXPLAIN_CUSTOM_TEST_FRAMEWORKS);
42-
43-
return vec![anno_item];
4442
}
4543

4644
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
@@ -25,7 +25,6 @@ pub fn expand_trace_macros(cx: &mut ExtCtxt,
2525
sp,
2626
feature_gate::GateIssue::Language,
2727
feature_gate::EXPLAIN_TRACE_MACROS);
28-
return base::DummyResult::any(sp);
2928
}
3029

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

0 commit comments

Comments
 (0)