Skip to content

Commit f12e66e

Browse files
Rollup merge of #37430 - robinst:missing-crate-message-add-semicolon, r=eddyb
Add semicolon to "Maybe a missing `extern crate foo`" message I had it a couple of times that I was missing the "extern crate" line after I introduced a new dependency. So I copied the text from the message and inserted it into the beginning of my code, only to find the compiler complaining that I was missing the semicolon. (I forgot to add it after the text that I had pasted.) There's a similar message which does include the semicolon, namely "help: you can import it into scope: `use foo::Bar;`". I think the two messages should be consistent, so this change adds it for "extern crate".
2 parents 777502e + de5172c commit f12e66e

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

src/librustc_resolve/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1401,7 +1401,7 @@ impl<'a> Resolver<'a> {
14011401

14021402
format!("Did you mean `{}{}`?", prefix, path_str)
14031403
}
1404-
None => format!("Maybe a missing `extern crate {}`?", segment_name),
1404+
None => format!("Maybe a missing `extern crate {};`?", segment_name),
14051405
}
14061406
} else {
14071407
format!("Could not find `{}` in `{}`", segment_name, module_name)

src/test/compile-fail/issue-12612.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use foo::bar;
1616

1717
mod test {
1818
use bar::foo; //~ ERROR unresolved import `bar::foo` [E0432]
19-
//~^ Maybe a missing `extern crate bar`?
19+
//~^ Maybe a missing `extern crate bar;`?
2020
}
2121

2222
fn main() {}

src/test/compile-fail/issue-1697.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
// Testing that we don't fail abnormally after hitting the errors
1212

1313
use unresolved::*; //~ ERROR unresolved import `unresolved::*` [E0432]
14-
//~^ Maybe a missing `extern crate unresolved`?
14+
//~^ Maybe a missing `extern crate unresolved;`?
1515

1616
fn main() {}

src/test/compile-fail/unresolved-import.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// ignore-tidy-linelength
1212

1313
use foo::bar; //~ ERROR unresolved import `foo::bar` [E0432]
14-
//~^ Maybe a missing `extern crate foo`?
14+
//~^ Maybe a missing `extern crate foo;`?
1515

1616
use bar::Baz as x; //~ ERROR unresolved import `bar::Baz` [E0432]
1717
//~^ no `Baz` in `bar`. Did you mean to use `Bar`?

0 commit comments

Comments
 (0)