Commit Graph

5090 Commits

Author SHA1 Message Date
Matthias Krüger
616650b6ca
Rollup merge of #141121 - compiler-errors:ambig-is-not-err, r=lcnr
Only select true errors in `impossible_predicates`

See description in test.

Fixes #141119

r? lcnr
2025-05-17 15:45:22 +02:00
Michael Goulet
9578b59eac Only select true errors in impossible_predicates 2025-05-17 12:09:15 +00:00
Matthias Krüger
8c14588fbb
Rollup merge of #140208 - compiler-errors:wf-coinductive, r=lcnr
Make well-formedness predicates no longer coinductive

This PR makes well-formedness no longer coinductive. It was made coinductive in https://github.com/rust-lang/rust/pull/98542, but AFAICT this was only to fix UI tests since we stopped lowering `where Ty:` to an empty-region outlives predicate but to a WF predicate instead.

Arguably it should lower to something completely different, something like a "type mentioned no-op predicate", but well-formedness serves this purpose fine today, and since no code (according to crater) relies on this coinductive behavior, we'd like to avoid having to emulate it in the new solver.

Fixes #123456 (I didn't want to add a test since it seems low-value to have a ICE test for a fuzzer minimization that is basically garbage code.)

Fixes #109764 (not sure if this behavior is emulatable w/o coinductive WF?)

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

r? lcnr
2025-05-17 10:33:08 +02:00
bors
c8bda740ea Auto merge of #140978 - davidtwco:deep-reject-in-match-norm-trait-ref, r=lcnr
trait_sel: deep reject `match_normalize_trait_ref`

Spotted during an in-person review of #137944 at RustWeek: `match_normalize_trait_ref` could be using `DeepRejectCtxt` to exit early as an optimisation for projection candidates, like is done with param candidates.

r? `@lcnr`
cc `@oli-obk`
2025-05-16 23:39:39 +00:00
Matthias Krüger
d0ea342440
Rollup merge of #140947 - compiler-errors:pending-norm, r=lcnr
Flush errors before deep normalize in `dropck_outlives`

Deep normalization doesn't allow the ocx to have pending obligations, so process them before deeply normalizing.

Fixes https://github.com/rust-lang/rust/issues/140931
Fixes https://github.com/rust-lang/rust/issues/140462
2025-05-15 22:28:51 +02:00
Matthias Krüger
1f84e114f1
Rollup merge of #140712 - lcnr:normalization-gat-args, r=compiler-errors
normalization: avoid incompletely constraining GAT args

We need to copy the behavior of #125214 in the new solver. This fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/202 which seems to be the cause of the regression in `deptypes`.

r? ```@compiler-errors```
2025-05-15 22:28:50 +02:00
bors
c4e05e53d1 Auto merge of #136988 - compiler-errors:impossible_predicates, r=lcnr
Use the new solver in the `impossible_predicates`

The old solver is unsound for many reasons. One of which was weaponized by `@lcnr` in #140212, where the old solver was incompletely considering a dyn vtable method to be impossible and replacing its vtable entry with a null value. This null function could be called post-mono.

The new solver is expected to be less incomplete due to its correct handling of higher-ranked aliases in relate. This PR switches the `impossible_predicates` query to use the new solver, which patches this UB.

r? lcnr
2025-05-15 15:31:24 +00:00
bors
4eca99a18e Auto merge of #140887 - pietroalbini:pa-bootstrap-update, r=compiler-errors
Stage0 bootstrap update

This PR [follows the release process](https://forge.rust-lang.org/release/process.html#master-bootstrap-update-tuesday) to update the stage0 compiler.

The only thing of note is 58651d1b31, which was flagged by clippy as a correctness fix. I think allowing that lint in our case makes sense, but it's worth to have a second pair of eyes on it.

r? `@Mark-Simulacrum`
2025-05-13 09:54:28 +00:00
Michael Goulet
a508011b1f Expect deep norm to fail if query norm failed 2025-05-13 09:18:17 +00:00
David Wood
a5e1dba0cd
trait_sel: deep reject match_normalize_trait_ref
Spotted during an in-person review of unrelated changes,
`match_normalize_trait_ref` could be using `DeepRejectCtxt` to exit early
as an optimisation for prejection candidates, like is done in param
candidates.
2025-05-13 07:33:51 +00:00
Michael Goulet
df1da673f7 Flush errors before deep normalize in dropck_outlives 2025-05-12 21:04:38 +00:00
omahs
1caaa88700 Fix typos 2025-05-12 17:20:49 +00:00
Pietro Albini
2ce08ca5d6
update cfg(bootstrap) 2025-05-12 15:33:37 +02:00
Jieyou Xu
7dae31828b
Disarm time bomb (diagnostics)
Revert "Rollup merge of #129343 - estebank:time-version, r=jieyouxu"

This reverts commit 26f75a65d7, reversing
changes made to 2572e0e8c9.

Imports are modified to fix merge conflicts and remove unused ones.
2025-05-09 12:09:15 +02:00
lcnr
31ebe11f61 normalization: avoid incompletely constraining GAT args 2025-05-08 14:38:47 +00:00
Matthias Krüger
4ed13189ec
Rollup merge of #140736 - xizheyin:issue-140166, r=petrochenkov
trait selection: check `&` before suggest remove deref

FIxes #140166

r? compiler
2025-05-08 13:55:44 +02:00
Matthias Krüger
74b79aee60
Rollup merge of #140711 - compiler-errors:combine-maybes, r=lcnr
Do not discard constraints on overflow if there was candidate ambiguity

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

There's a pretty chunky justification in the test.

r? lcnr
2025-05-08 08:14:18 +02:00
Matthias Krüger
aace48811b
Rollup merge of #140641 - lcnr:opaque-type-storage-entries, r=compiler-errors
detect additional uses of opaques after writeback

Based on #140607. It's a lot harder to encounter in practice than I though 😅 😁 I've still added it with the expectation that somebody will encounter it at some point.

Also modifies the `EvalCtxt` to use the same impl to detect newly added opaque types.

r? ``@compiler-errors``
2025-05-08 08:14:18 +02:00
lcnr
fc0ef54fd9 opaque_type_storage to InferCtxtLike 2025-05-07 17:58:20 +00:00
Michael Goulet
a910329c67 Use MaybeCause::or to allow constraints from overflows if they are combined with ambiguity 2025-05-07 17:12:15 +00:00
Michael Goulet
df13f7c1fa Require T: TypeFoldable in Binder<T> visit 2025-05-07 16:00:21 +00:00
xizheyin
bd88f3e3e3
Check & before suggest remove deref when trait_selection
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-05-07 23:23:25 +08:00
bors
f76c7367c6 Auto merge of #137995 - hkBst:parse_format_reuse_unescape, r=nnethercote
Remove duplicate impl of string unescape from parse_format

r? `@nnethercote`
2025-05-07 06:18:39 +00:00
lcnr
431f02d531 support duplicates in the opaque_types_storage 2025-05-06 14:59:09 +00:00
Marijn Schouten
3d4737fb5e Remove duplicate impl of string unescape 2025-05-06 10:00:22 +00:00
Guillaume Gomez
1c801a385c
Rollup merge of #140605 - lcnr:defer-opaque-type-error, r=compiler-errors
`fn check_opaque_type_parameter_valid` defer error

Will be used in #139587 to silence opaque type errors if there are other borrowck failures. I think it can be merged separately.

r? `@compiler-errors`
2025-05-05 21:32:33 +02:00
Guillaume Gomez
224e3ca096
Rollup merge of #140559 - rperier:type-ir-to-type-middle, r=compiler-errors
Removing rustc_type_ir in the rustc_infer codebase

cc #138449

This is a second refactoring of rustc_type_ir to use rustc_middle instead, this time that's for rustc_infer
2025-05-05 21:32:32 +02:00
Trevor Gross
e9a50b8a0a
Rollup merge of #140307 - mejrs:condition_parser, r=nnethercote
Refactor rustc_on_unimplemented's filter parser

Followup to https://github.com/rust-lang/rust/pull/139091; I plan on moving most of this code into `rustc_attr_parsing` at some point, but want to land this separately first.

I have taken care to preserve the original behavior as much as I could:
- All but one of the new error variants are replacements for the ones originally emitted by the cfg parsing machinery; so these errors are not "new".
- the `InvalidFlag` variant is new, this PR turns this (from being ignored and silently doing nothing) into an error:
    ```rust
    #[rustc_on_unimplemented(on(something, message = "y"))]
    //~^ ERROR invalid boolean flag
    //~^^ NOTE expected one of `crate_local`, `direct` or `from_desugaring`, not `something`
    trait InvalidFlag {}
    ```
    This does not occur anywhere except in this test. I couldn't find a way that I liked to keep allowing this or to do nothing, erroring was the cleanest solution.
- There are a bunch of FIXME throughout this and the previous PR, I plan on addressing those in follow up prs..

Finally, this gets rid of the "longest" dependency in rustc:
![image](https://github.com/user-attachments/assets/3c3eb3a0-b7b3-40d9-aada-a752e28c8678)
2025-05-05 00:20:57 -04:00
bors
1bea580f36 Auto merge of #140549 - BoxyUwU:proper_const_norm, r=lcnr
Set groundwork for proper const normalization

r? lcnr

Updates a lot of our normalization/alias infrastructure to be setup to handle mgca aliases and normalization once const items are represented more like aliases than bodies. Inherent associated consts are still super busted, I didn't update the assertions that IACs the right arg setup because that winds up being somewhat involved to do *before* proper support for normalizing const aliases is implemented.

I dont *intend* for this to have any effect on stable. We continue normalizing via ctfe on stable and the codepaths in `project` for consts should only be reachable with mgca or ace.
2025-05-04 03:12:41 +00:00
lcnr
d0216b5386 fn check_opaque_type_parameter_valid defer error 2025-05-03 21:32:24 +00:00
mejrs
4671081bdb Refactor rustc_on_unimplemented's filter parser 2025-05-02 22:08:35 +02:00
Matthias Krüger
296733d5ac
Rollup merge of #140519 - compiler-errors:name-based-comparison, r=oli-obk
Use select in projection lookup in `report_projection_error`

Using `for_each_relevant_impl` doesn't actually select the correct impl; we can use `select` here to actually get the correct impl with certainty. Follow-up to https://github.com/rust-lang/rust/pull/140278.

r? oli-obk
2025-05-02 19:37:57 +02:00
Romain Perier
6970813e78 Use less rustc_type_ir in the compiler codebase
This commit does the following:
  - Replaces use of rustc_type_ir by rustc_middle in rustc_infer.
  - The DelayedMap type is exposed by rustc_middle so everything can be
    accessed through rustc_middle in a coherent manner.
  - API-layer traits, like InferCtxtLike, Interner or inherent::* must be
    accessed via rustc_type_ir, not rustc_middle::ty. For this reason
    these are not reexported by rustc_middle::ty.
  - Replaces use of ty::Interner by rustc_type_ir::Interner in
    rustc_trait_selection
2025-05-02 09:37:06 +02:00
Boxy
238d113b07 Set groundwork for proper const normalization 2025-05-01 20:05:02 +01:00
Boxy
53e3907bcb No-op split into sub functions 2025-05-01 14:34:19 +01:00
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
Michael Goulet
f2930001aa Use select in projection lookup 2025-04-30 18:07:52 +00: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
Michael Goulet
38c05a68ee Adjust tests 2025-04-29 03:07:24 +00:00
Michael Goulet
f918b89f61 Wf is not coinductive 2025-04-29 02:43:06 +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