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

+2-4
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

-1
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

-1
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

-1
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

-1
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

-1
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

-1
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

-1
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

-2
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

-1
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()) {

src/test/ui/feature-gates/feature-gate-asm2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212

1313
fn main() {
1414
unsafe {
15-
println!("{}", asm!("")); //~ ERROR inline assembly is not stable
15+
println!("{:?}", asm!("")); //~ ERROR inline assembly is not stable
1616
}
1717
}

src/test/ui/feature-gates/feature-gate-asm2.stderr

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

src/test/ui/feature-gates/feature-gate-concat_idents2.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@
1212

1313
fn main() {
1414
concat_idents!(a, b); //~ ERROR `concat_idents` is not stable enough
15+
//~| ERROR cannot find value `ab` in this scope
1516
}

src/test/ui/feature-gates/feature-gate-concat_idents2.stderr

+9-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ LL | concat_idents!(a, b); //~ ERROR `concat_idents` is not stable enough
66
|
77
= help: add #![feature(concat_idents)] to the crate attributes to enable
88

9-
error: aborting due to previous error
9+
error[E0425]: cannot find value `ab` in this scope
10+
--> $DIR/feature-gate-concat_idents2.rs:14:5
11+
|
12+
LL | concat_idents!(a, b); //~ ERROR `concat_idents` is not stable enough
13+
| ^^^^^^^^^^^^^^^^^^^^^ not found in this scope
14+
15+
error: aborting due to 2 previous errors
1016

11-
For more information about this error, try `rustc --explain E0658`.
17+
Some errors occurred: E0425, E0658.
18+
For more information about an error, try `rustc --explain E0425`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

src/test/ui/feature-gates/feature-gate-log_syntax2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
// gate-test-log_syntax
1212

1313
fn main() {
14-
println!("{}", log_syntax!()); //~ ERROR `log_syntax!` is not stable
14+
println!("{:?}", log_syntax!()); //~ ERROR `log_syntax!` is not stable
1515
}

src/test/ui/feature-gates/feature-gate-log_syntax2.stderr

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

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

src/test/ui/trace_macros-gate.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,9 @@
1212

1313
fn main() {
1414
trace_macros!(); //~ ERROR `trace_macros` is not stable
15-
trace_macros!(1); //~ ERROR `trace_macros` is not stable
16-
trace_macros!(ident); //~ ERROR `trace_macros` is not stable
17-
trace_macros!(for); //~ ERROR `trace_macros` is not stable
18-
trace_macros!(true,); //~ ERROR `trace_macros` is not stable
19-
trace_macros!(false 1); //~ ERROR `trace_macros` is not stable
20-
21-
// Errors are signalled early for the above, before expansion.
22-
// See trace_macros-gate2 and trace_macros-gate3. for examples
23-
// of the below being caught.
15+
//~| ERROR trace_macros! accepts only `true` or `false`
16+
trace_macros!(true); //~ ERROR `trace_macros` is not stable
17+
trace_macros!(false); //~ ERROR `trace_macros` is not stable
2418

2519
macro_rules! expando {
2620
($x: ident) => { trace_macros!($x) } //~ ERROR `trace_macros` is not stable

src/test/ui/trace_macros-gate.stderr

+9-27
Original file line numberDiff line numberDiff line change
@@ -6,48 +6,30 @@ LL | trace_macros!(); //~ ERROR `trace_macros` is not stable
66
|
77
= help: add #![feature(trace_macros)] to the crate attributes to enable
88

9-
error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598)
10-
--> $DIR/trace_macros-gate.rs:15:5
11-
|
12-
LL | trace_macros!(1); //~ ERROR `trace_macros` is not stable
13-
| ^^^^^^^^^^^^^^^^^
9+
error: trace_macros! accepts only `true` or `false`
10+
--> $DIR/trace_macros-gate.rs:14:5
1411
|
15-
= help: add #![feature(trace_macros)] to the crate attributes to enable
12+
LL | trace_macros!(); //~ ERROR `trace_macros` is not stable
13+
| ^^^^^^^^^^^^^^^^
1614

1715
error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598)
1816
--> $DIR/trace_macros-gate.rs:16:5
1917
|
20-
LL | trace_macros!(ident); //~ ERROR `trace_macros` is not stable
21-
| ^^^^^^^^^^^^^^^^^^^^^
18+
LL | trace_macros!(true); //~ ERROR `trace_macros` is not stable
19+
| ^^^^^^^^^^^^^^^^^^^^
2220
|
2321
= help: add #![feature(trace_macros)] to the crate attributes to enable
2422

2523
error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598)
2624
--> $DIR/trace_macros-gate.rs:17:5
2725
|
28-
LL | trace_macros!(for); //~ ERROR `trace_macros` is not stable
29-
| ^^^^^^^^^^^^^^^^^^^
30-
|
31-
= help: add #![feature(trace_macros)] to the crate attributes to enable
32-
33-
error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598)
34-
--> $DIR/trace_macros-gate.rs:18:5
35-
|
36-
LL | trace_macros!(true,); //~ ERROR `trace_macros` is not stable
26+
LL | trace_macros!(false); //~ ERROR `trace_macros` is not stable
3727
| ^^^^^^^^^^^^^^^^^^^^^
3828
|
3929
= help: add #![feature(trace_macros)] to the crate attributes to enable
4030

4131
error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598)
42-
--> $DIR/trace_macros-gate.rs:19:5
43-
|
44-
LL | trace_macros!(false 1); //~ ERROR `trace_macros` is not stable
45-
| ^^^^^^^^^^^^^^^^^^^^^^^
46-
|
47-
= help: add #![feature(trace_macros)] to the crate attributes to enable
48-
49-
error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598)
50-
--> $DIR/trace_macros-gate.rs:26:26
32+
--> $DIR/trace_macros-gate.rs:20:26
5133
|
5234
LL | ($x: ident) => { trace_macros!($x) } //~ ERROR `trace_macros` is not stable
5335
| ^^^^^^^^^^^^^^^^^
@@ -57,6 +39,6 @@ LL | expando!(true);
5739
|
5840
= help: add #![feature(trace_macros)] to the crate attributes to enable
5941

60-
error: aborting due to 7 previous errors
42+
error: aborting due to 5 previous errors
6143

6244
For more information about this error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)