Commit Graph

248189 Commits

Author SHA1 Message Date
David Wood
2ee0409f32
errors: share SilentEmitter between rustc and rustfmt
Signed-off-by: David Wood <david@davidtw.co>
2024-03-05 10:14:36 +00:00
Luca Barbato
c98e25bab9 Add a build option to specify the bootstrap cache
Setting the bootstrap cache path to an external location can help to
speed up builds in cases where the build directory is not kept between
builds, e.g. in CI or other automated build systems.
2024-03-05 10:35:43 +01:00
许杰友 Jieyou Xu (Joe)
247a080b98
Update test names to not have dots 2024-03-05 09:02:33 +00:00
Ralf Jung
960dd38abe will_wake tests fail on Miri and that is expected 2024-03-05 09:33:55 +01:00
许杰友 Jieyou Xu (Joe)
53f48ddbc7
Assert that test names cannot contain dots
This is so that we can catch stray test output files, since test names
without dots can form predictable patterns we can match on.
2024-03-05 08:11:27 +00:00
bors
41d97c8a5d Auto merge of #122012 - matthiaskrgr:rollup-bzqjj2n, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #121213 (Add an example to demonstrate how Rc::into_inner works)
 - #121262 (Add vector time complexity)
 - #121287 (Clarify/add `must_use` message for Rc/Arc/Weak::into_raw.)
 - #121664 (Adjust error `yield`/`await` lowering)
 - #121826 (Use root obligation on E0277 for some cases)
 - #121838 (Use the correct logic for nested impl trait in assoc types)
 - #121913 (Don't panic when waiting on poisoned queries)
 - #121987 (pattern analysis: abort on arity mismatch)
 - #121993 (Avoid using unnecessary queries when printing the query stack in panics)
 - #121997 (interpret/cast: make more matches on FloatTy properly exhaustive)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-05 08:02:07 +00:00
Urgau
9d9b26bca9 Limit the number of names and values in check-cfg diagnostics 2024-03-05 07:54:04 +01:00
Nicholas Nethercote
d602394827 Change message type in bug functions.
From `impl Into<DiagnosticMessage>` to `impl Into<Cow<'static, str>>`.

Because these functions don't produce user-facing output and we don't
want their strings to be translated.
2024-03-05 17:11:42 +11:00
Oli Scherer
c98be3254f Stop using Bubble in coherence and instead emulate it with an intercrate check 2024-03-05 05:52:34 +00:00
Matthias Krüger
92ff43d87b
Rollup merge of #121997 - RalfJung:cast-float-ty, r=compiler-errors
interpret/cast: make more matches on FloatTy properly exhaustive

Actually implementing these is pretty trivial (at least once all the scalar methods are added, which happens in https://github.com/rust-lang/rust/pull/121926), but I'm staying consistent with the other f16/f128 PRs. Also adding adding all the tests to Miri would be quite a lot of work.

There's probably some way to reduce the code duplication here with more use of generics... but that's a future refactor.^^

r? ```@tgross35```
2024-03-05 06:40:33 +01:00
Matthias Krüger
87dc3fc950
Rollup merge of #121993 - Zoxc:query-stack-panic-queries, r=compiler-errors
Avoid using unnecessary queries when printing the query stack in panics

This should fix https://github.com/rust-lang/rust/issues/121974. Alternative to https://github.com/rust-lang/rust/pull/121981.
2024-03-05 06:40:33 +01:00
Matthias Krüger
44bd2b5166
Rollup merge of #121987 - Nadrieril:abort-on-arity-mismatch, r=compiler-errors
pattern analysis: abort on arity mismatch

This is one more PR replacing panics by `Err()` aborts. I recently audited all the `unwrap()` calls, but I had forgotten about array accesses. (Again [discovered by rust-analyzer](https://github.com/rust-lang/rust-analyzer/issues/16746)).

r? ```@compiler-errors```
2024-03-05 06:40:33 +01:00
Matthias Krüger
c483e637f3
Rollup merge of #121913 - Zoxc:query-fix, r=compiler-errors
Don't panic when waiting on poisoned queries

This fixes a bug introduced in https://github.com/rust-lang/rust/pull/119086.
2024-03-05 06:40:32 +01:00
Matthias Krüger
20dde1ea62
Rollup merge of #121838 - oli-obk:impl_trait_in_assoc_tys_fix, r=compiler-errors
Use the correct logic for nested impl trait in assoc types

Previously we accidentally continued with the TAIT visitor, which allowed more than we wanted to.

r? ```@compiler-errors```
2024-03-05 06:40:32 +01:00
Matthias Krüger
35f6eee51a
Rollup merge of #121826 - estebank:e0277-root-obligation-2, r=oli-obk
Use root obligation on E0277 for some cases

When encountering trait bound errors that satisfy some heuristics that tell us that the relevant trait for the user comes from the root obligation and not the current obligation, we use the root predicate for the main message.

This allows to talk about "X doesn't implement Pattern<'_>" over the most specific case that just happened to fail, like  "char doesn't implement Fn(&mut char)" in
`tests/ui/traits/suggest-dereferences/root-obligation.rs`

The heuristics are:

 - the type of the leaf predicate is (roughly) the same as the type from the root predicate, as a proxy for "we care about the root"
 - the leaf trait and the root trait are different, so as to avoid talking about `&mut T: Trait` and instead remain talking about `T: Trait` instead
 - the root trait is not `Unsize`, as to avoid talking about it in `tests/ui/coercion/coerce-issue-49593-box-never.rs`.

```
error[E0277]: the trait bound `&char: Pattern<'_>` is not satisfied
  --> $DIR/root-obligation.rs:6:38
   |
LL |         .filter(|c| "aeiou".contains(c))
   |                             -------- ^ the trait `Fn<(char,)>` is not implemented for `&char`, which is required by `&char: Pattern<'_>`
   |                             |
   |                             required by a bound introduced by this call
   |
   = note: required for `&char` to implement `FnOnce<(char,)>`
   = note: required for `&char` to implement `Pattern<'_>`
note: required by a bound in `core::str::<impl str>::contains`
  --> $SRC_DIR/core/src/str/mod.rs:LL:COL
help: consider dereferencing here
   |
LL |         .filter(|c| "aeiou".contains(*c))
   |                                      +
```

Fix #79359, fix #119983, fix #118779, cc #118415 (the suggestion needs to change), cc #121398 (doesn't fix the underlying issue).
2024-03-05 06:40:31 +01:00
Matthias Krüger
94bb2d2a97
Rollup merge of #121664 - compiler-errors:adjust-error-yield-lowering, r=spastorino
Adjust error `yield`/`await` lowering

Adjust the lowering of `yield`/`await` outside of their correct scopes so that we no longer make orpan HIR exprs.

Previously, `yield EXPR` would be lowered directly to `hir::TyKind::Error` (which I'll call `<error>`) which means that `EXPR` was not present in the HIR, but now we lower it to `{ EXPR; <error> }` so that `EXPR` is not orphaned.

Fixes #121096
2024-03-05 06:40:30 +01:00
Matthias Krüger
72651306b3
Rollup merge of #121287 - zachs18:rc-into-raw-must-use, r=cuviper
Clarify/add `must_use` message for Rc/Arc/Weak::into_raw.

The current `#[must_use]` messages for `{sync,rc}::Weak::into_raw` ("`self` will be dropped if the result is not used") are misleading, as `self` is consumed and will *not* be dropped.

This PR changes their `#[must_use]` message to the same as `Arc::into_raw`'s[ current `#[must_use]` message](d573564575/library/alloc/src/sync.rs (L1482)) ("losing the pointer will leak memory"), and also adds it to `Rc::into_raw`, which is not currently `#[must_use]`.
2024-03-05 06:40:30 +01:00
Matthias Krüger
22827fd5b1
Rollup merge of #121262 - 20jasper:add-vector-time-complexity, r=cuviper
Add vector time complexity

Added time complexity for `Vec` methods `push`, `push_within_capacity`, `pop`, and `insert`.

<details>

<summary> Reference images </summary>

![`Vec::push` documentation](https://github.com/rust-lang/rust/assets/78604367/dc966bbd-e92e-45a6-af82-35afabfa79a9)

![`Vec::push_within_capacity` documentation](https://github.com/rust-lang/rust/assets/78604367/9aadaf48-46ed-4fad-bdd5-74b98a61f4bb)

![`Vec::pop` documentation](https://github.com/rust-lang/rust/assets/78604367/88ec0389-a346-4ea5-a3b7-17caf514dd8b)

![`Vec::insert` documentation](https://github.com/rust-lang/rust/assets/78604367/960c15c3-ef8e-4aa7-badc-35ce80f6f221)

</details>

I followed a convention to use `#Time complexity` that I found in [the `BinaryHeap` documentation](https://doc.rust-lang.org/std/collections/struct.BinaryHeap.html#time-complexity-1). Looking through the rest of standard library collections, there is not a consistent way to handle this.

[`Vec::swap_remove`](https://doc.rust-lang.org/std/vec/struct.Vec.html#method.swap_remove) does not have a dedicated section for time complexity but does list it.

[`VecDeque::rotate_left`](https://doc.rust-lang.org/std/collections/struct.VecDeque.html#complexity) uses a `#complexity` heading.
2024-03-05 06:40:29 +01:00
Matthias Krüger
c2f6c0b806
Rollup merge of #121213 - Takashiidobe:takashi/example-for-rc-into-inner, r=cuviper
Add an example to demonstrate how Rc::into_inner works

This PR adds an example to Rc::into_inner, since it didn't have one previously.
2024-03-05 06:40:29 +01:00
bors
5a1e5449c8 Auto merge of #121001 - nyurik:optimize-core-fmt, r=cuviper
perf: improve write_fmt to handle simple strings

In case format string has no arguments, simplify its implementation with a direct call to `output.write_str(value)`. This builds on `@dtolnay` original [suggestion](https://github.com/serde-rs/serde/pull/2697#issuecomment-1940376414). This does not change any expectations because the original `fn write()` implementation calls `write_str` for parts of the format string.

```rust
write!(f, "text")  ->  f.write_str("text")
```

```diff
 /// [`write!`]: crate::write!
+#[inline]
 #[stable(feature = "rust1", since = "1.0.0")]
 pub fn write(output: &mut dyn Write, args: Arguments<'_>) -> Result {
+    if let Some(s) = args.as_str() { output.write_str(s) } else { write_internal(output, args) }
+}
+
+/// Actual implementation of the [`write`], but without the simple string optimization.
+fn write_internal(output: &mut dyn Write, args: Arguments<'_>) -> Result {
     let mut formatter = Formatter::new(output);
     let mut idx = 0;
```

* Hopefully it will improve the simple case for the https://github.com/rust-lang/rust/issues/99012
* Another related (original?) issues #10761
* Previous similar attempt to fix it by by `@Kobzol` #100700

CC: `@m-ou-se` as probably the biggest expert in everything `format!`
2024-03-05 05:33:17 +00:00
bors
1547c076bf Auto merge of #121780 - nnethercote:diag-renaming2, r=davidtwco
Diagnostic renaming 2

A sequel to #121489.

r? `@davidtwco`
2024-03-05 02:58:34 +00:00
jyn
8bfe9dbae2 libtest: Print the names of failed tests eagerly
Previously, libtest would wait until all tests finished running to print the progress, which made it
annoying to run many tests at once (since you don't know which have failed). Change it to print the
names as soon as they fail.

This also adds a test for the terse output; previously it was untested.
2024-03-04 21:45:41 -05:00
surechen
523ab25418 add test for #71450 2024-03-05 10:45:09 +08:00
jyn
678e2177dc bootstrap: print test name on failure even with verbose-tests=false
This makes it much easier to know which test failed without having to wait for compiletest to completely finish running. Before:
```
Testing stage0 compiletest suite=ui mode=ui (x86_64-unknown-linux-gnu)

running 15274 tests
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii    88/15274
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii   176/15274
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii   264/15274
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii   352/15274
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii   440/15274
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii   528/15274
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiFFiiiiiii
...
```

After:
```
Testing stage0 compiletest suite=ui mode=ui (x86_64-unknown-linux-gnu)

running 15274 tests
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii    88/15274
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii   176/15274
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii   264/15274
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii   352/15274
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii   440/15274
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii   528/15274
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
[ui] tests/ui/associated-type-bounds/implied-in-supertrait.rs ... F

[ui] tests/ui/associated-type-bounds/return-type-notation/basic.rs#next_with ... F
iiiiiiiiiiiii
...
```

This serves a similar use case to the existing RUSTC_TEST_FAIL_FAST, but is on by default and as a result much more discoverable.
We should consider unifying RUSTC_TEST_FAIL_FAST with the `--no-fail-fast` flag in the future for consistency and discoverability.
2024-03-04 21:15:22 -05:00
Nicholas Nethercote
1cd957498b Adjust Diag::new signature.
Make it use `impl Into<DiagMessage>` like all the other methods nearby.
2024-03-05 12:15:13 +11:00
Nicholas Nethercote
5cce28725f Rename DiagnosticMetadata as DiagMetadata. 2024-03-05 12:15:13 +11:00
Nicholas Nethercote
f8429390ec Rename StructuredDiagnostic as StructuredDiag. 2024-03-05 12:15:12 +11:00
Nicholas Nethercote
7aa0eea19c Rename BuiltinLintDiagnostics as BuiltinLintDiag.
Not the dropping of the trailing `s` -- this type describes a single
diagnostic and its name should be singular.
2024-03-05 12:15:10 +11:00
Nicholas Nethercote
d98ad0a181 Rename DiagnosticExt as DiagExt. 2024-03-05 12:14:49 +11:00
Nicholas Nethercote
d0e9bab51b Rename DiagnosticMode as DiagMode. 2024-03-05 12:14:49 +11:00
Nicholas Nethercote
573267cf3c Rename SubdiagnosticMessageOp as SubdiagMessageOp. 2024-03-05 12:14:49 +11:00
Nicholas Nethercote
60ea6e2831 Rename SubdiagnosticMessage as SubdiagMessage. 2024-03-05 12:14:49 +11:00
Nicholas Nethercote
f16a8d0390 Fix some out-of-date comments. 2024-03-05 12:14:49 +11:00
Nicholas Nethercote
18715c98c6 Rename DiagnosticMessage as DiagMessage. 2024-03-05 12:14:49 +11:00
Nicholas Nethercote
d849f5c225 Disable tests/ui-fulldeps/internal-lints/diagnostics.rs on stage 1.
When you make a change to the diagnostic lints, it uses the old version
of the lints with stage 1 and the new version with stage 2, which often
leads to failures in stage 1. Let's just stick to stage 2.
2024-03-05 12:14:49 +11:00
Nicholas Nethercote
a9dff2d931 Remove unused impl DummyAstNode for Block. 2024-03-05 12:05:04 +11:00
Nicholas Nethercote
b5d7da878f Decouple DummyAstNode and DummyResult.
They are two different ways of creating dummy results, with two
different purposes. Their implementations are separate except for
crates, where `DummyResult` depends on `DummyAstNode`.

This commit removes that dependency, so they are now fully separate. It
also expands the comment on `DummyAstNode`.
2024-03-05 12:05:04 +11:00
Christopher Durham
215a4b6c2d doc wording improvements
Co-authored-by: Simon Farnsworth <simon@farnz.org.uk>
2024-03-04 19:58:55 -05:00
Christopher Durham
4dbd2562b4 Explain use of display adapters 2024-03-04 19:58:45 -05:00
Chris Denton
2a09857729
Update debuginfo tests 2024-03-05 00:19:44 +00:00
Chris Denton
f700641bd9
Windows: Implement mutex using futex
Well, the Windows equivalent: `WaitOnAddress`, `WakeByAddressSingle` and `WakeByAddressAll`.
2024-03-05 00:19:42 +00:00
bors
2eeff462b7 Auto merge of #120675 - oli-obk:intrinsics3.0, r=pnkfelix
Add a scheme for moving away from `extern "rust-intrinsic"` entirely

All `rust-intrinsic`s can become free functions now, either with a fallback body, or with a dummy body and an attribute, requiring backends to actually implement the intrinsic.

This PR demonstrates the dummy-body scheme with the `vtable_size` intrinsic.

cc https://github.com/rust-lang/rust/issues/63585

follow-up to #120500

MCP at https://github.com/rust-lang/compiler-team/issues/720
2024-03-05 00:13:01 +00:00
okaneco
69637c9212 Add benches for net parsing
Add benches for IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4,
and SocketAddrV6 parsing
2024-03-04 18:46:24 -05:00
okaneco
31c758e052 net: Add branch to Parser::read_number for parsing without checked
arithmetic

If `max_digits.is_some()`, then we know we are parsing a `u8` or `u16`
because `read_number` is only called with `Some(3)` or `Some(4)`. Both
types fit well within a `u32` without risk of overflow. Thus, we can use
plain arithmetic to avoid extra instructions from `checked_mul` and
`checked_add`.
2024-03-04 18:46:09 -05:00
Ralf Jung
681dc38283
typo
Co-authored-by: Rémy Rakic <remy.rakic+github@gmail.com>
2024-03-04 23:18:02 +01:00
bors
50e77f133f Auto merge of #121998 - matthiaskrgr:rollup-l7lzwpb, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #120976 (constify a couple thread_local statics)
 - #121683 (Fix LVI tests after frame pointers are enabled by default)
 - #121703 (Add a way to add constructors for `rustc_type_ir` types)
 - #121732 (Improve assert_matches! documentation)
 - #121928 (Extract an arguments struct for `Builder::then_else_break`)
 - #121939 (Small enhancement to description of From trait)
 - #121968 (Don't run test_get_os_named_thread on win7)
 - #121969 (`ParseSess` cleanups)
 - #121977 (Doc: Fix incorrect reference to integer in Atomic{Ptr,Bool}::as_ptr.)
 - #121994 (Update platform-support.md with supported musl version)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-04 21:56:57 +00:00
Matthias Krüger
5e13bc45fb
Rollup merge of #121994 - wesleywiser:update_musl_version_docs, r=ehuss
Update platform-support.md with supported musl version

This just reflects the current status quo, there is no actual change here since the update to musl 1.2.3 occurred in #107129 and was approved in https://github.com/rust-lang/compiler-team/issues/572.

I also normalized all mentions of musl libc to "musl" (non-capitalized per the project's site and Wikipedia page).

r? ``@ehuss``
2024-03-04 22:16:34 +01:00
Matthias Krüger
c83ca5ba9a
Rollup merge of #121977 - Lee-Janggun:master, r=WaffleLapkin
Doc: Fix incorrect reference to integer in Atomic{Ptr,Bool}::as_ptr.

I am assuming "resulting integer" is an error, since we are talking about pointers and booleans here. Seems like it was missed while copy & pasting the docs from the integer versions. I also checked the rest of the docs, and this was the only mention of integers.
2024-03-04 22:16:34 +01:00
Matthias Krüger
13b971209a
Rollup merge of #121969 - nnethercote:ParseSess-cleanups, r=wesleywiser
`ParseSess` cleanups

The main change here is to rename all `ParseSess` values as `psess`. Plus a few other small cleanups.

r? `@wesleywiser`
2024-03-04 22:16:33 +01:00
Matthias Krüger
4944ab449a
Rollup merge of #121968 - roblabla:fix-win7, r=jhpratt
Don't run test_get_os_named_thread on win7

This test won't work on windows 7, as the Thread::set_name function is not implemented there (win7 does not provide a documented mechanism to set thread names).
2024-03-04 22:16:33 +01:00