From 04886f2c983cc06f595578e3d35b92fd44400210 Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Fri, 18 Nov 2016 00:03:10 +0000 Subject: [PATCH 1/2] Fix bug in loading proc macro dependencies. --- src/librustc_metadata/creader.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index 4298bb47fea..5384535024e 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -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) { 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"); @@ -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, @@ -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![], From 8918ddf0ed7ed02546919b2a360543c0930d6486 Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Fri, 18 Nov 2016 00:51:24 +0000 Subject: [PATCH 2/2] Add regression test. --- src/test/run-make/issue-37839/Makefile | 6 ++++++ src/test/run-make/issue-37839/a.rs | 13 +++++++++++++ src/test/run-make/issue-37839/b.rs | 12 ++++++++++++ src/test/run-make/issue-37839/c.rs | 12 ++++++++++++ 4 files changed, 43 insertions(+) create mode 100644 src/test/run-make/issue-37839/Makefile create mode 100644 src/test/run-make/issue-37839/a.rs create mode 100644 src/test/run-make/issue-37839/b.rs create mode 100644 src/test/run-make/issue-37839/c.rs diff --git a/src/test/run-make/issue-37839/Makefile b/src/test/run-make/issue-37839/Makefile new file mode 100644 index 00000000000..f17ce537fb8 --- /dev/null +++ b/src/test/run-make/issue-37839/Makefile @@ -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) diff --git a/src/test/run-make/issue-37839/a.rs b/src/test/run-make/issue-37839/a.rs new file mode 100644 index 00000000000..3dff45388c7 --- /dev/null +++ b/src/test/run-make/issue-37839/a.rs @@ -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 or the MIT license +// , 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"] diff --git a/src/test/run-make/issue-37839/b.rs b/src/test/run-make/issue-37839/b.rs new file mode 100644 index 00000000000..82f48f6d8d6 --- /dev/null +++ b/src/test/run-make/issue-37839/b.rs @@ -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 or the MIT license +// , 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; diff --git a/src/test/run-make/issue-37839/c.rs b/src/test/run-make/issue-37839/c.rs new file mode 100644 index 00000000000..85bece51427 --- /dev/null +++ b/src/test/run-make/issue-37839/c.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] +extern crate b;