#![feature(diagnostic_namespace)]
#[diagnostic::on_unimplemented(
on(_Self = "&str"),
//~^WARN malformed `on_unimplemented` attribute
//~|WARN malformed `on_unimplemented` attribute
message = "trait has `{Self}` and `{T}` as params",
label = "trait has `{Self}` and `{T}` as params",
note = "trait has `{Self}` and `{T}` as params",
parent_label = "in this scope",
//~^WARN malformed `on_unimplemented` attribute
//~|WARN malformed `on_unimplemented` attribute
append_const_msg
//~^WARN malformed `on_unimplemented` attribute
//~|WARN malformed `on_unimplemented` attribute
)]
trait Foo<T> {}
#[diagnostic::on_unimplemented = "Message"]
//~^WARN malformed `on_unimplemented` attribute
//~|WARN malformed `on_unimplemented` attribute
trait Bar {}
#[diagnostic::on_unimplemented(message = "Not allowed to apply it on a impl")]
//~^WARN #[diagnostic::on_unimplemented]` can only be applied to trait definitions
impl Bar for i32 {}
// cannot use special rustc_on_unimplement symbols
// in the format string
#[diagnostic::on_unimplemented(
message = "{from_desugaring}{direct}{cause}{integral}{integer}",
//~^WARN there is no parameter `from_desugaring` on trait `Baz`
//~|WARN there is no parameter `from_desugaring` on trait `Baz`
//~|WARN there is no parameter `direct` on trait `Baz`
//~|WARN there is no parameter `direct` on trait `Baz`
//~|WARN there is no parameter `cause` on trait `Baz`
//~|WARN there is no parameter `cause` on trait `Baz`
//~|WARN there is no parameter `integral` on trait `Baz`
//~|WARN there is no parameter `integral` on trait `Baz`
//~|WARN there is no parameter `integer` on trait `Baz`
//~|WARN there is no parameter `integer` on trait `Baz`
label = "{float}{_Self}{crate_local}{Trait}{ItemContext}"
//~^WARN there is no parameter `float` on trait `Baz`
//~|WARN there is no parameter `float` on trait `Baz`
//~|WARN there is no parameter `_Self` on trait `Baz`
//~|WARN there is no parameter `_Self` on trait `Baz`
//~|WARN there is no parameter `crate_local` on trait `Baz`
//~|WARN there is no parameter `crate_local` on trait `Baz`
//~|WARN there is no parameter `Trait` on trait `Baz`
//~|WARN there is no parameter `Trait` on trait `Baz`
//~|WARN there is no parameter `ItemContext` on trait `Baz`
//~|WARN there is no parameter `ItemContext` on trait `Baz`
)]
trait Baz {}
fn takes_foo(_: impl Foo<i32>) {}
fn takes_bar(_: impl Bar) {}
fn takes_baz(_: impl Baz) {}
fn main() {
takes_foo(());
//~^ERROR trait has `()` and `i32` as params
takes_bar(());
//~^ERROR the trait bound `(): Bar` is not satisfied
takes_baz(());
//~^ERROR {from_desugaring}{direct}{cause}{integral}{integer}
}
Version
No response
Logs and Backtrace
MARKER_ERROR_TRACE=1 MARKER_LOG=info RUST_BACKTRACE=1 LD_LIBRARY_PATH='/home/matthias/o/target/debug/deps:/home/matthias/.rustup/toolchains/nightly-2023-11-16-x86_64-unknown-linux-gnu/lib:/home/matthias/.rustup/toolchains/nightly-2023-11-16-x86_64-unknown-linux-gnu/lib:/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib' RUSTC_WORKSPACE_WRAPPER=/home/matthias/.rustup/toolchains/nightly-2023-11-16-x86_64-unknown-linux-gnu/bin/marker_rustc_driver MARKER_LINT_CRATES=marker_lints:/home/matthias/o/target/marker/lints/libmarker_lints.so RUSTUP_TOOLCHAIN=nightly-2023-11-16 /home/matthias/.rustup/toolchains/nightly-2023-11-16-x86_64-unknown-linux-gnu/bin/marker_rustc_driver /home/matthias/vcs/github/rust_misc_stuff/tests/ui/diagnostic_namespace/on_unimplemented/do_not_accept_options_of_the_internal_rustc_attribute.rs
warning: `#[diagnostic::on_unimplemented]` can only be applied to trait definitions
--> /home/matthias/vcs/github/rust_misc_stuff/tests/ui/diagnostic_namespace/on_unimplemented/do_not_accept_options_of_the_internal_rustc_attribute.rs:24:1
|
24 | #[diagnostic::on_unimplemented(message = "Not allowed to apply it on a impl")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default
warning: malformed `on_unimplemented` attribute
--> /home/matthias/vcs/github/rust_misc_stuff/tests/ui/diagnostic_namespace/on_unimplemented/do_not_accept_options_of_the_internal_rustc_attribute.rs:4:5
|
4 | on(_Self = "&str"),
| ^^^^^^^^^^^^^^^^^^ invalid option found here
|
= help: only `message`, `note` and `label` are allowed as options
warning: malformed `on_unimplemented` attribute
--> /home/matthias/vcs/github/rust_misc_stuff/tests/ui/diagnostic_namespace/on_unimplemented/do_not_accept_options_of_the_internal_rustc_attribute.rs:10:5
|
10 | parent_label = "in this scope",
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid option found here
|
= help: only `message`, `note` and `label` are allowed as options
warning: malformed `on_unimplemented` attribute
--> /home/matthias/vcs/github/rust_misc_stuff/tests/ui/diagnostic_namespace/on_unimplemented/do_not_accept_options_of_the_internal_rustc_attribute.rs:13:5
|
13 | append_const_msg
| ^^^^^^^^^^^^^^^^ invalid option found here
|
= help: only `message`, `note` and `label` are allowed as options
warning: malformed `on_unimplemented` attribute
--> /home/matthias/vcs/github/rust_misc_stuff/tests/ui/diagnostic_namespace/on_unimplemented/do_not_accept_options_of_the_internal_rustc_attribute.rs:19:32
|
19 | #[diagnostic::on_unimplemented = "Message"]
| ^^^^^^^^^^^ invalid option found here
|
= help: only `message`, `note` and `label` are allowed as options
error[E0277]: trait has `()` and `i32` as params
--> /home/matthias/vcs/github/rust_misc_stuff/tests/ui/diagnostic_namespace/on_unimplemented/do_not_accept_options_of_the_internal_rustc_attribute.rs:61:15
|
61 | takes_foo(());
| --------- ^^ trait has `()` and `i32` as params
| |
| required by a bound introduced by this call
|
= help: the trait `Foo<i32>` is not implemented for `()`
= note: trait has `()` and `i32` as params
help: this trait has no implementations, consider adding one
--> /home/matthias/vcs/github/rust_misc_stuff/tests/ui/diagnostic_namespace/on_unimplemented/do_not_accept_options_of_the_internal_rustc_attribute.rs:17:1
|
17 | trait Foo<T> {}
| ^^^^^^^^^^^^
note: required by a bound in `takes_foo`
--> /home/matthias/vcs/github/rust_misc_stuff/tests/ui/diagnostic_namespace/on_unimplemented/do_not_accept_options_of_the_internal_rustc_attribute.rs:56:22
|
56 | fn takes_foo(_: impl Foo<i32>) {}
| ^^^^^^^^ required by this bound in `takes_foo`
error[E0277]: the trait bound `(): Bar` is not satisfied
--> /home/matthias/vcs/github/rust_misc_stuff/tests/ui/diagnostic_namespace/on_unimplemented/do_not_accept_options_of_the_internal_rustc_attribute.rs:63:15
|
63 | takes_bar(());
| --------- ^^ the trait `Bar` is not implemented for `()`
| |
| required by a bound introduced by this call
|
= help: the trait `Bar` is implemented for `i32`
note: required by a bound in `takes_bar`
--> /home/matthias/vcs/github/rust_misc_stuff/tests/ui/diagnostic_namespace/on_unimplemented/do_not_accept_options_of_the_internal_rustc_attribute.rs:57:22
|
57 | fn takes_bar(_: impl Bar) {}
| ^^^ required by this bound in `takes_bar`
error: internal compiler error: compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs:804:37: broken on_unimplemented "{float}{_Self}{crate_local}{Trait}{ItemContext}" for <() as Baz>: no argument matching "crate_local"
thread 'rustc' panicked at /rustc/6b771f6b5a6c8b03b6322a9c77ac77cb346148f0/compiler/rustc_errors/src/lib.rs:1660:9:
Box<dyn Any>
stack backtrace:
0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
1: <rustc_errors::HandlerInner>::bug::<alloc::string::String>
2: <rustc_errors::Handler>::bug::<alloc::string::String>
3: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
4: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
5: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
6: rustc_middle::util::bug::bug_fmt
7: <rustc_trait_selection::traits::error_reporting::on_unimplemented::OnUnimplementedFormatString>::format
8: <rustc_trait_selection::traits::error_reporting::on_unimplemented::OnUnimplementedDirective>::evaluate
9: <rustc_infer::infer::error_reporting::TypeErrCtxt as rustc_trait_selection::traits::error_reporting::on_unimplemented::TypeErrCtxtExt>::on_unimplemented_note
10: <rustc_infer::infer::error_reporting::TypeErrCtxt as rustc_trait_selection::traits::error_reporting::type_err_ctxt_ext::TypeErrCtxtExt>::report_selection_error
11: <rustc_infer::infer::error_reporting::TypeErrCtxt as rustc_trait_selection::traits::error_reporting::type_err_ctxt_ext::InferCtxtPrivExt>::report_fulfillment_error
12: <rustc_infer::infer::error_reporting::TypeErrCtxt as rustc_trait_selection::traits::error_reporting::type_err_ctxt_ext::TypeErrCtxtExt>::report_fulfillment_errors
13: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_argument_types
14: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_call
15: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
16: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_block_with_expected
17: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
18: rustc_hir_typeck::check::check_fn
19: rustc_hir_typeck::typeck
[... omitted 1 frame ...]
20: rustc_hir_analysis::check_crate
21: rustc_interface::passes::analysis
[... omitted 1 frame ...]
22: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
note: we would appreciate a bug report: https://github.com/rust-marker/marker/issues/new?template=panic.yml
note: please attach the file at `/tmp/marker/rustc-ice-2023-12-17T23_38_20-1810745.txt` to your bug report
query stack during panic:
#0 [typeck] type-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack
note: marker_rustc_driver 0.4.3
note: Achievement Unlocked: [Free Ice Cream]
error: aborting due to 3 previous errors; 5 warnings emitted
For more information about this error, try `rustc --explain E0277`.
Summary
No response
Reproducer
Version
No response
Logs and Backtrace