Commit Graph

230660 Commits

Author SHA1 Message Date
Nicholas Nethercote
4ebf2be8bb Remove Iterator impl for TokenTreeCursor.
This is surprising, but the new comment explains why. It's a logical
conclusion in the drive to avoid `TokenTree` clones.

`TokenTreeCursor` is now only used within `Parser`. It's still needed
due to `replace_prev_and_rewind`.
2023-07-27 11:59:03 +10:00
Nicholas Nethercote
ee6ed60373 Avoid into_trees usage in rustfmt.
Token tree cloning is only needed in one place.
2023-07-27 11:58:42 +10:00
Nicholas Nethercote
d2f7f67921 Avoid some token tree cloning in decl macro parsing.
By changing `into_trees` into `trees`. Some of the subsequent paths
require explicit clones, but not all.
2023-07-27 11:58:42 +10:00
Nicholas Nethercote
853f453d57 Avoid some token cloning in filter_tokens_from_list.
Now the cloning only happens on some paths, instead of all paths.
2023-07-27 11:58:42 +10:00
Nicholas Nethercote
55a732461d Make TokenTree::uninterpolate take &self and return a Cow.
Making it similar to `Token::uninterpolate`. This avoids some more token
tree cloning.
2023-07-27 11:58:42 +10:00
Nicholas Nethercote
103bd4a820 Use TokenStream::trees instead of into_trees for attributes.
This avoids cloning some token trees. A couple of `clone` calls were
inserted, but only on some paths, and the next commit will remove them.
2023-07-27 11:58:42 +10:00
bors
e7d6ce3a6f Auto merge of #114034 - Amanieu:riscv-atomicbool, r=thomcc
Optimize `AtomicBool` for target that don't support byte-sized atomics

`AtomicBool` is defined to have the same layout as `bool`, which means that we guarantee that it has a size of 1 byte. However on certain architectures such as RISC-V, LLVM will emulate byte atomics using a masked CAS loop on an aligned word.

We can take advantage of the fact that `bool` only ever has a value of 0 or 1 to replace `swap` operations with `and`/`or` operations that LLVM can lower to word-sized atomic `and`/`or` operations. This takes advantage of the fact that the incoming value to a `swap` or `compare_exchange` for `AtomicBool` is often a compile-time constant.

### Example

```rust
pub fn swap_true(atomic: &AtomicBool) -> bool {
    atomic.swap(true, Ordering::Relaxed)
}
```

### Old

```asm
	andi	a1, a0, -4
	slli	a0, a0, 3
	li	a2, 255
	sllw	a2, a2, a0
	li	a3, 1
	sllw	a3, a3, a0
	slli	a3, a3, 32
	srli	a3, a3, 32
.LBB1_1:
	lr.w	a4, (a1)
	mv	a5, a3
	xor	a5, a5, a4
	and	a5, a5, a2
	xor	a5, a5, a4
	sc.w	a5, a5, (a1)
	bnez	a5, .LBB1_1
	srlw	a0, a4, a0
	andi	a0, a0, 255
	snez	a0, a0
	ret
```

### New

```asm
	andi	a1, a0, -4
	slli	a0, a0, 3
	li	a2, 1
	sllw	a2, a2, a0
	amoor.w	a1, a2, (a1)
	srlw	a0, a1, a0
	andi	a0, a0, 255
	snez	a0, a0
	ret
```
2023-07-27 01:00:12 +00:00
Nicholas Nethercote
a9d8459299 Replace into_trees with trees in a test.
There's no need for token tree cloning here.
2023-07-27 10:40:39 +10:00
Nicholas Nethercote
53379a7b65 Simplify the ttdelim_span test.
The existing code is a very complex and inefficient way to the get the
span of the last token.
2023-07-27 09:41:49 +10:00
Josh Stone
3cd3a91dbc ci: use armv7-a+fp for armv7-unknown-linux_musleabihf
This is consistent with what we had from `arm-linux-gnueabihf-gcc` in
the `ubuntu:20.04` base.
2023-07-26 16:00:05 -07:00
Veera
0169ce968c Fix URL for rmatches 2023-07-26 17:57:56 -05:00
jyn
37216f85a1 Prevent people from assigning me as a PR reviewer 2023-07-26 14:43:15 -07:00
bors
0d95f91329 Auto merge of #113843 - wesleywiser:replace_rustc_apfloat, r=pnkfelix
Replace in-tree `rustc_apfloat` with the new version of the crate

Replace the in-tree version of `rustc_apfloat` with the new version of the crate which has been correctly licensed. The new crate incorporates upstream changes from LLVM since the original port was done including many correctness fixes and has been extensively fuzz tested to validate correctness.

Fixes #100233
Fixes #102403
Fixes #113407
Fixes #113409
Fixes #55993
Fixes #93224
Closes #93225
Closes #109573
2023-07-26 21:21:19 +00:00
Joel Dice
6776265d1b
Update LLVM submodule
This adds https://github.com/rust-lang/llvm-project/pull/148.
2023-07-26 14:55:50 -06:00
Trevor Gross
9439e02fb2 Unite bless environment variables under RUSTC_BLESS
Currently, Clippy, Miri, Rustfmt, and rustc all use an environment variable to
indicate that output should be blessed, but they use different variable names.
In order to improve consistency, this patch applies the following changes:

- Emit `RUSTC_BLESS` within `prepare_cargo_test` so it is always
  available
- Change usage of `MIRI_BLESS` in the Miri subtree to use `RUSTC_BLESS`
- Change usage of `BLESS` in the Clippy subtree to `RUSTC_BLESS`
- Change usage of `BLESS` in the Rustfmt subtree to `RUSTC_BLESS`
- Adjust the blessable test in `rustc_errors` to use this same
  convention
- Update documentation where applicable

Any tools that uses `RUSTC_BLESS` should check that it is set to any value
other than `"0"`.
2023-07-26 16:54:02 -04:00
bors
fb7e6d078d Auto merge of #114103 - matthiaskrgr:rollup-01m6l2w, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #101994 (rand: freebsd update, using getrandom.)
 - #113930 (Add Param and Bound ty to SMIR)
 - #113942 (Squelch a noisy rustc_expand unittest)
 - #113996 (Define CMAKE_SYSTEM_NAME on a cross build targeting DragonFly.)
 - #114070 (Add `sym::iter_mut` + `sym::as_mut_ptr` for Clippy)
 - #114073 (Remove -Z diagnostic-width)
 - #114090 (compiletest: remove ci-specific remap-path-prefix)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-07-26 19:21:47 +00:00
Matthias Krüger
a1956e281a
Rollup merge of #114090 - mdibaiee:remove-remap-path-prefix-ci, r=wesleywiser
compiletest: remove ci-specific remap-path-prefix

Now that we have fixed the underlying cause of long type name inconsistencies in #113893, we can remove the remap-path-prefix logic from CI

resolves #113424
2023-07-26 20:49:14 +02:00
Matthias Krüger
43a38e7e55
Rollup merge of #114073 - ehuss:remove-z-diagnostic-width, r=fee1-dead
Remove -Z diagnostic-width

This removes the `-Z diagnostic-width` option since it is ignored and does nothing. `-Z diagnostic-width` was stabilized as `--diagnostic-width` in #95635. It is not entirely clear why the `-Z` flag was kept, but in part its final use was removed in #102216, but the `-Z` flag itself was not removed.
2023-07-26 20:49:14 +02:00
Matthias Krüger
c6bfa7761a
Rollup merge of #114070 - blyxyas:iter_mut_symbol, r=oli-obk
Add `sym::iter_mut` + `sym::as_mut_ptr` for Clippy

We currently have `sym::iter` and `sym::iter_repeat`, this PR adds `sym::iter_mut` as it's useful for https://github.com/rust-lang/rust-clippy/pull/11038 and another Clippy lint, it also adds `sym::as_mut_ptr` as it's useful for https://github.com/rust-lang/rust-clippy/pull/10962.
2023-07-26 20:49:13 +02:00
Matthias Krüger
998fd94405
Rollup merge of #113996 - inferiorhumanorgans:dragonfly-cmake-system-name, r=ozkanonur
Define CMAKE_SYSTEM_NAME on a cross build targeting DragonFly.

Without `CMAKE_SYSTEM_NAME` set to the target  a cross compile will generally fail.  Related to #109170.
2023-07-26 20:49:13 +02:00
Matthias Krüger
d35cf499d8
Rollup merge of #113942 - ehuss:squelch-bad_path_expr_1, r=fee1-dead
Squelch a noisy rustc_expand unittest

The test `rustc_parse::tests::bad_path_expr_1` prints an error message to stderr, circumventing libtest's stderr intercept. This causes noise when running tests, in particular they show up 16 times on the GitHub Actions summary page. The solution here is to not use an error emitter that prints to stderr, and instead check that the correct error is generated.
2023-07-26 20:49:12 +02:00
Matthias Krüger
d910e7d9eb
Rollup merge of #113930 - spastorino:smir-types-6, r=oli-obk
Add Param and Bound ty to SMIR

r? ``@oli-obk``
2023-07-26 20:49:12 +02:00
Matthias Krüger
26d791b351
Rollup merge of #101994 - devnexen:rand_fbsd_update, r=workingjubilee
rand: freebsd update, using getrandom.

supported since the 12th release, while 11.4 is EOL since 2021.
2023-07-26 20:49:11 +02:00
Michael Goulet
1794466c00 Dont pass -Zwrite-long-types-to-disk=no for ui-fulldeps --stage=1 2023-07-26 18:43:40 +00:00
bors
6908c73ab0 Auto merge of #114012 - GuillaumeGomez:fix-113982, r=notriddle
Fix missing attribute merge on glob foreign re-exports

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

The attributes were not merged with the import's in case of glob re-export of foreign items.

r? `@notriddle`
2023-07-26 17:35:51 +00:00
Ralf Jung
9d3e35ceaa Add tests for #102403 and #113407 2023-07-26 13:31:54 -04:00
yukang
98dd81e4e3 Add test case for #109567 2023-07-26 13:31:54 -04:00
bors
601a34de8c Auto merge of #113457 - davidtwco:lint-ctypes-issue-113436, r=oli-obk
lint/ctypes: fix `()` return type checks

Fixes #113436.

`()` is normally FFI-unsafe, but is FFI-safe when used as a return type. It is also desirable that a transparent newtype for `()` is FFI-safe when used as a return type.

In order to support this, when a type was deemed FFI-unsafe, because of a `()` type, and was used in return type - then the type was considered  FFI-safe. However, this was the wrong approach - it didn't check that the `()` was part of a transparent newtype! The consequence of this is that the presence of a `()` type in a more complex return type would make it the entire type be considered safe (as long as the `()` type was the first that the lint found) - which is obviously incorrect.

Instead, this logic is removed, and after [consultation with t-lang](https://github.com/rust-lang/rust/issues/113436#issuecomment-1640756721), I've fixed the bugs and inconsistencies and  made `()` FFI-safe within types.

I also refactor a function, but that's not too exciting.
2023-07-26 15:27:36 +00:00
Eric Huss
9914ae3292 Squelch a noisy rustc_expand unittest 2023-07-26 08:12:08 -07:00
klensy
31630859cc replace atty crate with std's isTerminal 2023-07-26 18:09:50 +03:00
Wesley Wiser
47a4484a78 Remove unused NCSA license 2023-07-26 10:20:15 -04:00
Wesley Wiser
6f5d960389 Fix miri 2023-07-26 10:20:15 -04:00
Wesley Wiser
15e9f56088 Replace in-tree rustc_apfloat with the new version of the crate 2023-07-26 10:20:15 -04:00
Guillaume Gomez
51eb0c3b36 Fix regression for private in public 2023-07-26 15:29:45 +02:00
MoskalykA
48e7f3e313 Have a better file name than just the issue id 2023-07-26 15:07:57 +02:00
bors
bd9785cce8 Auto merge of #114071 - RalfJung:interpret-generic-read-write, r=oli-obk
interpret: make read/write methods generic

Instead of always having to call `into()` to convert things to `PlaceTy`/`OpTy`, make the relevant methods generic. This also means that when we read from an `MPlaceTy`, we avoid creating an intermediate `PlaceTy`.

This makes it feasible to remove the `Copy` from `MPlaceTy`. All the other `*Ty` interpreter types already had their `Copy` removed a while ago so this is only consistent. (And in fact we had one function that accidentally took `MPlaceTy` instead of `&MPlaceTy`.)
2023-07-26 13:06:25 +00:00
Santiago Pastorino
7af1697138
Add Bound ty to SMIR 2023-07-26 09:26:39 -03:00
Santiago Pastorino
648cf070eb
Add Param ty to SMIR 2023-07-26 09:26:39 -03:00
Bruce Mitchener
9f47ff84e3 docs: fmt::Debug*: Fix comments for finish method.
In the code sample for the `finish` method on `DebugList`,
`DebugMap`, and `DebugSet`, refer to finishing the list, map, or
set, rather than struct as it did.
2023-07-26 19:02:26 +07:00
Martin Nordholts
075a6bbef9 Regression test println!() panic message on ErrorKind::BrokenPipe
No existing test failed if the [`panic!()`][1] of the `println!()`
family of functions was removed, or if its message was changed.

So add such a test.

[1] 104f4300cf/library/std/src/io/stdio.rs (L1007-L1009)
2023-07-26 13:41:39 +02:00
bors
52bdc37727 Auto merge of #114054 - oli-obk:cleanups, r=estebank
Split some functions with many arguments into builder pattern functions

r? `@estebank`

This doesn't resolve all of the ones in rustc, mostly because I need to do other cleanups in order to be able to use some builder derives from crates.io

Works around https://github.com/rust-lang/rust/issues/90672 by making `x test rustfmt --bless` format itself instead of testing that it is formatted
2023-07-26 11:17:35 +00:00
Mahdi Dibaiee
7d773c3304 compiletest: remove ci-specific remap-path-prefix
Now that we have fixed the underlying cause of long type name
inconsistencies in #113893, we can remove the remap-path-prefix logic
from CI
2023-07-26 10:55:51 +01:00
Ralf Jung
571e8ce777 valtree: a bit of cleanup 2023-07-26 11:45:35 +02:00
Oli Scherer
ad8303739f Bump syn dependency 2023-07-26 08:42:40 +00:00
Oli Scherer
cf325e8187 Bump syn now that it doesn't affect diagnostics anymore 2023-07-26 08:26:50 +00:00
Oli Scherer
841f8dc19f Make x test src/tools/rustfmt --bless format rustfmt with the freshly built in-tree version 2023-07-26 08:22:52 +00:00
bors
a6236fa460 Auto merge of #102757 - pcc:android-std-tests, r=workingjubilee
Make std tests pass on newer Android

Newer versions of Android forbid the creation of hardlinks as well as Unix domain sockets in the /data filesystem via SELinux rules, which causes several tests depending on this behavior to fail. So let's skip these tests on Android if we see an EACCES from one of these syscalls. To achieve this, introduce a macro with the horrible name of or_panic_or_skip_on_android_eacces (better suggestions welcome) which skips (returns from) the test if an EACCES return value is seen on Android.
2023-07-26 07:57:32 +00:00
bors
cf34adb0dd Auto merge of #113583 - asquared31415:tidy_no_issue_tests, r=workingjubilee
add tidy check that forbids issue-XXXX and ice-XXXX test filenames

Helps with #113345 by preventing any future tests with non-descriptive names from being added.

This PR only checks modified ui test files because there are far too many existing problematic tests to be fixed at once:
3063/15424 (~19.86%) `*.rs` ui test files match `^issue[-_ ]?\d+$`.
Another 1349 files, totaling ~28.60% of all ui test files, contain that pattern in addition to some other text, where they should probably omit it in favor of a comment.

note: between the creation of this PR and 2023-07-25 (14 days), 10 more tests were added that failed this check.

r? `@workingjubilee`
2023-07-26 04:35:37 +00:00
Eric Mark Martin
933fc180bd add stable NullaryOp 2023-07-26 00:22:38 -04:00
asquared31415
13e2abf6b3 add tidy check that forbids issue ui test filenames 2023-07-26 00:03:10 -04:00