Skip to content

Wrong message from object safety checker #40670

Closed
@qnighy

Description

@qnighy

UPDATE: There are mentoring instructions to be found in a comment below.


Object safety checker produces messages with "supertrait something" even when the cause is in where-clause.

trait Bar<X:?Sized> {}
trait Foo where Box<Self>: Bar<Self> {}
fn f(x: Box<Foo>) {}
fn main () {
}
rustc 1.17.0-nightly (b1e31766d 2017-03-03)
error[E0038]: the trait `Foo` cannot be made into an object
 --> <anon>:3:1
  |
3 | fn f(x: Box<Foo>) {}
  | ^^^^^^^^^^^^^^^^^^^^ the trait `Foo` cannot be made into an object
  |
  = note: the trait cannot use `Self` as a type parameter in the supertrait listing

error: aborting due to previous error

Rust Playground: https://is.gd/mAvVNW

Indeed this seems object-unsafe, but the message should be something about "where-clause", not "supertrait listing".

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.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