diff --git a/src/dependencies.rs b/src/dependencies.rs index 4952f758..9cb8bb2a 100644 --- a/src/dependencies.rs +++ b/src/dependencies.rs @@ -100,20 +100,11 @@ pub(crate) fn build_dependencies(config: &Config) -> Result { continue; }; if let cargo_metadata::Message::CompilerArtifact(artifact) = message { - if artifact - .filenames - .iter() - .any(|f| f.ends_with("build-script-build")) - { - continue; - } - // Check that we only collect rmeta and rlib crates, not build script crates - if artifact - .filenames - .iter() - .any(|f| !matches!(f.extension(), Some("rlib" | "rmeta"))) - { - continue; + for ctype in artifact.target.crate_types { + match ctype.as_str() { + "proc-macro" | "lib" => {} + _ => continue, + } } for filename in &artifact.filenames { import_paths.insert(filename.parent().unwrap().into()); diff --git a/src/rustc_stderr.rs b/src/rustc_stderr.rs index f7218a1b..2680fb1f 100644 --- a/src/rustc_stderr.rs +++ b/src/rustc_stderr.rs @@ -173,7 +173,7 @@ pub(crate) fn process(file: &Path, stderr: &[u8]) -> Diagnostics { let mut rendered = Vec::new(); let mut messages = vec![]; let mut messages_from_unknown_file_or_line = vec![]; - for (line_number, line) in stderr.lines_with_terminator().enumerate() { + for line in stderr.lines_with_terminator() { if line.starts_with_str(b"{") { match serde_json::from_slice::(line) { Ok(msg) => { @@ -187,11 +187,9 @@ pub(crate) fn process(file: &Path, stderr: &[u8]) -> Diagnostics { None, ); } - Err(err) => { - panic!( - "failed to parse rustc JSON output at line {line_number}: {err}: {}", - line.to_str_lossy() - ) + Err(_) => { + // FIXME: add a way to swap out the `process` function, so that cargo can use a different one from rustc + // The RustcMessage json just happens to match between the two } } } else { diff --git a/tests/integration.rs b/tests/integration.rs index fc26279f..d1b5e4ef 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -32,6 +32,11 @@ fn main() -> Result<()> { .envs .push(("BLESS".into(), (!args.check).then(|| String::new().into()))); + config + .program + .envs + .push(("RUST_BACKTRACE".into(), Some("0".into()))); + config.stdout_filter("in ([0-9]m )?[0-9\\.]+s", ""); config.stdout_filter(r#""--out-dir"(,)? "[^"]+""#, r#""--out-dir"$1 "$$TMP"#); config.filter("\\.exe", b""); diff --git a/tests/integrations/basic-bin/tests/actual_tests/foomp.rs b/tests/integrations/basic-bin/tests/actual_tests/foomp.rs index 52095e03..7157f58d 100644 --- a/tests/integrations/basic-bin/tests/actual_tests/foomp.rs +++ b/tests/integrations/basic-bin/tests/actual_tests/foomp.rs @@ -1,5 +1,9 @@ +//@normalize-stderr-test: "(file name should be).*" -> "$1" + use basic_bin::add; -//~^ ERROR: unresolved import `basic_bin` +//~^ ERROR: can't find crate for `basic_bin` +//~| ERROR: file name should be +//~| ERROR: extern location for basic_bin is of an unknown type fn main() { add("42", 3); diff --git a/tests/integrations/basic-bin/tests/actual_tests/foomp.stderr b/tests/integrations/basic-bin/tests/actual_tests/foomp.stderr index 0d1368ff..44c00d5a 100644 --- a/tests/integrations/basic-bin/tests/actual_tests/foomp.stderr +++ b/tests/integrations/basic-bin/tests/actual_tests/foomp.stderr @@ -1,9 +1,21 @@ -error[E0432]: unresolved import `basic_bin` - --> tests/actual_tests/foomp.rs:1:5 +error: extern location for basic_bin is of an unknown type: $DIR/tests/integrations/basic-bin/../../../target/$TMP/$TRIPLE/debug/basic_bin + --> tests/actual_tests/foomp.rs:3:5 | -1 | use basic_bin::add; - | ^^^^^^^^^ use of undeclared crate or module `basic_bin` +3 | use basic_bin::add; + | ^^^^^^^^^ -error: aborting due to 1 previous error +error: file name should be + --> tests/actual_tests/foomp.rs:3:5 + | +3 | use basic_bin::add; + | ^^^^^^^^^ + +error[E0463]: can't find crate for `basic_bin` + --> tests/actual_tests/foomp.rs:3:5 + | +3 | use basic_bin::add; + | ^^^^^^^^^ can't find crate + +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0432`. +For more information about this error, try `rustc --explain E0463`. diff --git a/tests/integrations/basic-fail/Cargo.stdout b/tests/integrations/basic-fail/Cargo.stdout index 06301a95..a73e0d35 100644 --- a/tests/integrations/basic-fail/Cargo.stdout +++ b/tests/integrations/basic-fail/Cargo.stdout @@ -373,7 +373,7 @@ error: internal compiler error: no errors reported for args thread 'rustc' panicked at compiler/rustc_errors/src/lib.rs: aborting due to `-Z treat-err-as-bug=1` -stack backtrace: +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace error: the compiler unexpectedly panicked. this is a bug. diff --git a/tests/integrations/basic/Cargo.lock b/tests/integrations/basic/Cargo.lock index e9fa5a92..69829e81 100644 --- a/tests/integrations/basic/Cargo.lock +++ b/tests/integrations/basic/Cargo.lock @@ -67,6 +67,7 @@ dependencies = [ name = "basic" version = "0.1.0" dependencies = [ + "serde_derive", "tempfile", "ui_test", ] diff --git a/tests/integrations/basic/Cargo.stdout b/tests/integrations/basic/Cargo.stdout index 6cf6132e..7a859645 100644 --- a/tests/integrations/basic/Cargo.stdout +++ b/tests/integrations/basic/Cargo.stdout @@ -13,6 +13,7 @@ Building aux file tests/actual_tests/auxiliary/derive_proc_macro.rs ... ok tests/actual_tests/aux_derive.rs ... ok Building aux file tests/actual_tests/auxiliary/the_proc_macro.rs ... ok tests/actual_tests/aux_proc_macro.rs ... ok +tests/actual_tests/dep_derive.rs ... ok tests/actual_tests/error_above.rs ... ok tests/actual_tests/executable.rs ... ok tests/actual_tests/foomp-rustfix.rs ... ok @@ -28,7 +29,7 @@ tests/actual_tests/unicode.rs ... ok tests/actual_tests/windows_paths.rs ... ok tests/actual_tests/subdir/aux_proc_macro.rs ... ok -test result: ok. 16 passed; +test result: ok. 17 passed; running 0 tests diff --git a/tests/integrations/basic/Cargo.toml b/tests/integrations/basic/Cargo.toml index 207ef02a..6d404d17 100644 --- a/tests/integrations/basic/Cargo.toml +++ b/tests/integrations/basic/Cargo.toml @@ -5,6 +5,9 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[dependencies] +serde_derive = "1.0" + [dev-dependencies] ui_test = { path = "../../.."} tempfile = "3.3.0" diff --git a/tests/integrations/basic/tests/actual_tests/dep_derive.rs b/tests/integrations/basic/tests/actual_tests/dep_derive.rs new file mode 100644 index 00000000..9db373db --- /dev/null +++ b/tests/integrations/basic/tests/actual_tests/dep_derive.rs @@ -0,0 +1,6 @@ +//@run + +#[macro_use] +extern crate serde_derive; + +fn main() {} diff --git a/tests/integrations/basic/tests/actual_tests/dep_derive.stderr b/tests/integrations/basic/tests/actual_tests/dep_derive.stderr new file mode 100644 index 00000000..5f7c2d9f --- /dev/null +++ b/tests/integrations/basic/tests/actual_tests/dep_derive.stderr @@ -0,0 +1,10 @@ +warning: unused `#[macro_use]` import + --> tests/actual_tests/dep_derive.rs:3:1 + | +3 | #[macro_use] + | ^^^^^^^^^^^^ + | + = note: `#[warn(unused_imports)]` on by default + +warning: 1 warning emitted +