Skip to content

Commit b9d09b0

Browse files
author
Ariel Ben-Yehuda
committed
improve error messages
1 parent 8cdba69 commit b9d09b0

10 files changed

Lines changed: 179 additions & 72 deletions

compiler/rustc_metadata/messages.ftl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ metadata_missing_native_library =
154154
could not find native static library `{$libname}`, perhaps an -L flag is missing?
155155
156156
metadata_mitigation_less_strict_in_dependency =
157-
your program uses the crate `{$extern_crate}`, that is not protected by `{$mitigation_name}{$mitigation_level}`
158-
.note = recompile `{$extern_crate}` with the mitigation enabled, or use `-Z allow-partial-mitigations={$mitigation_name}` to allow creating an artifact that has the mitigation only partially enabled
157+
your program uses the crate `{$extern_crate}`, that is not compiled with `{$mitigation_name}{$mitigation_level}` enabled
158+
.note = recompile `{$extern_crate}` with `{$mitigation_name}{$mitigation_level}` enabled, or use `-Z allow-partial-mitigations={$mitigation_name}` to allow creating an artifact that has the mitigation only partially enabled
159159
.help = it is possible to disable `-Z allow-partial-mitigations={$mitigation_name}` via `-Z allow-partial-mitigations=!{$mitigation_name}`
160160
161161
metadata_multiple_candidates =

compiler/rustc_metadata/src/errors.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,8 @@ pub struct RawDylibMalformed {
618618

619619
#[derive(Diagnostic)]
620620
#[diag(metadata_mitigation_less_strict_in_dependency)]
621+
#[help]
622+
#[note]
621623
pub struct MitigationLessStrictInDependency {
622624
#[primary_span]
623625
pub span: Span,

tests/ui/allow-partial-mitigations/err-allow-partial-mitigations-current-edition.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
// disallowed by default)
1111

1212
fn main() {}
13-
//~^ ERROR that is not protected by
14-
//~| ERROR that is not protected by
15-
//~| ERROR that is not protected by
16-
//~| ERROR that is not protected by
17-
//~| ERROR that is not protected by
13+
//~^ ERROR that is not compiled with
14+
//~| ERROR that is not compiled with
15+
//~| ERROR that is not compiled with
16+
//~| ERROR that is not compiled with
17+
//~| ERROR that is not compiled with
Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,47 @@
1-
error: your program uses the crate `std`, that is not protected by `control-flow-guard`
1+
error: your program uses the crate `std`, that is not compiled with `control-flow-guard` enabled
22
--> $DIR/err-allow-partial-mitigations-current-edition.rs:12:1
33
|
44
LL | fn main() {}
55
| ^
6+
|
7+
= help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z allow-partial-mitigations=!control-flow-guard`
8+
= note: recompile `std` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation only partially enabled
69

7-
error: your program uses the crate `core`, that is not protected by `control-flow-guard`
10+
error: your program uses the crate `core`, that is not compiled with `control-flow-guard` enabled
811
--> $DIR/err-allow-partial-mitigations-current-edition.rs:12:1
912
|
1013
LL | fn main() {}
1114
| ^
15+
|
16+
= help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z allow-partial-mitigations=!control-flow-guard`
17+
= note: recompile `core` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation only partially enabled
1218

13-
error: your program uses the crate `alloc`, that is not protected by `control-flow-guard`
19+
error: your program uses the crate `alloc`, that is not compiled with `control-flow-guard` enabled
1420
--> $DIR/err-allow-partial-mitigations-current-edition.rs:12:1
1521
|
1622
LL | fn main() {}
1723
| ^
24+
|
25+
= help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z allow-partial-mitigations=!control-flow-guard`
26+
= note: recompile `alloc` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation only partially enabled
1827

19-
error: your program uses the crate `compiler_builtins`, that is not protected by `control-flow-guard`
28+
error: your program uses the crate `compiler_builtins`, that is not compiled with `control-flow-guard` enabled
2029
--> $DIR/err-allow-partial-mitigations-current-edition.rs:12:1
2130
|
2231
LL | fn main() {}
2332
| ^
33+
|
34+
= help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z allow-partial-mitigations=!control-flow-guard`
35+
= note: recompile `compiler_builtins` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation only partially enabled
2436

25-
error: your program uses the crate `libc`, that is not protected by `control-flow-guard`
37+
error: your program uses the crate `libc`, that is not compiled with `control-flow-guard` enabled
2638
--> $DIR/err-allow-partial-mitigations-current-edition.rs:12:1
2739
|
2840
LL | fn main() {}
2941
| ^
42+
|
43+
= help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z allow-partial-mitigations=!control-flow-guard`
44+
= note: recompile `libc` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation only partially enabled
3045

3146
error: aborting due to 5 previous errors
3247

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,92 @@
1-
error: your program uses the crate `std`, that is not protected by `stack-protector=all`
1+
error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled
22
--> $DIR/err-allow-partial-mitigations.rs:13:1
33
|
44
LL | fn main() {}
55
| ^
6+
|
7+
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z allow-partial-mitigations=!stack-protector`
8+
= note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
69

7-
error: your program uses the crate `std`, that is not protected by `control-flow-guard`
10+
error: your program uses the crate `std`, that is not compiled with `control-flow-guard` enabled
811
--> $DIR/err-allow-partial-mitigations.rs:13:1
912
|
1013
LL | fn main() {}
1114
| ^
15+
|
16+
= help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z allow-partial-mitigations=!control-flow-guard`
17+
= note: recompile `std` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation only partially enabled
1218

13-
error: your program uses the crate `core`, that is not protected by `stack-protector=all`
19+
error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled
1420
--> $DIR/err-allow-partial-mitigations.rs:13:1
1521
|
1622
LL | fn main() {}
1723
| ^
24+
|
25+
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z allow-partial-mitigations=!stack-protector`
26+
= note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
1827

19-
error: your program uses the crate `core`, that is not protected by `control-flow-guard`
28+
error: your program uses the crate `core`, that is not compiled with `control-flow-guard` enabled
2029
--> $DIR/err-allow-partial-mitigations.rs:13:1
2130
|
2231
LL | fn main() {}
2332
| ^
33+
|
34+
= help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z allow-partial-mitigations=!control-flow-guard`
35+
= note: recompile `core` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation only partially enabled
2436

25-
error: your program uses the crate `alloc`, that is not protected by `stack-protector=all`
37+
error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled
2638
--> $DIR/err-allow-partial-mitigations.rs:13:1
2739
|
2840
LL | fn main() {}
2941
| ^
42+
|
43+
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z allow-partial-mitigations=!stack-protector`
44+
= note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
3045

31-
error: your program uses the crate `alloc`, that is not protected by `control-flow-guard`
46+
error: your program uses the crate `alloc`, that is not compiled with `control-flow-guard` enabled
3247
--> $DIR/err-allow-partial-mitigations.rs:13:1
3348
|
3449
LL | fn main() {}
3550
| ^
51+
|
52+
= help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z allow-partial-mitigations=!control-flow-guard`
53+
= note: recompile `alloc` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation only partially enabled
3654

37-
error: your program uses the crate `compiler_builtins`, that is not protected by `stack-protector=all`
55+
error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled
3856
--> $DIR/err-allow-partial-mitigations.rs:13:1
3957
|
4058
LL | fn main() {}
4159
| ^
60+
|
61+
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z allow-partial-mitigations=!stack-protector`
62+
= note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
4263

43-
error: your program uses the crate `compiler_builtins`, that is not protected by `control-flow-guard`
64+
error: your program uses the crate `compiler_builtins`, that is not compiled with `control-flow-guard` enabled
4465
--> $DIR/err-allow-partial-mitigations.rs:13:1
4566
|
4667
LL | fn main() {}
4768
| ^
69+
|
70+
= help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z allow-partial-mitigations=!control-flow-guard`
71+
= note: recompile `compiler_builtins` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation only partially enabled
4872

49-
error: your program uses the crate `libc`, that is not protected by `stack-protector=all`
73+
error: your program uses the crate `libc`, that is not compiled with `stack-protector=all` enabled
5074
--> $DIR/err-allow-partial-mitigations.rs:13:1
5175
|
5276
LL | fn main() {}
5377
| ^
78+
|
79+
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z allow-partial-mitigations=!stack-protector`
80+
= note: recompile `libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
5481

55-
error: your program uses the crate `libc`, that is not protected by `control-flow-guard`
82+
error: your program uses the crate `libc`, that is not compiled with `control-flow-guard` enabled
5683
--> $DIR/err-allow-partial-mitigations.rs:13:1
5784
|
5885
LL | fn main() {}
5986
| ^
87+
|
88+
= help: it is possible to disable `-Z allow-partial-mitigations=control-flow-guard` via `-Z allow-partial-mitigations=!control-flow-guard`
89+
= note: recompile `libc` with `control-flow-guard` enabled, or use `-Z allow-partial-mitigations=control-flow-guard` to allow creating an artifact that has the mitigation only partially enabled
6090

6191
error: aborting due to 10 previous errors
6292

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,47 @@
1-
error: your program uses the crate `std`, that is not protected by `stack-protector=all`
1+
error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled
22
--> $DIR/err-allow-partial-mitigations.rs:13:1
33
|
44
LL | fn main() {}
55
| ^
6+
|
7+
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z allow-partial-mitigations=!stack-protector`
8+
= note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
69

7-
error: your program uses the crate `core`, that is not protected by `stack-protector=all`
10+
error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled
811
--> $DIR/err-allow-partial-mitigations.rs:13:1
912
|
1013
LL | fn main() {}
1114
| ^
15+
|
16+
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z allow-partial-mitigations=!stack-protector`
17+
= note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
1218

13-
error: your program uses the crate `alloc`, that is not protected by `stack-protector=all`
19+
error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled
1420
--> $DIR/err-allow-partial-mitigations.rs:13:1
1521
|
1622
LL | fn main() {}
1723
| ^
24+
|
25+
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z allow-partial-mitigations=!stack-protector`
26+
= note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
1827

19-
error: your program uses the crate `compiler_builtins`, that is not protected by `stack-protector=all`
28+
error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled
2029
--> $DIR/err-allow-partial-mitigations.rs:13:1
2130
|
2231
LL | fn main() {}
2332
| ^
33+
|
34+
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z allow-partial-mitigations=!stack-protector`
35+
= note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
2436

25-
error: your program uses the crate `libc`, that is not protected by `stack-protector=all`
37+
error: your program uses the crate `libc`, that is not compiled with `stack-protector=all` enabled
2638
--> $DIR/err-allow-partial-mitigations.rs:13:1
2739
|
2840
LL | fn main() {}
2941
| ^
42+
|
43+
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z allow-partial-mitigations=!stack-protector`
44+
= note: recompile `libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
3045

3146
error: aborting due to 5 previous errors
3247

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,47 @@
1-
error: your program uses the crate `std`, that is not protected by `stack-protector=all`
1+
error: your program uses the crate `std`, that is not compiled with `stack-protector=all` enabled
22
--> $DIR/err-allow-partial-mitigations.rs:13:1
33
|
44
LL | fn main() {}
55
| ^
6+
|
7+
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z allow-partial-mitigations=!stack-protector`
8+
= note: recompile `std` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
69

7-
error: your program uses the crate `core`, that is not protected by `stack-protector=all`
10+
error: your program uses the crate `core`, that is not compiled with `stack-protector=all` enabled
811
--> $DIR/err-allow-partial-mitigations.rs:13:1
912
|
1013
LL | fn main() {}
1114
| ^
15+
|
16+
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z allow-partial-mitigations=!stack-protector`
17+
= note: recompile `core` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
1218

13-
error: your program uses the crate `alloc`, that is not protected by `stack-protector=all`
19+
error: your program uses the crate `alloc`, that is not compiled with `stack-protector=all` enabled
1420
--> $DIR/err-allow-partial-mitigations.rs:13:1
1521
|
1622
LL | fn main() {}
1723
| ^
24+
|
25+
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z allow-partial-mitigations=!stack-protector`
26+
= note: recompile `alloc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
1827

19-
error: your program uses the crate `compiler_builtins`, that is not protected by `stack-protector=all`
28+
error: your program uses the crate `compiler_builtins`, that is not compiled with `stack-protector=all` enabled
2029
--> $DIR/err-allow-partial-mitigations.rs:13:1
2130
|
2231
LL | fn main() {}
2332
| ^
33+
|
34+
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z allow-partial-mitigations=!stack-protector`
35+
= note: recompile `compiler_builtins` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
2436

25-
error: your program uses the crate `libc`, that is not protected by `stack-protector=all`
37+
error: your program uses the crate `libc`, that is not compiled with `stack-protector=all` enabled
2638
--> $DIR/err-allow-partial-mitigations.rs:13:1
2739
|
2840
LL | fn main() {}
2941
| ^
42+
|
43+
= help: it is possible to disable `-Z allow-partial-mitigations=stack-protector` via `-Z allow-partial-mitigations=!stack-protector`
44+
= note: recompile `libc` with `stack-protector=all` enabled, or use `-Z allow-partial-mitigations=stack-protector` to allow creating an artifact that has the mitigation only partially enabled
3045

3146
error: aborting due to 5 previous errors
3247

0 commit comments

Comments
 (0)