Commit Graph

5051 Commits

Author SHA1 Message Date
Matthias Krüger
6423d75076
Rollup merge of #140468 - BoxyUwU:normalization_confusings2, r=lcnr
Minor tweaks to make some normalization (adjacent) code less confusing

r? lcnr

sorry for double ping lol
2025-04-30 22:36:41 +02:00
Matthias Krüger
1e440aecc8
Rollup merge of #140516 - rperier:type-ir-to-type-middle, r=lcnr
Replace use of rustc_type_ir by rustc_middle

cc #138449

I want to help on this issue. I have replaced all the rustc_type_ir uses by the equivalent type in rustc_middle.
DelayedSet is also re-exposed by rustc_middle.
2025-04-30 17:28:02 +02:00
Romain Perier
ea7af1803f Use less rustc_type_ir in the compiler codebase
This commit does the following:
 - Replaces use of rustc_type_ir by rustc_middle
 - Removes the rustc_type_ir dependency
 - The DelayedSet type is exposed by rustc_middle so everything can be
   accessed through rustc_middle in a coherent manner.
2025-04-30 16:42:33 +02:00
Matthias Krüger
9625096d2c
Rollup merge of #140445 - oli-obk:const-manually-drop, r=fee1-dead
Treat ManuallyDrop as ~const Destruct

cc https://github.com/rust-lang/rust/issues/133214#issuecomment-2838078133

r? ```@compiler-errors```

cc ```@fee1-dead```
2025-04-30 10:18:28 +02:00
Boxy
c31794d6d3 confusings 2025-04-29 18:55:21 +01:00
Trevor Gross
a20fe8ff23
Rollup merge of #139909 - oli-obk:or-patterns, r=BoxyUwU
implement or-patterns for pattern types

These are necessary to represent `NonZeroI32`, as the range for that is `..0 | 1..`. The `rustc_scalar_layout_range_*` attributes avoided this by just implementing wraparound and having a single `1..=-1` range effectively. See https://rust-lang.zulipchat.com/#narrow/channel/481660-t-lang.2Fpattern-types/topic/.60or.20pattern.60.20representation.20in.20type.20system/with/504217694 for some background discussion

cc https://github.com/rust-lang/rust/issues/123646

r? `@BoxyUwU`
2025-04-29 12:28:22 -04:00
Oli Scherer
a1c70590b2 Treat ManuallyDrop as ~const Destruct 2025-04-29 10:39:54 +00:00
bors
25cdf1f674 Auto merge of #140388 - GuillaumeGomez:rollup-aj9o3ch, r=GuillaumeGomez
Rollup of 7 pull requests

Successful merges:

 - #140056 (Fix a wrong error message in 2024 edition)
 - #140220 (Fix detection of main function if there are expressions around it)
 - #140249 (Remove `weak` alias terminology)
 - #140316 (Introduce `BoxMarker` to improve pretty-printing correctness)
 - #140347 (ci: clean more disk space in codebuild)
 - #140349 (ci: use aws codebuild for the `dist-x86_64-linux` job)
 - #140379 (rustc-dev-guide subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-04-28 17:22:11 +00:00
Guillaume Gomez
7843686ffe
Rollup merge of #140249 - BoxyUwU:remove_weak_alias_terminology, r=oli-obk
Remove `weak` alias terminology

I find the "weak" alias terminology to be quite confusing. It implies the existence of "strong" aliases (which do not exist) and I'm not really sure what about weak aliases is "weak". I much prefer "free alias" as the term. I think it's much more obvious what it means as "free function" is a well defined term that already exists in rust.

It's also a little confusing given "weak alias" is already a term in linker/codegen spaces which are part of the compiler too. Though I'm not particularly worried about that as it's usually very obvious if you're talking about the type system or not lol. I'm also currently trying to write documentation about aliases and it's somewhat awkward/confusing to be talking about *weak* aliases, when I'm not really sure what the basis for that as the term actually *is*.

I would also be happy to just find out there's a nice meaning behind calling them "weak" aliases :-)

r? `@oli-obk`

maybe we want a types MCP to decide on a specific naming here? or maybe we think its just too late to go back on this naming decision ^^'
2025-04-28 13:30:45 +02:00
Andrew Zhogin
c366756a85 AsyncDrop implementation using shim codegen of async_drop_in_place::{closure}, scoped async drop added. 2025-04-28 16:23:13 +07:00
Oli Scherer
b023856f29 Add or-patterns to pattern types 2025-04-28 07:50:18 +00:00
Oli Scherer
cb6d3715a5 Split out various pattern type matches into their own function 2025-04-28 07:46:50 +00:00
Matthias Krüger
3c322bc1cc
Rollup merge of #140320 - lcnr:wf-use-term, r=compiler-errors
replace `GenericArg` with `Term` where applicable

r? types
2025-04-26 16:12:33 +02:00
Matthias Krüger
443358d25d
Rollup merge of #140318 - compiler-errors:specialized-async-fn-kind-err, r=fee1-dead
Simply try to unpeel AsyncFnKindHelper goal in `emit_specialized_closure_kind_error`

Tweak the handling of `AsyncFnKindHelper` goals in `emit_specialized_closure_kind_error` to not be so special-casey, and just try to unpeel one or two layers of obligation causes to get to their underlying `AsyncFn*` goal.

Fixes https://github.com/rust-lang/rust/issues/140292
2025-04-26 16:12:33 +02:00
lcnr
855035b038 convert some GenericArg to Term 2025-04-26 02:05:31 +00:00
Michael Goulet
4b309c67c6 Simply try to unpeel AsyncFnKindHelper goal in emit_specialized_closure_kind_error 2025-04-26 01:42:52 +00:00
Michael Goulet
31c8d10342 Track per-obligation recursion depth only if there is inference 2025-04-25 18:14:39 +00:00
Matthias Krüger
3c08a50a15
Rollup merge of #140278 - compiler-errors:name-based-comparison, r=nnethercote
Don't use item name to look up associated item from trait item

This fix should be self-justifying b/c the fact that we were using identifiers here was kinda sus anyways, esp b/c we have a failproof way of doing the comparison :) I'll leave some info about why this repro needs a macro.

Fixes https://github.com/rust-lang/rust/issues/140259

r? `@nnethercote`
2025-04-25 07:50:27 +02:00
Matthias Krüger
564e5ccb5c
Rollup merge of #140202 - est31:let_chains_feature_compiler, r=lcnr
Make #![feature(let_chains)] bootstrap conditional in compiler/

Let chains have been stabilized recently in #132833, so we can remove the gating from our uses in the compiler (as the compiler uses edition 2024).
2025-04-25 07:50:25 +02:00
Michael Goulet
1d0b3be659 Don't use item name to look up associated item from trait item 2025-04-25 01:57:45 +00:00
bors
3c877f6a47 Auto merge of #140245 - matthiaskrgr:rollup-e0fwsfv, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #139261 (mitigate MSVC alignment issue on x86-32)
 - #140075 (Mention average in midpoint documentations)
 - #140184 (Update doc of cygwin target)
 - #140186 (Rename `compute_x` methods)
 - #140194 (minicore: Have `//@ add-core-stubs` also imply `-Cforce-unwind-tables=yes`)
 - #140195 (triagebot: label minicore changes w/ `A-test-infra-minicore` and ping jieyouxu on changes)
 - #140214 (Remove comment about handling non-global where bounds with corresponding projection)
 - #140228 (Revert overzealous parse recovery for single colons in paths)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-04-24 12:06:16 +00:00
Boxy
bdfeb8f36b Remove weak alias terminology 2025-04-24 11:59:20 +01:00
Matthias Krüger
1553cfa4e6
Rollup merge of #140214 - compiler-errors:remove-hack, r=lcnr
Remove comment about handling non-global where bounds with corresponding projection

This comment is no longer relevant since we only assemble rigid projections if no param-env candidates hold.

Also remove a stray comment from the old solver.

r? lcnr
2025-04-24 11:40:46 +02:00
Matthias Krüger
60c2c34d1d
Rollup merge of #140186 - BoxyUwU:compute_what, r=compiler-errors
Rename `compute_x` methods

r? ```@lcnr```

I find the `compute_x` naming scheme to be overly confusing. It means `compute_wf_obligations_for_x_and_add_them_to_self` but shortens out all of the important parts of the actual operation being performed. `compute_x` sounds like its somehow performing `x`, maybe even returning it from the function, which is not true.

I've had some newer contributors be confused by this naming scheme so I think it's good to change it to something more self-evident

Some misc drive by niceties while I was here too.
2025-04-24 11:40:40 +02:00
Matthias Krüger
986750ded4
Rollup merge of #140232 - nnethercote:rm-unnecessary-clones, r=SparrowLii
Remove unnecessary clones

r? `@SparrowLii`
2025-04-24 08:13:01 +02:00
Matthias Krüger
2ba3a5c909
Rollup merge of #139945 - shepmaster:hir-lifetime-syntax-source, r=nnethercote
Extend HIR to track the source and syntax of a lifetime

An upcoming lint will want to be able to know if a lifetime is hidden (e.g. `&u8`, `ContainsLifetime`) or anonymous: (e.g. `&'_ u8`, `ContainsLifetime<'_>`). It will also want to know if the lifetime is related to a reference (`&u8`) or a path (`ContainsLifetime`).

r? ``@nnethercote``
2025-04-24 08:12:59 +02:00
Nicholas Nethercote
055a27da2a Remove some unnecessary clones.
I found these by grepping for `&[a-z_\.]*\.clone()`, i.e. expressions
like `&a.b.clone()`, which are sometimes unnecessary clones, and also
looking at clones nearby to cases like that.
2025-04-24 11:12:34 +10:00
bors
fa58ce343a Auto merge of #138845 - compiler-errors:stall-generators, r=lcnr
Properly stall coroutine witnesses in new solver

TODO: write description

r? lcnr
2025-04-23 21:35:15 +00:00
Jake Goulding
2a5c349f42 Extend HIR to track the source and syntax of a lifetime
An upcoming lint will want to be able to know if a lifetime is
hidden (e.g. `&u8`, `ContainsLifetime`) or anonymous: (e.g. `&'_ u8`,
`ContainsLifetime<'_>`). It will also want to know if the lifetime is
related to a reference (`&u8`) or a path (`ContainsLifetime`).
2025-04-23 16:37:39 -04:00
Michael Goulet
1162f42b86 Remove hack 2025-04-23 18:36:37 +00:00
Michael Goulet
f943f73db4 More 2025-04-23 15:09:25 +00:00
est31
7493e1cdf6 Make #![feature(let_chains)] bootstrap conditional in compiler/ 2025-04-23 16:40:30 +02:00
Boxy
c6e6ac9575 Module docs 2025-04-23 04:14:35 +01:00
Boxy
0a76ef816f Rename compute_x methods 2025-04-23 04:14:30 +01:00
Michael Goulet
7c1661f945 Consider Copy/Clone too 2025-04-22 17:05:15 +00:00
Michael Goulet
169955f3be Properly drain pending obligations for coroutines 2025-04-22 16:50:38 +00:00
Michael Goulet
67df5b9cfa Collect and resolve ambiguous obligations from normalizing in writeback 2025-04-22 16:50:38 +00:00
Oli Scherer
5d2952100f Use is_lang_item and as_lang_item instead of handrolling their logic 2025-04-22 11:02:37 +00:00
Chris Denton
f79eef91df
Rollup merge of #140021 - compiler-errors:no-deep-norm-ice, r=lcnr
Don't ICE on pending obligations from deep normalization in a loop

See the comment I left inline in `compiler/rustc_trait_selection/src/traits/normalize.rs`.

Fixes https://github.com/rust-lang/rust/issues/133868

r? lcnr
2025-04-21 15:55:58 +00:00
Michael Goulet
47911eb677 Don't ICE on pending obligations from deep normalization in a loop 2025-04-19 17:34:00 +00:00
Chris Denton
aad59a30de
Rollup merge of #139091 - mejrs:format, r=compiler-errors
Rewrite on_unimplemented format string parser.

This PR rewrites the format string parser for `rustc_on_unimplemented` and `diagnostic::on_unimplemented`. I plan on moving this code (and more) into the new attribute parsing system soon and wanted to PR it separately.

This PR introduces some minor differences though:
- `rustc_on_unimplemented` on trait *implementations* is no longer checked/used - this is actually never used (outside of some tests) so I plan on removing it in the future.
- for `rustc_on_unimplemented`, it introduces the `{This}` argument in favor of `{ThisTraitname}` (to be removed later). It'll be easier to parse.
- for `rustc_on_unimplemented`, `Self` can now consistently be used as a filter, rather than just `_Self`. It used to not match correctly on for example `Self = "[{integer}]"`
- Some error messages now have better spans.

Fixes https://github.com/rust-lang/rust/issues/130627
2025-04-19 15:09:33 +00:00
Matthias Krüger
da43826398
Rollup merge of #139774 - compiler-errors:supertrait-alias, r=lcnr
Fix replacing supertrait aliases in `ReplaceProjectionWith`

The new solver has a procedure called `predicates_for_object_candidate`, which elaborates the super-bounds and item-bounds that are required to hold for a dyn trait to implement something via a built-in object impl.

In that procedure, there is a folder called `ReplaceProjectionWith` which is responsible for replacing projections that reference `Self`, so that we don't encounter cycles when we then go on to normalize those projections in the process of proving these super-bounds.

That folder had a few problems: Firstly, it wasn't actually checking that this was a super bound originating from `Self`. Secondly, it only accounted for a *single* projection type def id, but trait objects can have multiple (i.e. `trait Foo<A, B>: Bar<A, Assoc = A> + Bar<B, Assoc = B>`).

To fix the first, it's simple enough to just add an equality check for the self ty. To fix the second, I implemented a matching step that's very similar to the `projection_may_match` check we have for upcasting, since on top of having multiple choices, we need to deal with both non-structural matches and ambiguity.

This probably lacks a bit of documentation, but I think it works pretty well.

Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/171

r? lcnr
2025-04-17 17:40:27 +02:00
bors
883f9f72e8 Auto merge of #139949 - matthiaskrgr:rollup-pxc5tsx, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #138632 (Stabilize `cfg_boolean_literals`)
 - #139416 (unstable book; document `macro_metavar_expr_concat`)
 - #139782 (Consistent with treating Ctor Call as Struct in liveness analysis)
 - #139885 (document RUSTC_BOOTSTRAP, RUSTC_OVERRIDE_VERSION_STRING, and -Z allow-features in the unstable book)
 - #139904 (Explicitly annotate edition for `unpretty=expanded` and `unpretty=hir` tests)
 - #139932 (transmutability: Refactor tests for simplicity)
 - #139944 (Move eager translation to a method on Diag)
 - #139948 (git: ignore `60600a6fa403216bfd66e04f948b1822f6450af7` for blame purposes)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-04-17 11:21:54 +00:00
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
Michael Goulet
3863018d96 Fix replacing supertrait aliases in ReplaceProjectionWith 2025-04-16 20:05:55 +00:00
Nicholas Nethercote
fe882bf330 Rename LifetimeName as LifetimeKind.
It's a much better name, more consistent with how we name such things.

Also rename `Lifetime::res` as `Lifetime::kind` to match. I suspect this
field used to have the type `LifetimeRes` and then the type was changed
but the field name remained the same.
2025-04-16 07:16:40 +10:00
bors
f433fa46b0 Auto merge of #139845 - Zalathar:rollup-u5u5y1v, r=Zalathar
Rollup of 17 pull requests

Successful merges:

 - #138374 (Enable contracts for const functions)
 - #138380 (ci: add runners for vanilla LLVM 20)
 - #138393 (Allow const patterns of matches to contain pattern types)
 - #139517 (std: sys: process: uefi: Use NULL stdin by default)
 - #139554 (std: add Output::exit_ok)
 - #139660 (compiletest: Add an experimental new executor to replace libtest)
 - #139669 (Overhaul `AssocItem`)
 - #139671 (Proc macro span API redesign: Replace proc_macro::SourceFile by Span::{file, local_file})
 - #139750 (std/thread: Use default stack size from menuconfig for NuttX)
 - #139772 (Remove `hir::Map`)
 - #139785 (Let CStrings be either 1 or 2 byte aligned.)
 - #139789 (do not unnecessarily leak auto traits in item bounds)
 - #139791 (drop global where-bounds before merging candidates)
 - #139798 (normalize: prefer `ParamEnv` over `AliasBound` candidates)
 - #139822 (Fix: Map EOPNOTSUPP to ErrorKind::Unsupported on Unix)
 - #139833 (Fix some HIR pretty-printing problems)
 - #139836 (Basic tests of MPMC receiver cloning)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-04-15 08:02:23 +00:00
Stuart Cook
13cd5256ac
Rollup merge of #139669 - nnethercote:overhaul-AssocItem, r=oli-obk
Overhaul `AssocItem`

`AssocItem` has multiple fields that only make sense some of the time. E.g. the `name` can be empty if it's an RPITIT associated type. It's clearer and less error prone if these fields are moved to the relevant `kind` variants.

r? ``@fee1-dead``
2025-04-15 15:47:27 +10:00
bors
58c2dd9a54 Auto merge of #139826 - matthiaskrgr:rollup-0q0qvkd, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #139745 (Avoid unused clones in `Cloned<I>` and `Copied<I>`)
 - #139757 (opt-dist: use executable-extension for host llvm-profdata)
 - #139778 (Add test for issue 34834)
 - #139783 (Use `compiletest-ignore-dir` for bootstrap self-tests)
 - #139797 (Allow (but don't require) `#[unsafe(naked)]` so that `compiler-builtins` can upgrade to it)
 - #139799 (Specify `--print info=file` syntax in `--help`)
 - #139811 (Use `newtype_index!`-generated types more idiomatically)
 - #139813 (Miri subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-04-15 04:50:15 +00:00
Nicholas Nethercote
78599d83e7 Move name field from AssocItem to AssocKind variants.
To accurately reflect that RPITIT assoc items don't have a name. This
avoids the use of `kw::Empty` to mean "no name", which is error prone.

Helps with #137978.
2025-04-15 08:07:15 +10:00