Skip to content

syntax error on edition 2015 anonymous parameters #16291

Open
@matthiaskrgr

Description

@matthiaskrgr
trait ParseError {
    type StreamError;
}
impl<T> ParseError for T {
    type StreamError = ();
}
trait Stream {
    type Error;
}
trait Parser
where
    <Self as Parser>::PartialState: Default,
{
    type PartialState;
    fn parse_mode(&Self, Self::PartialState) {}
}

pub fn main() {}

this compiles with edition 2015.
rustc:

    Checking bar v0.1.0 (/tmp/bar)
warning: anonymous parameters are deprecated and will be removed in the next edition
  --> src/main.rs:16:19
   |
16 |     fn parse_mode(&Self, Self::PartialState) {}
   |                   ^^^^^ help: try naming the parameter or explicitly ignoring it: `_: &Self`
   |
   = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
   = note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686>
   = note: `#[warn(anonymous_parameters)]` on by default

warning: anonymous parameters are deprecated and will be removed in the next edition
  --> src/main.rs:16:26
   |
16 |     fn parse_mode(&Self, Self::PartialState) {}
   |                          ^^^^^^^^^^^^^^^^^^ help: try naming the parameter or explicitly ignoring it: `_: Self::PartialState`
   |
   = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
   = note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686>

warning: `bar` (bin "bar") generated 2 warnings (run `cargo fix --bin "bar"` to apply 2 suggestions)
    Finished dev [unoptimized + debuginfo] target(s) in 0.03s

ra:

// rust-analyzer diagnostics  .
processing crate: bar, module: /tmp/bar/src/main.rs
Diagnostic { code: RustcHardError("syntax-error"), message: "Syntax Error: missing type for function parameter", range: FileRange { file_id: FileId(11), range: 245..245 }, severity: Error, unused: false, experimental: false, fixes: None, main_node: None }
Diagnostic { code: RustcHardError("syntax-error"), message: "Syntax Error: missing type for function parameter", range: FileRange { file_id: FileId(11), range: 265..265 }, severity: Error, unused: false, experimental: false, fixes: None, main_node: None }

diagnostic scan complete

Error: diagnostic error detected

rust-analyzer 1.77.0-nightly (595bc6f 2024-01-05)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-parserparser issuesC-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions