Skip to content

We shouldn't even try to resolve irrefutable patterns as constants #49680

Closed
@Manishearth

Description

@Manishearth
pub const bar: u8 = 1;
fn foo(bar: bool) { }

gives me a type error, because it resolves bar to the constant and then realizes it's the wrong type.

Resolving bar to a constant isn't something that will ever work anyway, because if you write something like

pub const bar: bool = true;
fn foo(bar: bool) { }

it will move on to the "refutable pattern in function argument" error.

We should just not attempt constant resolution for irrefutable patterns.

This is technically a language change -- code that would previously not compile will now compile. cc @rust-lang/lang

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-langRelevant to the language team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions