-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
check_consts: fix duplicate errors, make importance consistent #120933
Conversation
@@ -619,9 +619,12 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> { | |||
if base_ty.is_unsafe_ptr() { | |||
if place_ref.projection.is_empty() { | |||
let decl = &self.body.local_decls[place_ref.local]; | |||
if let LocalInfo::StaticRef { def_id, .. } = *decl.local_info() { | |||
let span = decl.source_info.span; | |||
self.check_static(def_id, span); |
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.
We already check_static each operand we see, so I don't understand why this was checked again here.
@@ -12,7 +12,6 @@ const fn g(x: &mut [u32; 8]) { | |||
//~^^ ERROR thread-local statics cannot be accessed | |||
//~| ERROR mutable references are not allowed | |||
//~| ERROR use of mutable static is unsafe | |||
//~| referencing statics |
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.
Here this was not a literal duplicate -- the other error is "thread-local statics cannot be accessed". So the old error was even wrong, since STATIC_VAR_2 is a thread-local static, not a regular static, and saying that this is "unstable" and needs the const_refs_to_static feature gate is not correct.
e93abfc
to
e13de31
Compare
@bors r+ rollup |
check_consts: fix duplicate errors, make importance consistent This is stuff I noticed while working on rust-lang#120932, but it's orthogonal to that PR. r? `@oli-obk`
…iaskrgr Rollup of 11 pull requests Successful merges: - rust-lang#120765 (Reorder diagnostics API) - rust-lang#120833 (More internal emit diagnostics cleanups) - rust-lang#120899 (Gracefully handle non-WF alias in `assemble_alias_bound_candidates_recur`) - rust-lang#120917 (Remove a bunch of dead parameters in functions) - rust-lang#120928 (Add test for recently fixed issue) - rust-lang#120933 (check_consts: fix duplicate errors, make importance consistent) - rust-lang#120936 (improve `btree_cursors` functions documentation) - rust-lang#120944 (Check that the ABI of the instance we are inlining is correct) - rust-lang#120956 (Clean inlined type alias with correct param-env) - rust-lang#120962 (Add myself to library/std review) - rust-lang#120972 (fix ICE for deref coercions with type errors) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#120933 - RalfJung:const-check-misc, r=oli-obk check_consts: fix duplicate errors, make importance consistent This is stuff I noticed while working on rust-lang#120932, but it's orthogonal to that PR. r? ``@oli-obk``
…iaskrgr Rollup of 11 pull requests Successful merges: - rust-lang#120765 (Reorder diagnostics API) - rust-lang#120833 (More internal emit diagnostics cleanups) - rust-lang#120899 (Gracefully handle non-WF alias in `assemble_alias_bound_candidates_recur`) - rust-lang#120917 (Remove a bunch of dead parameters in functions) - rust-lang#120928 (Add test for recently fixed issue) - rust-lang#120933 (check_consts: fix duplicate errors, make importance consistent) - rust-lang#120936 (improve `btree_cursors` functions documentation) - rust-lang#120944 (Check that the ABI of the instance we are inlining is correct) - rust-lang#120956 (Clean inlined type alias with correct param-env) - rust-lang#120962 (Add myself to library/std review) - rust-lang#120972 (fix ICE for deref coercions with type errors) r? `@ghost` `@rustbot` modify labels: rollup
This is stuff I noticed while working on #120932, but it's orthogonal to that PR.
r? @oli-obk