Commit graph

344 commits

Author SHA1 Message Date
Jake Goulding
0117884917 Move eager translation to a method on Diag
This will allow us to eagerly translate messages on a top-level
diagnostic, such as a `LintDiagnostic`. As a bonus, we can remove the
awkward closure passed into Subdiagnostic and make better use of
`Into`.
2025-04-16 21:38:59 -04:00
Jacob Pratt
883c8dd52e
Rollup merge of #139760 - petrochenkov:noerrpat2, r=jieyouxu
UI tests: migrate remaining compile time `error-pattern`s to line annotations when possible

There's a number of cases in which `error-pattern` is still necessary even for compile time checking.
- It checks something that compiler writes directly into stderr as text, and not to the structured json output. This includes some stuff reported during compiler panics, and also diagnostics that happen very early, for example when parsing the command line.
- It checks something that exists only in the full rendered diagnostic test, but not in its structured components, for example code fragments or output of `-Ztrack-diagnostics`. (The latter can probably be converted to structured form though.)

This is continuation of https://github.com/rust-lang/rust/pull/139137.
r? `@jieyouxu`
2025-04-13 23:57:41 -04:00
Vadim Petrochenkov
93bee0789a UI tests: migrate remaining compile time error-patterns to line annotations
when possible.
2025-04-13 21:48:53 +03:00
zjp
6d5f6fd293 import rustc_smir::rustc_internal in run_driver! 2025-04-13 18:09:10 +08:00
Jacob Pratt
2b54f9bfb1
Rollup merge of #139662 - nnethercote:tweak-DefPathData, r=compiler-errors
Tweak `DefPathData`

Some improvements in and around `DefPathData`, following on from #137977.

r? `@spastorino`
2025-04-11 21:21:01 +02:00
Nicholas Nethercote
cdf5b8d4e7 Change how anonymous associated types are printed.
Give them their own symbol `anon_assoc`, as is done for all the other
anonymous `DefPathData` variants.
2025-04-11 20:13:16 +10:00
Stuart Cook
0abc6c6e98
Rollup merge of #138682 - Alexendoo:extra-symbols, r=fee1-dead
Allow drivers to supply a list of extra symbols to intern

Allows adding new symbols as `const`s in external drivers, desirable in Clippy so we can use them in patterns to replace code like 75530e9f72/src/tools/clippy/clippy_lints/src/casts/cast_ptr_alignment.rs (L66)

The Clippy change adds a couple symbols as a demo, the exact `clippy_utils` API and replacing other usages can be done on the Clippy side to minimise sync conflicts

---

try-job: aarch64-gnu
2025-04-11 13:31:44 +10:00
Alex Macleod
f740326216 Allow drivers to supply a list of extra symbols to intern 2025-04-10 13:39:23 +00:00
Vadim Petrochenkov
b3f75353a2 UI tests: add missing diagnostic kinds where possible 2025-04-08 23:06:31 +03:00
Stuart Cook
93f7583491
Rollup merge of #138826 - makai410:assoc-items, r=celinval
StableMIR: Add `associated_items`.

Resolves: https://github.com/rust-lang/project-stable-mir/issues/87
2025-04-05 13:18:15 +11:00
Vadim Petrochenkov
4d64990690 compiletest: Require //~ annotations even if error-pattern is specified 2025-04-03 11:08:55 +03:00
makai410
f9ef4563c2 Implement associated_items api. 2025-04-01 17:11:53 +08:00
Stuart Cook
cb39217d44
Rollup merge of #138964 - compiler-errors:usage-of-interner, r=lcnr
Implement lint against using Interner and InferCtxtLike in random compiler crates

Often `Interner` defines similar methods to `TyCtxt` (but often simplified due to the simpler API surface of the type system layer for the new solver), which people will either unintentionally or intentionally import and use. Let's discourage that.

r? lcnr
2025-03-27 15:57:24 +11:00
Michael Goulet
14804d1ed1 Implement lint against using Interner and InferCtxtLike in random compiler crates 2025-03-26 04:39:38 +00:00
León Orell Valerian Liehr
848b0da34f
Remove fields that are dead since the removal of type ascription syntax
Since `{ ident: ident }` is a parse error, these fields are dead.
2025-03-24 20:04:23 +01:00
Matthias Krüger
1cb17dd6f2
Rollup merge of #138536 - makai410:mut-mir-visitor, r=celinval
stable_mir: Add `MutMirVisitor`

Resolves: [rust-lang/project-stable-mir#81](https://github.com/rust-lang/project-stable-mir/issues/81).

I am unsure if we should add a `MutableBody` like Kani did.
Currently, I use `&mut Body` in `MutMirVisitor::visit_body()`.

r? ``````@celinval``````
2025-03-22 11:59:17 +01:00
makai410
ad315f6074 Add test for MutMirVisitor 2025-03-18 09:49:06 +08:00
bjorn3
b54398e4ea Make opts.maybe_sysroot non-optional
build_session_options always uses materialize_sysroot anyway.
2025-03-12 15:05:24 +00:00
Tshepang Mbambo
20ed8fb0db Revert "Don't test new error messages with the stage 0 compiler"
This reverts commit ae428141f7.
2025-03-08 22:45:16 +02:00
许杰友 Jieyou Xu (Joe)
9aaf46ea23
Rollup merge of #136865 - jieyouxu:long-type-path-compare-mode, r=lqd
Perform deeper compiletest path normalization for `$TEST_BUILD_DIR` to account for compare-mode/debugger cases, and normalize long type file filename hashes

Fixes #136510.

### Summary

- Whereas previously `$TEST_BUILD_DIR` is a normalization of `/path/to/build/test/<test_suite_name>/`, we now more deeply normalize. `$TEST_BUILD_DIR` now becomes a normalization of `/path/to/build/test/<test_suite_name>/<subdirs>/$name.$revision.$compare_mode.$debugger/` to normalize away path name differences when `--compare-mode` and/or `--debugger` are specified.
- We also centralize the normalization of long type name hashes

cf. https://github.com/rust-lang/rust/pull/136328#discussion_r1936760908.

### Review advice

- Best reviewed commit-by-commit.
- Split into 3 commits:
    - **Commit 1**: compiletest changes to have `$TEST_BUILD_DIR` more deeply normalize.
    - **Commit 2**: remove per-test hacks for long type path hash normalizations, and rebless tests *specifically* affected by that.
    - **Commit 3**: rebless other tests that were changed as a side-effect of deeper `$TEST_BUILD_DIR` normalizations.

**Commit 2** is created via first finding tests that try to perform long type file hash normalizations on an ad hoc, per-test basis:

```
rg --no-ignore -l --no-ignore -F -e "long-type" tests/ui/**/*.rs
```

<details>
<summary>Tests with ad hoc long-type hash normalizations</summary>

```
tests/ui/type_length_limit.rs
tests/ui/traits/on_unimplemented_long_types.rs
tests/ui/regions/issue-102374.rs
tests/ui/recursion/recursion.rs
tests/ui/recursion/issue-83150.rs
tests/ui/recursion/issue-23122-2.rs
tests/ui/methods/inherent-bound-in-probe.rs
tests/ui/issues/issue-67552.rs
tests/ui/issues/issue-37311-type-length-limit/issue-37311.rs
tests/ui/issues/issue-20413.rs
tests/ui/issues/issue-8727.rs
tests/ui/infinite/infinite-instantiation.rs
tests/ui/infinite/infinite-instantiation-struct-tail-ice-114484.rs
tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-1.rs
tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-2.rs
tests/ui/higher-ranked/trait-bounds/hang-on-deeply-nested-dyn.rs
tests/ui/error-codes/E0275.rs
tests/ui/diagnostic-width/secondary-label-with-long-type.rs
tests/ui/diagnostic-width/long-e0277.rs
tests/ui/diagnostic-width/non-copy-type-moved.rs
tests/ui/diagnostic-width/long-E0308.rs
tests/ui/diagnostic-width/E0271.rs
tests/ui/diagnostic-width/binop.rs
```
</details>

These ad hoc normalizations were removed, and they are reblessed.

r? `````@lqd`````
2025-03-05 21:46:35 +08:00
Celina G. Val
4d75c4f8f3 Make CrateItem::body() function return an option
When we initially created `CrateItem`, it would only represent items
that contain a body.

That is no longer the case, for now, make this explicit by expanding
the APIs to retrieve the item body.

This is related to https://github.com/rust-lang/project-stable-mir/issues/34
2025-03-04 17:46:40 -08:00
许杰友 Jieyou Xu (Joe)
4f2a3dc196 tests: manually rebless tests/ui-fulldeps/codegen-backend/hotplug.rs 2025-03-04 00:21:02 +08:00
bors
f5729cfed3 Auto merge of #137573 - compiler-errors:rollup-noq9yhp, r=compiler-errors
Rollup of 11 pull requests

Successful merges:

 - #136522 (Remove `feature(dyn_compatible_for_dispatch)` from the compiler)
 - #137289 (Consolidate and improve error messaging for `CoerceUnsized` and `DispatchFromDyn`)
 - #137321 (Correct doc about `temp_dir()` behavior on Android)
 - #137417 (rustc_target: Add more RISC-V atomic-related features)
 - #137489 (remove `#[rustc_intrinsic_must_be_overridde]`)
 - #137530 (DWARF mixed versions with LTO on MIPS)
 - #137543 (std: Fix another new symlink test on Windows)
 - #137548 (Pass correct `TypingEnv` to `InlineAsmCtxt`)
 - #137550 (Don't immediately panic if dropck fails without returning errors)
 - #137552 (Update books)
 - #137556 (rename simd_shuffle_generic → simd_shuffle_const_generic)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-25 02:24:40 +00:00
Jana Dönszelmann
d8ea2a230f
change smir attributes getters to only support tool attributes 2025-02-24 14:31:19 +01:00
Jana Dönszelmann
309b46ad68
Fix test output expectations 2025-02-24 14:31:19 +01:00
Ralf Jung
6eea027aa9 remove support for rustc_intrinsic_must_be_overridden from the compiler 2025-02-24 07:53:59 +01:00
bors
2162e9d4b1 Auto merge of #137164 - matthiaskrgr:rollup-dj5826k, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #137095 (Replace some u64 hashes with Hash64)
 - #137100 (HIR analysis: Remove unnecessary abstraction over list of clauses)
 - #137105 (Restrict DerefPure for Cow<T> impl to T = impl Clone, [impl Clone], str.)
 - #137120 (Enable `relative-path-include-bytes-132203` rustdoc-ui test on Windows)
 - #137125 (Re-add missing empty lines in the releases notes)
 - #137145 (use add-core-stubs / minicore for a few more tests)
 - #137149 (Remove SSE ABI from i586-pc-windows-msvc)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-17 11:18:33 +00:00
Nicholas Nethercote
f86f7ad5f2 Move some Map methods onto TyCtxt.
The end goal is to eliminate `Map` altogether.

I added a `hir_` prefix to all of them, that seemed simplest. The
exceptions are `module_items` which became `hir_module_free_items` because
there was already a `hir_module_items`, and `items` which became
`hir_free_items` for consistency with `hir_module_free_items`.
2025-02-17 13:21:02 +11:00
Ben Kimock
4cf21866e8 Move hashes from rustc_data_structure to rustc_hashes so they can be shared with rust-analyzer 2025-02-16 16:18:30 -05:00
Jacob Pratt
2a8a1911da
Rollup merge of #134777 - saethlin:enable-more-tests-on-windows, r=Noratrieb
Enable more tests on Windows

As part of the discussion of https://github.com/rust-lang/compiler-team/issues/822 on Zulip, it was mentioned that problems with the i686-pc-windows-gnu target may have resulted in tests being disabled on Windows.

So in this PR, I've ripped out all our `//@ ignore-windows` directives, then re-added all the ones that are definitely required based on the outcome of try-builds, and in some cases I've improved the justification or tightened the directives to `//@ ignore-msvc` or ignoring specific targets.
2025-02-04 05:36:50 -05:00
Ben Kimock
7dfc786df1 Enable more tests on Windows 2025-02-03 10:39:32 -05:00
bjorn3
d237378cd1 Some cleanups around EarlyDiagCtxt
All callers of EarlyDiagCtxt::early_error now emit a fatal error.
2025-02-02 16:06:43 +00:00
Ralf Jung
93ee180cfa ABI-required target features: warn when they are missing in base CPU (rather than silently enabling them) 2025-01-28 04:40:42 +01:00
bjorn3
a77776cc1d Remove RunCompiler
It has become nothing other than a wrapper around run_compiler.
2025-01-23 09:38:58 +00:00
bjorn3
4f9b9a43c1 Remove the need to manually call set_using_internal_features 2025-01-23 09:38:58 +00:00
David Tolnay
0a09252866
Rollup merge of #134834 - dtolnay:unnamedcall, r=compiler-errors
Skip parenthesis around tuple struct field calls

The pretty-printer previously did not distinguish between named vs unnamed fields when printing a function call containing a struct field. It would print the call as `(self.fun)()` for a named field which is correct, and `(self.0)()` for an unnamed field which is redundant.

This PR changes function calls of tuple struct fields to print without parens.

**Before:**

```rust
struct Tuple(fn());

fn main() {
    let tuple = Tuple(|| {});
    (tuple.0)();
}
```

**After:**

```rust
struct Tuple(fn());

fn main() {
    let tuple = Tuple(|| {});
    tuple.0();
}
```
2024-12-27 18:43:05 -08:00
David Tolnay
26bb4e6464
Skip parenthesis around tuple struct field calls 2024-12-27 14:33:56 -08:00
David Tolnay
c95f9f50de
Add pretty-printer test of tuple field function call 2024-12-27 14:18:39 -08:00
David Tolnay
e67fe3698b
Skip parenthesis if . makes statement boundary unambiguous 2024-12-27 13:53:02 -08:00
David Tolnay
fef8ec5ad9
Add test of dot after eager statement boundary expr 2024-12-27 13:41:46 -08:00
Zalathar
835fbcbcab Remove the -test suffix from normalize directives 2024-12-27 19:58:16 +11:00
Michael Goulet
9a1c5eb5b3 Begin to implement type system layer of unsafe binders 2024-12-22 21:57:57 +00:00
Matthias Krüger
87be70e2b4
Rollup merge of #134599 - dtolnay:fulldepsparser, r=fmease
Detect invalid exprs in parser used by pretty-printer tests

This PR fixes a bug in https://github.com/rust-lang/rust/pull/133730 inherited from https://github.com/rust-lang/rust/pull/43742. Before this fix, the test might silently only operate on a prefix of some of the test cases in this table:

13170cd787/tests/ui-fulldeps/pprust-parenthesis-insertion.rs (L57)

For example, adding the test case `1 .. 2 .. 3` (a syntactically invalid expression) into the table would unexpectedly succeed the test instead of crashing at this unwrap:

13170cd787/tests/ui-fulldeps/pprust-parenthesis-insertion.rs (L199-L200)

because `parse_expr` would successfully parse just `1 .. 2` and disregard the last `.. 3`.

This PR adds a check that `parse_expr` reaches `Eof`, ensuring all the test cases actually test the whole expression they look like they are supposed to.
2024-12-22 09:12:11 +01:00
David Tolnay
1f2028f930
Show which test case was found to be meaningless 2024-12-21 18:50:11 -08:00
David Tolnay
822e8063fd
Switch pretty-printer roundtrip test to better parser 2024-12-21 18:49:51 -08:00
Matthias Krüger
bcdde4ea5b
Rollup merge of #134601 - dtolnay:dynstar, r=compiler-errors
Support pretty-printing `dyn*` trait objects

- Tracking issue: https://github.com/rust-lang/rust/issues/102425
2024-12-22 03:49:43 +01:00
David Tolnay
65ba6ac9a3
Extract ui-fulldeps expression parser into module 2024-12-21 18:48:13 -08:00
David Tolnay
23a250738b
Relocate dyn* test out of parenthesis insertion test 2024-12-20 21:31:21 -08:00
David Tolnay
1cc8289791
Support pretty-printing dyn* trait objects 2024-12-20 21:31:21 -08:00
David Tolnay
fe65e886f3
Change comparison operators to have Fixity::None 2024-12-20 20:12:22 -08:00