Skip to content

Commit cf535a3

Browse files
committed
rustc: Use --extern to always override
Previously if --extern was specified it would not override crates in the standard distribution, leading to issues like #21771. This commit alters the behavior such that if --extern is passed then it will always override any other choice of crates and no previous match will be used (unless it is the same path as --extern). Closes #21771
1 parent 1a51eb9 commit cf535a3

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

src/librustc/metadata/creader.rs

+1
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ impl<'a> CrateReader<'a> {
330330
if found {
331331
ret = Some(cnum);
332332
}
333+
return
333334
}
334335

335336
// Alright, so we've gotten this far which means that `data` has the
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-include ../tools.mk
2+
3+
all:
4+
$(RUSTC) libc.rs
5+
$(RUSTC) main.rs --extern libc=$(TMPDIR)/liblibc.rlib
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2015 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 fn foo() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2015 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 libc;
12+
13+
fn main() {
14+
libc::foo();
15+
}
16+

0 commit comments

Comments
 (0)