Skip to content

Invalid error (E0425) reported #27433

Closed
Closed
@GuillaumeGomez

Description

@GuillaumeGomez
Member

In the following code:

fn main() {
    let foo = 42u32;
    const FOO : u32 = foo;
}

We have the following errors:

<anon>:3:23: 3:26 error: attempt to use a non-constant value in a constant [E0435]
<anon>:3     const FOO : u32 = foo;
                               ^~~
<anon>:3:23: 3:26 error: unresolved name `foo` [E0425]
<anon>:3     const FOO : u32 = foo;

The first one is "normal", however, the E0425 might mislead developer's understanding on this error.

cc @eddyb

Activity

eddyb

eddyb commented on Jul 31, 2015

@eddyb
Member

IMO the second error is fine, because the local foo variable is not in scope for the FOO constant item.
The first one could be a note instead of an error and rephrased, perhaps.

brson

brson commented on Jan 26, 2017

@brson
Contributor

Current output:

fn main() {
    let foo = 42u32;
    const FOO : u32 = foo;
}

Seems fixed cc @GuillaumeGomez

added
E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
on Jan 26, 2017
brson

brson commented on Jan 26, 2017

@brson
Contributor

Just add test.

GuillaumeGomez

GuillaumeGomez commented on Jan 26, 2017

@GuillaumeGomez
MemberAuthor

@brson: Do you have the PR which fixed this issue by any chance? (so I can add the test accordingly to it if still needed)

brson

brson commented on Jan 27, 2017

@brson
Contributor

@GuillaumeGomez no I do not. I just noticed that the op is working.

added a commit that references this issue on Feb 8, 2017
added a commit that references this issue on Feb 9, 2017

Rollup merge of rust-lang#39653 - JanZerebecki:test-issue-27433, r=al…

removed
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Mar 9, 2017
estebank

estebank commented on Mar 13, 2017

@estebank
Contributor

@brson test merged, this issue can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsE-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @steveklabnik@eddyb@brson@estebank@GuillaumeGomez

        Issue actions

          Invalid error (E0425) reported · Issue #27433 · rust-lang/rust