summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-05-30 07:10:16 +0000
committerbors <bors@rust-lang.org>2018-05-30 07:10:16 +0000
commit2408095f3456ba8974032e5dd0a2806cc7329cfb (patch)
tree0760982561b96a8cc163f9259cc090fa424bff70
parentAuto merge of #50783 - pnkfelix:issue-27282-match-borrows-its-input-take-thre... (diff)
parentAdd test for reexported crate names (diff)
downloadgrust-2408095f3456ba8974032e5dd0a2806cc7329cfb.tar.gz
grust-2408095f3456ba8974032e5dd0a2806cc7329cfb.tar.bz2
grust-2408095f3456ba8974032e5dd0a2806cc7329cfb.tar.xz
Auto merge of #51017 - estebank:crate-name-in-path, r=michaelwoerister
Use crate name for reexported `extern crate` paths Fix #43189.
-rw-r--r--src/librustc/ty/item_path.rs6
-rw-r--r--src/test/ui/auxiliary/xcrate_issue_43189_a.rs17
-rw-r--r--src/test/ui/auxiliary/xcrate_issue_43189_b.rs13
-rw-r--r--src/test/ui/issue-43189.rs22
-rw-r--r--src/test/ui/issue-43189.stderr15
5 files changed, 72 insertions, 1 deletions
diff --git a/src/librustc/ty/item_path.rs b/src/librustc/ty/item_path.rs
index 93d78210b1..87ace45a90 100644
--- a/src/librustc/ty/item_path.rs
+++ b/src/librustc/ty/item_path.rs
@@ -169,7 +169,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
169 169
170 let data = cur_def_key.disambiguated_data.data; 170 let data = cur_def_key.disambiguated_data.data;
171 let symbol = data.get_opt_name().map(|n| n.as_str()).unwrap_or_else(|| { 171 let symbol = data.get_opt_name().map(|n| n.as_str()).unwrap_or_else(|| {
172 Symbol::intern("<unnamed>").as_str() 172 if let DefPathData::CrateRoot = data { // reexported `extern crate` (#43189)
173 self.original_crate_name(cur_def.krate).as_str()
174 } else {
175 Symbol::intern("<unnamed>").as_str()
176 }
173 }); 177 });
174 cur_path.push(symbol); 178 cur_path.push(symbol);
175 179
diff --git a/src/test/ui/auxiliary/xcrate_issue_43189_a.rs b/src/test/ui/auxiliary/xcrate_issue_43189_a.rs
new file mode 100644
index 0000000000..95b2d62e42
--- /dev/null
+++ b/src/test/ui/auxiliary/xcrate_issue_43189_a.rs
@@ -0,0 +1,17 @@
1// Copyright 2018 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#![crate_type="lib"]
12
13
14pub trait A {
15 fn a(&self) {}
16}
17impl A for () {}
diff --git a/src/test/ui/auxiliary/xcrate_issue_43189_b.rs b/src/test/ui/auxiliary/xcrate_issue_43189_b.rs
new file mode 100644
index 0000000000..a396c31e21
--- /dev/null
+++ b/src/test/ui/auxiliary/xcrate_issue_43189_b.rs
@@ -0,0 +1,13 @@
1// Copyright 2018 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#![crate_type="lib"]
12
13pub extern crate xcrate_issue_43189_a;
diff --git a/src/test/ui/issue-43189.rs b/src/test/ui/issue-43189.rs
new file mode 100644
index 0000000000..154bee5d1d
--- /dev/null
+++ b/src/test/ui/issue-43189.rs
@@ -0,0 +1,22 @@
1// Copyright 2018 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// Issue 46112: An extern crate pub re-exporting libcore was causing
12// paths rooted from `std` to be misrendered in the diagnostic output.
13
14// ignore-windows
15// aux-build:xcrate_issue_43189_a.rs
16// aux-build:xcrate_issue_43189_b.rs
17
18extern crate xcrate_issue_43189_b;
19fn main() {
20 ().a();
21 //~^ ERROR no method named `a` found for type `()` in the current scope [E0599]
22}
diff --git a/src/test/ui/issue-43189.stderr b/src/test/ui/issue-43189.stderr
new file mode 100644
index 0000000000..b2a02401c5
--- /dev/null
+++ b/src/test/ui/issue-43189.stderr
@@ -0,0 +1,15 @@
1error[E0599]: no method named `a` found for type `()` in the current scope
2 --> $DIR/issue-43189.rs:20:8
3 |
4LL | ().a();
5 | ^
6 |
7 = help: items from traits can only be used if the trait is in scope
8help: the following trait is implemented but not in scope, perhaps add a `use` for it:
9 |
10LL | use xcrate_issue_43189_b::xcrate_issue_43189_a::A;
11 |
12
13error: aborting due to previous error
14
15For more information about this error, try `rustc --explain E0599`.