Commit Graph

5066 Commits

Author SHA1 Message Date
lcnr
fc0ef54fd9 opaque_type_storage to InferCtxtLike 2025-05-07 17:58:20 +00: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
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