close
Skip to content

Add better default spans for the Ty impl of QueryKey#154846

Open
Zoxc wants to merge 1 commit intorust-lang:mainfrom
Zoxc:ty-def-span
Open

Add better default spans for the Ty impl of QueryKey#154846
Zoxc wants to merge 1 commit intorust-lang:mainfrom
Zoxc:ty-def-span

Conversation

@Zoxc
Copy link
Copy Markdown
Contributor

@Zoxc Zoxc commented Apr 5, 2026

This add default spans for Ty in its implementation of QueryKey. This is useful so we can get spans for the layout_of query which shows up in cycle errors.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 5, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 5, 2026

r? @JohnTitor

rustbot has assigned @JohnTitor.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 69 candidates
  • Random selection from 11 candidates

@rust-log-analyzer
Copy link
Copy Markdown
Collaborator

The job x86_64-gnu-miri failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
tests/fail/tree_borrows/wildcard/subtree_internal_relatedness.rs ... ok
tests/fail/tree_borrows/wildcard/subtree_internal_relatedness_wildcard.rs ... ok

FAILED TEST: tests/fail/layout_cycle.rs
command: MIRI_ENV_VAR_TEST="0" MIRI_TEMP="/tmp/miri-uitest-D8FLQD" RUST_BACKTRACE="1" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/miri" "--error-format=json" "--sysroot=/checkout/obj/build/x86_64-unknown-linux-gnu/miri-sysroot" "-Dwarnings" "-Dunused" "-Ainternal_features" "-Zui-testing" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/tmp/miri_ui/0/tests/fail" "tests/fail/layout_cycle.rs" "--edition" "2021"

error: actual output differed from expected
Execute `./miri test --bless` to update `tests/fail/layout_cycle.stderr` to the actual output
--- tests/fail/layout_cycle.stderr
+++ <stderr output>
 error[E0391]: cycle detected when computing layout of `S<S<()>>`
+  --> tests/fail/layout_cycle.rs:LL:CC
    |
-   = note: ...which requires computing layout of `<S<()> as Tr>::I`...
+LL | pub struct S<T: Tr> {
+   | ^^^^^^^^^^^^^^^^^^^
+   |
+note: ...which requires computing layout of `<S<()> as Tr>::I`...
+  --> tests/fail/layout_cycle.rs:LL:CC
+   |
+LL |     type I: Tr;
+   |     ^^^^^^^^^^
    = note: ...which again requires computing layout of `S<S<()>>`, completing the cycle
 note: cycle used when const-evaluating + checking `core::mem::SizedTypeProperties::SIZE`
... 7 lines skipped ...
 
 For more information about this error, try `rustc --explain E0391`.

Full unnormalized output:
error[E0391]: cycle detected when computing layout of `S<S<()>>`
##[error]  --> tests/fail/layout_cycle.rs:5:1
   |
LL | pub struct S<T: Tr> {
   | ^^^^^^^^^^^^^^^^^^^
   |
note: ...which requires computing layout of `<S<()> as Tr>::I`...
  --> tests/fail/layout_cycle.rs:10:5
   |
LL |     type I: Tr;
   |     ^^^^^^^^^^
   = note: ...which again requires computing layout of `S<S<()>>`, completing the cycle
note: cycle used when const-evaluating + checking `core::mem::SizedTypeProperties::SIZE`
  --> /checkout/library/core/src/mem/mod.rs:1282:5
   |
LL |     const SIZE: usize = intrinsics::size_of::<Self>();
   |     ^^^^^^^^^^^^^^^^^
   = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0391`.


error: `cycle detected when computing layout of` not found in diagnostics on line 1
##[error] --> tests/fail/layout_cycle.rs:1:12
  |
1 | //~ ERROR: cycle detected when computing layout of
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected because of this pattern
  |

error: there was 1 unmatched diagnostic
##[error] --> tests/fail/layout_cycle.rs:5:1
  |
5 | pub struct S<T: Tr> {
  | ^^^^^^^^^^^^^^^^^^^ Error[E0391]: cycle detected when computing layout of `S<S<()>>`
  |

full stderr:
error[E0391]: cycle detected when computing layout of `S<S<()>>`
##[error]  --> tests/fail/layout_cycle.rs:5:1
   |
LL | pub struct S<T: Tr> {
   | ^^^^^^^^^^^^^^^^^^^
   |
note: ...which requires computing layout of `<S<()> as Tr>::I`...
  --> tests/fail/layout_cycle.rs:10:5
   |
LL |     type I: Tr;
   |     ^^^^^^^^^^
   = note: ...which again requires computing layout of `S<S<()>>`, completing the cycle
note: cycle used when const-evaluating + checking `core::mem::SizedTypeProperties::SIZE`
  --> /checkout/library/core/src/mem/mod.rs:1282:5
   |
LL |     const SIZE: usize = intrinsics::size_of::<Self>();
   |     ^^^^^^^^^^^^^^^^^
   = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
---
Location:
   /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/ui_test-0.30.3/src/lib.rs:365

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   1: <color_eyre[63e67a754d3ed51f]::config::EyreHook>::into_eyre_hook::{closure#0}<unknown>
      at <unknown source file>:<unknown line>
   2: <eyre[c66936404cc262e8]::Report>::from_adhoc::<&str><unknown>
      at <unknown source file>:<unknown line>
   3: ui_test[a2d3f401acee3735]::run_tests_generic::<ui_test[a2d3f401acee3735]::default_file_filter, ui[7ae90bc2a8f55a33]::run_tests::{closure#1}, alloc[cad1373545e94290]::boxed::Box<dyn ui_test[a2d3f401acee3735]::status_emitter::StatusEmitter>><unknown>
      at <unknown source file>:<unknown line>
   4: ui[7ae90bc2a8f55a33]::ui<unknown>
      at <unknown source file>:<unknown line>
   5: ui[7ae90bc2a8f55a33]::main<unknown>
      at <unknown source file>:<unknown line>
   6: std[45aebd5218e977bd]::sys::backtrace::__rust_begin_short_backtrace::<fn() -> core[ec46d7d36b58147b]::result::Result<(), eyre[c66936404cc262e8]::Report>, core[ec46d7d36b58147b]::result::Result<(), eyre[c66936404cc262e8]::Report>><unknown>
      at <unknown source file>:<unknown line>
   7: std[45aebd5218e977bd]::rt::lang_start::<core[ec46d7d36b58147b]::result::Result<(), eyre[c66936404cc262e8]::Report>>::{closure#0}<unknown>
      at <unknown source file>:<unknown line>
   8: std[45aebd5218e977bd]::rt::lang_start_internal<unknown>
      at <unknown source file>:<unknown line>
   9: main<unknown>
      at <unknown source file>:<unknown line>
  10: __libc_start_main<unknown>
      at <unknown source file>:<unknown line>
  11: _start<unknown>
      at <unknown source file>:<unknown line>

Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering.
Run with RUST_BACKTRACE=full to include source snippets.
error: test failed, to rerun pass `--test ui`

Caused by:
  process didn't exit successfully: `/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/ui-626f07652299b838` (exit status: 1)
Bootstrap failed while executing `test --stage 2 src/tools/miri src/tools/miri/cargo-miri`
Command `/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo test -Zwarnings --target x86_64-unknown-linux-gnu -Zbinary-dep-depinfo -j 4 -Zroot-dir=/checkout --locked --color=always --profile=release --manifest-path /checkout/src/tools/miri/Cargo.toml -- [workdir=/checkout]` failed with exit code 1
Created at: src/bootstrap/src/core/build_steps/tool.rs:191:21
Executed at: src/bootstrap/src/core/build_steps/test.rs:739:19

--- BACKTRACE vvv
   0: <bootstrap::utils::exec::DeferredCommand>::finish_process
             at /checkout/src/bootstrap/src/utils/exec.rs:939:17
   1: <bootstrap::utils::exec::DeferredCommand>::wait_for_output::<&bootstrap::utils::exec::ExecutionContext>
             at /checkout/src/bootstrap/src/utils/exec.rs:831:21
   2: <bootstrap::utils::exec::ExecutionContext>::run
             at /checkout/src/bootstrap/src/utils/exec.rs:741:45
   3: <bootstrap::utils::exec::BootstrapCommand>::run::<&bootstrap::core::builder::Builder>
             at /checkout/src/bootstrap/src/utils/exec.rs:339:27
   4: <bootstrap::core::build_steps::test::Miri as bootstrap::core::builder::Step>::run
             at /checkout/src/bootstrap/src/core/build_steps/test.rs:739:19
   5: <bootstrap::core::builder::Builder>::ensure::<bootstrap::core::build_steps::test::Miri>
             at /checkout/src/bootstrap/src/core/builder/mod.rs:1579:36
   6: <bootstrap::core::build_steps::test::Miri as bootstrap::core::builder::Step>::make_run
             at /checkout/src/bootstrap/src/core/build_steps/test.rs:665:21
   7: <bootstrap::core::builder::StepDescription>::maybe_run
             at /checkout/src/bootstrap/src/core/builder/mod.rs:476:13
   8: bootstrap::core::builder::cli_paths::match_paths_to_steps_and_run
             at /checkout/src/bootstrap/src/core/builder/cli_paths.rs:232:18
   9: <bootstrap::core::builder::Builder>::run_step_descriptions
             at /checkout/src/bootstrap/src/core/builder/mod.rs:1122:9
  10: <bootstrap::core::builder::Builder>::execute_cli
             at /checkout/src/bootstrap/src/core/builder/mod.rs:1101:14
  11: <bootstrap::Build>::build
             at /checkout/src/bootstrap/src/lib.rs:799:25
  12: bootstrap::main
             at /checkout/src/bootstrap/src/bin/main.rs:130:11
  13: <fn() as core::ops::function::FnOnce<()>>::call_once
             at /rustc/ad726b5063362ec9897ef3d67452fc5606ee70fa/library/core/src/ops/function.rs:250:5
  14: std::sys::backtrace::__rust_begin_short_backtrace::<fn(), ()>
             at /rustc/ad726b5063362ec9897ef3d67452fc5606ee70fa/library/std/src/sys/backtrace.rs:166:18
  15: std::rt::lang_start::<()>::{closure#0}
             at /rustc/ad726b5063362ec9897ef3d67452fc5606ee70fa/library/std/src/rt.rs:206:18
  16: <&dyn core::ops::function::Fn<(), Output = i32> + core::panic::unwind_safe::RefUnwindSafe + core::marker::Sync as core::ops::function::FnOnce<()>>::call_once
             at /rustc/ad726b5063362ec9897ef3d67452fc5606ee70fa/library/core/src/ops/function.rs:287:21
  17: std::panicking::catch_unwind::do_call::<&dyn core::ops::function::Fn<(), Output = i32> + core::panic::unwind_safe::RefUnwindSafe + core::marker::Sync, i32>
             at /rustc/ad726b5063362ec9897ef3d67452fc5606ee70fa/library/std/src/panicking.rs:581:40
  18: std::panicking::catch_unwind::<i32, &dyn core::ops::function::Fn<(), Output = i32> + core::panic::unwind_safe::RefUnwindSafe + core::marker::Sync>
             at /rustc/ad726b5063362ec9897ef3d67452fc5606ee70fa/library/std/src/panicking.rs:544:19
  19: std::panic::catch_unwind::<&dyn core::ops::function::Fn<(), Output = i32> + core::panic::unwind_safe::RefUnwindSafe + core::marker::Sync, i32>
             at /rustc/ad726b5063362ec9897ef3d67452fc5606ee70fa/library/std/src/panic.rs:359:14
  20: std::rt::lang_start_internal::{closure#0}
             at /rustc/ad726b5063362ec9897ef3d67452fc5606ee70fa/library/std/src/rt.rs:175:24
  21: std::panicking::catch_unwind::do_call::<std::rt::lang_start_internal::{closure#0}, isize>
             at /rustc/ad726b5063362ec9897ef3d67452fc5606ee70fa/library/std/src/panicking.rs:581:40
---
  28: __libc_start_main
  29: _start


Command has failed. Rerun with -v to see more details.
Build completed unsuccessfully in 0:47:49
  local time: Sun Apr  5 12:01:42 UTC 2026
  network time: Sun, 05 Apr 2026 12:01:42 GMT
##[error]Process completed with exit code 1.
##[group]Run echo "disk usage:"

Copy link
Copy Markdown
Member

@JohnTitor JohnTitor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me once you fix the failure above

View changes since this review

@JohnTitor JohnTitor added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 10, 2026
@Zoxc
Copy link
Copy Markdown
Contributor Author

Zoxc commented Apr 10, 2026

Maybe this could just use characteristic_def_id_of_type if we're aiming to remove DefId from ty::Alias. @WaffleLapkin @lcnr Would there be a way to find the DefId / Span associated with the alias if that happens?

@lcnr
Copy link
Copy Markdown
Contributor

lcnr commented Apr 13, 2026

most aliases will still have an associated DefId, we just want to be able to add ones which don't in the future

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants