Skip to content

Prevent expr_cast hides prior error. #5889

New issue

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

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

Already on GitHub? # to your account

Closed
wants to merge 1 commit into from

Conversation

youknowone
Copy link
Contributor

This will help not to meet confusing errors.
In issue #5873, the error was "expected constant expr for vector length: Can't cast str to int".
It was orignally "expected constant expr for vector length: Non-constant path in constant expr" (though still invalid error).
This patch make the original error to be printed.

This will help not to meet confusing errors.
In issue rust-lang#5873, the error was "expected constant expr for vector length: Can't cast str to int".
It was originally "expected constant expr for vector length: Non-constant path in constant expr" (though still invalid error).
This patch make the original error to be printed.
@youknowone
Copy link
Contributor Author

Oh.. I made pull request to master. sorry.

@youknowone youknowone closed this Apr 15, 2013
flip1995 pushed a commit to flip1995/rust that referenced this pull request Aug 11, 2020
…r=Manishearth

Avoid or_fun_call for const_fn with no args

Based on rust-lang#5682 by @lzutao

This avoids a subset of false positives, specifically those related to `const fn`s that take no arguments.
For the rest, a much more involved fix would be needed, see rust-lang/rust-clippy#5682 (comment).

So this does *not* solve rust-lang#5658

changelog: Avoid triggering [`or_fun_call`] with `const fn`s that take no arguments.

Fixes rust-lang#5886
flip1995 pushed a commit to flip1995/rust that referenced this pull request Sep 10, 2020
or_fn_call: ignore nullary associated const fns

The fix in rust-lang#5889 was missing associated functions.

changelog: Ignore also `const fn` methods in [`or_fun_call`]

Fixes rust-lang#5693
flip1995 pushed a commit to flip1995/rust that referenced this pull request Oct 9, 2020
…thiaskrgr

Revert: or_fun_call should lint calls to `const fn`s with no args

The changes in rust-lang#5889 and rust-lang#5984 were done under the incorrect assumption that a `const fn` with no args was guaranteed to be evaluated at compile time.  A `const fn` is only guaranteed to be evaluated at compile time if it's inside a const context (the initializer of a `const` or a `static`).

See this [zulip conversation](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/Common.20misconception.3A.20.60const.20fn.60.20and.20its.20effect.20on.20codegen/near/208059113) for more details on this common misconception.

Given that none of the linted methods by `or_fun_call` can be called in const contexts, the lint should make no exceptions.

changelog: [`or_fun_call`] lints again calls to `const fn` with no args
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant