-
-
Notifications
You must be signed in to change notification settings - Fork 77
Description
I have a library that's tested by trybuild in a subproject (roughly this structure):
.
├── Cargo.lock
├── Cargo.toml
├── compile-fail
│ ├── Cargo.lock
│ ├── Cargo.toml
│ ├── src
│ │ └── lib.rs
│ └── tests
│ └── ui
│ ├── repro.rs
│ └── repro.stderr
└── src
└── lib.rs
src/lib.rs
pub trait MyTrait {}
impl MyTrait for i32 {}compile-fail/src/lib.rs
#[test]
fn ui() {
let t = trybuild::TestCases::new();
t.compile_fail("tests/ui/*.rs");
}compile-fail/tests/ui/repro.rs
use some_library::MyTrait;
fn repro() -> impl MyTrait {}
fn main() {}Notably, I include trybuild and my library as dev-dependencies since they are only being used for tests:
compile-fail/Cargo.toml
[package]
name = "alpha"
version = "0.1.0"
edition = "2024"
[dev-dependencies]
trybuild = "1.0"
some-library = { path = ".." }This results in a non-normalized stderr:
compile-fail/tests/ui/repro.stderr
error[E0277]: the trait bound `(): MyTrait` is not satisfied
--> tests/ui/repro.rs:3:15
|
3 | fn repro() -> impl MyTrait {}
| ^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `()`
|
help: the trait `MyTrait` is implemented for `i32`
--> /private/tmp/alpha/src/lib.rs:3:1
|
3 | impl MyTrait for i32 {}
| ^^^^^^^^^^^^^^^^^^^^
If I change to including it as dependencies, the path is normalized:
error[E0277]: the trait bound `(): MyTrait` is not satisfied
--> tests/ui/repro.rs:3:15
|
3 | fn repro() -> impl MyTrait {}
| ^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `()`
|
help: the trait `MyTrait` is implemented for `i32`
--> $SOME_LIBRARY/src/lib.rs
|
| impl MyTrait for i32 {}
| ^^^^^^^^^^^^^^^^^^^^
Ideally, both dependencies and dev-dependencies would be normalized the same way. Barring that, it'd be nice to note somewhere the intentional difference between the two. I actually didn't find any docs that mention that normalization occurred at all...
I've actually been using trybuild since mid-2019 and never realized that this feature existed / that I was missing it.