Commit Graph

271030 Commits

Author SHA1 Message Date
许杰友 Jieyou Xu (Joe)
0b157e88d7
Rollup merge of #133060 - tyrone-wu:removelet-span-suggestion, r=jieyouxu
Trim whitespace in RemoveLet primary span

Separate `RemoveLet` span into primary span for `let` and removal suggestion span for `let `, so that primary span does not include whitespace.

Fixes: #133031
2024-11-17 23:56:09 +08:00
许杰友 Jieyou Xu (Joe)
2f62fd3d13
Rollup merge of #133051 - estebank:cond-misparse, r=jieyouxu
Increase accuracy of `if` condition misparse suggestion

Fix #132656.

Look at the expression that was parsed when trying to recover from a bad `if` condition to determine what was likely intended by the user beyond "maybe this was meant to be an `else` body".

```
error: expected `{`, found `map`
  --> $DIR/missing-dot-on-if-condition-expression-fixable.rs:4:30
   |
LL |     for _ in [1, 2, 3].iter()map(|x| x) {}
   |                              ^^^ expected `{`
   |
help: you might have meant to write a method call
   |
LL |     for _ in [1, 2, 3].iter().map(|x| x) {}
   |                              +
```

If a macro statement has been parsed after `else`, suggest a missing `if`:

```
error: expected `{`, found `falsy`
  --> $DIR/else-no-if.rs:47:12
   |
LL |     } else falsy! {} {
   |       ---- ^^^^^
   |       |
   |       expected an `if` or a block after this `else`
   |
help: add an `if` if this is the condition of a chained `else if` statement
   |
LL |     } else if falsy! {} {
   |            ++
```
2024-11-17 23:56:08 +08:00
许杰友 Jieyou Xu (Joe)
2d9690d2e7
Rollup merge of #133029 - veluca93:abi-checks-tier3, r=workingjubilee
ABI checks: add support for some tier3 arches, warn on others.

Followup to
- https://github.com/rust-lang/rust/pull/132842
- https://github.com/rust-lang/rust/pull/132173
- https://github.com/rust-lang/rust/issues/131800

r? ``@workingjubilee``
2024-11-17 23:56:08 +08:00
bors
1e0df74445 Auto merge of #133120 - matthiaskrgr:rollup-4actosy, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #131717 (Stabilize `const_atomic_from_ptr`)
 - #132134 (Remove `ResultsVisitable`)
 - #132449 (mark is_val_statically_known intrinsic as stably const-callable)
 - #132569 (rustdoc search: allow queries to end in an empty path segment)
 - #132787 (Unify FnKind between AST visitors and make WalkItemKind more straight forward)
 - #132832 (Deny capturing late-bound ty/const params in nested opaques)
 - #133097 (Opt out TaKO8Ki from review rotation for now)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-17 09:45:48 +00:00
bors
ee4a56e353 Auto merge of #132566 - saethlin:querify-mir-collection, r=cjgillot
Querify MonoItem collection

Factored out of https://github.com/rust-lang/rust/pull/131650. These changes are required for post-mono MIR opts, because the previous implementation would load the MIR for every Instance that we traverse (as well as invoke queries on it). The cost of that would grow massively with post-mono MIR opts because we'll need to load new MIR for every Instance, instead of re-using the `optimized_mir` for every Instance with the same DefId.

So the approach here is to add two new queries, `items_of_instance` and `size_estimate`, which contain the specific information about an Instance's MIR that MirUsedCollector and CGU partitioning need, respectively. Caching these significantly increases the size of the query cache, but that's justified by our improved incrementality (I'm sure walking all the MIR for a huge crate scales quite poorly).

This also changes `MonoItems` into a type that will retain the traversal order (otherwise we perturb a bunch of diagnostics), and will also eliminate duplicate findings. Eliminating duplicates removes about a quarter of the query cache size growth.

The perf improvements in this PR are inflated because rustc-perf uses `-Zincremental-verify-ich`, which makes loading MIR a lot slower because MIR contains a lot of Spans and computing the stable hash of a Span is slow. And the primary goal of this PR is to load less MIR. Some squinting at `collector profile_local perf-record +stage1` runs suggests the magnitude of the improvements in this PR would be decreased by between a third and a half if that flag weren't being used. Though this effect may apply to the regressions too since most are incr-full and this change also causes such builds to encode more Spans.
2024-11-17 06:39:47 +00:00
bors
5afd5ad29c Auto merge of #133094 - weihanglo:update-cargo, r=weihanglo
Update cargo

15 commits in 4a2d8dc636445b276288543882e076f254b3ae95..69e595908e2c420e7f0d1be34e6c5b984c8cfb84
2024-11-09 19:10:33 +0000 to 2024-11-16 01:26:11 +0000
- refactor(fingerprint): Track the intent for each use of `UnitHash` (rust-lang/cargo#14826)
- fix(toml): Update frontmatter parser for RFC 3503 (rust-lang/cargo#14792)
- docs(unstable): Move -Zwarnings from stable to unstable section (rust-lang/cargo#14827)
- Simplify English used in guide (rust-lang/cargo#14825)
- feat(resolver): Stabilize resolver v3 (rust-lang/cargo#14754)
- docs: Clean up doc comments (rust-lang/cargo#14823)
- fix(remove): On error, suggest other dependencies  (rust-lang/cargo#14818)
- Always include Cargo.lock in published crates (rust-lang/cargo#14815)
- fix(build-rs)!: Updates from an audit (rust-lang/cargo#14817)
- feat(rustdoc): diplay env vars in extra verbose mode  (rust-lang/cargo#14812)
- Migrate build-rs to the Cargo repo (rust-lang/cargo#14786)
- chore(ci): Check for clippy `correctness` (rust-lang/cargo#14796)
- git: do not validate submodules of fresh checkouts (rust-lang/cargo#14605)
- refactor: clone-on-write when needed for InternedString (rust-lang/cargo#14808)
- fix(docs): typo in cargo-fmt.md (rust-lang/cargo#14805)
2024-11-17 03:38:37 +00:00
bors
f2a35426b6 Auto merge of #133115 - jieyouxu:cdb, r=chrisdenton
Update cdb annotations for some debuginfo tests with cdb `10.0.26100.2161`

GitHub CI runners [recently updated to Windows Server 2022 (20241113)](https://github.com/actions/runner-images/releases/tag/win22%2F20241113.3) which included Windows Software Development Kit version `10.1.26100.1742`, which transitively shipped a `cdb` version `10.0.26100.2161`.

This changed some cdb output, causing 3 debuginfo tests to fail (see #133107, https://rust-lang.zulipchat.com/#narrow/channel/242791-t-infra/topic/msvc.20update.20causing.20debuginfo.20failures):

```
tests\debuginfo\numeric-types.rs
tests\debuginfo\range-types.rs
tests\debuginfo\unit-type.rs
```

I updated cdb annotations for these 3 tests locally with a matching `cdb` version. However, I am not by any means a cdb expert nor debuginfo expert, I just reblessed the tests to match whatever the new cdb version produces to unblock the tree. It is certainly possible that debuginfo improved/regressed/both with the newer cdb version.

try-job: x86_64-msvc
2024-11-16 20:24:49 +00:00
Jieyou Xu
dccb6c0f27 Mark numeric-types.rs as 64-bit only for now
This is to unblock the tree, a proper fix will need to be investigated.
I think the debuginfo test suite supports revisions, however debugger
directives do not respect such revisions, which is problematic.

It's that 32-bit and 64-bit msvc of course have different integer widths
for `isize` and `usize`, meaning their underlying integer is different
and thus printed differently.
2024-11-17 04:16:59 +08:00
Matthias Krüger
17a9a7e345
Rollup merge of #133097 - jieyouxu:opt-out-review-rotation, r=jieyouxu
Opt out TaKO8Ki from review rotation for now

Hi `@TaKO8Ki,` I'm opting you out from compiler/diagnostics review rotation for now because I *think* you're very busy recently. Please feel free to re-add yourself (or close this PR) whenever you have more time / feel like it.
2024-11-16 21:05:47 +01:00
Matthias Krüger
a1c98ca160
Rollup merge of #132832 - compiler-errors:late-ty, r=cjgillot
Deny capturing late-bound ty/const params in nested opaques

First, this reverts a7f609504c. I can't exactly remember why I approved this specific bit of https://github.com/rust-lang/rust/pull/132466; specifically, I don't know that the purpose of that commit is, and afaict we will never have an opaque that captures late-bound params through a const because opaques can't be used inside of anon consts. Am I missing something `@cjgillot?` Since I can't see a case where this matters, and no tests seem to fail.

The second commit adds a `deny_late_regions: bool` to distinguish `Scope::LateBoundary` which should deny *any* late-bound params or just ty/consts. Then, when resolving opaques we wrap ourselves in a `Scope::LateBoundary { deny_late_regions: false }` so that we deny late-bound ty/const, which fixes a bunch of ICEs that all vaguely look like `impl for<T> Trait<Assoc = impl OtherTrait<T>>`.

I guess this could be achieved other ways; for example, with a different scope kind, or maybe we could just reuse `Scope::Opaque`. But this seems a bit more verbose. I'm open to feedback anyways.

Fixes #131535
Fixes #131637
Fixes #132530

I opted to remove those crashes tests ^ without adding them as regular tests, since they're basically triggering uninteresting late-bound ICEs far off in the trait solver, and the reason that existing tests such as `tests/ui/type-alias-impl-trait/non-lifetime-binder-in-constraint.rs` don't ICE are kinda just coincidental (i.e. due to a missing impl block). I don't really feel motivated to add random permutations to tests just to exercise non-lifetime binders.

r? cjgillot
2024-11-16 21:05:46 +01:00
Matthias Krüger
6b47c6d786
Rollup merge of #132787 - maxcabrajac:fnctxt, r=petrochenkov
Unify FnKind between AST visitors and make WalkItemKind more straight forward

Unifying `FnKind` requires a bunch of changes to `WalkItemKind::walk` signature so I'll change them in one go

related to #128974

r? `@petrochenkov`
2024-11-16 21:05:46 +01:00
Matthias Krüger
eff2b7017d
Rollup merge of #132569 - lolbinarycat:rustdoc-search-path-end-empty-v2, r=notriddle
rustdoc search: allow queries to end in an empty path segment

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

this can be used to show all items in a module,
or all associated items for a type.
currently sufferes slightly due to case insensitivity, so `Option::` will also show items in the `option::` module.

it disables the checking of the last path element, otherwise only items with short names will be shown

r? `@notriddle`
2024-11-16 21:05:45 +01:00
Matthias Krüger
fb5bd7ffcc
Rollup merge of #132449 - RalfJung:is_val_statically_known, r=compiler-errors
mark is_val_statically_known intrinsic as stably const-callable

The intrinsic doesn't actually "do" anything in terms of language semantics, and we are already using it in stable const fn. So let's just properly mark it as stably const-callable to avoid needing `rustc_allow_const_fn_unstable` (and thus reducing noise and keeping the remaining `rustc_allow_const_fn_unstable` as a more clear signal).

Cc `@rust-lang/lang` usually you have to approve exposing intrinsics in const, but this intrinsic is basically just a compiler implementation detail. So FCP doesn't seem necessary.
Cc `@rust-lang/wg-const-eval`
2024-11-16 21:05:44 +01:00
Matthias Krüger
5c81dbf4fa
Rollup merge of #132134 - nnethercote:rm-ResultsVisitable, r=cjgillot
Remove `ResultsVisitable`

`ResultsVisitable` has annoyed me for a while. This PR removes it. Details in the individual commits.

r? `@cjgillot.`
2024-11-16 21:05:44 +01:00
Matthias Krüger
07b033649e
Rollup merge of #131717 - tgross35:stabilize-const_atomic_from_ptr, r=RalfJung
Stabilize `const_atomic_from_ptr`

The API is already stable since https://github.com/rust-lang/rust/pull/115719, but const stability was blocked on `const_mut_refs`. Since that was recently stabilized, const stabilize the following:

```rust
// core::atomic

impl AtomicBool { pub const unsafe fn from_ptr<'a>(ptr: *mut bool) -> &'a AtomicBool; }

impl<T> AtomicPtr<T> { pub const unsafe fn from_ptr<'a>(ptr: *mut *mut T) -> &'a AtomicPtr<T>; }

impl AtomicU8    { pub const unsafe fn from_ptr<'a>(ptr: *mut u8)    -> &'a AtomicU8;    }
impl AtomicU16   { pub const unsafe fn from_ptr<'a>(ptr: *mut u16)   -> &'a AtomicU16;   }
impl AtomicU32   { pub const unsafe fn from_ptr<'a>(ptr: *mut u32)   -> &'a AtomicU32;   }
impl AtomicU64   { pub const unsafe fn from_ptr<'a>(ptr: *mut u64)   -> &'a AtomicU64;   }
impl AtomicUsize { pub const unsafe fn from_ptr<'a>(ptr: *mut usize) -> &'a AtomicUsize; }

impl AtomicI8    { pub const unsafe fn from_ptr<'a>(ptr: *mut i8)    -> &'a AtomicI8;    }
impl AtomicI16   { pub const unsafe fn from_ptr<'a>(ptr: *mut i16)   -> &'a AtomicI16;   }
impl AtomicI32   { pub const unsafe fn from_ptr<'a>(ptr: *mut i32)   -> &'a AtomicI32;   }
impl AtomicI64   { pub const unsafe fn from_ptr<'a>(ptr: *mut i64)   -> &'a AtomicI64;   }
impl AtomicIsize { pub const unsafe fn from_ptr<'a>(ptr: *mut isize) -> &'a AtomicIsize; }
```
2024-11-16 21:05:43 +01:00
Esteban Küber
6913194b8e review comment: move logic to new method 2024-11-16 20:03:31 +00:00
Esteban Küber
c09c73b996 Reword suggestion message 2024-11-16 20:03:31 +00:00
Esteban Küber
629a69f3e2 Better account for else if macro conditions mising an if
If a macro statement has been parsed after `else`, suggest a missing `if`:

```
error: expected `{`, found `falsy`
  --> $DIR/else-no-if.rs:47:12
   |
LL |     } else falsy! {} {
   |       ---- ^^^^^
   |       |
   |       expected an `if` or a block after this `else`
   |
help: add an `if` if this is the condition of a chained `else if` statement
   |
LL |     } else if falsy! {} {
   |            ++
```
2024-11-16 20:03:31 +00:00
Esteban Küber
04fe839177 Increase accuracy of if condition misparse suggestion
Look at the expression that was parsed when trying to recover from a bad `if` condition to determine what was likely intended by the user beyond "maybe this was meant to be an `else` body".

```
error: expected `{`, found `map`
  --> $DIR/missing-dot-on-if-condition-expression-fixable.rs:4:30
   |
LL |     for _ in [1, 2, 3].iter()map(|x| x) {}
   |                              ^^^ expected `{`
   |
help: you might have meant to write a method call
   |
LL |     for _ in [1, 2, 3].iter().map(|x| x) {}
   |                              +
```
2024-11-16 20:03:31 +00:00
Jieyou Xu
e70df0909a Update cdb annotations for unit-type.rs with cdb 10.0.26100.2161 2024-11-17 00:50:54 +08:00
Jieyou Xu
94f3dcf601 Update cdb annotations for range-types.rs with cdb 10.0.26100.2161 2024-11-17 00:42:30 +08:00
Jieyou Xu
1503279593 Update cdb annotations for numeric-types with cdb 10.0.26100.2161 2024-11-17 00:33:40 +08:00
Jieyou Xu
dd688cb6c7 Opt out TaKO8Ki from review rotation for now 2024-11-16 16:51:39 +08:00
Weihang Lo
9922514d27
Update cargo 2024-11-16 00:32:03 -05:00
bors
46e8d20301 Auto merge of #130443 - veluca93:legacy-const-generics-fix, r=BoxyUwU
Fix ICE when passing DefId-creating args to legacy_const_generics.

r? BoxyUwU

Fixes #123077
Fixes #129150
2024-11-16 04:57:15 +00:00
Luca Versari
b462c68aee Fix ICE when passing DefId-creating args to legacy_const_generics. 2024-11-16 01:07:51 +01:00
bors
d3a4b1f46b Auto merge of #133086 - GuillaumeGomez:rollup-kbkfrkj, r=GuillaumeGomez
Rollup of 5 pull requests

Successful merges:

 - #132936 (For expr `return (_ = 42);` unused_paren lint should not be triggered)
 - #132956 (Add visit_coroutine_kind to ast::Visitor)
 - #132978 (Mention both release *and* edition breakage for never type lints)
 - #133074 (make UI test OS-agnostic)
 - #133080 (Fix span edition for 2024 RPIT coming from an external macro )

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-15 23:08:55 +00:00
Guillaume Gomez
fc8d2b38d8
Rollup merge of #133080 - ehuss:edition-desugar-span, r=compiler-errors
Fix span edition for 2024 RPIT coming from an external macro

This fixes a problem where code generated by an external macro with an RPIT would end up using the call-site edition instead of the macro's edition for the RPIT. When used from a 2024 crate, this caused the code to change behavior to the 2024 capturing rules, which we don't want.

This was caused by the impl-trait lowering code would replace the span with one marked with `DesugaringKind::OpaqueTy` desugaring. However, it was also overriding the edition of the span with the edition of the local crate. Instead it should be using the edition of the span itself.

Fixes https://github.com/rust-lang/rust/issues/132917
2024-11-15 23:38:12 +01:00
Guillaume Gomez
c3a632c28b
Rollup merge of #133074 - ferrocene:ja-make-ui-test-os-agnostic, r=Noratrieb
make UI test OS-agnostic

the internal representation of `std::sync::Mutex` depends on the compilation target. due to this, the compiler produces different number of errors for UI test `issue-17431-6.rs` depending on the compilation target.

for example, when compiling the UI test to an `*-apple-*` or `*-qnx7*` target, the "cycle detected" error is not reported

``` console
$ cat src/lib.rs
use std::sync::Mutex;

enum Foo {
    X(Mutex<Option<Foo>>),
}

impl Foo {
    fn bar(self) {}
}

fn main() {}

$ cargo check --target x86_64-apple-ios 2>&1 | rg '^error\['
error[E0072]: recursive type `Foo` has infinite size
```

whereas rustc produces two errors for other OSes, like Linux, which is what the UI test expects

``` console
$ cargo check --target x86_64-unknown-linux-gnu 2>&1 | rg '^error\['
error[E0072]: recursive type `Foo` has infinite size
error[E0391]: cycle detected when computing when `Foo` needs drop
```

this commit replaces the problematic `Mutex` with `UnsafeCell`, which has the same internal representation regardless of the compilation target. with that change, rustc reports two errors for all compilation targets.

``` console
$ cat src/lib.rs
use std::cell::UnsafeCell;

enum Foo {
    X(UnsafeCell<Option<Foo>>),
}

impl Foo {
    fn bar(self) {}
}

fn main() {}

$ cargo check --target x86_64-apple-ios 2>&1 | rg '^error\['
error[E0072]: recursive type `Foo` has infinite size
error[E0391]: cycle detected when computing when `Foo` needs drop
```

with this change, we can remove the `ignore-apple` directive as the UI test now also passes on apple targets.
2024-11-15 23:38:11 +01:00
Guillaume Gomez
b3e2981ff7
Rollup merge of #132978 - WaffleLapkin:very-semantic-change-kind, r=compiler-errors
Mention both release *and* edition breakage for never type lints

This PR makes ~~two changes~~ a change to the never type lints (`dependency_on_unit_never_type_fallback` and `never_type_fallback_flowing_into_unsafe`):
1.  Change the wording of the note to mention that the breaking change will be made in an edition _and_ in a future release
2. ~~Make these warnings be reported in deps (hopefully the lints are matured enough)~~

r? ``@compiler-errors``
cc ``@ehuss``
closes #132930
2024-11-15 23:38:10 +01:00
Guillaume Gomez
325bc6c201
Rollup merge of #132956 - maxcabrajac:coroutine_kind, r=petrochenkov
Add visit_coroutine_kind to ast::Visitor

r? ``@petrochenkov``

related to #128974
2024-11-15 23:38:10 +01:00
Guillaume Gomez
1f83a4de1f
Rollup merge of #132936 - surechen:fix_131989, r=Nadrieril
For expr `return (_ = 42);` unused_paren lint should not be triggered

fixes #131989
2024-11-15 23:38:09 +01:00
binarycat
cd46ff6c05 rustdoc search: allow queries to end in an empty path segment
fixes https://github.com/rust-lang/rust/issues/129707

this can be used to show all items in a module,
or all associated items for a type.
currently sufferes slightly due to case insensitivity,
so `Option::` will also show items in the `option::` module.

it disables the checking of the last path element,
otherwise only items with short names will be shown
2024-11-15 16:32:40 -06:00
maxcabrajac
516a3b0c9b Make WalkItemKind::walk signature compatible between Visitor versions 2024-11-15 17:01:53 -03:00
maxcabrajac
6180173612 Add WalkItemKind::Ctxt so AssocCtxt is not sent to non-Assoc ItemKinds 2024-11-15 17:00:01 -03:00
maxcabrajac
1236656319 Make Visitor::FnKind and MutVisitor::FnKind compatible 2024-11-15 16:59:47 -03:00
bors
917a50a039 Auto merge of #133079 - matthiaskrgr:rollup-k8u7syk, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #132817 (Recurse into APITs in `impl_trait_overcaptures`)
 - #133021 (Refactor `configure_annotatable`)
 - #133045 (tests: Test pac-ret flag merging on clang with LTO)
 - #133049 (Change Visitor::visit_precise_capturing_arg so it returns a Visitor::Result)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-15 19:13:57 +00:00
Eric Huss
03e2828e88 Fix span edition for 2024 RPIT coming from an external macro
This fixes a problem where code generated by an external macro with an
RPIT would end up using the call-site edition instead of the macro's
edition for the RPIT. When used from a 2024 crate, this caused the code
to change behavior to the 2024 capturing rules, which we don't want.

This was caused by the impl-trait lowering code would replace the span
with one marked with `DesugaringKind::OpaqueTy` desugaring. However, it
was also overriding the edition of the span with the edition of the
local crate. Instead it should be using the edition of the span itself.

Fixes https://github.com/rust-lang/rust/issues/132917
2024-11-15 10:06:53 -08:00
Matthias Krüger
a111716c42
Rollup merge of #133049 - maxcabrajac:visit_precise_capturing_arg, r=compiler-errors
Change Visitor::visit_precise_capturing_arg so it returns a Visitor::Result

r? `@petrochenkov`

related to #128974
2024-11-15 19:05:18 +01:00
Matthias Krüger
249a9100a3
Rollup merge of #133045 - mrkajetanp:pauth-test-clang-lto-flag-merge, r=jieyouxu
tests: Test pac-ret flag merging on clang with LTO

Extend the test for pac-ret with clang and LTO by checking that different branch protection flags are preserved after the LTO step. There was an issue in older LLVM versions that was causing this to behave incorrectly.

try-job: aarch64-gnu-debug
2024-11-15 19:05:18 +01:00
Matthias Krüger
6963572c78
Rollup merge of #133021 - nnethercote:refactor-configure_annotatable, r=petrochenkov
Refactor `configure_annotatable`

This PR streamlines `configure_annotatable` and nearby code considerably.

r? `@petrochenkov`
2024-11-15 19:05:16 +01:00
Matthias Krüger
213803549a
Rollup merge of #132817 - compiler-errors:impl-trait-overcaptures-apit, r=BoxyUwU
Recurse into APITs in `impl_trait_overcaptures`

We were previously not detecting cases where an RPIT was located in the return type of an async function, leading to underfiring of the `impl_trait_overcaptures`. This PR does this recursion properly now.

cc https://github.com/rust-lang/rust/issues/132809
2024-11-15 19:05:15 +01:00
Eric Huss
d163541022 Add test for precise-capturing from an external macro 2024-11-15 09:54:06 -08:00
Tyrone Wu
dd557c988f
Trim whitespace in RemoveLet primary span
Separate `RemoveLet` span into primary span for `let` and removal
suggestion span for `let `, so that primary span does not include
whitespace.

Fixes: #133031

Signed-off-by: Tyrone Wu <wudevelops@gmail.com>
2024-11-15 17:43:29 +00:00
bors
ce40196577 Auto merge of #132992 - RalfJung:check-consts-feature-gate, r=compiler-errors
check_consts: fix error requesting feature gate when that gate is not actually needed

When working on https://github.com/rust-lang/hashbrown/pull/586 I noticed that the compiler asks for the `rustc_private` feature to be enabled if one forgets to set `rustc_const_stable_indirect` on a function -- but enabling `rustc_private` would not actually help. This fixes the diagnostics.

r? `@compiler-errors`
2024-11-15 16:03:47 +00:00
Jorge Aparicio
7f0275636e make UI test OS-agnostic
the internal representation of `std::sync::Mutex` depends on the compilation target. due to this,
the compiler produces different number of errors for UI test
`issue-17431-6.rs` depending on the compilation target.

for example, when compiling the UI test to an `*-apple-*` or `*-qnx7*` target, the "cycle detected"
error is not reported

``` console
$ cat src/lib.rs
use std::sync::Mutex;

enum Foo {
    X(Mutex<Option<Foo>>),
}

impl Foo {
    fn bar(self) {}
}

fn main() {}

$ cargo check --target x86_64-apple-ios 2>&1 | rg '^error\['
error[E0072]: recursive type `Foo` has infinite size
```

whereas rustc produces two errors for other OSes, like Linux, which is what the UI test expects

``` console
$ cargo check --target x86_64-unknown-linux-gnu 2>&1 | rg '^error\['
error[E0072]: recursive type `Foo` has infinite size
error[E0391]: cycle detected when computing when `Foo` needs drop
```

this commit replaces the problematic `Mutex` with `UnsafeCell`, which has the same internal
representation regardless of the compilation target. with that change, rustc reports two errors for
all compilation targets.

``` console
$ cat src/lib.rs
use std::cell::UnsafeCell;

enum Foo {
    X(UnsafeCell<Option<Foo>>),
}

impl Foo {
    fn bar(self) {}
}

fn main() {}

$ cargo check --target x86_64-apple-ios 2>&1 | rg '^error\['
error[E0072]: recursive type `Foo` has infinite size
error[E0391]: cycle detected when computing when `Foo` needs drop
```

with this change, we can remove the `ignore-apple` directive as the UI test now also passes on apple
targets.
2024-11-15 16:37:18 +01:00
Kajetan Puchalski
194471cbd4 tests: Test pac-ret flag merging on clang with LTO
Extend the test for pac-ret with clang and LTO by checking that
different branch protection flags are preserved after the LTO step.
There was an issue in older LLVM versions that was causing this to
behave incorrectly.

Tests the LLVM behaviour added in:
1782810b84
2024-11-15 14:13:38 +00:00
bors
76fd47124b Auto merge of #132910 - osiewicz:crate-loader-smarter-queries, r=saethlin
rustc_metadata: Preprocess search paths for better performance

Over in Zed we've noticed that loading crates for a large-ish workspace (~100 members of workspace, over 1000 crates being built for the main binary target) can take almost 200ms. We've pinned it down to how rustc searches for paths to dependency files, as it performs a linear search over the list of candidate paths. In our case the candidate list had about 20k entries which we had to iterate over for each dependency being loaded. Our workspace is also pretty bottom-heavy, e.g. most of the workspace members pull in most of the transitive dependencies one way or another, which means that we spend quite some time loading crates at rustc startup.

This commit introduces a simple FilesIndex that's just a BTreeMap under the hood. Since crates are looked up by both prefix and suffix, we perform a range search on said BTree (which constraints the search space based on prefix) and follow up with a linear scan of entries with matching suffixes.

Overall, this commit brings down build time for us in dev scenarios by about 6%. 100ms might not seem like much, but this is a constant cost that each of our workspace crates has to pay, even when said crate is miniscule.
2024-11-15 11:48:21 +00:00
Piotr Osiewicz
42e71bb8ea rustc_metadata: Preprocess search paths for better performance
Over in Zed we've noticed that loading crates for a large-ish workspace can take almost 200ms. We've pinned it down to how rustc searches for paths, as it performs a linear search over the list of candidate paths. In our case the candidate list had about 20k entries which we had to iterate over for each dependency being loaded.

This commit introduces a simple FilesIndex that's just a sorted Vec under the hood. Since crates are looked up by both prefix and suffix, we perform a range search on said Vec (which constraints the search space based on prefix) and follow up with a linear scan of entries with matching suffixes.
FilesIndex is also pre-filtered before any queries are performed using available target information; query prefixes/sufixes are based on the target we are compiling for, so we can remove entries that can never match up front.

Overall, this commit brings down build time for us in dev scenarios by about 6%.
100ms might not seem like much, but this is a constant cost that each of our workspace crates has to pay, even when said crate is miniscule.
2024-11-15 10:35:33 +01:00
bors
f00f68245e Auto merge of #132967 - klensy:docker-unite, r=Kobzol
fix REGISTRY_USERNAME to reuse cache between auto and pr jobs

see https://rust-lang.zulipchat.com/#narrow/channel/242791-t-infra/topic/reuse.20.28some.29.20docker.20images.20for.20pr.2Fauto.3F
2024-11-15 08:08:11 +00:00