Commit Graph

267031 Commits

Author SHA1 Message Date
Trevor Gross
1f52c07528
Rollup merge of #130752 - tdittr:cmse-assembly-tests, r=jieyouxu
Improve assembly test for CMSE ABIs

Tracking issues: #75835 #81391

This ensures the code-gen for these ABIs does not change silently. There is a small chance that this code-gen might change, however even GCC (https://godbolt.org/z/16arxab5x and https://godbolt.org/z/16arxab5x) generates almost the same assembly for these ABIs. I hope the notes in the comments should help fix the tests if it ever breaks.
2024-09-24 19:47:49 -04:00
Trevor Gross
75296fc721
Rollup merge of #130234 - lukas-code:ptr-cast-errors, r=WaffleLapkin
improve compile errors for invalid ptr-to-ptr casts with trait objects

This is a follow-up to https://github.com/rust-lang/rust/pull/120248 to improve some of its error messages.

1. Make the borrowcheck error for "type annotation requires that x must outlive y" actually point at the type annotation, i.e. the type `T` in a `x as T` cast. This makes the error more consistent with other errors caused by type annotation in other places, such as
```text
error: lifetime may not live long enough
 --> src/lib.rs:4:12
  |
3 | fn bar(a: &i32) {
  |           - let's call the lifetime of this reference `'1`
4 |     let b: &'static i32 = a;
  |            ^^^^^^^^^^^^ type annotation requires that `'1` must outlive `'static`
```

2. Don't say "cast" when we actually mean "coercion" and give borrowcheck errors from actual casts (which is currently just the check added in https://github.com/rust-lang/rust/pull/120248) a higher priority than ones from coercions. This can improve the errors for ptr-to-ptr cast between trait objects because they are are lowered as an upcast "unsizing" coercion if possible (which may be the identity upcast) followed by the actual cast.

3. Bring back the old "casting X as Y is invalid" message for type mismatch in the principals and reword the "vtable kinds may not match" message to more accurately describe the pointer metadata and not refer to "vtables" if the metadata is unknown.

fixes https://github.com/rust-lang/rust/issues/130030

r? `@WaffleLapkin` but feel free to reassign
2024-09-24 19:47:48 -04:00
bors
3f99982c63 Auto merge of #130739 - jieyouxu:stage0_run_make, r=Kobzol
Fix cargo staging for run-make tests

Follow-up to https://github.com/rust-lang/rust/pull/130642#issuecomment-2366891866 to make sure that when

```
$ COMPILETEST_FORCE_STAGE0=1 ./x test run-make --stage 0
```

is used, bootstrap cargo is used in order to avoid building stage 1 rustc. Note that run-make tests are usually not written with `--stage 0` in mind and some tests may rely on stage1 rustc (nightly) behavior, and it is expected that some tests will fail under this invocation.

This PR also fixes `tool::Cargo` staging in compiletest when preparing for `run-make` test mode, by chopping off a stage from the `compiler` passed to `tool::Cargo` such that when the user invokes with stage `N`

```
./x test run-make --stage N
```

the `run-make` test suite will be tested against the cargo built by stage `N` compiler. Let's take `N=1`, i.e. `--stage 1`, without chopping off a stage, previously `./x test run-make --stage 1` will cause stage 1 rustc + std to be built, then stage 2 rustc, and cargo will be produced by the stage 2 rustc, which is clearly not what we want. By chopping off a stage, it means that cargo will be produced by the stage 1 rustc.

cc #119946, #59864.
See discussions regarding the tool staging at https://rust-lang.zulipchat.com/#narrow/stream/326414-t-infra.2Fbootstrap/topic/.E2.9C.94.20stage1.20run-make.20tests.20now.20need.20stage2.20rustc.20built.20for.20c.2E.2E.2E.
2024-09-24 22:51:43 +00:00
Josh Stone
458537ebc0 Add a tracking issue for file_buffered 2024-09-24 15:06:55 -07:00
Josh Stone
0999b019f8 Dogfood feature(file_buffered) 2024-09-24 14:25:16 -07:00
Lukas Markeffsky
b62e72ce8c update doc comment 2024-09-24 23:12:02 +02:00
Lukas Markeffsky
39f66baa68 improve errors for invalid pointer casts 2024-09-24 23:12:02 +02:00
Lukas Markeffsky
bd31e3ed70 be even more precise about "cast" vs "coercion" 2024-09-24 23:12:02 +02:00
Josh Stone
1e9a50dde8 Pre-allocate buffers in File::open_buffered and create_buffered 2024-09-24 13:33:31 -07:00
Josh Stone
ee129b12ed Add File::open_buffered and create_buffered 2024-09-24 13:32:29 -07:00
Lukas Markeffsky
5e60d1f87e replace "cast" with "coercion" where applicable
This changes the remaining span for the cast, because the new `Cast`
category has a higher priority (lower `Ord`) than the old `Coercion`
category, so we no longer report the region error for the "unsizing"
coercion from `*const Trait` to itself.
2024-09-24 22:20:46 +02:00
Lukas Markeffsky
d1e82d438f use more accurate spans for user type ascriptions 2024-09-24 22:20:42 +02:00
Lukas Markeffsky
b52dea8230 add another test 2024-09-24 22:18:00 +02:00
Lukas Markeffsky
46ecb23198 unify dyn* coercions with other pointer coercions 2024-09-24 22:17:55 +02:00
bors
363ae41883 Auto merge of #129587 - Voultapher:opt-for-size-variants-of-sort-impls, r=cuviper
Add `optimize_for_size` variants for stable and unstable sort as well as select_nth_unstable

- Stable sort uses a simple merge-sort that re-uses the existing - rather gnarly - merge function.
- Unstable sort jumps directly to the branchless heapsort fallback.
- select_nth_unstable jumps directly to the median_of_medians fallback, which is augmented with a custom tiny smallsort and partition impl.

Some code is duplicated but de-duplication would bring it's own problems. For example `swap_if_less` is critical for performance, if the sorting networks don't inline it perf drops drastically, however `#[inline(always)]` is also a poor fit, if the provided comparison function is huge, it gives the compiler an out to only instantiate `swap_if_less` once and call it. Another aspect that would suffer when making `swap_if_less` pub, is having to cfg out dozens of functions in in smallsort module.

Part of https://github.com/rust-lang/rust/issues/125612

r​? `@Kobzol`
2024-09-24 18:48:08 +00:00
Lukas Markeffsky
2fdeb3b8f4 rustdoc: inherit parent's stability where applicable 2024-09-24 20:18:36 +02:00
Aviram Hassan
46fd76e9a5
add InProgress ErrorKind gated behind io_error_inprogress feature
Co-authored-by: David Tolnay <dtolnay@gmail.com>
Co-authored-by: nora <48135649+Noratrieb@users.noreply.github.com>
2024-09-24 20:49:56 +03:00
许杰友 Jieyou Xu (Joe)
50729fe6ca Mention COMPILETEST_VERBOSE_CRASHES on crash test failure 2024-09-24 17:02:47 +00:00
Philipp Krones
e60098bf8c
Remove unused import from Clippy versions.py file 2024-09-24 18:13:17 +02:00
Trevor Gross
e95d15a115 Pin memchr to 2.5.0 in the library rather than rustc_ast
The latest versions of `memchr` experience LTO-related issues when
compiling for windows-gnu [1], so needs to be pinned. The issue is
present in the standard library.

`memchr` has been pinned in `rustc_ast`, but since the workspace was
recently split, this pin no longer has any effect on library crates.

Resolve this by adding `memchr` as an _unused_ dependency in `std`,
pinned to 2.5. Additionally, remove the pin in `rustc_ast` to allow
non-library crates to upgrade to the latest version.

Link: https://github.com/rust-lang/rust/issues/127890 [1]
2024-09-24 18:09:43 +02:00
bors
316a15c9c4 Auto merge of #18164 - ShoyuVanilla:use-as-alias, r=Veykril
fix: Temporary fix for `remove_unused_imports` not handling import aliases correctly

Fixes #18129
2024-09-24 15:22:57 +00:00
Michael Goulet
ead569a06d Ban combination of GCE and new solver 2024-09-24 10:53:32 -04:00
bors
67bb749c2e Auto merge of #130775 - jieyouxu:revert-129047, r=nagisa
Revert "Apply EarlyOtherwiseBranch to scalar value #129047"

This reverts PR #129047, commit a772336fb3, reversing changes made to 702987f75b.

cc `@DianQK` and `@cjgillot` as the PR author and reviewer of #129047 respectively.

It seems [Apply EarlyOtherwiseBranch to scalar value #129047](https://github.com/rust-lang/rust/pull/129047) may have lead to several nightly regressions:

- https://github.com/rust-lang/rust/issues/130769
- https://github.com/rust-lang/rust/issues/130774
- https://github.com/rust-lang/rust/issues/130771

Example test that would ICE with changes in #129047 (this test is included in this PR):

```rs
//@ compile-flags: -C opt-level=3
//@ check-pass

use std::task::Poll;

pub fn poll(val: Poll<Result<Option<Vec<u8>>, u8>>) {
    match val {
        Poll::Ready(Ok(Some(_trailers))) => {}
        Poll::Ready(Err(_err)) => {}
        Poll::Ready(Ok(None)) => {}
        Poll::Pending => {}
    }
}
```

Since this is a mir-opt ICE that seems to quite easy to trigger with real-world crates being affected, let's revert for now and reland the mir-opt after these are fixed.
2024-09-24 14:52:06 +00:00
Shoyu Vanilla
8ca54f24e0 fix: Temporary fix for remove_unused_imports not handling import aliases correctly 2024-09-24 23:48:04 +09:00
Michael Goulet
28f69805de Fix tools 2024-09-24 10:12:05 -04:00
Michael Goulet
cfb8419900 Separate collection of crate-local inherent impls from error reporting 2024-09-24 10:12:05 -04:00
bors
4cbfcf1b7f Auto merge of #130389 - Luv-Ray:LLVMMDNodeInContext2, r=nikic
llvm: replace some deprecated functions

`LLVMMDStringInContext` and `LLVMMDNodeInContext` are deprecated, replace them with `LLVMMDStringInContext2` and `LLVMMDNodeInContext2`.
Also replace `Value` with `Metadata` in some function signatures for better consistency.
2024-09-24 12:07:48 +00:00
monkeydbobo
802bf71ece Fix up setting strip = true in Cargo.toml makes build scripts fail in release mode on MacOS 2024-09-24 19:51:11 +08:00
许杰友 Jieyou Xu (Joe)
f548216728 Update run-make tests to use cargo wrapper cmd 2024-09-24 19:04:51 +08:00
许杰友 Jieyou Xu (Joe)
53897921bd Fix run-make-support to respect per-stage cargo 2024-09-24 19:04:51 +08:00
许杰友 Jieyou Xu (Joe)
705ab171a4 Fix tool cargo being off-by-one from rustc staging
Previously if you pass compiler stage 1 to `tool::Cargo`, it will build
stage2 rustc and give you back a cargo built with stage2 rustc, which is
not what we want.

This commit adds a hack that chops off a stage from the compiler passed
to `tool::Cargo`, meaning that we will get a cargo built with stage 1
compiler, avoiding unnecessary and incorrect build of stage2 rustc and
the cargo built by that.
2024-09-24 19:04:51 +08:00
bors
ceb495a4d0 Auto merge of #18166 - ChayimFriedman2:dollar-crate-root, r=Veykril
fix: Fix a bug in span map merge, and add explanations of how span maps are stored

Because it took me hours to figure out that contrary to common sense, the offset stored is the *end* of the node, and we search by the *start*. Which is why we need a convoluted `partition_point()` instead of a simple `binary_search()`. And this was not documented at all. Which made me make mistakes with my implementation of `SpanMap::merge()`.

The other bug fixed about span map merging is correctly keeping track of the current offset in presence of multiple sibling macro invocations. Unrelated, but because of the previous issue it took me hours to debug, so I figured out I'll put them together for posterity.

Fixes #18163.
2024-09-24 11:01:05 +00:00
bors
a5f028b595 Auto merge of #18161 - ChayimFriedman2:postfix-mut, r=Veykril
fix: Better support references in consuming postfix completions

Fixes #18155.
2024-09-24 10:46:48 +00:00
bors
a8eaa9ed35 Auto merge of #18160 - ChayimFriedman2:fix-18138, r=Veykril
fix: Fix name resolution when an import is resolved to some namespace and then later in the algorithm another namespace is added

The import is flagged as "indeterminate", and previously it was re-resolved, but only at the end of name resolution, when it's already too late for anything that depends on it.

This issue was tried to fix in https://github.com/rust-lang/rust-analyzer/pull/2466, but it was not fixed fully.

That PR is also why IDE features did work: the import at the end was resolved correctly, so IDE features that re-resolved the macro path resolved it correctly.

I was concerned about the performance of this, but this doesn't seem to regress `analysis-stats .`, so I guess it's fine to land this. I have no idea about the incremental perf however and I don't know how to measure that, although when typing in `zbus` (including creating a new function, which should recompute the def map) completion was fast enough.

I didn't check what rustc does, so maybe it does something more performant, like keeping track of only possibly problematic imports.

Fixes #18138.
Probably fixes #17630.
2024-09-24 10:32:28 +00:00
bors
80c06828a2 Auto merge of #18157 - davidbarsky:davidbarsky/respect-disabling-proc-macros-in-analysis-stats, r=Veykril
analysis-stats: respect `--disable-proc-macros` flag

I noticed that this flag wasn't being respected by `analysis-stats` when profiling proc macro expansion, so here's a small fix.
2024-09-24 10:17:56 +00:00
bors
6ec41ab643 Auto merge of #18123 - jhgg:fix-ambigius-package-cargo-check, r=Veykril
fix: fix ambigious package name in flycheck

fixes #18121
2024-09-24 10:03:41 +00:00
Philipp Krones
f38b569ab6
Hotfix: remove profile from clippy Cargo.toml 2024-09-24 11:58:48 +02:00
Philipp Krones
907b6a1bc3
Update Cargo.lock 2024-09-24 11:58:12 +02:00
Philipp Krones
ae1c191467
Merge commit '7901289135257ca0fbed3a5522526f95b0f5edba' into clippy-subtree-update 2024-09-24 11:58:04 +02:00
bors
622c701c09 Auto merge of #18175 - Wilfred:completion_marker, r=Veykril
internal: Make COMPLETION_MARKER more explicitly r-a

If a user ever sees the completion marker, it's confusing to see text about IntelliJ. Use a string that's more explicitly about completion for rust-analyzer.
2024-09-24 09:49:25 +00:00
许杰友 Jieyou Xu (Joe)
ad7eb48ca9 Add regression test for #130769 2024-09-24 08:56:41 +00:00
bors
11e760b7f4 Auto merge of #130738 - bjoernager:const-make-ascii, r=jhpratt
Mark `make_ascii_uppercase` and `make_ascii_lowercase` in `[u8]` and `str` as const.

Relevant tracking issue: #130698

This PR extends #130697 and #130713 to the similar methods in byte slices (`[u8]`) and string slices (`str`).

For the `str` methods, this simply requires adding the `const` specifier to the function signatures. The `[u8]` methods, however, require (at least a temporary) reimplementation due to the use of iterators and `for` loops.
2024-09-24 08:52:12 +00:00
许杰友 Jieyou Xu (Joe)
16a02664e6 Revert "Auto merge of #129047 - DianQK:early_otherwise_branch_scalar, r=cjgillot"
This reverts commit a772336fb3, reversing
changes made to 702987f75b.

It seems Apply EarlyOtherwiseBranch to scalar value #129047 may have
lead to several nightly regressions:

- https://github.com/rust-lang/rust/issues/130769
- https://github.com/rust-lang/rust/issues/130774
- https://github.com/rust-lang/rust/issues/130771

And since this is a mir-opt ICE that seems to quite easy to trigger with
real-world crates being affected, let's revert for now and reland the
mir-opt later.
2024-09-24 08:44:26 +00:00
bors
5bc2e652a7 Auto merge of #18162 - ChayimFriedman2:gat-object-safe, r=Veykril
fix: Consider lifetime GATs object unsafe

Fixes #18156.
2024-09-24 08:14:00 +00:00
许杰友 Jieyou Xu (Joe)
6d132d9a5d Pass bootstrap cargo when --stage 0 and COMPILETST_FORCE_STAGE0
And stop passing `BOOTSTRAP_CARGO` as an env var, instead the provided
cargo should go through `--cargo-path.`
2024-09-24 15:45:36 +08:00
Huang Qi
24f622cf80 Initial std library support for NuttX
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2024-09-24 15:35:40 +08:00
Gabriel Bjørnager Jensen
e723fe1713 Mark and implement 'make_ascii_uppercase' and 'make_ascii_lowercase' in '[u8]' and 'str' as const; 2024-09-24 08:50:40 +02:00
bors
4cadeda932 Auto merge of #130768 - compiler-errors:rollup-8ncjy55, r=compiler-errors
Rollup of 7 pull requests

Successful merges:

 - #129545 (rustdoc: redesign toolbar and disclosure widgets)
 - #130618 (Skip query in get_parent_item when possible.)
 - #130727 (Check vtable projections for validity in miri)
 - #130750 (Add new Tier-3 target: `loongarch64-unknown-linux-ohos`)
 - #130758 (Revert "Add recursion limit to FFI safety lint")
 - #130759 (Update books)
 - #130762 (stabilize const_intrinsic_copy)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-09-24 06:02:43 +00:00
Michael Goulet
64aa4c6e25
Rollup merge of #130762 - RalfJung:const_intrinsic_copy, r=dtolnay
stabilize const_intrinsic_copy

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

This stabilizes
```rust
mod ptr {
    pub const unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);
    pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize);
}

impl *const T {
    pub const unsafe fn copy_to(self, dest: *mut T, count: usize);
    pub const unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize);
}

impl *mut T {
    pub const unsafe fn copy_to(self, dest: *mut T, count: usize);
    pub const unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize);

    pub const unsafe fn copy_from(self, src: *const T, count: usize);
    pub const unsafe fn copy_from_nonoverlapping(self, src: *const T, count: usize);
}

impl <T> NonNull<T> {
    pub const unsafe fn copy_to(self, dest: NonNull<T>, count: usize);
    pub const unsafe fn copy_to_nonoverlapping(self, dest: NonNull<T>, count: usize);

    pub const unsafe fn copy_from(self, src: NonNull<T>, count: usize);
    pub const unsafe fn copy_from_nonoverlapping(self, src: NonNull<T>, count: usize);
}
```
In particular, this reverts https://github.com/rust-lang/rust/pull/117905, which reverted https://github.com/rust-lang/rust/pull/97276.

The `NonNull` methods are not listed in the tracking issue, they were added to this feature gate in https://github.com/rust-lang/rust/pull/124498. The existing [FCP](https://github.com/rust-lang/rust/issues/80697#issuecomment-1022585839) does not cover them. They are however entirely identical to the `*mut` methods and already stable outside `const`. ``@rust-lang/libs-api`` please let me know if FCP will be required for the `NonNull` methods.
2024-09-23 23:49:14 -04:00
Michael Goulet
fdd4d644aa
Rollup merge of #130759 - rustbot:docs-update, r=ehuss
Update books

## rust-lang/book

5 commits in e7d217be2a75ef1753f0988d6ccaba4d7e376259..99cf75a5414fa8adbe3974bd0836661ca901708f
2024-09-23 16:18:39 UTC to 2024-09-11 18:38:03 UTC

- translations: remove broken link (rust-lang/book#4036)
- Update build instructions: include mdbook plugins (rust-lang/book#4032)
- Add `cargo init` usage suggestion to 1.3 (rust-lang/book#4025)
- Use immutable borrow of `TcpStream` when creating `BufReader` (rust-lang/book#4024)
- Upgrade to Rust 1.81 (rust-lang/book#4031)

## rust-lang/edition-guide

1 commits in b3ca7ade0f87d7e3fb538776defc5b2cc4188172..c7ebae25cb4801a31b6f05353f6d85bfa6feedd1
2024-09-22 08:47:02 UTC to 2024-09-22 08:47:02 UTC

- Update static_mut_refs now that it is a lint (rust-lang/edition-guide#322)

## rust-lang/reference

10 commits in 687faf9958c52116d003b41dfd29cc1cf44f5311..24fb2687cdbc54fa18ae4acf5d879cfceca77b2c
2024-09-22 09:07:12 UTC to 2024-09-10 19:24:17 UTC

- do not talk about the 'address of a constant' (rust-lang/reference#1624)
- Add spec identifier syntax to interior-mutability.md (rust-lang/reference#1585)
- Add spec identifier syntax to input-format.md (rust-lang/reference#1584)
- Document limitations on block doc comments (rust-lang/reference#1602)
- Places based on misaligned pointers: also mention 'static's as a possible base for place projections (rust-lang/reference#1606)
- type-layout: mention that call ABI compatibility is a separate concern (rust-lang/reference#1608)
- stabilize `const_extern_fn` (rust-lang/reference#1596)
- const_eval: update for const_mut_refs and const_refs_to_cell stabilization (rust-lang/reference#1590)
- fix: unclosed tag `sup` (rust-lang/reference#1612)
- Fix improper documentation on casting non_exhaustive enums (rust-lang/reference#1607)

## rust-lang/rustc-dev-guide

13 commits in 0ed9229f5b6f7824b333beabd7e3d5ba4b9bd971..555f3de2fa0d61c4294b74d245f1cbad6fcbf589
2024-09-23 12:51:33 UTC to 2024-09-10 07:32:10 UTC

- chore: add missing `.` (rust-lang/rustc-dev-guide#2074)
- Add remark on required free disk space (rust-lang/rustc-dev-guide#2073)
- fix broken links (rust-lang/rustc-dev-guide#2063)
- Add advice about submitting potentially hard-to-review PRs (rust-lang/rustc-dev-guide#2036)
- Edit a sentence for clarity (rust-lang/rustc-dev-guide#2071)
- Emphasize how to run a single tool test (rust-lang/rustc-dev-guide#2070)
- Remove chalk is owned by WG-traits (rust-lang/rustc-dev-guide#2068)
- Fix conditions lowering text for enums with no fields (rust-lang/rustc-dev-guide#2066)
- update proof tree chapter (rust-lang/rustc-dev-guide#2054)
- Add docs for JS tests (rust-lang/rustc-dev-guide#2048)
- Reflect `x.py test`'s `--rustc-args` option being renamed to `--compiletest-rustc-args` (rust-lang/rustc-dev-guide#2062)
- we standardized on this more reliable command (rust-lang/rustc-dev-guide#2061)
- Fix Typo and Remove Outdated Line About C Variadics (rust-lang/rustc-dev-guide#2060)
2024-09-23 23:49:13 -04:00