Commit graph

315740 commits

Author SHA1 Message Date
rust-bors[bot]
f57eac1bf9
Auto merge of #146923 - oli-obk:comptime-reflect, r=BoxyUwU
Reflection MVP

I am opening this PR for discussion about the general design we should start out with, as there are various options (that are not too hard to transition between each other, so we should totally just pick one and go with it and reiterate later)

r? @scottmcm and @joshtriplett

project goal issue: https://github.com/rust-lang/rust-project-goals/issues/406
tracking issue: https://github.com/rust-lang/rust/issues/146922

The design currently implemented by this PR is

* `TypeId::info` (method, usually used as `id.info()` returns a `Type` struct
* the `Type` struct has fields that contain information about the type
* the most notable field is `kind`, which is a non-exhaustive enum over all possible type kinds and their specific information. So it has a `Tuple(Tuple)` variant, where the only field is a `Tuple` struct type that contains more information (The list of type ids that make up the tuple).
* To get nested type information (like the type of fields) you need to call `TypeId::info` again.
* There is only one language intrinsic to go from `TypeId` to `Type`, and it does all the work

An alternative design could be

* Lots of small methods (each backed by an intrinsic) on `TypeId` that return all the individual information pieces (size, align, number of fields, number of variants, ...)
* This is how C++ does it (see https://lemire.me/blog/2025/06/22/c26-will-include-compile-time-reflection-why-should-you-care/ and https://isocpp.org/files/papers/P2996R13.html#member-queries)
* Advantage: you only get the information you ask for, so it's probably cheaper if you get just one piece of information for lots of types (e.g. reimplementing size_of in terms of `TypeId::info` is likely expensive and wasteful)
* Disadvantage: lots of method calling (and `Option` return types, or "general" methods like `num_fields` returning 0 for primitives) instead of matching and field accesses
* a crates.io crate could implement `TypeId::info` in terms of this design

The backing implementation is modular enough that switching from one to the other is probably not an issue, and the alternative design could be easier for the CTFE engine's implementation, just not as nice to use for end users (without crates wrapping the logic)

One wart of this design that I'm fixing in separate branches is that `TypeId::info` will panic if used at runtime, while it should be uncallable
2026-01-10 15:00:14 +00:00
Fabio Almeida
2b597f599e
feat: invisible character help string 2026-01-10 14:31:37 +00:00
Jonathan Brouwer
da0dda1503
Remove special case for AllowedTargets::CrateLevel 2026-01-10 14:27:44 +01:00
Jonathan Brouwer
00ad671406
Subscribe myself to attr parsing 2026-01-10 13:00:07 +01:00
Zalathar
539e855008 Use a hook to decouple rustc_mir_transform from rustc_mir_build 2026-01-10 22:14:35 +11:00
Jana Dönszelmann
9b811544f2
once again reorganize the EII tests a bit 2026-01-10 11:10:44 +01:00
Martin Nordholts
a0df7b2ad5 compiler: Forward attributes to eii-expanded macros
Otherwise you get errors like these if you have an Externally
Implementable Item defined in std:

    error: attribute macro has missing stability attribute
        --> library/std/src/io/mod.rs:2269:1
         |
    2269 | #[eii(on_broken_pipe)]
         | ^^^^^^^^^^^^^^^^^^^^--
         | |
         | in this attribute macro expansion
         |
        ::: library/core/src/macros/mod.rs:1899:5
         |
    1899 |     pub macro eii($item:item) {
         |     ------------- in this expansion of `#[eii]`

Or (fatal) warnings like these:

    warning: missing documentation for an attribute macro
        --> library/std/src/io/mod.rs:2269:1
2026-01-10 10:04:40 +01:00
Matthias Krüger
93993090c8
Rollup merge of #150884 - bors-email-ci, r=jieyouxu
Update bors email in CI postprocessing step

This was breaking CI job summaries. I don't think we have to backport it, should be mostly harmless.
2026-01-10 08:34:08 +01:00
Matthias Krüger
e7b08033a2
Rollup merge of #150882 - issue-149594, r=JonathanBrouwer
Supress unused_parens lint for guard patterns

Fixes rust-lang/rust#149594
2026-01-10 08:34:08 +01:00
Matthias Krüger
0161646212
Rollup merge of #150876 - gcc-dev-guide, r=Kobzol
Mention that `rustc_codegen_gcc` is a subtree in `rustc-dev-guide`

Was asked on [zulip](https://rust-lang.zulipchat.com/#narrow/channel/386786-rustc-codegen-gcc/topic/Subtree.20handling/with/564354089).

r? @RalfJung
2026-01-10 08:34:07 +01:00
Matthias Krüger
980e6ad91d
Rollup merge of #150875 - bootstrap-refactor-build-outputs, r=bjorn3
Refactor artifact keep mode in bootstrap

This makes it easier to understand which artifacts will be stored in the build stamp. Should help with https://github.com/rust-lang/rust/pull/145343.

Before, there were two booleans (keep .rmeta files and a special mode for rustc). I created an explicit enum for it instead. The mapping is:
- `(false, false)` => `ArtifactKeepMode::OnlyRlib`
- `(true, false)` => `ArtifactKeepMode::OnlyRmeta` (used for check/clippy builds)
- `(false, true)` => special rustc mode

r? @bjorn3
2026-01-10 08:34:00 +01:00
Matthias Krüger
da772d5195
Rollup merge of #150874 - fast-try-build-src-gpl, r=jieyouxu
Ignore `rustc-src-gpl` in fast try builds

I noticed that fast try builds now build this new component (unnecessarily).
2026-01-10 08:33:59 +01:00
Matthias Krüger
86806ab019
Rollup merge of #150872 - issue-150850, r=dianne
Fix some loop block coercion diagnostics

Fixes rust-lang/rust#150850
2026-01-10 08:33:58 +01:00
Matthias Krüger
68bd262521
Rollup merge of #150867 - chore-librustdoc-json-mem-take, r=GuillaumeGomez
rustdoc_json: Remove one call to `std::mem::take` in `after_krate`

This patch removes one call to `std::mem::take` to save two `memcpy`s: `JsonRenderer::index` can be quite large as noted https://github.com/rust-lang/rust/pull/142335. `self.index` can be passed directly to `types::Crate`. This removal makes `self` immutable.

The private `serialize_and_write` method is moved as a function: the `self` argument is replaced by `sess: &Session`. This `&Session` was fetched earlier in `after_krate` in all cases. This change allows to call `serialize_and_write` after `output_crate` is created, without having a conflict around the move of `self`: the borrow checker is now happy.

I wasn't able to measure the performance impact though because I don't know how to modify `rustc-perf` as [@nnethercote  did](https://github.com/rust-lang/rust/pull/142335#issuecomment-2961252113) (sorry).

---

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

r? @nnethercote
2026-01-10 08:33:58 +01:00
Matthias Krüger
6ab61b336d
Rollup merge of #150847 - siphash-doc-link, r=joboet
Fix broken documentation links to SipHash

The documentation of `SipHasher` previously linked to a page about SipHash on https://131002.net, a domain registered to Jean-Philippe Aumasson, one of the co-authors of the original SipHash paper (alongside Daniel J Bernstein).

That domain now redirects to another of Mr Aumasson's domains, https://www.aumasson.jp, but which does not host a similar page dedicated to SipHash.  Instead, his site links to a GitHub repository containing a C implementation together with links to the original research paper.  Mr Bernstein's own site, https://cr.yp.to, only hosts a copy of the research paper.

Therefore the GitHub repository appears to be the most official and complete reference to which we can link.

Fixes rust-lang/rust#150806
r? reddevilmidzy
2026-01-10 08:33:57 +01:00
Matthias Krüger
a8d66d4670
Rollup merge of #150765 - ua/missing-colon, r=estebank
rustc_parse_format: improve error for missing `:` before `?` in format args

Detect the `{ident?}` pattern where `?` is immediately followed by `}` and emit a clearer diagnostic explaining that `:` is required for Debug formatting. This avoids falling back to a generic “invalid format string” error and adds a targeted UI test for the case.
2026-01-10 08:33:57 +01:00
Matthias Krüger
727688a8e4
Rollup merge of #150713 - mgca-typeck-struct-fields, r=BoxyUwU
mgca: Type-check fields of struct expr const args

Fixes rust-lang/rust#150623.
Fixes rust-lang/rust#150712. Fixes rust-lang/rust#150714. Fixes rust-lang/rust#150734.

r? @BoxyUwU
2026-01-10 08:33:56 +01:00
Matthias Krüger
1df4902575
Rollup merge of #150269 - update-nvptx-maintainers, r=jieyouxu
Remove inactive nvptx maintainer

Since I just saw the discussion in [#t-compiler > Starting to enforce Tier 2-to-3 downgrade](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Starting.20to.20enforce.20Tier.202-to-3.20downgrade/with/564788312), and I saw him pinged on PRs or issues. His last active open-source contributions were in early 2022: https://github.com/RDambrosio016 and IIRC he also mentioned that he had moved on.

ping @RDambrosio016 so you can confirm or correct me, if you want to chime in. I also pinged him on Zulip.

cc @kjetilkjeka who is the other maintainer and active on related issues/prs for his target.

I'd leave it open for a while, but
r? @jieyouxu
2026-01-10 08:33:56 +01:00
oncecelll
14c6e602f4 Add missing documentation for globs feature
Signed-off-by: oncecelll <oncecell@outlook.com>
2026-01-10 13:25:31 +08:00
rust-bors[bot]
1b9ae9eddc
Auto merge of #150502 - petrochenkov:overglob, r=yaahc
resolve: Factor out and document the glob binding overwriting logic

Also, avoid creating fresh name declarations and overwriting declarations in modules to update some fields in `DeclData`, when possible.
Instead, change the fields directly in `DeclData` using cells.

Unblocks https://github.com/rust-lang/rust/pull/149195.
2026-01-10 05:03:09 +00:00
Alan Egerton
5674be29fa
Don't suggest breaking with value from for or while loops 2026-01-10 03:55:15 +00:00
Alan Egerton
7c7cf45dcf
Don't special-case while block type mismatch
67ea84d erroneously added this special-case when introducing `DesugaringKind::WhileLoop`.
It had the unintended effect of emitting erroneous diagnostics in certain `while` blocks.
2026-01-10 03:55:15 +00:00
Ayush Singh
ccc86f2228
std: sys: fs: uefi: Implement File::write
Tested using OVMF on QEMU.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2026-01-10 09:24:59 +05:30
reddevilmidzy
f2f45ffddd Add mGCA array expression tests 2026-01-10 12:45:26 +09:00
reddevilmidzy
522be7f1c0 Fix clippy 2026-01-10 12:45:17 +09:00
reddevilmidzy
618b0b5464 Lower hir::ConstArgKind::Array to a ValTree 2026-01-10 12:41:50 +09:00
reddevilmidzy
fc06a57a78 Introduce hir::ConstArgKind::Array 2026-01-10 12:41:50 +09:00
Trevor Gross
07fa70e104 llvm: Update reliable_f16 configuration for LLVM22
Since yesterday, the LLVM `main` branch should have working `f16` on all
platforms that Rust supports; this will be LLVM version 22, so update
how `cfg(target_has_reliable_f16)` is set to reflect this.

Within the rust-lang organization, this currently has no effect. The
goal is to start catching problems as early as possible in external CI
that runs top-of-tree rust against top-of-tree LLVM, and once testing
for the rust-lang bump to LLVM 22 starts. Hopefully this will mean that
we can fix any problems that show up before the bump actually happens,
meaning `f16` will be about ready for stabilization at that point (with
some considerations for the GCC patch at [1] propagating).

References:

* 919021b0df
* 054ee2f870
* db26ce5c55
* 549d7c4f35
* 4903c6260c

[1]: 8b6a18ecaf
2026-01-09 19:44:24 -06:00
rust-bors[bot]
2b82e05da4
Auto merge of #150900 - Urgau:rollup-og7uEW9, r=Urgau
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#149318 (Implement partial_sort_unstable for slice)
 - rust-lang/rust#150805 (Fix ICE in inline always warning emission.)
 - rust-lang/rust#150822 (Fix for ICE: eii: fn / macro rules None in find_attr())
 - rust-lang/rust#150853 (std: sys: fs: uefi: Implement File::read)
 - rust-lang/rust#150855 (std: sys: fs: uefi: Implement File::tell)
 - rust-lang/rust#150881 (Fix std::fs::copy on WASI by setting proper OpenOptions flags)
 - rust-lang/rust#150891 (Fix a trivial typo in def_id.rs)
 - rust-lang/rust#150892 (Don't check `[mentions]` paths in submodules from tidy)
 - rust-lang/rust#150894 (cg_llvm: add a pause to make comment less confusing)

r? @ghost
2026-01-10 01:19:39 +00:00
Guilherme Luiz
9156b540aa
Update to_uppercase docs to avoid ß->SS example 2026-01-09 19:50:06 -03:00
Keith-Cancel
f982bc6a2d Fix ICE: can't type-check body of DefId, since type_consts don't have a body.
Handling for inherent associated consts is missing elsewhere, remove so it can be handled later in that handling.

Diagnostic not always be emitted on associated constant

Add a test case and Fix for a different ICE I encountered.

I noticed when trying various permuations of the test case code to see if I could find anymore ICEs. I did, but not one that I expected. So in the instances of the a named const not having any args, insantiate it directly. Since it is likely an inherent assocaiated const.

Added tests.

Centralize the is_type_const() logic.

I also noticed basically the exact same check in other part the code.

Const blocks can't be a type_const, therefore this check is uneeded.

Fix comment spelling error.

get_all_attrs is not valid to call for all DefIds it seems.

Make sure that if the type is omitted for a type_const that we don't ICE.

Co-Authored-By: Boxy <rust@boxyuwu.dev>
2026-01-09 14:45:33 -08:00
Urgau
2b8d078abf
Rollup merge of #150894 - patch-1, r=mati865
cg_llvm: add a pause to make comment less confusing
2026-01-09 23:28:26 +01:00
Urgau
90de6e523a
Rollup merge of #150892 - tidy-triagebot-mentions-submodules, r=tgross35
Don't check `[mentions]` paths in submodules from tidy

As we were reminded in [#triagebot > Mentions glob matching](https://rust-lang.zulipchat.com/#narrow/channel/224082-triagebot/topic/Mentions.20glob.20matching/with/567093226), triagebot cannot see changes in submodules.

So let's reflect that in the `tidy` check to avoid accidentally adding paths inside submodules.

I tested it with these entries:

```toml
[mentions."src/tools/cargo"]
cc = ["@ehuss"]
[mentions."src/tools/cargo/"]
cc = ["@ehuss"]
[mentions."src/tools/cargo/*"]
cc = ["@ehuss"]
[mentions."src/tools/cargo/README.md"]
cc = ["@ehuss"]
```

and got (as expected):

```
tidy [triagebot]: triagebot.toml [mentions.*] 'src/tools/cargo/README.md' cannot match inside a submodule
tidy [triagebot]: triagebot.toml [mentions.*] contains 'src/tools/cargo/*' which doesn't match any file or directory in the repository
```
2026-01-09 23:28:26 +01:00
Urgau
f44b51688a
Rollup merge of #150891 - def-id-typo, r=Kivooeo
Fix a trivial typo in def_id.rs

s/then/than/
2026-01-09 23:28:25 +01:00
Urgau
c2f0209c3c
Rollup merge of #150881 - fix-wasi-fs-copy, r=alexcrichton
Fix std::fs::copy on WASI by setting proper OpenOptions flags

When PR rust-lang/rust#147572 switched WASI to use Unix-style filesystem APIs, the open_to_and_set_permissions function for WASI was implemented to call OpenOptions::new().open() without setting any access mode flags.

This causes std::fs::copy to fail with the error:
"must specify at least one of read, write, or append access"

The fix is to explicitly set .write(true), .create(true), and .truncate(true) on the OpenOptions, matching the behavior of the non-WASI Unix implementation but without the permission handling that WASI doesn't support.

Minimal reproduction:
```rs
    fn main() {
        std::fs::write("/src.txt", b"test").unwrap();
        match std::fs::copy("/src.txt", "/dst.txt") {
            Ok(_) => println!("PASS: fs::copy works!"),
            Err(e) => println!("FAIL: {}", e),
        }
    }
```
    # Compile and run:
    rustc +nightly --target wasm32-wasip2 test.rs -o test.wasm
    wasmtime -S cli --dir . test.wasm

    # Before fix: FAIL: must specify at least one of read, write, or append access
    # After fix:  PASS: fs::copy works!

Note: The existing test library/std/src/fs/tests.rs::copy_file_ok would have caught this regression if the std test suite ran on WASI targets. Currently std tests don't compile for wasm32-wasip2 due to Unix-specific test code in library/std/src/sys/fd/unix/tests.rs.

Fixes the regression introduced in nightly-2025-12-10.

r? @alexcrichton
2026-01-09 23:28:25 +01:00
Urgau
92b9e84172
Rollup merge of #150855 - uefi-fs-tell, r=joboet
std: sys: fs: uefi: Implement File::tell

- Just a call to get_position
- Tested with OVMF on QEMU

@rustbot label +O-UEFI
2026-01-09 23:28:24 +01:00
Urgau
93f6171e11
Rollup merge of #150853 - uefi-fs-read, r=joboet
std: sys: fs: uefi: Implement File::read

Tested using OVMF on QEMU.

@rustbot label +O-UEFI
2026-01-09 23:28:17 +01:00
Urgau
a8028abedb
Rollup merge of #150822 - fix-149981, r=@Kivooeo
Fix for ICE: eii: fn / macro rules None in find_attr()

Closes rust-lang/rust#149981

This used to ICE:
```rust
macro_rules! foo_impl {}
#[eii]
fn foo_impl() {}
```

`#[eii]` generates a macro (called `foo_impl`) and a default impl. So the partial expansion used to roughly look like the following:

```rust
macro_rules! foo_impl {} // actually resolves here

extern "Rust" {
    fn foo_impl();
}

#[eii_extern_target(foo_impl)]
macro foo_impl {
    () => {};
}

const _: () = {
    #[implements_eii(foo_impl)] // assumed to name resolve to the macro v2 above
    fn foo_impl() {}
};
```

Now, shadowing rules for macrov2 and macrov1 are super weird! Take a look at this: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=23f21421921360478b0ec0276711ad36

So instead of resolving to the macrov2, we resolve the macrov1 named the same thing.

A regression test was added to this, and some span_delayed_bugs were added to make sure we catch this in the right places. But that didn't fix the root cause.

To make sure this simply cannot happen again, I made it so that we don't even need to do a name resolution for the default. In other words, the new partial expansion looks more like:

```rust
macro_rules! foo_impl {}

extern "Rust" {
    fn foo_impl(); // resolves to here now!!!
}

#[eii_extern_target(foo_impl)]
macro foo_impl {
    () => {};
}

const _: () = {
    #[implements_eii(known_extern_target=foo_impl)] // still name resolved, but directly to the foreign function.
    fn foo_impl() {}
};
```

The reason this helps is that name resolution for non-macros is much more predictable. It's not possible to have two functions like that with the same name in scope.

We used to key externally implementable items off of the defid of the macro, but now the unique identifier is the foreign function's defid which seems much more sane.

Finally, I lied a tiny bit because the above partial expansion doesn't actually work.
```rust
extern "Rust" {
    fn foo_impl(); // not to here
}

const _: () = {
    #[implements_eii(known_extern_target=foo_impl)] // actually resolves to this function itself
    fn foo_impl() {} // <--- so to here
};
```

So the last few commits change the expansion to actually be this:

```rust
macro_rules! foo_impl {}

extern "Rust" {
    fn foo_impl(); // resolves to here now!!!
}

#[eii_extern_target(foo_impl)]
macro foo_impl {
    () => {};
}

const _: () = {
    mod dflt { // necessary, otherwise `super` doesn't work
        use super::*;
        #[implements_eii(known_extern_target=super::foo_impl)] // now resolves to outside the `dflt` module, so the foreign item.
        fn foo_impl() {}
    }
};
```

I apologize to whoever needs to review this, this is very subtle and I hope this makes it clear enough 😭.
2026-01-09 23:28:16 +01:00
Urgau
3bb7de6408
Rollup merge of #150805 - fix-def-path-ice, r=davidtwco
Fix ICE in inline always warning emission.

The calls to `def_path_str` were outside the decorate callback in `node_span_lint` which caused an ICE when the warning was an allowed warning due to the call to `def_path_str` being executed but the warning not actually being emitted.

r? @davidtwco
2026-01-09 23:28:16 +01:00
Urgau
65c0847f2d
Rollup merge of #149318 - slice_partial_sort_unstable, r=tgross35
Implement partial_sort_unstable for slice

This refers to https://github.com/rust-lang/rust/issues/149046.
2026-01-09 23:28:15 +01:00
rust-bors[bot]
1191620b8c
Auto merge of #150818 - flip1995:clippy-subtree-update, r=Manishearth,samueltardieu
Clippy subtree update

r? Manishearth

Cargo.lock update due to askama bump to be in line with the Rust repo.
2026-01-09 22:04:59 +00:00
Tshepang Mbambo
229673ac85
make sentence more simple 2026-01-09 22:49:32 +02:00
Tshepang Mbambo
8e61f0de27
cg_llvm: add a pause to make comment less confusing 2026-01-09 22:47:59 +02:00
Urgau
9d2ce87810 Don't check [mentions] paths in submodules from tidy 2026-01-09 21:02:08 +01:00
Guillaume Gomez
f9c71df88a Improve span for "unresolved intra doc link" on deprecated attribute 2026-01-09 20:36:52 +01:00
Daniel Smith
0401e792f4 Fix a trivial typo 2026-01-09 13:49:17 -05:00
Folkert de Vries
6f12b86e9c
s390x: support f16 and f16x8 in inline assembly 2026-01-09 18:42:46 +01:00
Ayush Singh
f6f901fa6d
std: sys: fs: uefi: Implement File::{flush, *sync}
- Make flush a noop since it is only for buffered writers.
- Also forward fsync to datasync. UEFI does not have anything
  separate for metadata sync.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2026-01-09 22:36:44 +05:30
Ayush Singh
fd59b32f8b
std: sys: fs: uefi: Implement File::read
Tested using OVMF on QEMU.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2026-01-09 22:32:40 +05:30
Colin Murphy
43c1db7d56 Run clippy 2026-01-09 11:51:59 -05:00