Skip to content

#[diagnostic::on_const] needs better generic parameter handling. #155570

Description

@mejrs

For example: playground

#![crate_type = "lib"]
#![feature(diagnostic_on_const, const_trait_impl)]

pub struct X<A, B> {
    field: (A, B),
}

pub const trait Y<Z> {
    fn blah(&self) {}
}

#[diagnostic::on_const(note = "Self = {Self}, Z = {Z}, A = {A}, B = {B}")]
impl<Z, A, B> Y<Z> for X<A, B> {}

const _: () = {
    X {
        field: (42_u8, "hello"),
    }
    .blah();
};

Compiler output:

  = note: Self = X<u8, &str>, Z = _, A = {A}, B = {B}
  • I expect it should be able to print A and B, since they're concrete in this scenario.
  • Is it right to print Z = _?
  • There's also no lint for if you try to format a generic that isn't anywhere on the trait, impl, or adt.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsF-const_trait_impl`#![feature(const_trait_impl)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions