Skip to content

Commit a4c6307

Browse files
author
Knight
committed
Updated E0432 to new format
1 parent 820c810 commit a4c6307

21 files changed

+83
-45
lines changed

src/librustc_resolve/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,10 +418,14 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
418418
}
419419
ResolutionError::UnresolvedImport(name) => {
420420
let msg = match name {
421-
Some((n, p)) => format!("unresolved import `{}`{}", n, p),
421+
Some((n, _)) => format!("unresolved import `{}`", n),
422422
None => "unresolved import".to_owned(),
423423
};
424-
struct_span_err!(resolver.session, span, E0432, "{}", msg)
424+
let mut err = struct_span_err!(resolver.session, span, E0432, "{}", msg);
425+
if let Some((_, p)) = name {
426+
err.span_label(span, &p);
427+
}
428+
err
425429
}
426430
ResolutionError::FailedToResolve(msg) => {
427431
let mut err = struct_span_err!(resolver.session, span, E0433,

src/librustc_resolve/resolve_imports.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
423423
if let Failed(err) = self.finalize_import(import) {
424424
errors = true;
425425
let (span, help) = match err {
426-
Some((span, msg)) => (span, format!(". {}", msg)),
426+
Some((span, msg)) => (span, msg),
427427
None => (import.span, String::new()),
428428
};
429429

@@ -596,9 +596,9 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
596596
};
597597
let module_str = module_to_string(module);
598598
let msg = if &module_str == "???" {
599-
format!("There is no `{}` in the crate root{}", name, lev_suggestion)
599+
format!("no `{}` in the root{}", name, lev_suggestion)
600600
} else {
601-
format!("There is no `{}` in `{}`{}", name, module_str, lev_suggestion)
601+
format!("no `{}` in `{}`{}", name, module_str, lev_suggestion)
602602
};
603603
Failed(Some((directive.span, msg)))
604604
} else {

src/test/compile-fail/import-from-missing.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use spam::{ham, eggs};
12-
//~^ ERROR unresolved import `spam::eggs`. There is no `eggs` in `spam`
11+
use spam::{ham, eggs}; //~ ERROR unresolved import `spam::eggs` [E0432]
12+
//~^ no `eggs` in `spam`
1313

1414
mod spam {
1515
pub fn ham() { }

src/test/compile-fail/import.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
// except according to those terms.
1010

1111
use zed::bar;
12-
use zed::baz;
13-
//~^ ERROR unresolved import `zed::baz`. There is no `baz` in `zed`
12+
use zed::baz; //~ ERROR unresolved import `zed::baz` [E0432]
13+
//~^ no `baz` in `zed`. Did you mean to use `bar`?
1414

1515

1616
mod zed {
1717
pub fn bar() { println!("bar"); }
18-
use foo; //~ ERROR unresolved import
18+
use foo; //~ ERROR unresolved import `foo` [E0432]
19+
//~^ no `foo` in the root
1920
}
2021

2122
fn main() {

src/test/compile-fail/import2.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use baz::zed::bar;
12-
//~^ ERROR unresolved import `baz::zed::bar`. Could not find `zed` in `baz`
11+
use baz::zed::bar; //~ ERROR unresolved import `baz::zed::bar` [E0432]
12+
//~^ Could not find `zed` in `baz`
1313

1414
mod baz {}
1515
mod zed {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ extern crate issue_12612_1 as foo;
1515
use foo::bar;
1616

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

2222
fn main() {}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
// except according to those terms.
1010

1111
use a::f;
12-
use b::f;
13-
//~^ ERROR: unresolved import `b::f`. There is no `f` in `b`
12+
use b::f; //~ ERROR: unresolved import `b::f` [E0432]
13+
//~^ no `f` in `b`
1414

1515
mod a { pub fn f() {} }
1616
mod b { }

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
// Testing that we don't fail abnormally after hitting the errors
1212

13-
use unresolved::*; //~ ERROR unresolved import `unresolved::*`. Maybe a missing `extern crate unres
13+
use unresolved::*; //~ ERROR unresolved import `unresolved::*` [E0432]
14+
//~^ Maybe a missing `extern crate unresolved`?
1415

1516
fn main() {}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use m::f as x; //~ ERROR unresolved import `m::f`. There is no `f` in `m`
11+
use m::f as x; //~ ERROR unresolved import `m::f` [E0432]
12+
//~^ no `f` in `m`
1213

1314
mod m {}
1415

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@
99
// except according to those terms.
1010

1111
type Alias = ();
12-
use Alias::*; //~ ERROR Not a module
13-
use std::io::Result::*; //~ ERROR Not a module
12+
use Alias::*;
13+
//~^ ERROR unresolved import `Alias::*` [E0432]
14+
//~| Not a module `Alias`
15+
use std::io::Result::*;
16+
//~^ ERROR unresolved import `std::io::Result::*` [E0432]
17+
//~| Not a module `Result`
1418

1519
trait T {}
1620
use T::*; //~ ERROR items in traits are not importable

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use bar::Foo; //~ ERROR There is no `Foo` in `bar` [E0432]
11+
use bar::Foo; //~ ERROR unresolved import `bar::Foo` [E0432]
12+
//~^ no `Foo` in `bar`
1213
mod bar {
13-
use Foo; //~ ERROR There is no `Foo` in the crate root [E0432]
14+
use Foo; //~ ERROR unresolved import `Foo` [E0432]
15+
//~^ no `Foo` in the root
1416
}
1517

1618
fn main() {}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ impl K for isize {} //~ ERROR: `K` is not a trait
1414
//~| NOTE: not a trait
1515
//~| NOTE: aliases cannot be used for traits
1616

17-
use ImportError; //~ ERROR unresolved
17+
use ImportError; //~ ERROR unresolved import `ImportError` [E0432]
18+
//~^ no `ImportError` in the root
1819
impl ImportError for () {} // check that this is not an additional error (c.f. #35142)
1920

2021
fn main() {}

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use self::*; //~ ERROR: unresolved import `self::*`. Cannot glob-import a module into itself.
11+
use self::*; //~ ERROR: unresolved import `self::*` [E0432]
12+
//~^ Cannot glob-import a module into itself.
1213

1314
mod foo {
14-
use foo::*; //~ ERROR: unresolved import `foo::*`. Cannot glob-import a module into itself.
15+
use foo::*; //~ ERROR: unresolved import `foo::*` [E0432]
16+
//~^ Cannot glob-import a module into itself.
1517

1618
mod bar {
1719
use super::bar::*;
18-
//~^ ERROR: unresolved import `super::bar::*`. Cannot glob-import a module into itself.
20+
//~^ ERROR: unresolved import `super::bar::*` [E0432]
21+
//~| Cannot glob-import a module into itself.
1922
}
2023

2124
}

src/test/compile-fail/privacy2.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@ pub fn foo() {}
2525

2626
fn test1() {
2727
use bar::foo;
28-
//~^ ERROR unresolved import `bar::foo`. There is no `foo` in `bar`
28+
//~^ ERROR unresolved import `bar::foo` [E0432]
29+
//~| no `foo` in `bar`
2930
}
3031

3132
fn test2() {
3233
use bar::glob::foo;
33-
//~^ ERROR unresolved import `bar::glob::foo`. There is no `foo` in `bar::glob`
34+
//~^ ERROR unresolved import `bar::glob::foo` [E0432]
35+
//~| no `foo` in `bar::glob`
3436
}
3537

3638
#[start] fn main(_: isize, _: *const *const u8) -> isize { 3 }

src/test/compile-fail/privacy3.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ pub fn foo() {}
2626

2727
fn test1() {
2828
use bar::gpriv;
29-
//~^ ERROR unresolved import `bar::gpriv`. There is no `gpriv` in `bar`
29+
//~^ ERROR unresolved import `bar::gpriv` [E0432]
30+
//~| no `gpriv` in `bar`
3031

3132
// This should pass because the compiler will insert a fake name binding
3233
// for `gpriv`

src/test/compile-fail/resolve_self_super_hint.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,20 @@
1111
mod a {
1212
extern crate collections;
1313
use collections::HashMap;
14-
//~^ ERROR unresolved import `collections::HashMap`. Did you mean `self::collections`?
14+
//~^ ERROR unresolved import `collections::HashMap` [E0432]
15+
//~| Did you mean `self::collections`?
1516
mod b {
1617
use collections::HashMap;
17-
//~^ ERROR unresolved import `collections::HashMap`. Did you mean `a::collections`?
18+
//~^ ERROR unresolved import `collections::HashMap` [E0432]
19+
//~| Did you mean `a::collections`?
1820
mod c {
1921
use collections::HashMap;
20-
//~^ ERROR unresolved import `collections::HashMap`. Did you mean `a::collections`?
22+
//~^ ERROR unresolved import `collections::HashMap` [E0432]
23+
//~| Did you mean `a::collections`?
2124
mod d {
2225
use collections::HashMap;
23-
//~^ ERROR unresolved import `collections::HashMap`. Did you mean `a::collections`?
26+
//~^ ERROR unresolved import `collections::HashMap` [E0432]
27+
//~| Did you mean `a::collections`?
2428
}
2529
}
2630
}

src/test/compile-fail/super-at-top-level.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use super::f; //~ ERROR unresolved import `super::f`. There are too many initial `super`s.
11+
use super::f; //~ ERROR unresolved import `super::f` [E0432]
12+
//~^ There are too many initial `super`s.
1213

1314
fn main() {
1415
}

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@
1010

1111
// ignore-tidy-linelength
1212

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

15-
use bar::Baz as x; //~ ERROR unresolved import `bar::Baz`. There is no `Baz` in `bar`. Did you mean to use `Bar`?
16+
use bar::Baz as x; //~ ERROR unresolved import `bar::Baz` [E0432]
17+
//~^ no `Baz` in `bar`. Did you mean to use `Bar`?
1618

17-
use food::baz; //~ ERROR unresolved import `food::baz`. There is no `baz` in `food`. Did you mean to use `bag`?
19+
use food::baz; //~ ERROR unresolved import `food::baz`
20+
//~^ no `baz` in `food`. Did you mean to use `bag`?
1821

19-
use food::{beens as Foo}; //~ ERROR unresolved import `food::beens`. There is no `beens` in `food`. Did you mean to use `beans`?
22+
use food::{beens as Foo}; //~ ERROR unresolved import `food::beens` [E0432]
23+
//~^ no `beens` in `food`. Did you mean to use `beans`?
2024

2125
mod bar {
2226
pub struct Bar;

src/test/compile-fail/use-from-trait.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ use Trait::C;
1818
//~^ ERROR `C` is not directly importable
1919

2020
use Foo::new;
21-
//~^ ERROR unresolved import `Foo::new`. Not a module `Foo`
21+
//~^ ERROR unresolved import `Foo::new` [E0432]
22+
//~| Not a module `Foo`
2223

2324
use Foo::C2;
24-
//~^ ERROR unresolved import `Foo::C2`. Not a module `Foo`
25+
//~^ ERROR unresolved import `Foo::C2` [E0432]
26+
//~| Not a module `Foo`
2527

2628
pub trait Trait {
2729
fn foo();

src/test/compile-fail/use-keyword.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@
1414
mod a {
1515
mod b {
1616
use self as A; //~ ERROR `self` imports are only allowed within a { } list
17-
//~^ ERROR unresolved import `self`. There is no `self` in the crate root
18-
use super as B; //~ ERROR unresolved import `super`. There is no `super` in the crate root
19-
use super::{self as C}; //~ERROR unresolved import `super`. There is no `super` in the crate
17+
//~^ ERROR unresolved import `self` [E0432]
18+
//~| no `self` in the root
19+
use super as B;
20+
//~^ ERROR unresolved import `super` [E0432]
21+
//~| no `super` in the root
22+
use super::{self as C};
23+
//~^ ERROR unresolved import `super` [E0432]
24+
//~| no `super` in the root
2025
}
2126
}
2227

src/test/compile-fail/use-mod-2.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010

1111
mod foo {
1212
use self::{self};
13-
//~^ ERROR unresolved import `self`. There is no `self` in the crate root
13+
//~^ ERROR unresolved import `self` [E0432]
14+
//~| no `self` in the root
1415

1516
use super::{self};
16-
//~^ ERROR unresolved import `super`. There is no `super` in the crate root
17+
//~^ ERROR unresolved import `super` [E0432]
18+
//~| no `super` in the root
1719
}
1820

1921
fn main() {}

0 commit comments

Comments
 (0)