Skip to content

Missing self_in_typedefs help message #54563

Closed
@leonardo-m

Description

@leonardo-m

This code compiles with recent Nightly:

#![feature(self_in_typedefs)]
enum Tree { Empty, Node(Box<Self>, i32, Box<Self>) }
fn main() {}

If I remove the feature, on Nightly:

enum Tree { Empty, Node(Box<Self>, i32, Box<Self>) }
fn main() {}

It gives error messages but no suggestion to add the self_in_typedefs feature:

error[E0411]: cannot find type `Self` in this scope
 --> ...\test.rs:1:29
  |
1 | enum Tree { Empty, Node(Box<Self>, i32, Box<Self>) }
  |                             ^^^^ `Self` is only available in traits and impls

error[E0411]: cannot find type `Self` in this scope
 --> ...\test.rs:1:45
  |
1 | enum Tree { Empty, Node(Box<Self>, i32, Box<Self>) }
  |                                             ^^^^ `Self` is only available in traits and impls

error: aborting due to 2 previous errors

For some other features Rustc gives such help:

enum Tree { Empty, Node(Box<Tree>, i32, Box<Tree>) }
fn main() {
    let t = Tree::Node(box Tree::Empty, 0, box Tree::Empty);
}
error[E0658]: box expression syntax is experimental; you can call `Box::new` instead. (see issue #49733)
 --> ...\test.rs:3:24
  |
3 |     let t = Tree::Node(box Tree::Empty, 0, box Tree::Empty);
  |                        ^^^^^^^^^^^^^^^
  |
  = help: add #![feature(box_syntax)] to the crate attributes to enable

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsE-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions