Commit Graph

263792 Commits

Author SHA1 Message Date
Zalathar
2a000c8d70 Don't panic on unknown JSON-like output lines
This function is called for both compiler and non-compiler output, so if the
line isn't recognized as JSON from the compiler then just print it as-is.
2024-08-13 20:23:48 +10:00
Matthias Krüger
42f70c240a
Rollup merge of #129040 - Zalathar:bless-rmake, r=jieyouxu
Fix blessing of rmake tests

Fixes #129038.

When running in `--bless` mode, we now set the value of `RUSTC_BLESS_TEST` to the current test's source directory. This allows the diff helper in `run_make_support` to find the original snapshot file in the source directory and bless that, instead of unhelpfully blessing the temporary copy in `build`.

r? `@jieyouxu`
2024-08-13 12:12:25 +02:00
Matthias Krüger
41aa9631ef
Rollup merge of #129026 - rcvalle:rust-cfi-move-cfi-ui-tests-to-cfi-directory, r=compiler-errors
CFI: Move CFI ui tests to cfi directory

Move the CFI ui tests to the cfi directory and removes the cfi prefix from tests file names similarly to how the cfi codegen tests are organized.
2024-08-13 12:12:25 +02:00
Matthias Krüger
9d9c9acc6e
Rollup merge of #128983 - Kobzol:bootstrap-target, r=onur-ozkan
Slightly refactor `TargetSelection` in bootstrap

Mostly a drive-by refactoring of `TargetSelection` to reduce some manual "windows-gnu" detection and also accesses to the `triple` field.

r? `@onur-ozkan`
2024-08-13 12:12:24 +02:00
Matthias Krüger
0643c3b910
Rollup merge of #128841 - lqd:rustc-args, r=onur-ozkan
bootstrap: don't use rustflags for `--rustc-args`

r? `@onur-ozkan`

This is going to require a bit of context.

https://github.com/rust-lang/rust/pull/47558 has added `--rustc-args` to `./x test` to allow passing flags when building `compiletest` tests. It was made specifically because using `RUSTFLAGS` would rebuild the compiler/stdlib, which would in turn require the flag you want to build tests with to successfully bootstrap.

#113178 made the request that it also works for other tests and doctests. This is not trivial to support across the board for `library`/`compiler` unit-tests/doctests and across stages. This issue was closed in #113948 by using `RUSTFLAGS`, seemingly incorrectly since https://github.com/rust-lang/rust/pull/123489 fixed that part to make it work.

Unfortunately #123489/#113948 have regressed the goals of `--rustc-args`:
- now we can't use rustc args that don't bootstrap, to run the UI tests: we can't test incomplete features. The new trait solver doesn't bootstrap, in-progress borrowck/polonius changes don't bootstrap, some other features are similarly incomplete, etc.
- using the flag now rebuilds everything from scratch: stage0 stdlib, stage1 compiler, stage1 stdlib. You don't need to re-do all this to compile UI tests, you only need the latter to run stdlib tests with a new flag, etc. This happens for contributors, but also on CI today. (Not to mention that in doing that it will rebuild things with flags that are not meant to be used, e.g. stdlib cfgs that don't exist in the compiler; or you could also imagine that this silently enables flags that were not meant to be enabled in this way).

Since then, bd71c71ea0 has started using it to test a stdlib feature, relying on the fact that it now rebuilds everything. So #125011 also regressed CI times more than necessary because it rebuilds everything instead of just stage 1 stdlib.

It's not easy for me to know how to properly fix #113178 in bootstrap, but #113948/#123489 are not it since they regress the initial intent. I'd think bootstrap would have to know from the list of test targets that are passed that the `library` or `compiler` paths that are passed could require rebuilding these crates with different rustflags, probably also depending on stages. Therefore I would not be able to fix it, and will just try in this PR to unregress the situation to unblock the initial use-case.

It seems miri now also uses `./x miri --rustc-args` in this incorrect meaning to rebuild the `library` paths they support to run with the new args. I've not made any bootstrap changes related to `./x miri` in this PR, so `--rustc-args` wouldn't work there anymore. I'd assume this would need to use rustflags again but I don't know how to make that work properly in bootstrap, hence opening as draft, so you can tell me how to do that. I assume we don't want to break their use-case again now that it exists, even though there are ways to use `./x test` to do exactly that.

`RUSTFLAGS_NOT_BOOTSTRAP=flag ./x test library/std` is a way to run unit tests with a new flag without rebuilding everything, while with #123489 there is no way anymore to run tests with a flag that doesn't bootstrap.

---
edit: after review, this PR:
- renames `./x test --rustc-args` to `./x test --compiletest-rustc-args` as it only applies there, and cannot use rustflags for this purpose.
- fixes the regression that using these args rebuilt everything from scratch
- speeds up some CI jobs via the above point
- removes `./x miri --rustc-args` as only library tests are supported, needs to rebuild libstd, and `./x miri --compiletest-rustc-args` wouldn't work since compiletests are not supported.
2024-08-13 12:12:23 +02:00
Matthias Krüger
37b956787a
Rollup merge of #128745 - dtolnay:spawnunchecked, r=workingjubilee
Remove unused lifetime parameter from spawn_unchecked

Amanieu caught this when reviewing the stabilization proposal in https://github.com/rust-lang/rust/issues/55132.

The `'a` lifetime here is useless. The signature is asking the caller of `spawn_unchecked` to "give me any lifetime that is shorter than your F's and T's lifetime", which they can always to with no effect, because arbitrarily short lifetimes exist.
2024-08-13 12:12:23 +02:00
Matthias Krüger
c977deb24b
Rollup merge of #128655 - joboet:play_with_the_dice, r=ChrisDenton
std: refactor UNIX random data generation

This PR makes a number of changes to the UNIX randomness implementation:
* Use `io::Error` for centralized error handling
* Move the file-fallback logic out of the `getrandom`-specific module
* Stop redefining the syscalls on macOS and DragonFly, they have appeared in `libc`
* Add a `OnceLock` to cache the random device file descriptor
2024-08-13 12:12:22 +02:00
Matthias Krüger
00d040e50a
Rollup merge of #128643 - beetrees:ppc64-abi-fix, r=bjorn3
Refactor `powerpc64` call ABI handling

As the [specification](https://openpowerfoundation.org/specifications/64bitelfabi/) for the ELFv2 ABI states that returned aggregates are returned like arguments as long as they are at most two doublewords, I've merged the `classify_arg` and `classify_ret` functions to reduce code duplication. The only functional change is to fix #128579: the `classify_ret` function was incorrectly handling aggregates where `bits > 64 && bits < 128`. I've used the aggregate handling implementation from `classify_arg` which doesn't have this issue.

`@awilfox` could you test this on `powerpc64-unknown-linux-musl`? I'm only able to cross-test on `powerpc64-unknown-linux-gnu` and `powerpc64le-unknown-linux-gnu` locally at the moment, and as a tier 3 target `powerpc64-unknown-linux-musl` has zero CI coverage.

Fixes: #128579
2024-08-13 12:12:21 +02:00
Tobias Bucher
811d7dd113 #[deprecated_safe_2024]: Also use the // TODO: hint in the compiler error
This doesn't work for translated compiler error messages.
2024-08-13 11:32:47 +02:00
Tobias Bucher
399ef23d2b Allow to customize // TODO: comment for deprecated safe autofix
Relevant for the deprecation of `CommandExt::before_exit` in #125970.
2024-08-13 11:32:24 +02:00
bors
a2e1d154d5 Auto merge of #128962 - devnexen:fs_get_mode_haiku, r=workingjubilee
std::fs: get_mode implementation for all unix
2024-08-13 09:10:32 +00:00
Jakub Beránek
1c0c2c3ad6 Implement AsRef<Path> for TargetSelection 2024-08-13 10:40:45 +02:00
Jakub Beránek
0cfbfa9532 Create a TargetSelection method for recognizing *-windows-gnu targets 2024-08-13 10:39:35 +02:00
bors
acc2c5d67a Auto merge of #17876 - Veykril:semantics-include-simplify, r=Veykril
internal: Remove unreachable logic for include token mapping

Turns out https://github.com/rust-lang/rust-analyzer/pull/17863 made this obsolete 🎉
2024-08-13 07:48:55 +00:00
Lukas Wirth
705a89e72f Remove unreachable logic for include token mapping 2024-08-13 09:44:13 +02:00
Zalathar
cc58cf6443 Fix blessing of rmake tests 2024-08-13 17:11:39 +10:00
Zalathar
6d91017b02 Extract a helper method for blessing in Diff 2024-08-13 16:34:36 +10:00
bors
84ac708b45 Auto merge of #17867 - ShoyuVanilla:issue-17854, r=Veykril
fix: Trailing excess comma in "Convert to named struct" assist

Fixes #17854
2024-08-13 06:24:19 +00:00
Mikhail Zabaluev
ac88b330b8 Revert to original loop for const pow exponents
Give LLVM the for original, optimizable loop in pow and wrapped_pow
functions in the case when the exponent is statically known.
2024-08-13 08:32:36 +03:00
bors
591ecb88df Auto merge of #128742 - RalfJung:miri-vtable-uniqueness, r=saethlin
miri: make vtable addresses not globally unique

Miri currently gives vtables a unique global address. That's not actually matching reality though. So this PR enables Miri to generate different addresses for the same type-trait pair.

To avoid generating an unbounded number of `AllocId` (and consuming unbounded amounts of memory), we use the "salt" technique that we also already use for giving constants non-unique addresses: the cache is keyed on a "salt" value n top of the actually relevant key, and Miri picks a random salt (currently in the range `0..16`) each time it needs to choose an `AllocId` for one of these globals -- that means we'll get up to 16 different addresses for each vtable. The salt scheme is integrated into the global allocation deduplication logic in `tcx`, and also used for functions and string literals. (So this also fixes the problem that casting the same function to a fn ptr over and over will consume unbounded memory.)

r? `@saethlin`
Fixes https://github.com/rust-lang/miri/issues/3737
2024-08-13 04:32:34 +00:00
Zalathar
fc733a668a Port run-make/libtest-junit to rmake 2024-08-13 13:28:03 +10:00
Zalathar
c4aa7a71a9 Port run-make/libtest-json to rmake 2024-08-13 13:27:15 +10:00
Henry Sloan
1e445f48d4 Add must_use attribute to Coroutine trait 2024-08-12 19:27:57 -07:00
Kyle Huey
1c5e3c90cf Rework MIR inlining debuginfo so function parameters show up in debuggers.
Line numbers of multiply-inlined functions were fixed in #114643 by using a
single DISubprogram. That, however, triggered assertions because parameters
weren't deduplicated. The "solution" to that in #115417 was to insert a
DILexicalScope below the DISubprogram and parent all of the parameters to that
scope. That fixed the assertion, but debuggers (including gdb and lldb) don't
recognize variables that are not parented to the subprogram itself as parameters,
even if they are emitted with DW_TAG_formal_parameter.

Consider the program:

use std::env;

fn square(n: i32) -> i32 {
    n * n
}

fn square_no_inline(n: i32) -> i32 {
    n * n
}

fn main() {
    let x = square(env::vars().count() as i32);
    let y = square_no_inline(env::vars().count() as i32);
    println!("{x} == {y}");
}

When making a release build with debug=2 and rustc 1.82.0-nightly (8b3870784 2024-08-07)

(gdb) r
Starting program: /ephemeral/tmp/target/release/tmp
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Breakpoint 1, tmp::square () at src/main.rs:5
5	    n * n
(gdb) info args
No arguments.
(gdb) info locals
n = 31
(gdb) c
Continuing.

Breakpoint 2, tmp::square_no_inline (n=31) at src/main.rs:10
10	    n * n
(gdb) info args
n = 31
(gdb) info locals
No locals.

This issue is particularly annoying because it removes arguments from stack traces.

The DWARF for the inlined function looks like this:

< 2><0x00002132 GOFF=0x00002132>      DW_TAG_subprogram
                                        DW_AT_linkage_name          _ZN3tmp6square17hc507052ff3d2a488E
                                        DW_AT_name                  square
                                        DW_AT_decl_file             0x0000000f /ephemeral/tmp/src/main.rs
                                        DW_AT_decl_line             0x00000004
                                        DW_AT_type                  0x00001a56<.debug_info+0x00001a56>
                                        DW_AT_inline                DW_INL_inlined
< 3><0x00002142 GOFF=0x00002142>        DW_TAG_lexical_block
< 4><0x00002143 GOFF=0x00002143>          DW_TAG_formal_parameter
                                            DW_AT_name                  n
                                            DW_AT_decl_file             0x0000000f /ephemeral/tmp/src/main.rs
                                            DW_AT_decl_line             0x00000004
                                            DW_AT_type                  0x00001a56<.debug_info+0x00001a56>
< 4><0x0000214e GOFF=0x0000214e>          DW_TAG_null
< 3><0x0000214f GOFF=0x0000214f>        DW_TAG_null

That DW_TAG_lexical_block inhibits every debugger I've tested from recognizing
'n' as a parameter.

This patch removes the additional lexical scope. Parameters can be easily
deduplicated by a tuple of their scope and the argument index, at the trivial
cost of taking a Hash + Eq bound on DIScope.
2024-08-12 19:20:00 -07:00
bors
e9e27ab0cf Auto merge of #128868 - s7tya:port-rustc-perf-cmp-command, r=Kobzol
Port rustc perf cmp command

I've integrated bench_cmp and bench_local into the bootstrap.

r​? `@Kobzol`
2024-08-13 02:07:10 +00:00
burlinchen
c4333026a0 chore(lib): fmt core::fmt::Formatter's write_fmt method 2024-08-13 08:40:08 +08:00
David Carlier
70e0f69632
trying common codepath for every unixes 2024-08-12 23:44:42 +01:00
David Carlier
a7be5bf683
std::fs: get_mode implementation for haiku. 2024-08-12 23:44:00 +01:00
bors
db5704ffca Auto merge of #129024 - matthiaskrgr:rollup-uj1pd0x, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #128712 (Normalize struct tail properly for `dyn` ptr-to-ptr casting in new solver)
 - #128912 (Store `do_not_recommend`-ness in impl header)
 - #129000 (bootstrap: clear miri ui-test deps when miri sysroot gets rebuilt)
 - #129013 (Remove unused script from run-make tests)
 - #129017 (Replace `std::fmt:FormatterFn` with `std::fmt::from_fn`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-12 22:17:05 +00:00
Ramon de C Valle
66c93ac8ba CFI: Move CFI ui tests to cfi directory
Moves the CFI ui tests to the cfi directory and removes the cfi prefix
from tests file names similarly to how the cfi codegen tests are
organized.
2024-08-12 14:59:50 -07:00
Matthias Krüger
522d43673a
Rollup merge of #129017 - its-the-shrimp:core_fmt_from_fn, r=Noratrieb
Replace `std::fmt:FormatterFn` with `std::fmt::from_fn`

Modelled after the suggestion made in [this](https://github.com/rust-lang/rust/issues/117729#issuecomment-1837628559) comment, this should bring this functionality in line with the existing `array::from_fn` & `iter::from_fn`
2024-08-12 23:10:52 +02:00
Matthias Krüger
0dfb5b9cb8
Rollup merge of #129013 - Kobzol:remove-unused-git-clone-sha-file, r=jieyouxu
Remove unused script from run-make tests

Its last usage was removed in https://github.com/rust-lang/rust/pull/128636.

Tracking issue: https://github.com/rust-lang/rust/issues/121876

r? jieyouxu
2024-08-12 23:10:52 +02:00
Matthias Krüger
301a4cab68
Rollup merge of #129000 - RalfJung:miri-bootstrap-clear, r=onur-ozkan
bootstrap: clear miri ui-test deps when miri sysroot gets rebuilt

Second attempt after https://github.com/rust-lang/rust/pull/128683: seems like it's not the compiler changing that we care about, but the sysroot changing.

I did some local testing with sysroot rebuilds and it works fine for at least those cases I checked.

r? ``@onur-ozkan``
2024-08-12 23:10:51 +02:00
Matthias Krüger
85eb465a10
Rollup merge of #128912 - compiler-errors:do-not-recommend-impl, r=lcnr
Store `do_not_recommend`-ness in impl header

Alternative to #128674

It's less flexible, but also less invasive. Hopefully it's also performant. I'd recommend we think separately about the design for how to gate arbitrary diagnostic attributes moving forward.
2024-08-12 23:10:51 +02:00
Matthias Krüger
4c49418472
Rollup merge of #128712 - compiler-errors:normalize-borrowck, r=lcnr
Normalize struct tail properly for `dyn` ptr-to-ptr casting in new solver

Realized that the new solver didn't handle ptr-to-ptr casting correctly.

r? lcnr

Built on #128694
2024-08-12 23:10:50 +02:00
Ding Xiang Fei
5534cb0a4a
derive(SmartPointer): register helper attributes 2024-08-13 04:26:48 +08:00
Esteban Küber
110b19b2b6 Properly differentiate between methods and assoc fns 2024-08-12 19:45:20 +00:00
Esteban Küber
61058937e5 Rework suggestion method
Make checking slightly cheaper (by restricting to the right item only).

Add tests.
2024-08-12 19:29:47 +00:00
Esteban Küber
4e985534e8 Ignore auto-deref for multiple crate version note
As per the case presented in #128569, we should be showing the extra info even if auto-deref is involved.
2024-08-12 19:29:47 +00:00
Esteban Küber
eeb72835d2 Account for fully-qualified path case of conflicting crate versions
When encountering the following, mention the precense of conflicting crates:

```
error[E0599]: no function or associated item named `get_decoded` found for struct `HpkeConfig` in the current scope
   --> src/main.rs:7:17
    |
7   |     HpkeConfig::get_decoded(&foo);
    |                 ^^^^^^^^^^^ function or associated item not found in `HpkeConfig`
    |
note: if you're trying to build a new `HpkeConfig`, consider using `HpkeConfig::new` which returns `HpkeConfig`
   --> ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/janus_messages-0.3.1/src/lib.rs:908:5
    |
908 | /     pub fn new(
909 | |         id: HpkeConfigId,
910 | |         kem_id: HpkeKemId,
911 | |         kdf_id: HpkeKdfId,
912 | |         aead_id: HpkeAeadId,
913 | |         public_key: HpkePublicKey,
914 | |     ) -> HpkeConfig {
    | |___________________^
note: there are multiple different versions of crate `prio` in the dependency graph
   --> src/main.rs:1:5
    |
1   | use prio::codec::Decode;
    |     ^^^^^^^^^^^^^^^^^^^ `prio` imported here doesn't correspond to the right crate version
    |
   ::: ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/prio-0.9.1/src/codec.rs:35:1
    |
35  | pub trait Decode: Sized {
    | ----------------------- this is the trait that was imported
    |
   ::: ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/prio-0.10.3/src/codec.rs:35:1
    |
35  | pub trait Decode: Sized {
    | ----------------------- this is the trait that is needed
...
43  |     fn get_decoded(bytes: &[u8]) -> Result<Self, CodecError> {
    |     -------------------------------------------------------- the method is available for `HpkeConfig` here
help: there is an associated function `decode` with a similar name
    |
7   |     HpkeConfig::decode(&foo);
    |                 ~~~~~~
```
2024-08-12 19:29:47 +00:00
Esteban Küber
5c427b4600 reword message 2024-08-12 19:29:47 +00:00
Esteban Küber
b2e7ae1f65 Detect multiple crate versions on method not found
When a type comes indirectly from one crate version but the imported trait comes from a separate crate version, the called method won't be found. We now show additional context:

```
error[E0599]: no method named `foo` found for struct `dep_2_reexport::Type` in the current scope
 --> multiple-dep-versions.rs:8:10
  |
8 |     Type.foo();
  |          ^^^ method not found in `Type`
  |
note: you have multiple different versions of crate `dependency` in your dependency graph
 --> multiple-dep-versions.rs:4:32
  |
4 | use dependency::{do_something, Trait};
  |                                ^^^^^ `dependency` imported here doesn't correspond to the right crate version
  |
 ::: ~/rust/build/x86_64-unknown-linux-gnu/test/run-make/crate-loading/rmake_out/multiple-dep-versions-1.rs:4:1
  |
4 | pub trait Trait {
  | --------------- this is the trait that was imported
  |
 ::: ~/rust/build/x86_64-unknown-linux-gnu/test/run-make/crate-loading/rmake_out/multiple-dep-versions-2.rs:4:1
  |
4 | pub trait Trait {
  | --------------- this is the trait that is needed
5 |     fn foo(&self);
  |        --- the method is available for `dep_2_reexport::Type` here
```
2024-08-12 19:29:47 +00:00
Zachary S
1b6df71192 Explicitly specify type parameter on FromResidual impls in stdlib.
To work around coherence issue. Also adds regression test.
2024-08-12 12:54:18 -05:00
schvv31n
027b19fa9b std::fmt::FormatterFn -> std::fmt::FromFn 2024-08-12 18:33:30 +01:00
rustbot
a719514777 Update books 2024-08-12 13:01:03 -04:00
Jakub Beránek
6863db5219 Remove unused script from run-make tests 2024-08-12 18:46:06 +02:00
bors
91376f4162 Auto merge of #129008 - GuillaumeGomez:rollup-6citttb, r=GuillaumeGomez
Rollup of 10 pull requests

Successful merges:

 - #128149 (nontemporal_store: make sure that the intrinsic is truly just a hint)
 - #128394 (Unify run button display with "copy code" button and with mdbook buttons)
 - #128537 (const vector passed through to codegen)
 - #128632 (std: do not overwrite style in `get_backtrace_style`)
 - #128878 (Slightly refactor `Flags` in bootstrap)
 - #128886 (Get rid of some `#[allow(rustc::untranslatable_diagnostic)]`)
 - #128929 (Fix codegen-units tests that were disabled 8 years ago)
 - #128937 (Fix warnings in rmake tests on `x86_64-unknown-linux-gnu`)
 - #128978 (Use `assert_matches` around the compiler more)
 - #128994 (Fix bug in `Parser::look_ahead`.)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-12 16:31:22 +00:00
Rémy Rakic
2abfa35acd add change tracker notice 2024-08-12 15:28:39 +00:00
Rémy Rakic
ee5d15ce43 regenerate ./x completions
to pick up changes to `./x miri` and `./x test` commands
2024-08-12 15:28:39 +00:00
Rémy Rakic
5e872568a8 rename ./x test's --rustc-args to --compiletest-rustc-args 2024-08-12 15:28:38 +00:00