2046 Commits

Author SHA1 Message Date
Jonathan Brouwer
a09c4fc862 Fix types being marked as dead when they are inferred generic arguments
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-10-30 08:31:07 +01:00
Matthias Krüger
8f11852e78 Rollup merge of #138679 - Shunpoco:issue-125323, r=oli-obk
Issue-125323: ICE non-ADT in struct pattern when long time constant evaluation is in for loop

This PR fixes #125323

## Context
According to the issue, the ICE happens since #121206.
In the PR, some error methods were reorganized. For example, has_errors() was renamed to has_errors_exclude_lint_errors(). However, some codes which used the original has_errors() were not switched to has_errors_exclude_lint_errors(). I finally found that report_error() in writeback.rs causes this ICE. Currently the method uses tainted_by_errors() to get guar (ErrorGuaranteed), but originally it used dcx().has_errors() but it wasn't changed to has_errors_exclude_lint_errors() when changes in #121206 were merged. I don't think I fully understand how an error is propagated, but I suppose that the error from long time constant evaluation is unexpectedly propagated other parts (in this ICE, for loop), then cause the non-ADT in struct pattern ICE.

## Change
- Fix report_error() in writeback.rs: use dcx().has_errors_exclude_lint_errors() instead of tainted_by_errors() to prevent error propagation from constant evaluation.
- Add test for the ICE
- Modify some tests to align the change: Due to this fix, E0282 error happens (or not happen anymore) in some tests.

## NOTE
The 4th commit aims to revert the fix in #123516 because I confirmed that the ICE solved by the PR doesn't happen if I modify report_error(). I think the root cause of that ICE is the same as #125323 . But I can discard this commit since we can fix #125323 without it.
2025-10-18 23:54:43 +02:00
Shunpoco
845ff73d39 address review 2025-10-17 18:20:21 +01:00
Shunpoco
8e59e3ba33 treat an error taint from const eval lint in late_lint and check_mod_deathness
error from const eval lint causes ICE at check_pat in late_lint, because the function expects the typeck result isn't tainted by error but it is.
To avoid the ICE, check_pat returns earlier if the typeck_result is tainted.

check_mod_deathness also has an issue from the same reason. visit_body for making live symbols expects the typeck result has no error.
So this commit adds a check in visit_nested_body to avoid the ICE.
However, if visit_nested_body just returns without doing anything, all codes with the error are marked as dead, because live_symbols is empty.
To avoid this side effect, visit_nested_body and other visit_* functions in MarkSymbolVistior should return appropriate error.
If a function returns ControlFlow::Break, live_symbols_and_ignore_derived_traits returns earlier with error,
then check_mod_deathness, the caller of the function returns earlier without pushing everything into dead_codes.
2025-10-17 18:20:21 +01:00
Cameron Steffen
e60e9f0826 Split impl_(opt_)trait_ref 2025-10-17 08:36:34 -05:00
Cameron Steffen
c17b2dc283 Split trait_id_of_impl into impl(_opt)_trait_id 2025-10-17 08:36:34 -05:00
Matthias Krüger
72030511bb Rollup merge of #147685 - jdonszelmann:deprecated-no-span, r=JonathanBrouwer
remove span calls from deprecated attribute checking

r? `@JonathanBrouwer`
2025-10-15 07:09:56 +02:00
Matthias Krüger
545ee6fe6b Rollup merge of #147683 - jdonszelmann:less-duplicate-checking, r=JonathanBrouwer
only check duplicates on old/unparsed attributes

r? ``@JonathanBrouwer``

This was effectively already what we were doing, but this was implicit because `.name()` etc were just returning None when dealing with a parsed attribute.... this makes it explicit
2025-10-14 19:47:35 +02:00
Matthias Krüger
ea0c8d8e73 Rollup merge of #147682 - jdonszelmann:convert-rustc-main, r=JonathanBrouwer
convert `rustc_main` to the new attribute parsing infrastructure

r? ``@JonathanBrouwer``
2025-10-14 19:47:34 +02:00
Jana Dönszelmann
43d915c426 remove span calls from deprecated attribute checking 2025-10-14 18:44:22 +02:00
Jana Dönszelmann
047c37cf23 convert rustc_main to the new attribute parsing infrastructure 2025-10-14 17:55:00 +02:00
Jana Dönszelmann
a51a793472 only check duplicates on old/unparsed attributes 2025-10-14 17:32:05 +02:00
Matthias Krüger
81dd4082ab Rollup merge of #147615 - jdonszelmann:span-calls-doc-attr, r=JonathanBrouwer,GuillaumeGomez
reduce calls to attr.span() in old doc attr parsing

r? `@oli-obk`

should be trivial, can also delegate to `@GuillaumeGomez` or `@JonathanBrouwer.`

As part of making span() return an option I want to reduce the number of places we call span in without it being known what specific attr it's for. This makes that more obvious for doc. Part of a chain of PRs that's coming.

https://github.com/rust-lang/rust/issues/131229#issuecomment-3395316064
2025-10-13 16:54:15 +02:00
Jana Dönszelmann
09ef5eb8af reduce calls to attr.span() in old doc attr parsing 2025-10-12 22:15:58 +02:00
Camille GILLOT
ca0379d6cd Diagnose liveness on MIR. 2025-10-11 20:50:21 +00:00
Camille Gillot
96b70fc3a1 Always compile hir_id_validator.
Making this compilation conditional causes an unused crate dependency
warning.
2025-10-11 20:50:21 +00:00
Camille GILLOT
5620c82e53 Report uninhabited call return types on MIR. 2025-10-11 20:50:20 +00:00
Stuart Cook
9ace0de26b Rollup merge of #147489 - chenyukang:yukang-prefer-repeat-n, r=Kivooeo,oli-obk
Prefer to use repeat_n over repeat().take()

More from https://github.com/rust-lang/rust/pull/147464, but batch processed with `ast-grep` to find and replace.

second commit add notes for library: affaf532f9

r? ``@RalfJung``
2025-10-09 18:43:26 +11:00
yukang
53c79f4523 bless format 2025-10-09 01:29:16 +08:00
yukang
1654cce210 prefer to use repeat_n over repeat and take 2025-10-09 01:24:55 +08:00
Boxy Uwu
8e9b0c4ca9 rename select_where_possible and select_all_or_error 2025-10-07 23:02:23 +01:00
bors
981353ca16 Auto merge of #147345 - Kivooeo:tidy-flt-fix, r=Kobzol
Tidy: revert `flt` to `ftl`

As was explained here https://github.com/rust-lang/rust/pull/147191#issuecomment-3353801210, this reverting this change because `flt` is incorrect format

Also maybe there is existed PR for that? I didn't found one

Follow up https://github.com/rust-lang/rust/pull/147191

cc `@GuillaumeGomez`
2025-10-05 15:55:18 +00:00
Stuart Cook
cae84c695a Rollup merge of #147320 - chenyukang:yukang-fix-147303-fn-arg, r=jieyouxu
Avoid to suggest pattern match on the similarly named in fn signature

Fixes rust-lang/rust#147303
2025-10-05 15:35:03 +11:00
Kivooeo
67bc030833 change flt back to ftl 2025-10-04 18:18:58 +00:00
yukang
e9a45e6646 Avoid to suggest pattern match on the similarly named in fn signature 2025-10-04 17:12:41 +08:00
Jules Bertholet
d5ba5c1c92 Mark PatternTypo suggestion as maybe incorrect 2025-10-03 16:00:15 -04:00
Guillaume Gomez
9362ab549f Improve code and fix typo 2025-09-27 11:29:50 +02:00
Guillaume Gomez
653e1036ed Apply first review round suggestions 2025-09-27 11:29:50 +02:00
Guillaume Gomez
553308b115 Improve code and better check doc(cfg(...)) attributes 2025-09-27 11:29:49 +02:00
Guillaume Gomez
1561efe41a Add code documentation, improve code and improve error message 2025-09-27 11:29:49 +02:00
Guillaume Gomez
63aefe0737 Strenghten checks for doc(auto_cfg(show/hide)) attributes 2025-09-27 11:29:48 +02:00
Guillaume Gomez
7c00bccd3b Implement RFC 3631 2025-09-27 11:29:48 +02:00
Matthias Krüger
d09bb02eb5 Rollup merge of #146704 - jdonszelmann:port-debug-visualizer, r=petrochenkov
port `#[debugger_visualizer]` to the new attribute system
2025-09-26 18:11:09 +02:00
Stuart Cook
fab06469ee Rollup merge of #146667 - calebzulawski:simd-mono-lane-limit, r=lcnr,RalfJung
Add an attribute to check the number of lanes in a SIMD vector after monomorphization

Allows std::simd to drop the `LaneCount<N>: SupportedLaneCount` trait and maintain good error messages.

Also, extends rust-lang/rust#145967 by including spans in layout errors for all ADTs.

r? ``@RalfJung``

cc ``@workingjubilee`` ``@programmerjake``
2025-09-25 20:31:53 +10:00
Caleb Zulawski
f5c6c9542e Add an attribute to check the number of lanes in a SIMD vector after monomorphization
Unify zero-length and oversized SIMD errors
2025-09-23 20:47:34 -04:00
Jana Dönszelmann
9acc63a48c port #[debugger_visualizer] to the new attribute system 2025-09-21 21:30:16 -07:00
Jonathan Brouwer
6abcadc235 Port #[macro_export] to the new attribute parsing infrastructure
Co-authored-by: Anne Stijns <anstijns@gmail.com>
2025-09-21 10:42:47 -04:00
Stuart Cook
540fd20ba6 Rollup merge of #146664 - fmease:clean-up-dyn, r=jdonszelmann
Clean up `ty::Dynamic`

1. As a follow-up to PR rust-lang/rust#143036, remove `DynKind` entirely.
2. Inside HIR ty lowering, consolidate modules `dyn_compatibility` and `lint` into `dyn_trait`
   * `dyn_compatibility` wasn't about dyn compatibility itself, it's about lowering trait object types
   * `lint` contained dyn-Trait-specific diagnostics+lints only
2025-09-18 11:48:51 +10:00
Jana Dönszelmann
205189c8c7 port #[rustc_coherence_is_core] to the new attribute parsing infrastructure 2025-09-17 10:02:23 -07:00
Stuart Cook
6ad98750e0 Rollup merge of #145660 - jbatez:darwin_objc, r=jdonszelmann,madsmtm,tmandry
initial implementation of the darwin_objc unstable feature

Tracking issue: https://github.com/rust-lang/rust/issues/145496

This feature makes it possible to reference Objective-C classes and selectors using the same ABI used by native Objective-C on Apple/Darwin platforms. Without it, Rust code interacting with Objective-C must resort to loading classes and selectors using costly string-based lookups at runtime. With it, these references can be loaded efficiently at dynamic load time.

r? ```@tmandry```

try-job: `*apple*`
try-job: `x86_64-gnu-nopt`
2025-09-17 14:56:44 +10:00
León Orell Valerian Liehr
26f3337d4e Remove DynKind 2025-09-17 04:46:46 +02:00
Jo Bates
1ebf69d1b1 initial implementation of the darwin_objc unstable feature 2025-09-13 16:06:22 -07:00
Jacob Pratt
141cb38f15 Rollup merge of #146171 - scrabsha:push-wovnxxwltsun, r=WaffleLapkin
tidy: check that error messages don't start with a capitalized letter
2025-09-13 18:55:17 -04:00
bors
637b50be01 Auto merge of #145186 - camsteffen:assoc-impl-kind, r=petrochenkov
Make `AssocItem` aware of its impl kind

The general goal is to have fewer query dependencies by making `AssocItem` aware of its parent impl kind (inherent vs. trait) without having to query the parent def_kind.

See individual commits.
2025-09-13 13:59:48 +00:00
Jana Dönszelmann
147e97ae68 Rollup merge of #146389 - jdonszelmann:no-std, r=oli-obk
Convert `no_std` and `no_core` to the new attribute infrastructure

r? ```@oli-obk```

Also added a test for these, since we didn't have any and I was kind of surprised new diagnostics didn't break anything hehe
2025-09-13 02:40:44 +02:00
Cameron Steffen
9615ec7d10 Split AssocContainer::{InherentImpl,TraitImpl} 2025-09-12 15:14:15 -05:00
Cameron Steffen
88a8bfcaf0 Introduce hir::ImplItemImplKind 2025-09-12 15:14:15 -05:00
Cameron Steffen
16c218c57f Introduce trait_item_of 2025-09-12 15:10:30 -05:00
Sasha Pourcelot
b152974301 tidy: check that error messages don't start with a capitalized letter 2025-09-10 21:45:07 +02:00
Matthias Krüger
422c76adae Rollup merge of #146178 - folkertdev:static-align, r=jdonszelmann,ralfjung,traviscross
Implement `#[rustc_align_static(N)]` on `static`s

Tracking issue: https://github.com/rust-lang/rust/issues/146177

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

#[rustc_align_static(64)]
static SO_ALIGNED: u64 = 0;
```

We need a different attribute than `rustc_align` because unstable attributes are tied to their feature (we can't have two unstable features use the same unstable attribute). Otherwise this uses all of the same infrastructure as `#[rustc_align]`.

r? `@traviscross`
2025-09-10 14:17:38 +02:00