Commit Graph

36853 Commits

Author SHA1 Message Date
Vadim Petrochenkov
6fea953267 rustc_span: By-value interface for ctxt update 2024-06-13 19:29:24 +03:00
Vadim Petrochenkov
4440f50996 rustc_span: Add conveniences for working with span formats 2024-06-13 19:29:24 +03:00
bors
b6e5e3ffbb Auto merge of #125289 - WaffleLapkin:never-obligations, r=compiler-errors
Implement lint for obligations broken by never type fallback change

This is the second (and probably last major?) lint required for the never type fallback change.

The idea is to check if the code errors with `fallback = ()` and if it errors with `fallback = !` and if it went from "ok" to "error", lint.

I'm not happy with the diagnostic, ideally we'd highlight what bound is the problem. But I'm really unsure how to do that  (cc `@jackh726,` iirc you had some ideas?)

r? `@compiler-errors`

Thanks `@BoxyUwU` with helping with trait solver stuff when I was implementing the initial version of this lint.

Tracking:
- https://github.com/rust-lang/rust/issues/123748
2024-06-13 14:05:19 +00:00
Waffle Lapkin
ea98e42bfd rebase blessing 2024-06-13 14:43:16 +02:00
León Orell Valerian Liehr
393b526018
Rollup merge of #126379 - RalfJung:find_closest_untracked_caller_location, r=oli-obk
interpret: update doc comment for find_closest_untracked_caller_location

Also add a doc comment to cur_span.

r? `@compiler-errors`
2024-06-13 13:05:27 +02:00
León Orell Valerian Liehr
3e96d58557
Rollup merge of #126366 - celinval:issue-0080-def-ty, r=oli-obk
Add a new trait to retrieve StableMir definition Ty

We implement the trait only for definitions that should have a type. It's possible that I missed a few definitions, but we can add them later if needed.

Fixes https://github.com/rust-lang/project-stable-mir/issues/80
2024-06-13 13:05:25 +02:00
Waffle Lapkin
8400cd0b34 Fixup links in lint docs
looks like prim@ stuff does not work here (is it possibly not handled by rustdoc at all?)
2024-06-13 12:24:31 +02:00
Waffle Lapkin
0f41d26f41 Apply review nits 2024-06-13 12:24:31 +02:00
Waffle Lapkin
b88d03b059 Add a fast exit to lint_obligations_broken_by_never_type_fallback_change 2024-06-13 12:24:31 +02:00
Waffle Lapkin
83f8f9f85d Implement lint for obligations broken by never type fallback change 2024-06-13 12:24:31 +02:00
Ralf Jung
d87ec03ed9 interpret: update doc comment for find_closest_untracked_caller_location 2024-06-13 09:08:57 +02:00
Jubilee
3b109987e1
Rollup merge of #126362 - artemagvanian:patch-1, r=celinval
Make `try_from_target_usize` method public

There is now no way to create a TyConst from an integer, so I propose making this method public unless there was a reason for keeping it otherwise.
2024-06-12 20:03:23 -07:00
Jubilee
d33ec8ed8c
Rollup merge of #126358 - jswrenn:fix-125811, r=compiler-errors
safe transmute: support `Single` enums

Previously, the implementation of `Tree::from_enum` incorrectly treated enums with `Variants::Single` and `Variants::Multiple` identically. This is incorrect for `Variants::Single` enums, which delegate their layout to that of a variant with a particular index (or no variant at all if the enum is empty).

This flaw manifested first as an ICE. `Tree::from_enum` attempted to compute the tag of variants other than the one at `Variants::Single`'s `index`, and fell afoul of a sanity-checking assertion in `compiler/rustc_const_eval/src/interpret/discriminant.rs`. This assertion is non-load-bearing, and can be removed; the routine its in is well-behaved even without it.

With the assertion removed, the proximate issue becomes apparent: calling `Tree::from_variant` on a variant that does not exist is ill-defined. A sanity check the given variant has `FieldShapes::Arbitrary` fails, and the analysis is (correctly) aborted with `Err::NotYetSupported`.

This commit corrects this chain of failures by ensuring that `Tree::from_variant` is not called on variants that are, as far as layout is concerned, nonexistent. Specifically, the implementation of `Tree::from_enum` is now partitioned into three cases:

  1. enums that are uninhabited
  2. enums for which all but one variant is uninhabited
  3. enums with multiple inhabited variants

`Tree::from_variant` is now only invoked in the third case. In the first case, `Tree::uninhabited()` is produced. In the second case, the layout is delegated to `Variants::Single`'s index.

Fixes #125811
2024-06-12 20:03:22 -07:00
Jubilee
9d946a3f6f
Rollup merge of #126356 - epage:check-cfg, r=Urgau
docs(rustc): Improve discoverable of Cargo docs

In preparing Cargo's blog post for 1.80, I tried to find the documentation for the lint configuration and I couldn't.  The link is only visible from the lint itself, which isn't where I started, and the side bar, which was collapsed for me.

The first place I went was the docs for `unexpected_cfgs` because this is configuration for that lint.  If using lint configuration were a one off, I could see skipping it here.  However, when we discussed this with at least one T-compiler member, there was interest in using this for other lints in the future.  To that end, it seems like we should be exposing this with the lint itself.

The second place I checked was the `check-cfg` documentation.  This now has a call out for the sub-page.
2024-06-12 20:03:22 -07:00
Jubilee
f6cc226f09
Rollup merge of #126353 - compiler-errors:move-match, r=lcnr
Move `MatchAgainstFreshVars` to old solver

Small change I noticed when trying to uplift the relations to the new trait solver.
2024-06-12 20:03:21 -07:00
Jubilee
f5af7eea1a
Rollup merge of #126328 - RalfJung:is_none_or, r=workingjubilee
Add Option::is_none_or

ACP: https://github.com/rust-lang/libs-team/issues/212
2024-06-12 20:03:20 -07:00
Jubilee
573ad2b964
Rollup merge of #126303 - sancho20021:patch-1, r=compiler-errors
Urls to docs in rust_hir

<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.

This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using

    r​? <reviewer name>
-->
2024-06-12 20:03:20 -07:00
Jubilee
25c55c51cb
Rollup merge of #126142 - compiler-errors:trait-ref-split, r=jackh726
Harmonize using root or leaf obligation in trait error reporting

When #121826 changed the error reporting to use root obligation and not the leafmost obligation, it didn't actually make sure that all the other diagnostics helper functions used the right obligation.

Specifically, when reporting similar impl candidates we are looking for impls of the root obligation, but trying to match them against the trait ref of the leaf obligation.

This does a few other miscellaneous changes. There's a lot more clean-up that could be done here, but working with this code is really grief-inducing due to how messy it has become over the years. Someone really needs to show it love. 😓

r? ``@estebank``

Fixes #126129
2024-06-12 20:03:19 -07:00
Jubilee
8719cc2579
Rollup merge of #125688 - compiler-errors:alias-reporting, r=lcnr
Walk into alias-eq nested goals even if normalization fails

Somewhat broken due to the fact that we don't handle aliases well, nor do we handle ambiguities well. Still want to put up this incremental piece, since it improves type errors for projections whose trait refs are not satisfied.

r? lcnr
2024-06-12 20:03:19 -07:00
Jack Wrenn
fb662f2126 safe transmute: support Variants::Single enums
Previously, the implementation of `Tree::from_enum` incorrectly
treated enums with `Variants::Single` and `Variants::Multiple`
identically. This is incorrect for `Variants::Single` enums,
which delegate their layout to that of a variant with a particular
index (or no variant at all if the enum is empty).

This flaw manifested first as an ICE. `Tree::from_enum` attempted
to compute the tag of variants other than the one at
`Variants::Single`'s `index`, and fell afoul of a sanity-checking
assertion in `compiler/rustc_const_eval/src/interpret/discriminant.rs`.
This assertion is non-load-bearing, and can be removed; the routine
its in is well-behaved even without it.

With the assertion removed, the proximate issue becomes apparent:
calling `Tree::from_variant` on a variant that does not exist is
ill-defined. A sanity check the given variant has
`FieldShapes::Arbitrary` fails, and the analysis is (correctly)
aborted with `Err::NotYetSupported`.

This commit corrects this chain of failures by ensuring that
`Tree::from_variant` is not called on variants that are, as far as
layout is concerned, nonexistent. Specifically, the implementation
of `Tree::from_enum` is now partitioned into three cases:

  1. enums that are uninhabited
  2. enums for which all but one variant is uninhabited
  3. enums with multiple inhabited variants

`Tree::from_variant` is now only invoked in the third case. In the
first case, `Tree::uninhabited()` is produced. In the second case,
the layout is delegated to `Variants::Single`'s index.

Fixes #125811
2024-06-13 01:38:51 +00:00
Michael Goulet
ae24ebe710 Rebase fallout 2024-06-12 21:17:33 -04:00
Aleksandr Pak
d1fa19ce93 Add urls to rust lang reference 2024-06-13 11:02:08 +10:00
Michael Goulet
2c0348a0d8 Stop passing traitref/traitpredicate by ref 2024-06-12 20:57:24 -04:00
Michael Goulet
f8d12d9189 Stop passing both trait pred and trait ref 2024-06-12 20:57:23 -04:00
Michael Goulet
c453c82de4 Harmonize use of leaf and root obligation in trait error reporting 2024-06-12 20:57:23 -04:00
Celina G. Val
6d4a825714 Add a new trait to retrieve StableMir definition Ty
We implement the trait only for definitions that should have a type.
It's possible that I missed a few definitions, but we can add them later
if needed.
2024-06-12 17:47:49 -07:00
bors
8cf5101d77 Auto merge of #125069 - amandasystems:scc-refactor, r=nikomatsakis
Extend SCC construction to enable extra functionality

Do YOU feel like your SCC construction doesn't do enough? Then I have a patch for you! SCCs can now do *everything*! Well, almost.

This patch has been extracted from #123720. It specifically enhances
`Sccs` to allow tracking arbitrary commutative properties (think min/max mappings on nodes vs arbitrary closures) of strongly connected components, including
- reachable values (max/min)
- SCC-internal values (max/min)

This helps with among other things universe computation. We can now identify
SCC universes as a reasonably straightforward "find max/min" operation during SCC construction. This is also included in this patch.

It's also more or less zero-cost; don't use the new features, don't pay for them.

This commit also vastly extends the documentation of the SCCs module, which I had a very hard time following. It may or may not have gotten easier to read for someone else.

I believe this logic can also be used in leak check, but haven't checked. Ha. ha. Ha.
2024-06-12 23:15:33 +00:00
Artem Agvanian
46391b7dcd
Make try_from_target_usize method public
There is now no way to create a TyConst from an integer, so I propose making this method public unless there was a reason for keeping it otherwise.
2024-06-12 16:15:02 -07:00
Michael Goulet
44040a0670 Also passthrough for projection clauses 2024-06-12 19:10:02 -04:00
Michael Goulet
b0c1474381 better error message for normalizes-to ambiguities 2024-06-12 19:03:37 -04:00
Michael Goulet
52b2c88bdf Walk into alias-eq nested goals even if normalization fails 2024-06-12 19:03:37 -04:00
bors
8337ba9189 Auto merge of #126345 - compiler-errors:rollup-lue8u92, r=compiler-errors
Rollup of 8 pull requests

Successful merges:

 - #125869 (Add `target_env = "p1"` to the `wasm32-wasip1` target)
 - #126019 (Add TODO comment to unsafe env modification)
 - #126036 (Migrate `run-make/short-ice` to `rmake`)
 - #126276 (Detect pub structs never constructed even though they impl pub trait with assoc constants)
 - #126282 (Ensure self-contained linker is only enabled on dev/nightly )
 - #126317 (Avoid a bunch of booleans in favor of Result<(), ErrorGuaranteed> as that more robustly proves that an error has been emitted)
 - #126324 (Adjust LoongArch64 data layouts for LLVM update)
 - #126340 (Fix outdated predacates_of.rs comments)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-06-12 20:48:06 +00:00
Ed Page
9232bd2e83 docs(rustc): Link unexpected_cfgs to the Cargo.toml docs
This is the first time we have a lint with configuration exposed in
`Cargo.toml`.
When this was done, interest was expressed in using this for other cases
in the future.
To this end, we need to make the documentation for the lint
configuration discoverable from the documentation for that lint.
2024-06-12 15:27:27 -05:00
Michael Goulet
4b809b9438 Move MatchAgainstFreshVars to old solver 2024-06-12 16:24:05 -04:00
Michael Goulet
0d1d6ba58c
Rollup merge of #126340 - fee1-dead-contrib:fix-predicates_of-comments, r=compiler-errors
Fix outdated predacates_of.rs comments

<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.

This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using

    r​? <reviewer name>
-->
2024-06-12 14:26:29 -04:00
Michael Goulet
754b26d882
Rollup merge of #126324 - zmodem:loongarch, r=nikic
Adjust LoongArch64 data layouts for LLVM update

The data layout was changed in LLVM 19: llvm/llvm-project#93814
2024-06-12 14:26:28 -04:00
Michael Goulet
7276f34a85
Rollup merge of #126317 - oli-obk:recursive_rpit4, r=compiler-errors
Avoid a bunch of booleans in favor of Result<(), ErrorGuaranteed> as that more robustly proves that an error has been emitted

pulled out of https://github.com/rust-lang/rust/pull/126316

This PR cannot have any effect on compilation.
All it does is shift a `Ty::new_misc_error` to a `span_delayed_bug` and preserve the `ErrorGuaranteed` in all other cases
2024-06-12 14:26:27 -04:00
Michael Goulet
306501044e
Rollup merge of #126276 - mu001999-contrib:dead/enhance, r=fee1-dead
Detect pub structs never constructed even though they impl pub trait with assoc constants

Extend dead code analysis to impl items of pub assoc constants.

<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.

This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using

    r​? <reviewer name>
-->
2024-06-12 14:26:26 -04:00
Michael Goulet
88984fe748
Rollup merge of #126019 - tbu-:pr_unsafe_env_fixme, r=fee1-dead
Add TODO comment to unsafe env modification

Addresses https://github.com/rust-lang/rust/pull/124636#issuecomment-2132119534.

I think that the diff display regresses a little, because it's no longer showing the `+` to show where the `unsafe {}` is added. I think it's still fine.

Tracking:
- https://github.com/rust-lang/rust/issues/124866

r? `@RalfJung`
2024-06-12 14:26:24 -04:00
Michael Goulet
7133257d4f
Rollup merge of #125869 - alexcrichton:add-p1-to-wasi-targets, r=wesleywiser
Add `target_env = "p1"` to the `wasm32-wasip1` target

This commit sets the `target_env` key for the
`wasm32-wasi{,p1,p1-threads}` targets to the string `"p1"`. This mirrors how the `wasm32-wasip2` target has `target_env = "p2"`. The intention of this is to more easily detect each target in downstream crates to enable adding custom code per-target.

cc #125803

<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.

This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using

    r​? <reviewer name>
-->
2024-06-12 14:26:24 -04:00
bors
c25ac9d6cc Auto merge of #126273 - pietroalbini:pa-bootstrap-update, r=Mark-Simulacrum
Bump stage0 to 1.80.0

r? `@Mark-Simulacrum`
2024-06-12 18:15:32 +00:00
Deadbeef
54429cf279 Fix outdated predacates_of.rs comments 2024-06-12 16:19:25 +00:00
bors
1d43fbbc73 Auto merge of #126332 - GuillaumeGomez:rollup-bu1q4pz, r=GuillaumeGomez
Rollup of 9 pull requests

Successful merges:

 - #126039 (Promote `arm64ec-pc-windows-msvc` to tier 2)
 - #126075 (Remove `DebugWithInfcx` machinery)
 - #126228 (Provide correct parent for nested anon const)
 - #126232 (interpret: dyn trait metadata check: equate traits in a proper way)
 - #126242 (Simplify provider api to improve llvm ir)
 - #126294 (coverage: Replace the old span refiner with a single function)
 - #126295 (No uninitalized report in a pre-returned match arm)
 - #126312 (Update `rustc-perf` submodule)
 - #126322 (Follow up to splitting core's PanicInfo and std's PanicInfo)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-06-12 15:58:32 +00:00
Tobias Bucher
4f5fb3126f Add TODO comment to unsafe env modification
Addresses https://github.com/rust-lang/rust/pull/124636#issuecomment-2132119534.

I think that the diff display regresses a little, because it's no longer
showing the `+` to show where the `unsafe {}` is added. I think it's
still fine.
2024-06-12 17:51:18 +02:00
r0cky
af106617f1 Detect pub structs never constructed even though they impl pub trait with assoc constants 2024-06-12 23:31:27 +08:00
Oli Scherer
62990713ce Avoid a Ty::new_misc_error when an ErrorGuaranteed is available 2024-06-12 14:25:34 +00:00
Ralf Jung
4c208ac233 use is_none_or in some places in the compiler 2024-06-12 16:20:07 +02:00
Amanda Stjerna
d63708b907 Address code review comments on the comments 2024-06-12 15:48:34 +02:00
Amanda Stjerna
2e1e119ba1 Move RegionTracker to region_infer
In terms of code organisation, this is a lot cleaner and allows
tighter access modifiers.
2024-06-12 15:48:34 +02:00
Amanda Stjerna
3bdcb9d436 Revise documentation after @lqd's comments 2024-06-12 15:47:32 +02:00