Skip to content

Commit c39ad4b

Browse files
Cldfireestebank
authored andcommitted
Correctly format extern crate conflict resolution help
1 parent 4cf26f8 commit c39ad4b

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

src/librustc_resolve/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3980,14 +3980,14 @@ impl<'a> Resolver<'a> {
39803980
container));
39813981

39823982
err.span_label(span, format!("`{}` re{} here", name, new_participle));
3983-
if old_binding.span != syntax_pos::DUMMY_SP {
3983+
if old_binding.span != DUMMY_SP {
39843984
err.span_label(self.session.codemap().def_span(old_binding.span),
39853985
format!("previous {} of the {} `{}` here", old_noun, old_kind, name));
39863986
}
39873987

39883988
// See https://github.com/rust-lang/rust/issues/32354
39893989
if old_binding.is_import() || new_binding.is_import() {
3990-
let binding = if new_binding.is_import() {
3990+
let binding = if new_binding.is_import() && new_binding.span != DUMMY_SP {
39913991
new_binding
39923992
} else {
39933993
old_binding

src/libsyntax/parse/parser.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -6128,9 +6128,11 @@ impl<'a> Parser<'a> {
61286128
} else {
61296129
(None, crate_name)
61306130
};
6131-
self.expect(&token::Semi)?;
61326131

6132+
// We grab this before expecting the `;` so it's not a part of the span
61336133
let prev_span = self.prev_span;
6134+
self.expect(&token::Semi)?;
6135+
61346136
Ok(self.mk_item(lo.to(prev_span),
61356137
ident,
61366138
ItemKind::ExternCrate(maybe_path),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
extern crate std;
12+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0259]: the name `std` is defined multiple times
2+
--> $DIR/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs:11:1
3+
|
4+
11 | extern crate std;
5+
| ^^^^^^^^^^^^^^^^ `std` reimported here
6+
|
7+
= note: `std` must be defined only once in the type namespace of this module
8+
help: You can use `as` to change the binding name of the import
9+
|
10+
11 | extern crate std as Otherstd;
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
13+
error: aborting due to previous error
14+

0 commit comments

Comments
 (0)