Commit Graph

48904 Commits

Author SHA1 Message Date
dianqk
d55cc9a9bd mir: Do not modify NonUse in super_projection_elem 2025-08-06 20:41:39 +08:00
bors
7cd950546b Auto merge of #144704 - compiler-errors:explode-wf, r=lcnr
expand WF obligations when checking method calls

Don't wrap a bunch of signatures in `FnPtr` then check their WF; instead, check the WFness of each input/output separately.

This is useful for the new trait solver, since because we stall on root obligations we end up needing to repeatedly recompute the WFness of possibly very large function signature types if it ends up bottoming out in ambiguity.

This may also give us more chances to hit the WF fast path for certain types like built-ins.

Finally, this just seems conceptually correct to do. There's nothing conceptually that suggests that wrapping the function signature in an fn pointer makes sense at all to do; I'm guessing that it was just convenient so that we didn't have to register WF obligations in a loop, but it doesn't affect the readability of this code at all.
2025-08-03 09:29:54 +00:00
bors
da19b9d24c Auto merge of #144677 - nnethercote:bound-const-handling, r=lcnr
Improve bound const handling

A few changes to make const handling more similar to type handling.

r? `@compiler-errors` -errors
2025-08-03 05:26:43 +00:00
bors
5b9564a189 Auto merge of #144814 - samueltardieu:rollup-qyum1hj, r=samueltardieu
Rollup of 17 pull requests

Successful merges:

 - rust-lang/rust#132748 (get rid of some false negatives in rustdoc::broken_intra_doc_links)
 - rust-lang/rust#143360 (loop match: error on `#[const_continue]` outside `#[loop_match]`)
 - rust-lang/rust#143662 ([rustdoc] Display unsafe attrs with edition 2024 `unsafe()` wrappers.)
 - rust-lang/rust#143771 (Constify some more `Result` functions)
 - rust-lang/rust#144185 (Document guarantees of poisoning)
 - rust-lang/rust#144395 (update fortanix tests)
 - rust-lang/rust#144478 (Improve formatting of doc code blocks)
 - rust-lang/rust#144614 (Fortify RemoveUnneededDrops test.)
 - rust-lang/rust#144703 ([test][AIX] ignore extern_weak linkage test)
 - rust-lang/rust#144747 (compiletest: Improve diagnostics for line annotation mismatches 2)
 - rust-lang/rust#144756 (detect infinite recursion with tail calls in ctfe)
 - rust-lang/rust#144766 (Add human readable name "Cygwin")
 - rust-lang/rust#144782 (Properly pass path to staged `rustc` to `compiletest` self-tests)
 - rust-lang/rust#144786 (Cleanup the definition of `group_type`)
 - rust-lang/rust#144796 (Add my previous commit name to .mailmap)
 - rust-lang/rust#144797 (Update safety comment for new_unchecked in niche_types)
 - rust-lang/rust#144803 (rustc-dev-guide subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-08-02 23:49:08 +00:00
Samuel Tardieu
c4b0fb79f0 Rollup merge of #144786 - JonathanBrouwer:cleanup-group-type, r=jdonszelmann
Cleanup the definition of `group_type`

r? ```@jdonszelmann```
2025-08-02 11:24:27 +02:00
Samuel Tardieu
179b4b6691 Rollup merge of #144756 - WaffleLapkin:inf-rec-etc-ctfe, r=lqd
detect infinite recursion with tail calls in ctfe

fixes rust-lang/rust#144753
2025-08-02 11:24:26 +02:00
Samuel Tardieu
d082ff4c04 Rollup merge of #144478 - joshtriplett:doc-code-formatting-prep, r=Amanieu
Improve formatting of doc code blocks

We don't currently apply automatic formatting to doc comment code blocks. As a
result, it has built up various idiosyncracies, which make such automatic
formatting difficult. Some of those idiosyncracies also make things harder for
human readers or other tools.

This PR makes a few improvements to doc code formatting, in the hopes of making
future automatic formatting easier, as well as in many cases providing net
readability improvements.

I would suggest reading each commit separately, as each commit contains one
class of changes.
2025-08-02 11:24:24 +02:00
Samuel Tardieu
93917ea97c Rollup merge of #143360 - folkertdev:const-continue-outside-loop-match, r=WaffleLapkin
loop match: error on `#[const_continue]` outside `#[loop_match]`

tracking issue https://github.com/rust-lang/rust/issues/132306
fixes https://github.com/rust-lang/rust/issues/143119
fixes https://github.com/rust-lang/rust/issues/143165

Fixes several ICEs because a panic was reachable.

``````@rustbot`````` label +F-loop_match
2025-08-02 11:24:20 +02:00
Samuel Tardieu
fc4b3fa3f9 Rollup merge of #132748 - lolbinarycat:rustdoc-intra-doc-link-warn-more-54191, r=GuillaumeGomez
get rid of some false negatives in rustdoc::broken_intra_doc_links

rustdoc will not try to do intra-doc linking if the "path" of a link looks too much like a "real url".

however, only inline links (`[text](url)`) can actually contain a url, other types of links (reference links, shortcut links) contain a *reference* which is later resolved to an actual url.

the "path" in this case cannot be a url, and therefore it should not be skipped due to looking like a url.

fixes https://github.com/rust-lang/rust/issues/54191

to minimize the number of false positives that will be introduced, the following heuristic is used:

If there's no backticks, be lenient revert to old behavior.
This is to prevent churn by linting on stuff that isn't meant to be a link.
only shortcut links have simple enough syntax that they
are likely to be written accidentlly, collapsed and reference links
need 4 metachars, and reference links will not usually use
backticks in the reference name.
therefore, only shortcut syntax gets the lenient behavior.
here's a truth table for how link kinds that cannot be urls are handled:

|              |  is shortcut link  | not shortcut link |
|--------------|--------------------|-------------------|
| has backtick |    never ignore    |    never ignore   |
| no backtick  | ignore if url-like |    never ignore   |
2025-08-02 11:24:20 +02:00
bors
6d091b2baa Auto merge of #144554 - cjgillot:no-hir-eff-vis, r=petrochenkov
Use less HIR to compute effective visibility.

r? `@ghost`
2025-08-02 09:23:36 +00:00
bors
889701db1f Auto merge of #129183 - estebank:cfg-visitor, r=davidtwco
Detect more `cfg`d out items in resolution errors

Use a visitor to collect *all* items (including those nested) that were stripped behind a `cfg` condition.

```
error[E0425]: cannot find function `f` in this scope
  --> $DIR/nested-cfg-attrs.rs:4:13
   |
LL | fn main() { f() }
   |             ^ not found in this scope
   |
note: found an item that was configured out
  --> $DIR/nested-cfg-attrs.rs:2:4
   |
LL | fn f() {}
   |    ^
note: the item is gated here
  --> $DIR/nested-cfg-attrs.rs:1:35
   |
LL | #[cfg_attr(all(), cfg_attr(all(), cfg(FALSE)))]
   |                                   ^^^^^^^^^^
```
2025-08-02 05:09:31 +00:00
Camille GILLOT
63e1327ce9 Use less HIR to compute effective visibility. 2025-08-02 02:08:52 +00:00
bors
c23f07d8c5 Auto merge of #144479 - cjgillot:incr-privacy-mod, r=petrochenkov
Perform check_private_in_public by module.

Based on https://github.com/rust-lang/rust/pull/116316
2025-08-02 01:59:11 +00:00
Esteban Küber
4b24c4bf23 Tweak rendering of cfg'd out item
```
error[E0433]: failed to resolve: could not find `doesnt_exist` in `inner`
  --> $DIR/diagnostics-cross-crate.rs:18:23
   |
LL |     cfged_out::inner::doesnt_exist::hello();
   |                       ^^^^^^^^^^^^ could not find `doesnt_exist` in `inner`
   |
note: found an item that was configured out
  --> $DIR/auxiliary/cfged_out.rs:6:13
   |
LL |     #[cfg(false)]
   |           ----- the item is gated here
LL |     pub mod doesnt_exist {
   |             ^^^^^^^^^^^^
```
2025-08-01 23:58:15 +00:00
Esteban Küber
77f75f91c5 tiny cleanup 2025-08-01 22:11:45 +00:00
Esteban Küber
4ba4559a9d remove recursive search for items 2025-08-01 22:02:52 +00:00
Esteban Küber
5210c501bc Limit how deep we visit items to find cfg'd out names 2025-08-01 21:51:05 +00:00
Esteban Küber
adcda6ca9a Detect more cfgd out items in resolution errors
Use a visitor to collect *all* items (including those nested) that were stripped behind a `cfg` condition.

```
error[E0425]: cannot find function `f` in this scope
  --> $DIR/nested-cfg-attrs.rs:4:13
   |
LL | fn main() { f() }
   |             ^ not found in this scope
   |
note: found an item that was configured out
  --> $DIR/nested-cfg-attrs.rs:2:4
   |
LL | fn f() {}
   |    ^
note: the item is gated here
  --> $DIR/nested-cfg-attrs.rs:1:35
   |
LL | #[cfg_attr(all(), cfg_attr(all(), cfg(FALSE)))]
   |                                   ^^^^^^^^^^
```
2025-08-01 21:50:36 +00:00
bors
63f6845e57 Auto merge of #144458 - compiler-errors:no-witness-mini, r=lcnr
Remove the witness type from coroutine *args* (without actually removing the type)

This does as much of rust-lang/rust#144157 as we can without having to break rust-lang/rust#143545 and/or introduce some better way of handling higher ranked assumptions.

Namely, it:
* Stalls coroutines based off of the *coroutine* type rather than the witness type.
* Reworks the dtorck constraint hack to not rely on the witness type.
* Removes the witness type from the args of the coroutine, eagerly creating the type for nested obligations when needed (auto/clone impls).

I'll experiment with actually removing the witness type in a follow-up.

r? lcnr
2025-08-01 21:07:49 +00:00
Jonathan Brouwer
32cf3d48b3 Cleanup the definition of group_type
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-08-01 17:08:02 +02:00
bors
924a5a4b7f Auto merge of #144773 - RalfJung:rollup-uif2yyj, r=RalfJung
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#144397 (`tests/ui/issues/`: The Issues Strike Back [2/N])
 - rust-lang/rust#144410 (Make tier 3 musl targets link dynamically by default)
 - rust-lang/rust#144708 (Add tracing to step.rs and friends)
 - rust-lang/rust#144730 (Create a typed wrapper for codegen backends in bootstrap)
 - rust-lang/rust#144771 (Remove some noisy triagebot pings for myself)
 - rust-lang/rust#144772 (add unsupported_calling_conventions to lint list)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-08-01 10:20:07 +00:00
Ralf Jung
21140a5111 Rollup merge of #144772 - RalfJung:unsupported_calling_conventions, r=lqd
add unsupported_calling_conventions to lint list

Seems like you can emit lints without them being on the list, but users cannot control them then... *oops*.
2025-08-01 09:59:06 +02:00
Ralf Jung
d9f794a158 Rollup merge of #144708 - Stypox:add-tracing-to-step, r=RalfJung
Add tracing to step.rs and friends

Adds tracing calls to functions in `step.rs` (01717ffecfd47eb51f4877da6ad867b329a1ddd5), to friend functions related to evaluation and stepping (cbfa7c4b96b2ea26c1db185da9b59506bf8c8e55), and adds a new trait method `EnteredTraceSpan::or_if_tracing_disabled` (f0d0d1f5ecdf174696c8a74a5bc98967a2751c93).

Adding `EnteredTraceSpan::or_if_tracing_disabled` is optional and is only useful to avoid having both `tracing::info!()` calls (that existed before) and `enter_trace_span!()` calls (that this PR adds) that would be redundant and would slow down the collection of traces. I say it is optional because it adds some cognitive complexity around `EnteredTraceSpan`, which is possibly not worth the reduced redundancy. Let me know if I should revert that commit.

The tracing calls added in this PR are meant to make it easier to understand what was being executing at a particular point when looking at a trace. But they are likely not useful for the purpose of understanding which components are fast/slow, hence why I used `tracing_separate_thread` for them. After opening a trace generated using the code in this PR in https://ui.perfetto.dev, and after executing the following query and then pressing on "Show debug track", you will see something like the following image in the timeline:

```sql
select slices.id, ts, dur, track_id, category, args.string_value as name, depth, stack_id, parent_stack_id, parent_id, slices.arg_set_id, thread_ts, thread_instruction_count, thread_instruction_delta, cat, slice_id from slices inner join args USING (arg_set_id) where args.key = "args." || slices.name and name = "step"
```

<img width="739" height="87" alt="image" src="https://github.com/user-attachments/assets/74ad9619-9a1f-40e5-9ef4-3db31e33d6e1" />
2025-08-01 09:59:04 +02:00
Ralf Jung
fce6771410 Rollup merge of #144410 - Gelbpunkt:musl-tier3-dynamic, r=jieyouxu
Make tier 3 musl targets link dynamically by default

Since we don't build std for these and don't provide any support for them, these can trivially be changed to link dynamically by default.
2025-08-01 09:59:03 +02:00
Ralf Jung
0cc4be268e add unsupported_calling_conventions to lint list 2025-08-01 09:47:47 +02:00
bors
e3ee7f7aea Auto merge of #144768 - jhpratt:rollup-otf1yfj, r=jhpratt
Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#143849 (rustdoc: never link to unnamable items)
 - rust-lang/rust#144683 (Simplify library dependencies on `compiler-builtins`)
 - rust-lang/rust#144691 (Extend `is_case_difference` to handle digit-letter confusables)
 - rust-lang/rust#144700 (rustdoc-json: Move `#[macro_export]` from `Other` to it's own  variant)
 - rust-lang/rust#144751 (Add correct dynamic_lib_extension for aix)
 - rust-lang/rust#144757 (Ping Muscraft when emitter change)
 - rust-lang/rust#144759 (triagebot: Label `compiler-builtins` T-libs)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-08-01 07:09:43 +00:00
Jacob Pratt
c7ec9bcc6e Rollup merge of #144691 - xizheyin:suggest-confuse, r=estebank
Extend `is_case_difference` to handle digit-letter confusables

This PR extends `is_case_difference` to handle digit-letter confusables

Add support for detecting 0/O, 1/l, 5/S, 8/B, 9/g confusables in error suggestions.

r? `@estebank`
2025-08-01 00:38:20 -04:00
bors
6c02dd4eae Auto merge of #144446 - nnethercote:opt-region-constraints, r=lcnr
Optimize region constraints

r? `@lcnr`
2025-08-01 04:06:21 +00:00
Folkert de Vries
040f71e812 loop match: error on #[const_continue] outside #[loop_match] 2025-08-01 00:28:52 +02:00
Waffle Lapkin
5aec4379e3 detect infinite recursion with tail calls in ctfe 2025-07-31 23:59:55 +02:00
Stypox
88c9a256a9 Add EnteredTraceSpan::or_if_tracing_disabled 2025-07-31 21:51:29 +02:00
Stypox
188f7367bf Add tracing to more functions related to step.rs 2025-07-31 21:51:29 +02:00
Stypox
4e806c8a34 Add tracing calls to eval_statement/terminator 2025-07-31 21:51:29 +02:00
Michael Goulet
e9765781b2 Remove the witness type from coroutine args 2025-07-31 17:38:28 +00:00
Michael Goulet
d05bb98d6b Extract borrowck coroutine drop-liveness hack 2025-07-31 17:38:28 +00:00
Michael Goulet
d525e79157 Stall coroutines based off of ty::Coroutine, not ty::CoroutineWitness 2025-07-31 17:31:51 +00:00
Jana Dönszelmann
e2ae91b74a Rollup merge of #144733 - Muscraft:secondary-file-sigil, r=compiler-errors
fix: Match width of ascii and unicode secondary file start

The current [unicode secondary file start](64ca23b623/compiler/rustc_errors/src/emitter.rs (L2991)) is only three characters, whereas the ASCII variant and normal [file start](64ca23b623/compiler/rustc_errors/src/emitter.rs (L2983-L2984)) are four characters. This slight difference caused the paths following a Unicode secondary file start to not align with other structured elements.
2025-07-31 17:19:41 +02:00
Jana Dönszelmann
26c28ee2ef Rollup merge of #144726 - jdonszelmann:move-attr-data-structures, r=lcnr
merge rustc_attr_data_structures into rustc_hir

this move was discussed on zulip: [#t-compiler > attribute parsing rework @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/attribute.20parsing.20rework/near/528530091)

Many PRs in the attribute rework depend on this move.
2025-07-31 17:19:40 +02:00
Jana Dönszelmann
5712d50648 Rollup merge of #144712 - nnethercote:dedup-num-types, r=fmease
Deduplicate `IntTy`/`UintTy`/`FloatTy`.

There are identical definitions in `rustc_type_ir` and `rustc_ast`. This commit removes them and places a single definition in `rustc_ast_ir`. This requires adding `rust_span` as a dependency of `rustc_ast_ir`, but means a bunch of silly conversion functions can be removed.

r? `@fmease`
2025-07-31 17:19:39 +02:00
Jana Dönszelmann
edd2574848 Rollup merge of #144711 - compiler-errors:op-span, r=petrochenkov
Consider operator's span when computing binop expr span

When computing the span of a binop consisting of `lhs` and `rhs`, we previously just took the spans of `lhs.span.to(rhs.span)`. In the case that both `lhs` and `rhs` are both arguments to a macro, this can produce a wildly incorrect span.

To fix this, first compute the span between `lhs` and the binary operator, which will cause `lhs` to possibly be adjusted to a relevant macro metavar, and then compute that span extended to `rhs`, which will cause it to also be adjusted to a relevant macro metavar.

This coincidentally fixes a FIXME in `tests/ui/lint/wide_pointer_comparisons.rs` and suppresses a nonsense suggestion.
2025-07-31 17:19:39 +02:00
Jana Dönszelmann
eec13cd273 Rollup merge of #144702 - compiler-errors:stall-const-arg-has-type, r=lcnr
stall `ConstArgHasType` in `compute_goal_fast_path`

I'm having major deja-vu about this; I thought that already implemented this but 🤷 maybe not.
2025-07-31 17:19:38 +02:00
Jana Dönszelmann
1fe488638b Rollup merge of #144688 - Stypox:better-enter-trace-span, r=RalfJung
Uniform `enter_trace_span!` and add documentation

1. The latest changes to `enter_trace_span!` were ported from Miri (see https://github.com/rust-lang/miri/pull/4452#discussion_r2204958019), so now both the `rustc_const_eval` and the Miri macro accept the same syntax. Furthermore, the Miri macro was changed to just call rustc_const_eval`'s, to avoid duplication.
2. I made the `layout_of` (& friends) calls use that new syntax, e.g. `enter_trace_span!(layouting::layout_of, ...)`
3. I made sure the macro specifies all types/traits/macros it refers to using `$crate::`, so the macro works anywhere independently of which types/traits/macros are imported in the context it is used in.
4. I added documentation, examples and tips to the macro's doc. To make the rustdoc compile I had to add some hidden lines (`#`), but now it acts as a compilation test which will avoid reintroducing issue 3. in the future. I will also create a documentation file with everything one needs to know about tracing at a later point, but I figured adding some of that info directly on the tracing macro makes it more discoverable.
5. In `stack.rs` I made it so that the `"frame"` span has a field named "frame" (instead of "message") with the data about the frame. This field used to be called "message" (tracing's default) since it was previously formatted using `"{}", instance`, and now I replaced it with `frame = %instance`.
2025-07-31 17:19:37 +02:00
Stypox
bb08a4dfc7 Make Miri's enter_trace_span! call const_eval's 2025-07-31 15:42:29 +02:00
Scott Schafer
935fdb6980 fix: Match width of ascii and unicode secondary file start 2025-07-31 07:26:39 -06:00
Jana Dönszelmann
e1d3ad89c7 remove rustc_attr_data_structures 2025-07-31 14:19:27 +02:00
bors
3fb1b53a9d Auto merge of #144731 - samueltardieu:rollup-36y30k2, r=samueltardieu
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#136840 (Fix linker-plugin-lto only doing thin lto)
 - rust-lang/rust#144053 (Remove install Rust script from CI)
 - rust-lang/rust#144297 (Make `libtest::ERROR_EXIT_CODE` const public to not redefine it in rustdoc)
 - rust-lang/rust#144721 (`std_detect`: Linux 6.16 support for RISC-V)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-07-31 12:04:04 +00:00
Samuel Tardieu
d8c09c10e5 Rollup merge of #136840 - Flakebi:linker-plugin-lto-fat, r=dianqk
Fix linker-plugin-lto only doing thin lto

When rust provides LLVM bitcode files to lld and the bitcode contains
function summaries as used for thin lto, lld defaults to using thin lto.
This prevents some optimizations that are only applied for fat lto.

We solve this by not creating function summaries when fat lto is
enabled. The bitcode for the module is just directly written out.

An alternative solution would be to set the `ThinLTO=0` module flag to
signal lld to do fat lto.
The code in clang that sets this flag is here:
560149b5e3/clang/lib/CodeGen/BackendUtil.cpp (L1150)
The code in LLVM that queries the flag and defaults to thin lto if not
set is here:
e258bca950/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp (L4441-L4446)

try-job: x86_64-gnu-debug
try-job: aarch64-gnu-debug
2025-07-31 13:12:45 +02:00
Nicholas Nethercote
066a973312 Overhaul Constraint.
This commit changes it to store a `Region` instead of a `RegionVid` for the `Var` cases:
- We avoid having to call `Region::new_var` to re-create `Region`s from
  `RegionVid`s in a few places, avoiding the interning process, giving a
  small perf win. (At the cost of the type allowing some invalid
  combinations of values.)
- All the cases now store two `Region`s, so the commit also separates
  the `ConstraintKind` (a new type) from the `sub` and `sup` arguments
  in `Constraint`.
2025-07-31 20:04:51 +10:00
Nicholas Nethercote
75a1f47750 Avoid vacuous Constraint::{VarSubVar,RegSubReg} constraints.
If the two regions are the same, we can skip it. This is a small perf win.
2025-07-31 20:04:51 +10:00
Nicholas Nethercote
704f2ca172 Tidy up Cargo.toml files.
- Add some missing `tidy-alphabetical-*` markers.
- Remove some unnecessary blank lines.
2025-07-31 19:58:04 +10:00