-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better error for non const PartialEq
call generated by match
#112232
Conversation
r? @b-naber (rustbot has picked a reviewer for you, use r? to override) |
This PR changes Stable MIR This PR changes MIR cc @oli-obk, @RalfJung, @JakobDegen, @davidtwco, @celinval, @vakaras Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
This comment has been minimized.
This comment has been minimized.
f565198
to
fd60cbc
Compare
Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
| | ||
= note: `str` cannot be compared in compile-time, and therefore cannot be used in `match`es | ||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants | ||
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this help note appear to users on stable too? It seems confusing either way, as adding it doesn't fix the error (just makes it slightly more detailed).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it doesn't. Stable users don't get the suggestion to add unstable features.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Had some thoughts/nits.
@@ -271,6 +271,18 @@ pub struct RawBytesNote { | |||
pub bytes: String, | |||
} | |||
|
|||
// FIXME(fee1-dead) do not use stringly typed `ConstContext` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you include this as a reminder to be fixed in this PR or do you want to change this later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to change this later, not in this PR
/// Represents how a `TerminatorKind::Call` was constructed, used for diagnostics | ||
#[derive(Clone, Copy, TyEncodable, TyDecodable, Debug, PartialEq, Hash, HashStable)] | ||
#[derive(TypeFoldable, TypeVisitable)] | ||
pub enum CallDesugaring { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this use a different name? Isn't desugaring exclusively used to refer to lowering of source-level constructs to internal constructs? So maybe ThirCallSource
or something would be more appropriate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if ThirCallSource
would be better as that means Option<ThirCallSource>::None
means that there was no call source from THIR. Option<CallDesugaring>::None
suggests that it was a normal call. For CallDesugaring::Misc
they still didn't come from normal calls so it would still mean using calls internally to represent code that does not explicitly try to call functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't we do this? 😅
enum ThirCallSource {
HirCall,
OverloadedOperator,
MatchCmp,
Misc,
}
@@ -100,7 +100,7 @@ pub struct FnCallNonConst<'tcx> { | |||
pub callee: DefId, | |||
pub substs: SubstsRef<'tcx>, | |||
pub span: Span, | |||
pub from_hir_call: bool, | |||
pub desugar: Option<CallDesugaring>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a similar comment to the one in TerminatorKind
?
/// is false then this is the desugaring. | ||
OverloadedOperator, | ||
/// This was from comparison generated by a match. | ||
MatchCmp, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you link to #90237 here?
☔ The latest upstream changes (presumably #112625) made this pull request unmergeable. Please resolve the merge conflicts. |
fd60cbc
to
f345403
Compare
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #100036) made this pull request unmergeable. Please resolve the merge conflicts. |
61db4ed
to
3de318b
Compare
3de318b
to
89c24af
Compare
Thanks for changing that. @bors r+ rollup |
…sg, r=b-naber Better error for non const `PartialEq` call generated by `match` Resolves rust-lang#90237
@bors r- failed in rollup: #112771 (comment) |
@bors r+ rollup |
…mpiler-errors Rollup of 8 pull requests Successful merges: - rust-lang#112232 (Better error for non const `PartialEq` call generated by `match`) - rust-lang#112499 (Fix python linting errors) - rust-lang#112596 (Suggest correct signature on missing fn returning RPITIT/AFIT) - rust-lang#112606 (Alter `Display` for `Ipv6Addr` for IPv4-compatible addresses) - rust-lang#112781 (Don't consider TAIT normalizable to hidden ty if it would result in impossible item bounds) - rust-lang#112787 (Add gha problem matcher) - rust-lang#112799 (Clean up "doc(hidden)" check) - rust-lang#112803 (Format the examples directory of cg_clif) r? `@ghost` `@rustbot` modify labels: rollup
…sg, r=b-naber Better error for non const `PartialEq` call generated by `match` Resolves rust-lang#90237
…sg, r=b-naber Better error for non const `PartialEq` call generated by `match` Resolves rust-lang#90237
Resolves #90237