Commit Graph

250649 Commits

Author SHA1 Message Date
bors
536606bc5d Auto merge of #122939 - joboet:proc_macro_bridge_state, r=petrochenkov
Simplify proc macro bridge state

Currently, `proc_macro` uses a `ScopedCell` to store the client-side proc-macro bridge. Unfortunately, this requires the `Bridge`, which has non-negligible size, to be copied out and back again on every access. In some cases, the optimizer might be able to elide these copies, but in general, this is suboptimal.

This PR removes `ScopedCell` and employs a similar trick as in [`scoped_tls`](https://crates.io/crates/scoped-tls), meaning that the only thing stored in TLS is a pointer to the state, which now is a `RefCell`. Access to the pointer is then scoped so that it is always within the lifetime of the reference to the state. Unfortunately, `scoped_tls` requires the referenced type to be `'static`, which `Bridge` is not, therefore we cannot simply copy that macro but have to reimplement its TLS trick.

This removes the `#[forbid(unsafe_code)]` on the `client` module so that we do not have to export `Bridge`, which currently is private, to the whole crate. I can change that, if necessary.
2024-03-26 13:05:59 +00:00
bors
519d892f95 Auto merge of #121387 - oli-obk:eager_const_failures_regression, r=lcnr
Avoid some unnecessary query invocations.

Specifically this inlines `const_eval_poly` and avoids computing the generic params, the param env, normalizing the param env and erasing lifetimes on everything.

should fix the perf regression from https://github.com/rust-lang/rust/pull/121087
2024-03-26 10:52:11 +00:00
bors
b13a71a2e7 Auto merge of #123081 - Muscraft:update-cargo, r=Muscraft,workingjubilee
Update cargo

5 commits in a510712d05c6c98f987af24dd73cdfafee8922e6..499a61ce7a0fc6a72040084862a68b2603e770e8
2024-03-25 03:45:54 +0000 to 2024-03-26 04:17:04 +0000
- fix: do not borrow shell across registry query (rust-lang/cargo#13647)
- Do not strip debuginfo by default for MSVC (rust-lang/cargo#13630)
- chore(deps): update msrv (rust-lang/cargo#13577)
- Fix doc collision for lib/bin with a dash in the inferred name. (rust-lang/cargo#13640)
- refactor: Make lint names snake_case (rust-lang/cargo#13635)

r? ghost
2024-03-26 08:49:46 +00:00
bors
73476d4990 Auto merge of #122849 - clubby789:no-metadata, r=petrochenkov
Don't emit load metadata in debug mode

r? `@ghost`
2024-03-26 06:46:43 +00:00
Scott Schafer
3d58ef9e3c
Update cargo 2024-03-26 00:06:06 -06:00
bors
8b9e47c136 Auto merge of #123065 - workingjubilee:rollup-bve45ex, r=workingjubilee
Rollup of 10 pull requests

Successful merges:

 - #122707 (Fix a typo in the alloc::string::String docs)
 - #122769 (extend comments for reachability set computation)
 - #122892 (fix(bootstrap/dist): use versioned dirs when vendoring)
 - #122896 (Update stdarch submodule)
 - #122923 (In `pretty_print_type()`, print `async fn` futures' paths instead of spans.)
 - #122950 (Add regression tests for #101903)
 - #123039 (Update books)
 - #123042 (Import the 2021 prelude in the core crate)
 - #123044 (`Instance` is `Copy`)
 - #123051 (did I mention that tests are super cool? )

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-26 02:07:49 +00:00
bors
c98ea0d808 Auto merge of #111769 - saethlin:ctfe-backtrace-ctrlc, r=RalfJung
Print a backtrace in const eval if interrupted

Demo:
```rust
#![feature(const_eval_limit)]
#![const_eval_limit = "0"]

const OW: u64 = {
    let mut res: u64 = 0;
    let mut i = 0;
    while i < u64::MAX {
        res = res.wrapping_add(i);
        i += 1;
    }
    res
};

fn main() {
    println!("{}", OW);
}
```
```
╭ ➜ ben@archlinux:~/rust
╰ ➤ rustc +stage1 spin.rs
^Cerror[E0080]: evaluation of constant value failed
 --> spin.rs:8:33
  |
8 |         res = res.wrapping_add(i);
  |                                 ^ Compilation was interrupted

note: erroneous constant used
  --> spin.rs:15:20
   |
15 |     println!("{}", OW);
   |                    ^^

note: erroneous constant used
  --> spin.rs:15:20
   |
15 |     println!("{}", OW);
   |                    ^^
   |
   = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

For more information about this error, try `rustc --explain E0080`.
```
2024-03-26 00:04:03 +00:00
Jubilee
56e8f67c87
Rollup merge of #123051 - matthiaskrgr:casetest, r=workingjubilee
did I mention that tests are super cool?

Fixes https://github.com/rust-lang/rust/issues/81974
Fixes https://github.com/rust-lang/rust/issues/84727
Fixes https://github.com/rust-lang/rust/issues/92979
2024-03-25 14:35:38 -07:00
Jubilee
77de550c61
Rollup merge of #123044 - compiler-errors:instance, r=oli-obk
`Instance` is `Copy`

No reason to take it by value; it was confusing ``@rcvalle`` to see it being mutated when it's also being passed by ref in some places.
2024-03-25 14:35:37 -07:00
Jubilee
ac0a9c58e8
Rollup merge of #123042 - dpaoliello:prelude, r=Nilstrieb
Import the 2021 prelude in the core crate

The `core` crate currently imports the v1 prelude
b3df0d7e5e/library/core/src/lib.rs (L285-L287)

This recently caused an issue when updating the `portable-simd` subtree since it was using a trait that was added to the 2021 prelude: https://github.com/rust-lang/rust/pull/122905#discussion_r1536228822

To make it easier to have a consistent build environment for subtrees and submodules that get included in `core`, we will now import the 2021 prelude into `core`.

Fixes #122912

r? `@Nilstrieb`
2024-03-25 14:35:37 -07:00
Jubilee
2b13f944fb
Rollup merge of #123039 - rustbot:docs-update, r=ehuss
Update books

## rust-lang/edition-guide

1 commits in e1eead1181a691e56299294d5f1d62fe7a26d317..98b33e9a441457b0a491fe1be90e7de64eafc3e5
2024-03-23 14:17:26 UTC to 2024-03-23 14:17:26 UTC

- remove indication that C string literals don't exist yet (rust-lang/edition-guide#295)

## rust-lang/reference

4 commits in 5afb503a4c1ea3c84370f8f4c08a1cddd1cdf6ad..984b36eca4b9293df04d5ba4eb5c4f77db0f51dc
2024-03-25 14:05:19 UTC to 2024-03-19 20:01:14 UTC

- Fix typo of shebang (rust-lang/reference#1486)
- Document importing `main` (rust-lang/reference#1461)
- add grammar for `associated_type_bounds` in reference (rust-lang/reference#1481)
- Literal expressions: fix mistake in the definition of unicode escapes (rust-lang/reference#1483)

## rust-lang/rust-by-example

1 commits in e093099709456e6fd74fecd2505fdf49a2471c10..7601e0c5ad29d5bd3b518700ea63fddfff5915a7
2024-03-17 21:37:25 UTC to 2024-03-17 21:37:25 UTC

- Update enum_use.md to use a more neutral theme (rust-lang/rust-by-example#1828)

## rust-lang/rustc-dev-guide

12 commits in 8a5d647f19b08998612146b1cb2ca47083db63e0..ffa246b7fd95a96e1cd54883e613aed42c32547d
2024-03-23 07:44:42 UTC to 2024-03-11 18:17:28 UTC

- [MCP 723] Rename AstConv to HIR ty lowering (rust-lang/rustc-dev-guide#1916)
- add chapter to summary (rust-lang/rustc-dev-guide#1947)
- document difference between solvers + new solver normalization (rust-lang/rustc-dev-guide#1945)
- Fix broken link in chapter '1. How to build and run the compiler' (rust-lang/rustc-dev-guide#1946)
- typo (rust-lang/rustc-dev-guide#1944)
- Reflect rustc_codegen_cranelift move (rust-lang/rustc-dev-guide#1941)
- Update rustdoc-internals.md (rust-lang/rustc-dev-guide#1911)
- Update test-implementation.md (rust-lang/rustc-dev-guide#1937)
- Extract Bootstrap into its own section (rust-lang/rustc-dev-guide#1939)
- typos (rust-lang/rustc-dev-guide#1938)
- More updates for recent diagnostics changes. (rust-lang/rustc-dev-guide#1936)
- Update bibliography.md (rust-lang/rustc-dev-guide#1912)
2024-03-25 14:35:36 -07:00
Jubilee
4856f9a42f
Rollup merge of #122950 - ShoyuVanilla:issue-101903, r=compiler-errors
Add regression tests for #101903

Closes #101903

See https://doc.rust-lang.org/1.77.0/nightly-rustc/rustc_lint/opaque_hidden_inferred_bound/static.OPAQUE_HIDDEN_INFERRED_BOUND.html#example
2024-03-25 14:35:36 -07:00
Jubilee
9775296796
Rollup merge of #122923 - kpreid:print-async-def, r=compiler-errors
In `pretty_print_type()`, print `async fn` futures' paths instead of spans.

This makes `-Zprint-type-sizes`'s output easier to read, because the name of an `async fn` is more immediately recognizable than its span. This change will also synergize with my other `-Zprint-type-sizes` PR #122922 which prints the type of child futures being awaited.

I also deleted the comment "FIXME(eddyb) should use `def_span`." because it appears to have already been fixed by commit 67727aa7c3.
2024-03-25 14:35:35 -07:00
Jubilee
cf9acea658
Rollup merge of #122896 - dpaoliello:stdarch, r=Amanieu
Update stdarch submodule

r? ```@Amanieu```
2024-03-25 14:35:35 -07:00
Jubilee
01263c45d0
Rollup merge of #122892 - lovesegfault:versioned-vendor, r=onur-ozkan
fix(bootstrap/dist): use versioned dirs when vendoring

Currently, if you attempt to run ui tests in a vendored build, you will
see this failure

```
---- [ui] tests/ui/issues/issue-21763.rs stdout ----
diff of stderr:

8          = note: required because it appears within the type `(Rc<()>, Rc<()>)`
9          = note: required for `hashbrown::raw::RawTable<(Rc<()>, Rc<()>)>` to implement `Send`
10      note: required because it appears within the type `hashbrown::map::HashMap<Rc<()>, Rc<()>, RandomState>`
-         --> $HASHBROWN_SRC_LOCATION
+         --> /rust/deps/hashbrown/src/map.rs:190:12
12      note: required because it appears within the type `HashMap<Rc<()>, Rc<()>>`
13        --> $SRC_DIR/std/src/collections/hash/map.rs:LL:COL
14      note: required by a bound in `foo`
```

This happens because the code that attempts to remap
`HASHBROWN_SRC_LOCATION` expects it to be under `hashbrown-$version`,
which is the case in a normal cargo registry, but not when vendoring, where
by default crates may not have the version in their directory name.

This change passes `--versioned-dirs` to `cargo vendor` to enforce that
every crate includes the version in the subdir name, which fixes the ui
test and brings `--enable-vendor` builds closer to normal ones.
2024-03-25 14:35:35 -07:00
Jubilee
2f8c9bd651
Rollup merge of #122769 - RalfJung:reachable, r=tmiasko
extend comments for reachability set computation

I hope this is right. :) Please review carefully.

r? ``@tmiasko``
Cc ``@oli-obk`` ``@saethlin``
2024-03-25 14:35:34 -07:00
Jubilee
c35e971ef7
Rollup merge of #122707 - reedwoodruff:string_docs_typo, r=workingjubilee
Fix a typo in the alloc::string::String docs
2024-03-25 14:35:34 -07:00
bors
5f2c7d2bfd Auto merge of #123040 - weihanglo:update-cargo, r=weihanglo
Update cargo

13 commits in d438c80c45c24be676ef5867edc79d0a14910efe..a510712d05c6c98f987af24dd73cdfafee8922e6
2024-03-19 16:11:22 +0000 to 2024-03-25 03:45:54 +0000
- Remove unnecessary test (rust-lang/cargo#13637)
- Use `gitoxide` for `list_files_git` (rust-lang/cargo#13592)
- fix: Warn on -Zlints (rust-lang/cargo#13632)
- feat: Add a basic linting system (rust-lang/cargo#13621)
- docs: remove untrue TODO for `native_dirs` (rust-lang/cargo#13631)
- refactor(testsuite): Rename lints to lints_table (rust-lang/cargo#13627)
- Fix debuginfo strip when using `--target` (rust-lang/cargo#13618)
- refactor(toml): Push diagnostic complexity on annotate-snippets (rust-lang/cargo#13619)
- Fix publish script due to crates.io CDN change (rust-lang/cargo#13614)
- fix(alias): dont panic when resolving an empty alias (rust-lang/cargo#13613)
- Update annotate snippets (rust-lang/cargo#13609)
- refactor(vendor): tiny not important refactors (rust-lang/cargo#13610)
- feat: Report some dependency changes on any command (rust-lang/cargo#13561)

r? ghost
2024-03-25 21:21:21 +00:00
Daniel Paoliello
d261647c93 Import the 2021 prelude in the core crate 2024-03-25 13:12:06 -07:00
Matthias Krüger
a3c2d752bd add test for ICE: failed to get layout for [type error] #92979
Fixes https://github.com/rust-lang/rust/issues/92979
2024-03-25 20:35:51 +01:00
Matthias Krüger
6fe555549b add test for ICE Where clause Binder(..) was applicable to Obligation(..) but now is not
Fixes https://github.com/rust-lang/rust/issues/84727
2024-03-25 20:20:01 +01:00
Matthias Krüger
5f95fc1dff add test for Compiler panic using fn_traits #81974
Fixes https://github.com/rust-lang/rust/issues/81974
2024-03-25 20:15:28 +01:00
Ralf Jung
d94f6576dd extend doc comment for reachability set computation
also extend the const fn reachability test
2024-03-25 19:57:57 +01:00
clubby789
b500693ad7 Don't emit load metadata in debug mode 2024-03-25 18:32:45 +00:00
bors
35936c4839 Auto merge of #123041 - RalfJung:miri, r=RalfJung
Miri subtree update

r? `@ghost`
2024-03-25 18:20:03 +00:00
Michael Goulet
99fbc6f8ef Instance is Copy 2024-03-25 13:58:40 -04:00
Weihang Lo
69c2a61e5b
Update cargo 2024-03-25 13:11:42 -04:00
rustbot
95f268efa6 Update books 2024-03-25 13:00:21 -04:00
bors
cf1eb93a02 Auto merge of #3414 - RalfJung:rustup, r=RalfJung
Rustup

Fixes https://github.com/rust-lang/miri/issues/3404
2024-03-25 16:34:41 +00:00
Ralf Jung
0d4ef69d66 support '--sysroot=' form of setting the sysroot as well 2024-03-25 17:33:02 +01:00
Ralf Jung
d8be714fee Merge from rustc 2024-03-25 17:17:57 +01:00
Ralf Jung
5b1319c754 Preparing for merge from rustc 2024-03-25 17:17:55 +01:00
bors
60b5ca6275 Auto merge of #123036 - matthiaskrgr:rollup-dj8hra4, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #122842 (Don't emit an error about failing to produce a file with a specific name if user never gave an explicit name)
 - #122881 (Delegation: fix ICE on `bound_vars` divergence)
 - #122910 (Validate that we're only matching on unit struct for path pattern)
 - #122970 (Use `chunk_by` when building `ReverseSccGraph`)
 - #122988 (add even more tests! )
 - #122999 (Fix unpretty UI test when /tmp does not exist)
 - #123001 (Rename `{enter,exit}_lint_attrs` to `check_attributes{,_post}`)
 - #123022 (Add `async-closures/once.rs` back to cranelift tests)
 - #123034 (Add a bunch of needs-unwind annotations to tests)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-25 16:16:59 +00:00
Matthias Krüger
4369718980
Rollup merge of #123034 - bjorn3:test_ignores, r=compiler-errors
Add a bunch of needs-unwind annotations to tests

To filter out tests that fail with cg_clif due to missing panic=unwind support.
2024-03-25 17:05:36 +01:00
Matthias Krüger
11f168ffa2
Rollup merge of #123022 - compiler-errors:clif-tests-async-closure, r=bjorn3
Add `async-closures/once.rs` back to cranelift tests

This was fixed afaict by #120717

r? `@bjorn3`
2024-03-25 17:05:35 +01:00
Matthias Krüger
10daf8aa99
Rollup merge of #123001 - Alexendoo:check-attributes, r=oli-obk
Rename `{enter,exit}_lint_attrs` to `check_attributes{,_post}`

Several places in Clippy want to check all the attributes of a node, we end up using `hir().attrs()` from several different `check_` functions (e.g. [in our doc lints](95c62ffae9/clippy_lints/src/doc/mod.rs (L396))) but this is error prone, we recently found that doc lints weren't triggering on struct fields for example

I went to add a `check_attributes` function but realised `enter_lint_attrs` is already this, the rename is to encourage their use

Also removes `LateContextAndPass::visit_attribute` since it's unused - `visit_attribute` for HIR visitors is only called by `hir().walk_attributes()` which lint passes do not use
2024-03-25 17:05:35 +01:00
Matthias Krüger
657dd0b797
Rollup merge of #122999 - Alexendoo:unpretty-avoid-crash-test, r=petrochenkov
Fix unpretty UI test when /tmp does not exist

On Windows this test fails if e.g. `C:\tmp` is created successfully
2024-03-25 17:05:35 +01:00
Matthias Krüger
877f29363d
Rollup merge of #122988 - matthiaskrgr:icetests, r=petrochenkov
add even more tests!

Fixes https://github.com/rust-lang/rust/issues/109869
Fixes https://github.com/rust-lang/rust/issues/110453
Fixes https://github.com/rust-lang/rust/issues/109020
Fixes https://github.com/rust-lang/rust/issues/108580
Fixes https://github.com/rust-lang/rust/issues/108220
Fixes https://github.com/rust-lang/rust/issues/113045
Fixes https://github.com/rust-lang/rust/issues/113133
Fixes https://github.com/rust-lang/rust/issues/114464
Fixes https://github.com/rust-lang/rust/issues/116599
Fixes https://github.com/rust-lang/rust/issues/119731
2024-03-25 17:05:34 +01:00
Matthias Krüger
9b4ee1be9e
Rollup merge of #122970 - cuviper:use-chunk_by, r=Mark-Simulacrum
Use `chunk_by` when building `ReverseSccGraph`

With stable `chunk_by` in Rust 1.77, this code doesn't need `Itertools::group_by` anymore.
2024-03-25 17:05:33 +01:00
Matthias Krüger
e9ec44251c
Rollup merge of #122910 - compiler-errors:unit-struct-in-path-pat-only, r=petrochenkov
Validate that we're only matching on unit struct for path pattern

Resolution doesn't validate that we only really take `CtorKind::Unit` in path patterns, since all it sees is `Res::SelfCtor(def_id)`. Check this instead during pattern typeck.

r? petrochenkov

Fixes #122809
2024-03-25 17:05:33 +01:00
Matthias Krüger
ccc5310922
Rollup merge of #122881 - Bryanskiy:delegation-fixes-2, r=petrochenkov
Delegation: fix ICE on `bound_vars` divergence

Fixes https://github.com/rust-lang/rust/issues/122550.

Bug was caused by divergence  between lowered type and corresponding `bound_vars` in `late_bound_vars_map`. In this patch `bound_vars` calculation for delegation item is moved from `lower_fn_ty` to `resolve_bound_vars` query.

r? `@petrochenkov`
2024-03-25 17:05:32 +01:00
Matthias Krüger
ded16b3a97
Rollup merge of #122842 - pacak:explicit_name, r=michaelwoerister
Don't emit an error about failing to produce a file with a specific name if user never gave an explicit name

Fixes #122509

You can ask `rustc` to produce some intermediate results with `--emit foo`, this operation comes in two flavors: `--emit asm` and `--emit asm=foo.s`. First one produces one or more `.s` files without any name guarantees, second one renames it into `foo.s`. Second version only works when compiler produces a single file - for asm files this means using a single compilation unit for example.

In case compilation produced more than a single file `rustc` runs following check to emit some warnings:

```rust
            if crate_output.outputs.contains_key(&output_type) {
                // 2) Multiple codegen units, with `--emit foo=some_name`. We have
                //    no good solution for this case, so warn the user.
                sess.dcx().emit_warn(errors::IgnoringEmitPath { extension });
            } else if crate_output.single_output_file.is_some() {
                // 3) Multiple codegen units, with `-o some_name`. We have
                //    no good solution for this case, so warn the user.
                sess.dcx().emit_warn(errors::IgnoringOutput { extension });
            } else {
                // 4) Multiple codegen units, but no explicit name. We
                //    just leave the `foo.0.x` files in place.
                // (We don't have to do any work in this case.)
            }
```

Comment in the final `else` branch implies that if user didn't ask for a specific name - there's no need to emit warnings. However because of the internal representation of `crate_output.outputs` - this doesn't work as expected: if user asked to produce an asm file without giving it an implicit name it will contain `Some(None)`.

To fix the problem new code actually checks if user gave an explicit name. I think this was an original intentional behavior, at least comments imply that.
2024-03-25 17:05:32 +01:00
bjorn3
5f5dcaefe6 Add needs-unwind for proc macro tests
Rustc gives a warning when compiling proc macros with panic=abort.
2024-03-25 15:02:55 +00:00
Kevin Reid
3010fa9afb In pretty_print_type(), print async fn futures' paths instead of spans.
This makes `-Zprint-type-sizes`'s output easier to read, because the
name of an `async fn` is more immediately recognizable than its span.

I also deleted the comment "FIXME(eddyb) should use `def_span`." because
it appears to have already been fixed by commit 67727aa7c3.
2024-03-25 08:01:15 -07:00
bjorn3
3733dcc72d Add needs-unwind annotations to a couple of tests 2024-03-25 14:19:07 +00:00
bors
cb7c63606e Auto merge of #123030 - GuillaumeGomez:rustdoc-sysroot-out-of-arg-file, r=notriddle
Move `--sysroot` argument out of the argument file to fix miri issue

Fixes https://github.com/rust-lang/miri/issues/3404.

For now, miri needs this argument to be moved out of the arg file so they can update it if needed.

cc `@RalfJung`

r? `@notriddle`
2024-03-25 14:09:33 +00:00
bors
c4611708bd Auto merge of #3413 - RalfJung:cargo-miri-misc, r=RalfJung
phase_rustdoc: add a heuristic to make us more certain that this is really rustdoc

Also add anyhow to test-cargo-miri; it has a custom build probe and is widely used so let's make sure the build script does not fail.
2024-03-25 13:51:23 +00:00
Ralf Jung
98e1cbbc02 phase_rustdoc: add a heuristic to make us more certain that this is really rustdoc 2024-03-25 14:40:32 +01:00
Ralf Jung
8afc4862d0 test-cargo-miri: test anyhow 2024-03-25 14:23:42 +01:00
bors
cf172a8ebd Auto merge of #3410 - RalfJung:all-targets, r=RalfJung
CONTRIBUTING: vsocde settings: add --all-targets

Seems like when setting a custom command, one needs to pass this flag manually, it's no longer automatically added by RA.
2024-03-25 12:55:08 +00:00