File tree Expand file tree Collapse file tree 8 files changed +88
-11
lines changed Expand file tree Collapse file tree 8 files changed +88
-11
lines changed Original file line number Diff line number Diff line change @@ -297,7 +297,17 @@ pub fn provide<'tcx>(providers: &mut Providers<'tcx>) {
297297 assert_eq ! ( cnum, LOCAL_CRATE ) ;
298298 let mut visible_parent_map: DefIdMap < DefId > = DefIdMap ( ) ;
299299
300- for & cnum in tcx. crates ( ) . iter ( ) {
300+ // Preferring shortest paths alone does not guarantee a
301+ // deterministic result; so sort by crate num to avoid
302+ // hashtable iteration non-determinism. This only makes
303+ // things as deterministic as crate-nums assignment is,
304+ // which is to say, its not deterministic in general. But
305+ // we believe that libstd is consistently assigned crate
306+ // num 1, so it should be enough to resolve #46112.
307+ let mut crates: Vec < CrateNum > = ( * tcx. crates ( ) ) . clone ( ) ;
308+ crates. sort ( ) ;
309+
310+ for & cnum in crates. iter ( ) {
301311 // Ignore crates without a corresponding local `extern crate` item.
302312 if tcx. missing_extern_crate_item ( cnum) {
303313 continue
Original file line number Diff line number Diff line change 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+ // Just exporting some type to test for correct diagnostics when this
12+ // crate is pulled in at a non-root location in client crate.
13+
14+ pub struct S ;
Original file line number Diff line number Diff line change 1010
1111//! Test that absolute path names are correct when a crate is not linked into the root namespace
1212
13+ // aux-build:issue_1920.rs
14+
1315mod foo {
14- pub extern crate core ;
16+ pub extern crate issue_1920 ;
1517}
1618
1719fn assert_clone < T > ( ) where T : Clone { }
1820
1921fn main ( ) {
20- assert_clone :: < foo:: core :: sync :: atomic :: AtomicBool > ( ) ;
21- //~^ ERROR `foo::core::sync::atomic::AtomicBool: foo::core ::clone::Clone` is not satisfied
22+ assert_clone :: < foo:: issue_1920 :: S > ( ) ;
23+ //~^ ERROR `foo::issue_1920::S: std ::clone::Clone` is not satisfied
2224}
Original file line number Diff line number Diff line change 1010
1111//! Test that when a crate is linked under another name that name is used in global paths
1212
13- extern crate core as bar;
13+ // aux-build:issue_1920.rs
14+
15+ extern crate issue_1920 as bar;
1416
1517fn assert_clone < T > ( ) where T : Clone { }
1618
1719fn main ( ) {
18- assert_clone :: < bar:: sync :: atomic :: AtomicBool > ( ) ;
19- //~^ ERROR `bar::sync::atomic::AtomicBool: bar ::clone::Clone` is not satisfied
20+ assert_clone :: < bar:: S > ( ) ;
21+ //~^ ERROR `bar::S: std ::clone::Clone` is not satisfied
2022}
Original file line number Diff line number Diff line change 1010
1111//! Test that when a crate is linked multiple times that the shortest absolute path name is used
1212
13+ // aux-build:issue_1920.rs
14+
1315mod foo {
14- pub extern crate core ;
16+ pub extern crate issue_1920 ;
1517}
1618
17- extern crate core ;
19+ extern crate issue_1920 ;
1820
1921fn assert_clone < T > ( ) where T : Clone { }
2022
2123fn main ( ) {
22- assert_clone :: < foo:: core :: sync :: atomic :: AtomicBool > ( ) ;
23- //~^ ERROR `core::sync::atomic::AtomicBool: core ::clone::Clone` is not satisfied
24+ assert_clone :: < foo:: issue_1920 :: S > ( ) ;
25+ //~^ ERROR `issue_1920::S: std ::clone::Clone` is not satisfied
2426}
Original file line number Diff line number Diff line change 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+ #![ crate_type="lib" ]
12+
13+ pub extern crate core;
Original file line number Diff line number Diff line change 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+ // Issue 46112: An extern crate pub reexporting libcore was causing
12+ // paths rooted from `std` to be misrendered in the diagnostic output.
13+
14+ // ignore-windows
15+ // aux-build:xcrate_issue_46112_rexport_core.rs
16+
17+ extern crate xcrate_issue_46112_rexport_core;
18+ fn test ( r : Result < Option < ( ) > , & ' static str > ) { }
19+ fn main ( ) { test ( Ok ( ( ) ) ) ; }
20+ //~^ mismatched types
Original file line number Diff line number Diff line change 1+ error[E0308]: mismatched types
2+ --> $DIR/issue-46112.rs:19:21
3+ |
4+ 19 | fn main() { test(Ok(())); }
5+ | ^^
6+ | |
7+ | expected enum `std::option::Option`, found ()
8+ | help: try using a variant of the expected type: `Some(())`
9+ |
10+ = note: expected type `std::option::Option<()>`
11+ found type `()`
12+
13+ error: aborting due to previous error
14+
You can’t perform that action at this time.
0 commit comments