auto merge of #16598 : bkoropoff/rust/import-shadow-name, r=alexcrichton
This partially alleviates the confusing behavior in issue #16597
This commit is contained in:
commit
cbacdbc5f3
|
@ -2822,9 +2822,10 @@ impl<'a> Resolver<'a> {
|
||||||
.contains_key(&name) {
|
.contains_key(&name) {
|
||||||
match import_resolution.type_target {
|
match import_resolution.type_target {
|
||||||
Some(ref target) if !target.shadowable => {
|
Some(ref target) if !target.shadowable => {
|
||||||
self.session.span_err(import_span,
|
let msg = format!("import `{}` conflicts with imported \
|
||||||
"import conflicts with imported \
|
crate in this module",
|
||||||
crate in this module");
|
token::get_name(name).get());
|
||||||
|
self.session.span_err(import_span, msg.as_slice());
|
||||||
}
|
}
|
||||||
Some(_) | None => {}
|
Some(_) | None => {}
|
||||||
}
|
}
|
||||||
|
@ -2845,9 +2846,10 @@ impl<'a> Resolver<'a> {
|
||||||
match *name_bindings.value_def.borrow() {
|
match *name_bindings.value_def.borrow() {
|
||||||
None => {}
|
None => {}
|
||||||
Some(ref value) => {
|
Some(ref value) => {
|
||||||
self.session.span_err(import_span,
|
let msg = format!("import `{}` conflicts with value \
|
||||||
"import conflicts with value \
|
in this module",
|
||||||
in this module");
|
token::get_name(name).get());
|
||||||
|
self.session.span_err(import_span, msg.as_slice());
|
||||||
match value.value_span {
|
match value.value_span {
|
||||||
None => {}
|
None => {}
|
||||||
Some(span) => {
|
Some(span) => {
|
||||||
|
@ -2867,9 +2869,10 @@ impl<'a> Resolver<'a> {
|
||||||
match *name_bindings.type_def.borrow() {
|
match *name_bindings.type_def.borrow() {
|
||||||
None => {}
|
None => {}
|
||||||
Some(ref ty) => {
|
Some(ref ty) => {
|
||||||
self.session.span_err(import_span,
|
let msg = format!("import `{}` conflicts with type in \
|
||||||
"import conflicts with type in \
|
this module",
|
||||||
this module");
|
token::get_name(name).get());
|
||||||
|
self.session.span_err(import_span, msg.as_slice());
|
||||||
match ty.type_span {
|
match ty.type_span {
|
||||||
None => {}
|
None => {}
|
||||||
Some(span) => {
|
Some(span) => {
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use std::slice as std; //~ ERROR import conflicts with imported crate
|
use std::slice as std; //~ ERROR import `std` conflicts with imported crate
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use std::mem::transmute;
|
use std::mem::transmute;
|
||||||
//~^ ERROR import conflicts with value in this module
|
//~^ ERROR import `transmute` conflicts with value in this module
|
||||||
|
|
||||||
fn transmute() {}
|
fn transmute() {}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
use std::slice::Items;
|
||||||
|
//~^ ERROR import `Items` conflicts with type in this module
|
||||||
|
|
||||||
|
struct Items;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue