Commit Graph

19780 Commits

Author SHA1 Message Date
Matthias Krüger
6ebf642a04 Rollup merge of #142237 - benschulz:unused-parens-fn, r=fee1-dead
Detect more cases of unused_parens around types

With this change, more unused parentheses around bounds and types nested within bounds are detected.
2025-07-02 19:29:35 +02:00
Matthias Krüger
3ff0aa530d Rollup merge of #143231 - xizheyin:143152, r=fee1-dead
Suggest use another lifetime specifier instead of underscore lifetime

cc rust-lang/rust#143152

r? compiler
2025-07-02 19:28:07 +02:00
Matthias Krüger
4f44014c5c Rollup merge of #143194 - folkertdev:fix-single-element-simd-bitcast, r=workingjubilee
fix bitcast of single-element SIMD vectors

in effect this reverts https://github.com/rust-lang/rust/pull/142768 and adds additional tests. That PR relaxed the conditions on an early return in an incorrect way that would create broken LLVM IR.

https://godbolt.org/z/PaaGWTv5a

```rust
#![feature(repr_simd)]

#[repr(simd)]
#[derive(Clone, Copy)]
struct S([i64; 1]);

#[no_mangle]
pub extern "C" fn single_element_simd(b: S) -> i64 {
    unsafe { std::mem::transmute(b) }
}
```
at the time of writing generates this LLVM IR, where the type of the return is different from the function's return type.

```llvm
define noundef i64 ``````@single_element_simd(<1`````` x i64> %b) unnamed_addr {
start:
  ret <1 x i64> %b
}
```

The test output is actually the same for the existing tests, showing that the change didn't actually matter for any tested behavior. It is probably a bit faster to do the early return, but, well, it's incorrect in general.

zullip thread: [#t-compiler > Is transmuting a &#96;T&#96; to &#96;Tx1&#96; (one-element SIMD vector) UB?](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Is.20transmuting.20a.20.60T.60.20to.20.60Tx1.60.20.28one-element.20SIMD.20vector.29.20UB.3F/with/526262799)
cc ``````@sayantn``````
r? ``````@scottmcm``````
2025-07-02 19:28:06 +02:00
Matthias Krüger
d5658d33de Rollup merge of #142321 - ostylk:fix/ppc64_abi, r=workingjubilee
Expose elf abi on ppc64 targets

Fixes https://github.com/rust-lang/rust/issues/60617 (after MCP https://github.com/rust-lang/compiler-team/issues/885 is accepted) by exposing the abi information on ppc64 targets.
Conditional compilation can now use `cfg(target_abi = "elfv1")` or `cfg(target_abi = "elfv2")` to determine the abi in use.

Technical details are included in the other PR https://github.com/rust-lang/rust/pull/142598
2025-07-02 19:28:05 +02:00
bors
1ce9c977ff Auto merge of #143214 - camsteffen:remove-let-chains-feature, r=est31
Remove let_chains unstable feature

Per https://github.com/rust-lang/rust/issues/53667#issuecomment-3016742982 (but then I also noticed rust-lang/rust#140722)

This replaces the feature gate with a parser error that says let chains require 2024.

A lot of tests were using the unstable feature. I either added edition:2024 to the test or split out the parts that require 2024.
2025-07-02 17:18:47 +00:00
Bastian Kersting
8a0d8dde44 Make the enum check work for negative discriminants
The discriminant check was not working correctly for negative numbers.
This change fixes that by masking out the relevant bits correctly.
2025-07-02 20:02:27 +03:00
Camille GILLOT
4a95b16527 Move crashes tests. 2025-07-02 10:51:40 +00:00
bors
f51c9870ba Auto merge of #142974 - cuviper:stage0-bump, r=Mark-Simulacrum
Update stage0 to 1.89.0-beta.1

- Update version placeholders
- Update stage0 to 1.89.0-beta.1
- Update `STAGE0_MISSING_TARGETS`
- Update `cfg(bootstrap)`

r? `@Mark-Simulacrum`

try-job: dist-i586-gnu-i586-i686-musl
2025-07-02 01:41:18 +00:00
Michael Goulet
91c53c97a9 Consider polarity in sizedness fast path 2025-07-02 00:37:40 +00:00
bors
085c24790e Auto merge of #143036 - compiler-errors:no-dyn-star, r=oli-obk
Remove support for `dyn*` from the compiler

This PR removes support for `dyn*` (https://github.com/rust-lang/rust/issues/102425), which are a currently un-RFC'd experiment that was opened a few years ago to explore a component that we thought was necessary for AFIDT (async fn in dyn trait).

It doesn't seem like we are going to need `dyn*` types -- even in an not-exposed-to-the-user way[^1] -- for us to implement AFIDT. Given that AFIDT was the original motivating purpose of `dyn*` types, I don't really see a compelling reason to have to maintain their implementation in the compiler.

[^1]: Compared to, e.g., generators whih are an unstable building block we use to implement stable syntax like `async {}`.

We've learned quite a lot from `dyn*`, but I think at this point its current behavior leads to more questions than answers. For example, `dyn*` support today remains somewhat fragile; it ICEs in many cases where the current "normal" `dyn Trait` types rely on their unsizedness for their vtable-based implementation to be sound I wouldn't be surprised if it's unsound in other ways, though I didn't play around with it too much. See the examples below.

```rust
#![feature(dyn_star)]

trait Foo {
    fn hello(self);
}

impl Foo for usize {
    fn hello(self) {
        println!("hello, world");
    }
}

fn main() {
    let x: dyn* Foo = 1usize;
    x.hello();
}
```

And:

```rust
#![feature(dyn_star)]

trait Trait {
    type Out where Self: Sized;
}

fn main() {
    let x: <dyn* Trait as Trait>::Out;
}
```

...and probably many more problems having to do with the intersection of dyn-compatibility and `Self: Sized` bounds that I was too lazy to look into like:
* GATs
* Methods with invalid signatures
* Associated consts

Generally, `dyn*` types also end up getting in the way of working with [normal `dyn` types](https://github.com/rust-lang/rust/issues/102425#issuecomment-1712604409) to an extent that IMO outweighs the benefit of experimentation.

I recognize that there are probably other, more creative usages of `dyn*` that are orthogonal to AFIDT. However, I think any work along those lines should first have to think through some of the more fundamental interactions between `dyn*` and dyn-compatibility before we think about reimplementing them in the type system.

---

I'm planning on removing the `DynKind` enum and the `PointerLike` built-in trait from the compiler after this PR lands.

Closes rust-lang/rust#102425.

cc `@eholk` `@rust-lang/lang` `@rust-lang/types`

Closes rust-lang/rust#116979.
Closes rust-lang/rust#119694.
Closes rust-lang/rust#134591.
Closes rust-lang/rust#104800.
2025-07-01 21:50:21 +00:00
Esteban Küber
bb74f47327 Do not suggest borrow that is already there in fully-qualified call
When encountering `&str::from("value")` do not suggest `&&str::from("value")`.

Fix #132041.
2025-07-01 21:49:56 +00:00
Michael Goulet
2516c33982 Remove support for dyn* 2025-07-01 19:00:21 +00:00
Kivooeo
1fb5e0149f moved tests 2025-07-01 23:33:59 +05:00
bors
71e4c005ca Auto merge of #143287 - GuillaumeGomez:rollup-fdjcti9, r=GuillaumeGomez
Rollup of 12 pull requests

Successful merges:

 - rust-lang/rust#136801 (Implement `Random` for tuple)
 - rust-lang/rust#141867 (Describe Future invariants more precisely)
 - rust-lang/rust#142760 (docs(fs): Touch up grammar on lock api)
 - rust-lang/rust#143181 (Improve testing and error messages for malformed attributes)
 - rust-lang/rust#143210 (`tests/ui`: A New Order [19/N] )
 - rust-lang/rust#143212 (`tests/ui`: A New Order [20/N])
 - rust-lang/rust#143230 ([COMPILETEST-UNTANGLE 2/N] Make some compiletest errors/warnings/help more visually obvious)
 - rust-lang/rust#143240 (Port `#[rustc_object_lifetime_default]` to the new attribute parsing …)
 - rust-lang/rust#143255 (Do not enable LLD by default in the dist profile)
 - rust-lang/rust#143262 (mir: Mark `Statement` and `BasicBlockData` as `#[non_exhaustive]`)
 - rust-lang/rust#143269 (bootstrap: make comment more clear)
 - rust-lang/rust#143279 (Remove `ItemKind::descr` method)

Failed merges:

 - rust-lang/rust#143237 (Port `#[no_implicit_prelude]` to the new attribute parsing infrastructure)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-07-01 18:09:52 +00:00
Josh Stone
9ce8930da6 Update version placeholders 2025-07-01 10:54:33 -07:00
Kivooeo
e9191ec57e moved tests 2025-07-01 21:42:20 +05:00
Guillaume Gomez
189bfc1e63 Rollup merge of #143279 - GuillaumeGomez:rm-itemkind-descr, r=oli-obk
Remove `ItemKind::descr` method

Follow-up of rust-lang/rust#143234.

After this PR is merged, it will remain two `descr` methods:

 * `hir::GenericArg::descr`
 * `hir::AssocItemConstraintKind::descr`

For both these enums, I don't think there is the right equivalent in `hir::DefKind` so unless I missed something, we can't remove these two methods because we can't convert these enums into `hir::DefKind`.

r? `@oli-obk`
2025-07-01 17:47:06 +02:00
Guillaume Gomez
65942afb97 Rollup merge of #143212 - Kivooeo:tf20, r=tgross35
`tests/ui`: A New Order [20/N]

> [!NOTE]
>
> Intermediate commits are intended to help review, but will be squashed prior to merge.

Some `tests/ui/` housekeeping, to trim down number of tests directly under `tests/ui/`. Part of rust-lang/rust#133895.

r? `@tgross35`
2025-07-01 17:47:03 +02:00
Guillaume Gomez
ff0a5f5ad7 Rollup merge of #143210 - Kivooeo:tf19, r=tgross35
`tests/ui`: A New Order [19/N]

> [!NOTE]
>
> Intermediate commits are intended to help review, but will be squashed prior to merge.

Some `tests/ui/` housekeeping, to trim down number of tests directly under `tests/ui/`. Part of rust-lang/rust#133895.

r? `@tgross35`
2025-07-01 17:47:02 +02:00
bors
4e97337005 Auto merge of #142030 - oli-obk:wfck-less-hir, r=compiler-errors
Start moving wf checking away from HIR

I'm trying to only access the HIR in the error path. My hope is that once we move significant portions of wfcheck off HIR that incremental will be able to cache wfcheck queries significantly better.

I think I am reaching a blocker because we normally need to provide good spans to `ObligationCause`, so that the trait solver can report good errors. In some cases I have been able to use bad spans and improve them depending on the `ObligationCauseCode` (by loading HIR in the case where we actually want to error). To scale that further we'll likely need to remove spans from the `ObligationCause` entirely (leaving it to some variants of `ObligationCauseCode` to have a span when they can't recompute the information later). Unsure this is the right approach, but we've already been using it. I will create an MCP about it, but that should not affect this PR, which is fairly limited in where it does those kind of tricks.

Especially b862d8828e is interesting here, because I think it improves spans in all cases
2025-07-01 14:59:58 +00:00
Jonathan Brouwer
57a5e3b6d2 Fix duplicate errors for link_section, rustc_layout_scalar_valid_range_start and rustc_layout_scalar_valid_range_end 2025-07-01 16:40:47 +02:00
Kivooeo
1549585f26 moved tests 2025-07-01 19:28:14 +05:00
Jonathan Brouwer
d22ce4c5eb Fix duplicate help on export_name and others
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-01 16:10:07 +02:00
Jonathan Brouwer
0b67d14b31 Fix #[rustc_macro_transparency] giving two errors
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-01 16:10:07 +02:00
Jonathan Brouwer
149bdde97e Fix #[must_use = 1] not giving an error
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-01 16:10:05 +02:00
Jonathan Brouwer
86b54d5729 Fix double error for export_name
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-01 16:10:02 +02:00
Jonathan Brouwer
0fcf295b64 New test for malformed attributes
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-01 16:10:02 +02:00
Folkert de Vries
8fdf0ef0ae loop match: handle opaque patterns
fixes issue 143203
2025-07-01 15:53:52 +02:00
Folkert de Vries
aa7cc5d2f4 loop match: run exhaustiveness check 2025-07-01 15:53:50 +02:00
Guillaume Gomez
7c3bddaa74 Update rustdoc GUI tests 2025-07-01 15:49:45 +02:00
Kivooeo
986f1c9b69 moved tests 2025-07-01 18:21:05 +05:00
Guillaume Gomez
022c91465a Remove ItemKind::descr method 2025-07-01 14:36:28 +02:00
xizheyin
e7c3703c53 Suggest use another lifetime specifier instead of underscore lifetime
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-01 19:58:27 +08:00
Camille GILLOT
4750dff54e Remove extraneous types. 2025-07-01 11:40:44 +00:00
Camille GILLOT
be41333604 Store a full Ty with each Value. 2025-07-01 11:40:36 +00:00
Kivooeo
1daba45636 cleaned up some tests 2025-07-01 16:26:57 +05:00
Trevor Gross
3b57db4d87 Give some UI tests more apropriate names
Prepare for rework done by the rest of RUST-142440.

Co-authored-by: Kivooeo <Kivooeo123@gmail.com>
2025-07-01 16:26:56 +05:00
Kivooeo
f12120d2bd cleaned up some tests 2025-07-01 15:29:29 +05:00
Kivooeo
6ca9b43ea9 moved test files 2025-07-01 15:22:16 +05:00
Kivooeo
da5c6395da cleaned up some tests 2025-07-01 15:16:56 +05:00
bors
86e05cd300 Auto merge of #142921 - JonathanBrouwer:rustc_attributes_parser, r=oli-obk
Port `#[rustc_layout_scalar_valid_range_start/end]` to the new attrib…

Ports `rustc_layout_scalar_valid_range_start` and `rustc_layout_scalar_valid_range_end` to the new attribute parsing infrastructure for https://github.com/rust-lang/rust/issues/131229#issuecomment-2971353197

r? `@jdonszelmann`
2025-07-01 08:33:00 +00:00
Tim Neumann
7ca9f9363d tests/codegen/enum/enum-match.rs: accept negative range attribute 2025-07-01 09:17:29 +02:00
Benjamin Schulz
7d6764a45b Detect more cases of unused_parens around types 2025-07-01 08:56:20 +02:00
Matthias Krüger
3944c8ce44 Rollup merge of #143264 - Muscraft:fix-suggestion-filename, r=compiler-errors
fix: Emit suggestion filename if primary diagnostic span is dummy

While working on using `annotate-snippets` as `rustc`'s emitter, I came across [`tests/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.stderr`](b03b3a7ec9/tests/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.stderr), which lacked a filename for both the annotation and the suggestion, which seemed like a bug to me. After some investigation, I found that this is happening because the primary span is a dummy, so its filename doesn't get output, and its filename matches the one for the suggestion, so the suggestion's filename doesn't get output. To fix this issue, I made it so that the filename for a suggestion will get output if the primary span is a dummy.
2025-07-01 04:25:38 +02:00
Matthias Krüger
cfe1942a3f Rollup merge of #143245 - tgross35:metavariable-expr-organization, r=petrochenkov
mbe: Add tests and restructure metavariable expressions

Add tests that show better diagnostics, and factor `concat` handling to a separate function. Each commit message has further details.

This performs the nonfunctional perparation for further changes such as https://github.com/rust-lang/rust/pull/142950 and https://github.com/rust-lang/rust/pull/142975 .
2025-07-01 04:25:36 +02:00
Matthias Krüger
e2ea213874 Rollup merge of #143234 - GuillaumeGomez:ice-143128, r=oli-obk
Replace `ItemCtxt::report_placeholder_type_error` match with a call to `TyCtxt::def_descr`

Fixes rust-lang/rust#143128.

We could likely use `tcx.def_descr` in more places (and therefore remove more `descr` methods). If it's something that we want to do, I can send a follow-up.

r? `@oli-obk`
2025-07-01 04:25:36 +02:00
Matthias Krüger
96fd669328 Rollup merge of #143156 - folkertdev:fn-align-inherit-from-trait, r=workingjubilee
inherit `#[align]` from trait method prototypes

````@workingjubilee```` this seems straightforward enough. Now that we're planning to make `-Cmin-function-alignment` a target modifier, I don't think there are any cross-crate complications here?

````@Jules-Bertholet```` is this the behavior you had in mind? In particular the inheritance of the attribute of a default impl is maybe a bit unintuitive at first? (but I think it's ok if that behavior is explicitly documented).

r? ghost
2025-07-01 04:25:35 +02:00
Scott Schafer
c8fac7779e fix: Emit suggestion filename if primary diagnostic span is dummy 2025-06-30 19:24:22 -06:00
Jeremy Smart
3bf650f980 add failing test, bless incorrect output 2025-06-30 18:03:39 -04:00
Kivooeo
9a7db566d7 moved tests 2025-07-01 02:45:14 +05:00