Skip to content

Commit

Permalink
Auto merge of #37846 - jseyfried:fix_proc_macro_dep, r=alexcrichton
Browse files Browse the repository at this point in the history
Fix bug in proc_macro dependency loading

Fixes #37839.
r? @alexcrichton
  • Loading branch information
bors authored Nov 18, 2016
2 parents 35e8924 + 8918ddf commit 509d14f
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/librustc_metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,11 @@ impl<'a> CrateLoader<'a> {
name: &str,
hash: Option<&Svh>,
span: Span,
kind: PathKind,
path_kind: PathKind,
mut dep_kind: DepKind)
-> (CrateNum, Rc<cstore::CrateMetadata>) {
info!("resolving crate `extern crate {} as {}`", name, ident);
let result = if let Some(cnum) = self.existing_match(name, hash, kind) {
let result = if let Some(cnum) = self.existing_match(name, hash, path_kind) {
LoadResult::Previous(cnum)
} else {
info!("falling back to a load");
Expand All @@ -332,7 +332,7 @@ impl<'a> CrateLoader<'a> {
ident: ident,
crate_name: name,
hash: hash.map(|a| &*a),
filesearch: self.sess.target_filesearch(kind),
filesearch: self.sess.target_filesearch(path_kind),
target: &self.sess.target.target,
triple: &self.sess.opts.target_triple,
root: root,
Expand All @@ -350,7 +350,7 @@ impl<'a> CrateLoader<'a> {
let mut proc_macro_locator = locator::Context {
target: &self.sess.host,
triple: config::host_triple(),
filesearch: self.sess.host_filesearch(PathKind::Crate),
filesearch: self.sess.host_filesearch(path_kind),
rejected_via_hash: vec![],
rejected_via_triple: vec![],
rejected_via_kind: vec![],
Expand Down
6 changes: 6 additions & 0 deletions src/test/run-make/issue-37839/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-include ../tools.mk

all:
$(RUSTC) a.rs && $(RUSTC) b.rs
$(BARE_RUSTC) c.rs -L dependency=$(TMPDIR) --extern b=$(TMPDIR)/libb.rlib \
--out-dir=$(TMPDIR)
13 changes: 13 additions & 0 deletions src/test/run-make/issue-37839/a.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2016 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.

#![feature(proc_macro)]
#![allow(unused)]
#![crate_type = "proc-macro"]
12 changes: 12 additions & 0 deletions src/test/run-make/issue-37839/b.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright 2016 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.

#![crate_type = "lib"]
#[macro_use] extern crate a;
12 changes: 12 additions & 0 deletions src/test/run-make/issue-37839/c.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright 2016 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.

#![crate_type = "lib"]
extern crate b;

0 comments on commit 509d14f

Please sign in to comment.