Commit graph

37397 commits

Author SHA1 Message Date
bors 6868c831a1 Auto merge of #127174 - matthiaskrgr:rollup-q87j6cn, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #126018 (Remove the `box_pointers` lint.)
 - #126895 (Fix simd_gather documentation)
 - #126981 (Replace some magic booleans in match-lowering with enums)
 - #127038 (Update test comment)
 - #127053 (Update the LoongArch target documentation)
 - #127069 (small correction to fmt::Pointer impl)
 - #127157 (coverage: Avoid getting extra unexpansion info when we don't need it)
 - #127160 (Add a regression test for #123630)
 - #127161 (Improve `run-make-support` library `args` API)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-06-30 20:14:40 +00:00
Matthias Krüger b2aebc1b76
Rollup merge of #127157 - Zalathar:unexpand, r=cjgillot
coverage: Avoid getting extra unexpansion info when we don't need it

Several callers of `unexpand_into_body_span_with_visible_macro` would immediately discard the additional macro-related information, which is wasteful. We can avoid this by having them instead call a simpler method that just returns the span they care about.

This PR also moves the relevant functions out of `coverage::spans::from_mir` and into a new submodule `coverage::unexpand`, so that calling them from `coverage::mappings` is less awkward.

There should be no actual changes to coverage-instrumentation output, as demonstrated by the absence of test updates.
2024-06-30 18:25:34 +02:00
Matthias Krüger d404ce7015
Rollup merge of #126981 - Zalathar:enums, r=Nadrieril
Replace some magic booleans in match-lowering with enums

This PR takes some boolean arguments used by the match-lowering code, and replaces them with dedicated enums that more clearly express their effect, while also making it much easier to find how each value is ultimately used.
2024-06-30 18:25:32 +02:00
Matthias Krüger 6f5765599e
Rollup merge of #126018 - nnethercote:rm-box_pointers-lint, r=lcnr
Remove the `box_pointers` lint.

As the comment says, this lint "is mostly historical, and not particularly useful". It's not worth keeping it around.

r? ``@estebank``
2024-06-30 18:25:31 +02:00
bors ef3d6fd700 Auto merge of #127162 - bjorn3:sync_cg_clif-2024-06-30, r=bjorn3
Subtree sync for rustc_codegen_cranelift

The main highlight this time is support for arm64 macOS in cg_clif. A future PR will enable distributing it as rustup component.

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
2024-06-30 16:23:04 +00:00
bors 6c3485512f Auto merge of #127156 - matthiaskrgr:rollup-jjfd464, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #126705 (Updated docs on `#[panic_handler]` in `library/core/src/lib.rs`)
 - #126876 (Add `.ignore` file to make `config.toml` searchable in vscode)
 - #126906 (Small fixme in core now that split_first has no codegen issues)
 - #127023 (CI: rename Rust for Linux CI job)
 - #127131 (Remove unused `rustc_trait_selection` dependencies)
 - #127134 (Print `TypeId` as a `u128` for `Debug`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-06-30 13:22:17 +00:00
bjorn3 9ec6a02ab3 Merge commit '49cd5dd454d0115cfbe9e39102a8b3ba4616aa40' into sync_cg_clif-2024-06-30 2024-06-30 11:28:14 +00:00
bors 2975a21b5d Auto merge of #127024 - cjgillot:jump-prof, r=oli-obk
Avoid cloning jump threading state when possible

The current implementation of jump threading passes most of its time cloning its state. This PR attempts to avoid such clones by special-casing the last predecessor when recursing through a terminator.

This is not optimal, but a first step while I refactor the state data structure to be sparse.

The two other commits are drive-by.
Fixes https://github.com/rust-lang/rust/issues/116721

r? `@oli-obk`
2024-06-30 11:09:53 +00:00
Zalathar 6c33149055 coverage: Avoid getting extra unexpansion info when we don't need it
These particular callers don't actually use the returned macro information, so
they can use a simpler span-unexpansion function that doesn't return it.
2024-06-30 19:05:14 +10:00
Zalathar ed07712e96 Replace a magic boolean with enum ScheduleDrops 2024-06-30 19:02:25 +10:00
Zalathar 3b22589cfa Replace a magic boolean with enum EmitStorageLive
The previous boolean used `true` to indicate that storage-live should _not_ be
emitted, so all occurrences of `Yes` and `No` should be the logical opposite of
the previous value.
2024-06-30 18:55:39 +10:00
Zalathar ad575b093b Replace a magic boolean with enum DeclareLetBindings
The new enum `DeclareLetBindings` has three variants:
- `Yes`: Declare `let` bindings as normal, for `if` conditions.
- `No`: Don't declare bindings, for match guards and let-else.
- `LetNotPermitted`: Assert that `let` expressions should not occur.
2024-06-30 18:55:39 +10:00
Matthias Krüger 515d17cd15
Rollup merge of #127131 - Kobzol:remove-unused-deps, r=compiler-errors
Remove unused `rustc_trait_selection` dependencies

Found using `cargo-machete`. The `bitflags` and `derivative` crates were added for the new trait solver, but weren't removed when the next trait solver code was uplifted to a separate crate.
2024-06-30 10:39:48 +02:00
Zalathar 617de8cfb5 coverage: Move span unexpansion into its own submodule 2024-06-30 17:44:19 +10:00
bors 716752ebe6 Auto merge of #127133 - matthiaskrgr:rollup-jxkp3yf, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #123237 (Various rustc_codegen_ssa cleanups)
 - #126960 (Improve error message in tidy)
 - #127002 (Implement `x perf` as a separate tool)
 - #127081 (Add a run-make test that LLD is not being used by default on the x64 beta/stable channel)
 - #127106 (Improve unsafe extern blocks diagnostics)
 - #127110 (Fix a error suggestion for E0121 when using placeholder _ as return types on function signature.)
 - #127114 (fix: prefer `(*p).clone` to `p.clone` if the `p` is a raw pointer)
 - #127118 (Show `used attribute`'s kind for user when find it isn't applied to a `static` variable.)
 - #127122 (Remove uneccessary condition in `div_ceil`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-06-30 02:20:01 +00:00
Matthias Krüger 5ea1a03cca
Rollup merge of #127118 - surechen:fix_126789, r=jieyouxu
Show `used attribute`'s kind for user when find it isn't applied to a `static` variable.

For example :
```rust
extern "C" {
    #[used] //~ ERROR attribute must be applied to a `static` variable
    static FOO: i32; // show the kind of this item to help user understand why the error is reported.
}
```

fixes #126789
2024-06-29 22:10:59 +02:00
Matthias Krüger 9879b4606c
Rollup merge of #127114 - linyihai:issue-126863, r=Nadrieril
fix: prefer `(*p).clone` to `p.clone` if the `p` is a raw pointer

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

I wonder if there is a better way to solve the regression problem of this test case:
`tests/ui/borrowck/issue-20801.rs`.
It's okay to drop the dereference symbol in this scenario.

But it's not correct in https://github.com/rust-lang/rust/issues/126863

```
help: consider removing the dereference here
  |
5 -         let inner: String = *p;
5 +         let inner: String = p;
```

I haven't found out how to tell if clone pointer is allowed, i.e. no type mismatch occurs
2024-06-29 22:10:58 +02:00
Matthias Krüger 80cf576f59
Rollup merge of #127110 - surechen:fix_125488_06, r=compiler-errors
Fix a error suggestion for E0121 when using placeholder _ as return types on function signature.

Recommit after refactoring based on comment:
https://github.com/rust-lang/rust/pull/126017#issuecomment-2189149361

But when changing return type's lifetime to `ReError` will affect the subsequent borrow check process and cause test11 in typeck_type_placeholder_item.rs to lost E0515 message.
```rust
fn test11(x: &usize) -> &_ {
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types
    &x //~ ERROR cannot return reference to function parameter(this E0515 msg will disappear)
}
```

fixes #125488

r? ``@pnkfelix``
2024-06-29 22:10:58 +02:00
Matthias Krüger 77152955b8
Rollup merge of #127106 - spastorino:improve-unsafe-extern-blocks-diagnostics, r=compiler-errors
Improve unsafe extern blocks diagnostics

Closes #126327

For this code:

```rust
extern {
    pub fn foo();
    pub safe fn bar();
}
```

We get ...

```
error: items in unadorned `extern` blocks cannot have safety qualifiers
 --> test.rs:3:5
  |
3 |     pub safe fn bar();
  |     ^^^^^^^^^^^^^^^^^^
  |
help: add unsafe to this `extern` block
  |
1 | unsafe extern {
  | ++++++

error[E0658]: `unsafe extern {}` blocks and `safe` keyword are experimental
 --> test.rs:3:9
  |
3 |     pub safe fn bar();
  |         ^^^^
  |
  = note: see issue #123743 <https://github.com/rust-lang/rust/issues/123743> for more information
  = help: add `#![feature(unsafe_extern_blocks)]` to the crate attributes to enable

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0658`.
```

And then making the extern block unsafe, we get ...

```
error: extern block cannot be declared unsafe
 --> test.rs:1:1
  |
1 | unsafe extern {
  | ^^^^^^
  |
  = note: see issue #123743 <https://github.com/rust-lang/rust/issues/123743> for more information
  = help: add `#![feature(unsafe_extern_blocks)]` to the crate attributes to enable

error: items in unadorned `extern` blocks cannot have safety qualifiers
 --> test.rs:3:5
  |
3 |     pub safe fn bar();
  |     ^^^^^^^^^^^^^^^^^^

error[E0658]: `unsafe extern {}` blocks and `safe` keyword are experimental
 --> test.rs:3:9
  |
3 |     pub safe fn bar();
  |         ^^^^
  |
  = note: see issue #123743 <https://github.com/rust-lang/rust/issues/123743> for more information
  = help: add `#![feature(unsafe_extern_blocks)]` to the crate attributes to enable

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0658`.
```

r? ``@compiler-errors``
2024-06-29 22:10:57 +02:00
Matthias Krüger 5b90824433
Rollup merge of #123237 - bjorn3:debuginfo_refactor, r=compiler-errors
Various rustc_codegen_ssa cleanups
2024-06-29 22:10:55 +02:00
Jakub Beránek e52d95bc82 Remove unused compiler dependencies 2024-06-29 22:09:58 +02:00
bors ba1d7f4a08 Auto merge of #120639 - fee1-dead-contrib:new-effects-desugaring, r=oli-obk
Implement new effects desugaring

cc `@rust-lang/project-const-traits.` Will write down notes once I have finished.

* [x] See if we want `T: Tr` to desugar into `T: Tr, T::Effects: Compat<true>`
* [x] Fix ICEs on `type Assoc: ~const Tr` and `type Assoc<T: ~const Tr>`
* [ ] add types and traits to minicore test
* [ ] update rustc-dev-guide

Fixes #119717
Fixes #123664
Fixes #124857
Fixes #126148
2024-06-29 20:08:10 +00:00
Santiago Pastorino 15d5dac32e
Avoid suggesting to add unsafe when the extern block is already unsafe 2024-06-29 14:40:32 -03:00
Lin Yihai 8dc36c1647 fix: prefer (*p).clone to p.clone if the p is a raw pointer 2024-06-29 19:58:18 +08:00
surechen 9c0ce05d24 Show used attribute's kind for user when find it isn't applied to a static variable.
fixes #126789
2024-06-29 19:39:09 +08:00
Camille GILLOT dec4e98522 Move entry point to a method. 2024-06-29 10:42:31 +00:00
Camille GILLOT a175817ea6 Avoid cloning state when possible. 2024-06-29 10:42:31 +00:00
Camille GILLOT 61ede075bf Stop ICEing on impossible predicates. 2024-06-29 10:42:31 +00:00
Matthias Krüger a4e92bfef0
Rollup merge of #127103 - compiler-errors:tighten-trait-bound-parsing, r=fmease
Move binder and polarity parsing into `parse_generic_ty_bound`

Let's pull out the parts of #127054 which just:
1. Make the parsing code less confusing
2. Fix `?use<>` (to correctly be denied)
3. Improve `T: for<'a> 'a` diagnostics

This should have no user-facing effects on stable parsing.

r? fmease
2024-06-29 09:14:59 +02:00
Matthias Krüger c1d7ff55b5
Rollup merge of #127101 - matthiaskrgr:thonk, r=compiler-errors
remove redundant match statement from dataflow const prop
2024-06-29 09:14:58 +02:00
Matthias Krüger 3369e8364b
Rollup merge of #127075 - glaubitz:copy-and-paste-fix, r=SparrowLii
rustc_data_structures: Explicitly check for 64-bit atomics support

Instead of keeping a list of architectures which have native support
for 64-bit atomics, just use #[cfg(target_has_atomic = "64")] and its
inverted counterpart to determine whether we need to use portable
AtomicU64 on the target architecture.
2024-06-29 09:14:57 +02:00
Matthias Krüger e9d5a2f45f
Rollup merge of #127045 - compiler-errors:explicit, r=oli-obk
Rename `super_predicates_of` and similar queries to `explicit_*` to note that they're not elaborated

Rename:
* `super_predicates_of` -> `explicit_super_predicates_of`
* `implied_predicates_of` -> `explicit_implied_predicates_of`
* `supertraits_containing_assoc_item` -> `explicit_supertraits_containing_assoc_item`

This makes it clearer that, unlike (for example) [`TyCtxt::super_traits_of`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.super_traits_of), we don't automatically elaborate this set of predicates.

r? ``@lcnr`` or ``@oli-obk`` or someone from t-types idc
2024-06-29 09:14:57 +02:00
Matthias Krüger 806c5c1971
Rollup merge of #126835 - Nadrieril:reify-decision-tree, r=matthewjasper
Simplifications in match lowering

A series of small simplifications and deduplications in the MIR lowering of patterns.

r? ````@matthewjasper````
2024-06-29 09:14:56 +02:00
surechen 50edb32939 Fix a error suggestion for E0121 when using placeholder _ as return types on function signature.
Recommit after refactoring based on comment:
https://github.com/rust-lang/rust/pull/126017#issuecomment-2189149361

But when changing return type's lifetime to `ReError` will affect the subsequent borrow check process and cause test11 in typeck_type_placeholder_item.rs to lost E0515 message.
```rust
fn test11(x: &usize) -> &_ {
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types
    &x //~ ERROR cannot return reference to function parameter(this E0515 msg will disappear)
}

```
2024-06-29 14:23:33 +08:00
bors d38cd229b7 Auto merge of #127096 - matthiaskrgr:rollup-kh7e0rh, r=matthiaskrgr
Rollup of 11 pull requests

Successful merges:

 - #123714 (Add test for fn pointer duplication.)
 - #124091 (Update AST validation module docs)
 - #127015 (Switch back `non_local_definitions` lint to allow-by-default)
 - #127016 (docs: check if the disambiguator matches its suffix)
 - #127029 (Fix Markdown tables in platform-support.md)
 - #127032 (Enable const casting for `f16` and `f128`)
 - #127055 (Mark Hasher::finish as #[must_use])
 - #127068 (Stall computing instance for drop shim until it has no unsubstituted const params)
 - #127070 (add () to the marker_impls macro for ConstParamTy)
 - #127071 (Remove (deprecated & unstable) {to,from}_bits pointer methods)
 - #127078 (Enable full tools and profiler for LoongArch Linux targets)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-06-29 05:00:11 +00:00
Santiago Pastorino a62cbda57e
Add feature diagnostic for unsafe_extern_blocks 2024-06-28 23:13:33 -03:00
Michael Goulet 3bc3247200 Move binder and polarity parsing into parse_generic_ty_bound 2024-06-28 19:40:31 -04:00
Matthias Krüger 45efd9ca8b remove some amusing but redundant code 2024-06-29 00:48:05 +02:00
Rémy Rakic 224cb3f638 Revert "Rollup merge of #126938 - RalfJung:link_section, r=compiler-errors"
This reverts commit 5c4ede88c6, reversing
changes made to 95332b8918.
2024-06-28 20:59:01 +00:00
Matthias Krüger 5afb4c2b21
Rollup merge of #127068 - compiler-errors:stall-drop, r=BoxyUwU
Stall computing instance for drop shim until it has no unsubstituted const params

Do not inline the drop shim for types that still have unsubstituted const params.

## Why?

#127030 ICEs because it tries to inline the drop shim for a type with an unsubstituted const param. In order to generate this shim, this requires calling the drop shim builder, which invokes the trait solver to compute whether constituent types need drop (since we compute if a type is copy to disqualify any `Drop` behavior):

9c3bc805dd/compiler/rustc_mir_dataflow/src/elaborate_drops.rs (L378)

However, since we don't keep the param-env of the instance we resolved the item for, we use the wrong param-env:
9c3bc805dd/compiler/rustc_mir_transform/src/shim.rs (L278)
(which is the param-env of `std::ptr::drop_in_place`)

This param-env is notably missing `ConstParamHasTy` predicates, and since we removed the type from consts in https://github.com/rust-lang/rust/pull/125958, we literally cannot prove these predicates in this (relatively) empty param-env. This currently happens in places like the MIR inliner, but may happen elsewhere such as in lints that resolve terminators.

## What?

We force the inliner to not consider calls for `drop_in_place` for types that have unsubstituted const params.

## So what?

This may negatively affect MIR inlining, but I doubt this matters in practice, and fixes a beta regression, so let's fix it. I will look into approaches for fixing this in a more maintainable way, perhaps delaying the creation of drop shim bodies until codegen (like how intrinsics work).
2024-06-28 22:04:18 +02:00
Matthias Krüger 93ca5ff900
Rollup merge of #127032 - tgross35:f16-f128-const-eval-cast, r=oli-obk
Enable const casting for `f16` and `f128`

I have an open PR to the Miri repo adding tests for this behavior https://github.com/rust-lang/miri/pull/3688, but that unfortunately hits the ICE path here. The changes seem reasonably low risk that it might be okay to merge separately from the tests, and I tested the result locally against an older version of https://github.com/rust-lang/miri/pull/3688.

Cc ``````@RalfJung``````
2024-06-28 22:04:17 +02:00
Matthias Krüger 3f560afde5
Rollup merge of #127015 - Urgau:non_local_def-tmp-allow, r=lqd
Switch back `non_local_definitions` lint to allow-by-default

This PR switch back (again) the `non_local_definitions` lint to allow-by-default as T-lang is requesting some (major) changes in the lint inner workings in https://github.com/rust-lang/rust/issues/126768#issuecomment-2192634762.

This PR will need to be beta-backported, as the lint is currently warn-by-default in beta.
2024-06-28 22:04:16 +02:00
Matthias Krüger 26df3146ab
Rollup merge of #124091 - jieyouxu:ast-validation-top-level-docs, r=wesleywiser
Update AST validation module docs

Drive-by doc update for AST validation pass:

- Syntax extensions are replaced by proc macros.
- Add rationale for why AST validation pass need to be run
  post-expansion and why the pass is needed in the first place.

This was discussed during this week's [rustc-dev-guide reading club](https://rust-lang.zulipchat.com/#narrow/stream/196385-t-compiler.2Fwg-rustc-dev-guide), and the rationale was explained by cc ``````@bjorn3.``````
2024-06-28 22:04:15 +02:00
Deadbeef 65a0bee0b7 address review comments 2024-06-28 15:44:20 +00:00
Michael Goulet f17b27b301 Don't inline drop shims with unsubstituted generic consts in MIR inliner 2024-06-28 10:18:20 -04:00
Deadbeef 8b2fac9612 finishing touches, move fixed ICEs to ui tests 2024-06-28 10:57:35 +00:00
Deadbeef 0a2330630d general fixups and turn TODOs into FIXMEs 2024-06-28 10:57:35 +00:00
Deadbeef f852a2c173 Implement Self::Effects: Compat<HOST> desugaring 2024-06-28 10:57:35 +00:00
Deadbeef b9886c6872 bless tests part 1 2024-06-28 10:57:35 +00:00
Deadbeef 74e7b5bd76 temporarily disable effects on specialization tests 2024-06-28 10:57:35 +00:00