Skip to content

Commit 1518459

Browse files
authored
Auto merge of #35362 - medzin:E0252, r=GuillaumeGomez
Updated error message E0252 Fixes #35306 as part of #35233. r? @GuillaumeGomez
2 parents 444ff9f + f4dd1f9 commit 1518459

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

src/librustc_resolve/lib.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -3375,7 +3375,11 @@ impl<'a> Resolver<'a> {
33753375
(true, _) | (_, true) => struct_span_err!(self.session, span, E0260, "{}", msg),
33763376
_ => match (old_binding.is_import(), binding.is_import()) {
33773377
(false, false) => struct_span_err!(self.session, span, E0428, "{}", msg),
3378-
(true, true) => struct_span_err!(self.session, span, E0252, "{}", msg),
3378+
(true, true) => {
3379+
let mut e = struct_span_err!(self.session, span, E0252, "{}", msg);
3380+
e.span_label(span, &format!("already imported"));
3381+
e
3382+
},
33793383
_ => {
33803384
let mut e = struct_span_err!(self.session, span, E0255, "{}", msg);
33813385
e.span_label(span, &format!("`{}` was already imported", name));

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10-
#![feature(no_core)]
11-
#![no_core]
1210

1311
// This tests that conflicting imports shows both `use` lines
1412
// when reporting the error.
@@ -23,5 +21,6 @@ mod sub2 {
2321

2422
use sub1::foo; //~ NOTE previous import of `foo` here
2523
use sub2::foo; //~ ERROR a value named `foo` has already been imported in this module [E0252]
24+
//~| NOTE already imported
2625

2726
fn main() {}

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

+2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
use std::sync::{self, Arc}; //~ NOTE previous import
1212
//~^ NOTE previous import
1313
use std::sync::Arc; //~ ERROR a type named
14+
//~| NOTE already imported
1415
use std::sync; //~ ERROR a module named
16+
//~| NOTE already imported
1517

1618
fn main() {
1719
}

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ use foo::bar::{
1515
Bar,
1616
self
1717
//~^ NOTE another `self` import appears here
18-
//~^^ ERROR a module named `bar` has already been imported in this module
18+
//~| ERROR a module named `bar` has already been imported in this module
19+
//~| NOTE already imported
1920
};
2021

2122
use {self};

0 commit comments

Comments
 (0)