Skip to content
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 compiler/rustc_metadata/src/dependency_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub(crate) fn calculate(tcx: TyCtxt<'_>) -> Dependencies {
fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
let sess = &tcx.sess;

if !sess.opts.output_types.should_codegen() {
if !sess.opts.output_types.should_link() {
return IndexVec::new();
}

Expand Down
14 changes: 14 additions & 0 deletions tests/ui/rmeta/rmeta_bin-pass.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//@ compile-flags: --emit=obj,metadata --crate-type=bin
//@ aux-build:rmeta-meta.rs
//@ no-prefer-dynamic
//@ build-pass

// Check that building a metadata bin crate works with a dependent, metadata
// crate if linking is not requested.

extern crate rmeta_meta;
use rmeta_meta::Foo;

pub fn main() {
let _ = Foo { field: 42 };
}
14 changes: 14 additions & 0 deletions tests/ui/rmeta/rmeta_bin.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//@ build-fail
//@ compile-flags: --crate-type=bin
//@ aux-build:rmeta-meta.rs
//@ no-prefer-dynamic
//@ error-pattern: crate `rmeta_meta` required to be available in rlib format, but was not found

// Check that building a bin crate fails if a dependent crate is metadata-only.

extern crate rmeta_meta;
use rmeta_meta::Foo;

fn main() {
let _ = Foo { field: 42 };
}
4 changes: 4 additions & 0 deletions tests/ui/rmeta/rmeta_bin.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
error: crate `rmeta_meta` required to be available in rlib format, but was not found in this form

error: aborting due to 1 previous error

Loading