Skip to content

use dyn syntax in error messages #49277

Closed

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>`

Activity

  1. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Mar 22, 2018
  2. added a commit that references this issue on Jun 26, 2018
    d72a67f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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