rust-lang / rust-lang/rust

never type appears in duplicate diagnostics

Open
#139,790 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-diagnostics F-const_trait_impl T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code
const fn foo() -> Option<()> { None?; None }
Current output
error[E0015]: `?` is not allowed on `Option<!>` in constant functions
 --> src/lib.rs:1:32
  |
1 | const fn foo() -> Option<()> { None?; None }
  |                                ^^^^^
  |
  = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants

error[E0015]: `?` is not allowed on `Option<()>` in constant functions
 --> src/lib.rs:1:32
  |
1 | const fn foo() -> Option<()> { None?; None }
  |                                ^^^^^
  |
  = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants

For more information about this error, try `rustc --explain E0015`.
error: could not compile `playground` (lib) due to 2 previous errors
Desired output
Minus the diagnostic about `Option<!>`
Rationale and extra context

This only happens on edition 2024.

Other cases

Rust Version
edition 2024
Anything else?

https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=44414f7fe4f727ef3120e30015bfdd28

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the linked Playground reproducer with edition 2024 and compare the two E0015 diagnostics. Trace the rustc diagnostic path responsible for the duplicate Option<!> and Option<()> messages, then add or update a regression test showing that only the valid diagnostic remains.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.