Skip to content

Commit 850faea

Browse files
committed
Do not use question as label
We don't want to have questions in the diagnostic output. Instead, we use wording that communicates uncertainty, like "might": ``` error[E0432]: unresolved import `spam` --> $DIR/import-from-missing-star-3.rs:2:9 | LL | use spam::*; | ^^^^ you might be missing crate `spam` | = help: consider adding `extern crate spam` to use the `spam` crate ```
1 parent 6106b05 commit 850faea

Some content is hidden

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

44 files changed

+159
-151
lines changed

compiler/rustc_resolve/src/diagnostics.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2012,7 +2012,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
20122012
)
20132013
} else if ident.name == sym::core {
20142014
(
2015-
format!("maybe a missing crate `{ident}`?"),
2015+
format!("you might be missing crate `{ident}`"),
20162016
Some((
20172017
vec![(ident.span, "std".to_string())],
20182018
"try using `std` instead of `core`".to_string(),
@@ -2021,7 +2021,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
20212021
)
20222022
} else if self.tcx.sess.is_rust_2015() {
20232023
(
2024-
format!("maybe a missing crate `{ident}`?"),
2024+
format!("you might be missing crate `{ident}`"),
20252025
Some((
20262026
vec![],
20272027
format!(

tests/rustdoc-ui/ice-unresolved-import-100241.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0432]: unresolved import `inner`
22
--> $DIR/ice-unresolved-import-100241.rs:9:13
33
|
44
LL | pub use inner::S;
5-
| ^^^^^ maybe a missing crate `inner`?
5+
| ^^^^^ you might be missing crate `inner`
66
|
77
= help: consider adding `extern crate inner` to use the `inner` crate
88

tests/rustdoc-ui/intra-doc/unresolved-import-recovery.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0433]: failed to resolve: maybe a missing crate `unresolved_crate`?
1+
error[E0433]: failed to resolve: you might be missing crate `unresolved_crate`
22
--> $DIR/unresolved-import-recovery.rs:3:5
33
|
44
LL | use unresolved_crate::module::Name;
5-
| ^^^^^^^^^^^^^^^^ maybe a missing crate `unresolved_crate`?
5+
| ^^^^^^^^^^^^^^^^ you might be missing crate `unresolved_crate`
66
|
77
= help: consider adding `extern crate unresolved_crate` to use the `unresolved_crate` crate
88

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// This previously triggered an ICE.
22

33
pub(in crate::r#mod) fn main() {}
4-
//~^ ERROR failed to resolve: maybe a missing crate `r#mod`
4+
//~^ ERROR failed to resolve: you might be missing crate `r#mod`

tests/rustdoc-ui/issues/issue-61732.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0433]: failed to resolve: maybe a missing crate `r#mod`?
1+
error[E0433]: failed to resolve: you might be missing crate `r#mod`
22
--> $DIR/issue-61732.rs:3:15
33
|
44
LL | pub(in crate::r#mod) fn main() {}
5-
| ^^^^^ maybe a missing crate `r#mod`?
5+
| ^^^^^ you might be missing crate `r#mod`
66
|
77
= help: consider adding `extern crate r#mod` to use the `r#mod` crate
88

tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ enum DiagnosticOnEnum {
5656
#[derive(Diagnostic)]
5757
#[diag(no_crate_example, code = E0123)]
5858
#[diag = "E0123"]
59-
//~^ ERROR failed to resolve: maybe a missing crate `core`
59+
//~^ ERROR failed to resolve: you might be missing crate `core`
6060
struct WrongStructAttrStyle {}
6161

6262
#[derive(Diagnostic)]
@@ -801,15 +801,15 @@ struct SuggestionsNoItem {
801801
struct SuggestionsInvalidItem {
802802
#[suggestion(code(foo))]
803803
//~^ ERROR `code(...)` must contain only string literals
804-
//~| ERROR failed to resolve: maybe a missing crate `core`
804+
//~| ERROR failed to resolve: you might be missing crate `core`
805805
sub: Span,
806806
}
807807

808808
#[derive(Diagnostic)] //~ ERROR cannot find value `__code_34` in this scope
809809
#[diag(no_crate_example)]
810810
struct SuggestionsInvalidLiteral {
811811
#[suggestion(code = 3)]
812-
//~^ ERROR failed to resolve: maybe a missing crate `core`
812+
//~^ ERROR failed to resolve: you might be missing crate `core`
813813
sub: Span,
814814
}
815815

tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -524,23 +524,23 @@ LL | #[suggestion(no_crate_suggestion, code = "")]
524524
= help: to show a suggestion consisting of multiple parts, use a `Subdiagnostic` annotated with `#[multipart_suggestion(...)]`
525525
= help: to show a variable set of suggestions, use a `Vec` of `Subdiagnostic`s annotated with `#[suggestion(...)]`
526526

527-
error[E0433]: failed to resolve: maybe a missing crate `core`?
527+
error[E0433]: failed to resolve: you might be missing crate `core`
528528
--> $DIR/diagnostic-derive.rs:58:8
529529
|
530530
LL | #[diag = "E0123"]
531-
| ^ maybe a missing crate `core`?
531+
| ^ you might be missing crate `core`
532532

533-
error[E0433]: failed to resolve: maybe a missing crate `core`?
533+
error[E0433]: failed to resolve: you might be missing crate `core`
534534
--> $DIR/diagnostic-derive.rs:802:23
535535
|
536536
LL | #[suggestion(code(foo))]
537-
| ^^^ maybe a missing crate `core`?
537+
| ^^^ you might be missing crate `core`
538538

539-
error[E0433]: failed to resolve: maybe a missing crate `core`?
539+
error[E0433]: failed to resolve: you might be missing crate `core`
540540
--> $DIR/diagnostic-derive.rs:811:25
541541
|
542542
LL | #[suggestion(code = 3)]
543-
| ^ maybe a missing crate `core`?
543+
| ^ you might be missing crate `core`
544544

545545
error: cannot find attribute `nonsense` in this scope
546546
--> $DIR/diagnostic-derive.rs:63:3

tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ struct G {
9494

9595
#[derive(Subdiagnostic)]
9696
#[label("...")]
97-
//~^ ERROR failed to resolve: maybe a missing crate `core`?
98-
//~| NOTE maybe a missing crate `core`?
97+
//~^ ERROR failed to resolve: you might be missing crate `core`
98+
//~| NOTE you might be missing crate `core`
9999
struct H {
100100
#[primary_span]
101101
span: Span,
@@ -310,8 +310,8 @@ struct AB {
310310

311311
#[derive(Subdiagnostic)]
312312
union AC {
313-
//~^ ERROR failed to resolve: maybe a missing crate `core`?
314-
//~| NOTE maybe a missing crate `core`?
313+
//~^ ERROR failed to resolve: you might be missing crate `core`
314+
//~| NOTE you might be missing crate `core`
315315
span: u32,
316316
b: u64,
317317
}
@@ -581,8 +581,8 @@ struct BD {
581581
span2: Span,
582582
#[suggestion_part(foo = "bar")]
583583
//~^ ERROR `code` is the only valid nested attribute
584-
//~| ERROR failed to resolve: maybe a missing crate `core`?
585-
//~| NOTE maybe a missing crate `core`?
584+
//~| ERROR failed to resolve: you might be missing crate `core`
585+
//~| NOTE you might be missing crate `core`
586586
span4: Span,
587587
#[suggestion_part(code = "...")]
588588
//~^ ERROR the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan`
@@ -674,8 +674,8 @@ enum BL {
674674
struct BM {
675675
#[suggestion_part(code("foo"))]
676676
//~^ ERROR expected exactly one string literal for `code = ...`
677-
//~| ERROR failed to resolve: maybe a missing crate `core`?
678-
//~| NOTE maybe a missing crate `core`?
677+
//~| ERROR failed to resolve: you might be missing crate `core`
678+
//~| NOTE you might be missing crate `core`
679679
span: Span,
680680
r#type: String,
681681
}
@@ -685,8 +685,8 @@ struct BM {
685685
struct BN {
686686
#[suggestion_part(code("foo", "bar"))]
687687
//~^ ERROR expected exactly one string literal for `code = ...`
688-
//~| ERROR failed to resolve: maybe a missing crate `core`?
689-
//~| NOTE maybe a missing crate `core`?
688+
//~| ERROR failed to resolve: you might be missing crate `core`
689+
//~| NOTE you might be missing crate `core`
690690
span: Span,
691691
r#type: String,
692692
}
@@ -696,8 +696,8 @@ struct BN {
696696
struct BO {
697697
#[suggestion_part(code(3))]
698698
//~^ ERROR expected exactly one string literal for `code = ...`
699-
//~| ERROR failed to resolve: maybe a missing crate `core`?
700-
//~| NOTE maybe a missing crate `core`?
699+
//~| ERROR failed to resolve: you might be missing crate `core`
700+
//~| NOTE you might be missing crate `core`
701701
span: Span,
702702
r#type: String,
703703
}
@@ -718,8 +718,8 @@ struct BP {
718718
#[multipart_suggestion(no_crate_example)]
719719
struct BQ {
720720
#[suggestion_part(code = 3)]
721-
//~^ ERROR failed to resolve: maybe a missing crate `core`?
722-
//~| NOTE maybe a missing crate `core`?
721+
//~^ ERROR failed to resolve: you might be missing crate `core`
722+
//~| NOTE you might be missing crate `core`
723723
span: Span,
724724
r#type: String,
725725
}
@@ -811,8 +811,8 @@ struct SuggestionStyleInvalid3 {
811811
#[derive(Subdiagnostic)]
812812
#[suggestion(no_crate_example, code = "", style("foo"))]
813813
//~^ ERROR expected `= "xxx"`
814-
//~| ERROR failed to resolve: maybe a missing crate `core`?
815-
//~| NOTE maybe a missing crate `core`?
814+
//~| ERROR failed to resolve: you might be missing crate `core`
815+
//~| NOTE you might be missing crate `core`
816816
struct SuggestionStyleInvalid4 {
817817
#[primary_span]
818818
sub: Span,

tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr

+16-16
Original file line numberDiff line numberDiff line change
@@ -451,53 +451,53 @@ error: suggestion without `#[primary_span]` field
451451
LL | #[suggestion(no_crate_example, code = "")]
452452
| ^
453453

454-
error[E0433]: failed to resolve: maybe a missing crate `core`?
454+
error[E0433]: failed to resolve: you might be missing crate `core`
455455
--> $DIR/subdiagnostic-derive.rs:96:9
456456
|
457457
LL | #[label("...")]
458-
| ^^^^^ maybe a missing crate `core`?
458+
| ^^^^^ you might be missing crate `core`
459459

460-
error[E0433]: failed to resolve: maybe a missing crate `core`?
460+
error[E0433]: failed to resolve: you might be missing crate `core`
461461
--> $DIR/subdiagnostic-derive.rs:312:1
462462
|
463463
LL | union AC {
464-
| ^^^^^ maybe a missing crate `core`?
464+
| ^^^^^ you might be missing crate `core`
465465

466-
error[E0433]: failed to resolve: maybe a missing crate `core`?
466+
error[E0433]: failed to resolve: you might be missing crate `core`
467467
--> $DIR/subdiagnostic-derive.rs:582:27
468468
|
469469
LL | #[suggestion_part(foo = "bar")]
470-
| ^ maybe a missing crate `core`?
470+
| ^ you might be missing crate `core`
471471

472-
error[E0433]: failed to resolve: maybe a missing crate `core`?
472+
error[E0433]: failed to resolve: you might be missing crate `core`
473473
--> $DIR/subdiagnostic-derive.rs:675:28
474474
|
475475
LL | #[suggestion_part(code("foo"))]
476-
| ^^^^^ maybe a missing crate `core`?
476+
| ^^^^^ you might be missing crate `core`
477477

478-
error[E0433]: failed to resolve: maybe a missing crate `core`?
478+
error[E0433]: failed to resolve: you might be missing crate `core`
479479
--> $DIR/subdiagnostic-derive.rs:686:28
480480
|
481481
LL | #[suggestion_part(code("foo", "bar"))]
482-
| ^^^^^ maybe a missing crate `core`?
482+
| ^^^^^ you might be missing crate `core`
483483

484-
error[E0433]: failed to resolve: maybe a missing crate `core`?
484+
error[E0433]: failed to resolve: you might be missing crate `core`
485485
--> $DIR/subdiagnostic-derive.rs:697:28
486486
|
487487
LL | #[suggestion_part(code(3))]
488-
| ^ maybe a missing crate `core`?
488+
| ^ you might be missing crate `core`
489489

490-
error[E0433]: failed to resolve: maybe a missing crate `core`?
490+
error[E0433]: failed to resolve: you might be missing crate `core`
491491
--> $DIR/subdiagnostic-derive.rs:720:30
492492
|
493493
LL | #[suggestion_part(code = 3)]
494-
| ^ maybe a missing crate `core`?
494+
| ^ you might be missing crate `core`
495495

496-
error[E0433]: failed to resolve: maybe a missing crate `core`?
496+
error[E0433]: failed to resolve: you might be missing crate `core`
497497
--> $DIR/subdiagnostic-derive.rs:812:48
498498
|
499499
LL | #[suggestion(no_crate_example, code = "", style("foo"))]
500-
| ^ maybe a missing crate `core`?
500+
| ^ you might be missing crate `core`
501501

502502
error: cannot find attribute `foo` in this scope
503503
--> $DIR/subdiagnostic-derive.rs:67:3

tests/ui/attributes/field-attributes-vis-unresolved.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
error[E0433]: failed to resolve: maybe a missing crate `nonexistent`?
1+
error[E0433]: failed to resolve: you might be missing crate `nonexistent`
22
--> $DIR/field-attributes-vis-unresolved.rs:17:12
33
|
44
LL | pub(in nonexistent) field: u8
5-
| ^^^^^^^^^^^ maybe a missing crate `nonexistent`?
5+
| ^^^^^^^^^^^ you might be missing crate `nonexistent`
66
|
77
= help: consider adding `extern crate nonexistent` to use the `nonexistent` crate
88

9-
error[E0433]: failed to resolve: maybe a missing crate `nonexistent`?
9+
error[E0433]: failed to resolve: you might be missing crate `nonexistent`
1010
--> $DIR/field-attributes-vis-unresolved.rs:22:12
1111
|
1212
LL | pub(in nonexistent) u8
13-
| ^^^^^^^^^^^ maybe a missing crate `nonexistent`?
13+
| ^^^^^^^^^^^ you might be missing crate `nonexistent`
1414
|
1515
= help: consider adding `extern crate nonexistent` to use the `nonexistent` crate
1616

tests/ui/error-codes/E0432.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0432]: unresolved import `something`
22
--> $DIR/E0432.rs:1:5
33
|
44
LL | use something::Foo;
5-
| ^^^^^^^^^ maybe a missing crate `something`?
5+
| ^^^^^^^^^ you might be missing crate `something`
66
|
77
= help: consider adding `extern crate something` to use the `something` crate
88

tests/ui/feature-gates/feature-gate-extern_absolute_paths.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ error[E0432]: unresolved import `core`
44
LL | use core::default;
55
| ^^^^
66
| |
7-
| maybe a missing crate `core`?
7+
| you might be missing crate `core`
88
| help: try using `std` instead of `core`: `std`
99

10-
error[E0433]: failed to resolve: maybe a missing crate `core`?
10+
error[E0433]: failed to resolve: you might be missing crate `core`
1111
--> $DIR/feature-gate-extern_absolute_paths.rs:4:19
1212
|
1313
LL | let _: u8 = ::core::default::Default();
14-
| ^^^^ maybe a missing crate `core`?
14+
| ^^^^ you might be missing crate `core`
1515
|
1616
help: try using `std` instead of `core`
1717
|

tests/ui/imports/import-from-missing-star-2.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0432]: unresolved import `spam`
22
--> $DIR/import-from-missing-star-2.rs:2:9
33
|
44
LL | use spam::*;
5-
| ^^^^ maybe a missing crate `spam`?
5+
| ^^^^ you might be missing crate `spam`
66
|
77
= help: consider adding `extern crate spam` to use the `spam` crate
88

tests/ui/imports/import-from-missing-star-3.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ error[E0432]: unresolved import `spam`
22
--> $DIR/import-from-missing-star-3.rs:2:9
33
|
44
LL | use spam::*;
5-
| ^^^^ maybe a missing crate `spam`?
5+
| ^^^^ you might be missing crate `spam`
66
|
77
= help: consider adding `extern crate spam` to use the `spam` crate
88

99
error[E0432]: unresolved import `spam`
1010
--> $DIR/import-from-missing-star-3.rs:27:13
1111
|
1212
LL | use spam::*;
13-
| ^^^^ maybe a missing crate `spam`?
13+
| ^^^^ you might be missing crate `spam`
1414
|
1515
= help: consider adding `extern crate spam` to use the `spam` crate
1616

tests/ui/imports/import-from-missing-star.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0432]: unresolved import `spam`
22
--> $DIR/import-from-missing-star.rs:1:5
33
|
44
LL | use spam::*;
5-
| ^^^^ maybe a missing crate `spam`?
5+
| ^^^^ you might be missing crate `spam`
66
|
77
= help: consider adding `extern crate spam` to use the `spam` crate
88

tests/ui/imports/import3.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0432]: unresolved import `main`
22
--> $DIR/import3.rs:2:5
33
|
44
LL | use main::bar;
5-
| ^^^^ maybe a missing crate `main`?
5+
| ^^^^ you might be missing crate `main`
66
|
77
= help: consider adding `extern crate main` to use the `main` crate
88

tests/ui/imports/issue-109343.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0432]: unresolved import `unresolved`
22
--> $DIR/issue-109343.rs:4:9
33
|
44
LL | pub use unresolved::f;
5-
| ^^^^^^^^^^ maybe a missing crate `unresolved`?
5+
| ^^^^^^^^^^ you might be missing crate `unresolved`
66
|
77
= help: consider adding `extern crate unresolved` to use the `unresolved` crate
88

tests/ui/imports/issue-1697.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Testing that we don't fail abnormally after hitting the errors
22

3-
use unresolved::*; //~ ERROR unresolved import `unresolved` [E0432]
4-
//~^ maybe a missing crate `unresolved`?
3+
use unresolved::*;
4+
//~^ ERROR unresolved import `unresolved` [E0432]
5+
//~| NOTE you might be missing crate `unresolved`
6+
//~| HELP consider adding `extern crate unresolved` to use the `unresolved` crate
57

68
fn main() {}

tests/ui/imports/issue-1697.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0432]: unresolved import `unresolved`
22
--> $DIR/issue-1697.rs:3:5
33
|
44
LL | use unresolved::*;
5-
| ^^^^^^^^^^ maybe a missing crate `unresolved`?
5+
| ^^^^^^^^^^ you might be missing crate `unresolved`
66
|
77
= help: consider adding `extern crate unresolved` to use the `unresolved` crate
88

0 commit comments

Comments
 (0)