Skip to content

use dyn syntax in error messages #49277

Closed
@nikomatsakis

Description

@nikomatsakis

We have not yet stabilized dyn Trait (see #49218), but once we do, we should start using it in error messages. So for example this test:

#![feature(dyn_trait)]
use std::fmt::{Debug, Display};
fn main() {
    let x: Box<dyn Debug> = Box::new(1);
    let _: Box<dyn Display> = x;
}

should print

error[E0308]: mismatched types
 --> src/main.rs:5:31
  |
5 |     let _: Box<dyn Display> = x;
  |                               ^ expected trait `std::fmt::Display`, found trait `std::fmt::Debug`
  |
  = note: expected type `std::boxed::Box<dyn std::fmt::Display>`
             found type `std::boxed::Box<dyn std::fmt::Debug>`

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-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