Skip to content

Commit

Permalink
Add a test that emitting diagnostics does not require the crate to use
Browse files Browse the repository at this point in the history
the corresponding feature.
  • Loading branch information
weiznich committed Dec 23, 2023
1 parent 3350e5b commit 4ed3257
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#![feature(diagnostic_namespace)]

#[diagnostic::on_unimplemented(
message = "Message",
note = "Note",
label = "label"
)]
pub trait Foo {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// aux-build:other.rs

extern crate other;

use other::Foo;

fn take_foo(_: impl Foo) {}

fn main() {
take_foo(());
//~^ERROR Message
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error[E0277]: Message
--> $DIR/error_is_shown_in_downstream_crates.rs:10:14
|
LL | take_foo(());
| -------- ^^ label
| |
| required by a bound introduced by this call
|
= help: the trait `Foo` is not implemented for `()`
= note: Note
note: required by a bound in `take_foo`
--> $DIR/error_is_shown_in_downstream_crates.rs:7:21
|
LL | fn take_foo(_: impl Foo) {}
| ^^^ required by this bound in `take_foo`

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0277`.

0 comments on commit 4ed3257

Please sign in to comment.