Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[beta] Fix mode generated in maybe_lib #5523

Merged
merged 1 commit into from
May 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cargo/core/compiler/context/unit_dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ fn maybe_lib<'a>(
bcx: &BuildContext,
profile_for: ProfileFor,
) -> Option<(Unit<'a>, ProfileFor)> {
let mode = check_or_build_mode(&unit.mode, unit.target);
unit.pkg.targets().iter().find(|t| t.linkable()).map(|t| {
let mode = check_or_build_mode(&unit.mode, t);
let unit = new_unit(bcx, unit.pkg, t, profile_for, unit.kind.for_target(t), mode);
(unit, profile_for)
})
Expand Down
46 changes: 46 additions & 0 deletions tests/testsuite/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -897,3 +897,49 @@ fn check_artifacts() {
0
);
}

#[test]
fn proc_macro() {
let p = project("foo")
.file(
"Cargo.toml",
r#"
[package]
name = "demo"
version = "0.0.1"

[lib]
proc-macro = true
"#,
)
.file(
"src/lib.rs",
r#"
extern crate proc_macro;

use proc_macro::TokenStream;

#[proc_macro_derive(Foo)]
pub fn demo(_input: TokenStream) -> TokenStream {
"".parse().unwrap()
}
"#,
)
.file(
"src/main.rs",
r#"
#[macro_use]
extern crate demo;

#[derive(Foo)]
struct A;

fn main() {}
"#,
)
.build();
assert_that(
p.cargo("check").arg("-v").env("RUST_LOG", "cargo=trace"),
execs().with_status(0),
);
}