Commit Graph

256724 Commits

Author SHA1 Message Date
bors 23e040adec Auto merge of #125426 - jieyouxu:rmake-support-env-reset, r=saethlin
Update `compiler-builtins` test to not clear essential env vars

Noticed in https://github.com/rust-lang/rust/pull/122580#issuecomment-2125755689, the `compiler-builtins` test failed on Windows for a `cargo` invocation because necessary env vars `TMP` and `TEMP` were cleared by `Command::env_clear`, causing temp dir eventually used by codegen to fallback to the Windows directory, which will trigger permission errors.

This PR removes the `env_clear` on the cargo invocation.

r? `@saethlin` (feel free to reroll, since you authored the test)

try-job: x86_64-msvc
try-job: test-various
2024-06-04 19:14:28 +00:00
Guillaume Gomez 7e993b24d5 Create `run-make` `env_var` and `env_var_os` helpers 2024-06-04 21:07:48 +02:00
Santiago Pastorino bac72cf7cf
Add safe/unsafe to static inside extern blocks 2024-06-04 14:19:43 -03:00
Santiago Pastorino b4cbdb7246
Fail when using safe/unsafe items inside unadorned extern blocks 2024-06-04 14:19:43 -03:00
Santiago Pastorino 2a377122dd
Handle safety keyword for extern block inner items 2024-06-04 14:19:42 -03:00
Santiago Pastorino bbddc9b58f
Allow using unsafe on functions inside extern blocks 2024-06-04 14:19:42 -03:00
Santiago Pastorino 3ba8de0b60
Make extern blocks without unsafe warn in edition 2024 2024-06-04 14:19:42 -03:00
Santiago Pastorino 46cd80b691
Test that unsafe extern defines unsafe fns 2024-06-04 14:19:42 -03:00
Santiago Pastorino 6d670b74e5
Allow unsafe extern on all editions 2024-06-04 14:19:42 -03:00
Santiago Pastorino 68b0b86c5b
Add unsafe extern blocks failing tests 2024-06-04 14:19:41 -03:00
bors 44701e070c Auto merge of #123536 - compiler-errors:simplify-int-float, r=lcnr
Simplify `IntVarValue`/`FloatVarValue`

r? `@ghost`
2024-06-04 17:07:13 +00:00
León Orell Valerian Liehr 874670399c
Orphanck: Consider opaque types to never cover type parameters 2024-06-04 18:57:19 +02:00
Andrei Damian 2bad3d1392 Make deleting on LinkedList aware of the allocator 2024-06-04 18:49:13 +03:00
Oli Scherer ffb1b2c148 Add test description 2024-06-04 15:34:04 +00:00
Oli Scherer 81895065bb Give test a more useful name 2024-06-04 15:33:51 +00:00
Oli Scherer 7894a11483 Move tests to a more appropriate directory 2024-06-04 15:33:20 +00:00
Oli Scherer 7d151fa3b0 Turn a delayed bug back into a normal bug by winnowing private method candidates instead of assuming any candidate of the right name will apply. 2024-06-04 15:32:41 +00:00
Oli Scherer 14f9c63759 Show that it will pick up the entirely wrong function as a private candidate 2024-06-04 15:32:37 +00:00
Oli Scherer 5e8df95dbb Manual rustfmt 2024-06-04 15:28:39 +00:00
Zalathar c7491a9885 Remove `tests/run-make-fulldeps/pretty-expanded`
This was an ancient regression test for #12685, caused by `-Zunpretty=expanded`
crashing on certain code produced by `#[derive(RustcEncodable)]`.
2024-06-05 00:51:09 +10:00
bors 30ea1a2693 Auto merge of #125976 - compiler-errors:rollup-xt3le7w, r=compiler-errors
Rollup of 8 pull requests

Successful merges:

 - #125667 (Silence follow-up errors directly based on error types and regions)
 - #125717 (Refactor `#[diagnostic::do_not_recommend]` support)
 - #125795 (Improve renaming suggestion for names with leading underscores)
 - #125865 (Fix ICE caused by ignoring EffectVars in type inference)
 - #125953 (Streamline `nested` calls.)
 - #125959 (Reduce `pub` exposure in `rustc_mir_build`)
 - #125967 (Split smir `Const` into `TyConst` and `MirConst`)
 - #125968 (Store the types of `ty::Expr` arguments in the `ty::Expr`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-06-04 14:49:54 +00:00
Sergi-Ferrez 744dc8c503 Use checked_sub 2024-06-04 16:05:51 +02:00
Michael Goulet a5dc684eee
Rollup merge of #125968 - BoxyUwU:shrink_ty_expr, r=oli-obk
Store the types of `ty::Expr` arguments in the `ty::Expr`

Part of #125958

In attempting to remove the `ty` field on `Const` it will become necessary to store the `Ty<'tcx>` inside of `Expr<'tcx>`. In order to do this without blowing up the size of `ConstKind`, we start storing the type/const args as `GenericArgs`

r? `@oli-obk`
2024-06-04 08:52:15 -04:00
Michael Goulet 288727ef42
Rollup merge of #125967 - BoxyUwU:split_smir_const, r=oli-obk
Split smir `Const` into `TyConst` and `MirConst`

Part of #125958

Building a `smir::Const` currently requires accessing the `Ty<'tcx>` of a `ty::Const`. This will stop being possible in the future. Replicate the split in rustc of having a representation of type level constants and mir constants with the latter being able to store the former. Ideally we wouldnt have `MirConst::Ty` but 🤷‍♀️

r? `@oli-obk`
2024-06-04 08:52:15 -04:00
Michael Goulet 8272c6d8cc
Rollup merge of #125959 - nnethercote:rustc_mir_build-cleanups, r=compiler-errors
Reduce `pub` exposure in `rustc_mir_build`

r? compiler
2024-06-04 08:52:14 -04:00
Michael Goulet 23f39a21db
Rollup merge of #125953 - nnethercote:streamline-nested-calls, r=lqd
Streamline `nested` calls.

`TyCtxt` impls `PpAnn` in `compiler/rustc_middle/src/hir/map/mod.rs`. We can call that impl, which then calls the one on `intravisit::Map`, instead of calling the one on `intravisit::Map` directly, avoiding a cast and extra references.

r? `@lqd`
2024-06-04 08:52:14 -04:00
Michael Goulet 7699da4858
Rollup merge of #125865 - ajwock:ice_not_fully_resolved, r=fee1-dead
Fix ICE caused by ignoring EffectVars in type inference

Fixes #119830
​r? ```@matthiaskrgr```
2024-06-04 08:52:13 -04:00
Michael Goulet 7e5528fa55
Rollup merge of #125795 - lucasscharenbroch:undescore-prefix-suggestion, r=compiler-errors
Improve renaming suggestion for names with leading underscores

Fixes #125650

Before:
```
error[E0425]: cannot find value `p` in this scope
 --> test.rs:2:13
  |
2 |     let _ = p;
  |             ^
  |
help: a local variable with a similar name exists, consider renaming `_p` into `p`
  |
1 | fn a(p: i32) {
  |      ~
```

After:
```
error[E0425]: cannot find value `p` in this scope
 --> test.rs:2:13
  |
1 | fn a(_p: i32) {
  |      -- `_p` defined here
2 |     let _ = p;
  |             ^
  |
help: the leading underscore in `_p` marks it as unused, consider renaming it to `p`
  |
1 | fn a(p: i32) {
  |      ~
```

This change doesn't exactly conform to what was proposed in the issue:

1. I've kept the suggested code instead of solely replacing it with the label
2. I've removed the "...similar name exists..." message instead of relocating to the usage span
3. You could argue that it still isn't completely clear that the change is referring to the definition (not the usage), but I'm not sure how to do this without playing down the fact that the error was caused by the usage of an undefined name.
2024-06-04 08:52:13 -04:00
Michael Goulet 46a033958a
Rollup merge of #125717 - weiznich:move/do_not_recommend_to_diganostic_namespace, r=compiler-errors
Refactor `#[diagnostic::do_not_recommend]` support

This commit refactors the `#[do_not_recommend]` support in the old parser to also apply to projection errors and not only to selection errors. This allows the attribute to be used more widely.

Part of #51992

r? `@compiler-errors`

<!--
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-04 08:52:12 -04:00
Michael Goulet 5019bb608a
Rollup merge of #125667 - oli-obk:taintify, r=TaKO8Ki
Silence follow-up errors directly based on error types and regions

During type_of, we used to just return an error type if there were any errors encountered. This is problematic, because it means a struct declared as `struct Foo<'static>` will end up not finding any inherent or trait impls because those impl blocks' `Self` type will be `{type error}` instead of `Foo<'re_error>`. Now it's the latter, silencing nonsensical follow-up errors about `Foo` not having any methods.

Unfortunately that now allows for new follow-up errors, because borrowck treats `'re_error` as `'static`, causing nonsensical errors about non-error lifetimes not outliving `'static`. So what I also did was to just strip all outlives bounds that borrowck found, thus never letting it check them. There are probably more nuanced ways to do this, but I worried there would be other nonsensical errors if some outlives bounds were missing. Also from the test changes, it looked like an improvement everywhere.
2024-06-04 08:52:12 -04:00
bors bc33782c23 Auto merge of #125948 - nnethercote:rustfmt-more-tests, r=lqd
rustfmt more tests

This finishes the formatting of tests begun in #125759 and continued in #125912.

r? `@lqd`
2024-06-04 11:51:35 +00:00
Sergi-Ferrez 617e64c9e7 Update code format and tests 2024-06-04 13:49:39 +02:00
Oli Scherer 67a73f265f bless privacy tests (only diagnostic duplication) 2024-06-04 11:27:54 +00:00
bors 85f90a4612 Auto merge of #125960 - jieyouxu:rollup-1s7f6lr, r=jieyouxu
Rollup of 8 pull requests

Successful merges:

 - #124486 (Add tracking issue and unstable book page for `"vectorcall"` ABI)
 - #125504 (Change pedantically incorrect OnceCell/OnceLock wording)
 - #125608 (Avoid follow-up errors if the number of generic parameters already doesn't match)
 - #125690 (ARM Target Docs Update)
 - #125750 (Align `Term` methods with `GenericArg` methods, add `Term::expect_*`)
 - #125818 (Handle no values cfgs with `--print=check-cfg`)
 - #125909 (rustdoc: add a regression test for a former blanket impl synthesis ICE)
 - #125919 (Remove stray "this")

r? `@ghost`
`@rustbot` modify labels: rollup
2024-06-04 09:38:16 +00:00
Boxy 7e08f80b34 Split smir `Const` into `TyConst` and `MirConst` 2024-06-04 10:14:45 +01:00
Boxy f076dec336 Downsize `ty::Expr` 2024-06-04 10:13:38 +01:00
Ross MacArthur 6a84995fae
Add function `core::iter::chain`
The addition of `core::iter::zip` (#82917) set a precedent for adding
plain functions for iterator adaptors. Adding `chain` makes it a little
easier to `chain` two iterators.

```
for (x, y) in chain(xs, ys) {}
// vs.
for (x, y) in xs.into_iter().chain(ys) {}
```
2024-06-04 10:51:05 +02:00
许杰友 Jieyou Xu (Joe) 2949195d9a compiler-builtins: don't clear env vars for cargo invocation 2024-06-04 08:04:22 +00:00
许杰友 Jieyou Xu (Joe) a04a6038bb
Rollup merge of #125919 - tbu-:pr_fix_typo, r=lqd
Remove stray "this"
2024-06-04 08:25:49 +01:00
许杰友 Jieyou Xu (Joe) 6abb7fba12
Rollup merge of #125909 - fmease:rustdoc-add-test-synth-blanket-impls, r=GuillaumeGomez
rustdoc: add a regression test for a former blanket impl synthesis ICE

Fixes #119792 (also passes in #125907 in case you were wondering).

r? rustdoc
2024-06-04 08:25:49 +01:00
许杰友 Jieyou Xu (Joe) 756af9d5bc
Rollup merge of #125818 - Urgau:print-check-cfg-no-values, r=petrochenkov
Handle no values cfgs with `--print=check-cfg`

This PR fix a bug with `--print=check-cfg`, where no values cfgs where not printed since we only printed cfgs that had at least one values.

The representation I choose is `CFG=`, since it doesn't correspond to any valid config, it also IMO nicely complements the `values()` (to indicate no values). Representing the absence of value by the absence of the value.

So for `cfg(feature, values())` we would print `feature=`.

I also added the missing tracking issue number in the doc.

r? ```@petrochenkov```
2024-06-04 08:25:48 +01:00
许杰友 Jieyou Xu (Joe) b477f89041
Rollup merge of #125750 - compiler-errors:expect, r=lcnr
Align `Term` methods with `GenericArg` methods, add `Term::expect_*`

* `Term::ty` -> `Term::as_type`.
* `Term::ct` -> `Term::as_const`.
* Adds `Term::expect_type` and `Term::expect_const`, and uses them in favor of `.ty().unwrap()`, etc.

I could also shorten these to `as_ty` and then do `GenericArg::as_ty` as well, but I do think the `as_` is important to signal that this is a conversion method, and not a getter, like `Const::ty` is.

r? types
2024-06-04 08:25:48 +01:00
许杰友 Jieyou Xu (Joe) 6c2cf0b038
Rollup merge of #125690 - Lokathor:arm-maintainer-reorg, r=ehuss
ARM Target Docs Update

Updates the ARM target docs, drawing more attention to the `arm-none-eabi` target group by placing all targets *within* that group as a sub-list in the Table of Contents.

Also updates the `armv4t-none-eabi` page (maintainer signoff: I'm that target's maintainer) to clarify that the page covers the arm version and the thumb version of the target, but that the target group page has the full info because there's nothing really specific to say for those targets.
2024-06-04 08:25:47 +01:00
许杰友 Jieyou Xu (Joe) 0dc65501cb
Rollup merge of #125608 - oli-obk:subsequent_lifetime_errors, r=BoxyUwU
Avoid follow-up errors if the number of generic parameters already doesn't match

fixes #125604

best reviewed commit-by-commit
2024-06-04 08:25:47 +01:00
许杰友 Jieyou Xu (Joe) d5a04221ef
Rollup merge of #125504 - mqudsi:once_nominal, r=cuviper
Change pedantically incorrect OnceCell/OnceLock wording

While the semantic intent of a OnceCell/OnceLock is that it can only be written to once (upon init), the fact of the matter is that both these types offer a `take(&mut self) -> Option<T>` mechanism that, when successful, resets the cell to its initial state, thereby [technically allowing it to be written to again](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=415c023a6ae1ef35f371a2d3bb1aa735)

Despite the fact that this can only happen with a mutable reference (generally only used during the construction of the OnceCell/OnceLock), it would be incorrect to say that the type itself as a whole *categorically* prevents being initialized or written to more than once (since it is possible to imagine an identical type only without the `take()` method that actually fulfills that contract).

To clarify, change "that cannot be.." to "that nominally cannot.." and add a note to OnceCell about what can be done with an `&mut Self` reference.

```@rustbot``` label +A-rustdocs
2024-06-04 08:25:46 +01:00
许杰友 Jieyou Xu (Joe) aa13b892c7
Rollup merge of #124486 - beetrees:vectorcall-tracking-issue, r=ehuss
Add tracking issue and unstable book page for `"vectorcall"` ABI

Originally added in 2015 by #30567, the Windows `"vectorcall"` ABI didn't have a tracking issue until now.

Tracking issue: #124485
2024-06-04 08:25:46 +01:00
onur-ozkan 8f677e8fb2 bootstrap: implement new feature `bootstrap-self-test`
Some of the bootstrap logics should be ignored during unit tests because they either
make the tests take longer or cause them to fail. Therefore we need to be able to exclude
them from the bootstrap when it's called by unit tests. This change introduces a new feature
called `bootstrap-self-test`, which is enabled on bootstrap unit tests by default. This allows
us to keep the logic separate between compiler builds and bootstrap tests without needing messy
workarounds (like checking if target names match those in the unit tests).

Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-06-04 09:59:05 +03:00
Nicholas Nethercote 5a5e2489c5 Reduce `pub` exposure.
A lot of errors don't need to be visible outside the crate, and some
other things as well.
2024-06-04 16:55:55 +10:00
Raoul Strackx 8db363c44b Let compiler auto impl `Send` for `Task` 2024-06-04 08:46:45 +02:00
Raoul Strackx b8c6008fbc Store `Task::p` as `dyn FnOnce() + Send` 2024-06-04 08:46:38 +02:00