Commit Graph

24946 Commits

Author SHA1 Message Date
Jonathan Brouwer 2834b1654a Rollup merge of #155068 - lapla-cogito:multibyte_char, r=mati865
Fix ICE in `span_extend_prev_while` with multibyte characters

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

The function assumed that the character found by `rfind` was always one byte wide, using a hardcoded `1` instead of `c.len_utf8()`. When a multibyte character appeared immediately before the span, this caused the resulting span to point into the middle of a UTF-8 sequence, triggering an assertion failure in `bytepos_to_file_charpos`.
2026-04-12 15:44:20 +02:00
Jonathan Brouwer 5daeaa9b3a Rollup merge of #155014 - androm3da:hexagon-scalar-target-features, r=mati865
Hexagon: add scalar arch-version target features (v60-v79, audio)

Add target features corresponding to Hexagon LLVM CPU generations to complement the existing HVX vector features. These are needed for gating scalar intrinsics by architecture version.

New features: audio, v60, v62, v65, v66, v67, v68, v69, v71, v73, v75, v79

Each version implies the previous (e.g. v68 implies v67 which implies v66, etc.), matching LLVM's ArchV60-ArchV79 subtarget features.

Also adds hexagon revisions to the feature-hierarchy test to verify the implied feature chains work correctly.
2026-04-12 15:44:19 +02:00
Jonathan Brouwer b36833d634 Rollup merge of #154804 - cijiugechu:fix/host-effect-hrtb-ice, r=adwinwhite
Fix ICE when reporting host-effect errors for const Fn HRTBs in next trait solver

Avoid leaking bound vars into the diagnostic selection path for HRTB host-effect predicates.

Closes rust-lang/rust#151894 .
2026-04-12 15:44:18 +02:00
cijiugechu 0b02f678c4 Handle leaked host-effect HRTBs before selection 2026-04-12 14:44:20 +08:00
Matthias Krüger 56ecb157e2 Rollup merge of #153630 - arferreira:fix-doc-hidden-reexport-diagnostic-path, r=jackh726
Deprioritize doc(hidden) re-exports in diagnostic paths

Fixes rust-lang/rust#153477.

This is the other half of rust-lang/rust#99698, which fixed the case where the *parent module* is `#[doc(hidden)]` but left the case where the re-export itself is `#[doc(hidden)]` as a FIXME (with a tracking test in `dont-suggest-doc-hidden-variant-for-enum/hidden-child.rs`).

The problem: when a crate does `#[doc(hidden)] pub use core::error::Error`, diagnostics pick up the hidden re-export path instead of the canonical one. For example, `snafu::Error` instead of `std::error::Error`.

Two changes:

In `visible_parent_map`, the `add_child` closure now checks whether the re-export itself is `#[doc(hidden)]` via `reexport_chain` and sends it to `fallback_map`, same treatment as doc-hidden parents and underscore re-exports.

`should_encode_attrs` now returns `true` for `DefKind::Use`. Without this, `#[doc(hidden)]` on `use` items was never written to crate metadata, so `is_doc_hidden` always returned `false` cross-crate. This was the actual root cause, the check in `visible_parent_map` alone isn't enough if the attribute isn't in the metadata.

The existing FIXME test now serves as the regression test. The `.stderr` goes from suggesting `hidden_child::__private::Some(1i32)` to just `Some(1i32)`.

cc @eggyal
2026-04-12 08:15:46 +02:00
Jacob Pratt 22328dc33a Rollup merge of #155159 - TaKO8Ki:min-specialization-next-solver-region-resolution, r=Kivooeo
Fix min-specialization ICE from ignored region resolution failure

Fixes rust-lang/rust#151327

`min_specialization::get_impl_args` resolved regions and then immediately called `fully_resolve`, but it ignored failures from `resolve_regions_and_report_errors`.

Propagate the region-resolution error instead of ignoring it. That matches the pattern used in:

https://github.com/rust-lang/rust/blob/40a3ed1e1407ebbe892ce1a74128482ea1dadf7a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs#L706

https://github.com/rust-lang/rust/blob/40a3ed1e1407ebbe892ce1a74128482ea1dadf7a/compiler/rustc_hir_analysis/src/coherence/builtin.rs#L421
2026-04-11 21:12:23 -04:00
Jacob Pratt 1700a21d10 Rollup merge of #155126 - folkertdev:target-object-format, r=Urgau
add `cfg(target_object_format = "...")`

tracking issue: https://github.com/rust-lang/rust/issues/152586

I'm implementing the predicate as `target_object_format`, because that's what is useful to me (for testing `#[link_section = "..."]` where `mach-o` has some extra restrictions) and maps cleanly to the `BinaryFormat` enum that is used internally. There is still room for a future `target_executable_format` when there is a use case.

cc @joshtriplett as the lang sponsor of this feature, @workingjubilee as the author of the proposal.

r? JonathanBrouwer a sidequest from the sidequest that is https://github.com/rust-lang/rust/pull/155065
2026-04-11 21:12:20 -04:00
Jacob Pratt d83352b491 Rollup merge of #155084 - scottmcm:add-transmute-prefix, r=Mark-Simulacrum
Initial functions to start on transmute v2

For context, see https://github.com/rust-lang/rfcs/pull/3844 and https://github.com/rust-lang/libs-team/issues/772

*Experimental* still, tracked under https://github.com/rust-lang/rust/issues/155079

This is just library functions.  A future PR will do compiler changes for things like lints.
2026-04-11 21:12:19 -04:00
Takayuki Maeda 8998c11244 add next-solver min-specialization region-resolution regression test 2026-04-12 00:03:26 +09:00
bors bf4fbfb7a1 Auto merge of #155149 - danieljofficial:move-tests-deref, r=Kivooeo
Move deref tests from issues into deref folder

Hi, Some deref tests, please look at them when you can
 r? @Kivooeo
2026-04-11 13:43:17 +00:00
Folkert de Vries 6bcd172f5a add cfg(target_object_format = "...") 2026-04-11 14:12:39 +02:00
danieljofficial cf986478fd add issue links and bless 2026-04-11 12:01:46 +01:00
danieljofficial c00aa3de46 move deref tests out of tests/ui/issues 2026-04-11 10:23:58 +01:00
bors 5f36a7f807 Auto merge of #155145 - jhpratt:rollup-atReM8h, r=jhpratt
Rollup of 3 pull requests

Successful merges:

 - rust-lang/rust#154827 (distinguish "expected a single argument" and "expected an argument" on attribute parsing)
 - rust-lang/rust#155104 (bootstrap: auto-patch libgccjit.so for NixOS)
 - rust-lang/rust#155120 (Use a linting node closer the parsing of `#[cfg_attr]`)
2026-04-11 09:03:13 +00:00
Jacob Pratt b2088a21df Rollup merge of #155120 - Urgau:check-cfg-allow-cfg_attr-mod, r=JonathanBrouwer
Use a linting node closer the parsing of `#[cfg_attr]`

The parsing of `#[cfg_attr]` unconditionally used the crate-root as a linting node to attach lints, but the `unexpected_cfgs` lint can fire when parsing the attribute and users expect to be able to allow it at places other than the crate-root.

Let's instead use the linting node id, which is unfortunately always the parent but that's better than the crate-root when you are in a sub-module.

The parsing of `#[cfg]` and other already use the expansion linting node id, so no change required there.

Related to https://github.com/rust-lang/rust/issues/155118
2026-04-11 04:50:17 -04:00
Jacob Pratt ca34f771c0 Rollup merge of #154827 - scrabsha:push-zuosxmmnzkrq, r=jdonszelmann
distinguish "expected a single argument" and "expected an argument" on attribute parsing
2026-04-11 04:50:15 -04:00
Jacob Pratt 9237f14282 Rollup merge of #155132 - jakedrew:fix/suggest-similar-target-on-unrecognized-155085, r=Kivooeo
Suggest similar target names on unrecognized `--target`

When an unrecognized `--target` is passed check the list of available targets and suggest the closest matching built-in target as a help message.

### Before

```
    error: error loading target specification: could not find specification for target "x86_64-linux-gnu"
      = help: run `rustc --print target-list` for a list of built-in targets
```

### After

```
    error: error loading target specification: could not find specification for target "x86_64-linux-gnu"
      = help: run `rustc --print target-list` for a list of built-in targets
      = help: did you mean `x86_64-unknown-linux-gnu`?
```

Regarding the expected test case in https://github.com/rust-lang/rust/issues/155085#issuecomment-4222050023 the `edit_distance_with_substrings` was used over `edit_distance` because in the case of `x86_64-linux-gnu` the `edit_distance` would return `x86_64-linux-android` instead of `x86_64-unknown-linux-gnu`

rust-lang/rust#155085
2026-04-11 01:49:13 -04:00
Jacob Pratt 44bad026ce Rollup merge of #154661 - CoCo-Japan-pan:impl-restriction-check, r=jhpratt,Urgau
Semantic checks of `impl` restrictions

This PR implements semantic checks for `impl` restrictions proposed in the [Restrictions RFC](https://rust-lang.github.io/rfcs/3323-restrictions.html) (Tracking Issue rust-lang/rust#105077), and linked to a [GSOC idea/proposal](https://github.com/rust-lang/google-summer-of-code/tree/142433eb3b104b2f32bae0b9dfafb78a0a2ac579?tab=readme-ov-file#implementing-impl-and-mut-restrictions).

It lowers the resolved paths of `impl` restrictions from the AST to HIR and into `TraitDef`, and integrates the checks into the coherence phase by extending `check_impl`. As parsing (rust-lang/rust#152943) and path resolution (rust-lang/rust#153556) have already been implemented, this PR provides a working implementation of `impl` restrictions.

r? @Urgau
cc @jhpratt
2026-04-11 01:49:12 -04:00
bors c7c14d4fb0 Auto merge of #155044 - WaffleLapkin:dont-remove-unneeded-drops, r=scottmcm
Don't try to remove `drop_in_place` calls in `RemoveUnneededDrops`



As per my justification in https://github.com/rust-lang/rust/pull/154327#discussion_r3056946688

r? scottmcm
2026-04-11 00:55:22 +00:00
Jake Drew 1137762b09 Suggest similar target names on unrecognized --target 2026-04-10 22:47:09 +01:00
bors 02c7f9bec0 Auto merge of #155115 - JonathanBrouwer:rollup-RePrRPQ, r=JonathanBrouwer
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#152901 (Introduce a `#[diagnostic::on_unknown]` attribute)
 - rust-lang/rust#155078 (Reject dangling attributes in where clauses)
 - rust-lang/rust#154449 (Invert dependency between `rustc_errors` and `rustc_abi`.)
 - rust-lang/rust#154646 (Add suggestion to `.to_owned()` used on `Cow` when borrowing)
 - rust-lang/rust#154993 (compiletest: pass -Zunstable-options for unpretty and no-codegen paths)
 - rust-lang/rust#155097 (Make `rustc_attr_parsing::SharedContext::emit_lint` take a `MultiSpan` instead of a `Span`)
2026-04-10 18:19:03 +00:00
Urgau f97143d951 Use a linting node closer the parsing of #[cfg_attr] 2026-04-10 20:04:37 +02:00
Jonathan Brouwer 9c01701171 Rollup merge of #154646 - m4rch3n1ng:144792-cow-diag, r=davidtwco
Add suggestion to `.to_owned()` used on `Cow` when borrowing

fixes rust-lang/rust#144792
supersedes rust-lang/rust#144925 with the review comments addressed

the tests suggested from @Kivooeo from https://github.com/rust-lang/rust/pull/144925#discussion_r2252703007 didn't work entirely, because these tests failed due to error `[E0308]` mismatched types, which actually already provides a suggestion, that actually makes the code compile:

```
$ cargo check
error[E0308]: mismatched types
 --> src/main.rs:3:5
  |
1 | fn test_cow_suggestion() -> String {
  |                             ------ expected `std::string::String` because of return type
2 |     let os_string = std::ffi::OsString::from("test");
3 |     os_string.to_string_lossy().to_owned()
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `String`, found `Cow<'_, str>`
  |
  = note: expected struct `std::string::String`
               found enum `std::borrow::Cow<'_, str>`
help: try using a conversion method
  |
3 |     os_string.to_string_lossy().to_owned().to_string()
  |                                           ++++++++++++
```

now this suggestion is of course not good or efficient code, but via clippy with `-Wclippy::nursery` lint group you can actually get to the correct code, so i don't think this is too much of an issue:

<details>
<summary>the clippy suggestions</summary>

```
$ cargo clippy -- -Wclippy::nursery
warning: this `to_owned` call clones the `Cow<'_, str>` itself and does not cause its contents to become owned
 --> src/main.rs:3:5
  |
3 |     os_string.to_string_lossy().to_owned().to_string()
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/beta/index.html#suspicious_to_owned
  = note: `#[warn(clippy::suspicious_to_owned)]` on by default
help: depending on intent, either make the `Cow` an `Owned` variant
  |
3 |     os_string.to_string_lossy().into_owned().to_string()
  |                                 ++
help: or clone the `Cow` itself
  |
3 -     os_string.to_string_lossy().to_owned().to_string()
3 +     os_string.to_string_lossy().clone().to_string()
  |
$ # apply first suggestion
$ cargo c -- -Wclippy::nursery
warning: redundant clone
 --> src/main.rs:3:45
  |
3 |     os_string.to_string_lossy().into_owned().to_string()
  |                                             ^^^^^^^^^^^^ help: remove this
  |
note: this value is dropped without further use
 --> src/main.rs:3:5
  |
3 |     os_string.to_string_lossy().into_owned().to_string()
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  = help: for further information visit https://rust-lang.github.io/rust-clippy/beta/index.html#redundant_clone
  = note: `-W clippy::redundant-clone` implied by `-W clippy::nursery`
  = help: to override `-W clippy::nursery` add `#[allow(clippy::redundant_clone)]`
```

</details>

the actual error that we are looking for is error `[E0515]`, cannot return value referencing local variable, which was only present in the original issue due to automatic type inference assuming you want to return a cloned `Cow<'_, str>`, which is of course not possible. this is why i took the original test functions and turned them into closures, where it's less obvious that it's trying to return the wrong type.

r? davidtwco

(because you reviewed the last attempt)
(also, let me know if i should squash this down to one commit and add myself as the co-contributor)
2026-04-10 18:38:14 +02:00
Jonathan Brouwer c729f33e46 Rollup merge of #155078 - cijiugechu:fix/where-clause-trailing-attrs, r=petrochenkov
Reject dangling attributes in where clauses

Report `attribute without where predicates` for trailing outer attributes in where clauses.

Closes rust-lang/rust#155073 .
2026-04-10 18:38:12 +02:00
Jonathan Brouwer dbf9492774 Rollup merge of #152901 - weiznich:feature/on_unknown_item, r=jdonszelmann
Introduce a `#[diagnostic::on_unknown]` attribute

This PR introduces a `#[diagnostic::on_unknown]` attribute that allows crate authors to customize the error messages emitted by unresolved imports. The main usecase for this is using this attribute as part of a proc macro that expects a certain external module structure to exist or certain dependencies to be there.

For me personally the motivating use-case are several derives in diesel, that expect to refer to a `tabe` module. That is done either implicitly (via the name of the type with the derive) or explicitly by the user. This attribute would allow us to improve the error message in both cases:

* For the implicit case we could explicity call out our assumptions (turning the name into lower case, adding an `s` in the end)
+ point to the explicit variant as alternative
* For the explicit variant we would add additional notes to tell the user why this is happening and what they should look for to fix the problem (be more explicit about certain diesel specific assumptions of the module structure)

I assume that similar use-cases exist for other proc-macros as well, therefore I decided to put in the work implementing this new attribute. I would also assume that this is likely not useful for std-lib internal usage.

related rust-lang/rust#152900 and rust-lang/rust#128674
2026-04-10 18:38:11 +02:00
bors b6100ccf71 Auto merge of #155099 - JonathanBrouwer:rollup-nKbnTlV, r=JonathanBrouwer
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#155047 (Always exhaustively match on typing mode)
 - rust-lang/rust#155080 (Simplify `try_load_from_disk_fn`.)
 - rust-lang/rust#152384 (Restrict EII declarations to functions at lowering time)
 - rust-lang/rust#153796 (Fix ICE when combining #[eii] with #[core::contracts::ensures])
 - rust-lang/rust#154369 (Fix `pattern_from_macro_note` for bit-or expr)
 - rust-lang/rust#155027 ( Rename some more of our internal `#[rustc_*]` TEST attributes)
 - rust-lang/rust#155031 (delegation: fix unelided lifetime ICE, refactoring of GenericArgPosition)
 - rust-lang/rust#155040 (Fix code block whitespace handling in Markdown)
2026-04-10 14:43:38 +00:00
cijiugechu 3c6cf27ae4 Reject dangling attributes in where clauses 2026-04-10 21:45:26 +08:00
CoCo-Japan-pan 46befd885d Display only crate name for external trait impl restrictions 2026-04-10 22:40:29 +09:00
Jonathan Brouwer 3b8c7eccdc Rollup merge of #155031 - aerooneqq:delegation-generic-args-lowering-ice, r=petrochenkov
delegation: fix unelided lifetime ICE, refactoring of GenericArgPosition

This PR does two things:
- First it restores `lower_generic_args_of_path` as it was before rust-lang/rust#151864, as it turns out we should use `GenericArgPosition::Type` for generic args lowering for signature inheritance, as it will not cause lifetime inference and then ICEs during child args lowering,
- Next it refactors `GenericArgPosition` enum replacing `Value` and `MethodCall` with `Call(IsMethodCall)`, as the only place where we created `Value` or `MethodCall` variants was in `check_generic_arg_count_for_call`, where it was a match over `is_method_call`. Not sure it is needed, but seems cleaner to me.

Fixes rust-lang/rust#154178, part of rust-lang/rust#118212.

r? @petrochenkov
2026-04-10 15:33:14 +02:00
Jonathan Brouwer 6547a33a8b Rollup merge of #155027 - fmease:more-test-attr-renamings, r=JonathanBrouwer
Rename some more of our internal `#[rustc_*]` TEST attributes

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

r? JonathanBrouwer or jdonszelmann
2026-04-10 15:33:13 +02:00
Jonathan Brouwer ad68deab08 Rollup merge of #154369 - ver-nyan:fix-bit_or-pat_macro-msg, r=JohnTitor
Fix `pattern_from_macro_note` for bit-or expr

This is a continuation of issue https://github.com/rust-lang/rust/issues/99380 (and pr https://github.com/rust-lang/rust/pull/124488) but covers bit-or pattern.

Essentially a `pat1 | pat2`, or any bit-or pattern used in a `$e:expr` was not firing the `.pattern_from_macro_note` diagnostic bc `ast::Expr::is_approximately_pattern()` did not cover bit-or.

The cover for bit-or is only added in `lower_expr_within_pat()`, otherwise doing it in `is_approximately_pattern()` would result in the suggestion `if (i + 2) = 2 => if let (i + 2) = 2` from `suggest_pattern_match_with_let()` (which is the only other place `ast::Expr::is_approximately_pattern()` is used from what i see).

resolves https://github.com/rust-lang/rust/issues/99380
refs https://github.com/rust-lang/rust/pull/124488
2026-04-10 15:33:13 +02:00
Jonathan Brouwer 45223feeba Rollup merge of #153796 - GokhanKabar:fix-ice-missing-tokens-eii-attr-expansion, r=jdonszelmann
Fix ICE when combining #[eii] with #[core::contracts::ensures]

Fixes rust-lang/rust#153745

Builtin attribute macros like #[eii] generate AST items programmatically without collected tokens. When another attribute macro was present on the same item, the compiler would panic in TokenStream::from_ast() trying to tokenize the generated items during subsequent attribute expansion.

Generate fake token streams (via pretty-print and re-parse) for Item and ForeignItem nodes that lack collected tokens, following the existing pattern used for Crate and out-of-line modules.
2026-04-10 15:33:12 +02:00
Jonathan Brouwer 5b16a31a0e Rollup merge of #152384 - enthropy7:fix-eii-root-resolution-clean, r=jdonszelmann
Restrict EII declarations to functions at lowering time

We tighten EII declaration resolution so that `lower_path_simple_eii` only accepts function‑like items (`Fn, AssocFn, Ctor(_, Fn)`) as valid EII targets. If name resolution points at something else (like a const with the same name), we now emit a direct error (“`externally implementable items must refer to a function`”) at the declaration site, which prevents bad `DefIds` from ever reaching `compare_eii_function_types` and turning into an ICE

this is more robust and root-cause oriented fix to rust-lang/rust#152337 issue and an alternate of my more simple PR rust-lang/rust#152365

test included
2026-04-10 15:33:11 +02:00
Jonathan Brouwer 610eaec233 Rollup merge of #155047 - jdonszelmann:lint-against-eq-typing-mode, r=lcnr
Always exhaustively match on typing mode

r? @lcnr

Unimplements Eq/PartialEq for TypingMode, adds TypingModeEqWrapper for the few cases where we need it (mainly in the query system), and adds a new rustc internal lint to detect cases where we non-exhaustively match on typing mode.
2026-04-10 15:33:10 +02:00
Jana Dönszelmann 18d118a7b7 fixup rustdoc,clippy,rustfmt 2026-04-10 15:10:04 +02:00
Jana Dönszelmann d5d0153254 make all typing-mode conditional code an exhaustive match 2026-04-10 15:01:37 +02:00
bors 8317fef204 Auto merge of #152996 - mu001999-contrib:feat/extend-import-self, r=petrochenkov
Replacing `self` overwriting with proper resolution

Reference PR:

- https://github.com/rust-lang/reference/pull/2221



As a follow-up PR to https://github.com/rust-lang/rust/pull/146972 ([step 1](https://github.com/rust-lang/rust/pull/152996#issuecomment-4011548479)), after this PR:
~~1. Trailing `self` can appear in paths (as the consensus in https://github.com/rust-lang/rust/pull/146972#issuecomment-3719825627)~~ (in future)
~~2. [E0429](https://doc.rust-lang.org/stable/error_codes/E0429.html#error-code-e0429) will be no longer emitted, `use ...::self [as target];` will be equivalent to `use ...::{self [as target]};`~~ (in future)
3. Things like `struct S {}; use S::{self as Other};` will be rejected

---

This PR used to add a new lint `redundant_self`, which would lint `use ...::self [as target];` and `use ...::{self [as target]};`, and fixes all warnings emitted by this lint.

But this lint and clippy lint [unnecessary_self_imports](https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_self_imports) have some overlap. And `use std::io::self;` is not equivalent to `use std::io` in fact for now, the new lint will also cause the following known issue:
> Removing `::{self}` will cause any non-module items at the same path to also be imported. This might cause a naming conflict (https://github.com/rust-lang/rustfmt/issues/3568).

So I removed this lint, and I think what it does should be done by extending the clippy lint `unnecessary_self_imports`.

r? petrochenkov
2026-04-10 11:30:02 +00:00
León Orell Valerian Liehr cb4a7f4f19 Rename #[rustc_symbol_name] to #[rustc_dump_symbol_name] 2026-04-10 12:14:39 +02:00
León Orell Valerian Liehr 0a597064ba Rename #[rustc_def_path] to #[rustc_dump_def_path] 2026-04-10 12:14:23 +02:00
León Orell Valerian Liehr dda1ea0c43 Rename #[rustc_hidden_type_of_opaques] to #[rustc_dump_hidden_type_of_opaques] 2026-04-10 12:14:07 +02:00
León Orell Valerian Liehr 7025605b8c Rename #[rustc_dump_layout]'s abi option to backend_repr
Moreover, dereference `ty_layout.align` for `#[rustc_dump_layout(align)]`
to render `align: Align($N bytes)` instead of `align: AbiAlign { abi: Align($N bytes) }`
which contains the same amount of information but it more concise and legible.
2026-04-10 12:13:52 +02:00
León Orell Valerian Liehr 357f670fde Rename #[rustc_layout] to #[rustc_dump_layout] 2026-04-10 12:13:48 +02:00
Jana Dönszelmann 2facd34bc8 add #[rustc_must_match_exhaustively] 2026-04-10 11:43:27 +02:00
Scott McMurray 63d7f8e7ae Initial methods to start on transmute v2 2026-04-10 01:58:56 -07:00
Waffle Lapkin fa73f032b8 don't try to remove drop_in_place calls in RemoveUnneededDrops 2026-04-10 09:32:35 +02:00
Georg Semmler 97da8195de Rename the attribute to on_unknown 2026-04-10 09:01:20 +02:00
Georg Semmler 6e5fc9075c Introduce a #[diagnostic::on_unknown_item] attribute
This PR introduces a `#[diagnostic::on_unknown_item]` attribute that
allows crate authors to customize the error messages emitted by
unresolved imports. The main usecase for this is using this attribute as
part of a proc macro that expects a certain external module structure to
exist or certain dependencies to be there.

For me personally the motivating use-case are several derives in diesel,
that expect to refer to a `tabe` module. That is done either
implicitly (via the name of the type with the derive) or explicitly by
the user. This attribute would allow us to improve the error message in
both cases:

* For the implicit case we could explicity call out our
assumptions (turning the name into lower case, adding an `s` in the end)
+ point to the explicit variant as alternative
* For the explicit variant we would add additional notes to tell the
user why this is happening and what they should look for to fix the
problem (be more explicit about certain diesel specific assumptions of
the module structure)

I assume that similar use-cases exist for other proc-macros as well,
therefore I decided to put in the work implementing this new attribute.
I would also assume that this is likely not useful for std-lib internal
usage.
2026-04-10 08:55:02 +02:00
aerooneqq 9e8069fef1 Fix unelided lifetime ICE, refactoring of GenericArgPosition 2026-04-10 09:53:31 +03:00
Jacob Pratt c305a1a5e9 Rollup merge of #155071 - Fayti1703:alloc/no-thread-local, r=Kivooeo
Deny `#[global_allocator]` + `#[thread_local]`

This forbids using `#[thread_local]` on `static` items that are also `#[global_allocator]`s.

Fixes rust-lang/rust#85517.
2026-04-10 00:00:03 -04:00
Jacob Pratt d788fbfb58 Rollup merge of #155015 - jakubadamw:issues-104037-112623-113899, r=Kivooeo
Add tests for three fixed issues (an LLVM crash, an ICE and poor codegen)

Closes rust-lang/rust#104037.
Closes rust-lang/rust#112623.
Closes rust-lang/rust#113899.
2026-04-10 00:00:01 -04:00