Commit graph

160 commits

Author SHA1 Message Date
bors
b765963267 Auto merge of #150843 - fmease:dyn-ace, r=BoxyUwU
mGCA: Make trait object types with type-level associated consts dyn compatible

Under feature `min_generic_const_args` (mGCA) (rust-lang/rust#132980), render traits with non-parametrized type-level associated constants (i.e., `#[type_const]` ones) dyn compatible but force the user to specify all type-level associated consts in the trait object type via bindings (either directly, via supertrait bounds and/or behind trait aliases) just like associated types, their sibling.

Fixes rust-lang/rust#130300 (feature request).
Fixes rust-lang/rust#136063 (bug).
Fixes rust-lang/rust#137260 (bug).
Fixes rust-lang/rust#137514 (bug).

While I'm accounting for most illegal `Self` references via const projections & params, I'm intentionally ignoring RUST-123140 (and duplicates) in this PR which is to be tackled some other time.

Additional context: Crate `rustc-demangle` had to be updated to fix v0 demangling. I've patched it in PR https://github.com/rust-lang/rustc-demangle/pull/87 which was was released in version 0.1.27 via PR https://github.com/rust-lang/rustc-demangle/pull/88.
2026-01-22 01:56:41 +00:00
León Orell Valerian Liehr
558a59258e
Support debuginfo for assoc const bindings 2026-01-21 18:52:08 +01:00
Jonathan Brouwer
74ff006ce6
Rollup merge of #147426 - Enselic:better-stepping, r=saethlin
tests/debuginfo/basic-stepping.rs: Add revisions `default-mir-passes`, `no-SingleUseConsts-mir-pass`

To prevent regressions our test must cover the code both inside and outside of the `SingleUseConsts` MIR pass. Use revisions for that.

We know this use case is sensitive to regressions because it already happened at least once. See https://github.com/rust-lang/rust/issues/33013#issuecomment-3121579216.

CC https://github.com/rust-lang/rust/issues/130896
2026-01-21 16:39:39 +01:00
dianqk
5769006794
Run dummy_span.rs test with SimplifyComparisonIntegral 2026-01-14 18:57:17 +08:00
Martin Nordholts
622572f6df tests/debuginfo/basic-stepping.rs: Add revisions default-mir-passes, no-SingleUseConsts-mir-pass
To prevent regressions our test must cover the code both inside and
outside of the `SingleUseConsts` MIR pass. Use revisions for that.
2026-01-05 08:08:52 +01:00
Martin Nordholts
de505d24db tests/debuginfo/basic-stepping.rs: Don't mix compile-flags with ignore-*
We want directives nice and tidy.
2026-01-05 08:08:03 +01:00
Martin Nordholts
423a8dc409 tests/debuginfo/macro-stepping.rs: Add revisions default-mir-passes, no-SingleUseConsts-mir-pass
To prevent the test from regressing both with and without
`SingleUseConsts` MIR pass.
2025-12-23 15:33:56 +01:00
Martin Nordholts
b7a0f84a5a tests/debuginfo/function-arg-initialization.rs: Stop disabling SingleUseConsts MIR pass 2025-12-20 20:35:30 +01:00
Ralf Jung
18af84b138 debuginfo/macro-stepping test: extend comments 2025-12-01 22:32:36 +01:00
joboet
c22b819952
update type names in debuginfo tests 2025-11-29 15:59:11 +01:00
Orson Peters
492fbc56c1 Update debuginfo test from Global to System 2025-11-28 23:35:38 +01:00
Martin Nordholts
5b57d02e9f compiletest: Use //@ prefixes also for debuginfo test directives
So that when we later add support for revisions we can use the same
syntax for revisions as elsewhere.

This also prevents people from making typos for commands since
`src/tools/compiletest/src/directives/directive_names.rs` will catch such
typos now.

Note that we one FIXME for a non-trivial change for later:
```
// FIXME(148097): Change `// cdb-checksimple_closure` to `//@ cdb-check:simple_closure`
```
2025-11-25 06:13:45 +01:00
Walnut
af1c2b277d update tests 2025-11-24 00:17:53 -06:00
David Wood
ff00110543
sess: default to v0 symbol mangling
Rust's current mangling scheme depends on compiler internals; loses
information about generic parameters (and other things) which makes for
a worse experience when using external tools that need to interact with
Rust symbol names; is inconsistent; and can contain `.` characters
which aren't universally supported. Therefore, Rust has defined its own
symbol mangling scheme which is defined in terms of the Rust language,
not the compiler implementation; encodes information about generic
parameters in a reversible way; has a consistent definition; and
generates symbols that only use the characters `A-Z`, `a-z`, `0-9`, and
`_`.

Support for the new Rust symbol mangling scheme has been added to
upstream tools that will need to interact with Rust symbols (e.g.
debuggers).

This commit changes the default symbol mangling scheme from the legacy
scheme to the new Rust mangling scheme.

Signed-off-by: David Wood <david.wood@huawei.com>
2025-11-19 11:55:09 +00:00
Martin Nordholts
5ad2f434dc rustc_codegen_llvm: Require opt-level >= 1 for index-based loop
To make debugger stepping intuitive with `-Copt-level=0`. See the
adjusted `basic-stepping.rs` test.

This is kind of a revert of bd0aae92dc, except we don't revert it,
we just make it conditional on `opt-level`. That commit regressed
`basic-stepping.rs`, but it was not noticed since that test did not
exist back then. I have retroactively bisected to find that out.

It seems messy to sprinkle if-cases inside of the
`write_operand_repeatedly()` so make the whole function conditional.

The test that bd0aae92dc added in
`tests/codegen/issues/issue-111603.rs` already use `-Copt-level=3`, so
we don't need to adjust the compiler flags for it to keep passing.
2025-11-13 06:29:55 +01:00
Tom Tromey
71e2e0cded Minor fixes to StdNonZeroNumberProvider for gdb
While looking at the pretty-printers, I found a few minor oddities in
StdNonZeroNumberProvider.

First, gdb.Type.fields() already returns a sequence, so there's no
need to call list().

Second, it's more idiomatic for the (somewhat misnamed) to_string
method to simply return the underlying gdb.Value.  This also lets gdb
apply whatever formats were passed to `print`, as the new test shows.

Third, there's no need to use the field's name when looking up a field
in a value, the gdb.Field itself can be used.
2025-11-05 11:42:54 -07:00
bors
35ebdf9ba1 Auto merge of #147728 - Enselic:gdbt-check-typo, r=Zalathar
tests: activate misspelled `gdb-check` in `function-arg-initialization.rs`

In 9253e1206e a bunch of `gdbr-check` (for `rust-gdb`) directives and `gdbg-check` (for plain `gdb`) directives were added. But in two places the author accidentally wrote `gdbt-check` instead (`t` is next to `r` on the keyboard). This commit fixes that typo.

rust-lang/rust#129218 later renamed `gdbr-check` to just `gdb-check` which is why we rename to `gdb-check` directly.

The test still passes locally for me after the change, but fails if I change the `gdb-check` checks to check for some other string, so the check seems to still perform its intended function.

Note that we need to add a `std::hint::black_box()` to avoid

    $4 = <optimized out>

prints on at least `aarch64-gnu-llvm-20-1`.

After this there are no more instances of the string `gdbt` in the code base:
```console
$ git grep gdbt
```

try-job: dist-i586-gnu-i586-i686-musl
2025-11-03 10:10:34 +00:00
Martin Nordholts
192f862c93 tests: activate misspelled gdb-check in function-arg-initialization.rs
In 9253e1206e a bunch of `gdbr-check` (for `rust-gdb`) and
`gdbg-check` (for plain `gdb`) was added. But in two places the author
accidentally wrote `gdbt-check` instead. This commit fixes this typo.
2025-10-28 06:21:17 +01:00
Jamesbarford
a918702bca Re-enable macro-stepping test for AArch64 2025-10-27 10:26:57 +00:00
bors
2f7620a5cc Auto merge of #146414 - GuillaumeGomez:run-test-with-gcc-backend, r=Kobzol
Add a CI job that runs a subset of UI tests with the GCC backend

Part of https://github.com/rust-lang/compiler-team/issues/891.

r? `@Kobzol`
2025-10-14 09:21:23 +00:00
Guillaume Gomez
2ad443c849 Ignore failing debuginfo tests with gcc backend 2025-10-13 15:20:49 +02:00
Zalathar
10393a8052 Add LLDB commands to tests/debuginfo/basic-types-globals.rs 2025-10-12 21:44:13 +11:00
dianqk
1bd89bd42e
codegen: Generate dbg_value for the ref statement 2025-10-02 14:55:51 +08:00
Caiweiran
a54567e76c tests: Ignore basic-stepping.rs on riscv64 2025-08-29 08:11:48 +00:00
Jacob Pratt
561656db67
Rollup merge of #145745 - heiher:ignore-basic-stepping, r=lqd
tests: Ignore basic-stepping.rs on LoongArch
2025-08-22 22:00:58 -04:00
Jacob Pratt
5cfdbd6c08
Rollup merge of #145218 - nilptr:nilptr/feat/lldb-enum-pretty-printer, r=Mark-Simulacrum
[Debuginfo] improve enum value formatting in LLDB for better readability

> TL;DR: When debugging with CodeLLDB, I noticed enum values were often hard to read because LLDB lists every possible variant, resulting in a verbose and cluttered view, even though only one variant is actually valid. Interestingly, raw enum types display nicely. After some investigation, I found that `&enum` values get classified as `Other`, so it falls back to `DefaultSyntheticProvider`, which causes this verbose output.

## What does this PR do?

This PR contains 2 commits:

1. change the enum value formatting from showing 2 separate fields (`value` for attached data and `$discr$` for the discriminator) to a concise `<readable variant name>: <attached data>` format
2. dereference pointer types in `classify_rust_type` so that it can return more accurate type for reference type

## Self-test proof

Before:

<img width="1706" height="799" alt="before" src="https://github.com/user-attachments/assets/b66c7e22-990a-4da5-9036-34e3f9f62367" />

After:

<img width="1541" height="678" alt="after" src="https://github.com/user-attachments/assets/36db32e2-f822-4883-8f17-cb8067e509f6" />
2025-08-22 22:00:49 -04:00
WANG Rui
d61353ff43 tests: Ignore basic-stepping.rs on LoongArch 2025-08-22 15:58:52 +08:00
Jacob Pratt
537d5f40a6
Rollup merge of #145297 - adwinwhite:recursive-debuginfo, r=wesleywiser
fix(debuginfo): handle false positives in overflow check

Fixes rust-lang/rust#144636.

Duplicate wrappers and normal recursive types can lead to false positives.
```rust
struct Recursive {
	a: Box<Box<Recursive>>,
}
```
The ADT stack can be:
- `Box<Recursive>`
- `Recursive`
- `Box<Box<Recursive>>` (`Box` now detected as expanding)

We can filter them out by tracing the generic arg back through the stack, as true expanding recursive types must have their expanding arg used as generic arg throughout.

r? ````@wesleywiser````
2025-08-21 01:12:16 -04:00
nilptr
12eb1a0bce feat(lldb debug info): improve enum value formatting in lldb 2025-08-17 21:15:18 +08:00
Adwin White
e13e1e4c0c fix(debuginfo): handle false positives in overflow check 2025-08-12 17:13:13 +08:00
bjorn3
270c1a4d24 Revert "Embed GDB pretty printers in rlibs and dylibs"
This reverts commit b4d923cea0.
2025-08-06 18:00:58 +00:00
Sebastian Poeplau
b4d923cea0 Embed GDB pretty printers in rlibs and dylibs
Instead of collecting pretty printers transitively when building
executables/staticlibs/cdylibs, let the debugger find each crate's
pretty printers via its .debug_gdb_scripts section. This covers the case
where libraries defining custom pretty printers are loaded dynamically.
2025-08-06 13:24:43 +02:00
Stuart Cook
cc7c63b907
Rollup merge of #144497 - Enselic:basic-stepping, r=Mark-Simulacrum
tests: Add test for basic line-by-line stepping in a debugger

Let's wait with lldb testing until the test works properly with gdb.

This is a regression test to prevent further regressions of https://github.com/rust-lang/rust/issues/33013 which unfortunately regressed in **nightly-2023-04-24**. See https://github.com/rust-lang/rust/issues/33013#issuecomment-3121579216.
2025-08-04 11:24:37 +10:00
bjorn3
ae2f8d9216 Remove the omit_gdb_pretty_printer_section attribute
Disabling loading of pretty printers in the debugger itself is more
reliable. Before this commit the .gdb_debug_scripts section couldn't be
included in dylibs or rlibs as otherwise there is no way to disable the
section anymore without recompiling the entire standard library.
2025-08-01 20:04:59 +00:00
Daniel Paoliello
cffde732ce Verify llvm-needs-components are not empty and match the --target value 2025-07-29 11:20:23 -07:00
Martin Nordholts
534b1355ef tests: Add test for basic line-by-line stepping in a debugger
Let's wait with lldb testing until the test works properly with gdb.
2025-07-26 13:06:21 +02:00
Jens Reidel
e1b6cfe62e
Rephrase comment to include some tracking issues
Signed-off-by: Jens Reidel <adrian@travitia.xyz>
2025-07-21 21:57:08 +02:00
Jens Reidel
1d0eddbedd tests: debuginfo: Work around or disable broken tests on powerpc
f16 support for PowerPC has issues in LLVM, therefore we need a small
workaround to prevent LLVM from emitting symbols that don't exist for
PowerPC yet.

It also appears that unused by-value non-immedate issue with gdb applies
to PowerPC targets as well, though I've only tested 64-bit Linux targets.

Signed-off-by: Jens Reidel <adrian@travitia.xyz>
2025-07-20 07:29:19 +02:00
David Wood
322cc31504
tests: {Meta,Pointee}Sized in non-minicore tests
As before, add `MetaSized` and `PointeeSized` traits to all of the
non-minicore `no_core` tests so that they don't fail for lack of
language items.
2025-06-16 23:04:33 +00:00
Jubilee Young
643a9d233b tests: Change "fastcall" to "system" in some tests
Lets the test still work on different architectures.
2025-06-09 16:10:21 -07:00
Jacob Pratt
8951c74e2a
Rollup merge of #138285 - beetrees:repr128-stable, r=traviscross,bjorn3
Stabilize `repr128`

## Stabilisation report

The `repr128` feature ([tracking issue](https://github.com/rust-lang/rust/issues/56071)) allows the use of `#[repr(u128)]` and `#[repr(i128)]` on enums in the same way that other primitive representations such as `#[repr(u64)]` can be used. For example:

```rust
#[repr(u128)]
enum Foo {
    One = 1,
    Two,
    Big = u128::MAX,
}

#[repr(i128)]
enum Bar {
    HasThing(u16) = 42,
    HasSomethingElse(i64) = u64::MAX as i128 + 1,
    HasNothing,
}
```

This is the final part of adding 128-bit integers to Rust ([RFC 1504](https://rust-lang.github.io/rfcs/1504-int128.html)); all other parts of 128-bit integer support were stabilised in #49101 back in 2018.

From a design perspective, `#[repr(u128)]`/`#[repr(i128)]` function like `#[repr(u64)]`/`#[repr(i64)]` but for 128-bit integers instead of 64-bit integers. The only differences are:

- FFI safety: as `u128`/`i128` are not currently considered FFI safe, neither are `#[repr(u128)]`/`#[repr(i128)]` enums (I discovered this wasn't the case while drafting this stabilisation report, so I have submitted #138282 to fix this).
- Debug info: while none of the major debuggers currently support 128-bit integers, as of LLVM 20 `rustc` will emit valid debuginfo for both DWARF and PDB (PDB makes use of the same natvis that is also used for all enums with fields, whereas DWARF has native support).

Tests for `#[repr(u128)]`/`#[repr(i128)]` enums include:
- [ui/enum-discriminant/repr128.rs](385970f0c1/tests/ui/enum-discriminant/repr128.rs): checks that 128-bit enum discriminants have the correct values.
- [debuginfo/msvc-pretty-enums.rs](385970f0c1/tests/debuginfo/msvc-pretty-enums.rs): checks the PDB debuginfo is correct.
- [run-make/repr128-dwarf](385970f0c1/tests/run-make/repr128-dwarf/rmake.rs): checks the DWARF debuginfo is correct.

Stabilising this feature does not require any changes to the Rust Reference as [the documentation on primitive representations](https://doc.rust-lang.org/nightly/reference/type-layout.html#r-layout.repr.primitive.intro) already includes `u128` and `i128`.

Closes #56071
Closes https://github.com/rust-lang/reference/issues/1368

r? lang

```@rustbot``` label +I-lang-nominated +T-lang
2025-05-29 04:50:46 +02:00
beetrees
467eeabbb5
Stabilise repr128 2025-05-28 15:14:34 +01:00
MarcoIeni
1b7a927d84
ci: move tests from x86_64-gnu-llvm-19 job to aarch64 2025-05-26 22:27:20 +02:00
Kyle Huey
caf665e692 Use the fn_span when emitting function calls for better debug info.
This especially improves the developer experience for long chains
of function calls that span multiple lines, which is common with
builder patterns, chains of iterator/future combinators, etc.
2025-05-22 14:06:24 -07:00
Daniel Paoliello
3286d4aad7 [win][arm64] Disable various DebugInfo tests that don't work on Arm64 Windows 2025-05-07 10:49:54 -07:00
Matthias Krüger
68b439c63b
Rollup merge of #138599 - adwinwhite:recursive-overflow, r=wesleywiser
avoid overflow when generating debuginfo for expanding recursive types

Fixes #135093
Fixes #121538
Fixes #107362
Fixes #100618
Fixes #115994

The overflow happens because expanding recursive types keep creating new nested types when recurring into sub fields.
I fixed that by returning an empty stub node when expanding recursion is detected.
2025-04-18 05:17:53 +02:00
Jieyou Xu
d1178faa93
tests: refine disable reason for tests/debuginfo/drop-locations.rs 2025-04-17 18:52:57 +08:00
Pietro Albini
cd371b90e2
replace //@ compile-flags: --edition with //@ edition 2025-04-10 09:56:37 +02:00
Adwin White
d5c4ed0484 (re)move fixed crash tests 2025-03-17 19:43:31 +08:00
Adwin White
8e235258f3 fix(debuginfo): avoid overflow when handling expanding recursive type 2025-03-17 18:33:40 +08:00