Commit Graph

269751 Commits

Author SHA1 Message Date
lcnr
dc750665ae normalization folders, yeet ParamEnv::reveal 2024-10-31 14:55:53 +01:00
lcnr
2cde638ac0 stop using ParamEnv::reveal while handling MIR 2024-10-31 14:55:53 +01:00
lcnr
563c473e8d clippy: we've got a LateContext use it for TypingMode 2024-10-31 12:43:22 +01:00
lcnr
aab149b58c ConstCx stop using ParamEnv::reveal 2024-10-31 12:43:22 +01:00
lcnr
84295b917d traits::project: yeet ParamEnv::reveal 2024-10-31 12:06:19 +01:00
bors
4d296eabe4 Auto merge of #132384 - matthiaskrgr:rollup-0ze5wc4, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #132347 (Remove `ValueAnalysis` and `ValueAnalysisWrapper`.)
 - #132365 (pass `RUSTC_HOST_FLAGS` at once without the for loop)
 - #132366 (Do not enforce `~const` constness effects in typeck if `rustc_do_not_const_check`)
 - #132376 (Annotate `input` reference tests)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-10-31 06:22:57 +00:00
Matthias Krüger
49a76c14c4
Rollup merge of #132376 - ehuss:reference-input, r=traviscross
Annotate `input` reference tests

This adds test annotations for rules in the [input chapter](https://doc.rust-lang.org/nightly/reference/input-format.html) of the reference.
2024-10-31 06:11:58 +01:00
Matthias Krüger
39086e4290
Rollup merge of #132366 - compiler-errors:do-not-const-check, r=fee1-dead
Do not enforce `~const` constness effects in typeck if `rustc_do_not_const_check`

Fixes a slight inconsistency between HIR and MIR enforcement of `~const` :D

r? `@rust-lang/project-const-traits`
2024-10-31 06:11:58 +01:00
Matthias Krüger
2b93bf60ee
Rollup merge of #132365 - onur-ozkan:less-rustc-overhead, r=Kobzol
pass `RUSTC_HOST_FLAGS` at once without the for loop

For obvious reasons...
2024-10-31 06:11:57 +01:00
Matthias Krüger
e228e31293
Rollup merge of #132347 - nnethercote:rm-ValueAnalysisWrapper, r=cjgillot
Remove `ValueAnalysis` and `ValueAnalysisWrapper`.

They represent a lot of abstraction and indirection, but they're only used for `ConstAnalysis`, and apparently won't be used for any other analyses in the future. This commit inlines and removes them, which makes `ConstAnalysis` easier to read and understand.

r? `@cjgillot`
2024-10-31 06:11:57 +01:00
bors
c8b83785dc Auto merge of #131186 - compiler-errors:precise-capturing-borrowck, r=estebank
Try to point out when edition 2024 lifetime capture rules cause borrowck issues

Lifetime capture rules in 2024 are modified to capture more lifetimes, which sometimes lead to some non-local borrowck errors. This PR attempts to link these back together with a useful note pointing out the capture rule changes.

This is not a blocking concern, but I'd appreciate feedback (though, again, I'd like to stress that I don't want to block this PR on this): I'm worried about this note drowning in the sea of other diagnostics that borrowck emits. I was tempted to change the level of the note to `.span_warn` just so it would show up in a different color. Thoughts?

Fixes #130545

Opening as a draft first since it's stacked on #131183.
r? `@ghost`
2024-10-31 03:36:06 +00:00
Nicholas Nethercote
846e20c3b6 Reduce some visibilities. 2024-10-31 12:46:30 +11:00
Nicholas Nethercote
911edbfe42 Remove ValueAnalysis and ValueAnalysisWrapper.
They represent a lot of abstraction and indirection, but they're only
used for `ConstAnalysis`, and apparently won't be used for any other
analyses in the future. This commit inlines and removes them, which
makes `ConstAnalysis` easier to read and understand.
2024-10-31 12:46:26 +11:00
Michael Goulet
c1457798db Try to point out when edition 2024 lifetime capture rules cause borrowck issues 2024-10-31 01:35:14 +00:00
Michael Goulet
e093b82a41 Encode cross-crate opaque type origin 2024-10-31 01:35:13 +00:00
bors
75eff9a574 Auto merge of #132377 - matthiaskrgr:rollup-3p1c6hs, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #132368 (Remove `do_not_const_check` from `Iterator` methods)
 - #132373 (Make sure `type_param_predicates` resolves correctly for RPITIT)
 - #132374 (Remove dead code stemming from the old effects desugaring)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-10-31 00:46:22 +00:00
Matthias Krüger
7d0dbc5f53
Rollup merge of #132374 - fmease:rm-dead-eff-code, r=compiler-errors
Remove dead code stemming from the old effects desugaring

r? project-const-traits
2024-10-31 01:14:04 +01:00
Matthias Krüger
efd5645e43
Rollup merge of #132373 - compiler-errors:rpitit-bound, r=fmease
Make sure `type_param_predicates` resolves correctly for RPITIT

After #132194, we end up lowering the item bounds for an RPITIT in an `ItemCtxt` whose def id is the *synthetic GAT*, not the opaque type from the HIR.

This means that when we're resolving a shorthand projection like `T::Assoc`, we call the `type_param_predicates` function with the `item_def_id` of the *GAT* and not the opaque. That function operates on the HIR, and is not designed to work with the `Node::Synthetic` that gets fed for items synthesized by the compiler...

This PR reuses the trick we use elsewhere in lowering, where we intercept whether an item comes from RPITIT lowering, and forwards the query off to the correct item.

Fixes #132372
2024-10-31 01:14:03 +01:00
Matthias Krüger
271a8c9f43
Rollup merge of #132368 - compiler-errors:do-not-iterator, r=tgross35
Remove `do_not_const_check` from `Iterator` methods

This attribute is not yet used, but keeping them around seems unnecessarily risky. I don't believe we should be constifying the `Iterator` trait until we've fully thought out how const closures are gonna work and have transitively consified all of its (implementation) dependencies.

cc `@rust-lang/project-const-traits`
r? libs
2024-10-31 01:14:02 +01:00
Eric Huss
37c3884152 Annotate input reference tests 2024-10-30 16:47:47 -07:00
León Orell Valerian Liehr
a6bbdf0fd4
Remove dead code stemming from the old effects desugaring 2024-10-30 23:55:13 +01:00
Michael Goulet
d53ca63453 Make sure type_param_predicates resolves correctly for RPITIT 2024-10-30 22:30:28 +00:00
bors
4add5e4211 Auto merge of #132371 - workingjubilee:rollup-aqd86tm, r=workingjubilee
Rollup of 5 pull requests

Successful merges:

 - #129383 (Remap impl-trait lifetimes on HIR instead of AST lowering)
 - #132210 (rustdoc: make doctest span tweak a 2024 edition change)
 - #132246 (Rename `rustc_abi::Abi` to `BackendRepr`)
 - #132267 (force-recompile library changes on download-rustc="if-unchanged")
 - #132344 (Merge `HostPolarity` and `BoundConstness`)

Failed merges:

 - #132347 (Remove `ValueAnalysis` and `ValueAnalysisWrapper`.)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-10-30 22:07:49 +00:00
onur-ozkan
4b52bbcf03 pass RUSTC_HOST_FLAGS at once without the for loop
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-10-31 00:12:25 +03:00
Jubilee
7b19508abe
Rollup merge of #132344 - compiler-errors:same-thing, r=lcnr
Merge `HostPolarity` and `BoundConstness`

They're basically the same thing, and I think `BoundConstness` is easier to use.

r? fee1-dead or reassign
2024-10-30 14:01:38 -07:00
Jubilee
f90abe763b
Rollup merge of #132267 - onur-ozkan:rustc-if-unchanged-force-library, r=Kobzol
force-recompile library changes on download-rustc="if-unchanged"

This makes the download-rustc="if-unchanged" option more functional and useful for library developers.

Implements the second item from [this tracking issue](https://github.com/rust-lang/rust/issues/131744).
2024-10-30 14:01:38 -07:00
Jubilee
847b6fe6b0
Rollup merge of #132246 - workingjubilee:campaign-on-irform, r=compiler-errors
Rename `rustc_abi::Abi` to `BackendRepr`

Remove the confabulation of `rustc_abi::Abi` with what "ABI" actually means by renaming it to `BackendRepr`, and rename `Abi::Aggregate` to `BackendRepr::Memory`. The type never actually represented how things are passed, as that has to have `PassMode` considered, at minimum, but rather it just is how we represented some things to the backend. This conflation arose because LLVM, the primary backend at the time, would lower certain IR forms using certain ABIs. Even that only somewhat was true, as it broke down when one ventured significantly afield of what is described by the System V AMD64 ABI either by using different architectures, ABI-modifying IR annotations, the same architecture **with different ISA extensions enabled**, or other... unexpected delights.

Unfortunately both names are still somewhat of a misnomer right now, as people have written code for years based on this misunderstanding. Still, their original names are even moreso, and for better or worse, this backend code hasn't received as much maintenance as the rest of the compiler, lately. Actually arriving at a correct end-state will simply require us to disentangle a lot of code in order to fix, much of it pointlessly repeated in several places. Thus this is not an "actual fix", just a way to deflect further misunderstandings.
2024-10-30 14:01:37 -07:00
Jubilee
62ba25de39
Rollup merge of #132210 - notriddle:notriddle/doctest-span-hack, r=GuillaumeGomez
rustdoc: make doctest span tweak a 2024 edition change

Fixes #132203

This is a compatibility hack, because I think the new behavior is better. When an A `include_str!` B, and B `include_str!` C, the path to C should be resolved relative to B, not A. That's how `include!` itself works, so that's how `include_str!` with should work.
2024-10-30 14:01:37 -07:00
Jubilee
6b60f03f15
Rollup merge of #129383 - cjgillot:opaque-noremap, r=compiler-errors,petrochenkov
Remap impl-trait lifetimes on HIR instead of AST lowering

Current AST->HIR lowering goes out of its way to remap lifetimes for opaque types. This is complicated and leaks into upstream and downstream code.

This PR stops trying to be clever during lowering, and prefers to do this remapping during the HIR->ty lowering. The remapping computation easily fits into the bound var resolution code. Its result can be used in by `generics_of` and `hir_ty_lowering::new_opaque` to add the proper parameters and arguments.

See an example on the doc for query `opaque_captured_lifetimes`.

Based on https://github.com/rust-lang/rust/pull/129244/

Fixes https://github.com/rust-lang/rust/issues/125249
Fixes https://github.com/rust-lang/rust/issues/126850

cc `@compiler-errors` `@spastorino`
r? `@petrochenkov`
2024-10-30 14:01:36 -07:00
Michael Howell
ac7de1a0d9 Ignore Windows due to its differing path syntax 2024-10-30 12:39:05 -07:00
Michael Goulet
c62f0977a0 Remove do_not_const_check from Iterator methods 2024-10-30 19:24:34 +00:00
Michael Goulet
ec033e5bf1 Do not enforce ~const constness effects in typeck if rustc_do_mot_const_check 2024-10-30 17:41:09 +00:00
bors
759e07f063 Auto merge of #132361 - jieyouxu:rollup-zburkwr, r=jieyouxu
Rollup of 6 pull requests

Successful merges:

 - #130098 (Reject generic self types.)
 - #131096 (rustdoc: Remove usage of `allow(unused)` attribute on `no_run` merged doctests)
 - #132315 (compiletest: improve robustness of LLVM version handling)
 - #132346 (Some graphviz tweaks)
 - #132359 (Fix AIX libc call char type from i8 to u8)
 - #132360 (Un-vacation myself)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-10-30 17:14:47 +00:00
Michael Goulet
802f3a78a6 Merge HostPolarity and BoundConstness 2024-10-30 16:23:16 +00:00
Camille GILLOT
2d74d8f333 Actually capture all in-scope lifetimes. 2024-10-30 16:22:23 +00:00
Camille GILLOT
8f6e0a6a4b Promote test. 2024-10-30 16:22:14 +00:00
Camille GILLOT
27c958fb44 Review comments. 2024-10-30 16:20:49 +00:00
Camille GILLOT
d804ef8be8 Adapt comments. 2024-10-30 16:20:02 +00:00
Camille GILLOT
d693e19268 Promote crashes tests to ui. 2024-10-30 16:19:53 +00:00
Camille GILLOT
b6e1214ac0 Remap impl-trait lifetimes on HIR instead of AST lowering. 2024-10-30 16:18:50 +00:00
许杰友 Jieyou Xu (Joe)
5209757e29
Rollup merge of #132360 - BoxyUwU:hellorustc, r=BoxyUwU
Un-vacation myself

beep boop
2024-10-30 22:22:06 +08:00
许杰友 Jieyou Xu (Joe)
426f2fbbe2
Rollup merge of #132359 - mustartt:henry/match-libc-char-type, r=jieyouxu
Fix AIX libc call char type from i8 to u8

There was an update to AIX `libc` default char type from `i8 -> u8`, we should reflect that on the call site to satisfy the type checker.

81f0cd3d97/src/unix/aix/mod.rs (L1)
2024-10-30 22:22:06 +08:00
许杰友 Jieyou Xu (Joe)
18e44f89bf
Rollup merge of #132346 - nnethercote:some-graphviz-tweaks, r=cjgillot
Some graphviz tweaks

r? `@cjgillot`
2024-10-30 22:22:05 +08:00
许杰友 Jieyou Xu (Joe)
c22832fdbe
Rollup merge of #132315 - jieyouxu:extract-llvm-version, r=onur-ozkan
compiletest: improve robustness of LLVM version handling

Previously, `extract_llvm_versions` did some gymnastics for llvm versions by combining `(major, minor, patch)` into a combined version integer, but that is not very robust and made it difficult to add `max-llvm-major-version`. This PR tries to:

- Improve llvm version handling robustness by parsing and representing the version as a semver. We intentionally deviate from strict semver standards by allowing omission of minor and patch versions. They default to `0` when absent. This is for convenience to allow the user to write e.g. `//@ min-llvm-version: 18` instead of having to spell out the full `major.minor.patch` semver string `//@ min-llvm-verison: 18.0.0`.
- Adjust some panic messages to include a bit more context about *why* the version string was rejected.

Prerequisite for #132310.

r? bootstrap (or compiler)
2024-10-30 22:22:04 +08:00
许杰友 Jieyou Xu (Joe)
a864e30269
Rollup merge of #131096 - GuillaumeGomez:rm-no_unused, r=notriddle
rustdoc: Remove usage of `allow(unused)` attribute on `no_run` merged doctests

Fixes [#130681](https://github.com/rust-lang/rust/issues/130681).

It fixes the behaviour difference with the current doctests.

r? ``@notriddle``
2024-10-30 22:22:04 +08:00
许杰友 Jieyou Xu (Joe)
8d9686efc2
Rollup merge of #130098 - adetaylor:arbitrary-self-types-block-generics, r=wesleywiser
Reject generic self types.

The RFC for arbitrary self types v2 declares that we should reject "generic" self types. This commit does so.

The definition of "generic" was unclear in the RFC, but has been explored in
https://github.com/rust-lang/rust/issues/129147
and the conclusion is that "generic" means any `self` type which is a type parameter defined on the method itself, or references to such a type.

This approach was chosen because other definitions of "generic" don't work. Specifically,
* we can't filter out generic type _arguments_, because that would filter out Rc<Self> and all the other types of smart pointer we want to support;
* we can't filter out all type params, because Self itself is a type param, and because existing Rust code depends on other type params declared on the type (as opposed to the method).

This PR decides to make a new error code for this case, instead of reusing the existing E0307 error. This makes the code a bit more complex, but it seems we have an opportunity to provide specific diagnostics for this case so we should do so.

This PR filters out generic self types whether or not the 'arbitrary self types' feature is enabled. However, it's believed that it can't have any effect on code which uses stable Rust, since there are no stable traits which can be used to indicate a valid generic receiver type, and thus it would have been impossible to write code which could trigger this new error case. It is however possible that this could break existing code which uses either of the unstable `arbitrary_self_types` or `receiver_trait` features. This breakage is intentional; as we move arbitrary self types towards stabilization we don't want to continue to support generic such types.

This PR adds lots of extra tests to arbitrary-self-from-method-substs. Most of these are ways to trigger a "type mismatch" error which 9b82580c73/compiler/rustc_hir_typeck/src/method/confirm.rs (L519) hopes can be minimized by filtering out generics in this way. We remove a FIXME from confirm.rs suggesting that we make this change. It's still possible to cause type mismatch errors, and a subsequent PR may be able to improve diagnostics in this area, but it's harder to cause these errors without contrived uses of the turbofish.

This is a part of the arbitrary self types v2 project, https://github.com/rust-lang/rfcs/pull/3519
https://github.com/rust-lang/rust/issues/44874

r? `@wesleywiser`
2024-10-30 22:22:02 +08:00
Boxy
0900a1bd80 the unvacationer 2024-10-30 13:29:05 +00:00
Henry Jiang
a43a37c706 fix libc call from i8 to u8 2024-10-30 09:17:44 -04:00
Adrian Taylor
86af0f9b7e Switch to comparing indices instead of names. 2024-10-30 10:48:10 +00:00
Adrian Taylor
6d8d79595e Reject generic self types.
The RFC for arbitrary self types v2 declares that we should reject
"generic" self types. This commit does so.

The definition of "generic" was unclear in the RFC, but has been
explored in
https://github.com/rust-lang/rust/issues/129147
and the conclusion is that "generic" means any `self` type which
is a type parameter defined on the method itself, or references
to such a type.

This approach was chosen because other definitions of "generic"
don't work. Specifically,
* we can't filter out generic type _arguments_, because that would
  filter out Rc<Self> and all the other types of smart pointer
  we want to support;
* we can't filter out all type params, because Self itself is a
  type param, and because existing Rust code depends on other
  type params declared on the type (as opposed to the method).

This PR decides to make a new error code for this case, instead of
reusing the existing E0307 error. This makes the code a
bit more complex, but it seems we have an opportunity to provide
specific diagnostics for this case so we should do so.

This PR filters out generic self types whether or not the
'arbitrary self types' feature is enabled. However, it's believed
that it can't have any effect on code which uses stable Rust, since
there are no stable traits which can be used to indicate a valid
generic receiver type, and thus it would have been impossible to
write code which could trigger this new error case.
It is however possible that this could break existing code which
uses either of the unstable `arbitrary_self_types` or
`receiver_trait` features. This breakage is intentional; as
we move arbitrary self types towards stabilization we don't want
to continue to support generic such types.

This PR adds lots of extra tests to arbitrary-self-from-method-substs.
Most of these are ways to trigger a "type mismatch" error which
9b82580c73/compiler/rustc_hir_typeck/src/method/confirm.rs (L519)
hopes can be minimized by filtering out generics in this way.
We remove a FIXME from confirm.rs suggesting that we make this change.
It's still possible to cause type mismatch errors, and a subsequent
PR may be able to improve diagnostics in this area, but it's harder
to cause these errors without contrived uses of the turbofish.

This is a part of the arbitrary self types v2 project,
https://github.com/rust-lang/rfcs/pull/3519
https://github.com/rust-lang/rust/issues/44874

r? @wesleywiser
2024-10-30 10:48:08 +00:00