about summary refs log tree commit diff
path: root/tests/ui/statics
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-07-01 14:59:58 +0000
committerbors <bors@rust-lang.org>2025-07-01 14:59:58 +0000
commit4e973370053a5fe87ee96d43c506623e9bd1eb9d (patch)
tree3aee0330fbc9174bfc1274ba909cfb5a2ece11c1 /tests/ui/statics
parent076a0a26fd6f4c445647a33d6daaac56f732ac05 (diff)
parent422eea2863e7b60dae30eb1a348eea446ac6003a (diff)
downloadrust-4e973370053a5fe87ee96d43c506623e9bd1eb9d.tar.gz
rust-4e973370053a5fe87ee96d43c506623e9bd1eb9d.zip
Auto merge of #142030 - oli-obk:wfck-less-hir, r=compiler-errors
Start moving wf checking away from HIR

I'm trying to only access the HIR in the error path. My hope is that once we move significant portions of wfcheck off HIR that incremental will be able to cache wfcheck queries significantly better.

I think I am reaching a blocker because we normally need to provide good spans to `ObligationCause`, so that the trait solver can report good errors. In some cases I have been able to use bad spans and improve them depending on the `ObligationCauseCode` (by loading HIR in the case where we actually want to error). To scale that further we'll likely need to remove spans from the `ObligationCause` entirely (leaving it to some variants of `ObligationCauseCode` to have a span when they can't recompute the information later). Unsure this is the right approach, but we've already been using it. I will create an MCP about it, but that should not affect this PR, which is fairly limited in where it does those kind of tricks.

Especially https://github.com/rust-lang/rust/commit/b862d8828e375ab8c128a9d9e93bf98b77cb5928 is interesting here, because I think it improves spans in all cases
Diffstat (limited to 'tests/ui/statics')
-rw-r--r--tests/ui/statics/issue-17718-static-sync.stderr4
-rw-r--r--tests/ui/statics/uninhabited-static.stderr24
-rw-r--r--tests/ui/statics/unsized_type2.stderr4
-rw-r--r--tests/ui/statics/unsizing-wfcheck-issue-127299.stderr4
4 files changed, 18 insertions, 18 deletions
diff --git a/tests/ui/statics/issue-17718-static-sync.stderr b/tests/ui/statics/issue-17718-static-sync.stderr
index 96f894146c5..d49dbd947c5 100644
--- a/tests/ui/statics/issue-17718-static-sync.stderr
+++ b/tests/ui/statics/issue-17718-static-sync.stderr
@@ -1,8 +1,8 @@
 error[E0277]: `Foo` cannot be shared between threads safely
-  --> $DIR/issue-17718-static-sync.rs:9:13
+  --> $DIR/issue-17718-static-sync.rs:9:1
    |
 LL | static BAR: Foo = Foo;
-   |             ^^^ `Foo` cannot be shared between threads safely
+   | ^^^^^^^^^^^^^^^ `Foo` cannot be shared between threads safely
    |
    = help: the trait `Sync` is not implemented for `Foo`
    = note: shared static variables must have a type that implements `Sync`
diff --git a/tests/ui/statics/uninhabited-static.stderr b/tests/ui/statics/uninhabited-static.stderr
index f799a82f139..a0f9ad6772d 100644
--- a/tests/ui/statics/uninhabited-static.stderr
+++ b/tests/ui/statics/uninhabited-static.stderr
@@ -1,8 +1,8 @@
 error: static of uninhabited type
-  --> $DIR/uninhabited-static.rs:6:5
+  --> $DIR/uninhabited-static.rs:12:1
    |
-LL |     static VOID: Void;
-   |     ^^^^^^^^^^^^^^^^^
+LL | static VOID2: Void = unsafe { std::mem::transmute(()) };
+   | ^^^^^^^^^^^^^^^^^^
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #74840 <https://github.com/rust-lang/rust/issues/74840>
@@ -14,30 +14,30 @@ LL | #![deny(uninhabited_static)]
    |         ^^^^^^^^^^^^^^^^^^
 
 error: static of uninhabited type
-  --> $DIR/uninhabited-static.rs:8:5
+  --> $DIR/uninhabited-static.rs:15:1
    |
-LL |     static NEVER: !;
-   |     ^^^^^^^^^^^^^^^
+LL | static NEVER2: Void = unsafe { std::mem::transmute(()) };
+   | ^^^^^^^^^^^^^^^^^^^
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #74840 <https://github.com/rust-lang/rust/issues/74840>
    = note: uninhabited statics cannot be initialized, and any access would be an immediate error
 
 error: static of uninhabited type
-  --> $DIR/uninhabited-static.rs:12:1
+  --> $DIR/uninhabited-static.rs:6:5
    |
-LL | static VOID2: Void = unsafe { std::mem::transmute(()) };
-   | ^^^^^^^^^^^^^^^^^^
+LL |     static VOID: Void;
+   |     ^^^^^^^^^^^^^^^^^
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #74840 <https://github.com/rust-lang/rust/issues/74840>
    = note: uninhabited statics cannot be initialized, and any access would be an immediate error
 
 error: static of uninhabited type
-  --> $DIR/uninhabited-static.rs:15:1
+  --> $DIR/uninhabited-static.rs:8:5
    |
-LL | static NEVER2: Void = unsafe { std::mem::transmute(()) };
-   | ^^^^^^^^^^^^^^^^^^^
+LL |     static NEVER: !;
+   |     ^^^^^^^^^^^^^^^
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #74840 <https://github.com/rust-lang/rust/issues/74840>
diff --git a/tests/ui/statics/unsized_type2.stderr b/tests/ui/statics/unsized_type2.stderr
index 3f9b0879c16..293df7554e9 100644
--- a/tests/ui/statics/unsized_type2.stderr
+++ b/tests/ui/statics/unsized_type2.stderr
@@ -1,8 +1,8 @@
 error[E0277]: the size for values of type `str` cannot be known at compilation time
-  --> $DIR/unsized_type2.rs:14:24
+  --> $DIR/unsized_type2.rs:14:1
    |
 LL | pub static WITH_ERROR: Foo = Foo { version: 0 };
-   |                        ^^^ doesn't have a size known at compile-time
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
    |
    = help: within `Foo`, the trait `Sized` is not implemented for `str`
 note: required because it appears within the type `Foo`
diff --git a/tests/ui/statics/unsizing-wfcheck-issue-127299.stderr b/tests/ui/statics/unsizing-wfcheck-issue-127299.stderr
index e401277a020..8a19207c5d7 100644
--- a/tests/ui/statics/unsizing-wfcheck-issue-127299.stderr
+++ b/tests/ui/statics/unsizing-wfcheck-issue-127299.stderr
@@ -22,10 +22,10 @@ LL |     fn bar() -> i32 where Self: Sized;
    |                     +++++++++++++++++
 
 error[E0277]: `(dyn Qux + 'static)` cannot be shared between threads safely
-  --> $DIR/unsizing-wfcheck-issue-127299.rs:12:13
+  --> $DIR/unsizing-wfcheck-issue-127299.rs:12:1
    |
 LL | static FOO: &Lint = &Lint { desc: "desc" };
-   |             ^^^^^ `(dyn Qux + 'static)` cannot be shared between threads safely
+   | ^^^^^^^^^^^^^^^^^ `(dyn Qux + 'static)` cannot be shared between threads safely
    |
    = help: within `&'static Lint`, the trait `Sync` is not implemented for `(dyn Qux + 'static)`
    = note: required because it appears within the type `&'static (dyn Qux + 'static)`