Skip to content

Commit 3ab9706

Browse files
committed
Tweak unstable diagnostic output
1 parent 96d700f commit 3ab9706

File tree

172 files changed

+842
-453
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+842
-453
lines changed

src/libsyntax/feature_gate.rs

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ pub const BUILTIN_ATTRIBUTES: &[(&str, AttributeType, AttributeTemplate, Attribu
903903
("thread_local", Whitelisted, template!(Word), Gated(Stability::Unstable,
904904
"thread_local",
905905
"`#[thread_local]` is an experimental feature, and does \
906-
not currently handle destructors.",
906+
not currently handle destructors",
907907
cfg_fn!(thread_local))),
908908

909909
("rustc_on_unimplemented", Whitelisted, template!(List:
@@ -1438,42 +1438,58 @@ pub enum GateStrength {
14381438
Soft,
14391439
}
14401440

1441-
pub fn emit_feature_err(sess: &ParseSess, feature: &str, span: Span, issue: GateIssue,
1442-
explain: &str) {
1441+
pub fn emit_feature_err(
1442+
sess: &ParseSess,
1443+
feature: &str,
1444+
span: Span,
1445+
issue: GateIssue,
1446+
explain: &str,
1447+
) {
14431448
feature_err(sess, feature, span, issue, explain).emit();
14441449
}
14451450

1446-
pub fn feature_err<'a>(sess: &'a ParseSess, feature: &str, span: Span, issue: GateIssue,
1447-
explain: &str) -> DiagnosticBuilder<'a> {
1451+
pub fn feature_err<'a>(
1452+
sess: &'a ParseSess,
1453+
feature: &str,
1454+
span: Span,
1455+
issue: GateIssue,
1456+
explain: &str,
1457+
) -> DiagnosticBuilder<'a> {
14481458
leveled_feature_err(sess, feature, span, issue, explain, GateStrength::Hard)
14491459
}
14501460

1451-
fn leveled_feature_err<'a>(sess: &'a ParseSess, feature: &str, span: Span, issue: GateIssue,
1452-
explain: &str, level: GateStrength) -> DiagnosticBuilder<'a> {
1461+
fn leveled_feature_err<'a>(
1462+
sess: &'a ParseSess,
1463+
feature: &str,
1464+
span: Span,
1465+
issue: GateIssue,
1466+
explain: &str,
1467+
level: GateStrength,
1468+
) -> DiagnosticBuilder<'a> {
14531469
let diag = &sess.span_diagnostic;
14541470

14551471
let issue = match issue {
14561472
GateIssue::Language => find_lang_feature_issue(feature),
14571473
GateIssue::Library(lib) => lib,
14581474
};
14591475

1460-
let explanation = match issue {
1461-
None | Some(0) => explain.to_owned(),
1462-
Some(n) => format!("{} (see issue #{})", explain, n)
1463-
};
1464-
14651476
let mut err = match level {
14661477
GateStrength::Hard => {
1467-
diag.struct_span_err_with_code(span, &explanation, stringify_error_code!(E0658))
1478+
diag.struct_span_err_with_code(span, explain, stringify_error_code!(E0658))
14681479
}
1469-
GateStrength::Soft => diag.struct_span_warn(span, &explanation),
1480+
GateStrength::Soft => diag.struct_span_warn(span, explain),
14701481
};
14711482

1483+
match issue {
1484+
None | Some(0) => {}
1485+
Some(n) => {
1486+
err.note(&format!("for more information, see tracking issue #{}", n));
1487+
}
1488+
}
1489+
14721490
// #23973: do not suggest `#![feature(...)]` if we are in beta/stable
14731491
if sess.unstable_features.is_nightly_build() {
1474-
err.help(&format!("add #![feature({})] to the \
1475-
crate attributes to enable",
1476-
feature));
1492+
err.help(&format!("add #![feature({})] to the crate attributes to enable", feature));
14771493
}
14781494

14791495
// If we're on stable and only emitting a "soft" warning, add a note to
@@ -1488,10 +1504,10 @@ fn leveled_feature_err<'a>(sess: &'a ParseSess, feature: &str, span: Span, issue
14881504
}
14891505

14901506
const EXPLAIN_BOX_SYNTAX: &str =
1491-
"box expression syntax is experimental; you can call `Box::new` instead.";
1507+
"box expression syntax is experimental; you can call `Box::new` instead";
14921508

14931509
pub const EXPLAIN_STMT_ATTR_SYNTAX: &str =
1494-
"attributes on expressions are experimental.";
1510+
"attributes on expressions are experimental";
14951511

14961512
pub const EXPLAIN_ASM: &str =
14971513
"inline assembly is not stable enough for use and is subject to change";
@@ -1685,10 +1701,12 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
16851701

16861702
fn visit_name(&mut self, sp: Span, name: ast::Name) {
16871703
if !name.as_str().is_ascii() {
1688-
gate_feature_post!(&self,
1689-
non_ascii_idents,
1690-
self.context.parse_sess.source_map().def_span(sp),
1691-
"non-ascii idents are not fully supported.");
1704+
gate_feature_post!(
1705+
&self,
1706+
non_ascii_idents,
1707+
self.context.parse_sess.source_map().def_span(sp),
1708+
"non-ascii idents are not fully supported"
1709+
);
16921710
}
16931711
}
16941712

src/libsyntax/json.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -348,19 +348,17 @@ impl DiagnosticSpanLine {
348348
/// `span` within the line.
349349
fn from_span(span: Span, je: &JsonEmitter) -> Vec<DiagnosticSpanLine> {
350350
je.sm.span_to_lines(span)
351-
.map(|lines| {
352-
let fm = &*lines.file;
353-
lines.lines
354-
.iter()
355-
.map(|line| {
356-
DiagnosticSpanLine::line_from_source_file(fm,
357-
line.line_index,
358-
line.start_col.0 + 1,
359-
line.end_col.0 + 1)
360-
})
361-
.collect()
362-
})
363-
.unwrap_or_else(|_| vec![])
351+
.map(|lines| {
352+
let fm = &*lines.file;
353+
lines.lines
354+
.iter()
355+
.map(|line| DiagnosticSpanLine::line_from_source_file(
356+
fm,
357+
line.line_index,
358+
line.start_col.0 + 1,
359+
line.end_col.0 + 1,
360+
)).collect()
361+
}).unwrap_or_else(|_| vec![])
364362
}
365363
}
366364

src/test/ui/cast/cast-ptr-to-int-const.stderr

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
error[E0658]: casting pointers to integers in constants is unstable (see issue #51910)
1+
error[E0658]: casting pointers to integers in constants is unstable
22
--> $DIR/cast-ptr-to-int-const.rs:5:9
33
|
44
LL | main as u32
55
| ^^^^^^^^^^^
66
|
7+
= note: for more information, see tracking issue #51910
78
= help: add #![feature(const_raw_ptr_to_usize_cast)] to the crate attributes to enable
89

9-
error[E0658]: casting pointers to integers in constants is unstable (see issue #51910)
10+
error[E0658]: casting pointers to integers in constants is unstable
1011
--> $DIR/cast-ptr-to-int-const.rs:9:9
1112
|
1213
LL | &Y as *const u32 as u32
1314
| ^^^^^^^^^^^^^^^^^^^^^^^
1415
|
16+
= note: for more information, see tracking issue #51910
1517
= help: add #![feature(const_raw_ptr_to_usize_cast)] to the crate attributes to enable
1618

1719
error: aborting due to 2 previous errors

src/test/ui/conditional-compilation/cfg-attr-crate-2.stderr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
error[E0658]: no_core is experimental (see issue #29639)
1+
error[E0658]: no_core is experimental
22
--> $DIR/cfg-attr-crate-2.rs:6:21
33
|
44
LL | #![cfg_attr(broken, no_core)]
55
| ^^^^^^^
66
|
7+
= note: for more information, see tracking issue #29639
78
= help: add #![feature(no_core)] to the crate attributes to enable
89

910
error: aborting due to previous error

src/test/ui/conditional-compilation/cfg-attr-multi-invalid-1.stderr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
error[E0658]: no_core is experimental (see issue #29639)
1+
error[E0658]: no_core is experimental
22
--> $DIR/cfg-attr-multi-invalid-1.rs:4:21
33
|
44
LL | #![cfg_attr(broken, no_core, no_std)]
55
| ^^^^^^^
66
|
7+
= note: for more information, see tracking issue #29639
78
= help: add #![feature(no_core)] to the crate attributes to enable
89

910
error: aborting due to previous error

src/test/ui/conditional-compilation/cfg-attr-multi-invalid-2.stderr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
error[E0658]: no_core is experimental (see issue #29639)
1+
error[E0658]: no_core is experimental
22
--> $DIR/cfg-attr-multi-invalid-2.rs:4:29
33
|
44
LL | #![cfg_attr(broken, no_std, no_core)]
55
| ^^^^^^^
66
|
7+
= note: for more information, see tracking issue #29639
78
= help: add #![feature(no_core)] to the crate attributes to enable
89

910
error: aborting due to previous error

src/test/ui/conditional-compilation/cfg-attr-unknown-attribute-macro-expansion.stderr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0658]: The attribute `unknown` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
1+
error[E0658]: The attribute `unknown` is currently unknown to the compiler and may have meaning added to it in the future
22
--> $DIR/cfg-attr-unknown-attribute-macro-expansion.rs:3:27
33
|
44
LL | #[cfg_attr(all(), unknown)]
@@ -7,6 +7,7 @@ LL | #[cfg_attr(all(), unknown)]
77
LL | foo!();
88
| ------- in this macro invocation
99
|
10+
= note: for more information, see tracking issue #29642
1011
= help: add #![feature(custom_attribute)] to the crate attributes to enable
1112

1213
error: aborting due to previous error

src/test/ui/consts/const-deref-ptr.stderr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
error[E0658]: dereferencing raw pointers in statics is unstable (see issue #51911)
1+
error[E0658]: dereferencing raw pointers in statics is unstable
22
--> $DIR/const-deref-ptr.rs:4:29
33
|
44
LL | static C: u64 = unsafe {*(0xdeadbeef as *const u64)};
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
7+
= note: for more information, see tracking issue #51911
78
= help: add #![feature(const_raw_ptr_deref)] to the crate attributes to enable
89

910
error: aborting due to previous error

src/test/ui/consts/const-eval/feature-gate-const_fn_union.stderr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
error[E0658]: unions in const fn are unstable (see issue #51909)
1+
error[E0658]: unions in const fn are unstable
22
--> $DIR/feature-gate-const_fn_union.rs:11:5
33
|
44
LL | Foo { u }.i
55
| ^^^^^^^^^^^
66
|
7+
= note: for more information, see tracking issue #51909
78
= help: add #![feature(const_fn_union)] to the crate attributes to enable
89

910
error: aborting due to previous error

src/test/ui/consts/const-eval/feature-gate-const_panic.stderr

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
1-
error[E0658]: panicking in constants is unstable (see issue #51999)
1+
error[E0658]: panicking in constants is unstable
22
--> $DIR/feature-gate-const_panic.rs:3:15
33
|
44
LL | const Z: () = panic!("cheese");
55
| ^^^^^^^^^^^^^^^^
66
|
7+
= note: for more information, see tracking issue #51999
78
= help: add #![feature(const_panic)] to the crate attributes to enable
89
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
910

10-
error[E0658]: panicking in constants is unstable (see issue #51999)
11+
error[E0658]: panicking in constants is unstable
1112
--> $DIR/feature-gate-const_panic.rs:9:15
1213
|
1314
LL | const X: () = unimplemented!();
1415
| ^^^^^^^^^^^^^^^^
1516
|
17+
= note: for more information, see tracking issue #51999
1618
= help: add #![feature(const_panic)] to the crate attributes to enable
1719
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
1820

19-
error[E0658]: panicking in constants is unstable (see issue #51999)
21+
error[E0658]: panicking in constants is unstable
2022
--> $DIR/feature-gate-const_panic.rs:6:15
2123
|
2224
LL | const Y: () = unreachable!();
2325
| ^^^^^^^^^^^^^^
2426
|
27+
= note: for more information, see tracking issue #51999
2528
= help: add #![feature(const_panic)] to the crate attributes to enable
2629
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
2730

src/test/ui/consts/const-eval/match-test-ptr-null.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ fn main() {
33
// that pointer comparison is disallowed, not that parts of a pointer are accessed as raw
44
// bytes.
55
let _: [u8; 0] = [4; {
6-
match &1 as *const i32 as usize { //~ ERROR casting pointers to integers in constants
6+
match &1 as *const i32 as usize {
7+
//~^ ERROR casting pointers to integers in constants
8+
//~| NOTE for more information, see tracking issue #51910
79
0 => 42, //~ ERROR constant contains unimplemented expression type
810
//~^ NOTE "pointer arithmetic or comparison" needs an rfc before being allowed
911
//~| ERROR evaluation of constant value failed

src/test/ui/consts/const-eval/match-test-ptr-null.stderr

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
error[E0658]: casting pointers to integers in constants is unstable (see issue #51910)
1+
error[E0658]: casting pointers to integers in constants is unstable
22
--> $DIR/match-test-ptr-null.rs:6:15
33
|
44
LL | match &1 as *const i32 as usize {
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
7+
= note: for more information, see tracking issue #51910
78
= help: add #![feature(const_raw_ptr_to_usize_cast)] to the crate attributes to enable
89

910
error[E0019]: constant contains unimplemented expression type
10-
--> $DIR/match-test-ptr-null.rs:7:13
11+
--> $DIR/match-test-ptr-null.rs:9:13
1112
|
1213
LL | 0 => 42,
1314
| ^
1415

1516
error[E0080]: evaluation of constant value failed
16-
--> $DIR/match-test-ptr-null.rs:7:13
17+
--> $DIR/match-test-ptr-null.rs:9:13
1718
|
1819
LL | 0 => 42,
1920
| ^ "pointer arithmetic or comparison" needs an rfc before being allowed inside constants

src/test/ui/consts/min_const_fn/min_const_fn_unsafe.stderr

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,37 @@
1-
error[E0658]: dereferencing raw pointers in constant functions is unstable (see issue #51911)
1+
error[E0658]: dereferencing raw pointers in constant functions is unstable
22
--> $DIR/min_const_fn_unsafe.rs:50:77
33
|
44
LL | const fn bad_const_fn_deref_raw(x: *mut usize) -> &'static usize { unsafe { &*x } }
55
| ^^^
66
|
7+
= note: for more information, see tracking issue #51911
78
= help: add #![feature(const_raw_ptr_deref)] to the crate attributes to enable
89

9-
error[E0658]: dereferencing raw pointers in constant functions is unstable (see issue #51911)
10+
error[E0658]: dereferencing raw pointers in constant functions is unstable
1011
--> $DIR/min_const_fn_unsafe.rs:53:70
1112
|
1213
LL | const unsafe fn bad_const_unsafe_deref_raw(x: *mut usize) -> usize { *x }
1314
| ^^
1415
|
16+
= note: for more information, see tracking issue #51911
1517
= help: add #![feature(const_raw_ptr_deref)] to the crate attributes to enable
1618

17-
error[E0658]: dereferencing raw pointers in constant functions is unstable (see issue #51911)
19+
error[E0658]: dereferencing raw pointers in constant functions is unstable
1820
--> $DIR/min_const_fn_unsafe.rs:56:83
1921
|
2022
LL | const unsafe fn bad_const_unsafe_deref_raw_ref(x: *mut usize) -> &'static usize { &*x }
2123
| ^^^
2224
|
25+
= note: for more information, see tracking issue #51911
2326
= help: add #![feature(const_raw_ptr_deref)] to the crate attributes to enable
2427

25-
error[E0658]: unions in const fn are unstable (see issue #51909)
28+
error[E0658]: unions in const fn are unstable
2629
--> $DIR/min_const_fn_unsafe.rs:63:5
2730
|
2831
LL | Foo { x: () }.y
2932
| ^^^^^^^^^^^^^^^
3033
|
34+
= note: for more information, see tracking issue #51909
3135
= help: add #![feature(const_fn_union)] to the crate attributes to enable
3236

3337
error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block

src/test/ui/consts/projection_qualif.stderr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ error[E0019]: constant contains unimplemented expression type
1010
LL | unsafe { *b = 5; }
1111
| ^^^^^^
1212

13-
error[E0658]: dereferencing raw pointers in constants is unstable (see issue #51911)
13+
error[E0658]: dereferencing raw pointers in constants is unstable
1414
--> $DIR/projection_qualif.rs:7:18
1515
|
1616
LL | unsafe { *b = 5; }
1717
| ^^^^^^
1818
|
19+
= note: for more information, see tracking issue #51911
1920
= help: add #![feature(const_raw_ptr_deref)] to the crate attributes to enable
2021

2122
error: aborting due to 3 previous errors

src/test/ui/custom_attribute.stderr

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
1-
error[E0658]: The attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
1+
error[E0658]: The attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future
22
--> $DIR/custom_attribute.rs:3:3
33
|
44
LL | #[foo]
55
| ^^^
66
|
7+
= note: for more information, see tracking issue #29642
78
= help: add #![feature(custom_attribute)] to the crate attributes to enable
89

9-
error[E0658]: The attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
10+
error[E0658]: The attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future
1011
--> $DIR/custom_attribute.rs:5:7
1112
|
1213
LL | #[foo]
1314
| ^^^
1415
|
16+
= note: for more information, see tracking issue #29642
1517
= help: add #![feature(custom_attribute)] to the crate attributes to enable
1618

17-
error[E0658]: The attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
19+
error[E0658]: The attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future
1820
--> $DIR/custom_attribute.rs:7:7
1921
|
2022
LL | #[foo]
2123
| ^^^
2224
|
25+
= note: for more information, see tracking issue #29642
2326
= help: add #![feature(custom_attribute)] to the crate attributes to enable
2427

2528
error: aborting due to 3 previous errors

0 commit comments

Comments
 (0)