Commit Graph

257306 Commits

Author SHA1 Message Date
David Tolnay
57106e4a46
Rename proc_macro::Literal tests from parse.rs to literal.rs
This module contains tests not just of parse (FromStr) but also
to_string (Display) for literals.
2024-06-13 09:39:27 -07: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
bors
9fdbfe1441 Auto merge of #126396 - fmease:rollup-3j7f6wk, r=fmease
Rollup of 6 pull requests

Successful merges:

 - #126347 (Simplify `try_*`'s signature on `Iterator`)
 - #126348 (Improve error message if dependency installation in tidy fails)
 - #126366 (Add a new trait to retrieve StableMir definition Ty)
 - #126370 (compiletest: Stricter parsing of `//@ normalize-*` headers)
 - #126379 (interpret: update doc comment for find_closest_untracked_caller_location)
 - #126384 (add tracking issue for is_none_or)

Failed merges:

 - #126388 (const-eval: make lint scope computation consistent)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-06-13 11:55:16 +00:00
León Orell Valerian Liehr
f1a4f30940
Rollup merge of #126384 - RalfJung:is_none_or, r=workingjubilee
add tracking issue for is_none_or

This was forgotten in https://github.com/rust-lang/rust/pull/126328.

Cc https://github.com/rust-lang/rust/issues/126383
2024-06-13 13:05:27 +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
2b5c672a0b
Rollup merge of #126370 - Zalathar:normalize, r=oli-obk
compiletest: Stricter parsing of `//@ normalize-*` headers

I noticed some problems with the existing parser for these headers:

- It is extremely lax, and basically ignores everything other than the text between two pairs of double-quote characters.
  - Unlike other name-value headers, it doesn't even check for a colon after the header name, so the test suite contains a mixture of with-colon and without-colon normalization rules.
- If parsing fails, the header is silently ignored.

The latter is especially bad for platform-specific normalization rules, because the lack of normalization probably won't be noticed until the test mysteriously fails in one of the full CI jobs.
2024-06-13 13:05:26 +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
León Orell Valerian Liehr
83e2975797
Rollup merge of #126348 - Kobzol:venv-debug-error, r=albertlarsan68
Improve error message if dependency installation in tidy fails

Should help with easier debugging of issues occuring during [venv installation](https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/PR.20CI.20broken) of `tidy` dependencies.
2024-06-13 13:05:25 +02:00
León Orell Valerian Liehr
1fc56c94f1
Rollup merge of #126347 - slanterns:try_simplify, r=scottmcm
Simplify `try_*`'s signature on `Iterator`

Inspired by https://github.com/rust-lang/rust/pull/126249#issuecomment-2161859295.

r? `@scottmcm`

(Seems there's no need to explicitly use `<Self as Iterator>::Item`? I only find this occurrence across the whole file.)
2024-06-13 13:05:24 +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
a22f8aa17a Fixup clippy tests
Don't depend on the fact that `!` falls back to `()` and so panic-ish things
can be used in `-> impl ImplementedForUnit` functions
2024-06-13 12:24:31 +02:00
Waffle Lapkin
268b556393 Bless a test 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
898b541cb6 add tracking issue for is_none_or 2024-06-13 10:09:59 +02:00
bors
921645c737 Auto merge of #126197 - jieyouxu:rmake-must-use, r=Kobzol
run-make: annotate library with `#[must_use]` and enforce `unused_must_use` in rmake.rs

This PR adds `#[must_use]` annotations to functions of the `run_make_support` library where it makes sense, and adjusts compiletest to compile rmake.rs with `-Dunused_must_use`.

The rationale is that it's highly likely that unused `#[must_use]` values in rmake.rs test files are bugs. For example, unused fs/io results are often load-bearing to the correctness of the test and often unchecked fs/io results allow the test to silently pass where it would've failed if the result was checked.

This PR is best reviewed commit-by-commit.

try-job: test-various
try-job: x86_64-msvc
2024-06-13 07:26:21 +00:00
Ralf Jung
d87ec03ed9 interpret: update doc comment for find_closest_untracked_caller_location 2024-06-13 09:08:57 +02:00
bors
56e112afb6 Auto merge of #126374 - workingjubilee:rollup-tz0utfr, r=workingjubilee
Rollup of 10 pull requests

Successful merges:

 - #125674 (Rewrite `symlinked-extern`, `symlinked-rlib` and `symlinked-libraries` `run-make` tests in `rmake.rs` format)
 - #125688 (Walk into alias-eq nested goals even if normalization fails)
 - #126142 (Harmonize using root or leaf obligation in trait error reporting)
 - #126303 (Urls to docs in rust_hir)
 - #126328 (Add Option::is_none_or)
 - #126337 (Add test for walking order dependent opaque type behaviour)
 - #126353 (Move `MatchAgainstFreshVars` to old solver)
 - #126356 (docs(rustc): Improve discoverable of Cargo docs)
 - #126358 (safe transmute: support `Single` enums)
 - #126362 (Make `try_from_target_usize` method public)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-06-13 05:00:13 +00: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
100588ff31
Rollup merge of #126337 - oli-obk:nested_gat_opaque, r=lcnr
Add test for walking order dependent opaque type behaviour

r? ```@lcnr```

adding the test for your comment here: https://github.com/rust-lang/rust/pull/122366/files#r1521124754
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
Jubilee
1a6b1a14f9
Rollup merge of #125674 - Oneirical:another-day-another-test, r=jieyouxu
Rewrite `symlinked-extern`, `symlinked-rlib` and `symlinked-libraries` `run-make` tests in `rmake.rs` format

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

try-job: x86_64-msvc
2024-06-12 20:03:18 -07:00
bors
f6b4b71ef1 Auto merge of #125165 - Oneirical:pgo-branch-weights, r=jieyouxu
Migrate `run-make/pgo-branch-weights` to `rmake`

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

This is a scary one and I expect things to break. Set as draft, because this isn't ready.

- [x] There is this comment here, which suggests the test is excluded from the testing process due to a platform specific issue? I can't see anything here that would cause this test to not run...
> // FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works
// properly. Since we only have GCC on the CI ignore the test for now."

EDIT: This is specific to Windows-gnu.

- [x] The Makefile has this line:
```
ifneq (,$(findstring x86,$(TARGET)))
COMMON_FLAGS=-Clink-args=-fuse-ld=gold
```
I honestly can't tell whether this is checking if the target IS x86, or IS NOT. EDIT: It's checking if it IS x86.

- [x] I don't know why the Makefile was trying to pass an argument directly in the Makefile instead of setting that "aaaaaaaaaaaa2bbbbbbbbbbbb2bbbbbbbbbbbbbbbbcc" input as a variable in the Rust program directly. I changed that, let me know if that was wrong.

- [x] Trying to rewrite `cat "$(TMPDIR)/interesting.ll" | "$(LLVM_FILECHECK)" filecheck-patterns.txt` resulted in some butchery. For starters, in `tools.mk`, LLVM_FILECHECK corrects its own backslashes on Windows distributions, but there is no further mention of it, so I assume this is a preset environment variable... but is it really? Then, the command itself uses a Standard Input and a passed input file as an argument simultaneously, according to the [documentation](https://llvm.org/docs/CommandGuide/FileCheck.html#synopsis).

try-job: aarch64-gnu
2024-06-13 02:46:23 +00:00
Zalathar
e09eedbe93 compiletest: Stricter parsing of //@ normalize-* headers 2024-06-13 11:55:18 +10: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
Zalathar
c9d880bf01 compiletest: Move static_regex! into compiletest::util 2024-06-13 11:21:27 +10: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
93d83c8f69 Bless and add ICE regression test 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
Ed Page
e171e648ea docs(rustc): De-emphasize --cfg/--check-cfg note
At the suggestion of @Urgau
2024-06-12 15:57:13 -05: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