Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5461fd4
Gracefully handle non-WF alias in assemble_alias_bound_candidates_recur
compiler-errors Feb 10, 2024
1fa75af
Add test
c410-f3r Feb 11, 2024
89abbb0
Add ChrisDenton to review queue
ChrisDenton Feb 11, 2024
d5de9a6
check_consts: fix some duplicate errors by not calling check_static u…
RalfJung Feb 11, 2024
e13de31
make Primary/Secondary importance consistent between CellBorrow and M…
RalfJung Feb 11, 2024
792fa24
improve `btree_cursors` functions documentation
ripytide Feb 11, 2024
f415339
fix incorrect doctest
ripytide Feb 11, 2024
9789e88
Check that the ABI of the instance we are inlining is correct
compiler-errors Feb 11, 2024
f34d9da
fix intra-doc links
ripytide Feb 11, 2024
c35983a
Reorder the diagnostic API methods.
nnethercote Feb 8, 2024
b7b6ebc
Fix inconsistencies in the diagnostic API methods.
nnethercote Feb 8, 2024
2bcbc16
remove a bunch of dead parameters in fn
chenyukang Feb 11, 2024
fc7693d
Clean inlined type alias with correct param-env
compiler-errors Feb 12, 2024
30774b0
Remove final unwanted `unchecked_error_guaranteed` calls.
nnethercote Feb 9, 2024
e0a0cc2
Remove `dcx` arg from `ReportErrorExt::add_args`.
nnethercote Feb 12, 2024
d4b77f6
Tweak delayed bug mentions.
nnethercote Feb 12, 2024
1f39c8b
Change level used in `print_error_count`.
nnethercote Feb 12, 2024
95c5b06
fix ICE for deref coercions with type errors
Feb 11, 2024
57a2e91
Rollup merge of #120765 - nnethercote:reorder-diag-API, r=compiler-er…
matthiaskrgr Feb 12, 2024
f08ece3
Rollup merge of #120833 - nnethercote:more-internal-emit_diagnostics-…
matthiaskrgr Feb 12, 2024
733f93d
Rollup merge of #120899 - compiler-errors:non-wf-alias, r=lcnr
matthiaskrgr Feb 12, 2024
ebe36ac
Rollup merge of #120917 - chenyukang:yukang-dead-parameters, r=compil…
matthiaskrgr Feb 12, 2024
02c1e3e
Rollup merge of #120928 - c410-f3r:tests-tests-tests, r=davidtwco
matthiaskrgr Feb 12, 2024
3f67169
Rollup merge of #120933 - RalfJung:const-check-misc, r=oli-obk
matthiaskrgr Feb 12, 2024
8305686
Rollup merge of #120936 - ripytide:master, r=Amanieu
matthiaskrgr Feb 12, 2024
8ec144d
Rollup merge of #120944 - compiler-errors:inliner-abi, r=oli-obk
matthiaskrgr Feb 12, 2024
a0156e5
Rollup merge of #120956 - compiler-errors:clean-type-alias, r=Guillau…
matthiaskrgr Feb 12, 2024
323f66a
Rollup merge of #120962 - ChrisDenton:review, r=Nilstrieb
matthiaskrgr Feb 12, 2024
8e5f722
Rollup merge of #120972 - lukas-code:autoderef-type-error, r=compiler…
matthiaskrgr Feb 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
check_consts: fix some duplicate errors by not calling check_static u…
…nnecessarily
  • Loading branch information
RalfJung committed Feb 11, 2024
commit d5de9a610556642da338e62c53f04ce4cc7f02b6
8 changes: 5 additions & 3 deletions compiler/rustc_const_eval/src/transform/check_consts/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,9 +619,11 @@ 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);
// If this is a static, then this is not really dereferencing a pointer,
// just directly accessing a static. That is not subject to any feature
// gates (except for the one about whether statics can even be used, but
// that is checked already by `visit_operand`).
if let LocalInfo::StaticRef { .. } = *decl.local_info() {
return;
}
}
Expand Down
1 change: 0 additions & 1 deletion tests/ui/consts/issue-17718-const-bad-values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const C1: &'static mut [usize] = &mut [];
static mut S: usize = 3;
const C2: &'static mut usize = unsafe { &mut S };
//~^ ERROR: referencing statics in constants
//~| ERROR: referencing statics in constants
//~| WARN mutable reference of mutable static is discouraged [static_mut_ref]

fn main() {}
15 changes: 1 addition & 14 deletions tests/ui/consts/issue-17718-const-bad-values.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,7 @@ LL | const C2: &'static mut usize = unsafe { &mut S };
= note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
= help: to fix this, the value can be extracted to a `const` and then used.

error[E0658]: referencing statics in constants is unstable
--> $DIR/issue-17718-const-bad-values.rs:5:46
|
LL | const C2: &'static mut usize = unsafe { &mut S };
| ^
|
= note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information
= help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
= note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
= help: to fix this, the value can be extracted to a `const` and then used.
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: aborting due to 3 previous errors; 1 warning emitted
error: aborting due to 2 previous errors; 1 warning emitted

Some errors have detailed explanations: E0658, E0764.
For more information about an error, try `rustc --explain E0658`.
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ help: skipping check for `const_refs_to_static` feature
|
LL | const READ_MUT: u32 = unsafe { MUTABLE };
| ^^^^^^^
help: skipping check for `const_refs_to_static` feature
--> $DIR/const_refers_to_static.rs:18:32
|
LL | const READ_MUT: u32 = unsafe { MUTABLE };
| ^^^^^^^
help: skipping check for `const_refs_to_static` feature
--> $DIR/const_refers_to_static.rs:24:18
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ help: skipping check for `const_refs_to_static` feature
|
LL | const READ_MUT: u32 = unsafe { MUTABLE };
| ^^^^^^^
help: skipping check for `const_refs_to_static` feature
--> $DIR/const_refers_to_static.rs:18:32
|
LL | const READ_MUT: u32 = unsafe { MUTABLE };
| ^^^^^^^
help: skipping check for `const_refs_to_static` feature
--> $DIR/const_refers_to_static.rs:24:18
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,6 @@ help: skipping check for `const_refs_to_static` feature
|
LL | unsafe { &static_cross_crate::ZERO }
| ^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check for `const_refs_to_static` feature
--> $DIR/const_refers_to_static_cross_crate.rs:12:15
|
LL | unsafe { &static_cross_crate::ZERO }
| ^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check for `const_refs_to_static` feature
--> $DIR/const_refers_to_static_cross_crate.rs:18:15
|
LL | unsafe { &static_cross_crate::ZERO[0] }
| ^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check for `const_refs_to_static` feature
--> $DIR/const_refers_to_static_cross_crate.rs:18:15
|
LL | unsafe { &static_cross_crate::ZERO[0] }
| ^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check for `const_refs_to_static` feature
--> $DIR/const_refers_to_static_cross_crate.rs:18:15
|
Expand All @@ -113,26 +98,6 @@ help: skipping check for `const_refs_to_static` feature
|
LL | match static_cross_crate::OPT_ZERO {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check for `const_refs_to_static` feature
--> $DIR/const_refers_to_static_cross_crate.rs:28:15
|
LL | match static_cross_crate::OPT_ZERO {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check for `const_refs_to_static` feature
--> $DIR/const_refers_to_static_cross_crate.rs:28:15
|
LL | match static_cross_crate::OPT_ZERO {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check for `const_refs_to_static` feature
--> $DIR/const_refers_to_static_cross_crate.rs:28:15
|
LL | match static_cross_crate::OPT_ZERO {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check for `const_refs_to_static` feature
--> $DIR/const_refers_to_static_cross_crate.rs:28:15
|
LL | match static_cross_crate::OPT_ZERO {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 8 previous errors; 2 warnings emitted

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,6 @@ help: skipping check for `const_refs_to_static` feature
|
LL | unsafe { &static_cross_crate::ZERO }
| ^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check for `const_refs_to_static` feature
--> $DIR/const_refers_to_static_cross_crate.rs:12:15
|
LL | unsafe { &static_cross_crate::ZERO }
| ^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check for `const_refs_to_static` feature
--> $DIR/const_refers_to_static_cross_crate.rs:18:15
|
LL | unsafe { &static_cross_crate::ZERO[0] }
| ^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check for `const_refs_to_static` feature
--> $DIR/const_refers_to_static_cross_crate.rs:18:15
|
LL | unsafe { &static_cross_crate::ZERO[0] }
| ^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check for `const_refs_to_static` feature
--> $DIR/const_refers_to_static_cross_crate.rs:18:15
|
Expand All @@ -113,26 +98,6 @@ help: skipping check for `const_refs_to_static` feature
|
LL | match static_cross_crate::OPT_ZERO {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check for `const_refs_to_static` feature
--> $DIR/const_refers_to_static_cross_crate.rs:28:15
|
LL | match static_cross_crate::OPT_ZERO {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check for `const_refs_to_static` feature
--> $DIR/const_refers_to_static_cross_crate.rs:28:15
|
LL | match static_cross_crate::OPT_ZERO {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check for `const_refs_to_static` feature
--> $DIR/const_refers_to_static_cross_crate.rs:28:15
|
LL | match static_cross_crate::OPT_ZERO {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check for `const_refs_to_static` feature
--> $DIR/const_refers_to_static_cross_crate.rs:28:15
|
LL | match static_cross_crate::OPT_ZERO {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 8 previous errors; 2 warnings emitted

Expand Down
15 changes: 0 additions & 15 deletions tests/ui/consts/miri_unleashed/mutable_references_err.32bit.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,6 @@ help: skipping check for `const_refs_to_static` feature
|
LL | const SUBTLE: &mut i32 = unsafe { &mut FOO };
| ^^^
help: skipping check for `const_refs_to_static` feature
--> $DIR/mutable_references_err.rs:32:40
|
LL | const SUBTLE: &mut i32 = unsafe { &mut FOO };
| ^^^
help: skipping check that does not even have a feature gate
--> $DIR/mutable_references_err.rs:32:35
|
Expand All @@ -144,16 +139,6 @@ help: skipping check for `const_refs_to_static` feature
|
LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE };
| ^^^^^^^
help: skipping check for `const_refs_to_static` feature
--> $DIR/mutable_references_err.rs:47:44
|
LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE };
| ^^^^^^^
help: skipping check for `const_refs_to_static` feature
--> $DIR/mutable_references_err.rs:51:45
|
LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF };
| ^^^^^^^^^^^
help: skipping check for `const_refs_to_static` feature
--> $DIR/mutable_references_err.rs:51:45
|
Expand Down
15 changes: 0 additions & 15 deletions tests/ui/consts/miri_unleashed/mutable_references_err.64bit.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,6 @@ help: skipping check for `const_refs_to_static` feature
|
LL | const SUBTLE: &mut i32 = unsafe { &mut FOO };
| ^^^
help: skipping check for `const_refs_to_static` feature
--> $DIR/mutable_references_err.rs:32:40
|
LL | const SUBTLE: &mut i32 = unsafe { &mut FOO };
| ^^^
help: skipping check that does not even have a feature gate
--> $DIR/mutable_references_err.rs:32:35
|
Expand All @@ -144,16 +139,6 @@ help: skipping check for `const_refs_to_static` feature
|
LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE };
| ^^^^^^^
help: skipping check for `const_refs_to_static` feature
--> $DIR/mutable_references_err.rs:47:44
|
LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE };
| ^^^^^^^
help: skipping check for `const_refs_to_static` feature
--> $DIR/mutable_references_err.rs:51:45
|
LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF };
| ^^^^^^^^^^^
help: skipping check for `const_refs_to_static` feature
--> $DIR/mutable_references_err.rs:51:45
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const C1_READ: () = {
assert!(*C1 == 0);
};
const C2: *const i32 = unsafe { std::ptr::addr_of!(S_MUT) }; //~ERROR: referencing statics in constants is unstable
//~^ERROR: referencing statics in constants is unstable

fn main() {
}
15 changes: 1 addition & 14 deletions tests/ui/feature-gates/feature-gate-const-refs-to-static.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,6 @@ LL | const C2: *const i32 = unsafe { std::ptr::addr_of!(S_MUT) };
= note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
= help: to fix this, the value can be extracted to a `const` and then used.

error[E0658]: referencing statics in constants is unstable
--> $DIR/feature-gate-const-refs-to-static.rs:8:52
|
LL | const C2: *const i32 = unsafe { std::ptr::addr_of!(S_MUT) };
| ^^^^^
|
= note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information
= help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
= note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
= help: to fix this, the value can be extracted to a `const` and then used.
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: aborting due to 3 previous errors
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0658`.
1 change: 0 additions & 1 deletion tests/ui/thread-local/thread-local-static.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

fn main() {}
14 changes: 1 addition & 13 deletions tests/ui/thread-local/thread-local-static.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,6 @@ error[E0625]: thread-local statics cannot be accessed at compile-time
LL | std::mem::swap(x, &mut STATIC_VAR_2)
| ^^^^^^^^^^^^

error[E0658]: referencing statics in constant functions is unstable
--> $DIR/thread-local-static.rs:10:28
|
LL | std::mem::swap(x, &mut STATIC_VAR_2)
| ^^^^^^^^^^^^
|
= note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information
= help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
= note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
= help: to fix this, the value can be extracted to a `const` and then used.

error[E0658]: mutable references are not allowed in constant functions
--> $DIR/thread-local-static.rs:10:23
|
Expand All @@ -59,7 +47,7 @@ LL | std::mem::swap(x, &mut STATIC_VAR_2)
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error: aborting due to 5 previous errors; 1 warning emitted
error: aborting due to 4 previous errors; 1 warning emitted

Some errors have detailed explanations: E0133, E0625, E0658.
For more information about an error, try `rustc --explain E0133`.