Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syntax error on edition 2015 anonymous parameters #16291

Open
matthiaskrgr opened this issue Jan 6, 2024 · 1 comment
Open

syntax error on edition 2015 anonymous parameters #16291

matthiaskrgr opened this issue Jan 6, 2024 · 1 comment
Labels
A-parser parser issues C-bug Category: bug

Comments

@matthiaskrgr
Copy link
Member

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)

@matthiaskrgr matthiaskrgr added the C-bug Category: bug label Jan 6, 2024
@Young-Flash
Copy link
Member

related to #16324

@Veykril Veykril added the A-parser parser issues label Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser parser issues C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

3 participants