Commit Graph

14245 Commits

Author SHA1 Message Date
Matthias Krüger
ea61714d52
Rollup merge of #132927 - BoxyUwU:consolidate_type_system_const_eval, r=compiler-errors
Consolidate type system const evaluation under `traits::evaluate_const`

Part of #130704

Fixes #128232
Fixes #118545

Removes `ty::Const::{normalize_internal, eval_valtree}` and `InferCtxt::(try_)const_eval_resolve`, consolidating the associated logic into `evaluate_const` in `rustc_trait_selection`. This results in an API for `ty::Const` that is free of any normalization/evaluation functions that would be incorrect to use under `min_generic_const_args`/`associated_const_equality`/`generic_const_exprs` or, more generally, that would be incorrect to use in the presence of generic type system constants.

Moving this logic to `rustc_trait_selection` and out of `rustc_middle` is also a pre-requisite for ensuring that we do not evaluate constants whose where clauses do not hold.

From this point it should be relatively simple (hah) to implement more complex normalization of type system constants such as: checking wf'ness before invoking CTFE machinery, or being able to normalize const aliases that still refer to generic parameters.

r? `@compiler-errors`
2024-11-12 08:07:18 +01:00
Matthias Krüger
1dd975beb3
Rollup merge of #132668 - ehuss:yield-gate-2024, r=davidtwco
Feature gate yield expressions not in 2024

This changes it so that yield expressions are no longer allowed in the 2024 edition without a feature gate. We are currently only reserving the `gen` keyword in the 2024 edition, and not allowing anything else to be implicitly enabled by the edition.

In practice this doesn't have a significant difference since yield expressions can't really be used outside of coroutines or gen blocks, which have their own feature gates. However, it does affect what is accepted pre-expansion, and I would feel more comfortable not allowing yield expressions.

I believe the stabilization process for gen blocks or coroutines will not need to check the edition here, so this shouldn't ever be needed.
2024-11-12 08:07:16 +01:00
Matthias Krüger
b18ee9858b
Rollup merge of #132651 - PonasKovas:master, r=fmease
Remove attributes from generics in built-in derive macros

Related issue #132561

Removes all attributes from generics in the expanded implementations of built-in derive macros.
2024-11-12 08:07:15 +01:00
Boxy
bea0148ac6 Consolidate type system const evaluation under traits::evaluate_const
mew
2024-11-12 02:54:03 +00:00
bors
67f21277cd Auto merge of #132919 - matthiaskrgr:rollup-ogghyvp, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #120077 (Add Set entry API )
 - #132144 (Arbitrary self types v2: (unused) Receiver trait)
 - #132297 (Document some `check_expr` methods, and other misc `hir_typeck` tweaks)
 - #132820 (Add a default implementation for CodegenBackend::link)
 - #132881 (triagebot: Autolabel rustdoc book)
 - #132912 (Simplify some places that deal with generic parameter defaults)
 - #132916 (Unvacation fmease)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-12 02:51:21 +00:00
Matthias Krüger
35225d61f4
Rollup merge of #132820 - bjorn3:default_backend_link_impl, r=jieyouxu
Add a default implementation for CodegenBackend::link

As a side effect this should add raw-dylib support to cg_gcc as the default ArchiveBuilderBuilder that is used implements create_dll_import_lib. I haven't tested if the raw-dylib support actually works however.
2024-11-11 21:58:32 +01:00
bors
81eef2d362 Auto merge of #132902 - matthiaskrgr:rollup-43qgg3t, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #129627 (Ensure that tail expr receive lifetime extension)
 - #130999 (Implement file_lock feature)
 - #132873 (handle separate prefixes in clippy rules)
 - #132891 (Remove `rustc_session::config::rustc_short_optgroups`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-11 19:25:06 +00:00
PonasKovas
7c0a7f78a0 remove attributes from generics in built-in derive macros
add a test

add github issue link to description of the test

replace new ThinVec with clear()

Co-authored-by: León Orell Valerian Liehr <me@fmease.dev>
2024-11-11 21:20:02 +02:00
Matthias Krüger
d4abc3183d
Rollup merge of #129627 - dingxiangfei2009:ensure-tail-expr-in-let-block-works, r=jieyouxu
Ensure that tail expr receive lifetime extension

cc `@jieyouxu` `@traviscross`

It just came to me that we should add a test to make sure that we honor the contract from the temporary lifetime rule #121346. We should continue to implement this rule in Edition 2021 onward and shorter tail expression lifetime should not override it.

This is a small PR to improve our assurance and establish a stronger contract.

Tracked by rust-lang/rust#123739
2024-11-11 15:23:32 +01:00
Eric Huss
e04acff14f Feature gate yield expressions not in 2024 2024-11-11 06:17:11 -08:00
Ding Xiang Fei
aee8152805
ensure that tail expr receive lifetime extension 2024-11-11 20:34:36 +08:00
bors
d4822c2d84 Auto merge of #127589 - notriddle:notriddle/search-sem-3, r=GuillaumeGomez
rustdoc-search: simplify rules for generics and type params

**Heads up!**: This PR is a follow-up that depends on #124544. It adds 12dc24f460, a change to the filtering behavior, and 9900ea48b5, a minor ranking tweak.

Part of https://github.com/rust-lang/rust-project-goals/issues/112

This PR overturns https://github.com/rust-lang/rust/pull/109802

## Preview

* no results: [`Box<[A]> -> Vec<B>`](http://notriddle.com/rustdoc-html-demo-12/search-sem-3/std/index.html?search=Box%3C%5BA%5D%3E%20-%3E%20Vec%3CB%3E)
* results: [`Box<[A]> -> Vec<A>`](http://notriddle.com/rustdoc-html-demo-12/search-sem-3/std/index.html?search=Box%3C%5BA%5D%3E%20-%3E%20Vec%3CA%3E)
* [`T -> U`](http://notriddle.com/rustdoc-html-demo-12/search-sem-3/std/index.html?search=T%20-%3E%20U)
* [`Cx -> TyCtxt`](http://notriddle.com/rustdoc-html-demo-12/search-sem-3-compiler/rustdoc/index.html?search=Cx%20-%3E%20TyCtxt)

![image](https://github.com/user-attachments/assets/015ae28c-7469-4f7f-be03-157d28d7ec97)

## Description

This commit is a response to feedback on the displayed type signatures results, by making generics act stricter.

- Order within generics is significant. This means `Vec<Allocator>` now matches only with a true vector of allocators, instead of matching the second type param. It also makes unboxing within generics stricter, so `Result<A, B>` only matches if `B` is in the error type and `A` is in the success type. The top level of the function search is unaffected.
- Generics are only "unboxed" if a type is explicitly opted into it. References and tuples are hardcoded to allow unboxing, and Box, Rc, Arc, Option, Result, and Future are opted in with an unstable attribute. Search result unboxing is the process that allows you to search for `i32 -> str` and get back a function with the type signature `&Future<i32> -> Box<str>`.
- Instead of ranking by set overlap, it ranks by the number of items in the type signature. This makes it easier to find single type signatures like transmute.

## Find the discussion on

* <https://rust-lang.zulipchat.com/#narrow/stream/393423-t-rustdoc.2Fmeetings/topic/meeting.202024-07-08/near/449965149>
* <https://github.com/rust-lang/rust/pull/124544#issuecomment-2204272265>
* <https://rust-lang.zulipchat.com/#narrow/channel/266220-t-rustdoc/topic/deciding.20on.20semantics.20of.20generics.20in.20rustdoc.20search>
2024-11-11 12:26:00 +00:00
bors
fbcdd728ed Auto merge of #132885 - jhpratt:rollup-4ddd31p, r=jhpratt
Rollup of 3 pull requests

Successful merges:

 - #131080 (Stabilize WebAssembly `multivalue`, `reference-types`, and `tail-call` target features)
 - #132871 (add regression test for #85763)
 - #132878 (triagebot: Assign rustdoc tests to T-rustdoc.)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-11 02:31:12 +00:00
Jacob Pratt
5742e2255e
Rollup merge of #132871 - lolbinarycat:rustdoc-heterogeneous-first-paragraph-85763, r=aDotInTheVoid
add regression test for #85763

closes #85763
2024-11-10 19:12:26 -05:00
Jacob Pratt
7c53b5d206
Rollup merge of #131080 - alexcrichton:stabilize-more-wasm-target-features, r=petrochenkov
Stabilize WebAssembly `multivalue`, `reference-types`, and `tail-call` target features

For the `multivalue` and `reference-types` features this commit is
similar to https://github.com/rust-lang/rust/pull/117457 in that it's stabilizing target features specific to
WebAssembly targets. The previous PR left out these two features because
they weren't expected to change much about compiled code so it was
unclear what the rationale was. It has [since been discovered][blog]
that `reference-types` can be useful as it changes the binary format of
the `call_indirect` instruction. Additionally [on Zulip][zulip] there's
a use case of detecting these features at compile time and generating a
compile error to better warn users about features not supported on
engines.

This PR then additionally adds the `tail-call` feature which corresponds
to the [tail-call] proposal to WebAssembly. This feature advanced to
"phase 4" in the WebAssembly CG awhile back and has been supported in
LLVM for quite some time now. Engines are finishing up implementations
or have already shipped implementations, so while this is a bit of a
late addition to Rust itself it reflects the current status of
WebAssembly's state of the feature.

A test has been added here not only for these features but other
WebAssembly features as well to showcase that they're usable without
feature gates in stable Rust.

[blog]: https://blog.rust-lang.org/2024/09/24/webassembly-targets-change-in-default-target-features.html
[zulip]: https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/wasm32.20reference-types.20.2F.20multivalue.20in.201.2E82-beta.20not.20enabled/near/473893987
[tail-call]: https://github.com/webassembly/tail-call
2024-11-10 19:12:25 -05:00
bors
42b2496320 Auto merge of #126597 - estebank:unicode-output, r=fmease
Add Unicode block-drawing compiler output support

Add nightly-only theming support to rustc output using Unicode box
drawing characters instead of ASCII-art to draw the terminal UI.

In order to enable, the flags `-Zunstable-options=yes --error-format=human-unicode` must be passed in.

After:

```
error: foo
  ╭▸ test.rs:3:3
  │
3 │       X0 Y0 Z0
  │   ┌───╿──│──┘
  │  ┌│───│──┘
  │ ┏││━━━┙
  │ ┃││
4 │ ┃││   X1 Y1 Z1
5 │ ┃││   X2 Y2 Z2
  │ ┃│└────╿──│──┘ `Z` label
  │ ┃└─────│──┤
  │ ┗━━━━━━┥  `Y` is a good letter too
  │        `X` is a good letter
  ╰╴
note: bar
  ╭▸ test.rs:4:3
  │
4 │ ┏   X1 Y1 Z1
5 │ ┃   X2 Y2 Z2
6 │ ┃   X3 Y3 Z3
  │ ┗━━━━━━━━━━┛
  ├ note: bar
  ╰ note: baz
note: qux
  ╭▸ test.rs:4:3
  │
4 │   X1 Y1 Z1
  ╰╴  ━━━━━━━━
```

Before:

```
error: foo
 --> test.rs:3:3
  |
3 |       X0 Y0 Z0
  |    ___^__-__-
  |   |___|__|
  |  ||___|
  | |||
4 | |||   X1 Y1 Z1
5 | |||   X2 Y2 Z2
  | |||____^__-__- `Z` label
  | ||_____|__|
  | |______|  `Y` is a good letter too
  |        `X` is a good letter
  |
note: bar
 --> test.rs:4:3
  |
4 | /   X1 Y1 Z1
5 | |   X2 Y2 Z2
6 | |   X3 Y3 Z3
  | |__________^
  = note: bar
  = note: baz
note: qux
 --> test.rs:4:3
  |
4 |   X1 Y1 Z1
  |   ^^^^^^^^
```

After:

![rustc output with unicode box drawing characters](https://github.com/rust-lang/rust/assets/1606434/d210b79a-6579-4407-9706-ba8edc6e9f25)

Before:
![current rustc output with ASCII art](https://github.com/rust-lang/rust/assets/1606434/5aecccf8-a6ee-4469-8b39-72fb0d979a9f)
2024-11-11 00:00:58 +00:00
Esteban Küber
1d78004575
Add Unicode block-drawing compiler output support
Add nightly-only theming support to rustc output using Unicode box
drawing characters instead of ASCII-art to draw the terminal UI:

After:

```
error: foo
  ╭▸ test.rs:3:3
  │
3 │       X0 Y0 Z0
  │   ┌───╿──│──┘
  │  ┌│───│──┘
  │ ┏││━━━┙
  │ ┃││
4 │ ┃││   X1 Y1 Z1
5 │ ┃││   X2 Y2 Z2
  │ ┃│└────╿──│──┘ `Z` label
  │ ┃└─────│──┤
  │ ┗━━━━━━┥  `Y` is a good letter too
  │        `X` is a good letter
  ╰╴
note: bar
  ╭▸ test.rs:4:3
  │
4 │ ┏   X1 Y1 Z1
5 │ ┃   X2 Y2 Z2
6 │ ┃   X3 Y3 Z3
  │ ┗━━━━━━━━━━┛
  ├ note: bar
  ╰ note: baz
note: qux
  ╭▸ test.rs:4:3
  │
4 │   X1 Y1 Z1
  ╰╴  ━━━━━━━━
```

Before:

```
error: foo
 --> test.rs:3:3
  |
3 |       X0 Y0 Z0
  |    ___^__-__-
  |   |___|__|
  |  ||___|
  | |||
4 | |||   X1 Y1 Z1
5 | |||   X2 Y2 Z2
  | |||____^__-__- `Z` label
  | ||_____|__|
  | |______|  `Y` is a good letter too
  |        `X` is a good letter
  |
note: bar
 --> test.rs:4:3
  |
4 | /   X1 Y1 Z1
5 | |   X2 Y2 Z2
6 | |   X3 Y3 Z3
  | |__________^
  = note: bar
  = note: baz
note: qux
 --> test.rs:4:3
  |
4 |   X1 Y1 Z1
  |   ^^^^^^^^
```
2024-11-10 23:57:18 +01:00
Matthias Krüger
54cb1f7fe6
Rollup merge of #132426 - Urgau:unreach_pub-super, r=petrochenkov
Prefer `pub(super)` in `unreachable_pub` lint suggestion

This PR updates the `unreachable_pub` lint suggestion to prefer `pub(super)` instead of `pub(crate)` when possible.

cc `@petrochenkov`
r? `@nnethercote`
2024-11-10 22:20:35 +01:00
Matthias Krüger
cdb76c77ac
Rollup merge of #131781 - taiki-e:arm64ec-stabilize-asm, r=Amanieu,traviscross
Stabilize Arm64EC inline assembly

This stabilizes inline assembly for Arm64EC ("Emulation Compatible").

Corresponding reference PR: https://github.com/rust-lang/reference/pull/1653

---

From the requirements of stabilization mentioned in https://github.com/rust-lang/rust/issues/93335

> Each architecture needs to be reviewed before stabilization:

> - It must have clobber_abi.

Done in https://github.com/rust-lang/rust/pull/131332.

> - It must be possible to clobber every register that is normally clobbered by a function call.

This is possible from the time of the initial implementation.

> - Generally review that the exposed register classes make sense.

The registers available in this target are a subset of those available in the AArch64 inline assembly which is already stable.

The following registers cannot be used in Arm64EC compared to AArch64:

- `x13`, `x14`, `x23`, `x24`, `x28` (register class: `reg`)
- `v[16-31]` (register class: `vreg`)
- `p[0-15]`, `ffr` (clobber-only register class `preg`)

These are disallowed by the ABI (see also [abi docs](https://learn.microsoft.com/en-us/cpp/build/arm64ec-windows-abi-conventions?view=msvc-170#register-mapping) for `reg`/`vreg` and https://github.com/rust-lang/rust/pull/131332#issuecomment-2401189142 for `preg`).

Although not listed in the above requirements, preserves_flags is also implemented and the same as AArch64.

---

cc `@dpaoliello`

r? `@Amanieu`

`@rustbot` label O-windows O-AArch64 +A-inline-assembly +T-lang -T-compiler +needs-fcp
2024-11-10 22:20:34 +01:00
binarycat
93ea5bb709 add regression test for #85763 2024-11-10 13:38:41 -06:00
bors
2128d8df0e Auto merge of #132863 - matthiaskrgr:rollup-1zbjz5f, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #132675 (coverage: Restrict empty-span expansion to only cover `{` and `}`)
 - #132849 (Miri subtree update)
 - #132858 (Update minifer version to `0.3.2`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-10 18:06:48 +00:00
Matthias Krüger
b95232dabb
Rollup merge of #132675 - Zalathar:empty-spans, r=jieyouxu
coverage: Restrict empty-span expansion to only cover `{` and `}`

Coverage instrumentation has some tricky code for converting a coverage-relevant `Span` into a set of start/end line/byte-column coordinates that will be embedded in the CGU's coverage metadata.

A big part of this complexity is special code for handling empty spans, which are expanded into non-empty spans (if possible) because LLVM's coverage reporter does not handle empty spans well.

This PR simplifies that code by restricting it to only apply in two specific situations: when the character after the empty span is `{`, or the character before the empty span is `}`.

(As an added benefit, this means that the expanded spans no longer extend awkwardly beyond the end of a physical line, which was common under the previous implementation.)

Along the way, this PR also removes some unhelpful code for dealing with function source code spread across multiple files. Functions currently can't have coverage spans in multiple files, and if that ever changes (e.g. to properly support expansion regions) then this code will need to be completely overhauled anyway.
2024-11-10 17:43:07 +01:00
Alex Crichton
3af91a4cd4 Stabilize WebAssembly multivalue, reference-types, and tail-call target features
For the `multivalue` and `reference-types` features this commit is
similar to #117457 in that it's stabilizing target features specific to
WebAssembly targets. The previous PR left out these two features because
they weren't expected to change much about compiled code so it was
unclear what the rationale was. It has [since been discovered][blog]
that `reference-types` can be useful as it changes the binary format of
the `call_indirect` instruction. Additionally [on Zulip][zulip] there's
a use case of detecting these features at compile time and generating a
compile error to better warn users about features not supported on
engines.

This PR then additionally adds the `tail-call` feature which corresponds
to the [tail-call] proposal to WebAssembly. This feature advanced to
"phase 4" in the WebAssembly CG awhile back and has been supported in
LLVM for quite some time now. Engines are finishing up implementations
or have already shipped implementations, so while this is a bit of a
late addition to Rust itself it reflects the current status of
WebAssembly's state of the feature.

A test has been added here not only for these features but other
WebAssembly features as well to showcase that they're usable without
feature gates in stable Rust.

[blog]: https://blog.rust-lang.org/2024/09/24/webassembly-targets-change-in-default-target-features.html
[zulip]: https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/wasm32.20reference-types.20.2F.20multivalue.20in.201.2E82-beta.20not.20enabled/near/473893987
[tail-call]: https://github.com/webassembly/tail-call
2024-11-10 07:45:14 -08:00
Jieyou Xu
5c9cc0cfbb Re-enable version-verbose-commit-hash run-make test 2024-11-10 16:28:54 +01:00
Jieyou Xu
c4c6d2b8d5 Temporarily disable version-verbose-commit-hash to force revert through 2024-11-10 20:31:18 +08:00
bjorn3
e8b10297b5 Fix error message for direct usage of sess.opts.crate_types 2024-11-10 10:37:53 +00:00
Matthias Krüger
c1f3c7078a
Rollup merge of #132816 - compiler-errors:2024-apit, r=jieyouxu
Dont suggest `use<impl Trait>` when we have an edition-2024-related borrowck issue

#131186 implements some machinery to detect in borrowck when we may have RPIT overcaptures due to edition 2024, and suggests adding `+ use<'a, T>` to go back to the edition 2021 capture rules. However, we weren't filtering out cases when there are APITs in scope.

This PR implements a more sophisticated diagnostic where we will suggest turning any APITs in scope into type parameters, and applies this to both the borrowck error note, and to the `impl_trait_overcaptures` migration lint.

cc #132809
2024-11-10 10:09:52 +01:00
Taiki Endo
965a2801a0 Stabilize Arm64EC inline assembly 2024-11-10 17:43:46 +09:00
bors
668959740f Auto merge of #132831 - workingjubilee:rollup-6fdif44, r=workingjubilee
Rollup of 6 pull requests

Successful merges:

 - #131258 (Stabilize s390x inline assembly)
 - #132801 (interpret: get_alloc_info: also return mutability)
 - #132823 (require const_impl_trait gate for all conditional and trait const calls)
 - #132824 (Update grammar in wasm-c-abi's compiler flag documentation)
 - #132825 (Exclude relnotes-tracking-issue from needs-triage)
 - #132828 (Additional tests to ensure let is rejected during parsing)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-10 05:54:13 +00:00
Jubilee
c19d56c902
Rollup merge of #132828 - est31:let_chains_parsing_tests, r=compiler-errors
Additional tests to ensure let is rejected during parsing

In the original stabilization PR, @ `compiler-errors` has [pointed out](https://github.com/rust-lang/rust/pull/94927#issuecomment-1165156328) that #97295 wasn't enough to address the concerns about having `let` in expressions being rejected at parsing time, instead of later.

Thankfully, since then the situation has been greatly improved by #115677. This PR adds some additional tests to `disallowed-positions.rs`, and adds two additional revisions to the "normal" case which is now given the `feature` name:

* `no_feature`: Added to incorporate `disallowed-positions-without-feature-gate.rs` into the file, reducing duplication.
* `nothing`: like feature, but all functions are cfg'd out. Ensures that the errors are really emitted during parsing.

cc tracking issue #53667
2024-11-09 20:28:46 -08:00
Jubilee
d4c81c6987
Rollup merge of #132823 - RalfJung:conditional-const-calls, r=fee1-dead,compiler-errors
require const_impl_trait gate for all conditional and trait const calls

Alternative to https://github.com/rust-lang/rust/pull/132786.

`@compiler-errors`  this is basically what I meant with my proposals. I found it's easier to express this in code than English. ;)

r? `@compiler-errors`
2024-11-09 20:28:44 -08:00
Jubilee
2f98dcf9ba
Rollup merge of #131258 - taiki-e:s390x-stabilize-asm, r=Amanieu
Stabilize s390x inline assembly

This stabilizes inline assembly for s390x (SystemZ).

Corresponding reference PR: https://github.com/rust-lang/reference/pull/1643

---

From the requirements of stabilization mentioned in https://github.com/rust-lang/rust/issues/93335

> Each architecture needs to be reviewed before stabilization:

> - It must have clobber_abi.

Done in https://github.com/rust-lang/rust/pull/130630.

> - It must be possible to clobber every register that is normally clobbered by a function call.

Done in the PR that added support for clobber_abi.

> - Generally review that the exposed register classes make sense.

The followings can be used as input/output:

- `reg` (`r[0-10]`, `r[12-14]`): General-purpose register

- `reg_addr` (`r[1-10]`, `r[12-14]`): General-purpose register except `r0` which is evaluated as zero in an address context

  This class is needed because `r0`, which may be allocated when using the `reg` class, cannot be used as a register in certain contexts. This is identical to the `a` constraint in LLVM and GCC. See https://github.com/rust-lang/rust/pull/119431 for details.

- `freg` (`f[0-15]`): Floating-point register

The followings are clobber-only:

- `vreg` (`v[0-31]`): Vector register

  Technically `vreg` should be able to accept `#[repr(simd)]` types as input/output if the unstable `vector` target feature added is enabled, but `core::arch` has no s390x vector type and both `#[repr(simd)]` and `core::simd` are unstable. Everything related is unstable, so the fact that this is currently a clobber-only should not be considered a stabilization blocker. (https://github.com/rust-lang/rust/issues/130869 tracks unstable stuff here)

- `areg` (`a[2-15]`): Access register

All of the above register classes except `reg_addr` are needed for `clobber_abi`.

The followings cannot be used as operands for inline asm (see also [getReservedRegs](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/SystemZ/SystemZRegisterInfo.cpp#L258-L282) and [SystemZELFRegisters](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/SystemZ/SystemZRegisterInfo.h#L107-L128) in LLVM):

- `r11`: frame pointer
- `r15`: stack pointer
- `a0`, `a1`: Reserved for system use
- `c[0-15]` (control register)  Reserved by the kernel

Although not listed in the above requirements, `preserves_flags` is implemented in https://github.com/rust-lang/rust/pull/111331.

---

cc ``@uweigand``

r? ``@Amanieu``

``@rustbot`` label +O-SystemZ +A-inline-assembly
2024-11-09 20:28:43 -08:00
bors
7660aed73d Auto merge of #132173 - veluca93:abi_checks, r=RalfJung,compiler-errors
Emit warning when calling/declaring functions with unavailable vectors.

On some architectures, vector types may have a different ABI depending on whether the relevant target features are enabled. (The ABI when the feature is disabled is often not specified, but LLVM implements some de-facto ABI.)

As discussed in rust-lang/lang-team#235, this turns out to very easily lead to unsound code.

This commit makes it a post-monomorphization future-incompat warning to declare or call functions using those vector types in a context in which the corresponding target features are disabled, if using an ABI for which the difference is relevant. This ensures that these functions are always called with a consistent ABI.

See the [nomination comment](https://github.com/rust-lang/rust/pull/127731#issuecomment-2288558187) for more discussion.

Part of #116558

r? RalfJung
2024-11-10 02:52:25 +00:00
est31
935bf6995f Add more places where expressions can occur 2024-11-10 01:18:35 +01:00
est31
7312b41239 Unify disallowed-positions test files into one file
Also make the file have a third mode for where everything is cfg'd out to make sure it's an early error.
2024-11-10 01:18:00 +01:00
Ralf Jung
f235b6f9c6 give a hint which feature is missing 2024-11-09 23:32:06 +01:00
Ralf Jung
822762c966 require const_impl_trait gate for all conditional and trait const calls 2024-11-09 23:02:20 +01:00
bors
4adafcf40a Auto merge of #132815 - matthiaskrgr:rollup-nti992u, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #132341 (Reject raw lifetime followed by `'`, like regular lifetimes do)
 - #132363 (Enforce that raw lifetimes must be valid raw identifiers)
 - #132744 (add regression test for #90781)
 - #132754 (Simplify the internal API for declaring command-line options)
 - #132772 (use `download-rustc="if-unchanged"` as a global default)
 - #132774 (Use lld with non-LLVM backends)
 - #132799 (Make `Ty::primitive_symbol` recognize `str`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-09 19:52:46 +00:00
Michael Goulet
a1f9d5bfba Dont suggest use<APIT> 2024-11-09 19:41:53 +00:00
Michael Goulet
ad20906065 Suggest turning APITs into generics in opaque overcaptures 2024-11-09 19:18:22 +00:00
Matthias Krüger
3aa1a24799
Rollup merge of #132799 - zachs18:str-primitive-symbol, r=compiler-errors
Make `Ty::primitive_symbol` recognize `str`

Make `Ty::primitive_symbol` recognize `str`, which makes `str` eligible for the "expected primitive, found local type" (and vice versa) [diagnostic](https://github.com/rust-lang/rust/blob/master/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs#L1430-L1437) that already exists for other primitives.

<details><summary> diagnostic difference</summary>

```rs
#[allow(non_camel_case_types)]
struct str;

fn foo() {
    let _: &str = "hello";
    let _: &core::primitive::str = &str;
}
```

`rustc --crate-type lib --edition 2021 a.rs`

Current nightly:

```rs
error[E0308]: mismatched types
 --> a.rs:5:19
  |
5 |     let _: &str = "hello";
  |            ----   ^^^^^^^ expected `str`, found a different `str`
  |            |
  |            expected due to this
  |
  = note: expected reference `&str`
             found reference `&'static str`

error[E0308]: mismatched types
 --> a.rs:6:36
  |
6 |     let _: &core::primitive::str = &str;
  |            ---------------------   ^^^^ expected `str`, found a different `str`
  |            |
  |            expected due to this
  |
  = note: expected reference `&str` (`str`)
             found reference `&str` (`str`)

error: aborting due to 2 previous errors

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

With this patch:

```rs
error[E0308]: mismatched types
 --> a.rs:5:19
  |
5 |     let _: &str = "hello";
  |            ----   ^^^^^^^ expected `str`, found a different `str`
  |            |
  |            expected due to this
  |
  = note: str and `str` have similar names, but are actually distinct types
  = note: str is a primitive defined by the language
note: `str` is defined in the current crate
 --> a.rs:2:1
  |
2 | struct str;
  | ^^^^^^^^^^

error[E0308]: mismatched types
 --> a.rs:6:36
  |
6 |     let _: &core::primitive::str = &str;
  |            ---------------------   ^^^^ expected `str`, found a different `str`
  |            |
  |            expected due to this
  |
  = note: str and `str` have similar names, but are actually distinct types
  = note: str is a primitive defined by the language
note: `str` is defined in the current crate
 --> a.rs:2:1
  |
2 | struct str;
  | ^^^^^^^^^^

error: aborting due to 2 previous errors

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

</details>
2024-11-09 19:16:46 +01:00
Matthias Krüger
88acd493f9
Rollup merge of #132754 - Zalathar:opts, r=GuillaumeGomez,jieyouxu
Simplify the internal API for declaring command-line options

The internal APIs for declaring command-line options are old, and intimidatingly complex. This PR replaces them with a single function that takes explicit `stability` and `kind` arguments, making it easier to see how each option is handled, and whether it is treated as stable or unstable.

We also don't appear to have any tests for the output of `rustc --help` and similar, so I've added a run-make test to verify that this PR doesn't change any output. (There is already a similar run-make test for rustdoc's help output.)

---

The librustdoc changes are simply adjusting to updated compiler APIs; no functional change intended.

---

A side-effect of these changes is that rustfmt can once again format the entirety of these option declaration lists, which it was not doing before.
2024-11-09 19:16:44 +01:00
Matthias Krüger
5f58dc9ebd
Rollup merge of #132744 - lolbinarycat:test-90781, r=aDotInTheVoid
add regression test for #90781

closes #90781
2024-11-09 19:16:44 +01:00
Matthias Krüger
910ac7eabf
Rollup merge of #132363 - compiler-errors:raw-lt-id-valid, r=wesleywiser
Enforce that raw lifetimes must be valid raw identifiers

Make sure that the identifier part of a raw lifetime is a valid raw identifier. This precludes `'r#_` and all module segment paths for now.

I don't believe this is compelling to support. This was raised by `@ehuss` in https://github.com/rust-lang/reference/pull/1603#discussion_r1822726753 (well, specifically the `'r#_` case), but I don't see why we shouldn't just make it consistent with raw identifiers.
2024-11-09 19:16:43 +01:00
Matthias Krüger
9b50092fdc
Rollup merge of #132341 - compiler-errors:raw-lt-prefix-id, r=chenyukang
Reject raw lifetime followed by `'`, like regular lifetimes do

See comment. We want to reject cases like `'r#long'id`, which currently gets interpreted as a raw lifetime (`'r#long`) followed by a lifetime (`'id`). This could have alternative lexes, such as an overlong char literal (`'r#long'`) followed by an identifier (`id`). To avoid committing to this in any case, let's reject the whole thing.

`@mattheww,` is this what you were looking for in https://github.com/rust-lang/reference/pull/1603#issuecomment-2339237325? I'd say ignore the details about the specific error message (the fact that this gets reinterpreted as a char literal is 🤷), just that because this causes a lexer error we're effectively saving syntactical space like you wanted.
2024-11-09 19:16:43 +01:00
Kyle Huey
1dc106121b Add discriminators to DILocations when multiple functions are inlined into a single point.
LLVM does not expect to ever see multiple dbg_declares for the same variable at the same
location with different values. proc-macros make it possible for arbitrary code,
including multiple calls that get inlined, to happen at any given location in the source
code. Add discriminators when that happens so these locations are different to LLVM.

This may interfere with the AddDiscriminators pass in LLVM, which is added by the
unstable flag -Zdebug-info-for-profiling.

Fixes #131944
2024-11-09 08:01:31 -08:00
Matthias Krüger
2829c2725a
Rollup merge of #132777 - durin42:llvm-20-poison-prop, r=nikic
try_question_mark_nop: update test for LLVM 20

llvm/llvm-project@dd116369f6 changes the IR of this test in a way that I don't think is bad, but needs adjusting.

r? `@nikic`
`@rustbot` label: +llvm-main
2024-11-09 10:52:04 +01:00
Matthias Krüger
6e05afd744
Rollup merge of #132745 - RalfJung:pointee-info-inside-enum, r=DianQK
pointee_info_at: fix logic for recursing into enums

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

The logic in `pointee_info_at` was likely written at a time when the null pointer optimization was the *only* enum layout optimization -- and as `Variant::Multiple` kept getting expanded, nobody noticed that the logic is now unsound.

The job of this function is to figure out whether there is a dereferenceable-or-null and aligned pointer at a given offset inside a type. So when we recurse into a multi-variant enum, we better make sure that all the other enum variants must be null! This is the part that was forgotten, and this PR adds it.

The reason this didn't explode in many ways so far is that our references only have 1 niche value (null), so it's not possible on stable to have a multi-variant enum with a dereferenceable pointer and other enum variants that are not null. But with `rustc_layout_scalar_valid_range` attributes one can force such a layout, and if `@the8472's` work on alignment niches ever lands, that will make this possible on stable.
2024-11-09 10:52:03 +01:00
Matthias Krüger
b9d4ef16c9
Rollup merge of #132552 - taiki-e:sparc-target-feature, r=workingjubilee
Add v9, v8plus, and leoncasa target feature to sparc and use v8plus in create_object_file

This adds the following three unstable target features:

- `v9`: SPARC-V9 instructions ([LLVM definition][sparc-v9])
  - Relevant to https://github.com/rust-lang/rust/pull/131222#issuecomment-2453310963
  - Relevant to https://github.com/rust-lang/rust/pull/132472#discussion_r1832606081
  - This is also needed to implement https://github.com/taiki-e/atomic-maybe-uninit/pull/31 (depends on inline assembly support) more robustly.
- `v8plus`: SPARC-V8+ ABI ([LLVM definition][sparc-v8plus])
  - This is added in LLVM 20. In LLVM 19 and older, it is emulated to work the same way as LLVM in each LLVM version.
  - See https://github.com/rust-lang/rust/issues/132585#issuecomment-2453926257 for more.
- `leoncasa`: CASA instruction[^1] of LEON3 and LEON4 processors ([LLVM definition][sparc-leoncasa], LLVM feature name: `hasleoncasa`)
  - This is needed to implement https://github.com/taiki-e/atomic-maybe-uninit/pull/31 (depends on inline assembly support) more robustly.

[^1]: Atomic CAS instruction

[sparc-v9]: f5e4ffaa49/llvm/lib/Target/Sparc/Sparc.td (L37-L39)
[sparc-v8plus]: f5e4ffaa49/llvm/lib/Target/Sparc/Sparc.td (L37-L39)
[sparc-leoncasa]: https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/Sparc/LeonFeatures.td#L32-L37
2024-11-09 10:52:03 +01:00
Zachary S
5f6645dc51 Add test for str for "expected primitive, found type" 2024-11-09 00:23:53 -06:00