Commit Graph

9508 Commits

Author SHA1 Message Date
clubby789
94371d5a8c Validate and test -Zmir-enable-passes 2024-11-12 13:28:05 +00:00
Yihai Lin
949cf61fdc add parentheses when unboxing suggestion needed 2024-11-12 18:23:57 +08:00
bors
5700240aff Auto merge of #132943 - matthiaskrgr:rollup-164l3ej, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #132651 (Remove attributes from generics in built-in derive macros)
 - #132668 (Feature gate yield expressions not in 2024)
 - #132771 (test(configure): cover `parse_args` in `src/bootstrap/configure.py`)
 - #132895 (Generalize `NonNull::from_raw_parts` per ACP362)
 - #132914 (Update grammar in std::cell docs.)
 - #132927 (Consolidate type system const evaluation under `traits::evaluate_const`)
 - #132935 (Make sure to ignore elided lifetimes when pointing at args for fulfillment errors)
 - #132941 (Subtree update of `rust-analyzer`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-12 08:15:38 +00:00
Matthias Krüger
9a4a954359
Rollup merge of #132935 - compiler-errors:arg-math, r=nnethercote
Make sure to ignore elided lifetimes when pointing at args for fulfillment errors

See the comment I left in the code.

---

If we have something like:

```
fn foo<'a, T: 'a + BoundThatIsNotSatisfied>() {}
```

And the user turbofishes just the type args:

```
foo::<()>();
```

Then if we try pointing at `()` (i.e. the type argument for `T`), we don't actually consider the possibility that the lifetimes may have been left out of the turbofish. We try indexing incorrectly into the HIR args, and bail on the suggestion.
2024-11-12 08:07:19 +01:00
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
Ralf Jung
378049633d allow rustc_private feature in force-unstable-if-unmarked crates 2024-11-12 07:14:49 +01:00
Matthias Krüger
506f52c7f3
Rollup merge of #132933 - compiler-errors:never-lint-arg-bug, r=WaffleLapkin
Make sure that we suggest turbofishing the right type arg for never suggestion

I had a bug where rust would suggest the wrong arg to turbofish `()` if there were any early-bound lifetimes...

r? WaffleLapkin
2024-11-12 06:27:20 +01:00
Matthias Krüger
b7dc4813a8
Rollup merge of #132653 - BoxyUwU:const_arg_stmt_mac_call, r=compiler-errors
Don't use `maybe_unwrap_block` when checking for macro calls in a block expr

Fixes #131915

Using `maybe_unwrap_block` to determine if we are looking at a `{ mac_call!{} }` will fail sometimes as `mac_call!{}` could be a `StmtKind::MacCall` not a `StmtKind::Expr`. This caused the def collector to think that `{ mac_call!{} }` was a non-trivial const argument and create a definition for it even though it should not.

r? `@compiler-errors`  cc `@camelid`
2024-11-12 06:27:17 +01:00
Matthias Krüger
9098e03fb2
Rollup merge of #132487 - dianne:include-trait-args-in-suggestion, r=fmease
Provide placeholder generics for traits in "no method found for type parameter" suggestions

In the diagnostics for the error ``no method named `method` found for type parameter `T` in the current scope [E0599]``, the compiler will suggest adding bounds on `T` for traits that define a method named `method`. However, these suggestions didn't include any generic arguments, so applying them would result in a `missing generics for trait` or `missing lifetime specifier` error. This PR adds placeholder arguments to the suggestion in such cases. Specifically, I tried to base the placeholders off of what's done in suggestions for when generics are missing or too few are provided:
- The placeholder for a parameter without a default is the name of the parameter.
- Placeholders are not provided for parameters with defaults.

Placeholder arguments are enclosed in `/*` and `*/`, and the applicability of the suggestion is downgraded to `Applicability::HasPlaceholders` if any placeholders are provided.

Fixes #132407
2024-11-12 06:27:16 +01:00
Michael Goulet
0dc6c1e594 Make precise capturing suggestion machine-applicable only if it has not APITs 2024-11-12 04:08:34 +00:00
Michael Goulet
8473e3f6af Make sure that we suggest turbofishing the right type arg 2024-11-12 03:02:23 +00:00
Boxy
bea0148ac6 Consolidate type system const evaluation under traits::evaluate_const
mew
2024-11-12 02:54:03 +00:00
surechen
33d3c27d38 For expr return (_ = 42); unused_paren lint should not be triggered
fixes #131989
2024-11-12 10:17:41 +08:00
Michael Goulet
d128c80c7a Make sure to ignore elided lifetimes when pointing at args for fulfillment errors 2024-11-12 02:08:39 +00:00
Michael Goulet
8e068b989b Recurse into APITs in impl_trait_overcaptures 2024-11-11 20:53:08 +00:00
gavincrawford
8ec94d30e5
Update dangling pointer tests 2024-11-11 13:36:43 -07:00
dianne
02add7d0fb Provide placeholder generic arguments for traits in "no method found for type parameter" suggestions 2024-11-11 12:33:15 -08: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
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
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
Ralf Jung
e96808162a ensure that all publicly reachable const fn have const stability info 2024-11-10 10:16:26 +01: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
Ralf Jung
686eeb83e9 honor rustc_const_stable_indirect in non-staged_api crate with -Zforce-unstable-if-unmarked 2024-11-10 10:01:27 +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
Michael Goulet
8d871b7687 Deny capturing late-bound ty/ct params in nested opaques 2024-11-10 04:30:33 +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
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
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
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
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
Jubilee
c4922f12fd
Rollup merge of #132780 - compiler-errors:verbose, r=estebank
use verbose for path separator suggestion

A single `-` of suggestion underlining that is adjacent to a much more significant `^^^` underlying of the LHS path component is hard to distinguish. IMO this presents much more cleanly when it's verbose, especially because it's a *replacment* suggestion.

r? estebank
2024-11-08 20:46:15 -08:00
Jubilee
b598849941
Rollup merge of #132760 - dianne:iter-into-iter, r=lcnr
Don't suggest `.into_iter()` on iterators

This makes the the suggestion to call `.into_iter()` only consider unsatisfied `Iterator` bounds for the receiver type itself. That way, it ignores predicates generated by trying to auto-ref the receiver (the result of which usually won't implement `Iterator`).

Fixes #127511

Unfortunately, the error in that case is still confusing: it labels `Iterator` as an unsatisfied bound because `&impl Iterator: Iterator` can't be satisfied, despite that not being required or helpful. I'd like to handle that in a separate PR. ~~I'm hoping fixing #124802 will fix it too.~~ It doesn't look connected to that issue. Still, I think it'd be clearest to visually distinguish unsatisfied predicates from different attempts at `pick_method`; I'll make a PR for that soon.
2024-11-08 20:46:12 -08:00
Jubilee
7a4970476e
Rollup merge of #132757 - compiler-errors:yeet-check-wf, r=lcnr
Get rid of `check_opaque_type_well_formed`

Instead, replicate it by improving the span of the opaque in `check_opaque_meets_bounds`.

This has two consequences:
1. We now prefer "concrete type differs" errors, since we'll hit those first before we check the opaque is WF.
2. Spans have gotten slightly worse.

Specifically, (2.) could be improved by adding a new obligation cause that explains that the definition's environment has stronger assumptions than the declaration.

r? lcnr
2024-11-08 20:46:12 -08:00
dianne
cea82ed162 Don't suggest .into_iter() on iterators 2024-11-08 17:43:13 -08:00
Taiki Endo
c059eb7750 Add v8plus target feature to sparc and use it in create_object_file 2024-11-09 03:22:09 +09:00
Taiki Endo
400a690b5f Add v9 and leoncasa target feature to sparc 2024-11-09 03:17:24 +09:00
Michael Goulet
0e481b44f5 use verbose for path separator suggestion 2024-11-08 16:58:19 +00:00
bors
209799f3b9 Auto merge of #132717 - RalfJung:rustc_safe_intrinsic, r=compiler-errors
remove support for rustc_safe_intrinsic attribute; use rustc_intrinsic functions instead

This brings us one step closer towards removing support for `extern "rust-intrinsic"` blocks, in favor of `#[rustc_intrinsic]` functions.

Also move `#[rustc_intrinsic]` under the `intrinsics` feature gate, to match the `extern "rust-intrinsic"` style.
2024-11-08 10:28:47 +00:00
Ralf Jung
e3010e84db remove support for rustc_safe_intrinsic attribute; use rustc_intrinsic functions instead 2024-11-08 09:16:00 +01:00
Stuart Cook
4b904ceb46
Rollup merge of #132738 - cuviper:channel-heap-init, r=ibraheemdev
Initialize channel `Block`s directly on the heap

The channel's `Block::new` was causing a stack overflow because it held
32 item slots, instantiated on the stack before moving to `Box::new`.
The 32x multiplier made modestly-large item sizes untenable.

That block is now initialized directly on the heap.

Fixes #102246

try-job: test-various
2024-11-08 18:51:30 +11:00
Stuart Cook
5043c574ac
Rollup merge of #132161 - celinval:smir-fix-indent, r=compiler-errors
[StableMIR] A few fixes to pretty printing

Improve identation, and a few other rvalue printing

try-job: x86_64-msvc
try-job: test-various
2024-11-08 18:51:28 +11:00
Ralf Jung
7651fc6edc mark is_val_statically_known intrinsic as stably const-callable 2024-11-08 08:46:49 +01:00
Michael Goulet
97dfe8b871 Manually register some bounds for a better span 2024-11-08 04:56:08 +00:00
Michael Goulet
e4c1a0016c Get rid of check_opaque_type_well_formed 2024-11-08 03:46:27 +00:00
bors
78bb5ee79e Auto merge of #132756 - workingjubilee:rollup-bed2akn, r=workingjubilee
Rollup of 10 pull requests

Successful merges:

 - #130586 (Set "symbol name" in raw-dylib import libraries to the decorated name)
 - #131913 (Add `{ignore,needs}-{rustc,std}-debug-assertions` directive support)
 - #132095 (Fix #131977 parens mangled in shared mut static lint suggestion)
 - #132131 ([StableMIR] API to retrieve definitions from crates)
 - #132639 (core: move intrinsics.rs into intrinsics folder)
 - #132696 (Compile `test_num_f128` conditionally on `reliable_f128_math` config)
 - #132737 (bootstrap: Print better message if lock pid isn't available)
 - #132739 (Fix `librustdoc/scrape_examples.rs` formatting)
 - #132740 (Update test for LLVM 20's new vector splat syntax)
 - #132741 (Update mips64 data layout to match LLVM 20 change)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-08 03:32:51 +00:00
Jubilee
0683e031a8
Rollup merge of #132639 - RalfJung:intrinsics, r=workingjubilee,Amanieu
core: move intrinsics.rs into intrinsics folder

This makes the rustbot notification we have set up for this folder in `triagebot.toml` actually work. Also IMO it makes more sense to have it all in one folder.
2024-11-07 18:48:23 -08:00
Jubilee
6c0e8ef86a
Rollup merge of #132095 - gechelberger:fix-131977, r=wesleywiser
Fix #131977 parens mangled in shared mut static lint suggestion

Resolves #131977 for static mut references after discussion with
Esteban & Jieyou on [t-compiler/help](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/linting.20with.20parens.20in.20the.20HIR).

This doesn't do anything to change the underlying issue if there are other expressions that generate lint suggestions which need to be applied within parentheses.
2024-11-07 18:48:21 -08:00
Jubilee
93e9ec05a9
Rollup merge of #131913 - jieyouxu:only_debug_assertions, r=onur-ozkan
Add `{ignore,needs}-{rustc,std}-debug-assertions` directive support

Add `{ignore,needs}-{rustc,std}-debug-assertions` compiletest directives and retire the old `{ignore,only}-debug` directives. The old `{ignore,only}-debug` directives were ambiguous because you could have std built with debug assertions but rustc not built with debug assertions or vice versa. If we want to support the use case of controlling test run based on if rustc was built with debug assertions, then having `{ignore,only}-debug` will be very confusing.

cc ````@matthiaskrgr````

Closes #123987.

r? bootstrap (or compiler tbh)
2024-11-07 18:48:21 -08:00
Josh Stone
9827c6dc2c This test needs threads 2024-11-07 18:18:34 -08:00
bors
5b20c45999 Auto merge of #128849 - estebank:issue-89143, r=jackh726
Tweak detection of multiple crate versions to be more encompassing

Previously, we only emitted the additional context if the type was in the same crate as the trait that appeared multiple times in the dependency tree. Now, we look at all traits looking for two with the same name in different crates with the same crate number, and we are more flexible looking for the types involved. This will work even if the type that implements the wrong trait version is from a different crate entirely.

```
error[E0277]: the trait bound `CustomErrorHandler: ErrorHandler` is not satisfied because the trait comes from a different crate version
 --> src/main.rs:5:17
  |
5 |     cnb_runtime(CustomErrorHandler {});
  |                 ^^^^^^^^^^^^^^^^^^^^^ the trait `ErrorHandler` is not implemented for `CustomErrorHandler`
  |
note: there are multiple different versions of crate `c` in the dependency graph
 --> /home/gh-estebank/testcase-rustc-crate-version-mismatch/c-v0.2/src/lib.rs:1:1
  |
1 | pub trait ErrorHandler {}
  | ^^^^^^^^^^^^^^^^^^^^^^ this is the required trait
  |
 ::: src/main.rs:1:5
  |
1 | use b::CustomErrorHandler;
  |     - one version of crate `c` is used here, as a dependency of crate `b`
2 | use c::cnb_runtime;
  |     - one version of crate `c` is used here, as a direct dependency of the current crate
  |
 ::: /home/gh-estebank/testcase-rustc-crate-version-mismatch/b/src/lib.rs:1:1
  |
1 | pub struct CustomErrorHandler {}
  | ----------------------------- this type doesn't implement the required trait
  |
 ::: /home/gh-estebank/testcase-rustc-crate-version-mismatch/c-v0.1/src/lib.rs:1:1
  |
1 | pub trait ErrorHandler {}
  | ---------------------- this is the found trait
  = note: two types coming from two different versions of the same crate are different types even if they look the same
  = help: you can use `cargo tree` to explore your dependency tree
```

Fix #89143.
2024-11-08 00:34:48 +00:00
Celina G. Val
dd6ddcb18e [StableMIR] A few fixes to pretty printing
Improve identation, and a few other rvalue printing
2024-11-07 16:16:38 -08:00
bors
b91a3a0560 Auto merge of #132472 - taiki-e:sparc-asm, r=Amanieu
Basic inline assembly support for SPARC and SPARC64

This implements asm_experimental_arch (tracking issue https://github.com/rust-lang/rust/issues/93335) for SPARC and SPARC64.

This PR includes:

- General-purpose registers `r[0-31]` (`reg` register class, LLVM/GCC constraint `r`)
  Supported types: i8, i16, i32, i64 (SPARC64-only)
  Aliases: `g[0-7]` (`r[0-7]`), `o[0-7]` (`r[8-15]`), `l[0-7]` (`r[16-23]`), `i[0-7]` (`r[24-31]`)
- `y` register (clobber-only, needed for clobber_abi)
- preserves_flags: Integer condition codes (`icc`, `xcc`) and floating-point condition codes (`fcc*`)

The following are *not* included:

- 64-bit integer support on SPARC-V8+'s global or out registers (`g[0-7]`, `o[0-7]`): GCC's `h` constraint (it seems that there is no corresponding constraint in LLVM?)
- Floating-point registers (LLVM/GCC constraint `e`/`f`):
  I initially tried to implement this, but postponed it for now because there seemed to be several parts in LLVM that behaved differently than in the LangRef's description.
- clobber_abi: Support for floating-point registers is needed.

Refs:
- LLVM
  - Reserved registers https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/Sparc/SparcRegisterInfo.cpp#L52
  - Register definitions https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/Sparc/SparcRegisterInfo.td
  - Supported constraints https://llvm.org/docs/LangRef.html#supported-constraint-code-list
- GCC
  - Reserved registers 63b6967b06/gcc/config/sparc/sparc.h (L633-L658)
  - Supported constraints https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html
- SPARC ISA/ABI
  - (64-bit ISA) The SPARC Architecture Manual, Version 9
    (32-bit ISA) The SPARC Architecture Manual, Version 8
    (64-bit ABI) System V Application Binary Interface SPARC Version 9 Processor Supplement, Rev 1.35
    (32-bit ABI) System V Application Binary Interface SPARC Processor Supplement, Third Edition
    The above docs can be downloaded from https://sparc.org/technical-documents
  - (32-bit V8+ ABI) The V8+ Technical Specification
    https://temlib.org/pub/SparcStation/Standards/V8plus.pdf

cc `@thejpster` (sparc-unknown-none-elf target maintainer)
(AFAIK, other sparc/sprac64 targets don't have target maintainers)

r? `@Amanieu`

`@rustbot` label +O-SPARC +A-inline-assembly
2024-11-07 21:07:06 +00:00
Esteban Küber
76c59896e7 fix test 2024-11-07 20:56:36 +00:00
Josh Stone
03383ad102 Initialize channel Blocks directly on the heap
The channel's `Block::new` was causing a stack overflow because it held
32 item slots, instantiated on the stack before moving to `Box::new`.
The 32x multiplier made modestly-large item sizes untenable.

That block is now initialized directly on the heap.

Fixes #102246
2024-11-07 10:09:45 -08:00
Ralf Jung
ab1787b223 core: move intrinsics.rs into intrinsics folder 2024-11-07 17:49:45 +01:00
Taiki Endo
241f82ad91 Basic inline assembly support for SPARC and SPARC64 2024-11-07 21:19:03 +09:00
Jonas Böttiger
59582fb21a
Rollup merge of #132707 - zmodem:tests_vs_diagnostic_width, r=jieyouxu
Add --diagnostic-width to some tests failing after 1a0c502183

Otherwise the tests would fail depending on the execution environment.
2024-11-07 13:08:28 +01:00
Hans Wennborg
029add206f Add --diagnostic-width to some tests failing after 1a0c502183
Otherwise the tests would fail depending on the execution environment.
2024-11-06 20:02:42 +01:00
bors
4d215e2426 Auto merge of #132404 - makai410:suggest-swap-lhs-rhs, r=fee1-dead
Suggest swapping LHS and RHS when RHS impls `PartialEq<lhs_ty>`

Closes: #130495
r? `@fee1-dead`
2024-11-06 11:49:52 +00:00
bors
e1fb288562 Auto merge of #132663 - estebank:e0320-tweak, r=compiler-errors
Tweak E0320 overflow error wording

Surround type with backticks as we should in every error.
2024-11-06 06:40:17 +00:00
bors
a69df72bdc Auto merge of #132664 - matthiaskrgr:rollup-i27nr7i, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #131261 (Stabilize `UnsafeCell::from_mut`)
 - #131405 (bootstrap/codegen_ssa: ship llvm-strip and use it for -Cstrip)
 - #132077 (Add a new `wide-arithmetic` feature for WebAssembly)
 - #132562 (Remove the `wasm32-wasi` target from rustc)
 - #132660 (Remove unused errs.rs file)

Failed merges:

 - #131721 (Add new unstable feature `const_eq_ignore_ascii_case`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-06 01:21:42 +00:00
Matthias Krüger
088e698835
Rollup merge of #132077 - alexcrichton:wide-arithmetic, r=jieyouxu
Add a new `wide-arithmetic` feature for WebAssembly

This commit adds a new rustc target feature named `wide-arithmetic` for WebAssembly targets. This corresponds to the [wide-arithmetic] proposal for WebAssembly which adds new instructions catered towards accelerating integer arithmetic larger than 64-bits. This proposal to WebAssembly is not standard yet so this new feature is flagged as an unstable target feature. Additionally Rust's LLVM version doesn't support this new feature yet since support will first be added in LLVM 20, so the feature filtering logic for LLVM is updated to handle this.

I'll also note that I'm not currently planning to add wasm-specific intrinsics to `std::arch::wasm32` at this time. The currently proposed instructions are all accessible through `i128` or `u128`-based operations which Rust already supports, so intrinsic shouldn't be necessary to get access to these new instructions.

[wide-arithmetic]: https://github.com/WebAssembly/wide-arithmetic
2024-11-05 23:43:57 +01:00
Esteban Küber
dceb3fc9fa Tweak E0320 overflow error wording
Surrount type with backticks as we should in every error.
2024-11-05 21:54:45 +00:00
Matthias Krüger
aa4fe48afe
Rollup merge of #132571 - RalfJung:const_eval_select_macro, r=oli-obk
add const_eval_select macro to reduce redundancy

I played around a bit with a macro to make const_eval_select invocations look a bit nicer and avoid repeating the argument lists. Here's what I got. What do you think?

I didn't apply this everywhere yet because I wanted to gather feedback first.

The second commit moves the macros from https://github.com/rust-lang/rust/pull/132542 into a more sensible place. It didn't seem worth its own PR and would conflict with this PR if done separately.

Cc ``@oli-obk`` ``@saethlin`` ``@tgross35``

try-job: dist-aarch64-msvc
2024-11-05 20:10:52 +01:00
Matthias Krüger
bb50ebfca4
Rollup merge of #132567 - estebank:bad-suggestion, r=Nadrieril
Properly suggest `E::assoc` when we encounter `E::Variant::assoc`

Use the right span when encountering an enum variant followed by an associated item so we don't lose the associated item in the resulting code.

Do not suggest the thing twice, once as a removal of the associated item and a second time as a typo suggestion.
2024-11-05 20:10:51 +01:00
Matthias Krüger
b23655893e
Rollup merge of #132498 - uellenberg:typo-and-let-suggestions, r=estebank
Suggest fixing typos and let bindings at the same time

Fixes #132483

Currently, a suggestion for adding a let binding won't be shown if we suggest fixing a typo. This changes that behavior to always show both, if possible. Essentially, this turns the suggestion from
```rust
error[E0425]: cannot find value `x2` in this scope
 --> src/main.rs:4:5
  |
4 |     x2 = 2;
  |     ^^ help: a local variable with a similar name exists: `x1`

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

to
```rust
error[E0425]: cannot find value `x2` in this scope
 --> src/main.rs:4:5
  |
4 |     x2 = 2;
  |     ^^
  |
help: a local variable with a similar name exists
  |
4 |     x1 = 2;
  |     ~~
help: you might have meant to introduce a new binding
  |
4 |     let x2 = 2;
  |     +++

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

for the following code:
```rust
fn main() {
    let x1 = 1;
    x2 = 2;
}
```

The original behavior only shows the suggestion for a let binding if a typo suggestion wasn't already displayed. However, this falls apart in the cases like the one above where we have multiple similar variables. I don't think it makes sense to hide this suggestion if there's a similar variable, since that defeats the purpose of this suggestion in that case (it's meant to help those coming from languages like Python).
2024-11-05 20:10:50 +01:00
Matthias Krüger
c8247c0a19
Rollup merge of #132259 - mrkajetanp:branch-protection-pauth-lr, r=davidtwco
rustc_codegen_llvm: Add a new 'pc' option to branch-protection

Add a new 'pc' option to -Z branch-protection for aarch64 that enables the use of PC as a diversifier in PAC branch protection code.

When the pauth-lr target feature is enabled in combination with -Z branch-protection=pac-ret,pc, the new 9.5-a instructions (pacibsppc, retaasppc, etc) will be generated.
2024-11-05 20:10:49 +01:00
Boxy
1d6e847674 Check for both StmtKind::MacCall and ExprKind::MacCall 2024-11-05 18:23:21 +00:00
bors
e8c698bb3b Auto merge of #129884 - RalfJung:forbidden-target-features, r=workingjubilee
mark some target features as 'forbidden' so they cannot be (un)set with -Ctarget-feature

The context for this is https://github.com/rust-lang/rust/issues/116344: some target features change the way floats are passed between functions. Changing those target features is unsound as code compiled for the same target may now use different ABIs.

So this introduces a new concept of "forbidden" target features (on top of the existing "stable " and "unstable" categories), and makes it a hard error to (un)set such a target feature. For now, the x86 and ARM feature `soft-float` is on that list. We'll have to make some effort to collect more relevant features, and similar features from other targets, but that can happen after the basic infrastructure for this landed. (These features are being collected in https://github.com/rust-lang/rust/issues/131799.)

I've made this a warning for now to give people some time to speak up if this would break something.

MCP: https://github.com/rust-lang/compiler-team/issues/780
2024-11-05 16:25:45 +00:00
bors
096277e989 Auto merge of #132580 - compiler-errors:globs, r=Noratrieb
Remove unnecessary pub enum glob-imports from `rustc_middle::ty`

We used to have an idiom in the compiler where we'd prefix or suffix all the variants of an enum, for example `BoundRegionKind`, with something like `Br`, and then *glob-import* that enum variant directly.

`@noratrieb` brought this up, and I think that it's easier to read when we just use the normal style `EnumName::Variant`.

This PR is a bit large, but it's just naming.

The only somewhat opinionated change that this PR does is rename `BorrowKind::Imm` to `BorrowKind::Immutable` and same for the other variants. I think these enums are used sparingly enough that the extra length is fine.

r? `@noratrieb` or reassign
2024-11-05 08:30:56 +00:00
Ralf Jung
613f53ef19 add const_eval_select macro to reduce redundancy
also move internal const_panic helpers to a better location
2024-11-05 09:26:08 +01:00
bors
27e38f8fc7 Auto merge of #132626 - workingjubilee:rollup-hbmtbzk, r=workingjubilee
Rollup of 11 pull requests

Successful merges:

 - #131153 (Improve duplicate derive Copy/Clone diagnostics)
 - #132025 (fix suggestion for diagnostic error E0027)
 - #132303 (More tests for non-exhaustive C-like enums in FFI)
 - #132492 (remove support for extern-block const intrinsics)
 - #132587 (Revert "Avoid nested replacement ranges" from #129346.)
 - #132596 ([rustdoc] Fix `--show-coverage` when JSON output format is used)
 - #132598 (Clippy: Move some attribute lints to be early pass (post expansion))
 - #132601 (Update books)
 - #132606 (Improve example of `impl Pattern for &[char]`)
 - #132608 (document `type_implements_trait`)
 - #132609 (docs: fix grammar in doc comment at unix/process.rs)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-05 05:53:19 +00:00
Jubilee
23ef001d66
Rollup merge of #132492 - RalfJung:const-intrinsics, r=compiler-errors
remove support for extern-block const intrinsics

This converts all const-callable intrinsics into the "new" form of a regular `fn` with `#[rustc_intrinsic]` attribute. That simplifies some of the logic since those functions can be marked `const fn` like regular functions, so intrinsics no longer need a special case to be considered const-callable at all.

I also added a new attribute `#[rustc_const_stable_intrinsic]` to mark an intrinsic as being ready to be exposed on stable. Previously we used the `#[rustc_const_stable_indirect]` attribute for that, but that attribute had a dual role -- when used on a regular function, it is an entirely safe marker to make this function part of recursive const stability, but on an intrinsic it is a trusted marker requiring special care. It's not great for the same attribute to be sometimes fully checked and safe, and sometimes trusted and requiring special care, so I split this into two attributes.

This also fixes https://github.com/rust-lang/rust/issues/122652 by accepting intrinsics as const-stable if they have a fallback body that is recursively const-stable.

The library changes are best reviewed with whitespace hidden.

r? `@compiler-errors`
2024-11-04 20:40:46 -08:00
Jubilee
56aa51e67f
Rollup merge of #132303 - nyurik:non-exhaustive-err, r=compiler-errors
More tests for non-exhaustive C-like enums in FFI

Add a few more tests for the `improper_ctypes` lint as found with the [varnish-rs](https://github.com/gquintard/varnish-rs) project.

This follows up on #116831, fixed in #116863 by ``@workingjubilee`` - I have been seeing these fail with the bindgen-generated non-exhaustive enums inside other structs. Seems the issue does not exist in the primary branch, so this PR just makes sure more cases are covered for the future.
2024-11-04 20:40:45 -08:00
Jubilee
c17cf1d84e
Rollup merge of #132025 - duncpro:E0027, r=compiler-errors
fix suggestion for diagnostic error E0027

Closes #132008
2024-11-04 20:40:45 -08:00
Jubilee
972fef232e
Rollup merge of #131153 - VulnBandit:copy_impl_vuln, r=compiler-errors
Improve duplicate derive Copy/Clone diagnostics

Improve duplicate derive Copy/Clone diagnostics.
Closes #131083
2024-11-04 20:40:44 -08:00
bors
96477c55bc Auto merge of #131341 - taiki-e:ppc-clobber-abi, r=bzEq,workingjubilee
Support clobber_abi and vector registers (clobber-only) in PowerPC inline assembly

This supports `clobber_abi` which is one of the requirements of stabilization mentioned in #93335.

This basically does a similar thing I did in https://github.com/rust-lang/rust/pull/130630 to implement `clobber_abi` for s390x, but for powerpc/powerpc64/powerpc64le.
- This also supports vector registers (as `vreg`) as clobber-only, which need to support clobbering of them to implement `clobber_abi`.
- `vreg` should be able to accept `#[repr(simd)]` types as input/output if the unstable `altivec` target feature is enabled, but `core::arch::{powerpc,powerpc64}` vector types, `#[repr(simd)]`, and `core::simd` are all unstable, so the fact that this is currently a clobber-only should not be considered a blocker of clobber_abi implementation or stabilization. So I have not implemented it in this PR.
  - See https://github.com/rust-lang/rust/pull/131551 (which is based on this PR) for a PR to implement this.
  - (I'm not sticking to whether that PR should be a separate PR or part of this PR, so I can merge that PR into this PR if needed.)

Refs:
- PPC32 SysV: Section "Function Calling Sequence" in [System V Application Binary Interface PowerPC Processor Supplement](https://refspecs.linuxfoundation.org/elf/elfspec_ppc.pdf)
- PPC64 ELFv1: Section 3.2 "Function Calling Sequence" in [64-bit PowerPC ELF Application Binary Interface Supplement](https://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi.html#FUNC-CALL)
- PPC64 ELFv2: Section 2.2 "Function Calling Sequence" in [64-Bit ELF V2 ABI Specification](https://openpowerfoundation.org/specifications/64bitelfabi/)
- AIX: [Register usage and conventions](https://www.ibm.com/docs/en/aix/7.3?topic=overview-register-usage-conventions), [Special registers in the PowerPC®](https://www.ibm.com/docs/en/aix/7.3?topic=overview-special-registers-in-powerpc), [AIX vector programming](https://www.ibm.com/docs/en/aix/7.3?topic=concepts-aix-vector-programming)
- Register definition in LLVM: https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/PowerPC/PPCRegisterInfo.td#L189

If I understand the above four ABI documentations correctly, except for the PPC32 SysV's VR (Vector Registers) and 32-bit AIX (currently not supported by rustc)'s r13, there does not appear to be important differences in terms of implementing `clobber_abi`:
- The above four ABIs are consistent about FPR (0-13: volatile, 14-31: nonvolatile), CR (0-1,5-7: volatile, 2-4: nonvolatile), XER (volatile), and CTR (volatile).
- As for GPR, only the registers we are treating as reserved are slightly different
  - r0, r3-r12 are volatile
  - r1(sp, reserved), r14-31 are nonvolatile
  - r2(reserved) is TOC pointer in PPC64 ELF/AIX, system-reserved register in PPC32 SysV (AFAIK used as thread pointer in Linux/BSDs)
  - r13(reserved for non-32-bit-AIX) is thread pointer in PPC64 ELF, small data area pointer register in PPC32 SysV, "reserved under 64-bit environment; not restored across system calls[^r13]" in AIX)
- As for FPSCR, volatile in PPC64 ELFv1/AIX, some fields are volatile only in certain situations (rest are volatile) in PPC32 SysV/PPC64 ELFv2.
- As for VR (Vector Registers), it is not mentioned in PPC32 SysV, v0-v19 are volatile in both in PPC64 ELF/AIX, v20-v31 are nonvolatile in PPC64 ELF, reserved or nonvolatile depending on the ABI ([vec-extabi vs vec-default in LLVM](https://reviews.llvm.org/D89684), we are [using vec-extabi](https://github.com/rust-lang/rust/pull/131341#discussion_r1797693299)) in AIX:
  > When the default Vector enabled mode is used, these registers are reserved and must not be used.
  > In the extended ABI vector enabled mode, these registers are nonvolatile and their values are preserved across function calls

  I left [FIXME comment about PPC32 SysV](https://github.com/rust-lang/rust/pull/131341#discussion_r1790496095) and added ABI check for AIX.
- As for VRSAVE, it is not mentioned in PPC32 SysV, nonvolatile in PPC64 ELFv1, reserved in PPC64 ELFv2/AIX
- As for VSCR, it is not mentioned in PPC32 SysV/PPC64 ELFv1, some fields are volatile only in certain situations (rest are volatile) in PPC64 ELFv2, volatile in AIX

We are currently treating r1-r2, r13 (non-32-bit-AIX), r29-r31, LR, CTR, and VRSAVE as reserved.
We are currently not processing anything about FPSCR and VSCR, but I feel those are things that should be processed by `preserves_flags` rather than `clobber_abi` if we need to do something about them. (However, PPCRegisterInfo.td in LLVM does not seem to define anything about them.)

Replaces #111335 and #124279

cc `@ecnelises` `@bzEq` `@lu-zero`

r? `@Amanieu`

`@rustbot` label +O-PowerPC +A-inline-assembly

[^r13]: callee-saved, according to [LLVM](6a6af0246b/llvm/lib/Target/PowerPC/PPCCallingConv.td (L322)) and [GCC](a9173a50e7/gcc/config/rs6000/rs6000.h (L859)).
2024-11-05 03:13:47 +00:00
makai410
5791a66a88 suggest swapping the equality 2024-11-05 10:09:34 +08:00
Ralf Jung
a741b33c14 when an intrinsic has a const-stable fallback body, we can easily expose it on stable 2024-11-04 23:27:46 +01:00
Ralf Jung
5069434c81 most const intrinsics don't need an explicit rustc_const_unstable any more 2024-11-04 23:27:46 +01:00
Ralf Jung
1f0ed2b0f5 add new rustc_const_stable_intrinsic attribute for const-stable intrinsics 2024-11-04 23:27:46 +01:00
Ralf Jung
10723c2896 remove support for extern-block const intrinsics 2024-11-04 23:27:45 +01:00
Ralf Jung
ffad9aac27 mark some target features as 'forbidden' so they cannot be (un)set
For now, this is just a warning, but should become a hard error in the future
2024-11-04 22:56:47 +01:00
Urgau
0bc622d251 Prefer pub(super) in unreachable_pub lint suggestion 2024-11-04 19:09:40 +01:00
Matthias Krüger
a4f323ce9c
Rollup merge of #132583 - mejrs:tuples, r=compiler-errors
Suggest creating unary tuples when types don't match a trait

When you want to have a variadic function, a common workaround to implement this is to create a trait and then implement that trait for various tuples. For example in `pyo3` there exists
```rust
/// Calls the object with only positional arguments.
pub fn call1(&self, args: impl IntoPy<Py<PyTuple>>) -> PyResult<&PyAny> {
   ...
}
```

with various impls like
```rust
impl<A: IntoPy<PyObject> IntoPy<Py<PyAny>> for (A,)
impl<A: IntoPy<PyObject, B: IntoPy<PyObject> IntoPy<Py<PyAny>> for (A, B)
... etc
```

This means that if you want to call the method with a single item you have to create a unary tuple, like `(x,)`, rather than just `x`.

This PR implements a suggestion to do that, if applicable.
2024-11-04 18:12:48 +01:00
Matthias Krüger
909574e411
Rollup merge of #132559 - bvanjoi:fix-132534, r=compiler-errors
find the generic container rather than simply looking up for the assoc with const arg

Fixes #132534

This issue is caused by mismatched generic parameters. Previously, it tried to find `T` in `trait X`, but after this change, it will find `T` in `fn a`.

r? `@compiler-errors`  as this assertion was introduced by you.
2024-11-04 18:12:47 +01:00
Matthias Krüger
b9db639ea5
Rollup merge of #132544 - dianne:unstable-library-feature-backticks, r=compiler-errors
Use backticks instead of single quotes for library feature names in diagnostics

This PR changes the text of library feature errors for using unstable or body-unstable items. Displaying library feature names in backticks is consistent with other diagnostics (e.g. those from `rustc_passes`) and with the `reason`s on unstable attributes in the library. Additionally, this simplifies diagnostics when supporting multiple unstable attributes on items (see #131824) since `DiagSymbolList` also displays symbols using backticks.
2024-11-04 18:12:46 +01:00
mejrs
5a48fe2c20 Suggest creating unary tuples 2024-11-04 12:06:19 +01:00
Michael Goulet
e3bd6b27f3 Fix minicore, add tests based off of it 2024-11-04 04:51:32 +00:00
Michael Goulet
883f8705d4 Remove BorrowKind glob, make names longer 2024-11-04 04:45:52 +00:00
bohan
6026a0f6c9 find the generic container rather than simply looking up for the assoc with const arg 2024-11-04 12:17:44 +08:00
Jubilee
6bc7be5efa
Rollup merge of #132516 - taiki-e:asm-ui, r=workingjubilee
Add bad-reg inline assembly ui test for RISC-V and s390x

https://github.com/rust-lang/rust/pull/131341#discussion_r1826555431

> Btw, such unsupported registers are present in most architectures, but only aarch64/arm64ec, x86_64, and not yet merged [sparc/sparc64](https://github.com/rust-lang/rust/pull/132472/files#diff-02aebda3376c2b020265137f9ce2c387669ca5cfecd7d60494275c2387db5114) (and powerpc/powerpc64 by this PR) currently have ui tests for them.  I plan to add tests for other arches later.

Starting with RISC-V and s390x, which I'm familiar with and relatively easy to check for correctness.

(Relevant rustc code are supported_types/def_regs/overlapping_regs in [compiler/rustc_target/src/asm/riscv.rs](588a420350/compiler/rustc_target/src/asm/riscv.rs) and [compiler/rustc_target/src/asm/s390x.rs](588a420350/compiler/rustc_target/src/asm/s390x.rs).)

r? workingjubilee

`@rustbot` label +A-inline-assembly
2024-11-03 15:24:57 -08:00
dianne
d7d6238b23 use backticks instead of single quotes when reporting "use of unstable library feature"
This is consistent with all other diagnostics I could find containing
features and enables the use of `DiagSymbolList` for generalizing
diagnostics for unstable library features to multiple features.
2024-11-03 13:55:52 -08:00
Michael Goulet
6b96103bf3 Rename the FIXMEs, remove a few that dont matter anymore 2024-11-03 18:59:41 +00:00
Michael Goulet
0b5ddf30eb Yeet effects feature 2024-11-03 18:59:31 +00:00
Esteban Küber
e26ad8b67d Properly suggest E::assoc when we encounter E::Variant::assoc
Use the right span when encountering an enum variant followed by an associated item so we don't lose the associated item in the resulting code.

Do not suggest the thing twice, once as a removal of the associated item and a second time as a typo suggestion.
2024-11-03 18:55:19 +00:00
Michael Goulet
ace9e4c078 Gate checking ~const bounds on const_trait_impl 2024-11-03 18:48:24 +00:00
Esteban Küber
06fc531c96 Add test for assoc fn suggestion on enum variant 2024-11-03 17:15:22 +00:00
Matthias Krüger
1a0ab892cd
Rollup merge of #132528 - compiler-errors:fallback-sugg-opt, r=jieyouxu
Use `*_opt` typeck results fns to not ICE in fallback suggestion

Self-explanatory. Fixes #132517.
2024-11-03 12:08:54 +01:00
Matthias Krüger
625264329f
Rollup merge of #132523 - ranger-ross:test-issue-117446, r=compiler-errors
Added regression test for generics index out of bounds

Added a regression test for  #117446
This ICE was fixed in Rust 1.75 but a regression test was never added.

This PR adds a UI test with a reduced version of the original bug report that does not rely on external crates.
2024-11-03 12:08:54 +01:00
Matthias Krüger
9c7cdc2352
Rollup merge of #132520 - matthiaskrgr:knobu, r=jieyouxu
NFC add known bug nr to test

r? ```````@jieyouxu```````
2024-11-03 12:08:53 +01:00
Taiki Endo
b07232d95d Move tests/ui/abi/riscv32e-registers.rs to tests/ui/asm/riscv
This also adds comments explaining the difference to bad-reg.rs.
2024-11-03 18:32:04 +09:00
bors
8ccb78e0d5 Auto merge of #125579 - Noratrieb:print-host, r=davidtwco
Add `--print host-tuple` to print host target tuple

People often parse `-vV` output to get to the host tuple, which is annoying to do. It's easier to just get it directly.

I called it "host-tuple" instead of "host" because it's clearer that it's just the target name. I'm open to different names, but I think this one is fine.

a quick GitHub search for `'^host` reveals many instances of people doing the parsing, for example:

68e0ca57cd/README.md (L369)
0e38473b0c/main.sh (L96)
8a3553b865/README.md (L625)
43f3ec3970/do.sh (L35)

needs a compiler FCP. I could also do an MCP but I think just an FCP here makes the most sense.
2024-11-02 23:04:42 +00:00
uellenberg
67a85925b1 Suggest fixing typos and let bindings at the same time
Fixes #132483
2024-11-02 14:40:37 -07:00
Noratrieb
ba481518da Add --print host-triple
People often parse `-vV` output to get to the host triple, which is
annoying to do. It's easier to just get it directly.
2024-11-02 21:29:59 +01:00
Nilstrieb
77d0b4ddfb move deployment-target tests to print-request 2024-11-02 21:29:59 +01:00
bors
b3f75cc872 Auto merge of #132147 - estebank:long-types-2, r=davidtwco
Tweak E0277 output when a candidate is available

*Follow up to #132086.*

Go from

```
error[E0277]: the trait bound `Then<Ignored<chumsky::combinator::Filter<chumsky::primitive::Any<&str, chumsky::extra::Full<EmptyErr, (), ()>>, {closure@src/main.rs:9:17: 9:27}>, char>, chumsky::combinator::Map<impl CSTParser<'a, O>, O, {closure@src/main.rs:11:24: 11:27}>, (), (), chumsky::extra::Full<EmptyErr, (), ()>>: CSTParser<'a>` is not satisfied
 --> src/main.rs:7:50
  |
7 | fn leaf<'a, O>(parser: impl CSTParser<'a, O>) -> impl CSTParser<'a, ()> {
  |                                                  ^^^^^^^^^^^^^^^^^^^^^^ the trait `chumsky::private::ParserSealed<'_, &str, (), chumsky::extra::Full<EmptyErr, (), ()>>` is not implemented for `Then<Ignored<Filter<Any<&str, ...>, ...>, ...>, ..., ..., ..., ...>`, which is required by `Then<Ignored<chumsky::combinator::Filter<chumsky::primitive::Any<&str, chumsky::extra::Full<EmptyErr, (), ()>>, {closure@src/main.rs:9:17: 9:27}>, char>, chumsky::combinator::Map<impl CSTParser<'a, O>, O, {closure@src/main.rs:11:24: 11:27}>, (), (), chumsky::extra::Full<EmptyErr, (), ()>>: CSTParser<'a>`
  |
  = help: the trait `chumsky::private::ParserSealed<'_, &'a str, ((), ()), chumsky::extra::Full<EmptyErr, (), ()>>` is implemented for `Then<Ignored<chumsky::combinator::Filter<chumsky::primitive::Any<&str, chumsky::extra::Full<EmptyErr, (), ()>>, {closure@src/main.rs:9:17: 9:27}>, char>, chumsky::combinator::Map<impl CSTParser<'a, O>, O, {closure@src/main.rs:11:24: 11:27}>, (), (), chumsky::extra::Full<EmptyErr, (), ()>>`
  = help: for that trait implementation, expected `((), ())`, found `()`
  = note: required for `Then<Ignored<Filter<Any<&str, ...>, ...>, ...>, ..., ..., ..., ...>` to implement `Parser<'_, &str, ()>`
note: required for `Then<Ignored<Filter<Any<&str, ...>, ...>, ...>, ..., ..., ..., ...>` to implement `CSTParser<'a>`
 --> src/main.rs:5:16
  |
5 | impl<'a, O, T> CSTParser<'a, O> for T where T: Parser<'a, &'a str, O> {}
  |                ^^^^^^^^^^^^^^^^     ^          ---------------------- unsatisfied trait bound introduced here
  = note: the full name for the type has been written to '/home/gh-estebank/longlong/target/debug/deps/longlong-0008f9a4f2023b08.long-type-13239977239800463552.txt'
  = note: consider using `--verbose` to print the full type name to the console
  = note: the full name for the type has been written to '/home/gh-estebank/longlong/target/debug/deps/longlong-0008f9a4f2023b08.long-type-13239977239800463552.txt'
  = note: consider using `--verbose` to print the full type name to the console
```

to

```
error[E0277]: the trait bound `Then<Ignored<chumsky::combinator::Filter<chumsky::primitive::Any<&str, chumsky::extra::Full<EmptyErr, (), ()>>, {closure@src/main.rs:9:17: 9:27}>, char>, chumsky::combinator::Map<impl CSTParser<'a, O>, O, {closure@src/main.rs:11:24: 11:27}>, (), (), chumsky::extra::Full<EmptyErr, (), ()>>: CSTParser<'a>` is not satisfied
  --> src/main.rs:7:50
   |
7  | fn leaf<'a, O>(parser: impl CSTParser<'a, O>) -> impl CSTParser<'a, ()> {
   |                                                  ^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
...
11 |     ws.then(parser.map(|_| ()))
   |     --------------------------- return type was inferred to be `Then<Ignored<..., ...>, ..., ..., ..., ...>` here
   |
   = help: the trait `ParserSealed<'_, &_, (), Full<_, _, _>>` is not implemented for `Then<Ignored<..., ...>, ..., ..., ..., ...>`
           but trait `ParserSealed<'_, &'a _, ((), ()), Full<_, _, _>>` is implemented for it
   = help: for that trait implementation, expected `((), ())`, found `()`
   = note: required for `Then<Ignored<..., ...>, ..., ..., ..., ...>` to implement `Parser<'_, &str, ()>`
note: required for `Then<Ignored<..., ...>, ..., ..., ..., ...>` to implement `CSTParser<'a>`
  --> src/main.rs:5:16
   |
5  | impl<'a, O, T> CSTParser<'a, O> for T where T: Parser<'a, &'a str, O> {}
   |                ^^^^^^^^^^^^^^^^     ^          ---------------------- unsatisfied trait bound introduced here
   = note: the full name for the type has been written to '/home/gh-estebank/longlong/target/debug/deps/longlong-df9d52be87eada65.long-type-1337037744507305372.txt'
   = note: consider using `--verbose` to print the full type name to the console
```

* Remove redundant wording
* Introduce trait diff highlighting logic and use it
* Fix incorrect "long type written to path" logic (can be split off)
* Point at tail expression in more cases in E0277
* Avoid long primary span labels in E0277 by moving them to a `help`

Fix #132013.

There are individual commits that can be their own PR. If the review load is too big, happy to split them off.
2024-11-02 20:22:49 +00:00
Esteban Küber
7e0d3ed951 fix tests
Paths in CI can be longer than in devs' machines.
2024-11-02 16:58:50 +00:00
Michael Goulet
82f8b8f0e3 Use opt functions to not ICE in fallback suggestion 2024-11-02 15:25:12 +00:00
Jieyou Xu
5596a592e3 Adjust tests to use minicore and rebless 2024-11-02 21:59:27 +08:00
Taiki Endo
e97ba53879 Add bad-reg inline assembly ui test for RISC-V and s390x 2024-11-02 21:37:03 +08:00
ranger-ross
b9196757a0
Added regression test for 117446 2024-11-02 22:17:46 +09:00
Matthias Krüger
f341a19366 NFC add known bug nr to test 2024-11-02 13:33:39 +01:00
Taiki Endo
d19517dcd0 Support clobber_abi and vector registers (clobber-only) in PowerPC inline assembly 2024-11-02 20:26:08 +09:00
bors
588a420350 Auto merge of #132497 - matthiaskrgr:rollup-gaskcn0, r=matthiaskrgr
Rollup of 11 pull requests

Successful merges:

 - #131037 (Move versioned Apple LLVM targets from `rustc_target` to `rustc_codegen_ssa`)
 - #132170 (Add a Few Codegen Tests)
 - #132333 (rust_analyzer_helix.toml: add library/ manifest)
 - #132398 (Add a couple of intra-doc links to str)
 - #132411 (CI: switch dist-x86_64-musl to free runner)
 - #132453 (Also treat `impl` definition parent as transparent regarding modules)
 - #132457 (Remove needless #![feature(asm_experimental_arch)] from loongarch64 inline assembly test)
 - #132465 (refactor(config): remove FIXME statement in comment of `omit-git-hash`)
 - #132466 (Account for late-bound depth when capturing all opaque lifetimes.)
 - #132471 (Add a bunch of mailmap entries)
 - #132488 (Remove or fix some more `FIXME(async_closure)`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-02 08:25:59 +00:00
Matthias Krüger
30497b05cd
Rollup merge of #132488 - compiler-errors:more-fixmes-bye, r=jieyouxu
Remove or fix some more `FIXME(async_closure)`

Self-explanatory
2024-11-02 08:33:15 +01:00
Matthias Krüger
020b63aebc
Rollup merge of #132466 - cjgillot:opaque-late, r=compiler-errors
Account for late-bound depth when capturing all opaque lifetimes.

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

r? ````@compiler-errors````
2024-11-02 08:33:14 +01:00
Matthias Krüger
fa69b671a9
Rollup merge of #132453 - Urgau:non_local_defs-impl-mod-transparent, r=jieyouxu
Also treat `impl` definition parent as transparent regarding modules

This PR changes the `non_local_definitions` lint logic to also consider `impl` definition parent as transparent regarding modules.

See tests and explanation in the changes.

``````@rustbot`````` label +L-non_local_definitions
Fixes *(after beta-backport)* #132427
cc ``````@leighmcculloch``````
r? ``````@jieyouxu``````
2024-11-02 08:33:13 +01:00
bors
b5f4883a06 Auto merge of #132352 - DianQK:llvm/19.1.3, r=nikic
Update LLVM to 19.1.3

Closes #131031.

r? nikic
2024-11-02 04:59:26 +00:00
Michael Goulet
9e5e47fc32 Remove or fix some FIXME(async_closure) 2024-11-02 03:33:31 +00:00
Esteban Küber
143b072c62 Account for negative bounds in E0277 note and suggestion
Do not suggest `#[derive(Copy)]` when we wanted a `!Copy` type.

Do not say "`Copy` is not implemented for `T` but `Copy` is".

Do not talk about `Trait` having no implementations when `!Trait` was desired.
2024-11-02 03:08:04 +00:00
Esteban Küber
1a0c502183 On long E0277 primary span label, move it to a help
Long span labels don't read well.
2024-11-02 03:08:04 +00:00
Esteban Küber
092ecca5b9 Point at tail expression on rpit E0277
```
error[E0277]: the trait bound `{gen block@$DIR/gen_block_is_coro.rs:7:5: 7:8}: Coroutine` is not satisfied
  --> $DIR/gen_block_is_coro.rs:6:13
   |
LL | fn foo() -> impl Coroutine<Yield = u32, Return = ()> {
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Coroutine` is not implemented for `{gen block@$DIR/gen_block_is_coro.rs:7:5: 7:8}`
LL |     gen { yield 42 }
   |     ---------------- return type was inferred to be `{gen block@$DIR/gen_block_is_coro.rs:7:5: 7:8}` here
```

The secondary span label is new.
2024-11-02 03:08:04 +00:00
Esteban Küber
7b9105dd88 Trim output of E0277 in some cases
Remove default note for "trait is not implemented" in favor of the
more colorful diff output from the previous commit. Removes
duplicated output.
2024-11-02 03:08:04 +00:00
Esteban Küber
b7fc1a7431 Add trait diff highlighting logic and use it in E0277
When a trait is not implemented for a type, but there *is* an `impl`
for another type or different trait params, we format the output to
use highlighting in the same way that E0308 does for types.

The logic accounts for 3 cases:
- When both the type and trait in the expected predicate and the candidate are different
- When only the types are different
- When only the trait generic params are different

For each case, we use slightly different formatting and wording.
2024-11-02 03:08:04 +00:00
bors
7c7bb7dc01 Auto merge of #132470 - GuillaumeGomez:rollup-1a1mkmp, r=GuillaumeGomez
Rollup of 14 pull requests

Successful merges:

 - #131829 (Remove support for `-Zprofile` (gcov-style coverage instrumentation))
 - #132369 (style-guide: Only use the new binop heuristic for assignments)
 - #132383 (Implement suggestion for never type fallback lints)
 - #132413 (update offset_of! docs to reflect the stabilization of nesting)
 - #132438 (Remove unncessary option for default rust-analyzer setting)
 - #132439 (Add `f16` and `f128` to `invalid_nan_comparison`)
 - #132444 (rustdoc: Directly use rustc_abi instead of reexports)
 - #132445 (Cleanup attributes around unchecked shifts and unchecked negation in const)
 - #132448 (Add missing backtick)
 - #132450 (Show actual MIR when MIR building forgot to terminate block)
 - #132451 (remove some unnecessary rustc_allow_const_fn_unstable)
 - #132455 (make const_alloc_layout feature gate only about functions that are already stable)
 - #132456 (Move remaining inline assembly test files into asm directory)
 - #132459 (feat(byte_sub_ptr): unstably add ptr::byte_sub_ptr)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-01 21:49:15 +00:00
Luca Versari
c8b76bcf58 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
2024-11-01 22:24:35 +01:00
Guillaume Gomez
e9e7aa8487
Rollup merge of #132448 - chengehe:master, r=Noratrieb
Add missing backtick
2024-11-02 03:08:54 +08:00