Skip to content

let x: vec![] makes rust suggest modifying stdlib #158492

Description

@theemathas

Code

fn main() {
    let x: vec![];
}

Current output

error: expected type, found associated function call
  --> src/main.rs:2:12
   |
 2 |     let x: vec![];
   |            ^^^^^^
   |
help: use `=` if you meant to assign
  --> /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/macros.rs:44:9
   |
44 -         $crate::vec::Vec::new()
44 +          = 
   |

Desired output

Rationale and extra context

No response

Other cases

Rust Version

Reproducible on the playground with version 1.98.0-nightly (2026-06-26 ce9954c0cfc4bf26b82a)

Anything else?

No response

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions