-
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
Make promote_consts
emit the errors when required promotion fails
#65946
Conversation
@@ -360,8 +369,6 @@ impl<'tcx> Validator<'_, 'tcx> { | |||
} | |||
}, | |||
Candidate::Argument { bb, index } => { | |||
assert!(self.explicit); | |||
|
|||
let terminator = self.body[bb].terminator(); | |||
match &terminator.kind { | |||
TerminatorKind::Call { args, .. } => { |
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 guess you didn't want to emit the error here?
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 can imagine calling validate_candidate
and not wanting to emit errors, e.g. for diagnostics.
} else { | ||
if is_shuffle { | ||
span_err!(self.tcx.sess, self.span, E0526, | ||
"shuffle indices are not constant"); |
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.
Probably need to fix tests because this shuffle-specific error message/code isn't emitted anymore? (i.e. now shuffles use the more general error)
I wonder what @gnzlbg thinks (it wouldn't be that hard to keep tbh).
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.
There are no tests for non-const simd_shuffle
args AFAICT. I could add one in this PR.
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 can store is_shuffle
in Candidate::Argument
for now. Up to you.
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 actually sure how to test simd_shuffle
, I might have to add a test in stdarch
? The only thing exposed from core
are platform-specific intrinsics that wrap the LLVM one and that already have rustc_args_required_const
. Let me know if you have ideas.
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.
Probably need to fix tests because this shuffle-specific error message/code isn't emitted anymore? (i.e. now shuffles use the more general error)
I wonder what @gnzlbg thinks (it wouldn't be that hard to keep tbh).
The shuffle intrinsics are only directly used by libcore, so this errors should only be seen by libcore
-developers. I don't think having an specific error for this is worth it, the general one should do. rust-lang/stdarch#825 looks like a nice way to solve this problem, so this LGTM.
e7b0424
to
5e00a78
Compare
5e00a78
to
122c6fe
Compare
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.
r=me after error code cleanup
if !IsNotPromotable::in_operand(self, arg) { | ||
debug!("visit_terminator_kind: candidate={:?}", candidate); | ||
self.promotion_candidates.push(candidate); | ||
} else { | ||
if is_shuffle { | ||
span_err!(self.tcx.sess, self.span, E0526, |
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.
Please remove (comment out? not sure) E0526
from:
src/librustc_mir/error_codes.rs
src/tools/tidy/src/error_codes_check.rs
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 removed it entirely from tidy
but commented it out in librustc_mir
where there's other unused errors that are commented out.
It remains as a comment in `error_codes.rs` for consistency with other unused errors.
All instances of the unused error code have been removed or commented out. @bors r+ r=eddyb |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
📌 Commit 627e3ef has been approved by |
Clearly I need to read up on bors etiquette XD. |
… r=eddyb Make `promote_consts` emit the errors when required promotion fails A very minimal version of rust-lang#65942. This will cause a generic "argument X is required to be a constant" message for `simd_shuffle` LLVM intrinsics instead of the [custom one](https://github.com/rust-lang/rust/blob/caa1f8d7b3b021c86a70ff62d23a07d97acff4c4/src/librustc_mir/transform/qualify_consts.rs#L1616). It may be possible to remove this special-casing altogether after rust-lang/stdarch#825. r? @eddyb
Rollup of 14 pull requests Successful merges: - #65112 (Add lint and tests for unnecessary parens around types) - #65459 (Fix `-Zunpretty=mir-cfg` to render multiple items) - #65471 (Add long error explanation for E0578) - #65857 (rustdoc: Resolve module-level doc references more locally) - #65914 (Use structured suggestion for unnecessary bounds in type aliases) - #65945 (Optimize long-linker-command-line test) - #65946 (Make `promote_consts` emit the errors when required promotion fails) - #65960 (doc: reword iter module example and mention other methods) - #65963 (update submodules to rust-lang) - #65972 (Fix libunwind build: Define __LITTLE_ENDIAN__ for LE targets) - #65977 (Fix incorrect diagnostics for expected type in E0271 with an associated type) - #65995 (Add error code E0743 for "C-variadic has been used on a non-foreign function") - #65997 (Fix outdated rustdoc of Once::init_locking function) - #66005 (vxWorks: remove code related unix socket) Failed merges: r? @ghost
… r=eddyb Make `promote_consts` emit the errors when required promotion fails A very minimal version of rust-lang#65942. This will cause a generic "argument X is required to be a constant" message for `simd_shuffle` LLVM intrinsics instead of the [custom one](https://github.com/rust-lang/rust/blob/caa1f8d7b3b021c86a70ff62d23a07d97acff4c4/src/librustc_mir/transform/qualify_consts.rs#L1616). It may be possible to remove this special-casing altogether after rust-lang/stdarch#825. r? @eddyb
Rollup of 16 pull requests Successful merges: - #65112 (Add lint and tests for unnecessary parens around types) - #65470 (Don't hide ICEs from previous incremental compiles) - #65471 (Add long error explanation for E0578) - #65857 (rustdoc: Resolve module-level doc references more locally) - #65902 (Make ItemContext available for better diagnositcs) - #65914 (Use structured suggestion for unnecessary bounds in type aliases) - #65946 (Make `promote_consts` emit the errors when required promotion fails) - #65960 (doc: reword iter module example and mention other methods) - #65963 (update submodules to rust-lang) - #65972 (Fix libunwind build: Define __LITTLE_ENDIAN__ for LE targets) - #65977 (Fix incorrect diagnostics for expected type in E0271 with an associated type) - #65995 (Add error code E0743 for "C-variadic has been used on a non-foreign function") - #65997 (Fix outdated rustdoc of Once::init_locking function) - #66002 (Stabilize float_to_from_bytes feature) - #66005 (vxWorks: remove code related unix socket) - #66018 (Revert PR 64324: dylibs export generics again (for now)) Failed merges: r? @ghost
A very minimal version of #65942.
This will cause a generic "argument X is required to be a constant" message for
simd_shuffle
LLVM intrinsics instead of the custom one. It may be possible to remove this special-casing altogether after rust-lang/stdarch#825.r? @eddyb