about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2024-12-02Rollup merge of #133715 - aDotInTheVoid:rdj-static, r=GuillaumeGomezGuillaume Gomez-14/+84
rustdoc-json: Include safety of `static`s `static`s in an `extern` block can have an associated safety annotation ["because there is nothing guaranteeing that the bit pattern at the static’s memory is valid for the type it is declared with"](https://doc.rust-lang.org/reference/items/external-blocks.html#statics). Rustdoc already knows this and displays in for HTML. This PR also includes it in JSON. Inspired by https://github.com/obi1kenobi/cargo-semver-checks/issues/975 which needs this, but it's probably useful in other places. r? `@GuillaumeGomez.` Possibly easier to review commit-by-commit.
2024-12-02Rollup merge of #133603 - dtolnay:precedence, r=lcnrGuillaume Gomez-198/+222
Eliminate magic numbers from expression precedence Context: see https://github.com/rust-lang/rust/pull/133140. This PR continues on backporting Syn's expression precedence design into rustc. Rustc's design used mysterious integer quantities represented variously as `i8` or `usize` (e.g. `PREC_CLOSURE = -40i8`), a special significance around `0` that is never named, and an extra `PREC_FORCE_PAREN` precedence level that does not correspond to any expression. Syn's design uses a C-like enum with variants that clearly correspond to specific sets of expression kinds. This PR is a refactoring that has no intended behavior change on its own, but it unblocks other precedence work that rustc's precedence design was poorly suited to accommodate. - Asymmetrical precedence, so that a pretty-printer can tell `(return 1) + 1` needs parens but `1 + return 1` does not. - Squashing the `Closure` and `Jump` cases into a single precedence level. - Numerous remaining false positives and false negatives in rustc pretty-printer's parenthesization of macro metavariables, for example in `$e < rhs` where $e is `lhs as Thing<T>`. FYI `@fmease` &mdash; you don't need to review if rustbot picks someone else, but you mentioned being interested in the followup PRs.
2024-12-02Auto merge of #133728 - jhpratt:rollup-k1i60pg, r=jhprattbors-232/+108
Rollup of 4 pull requests Successful merges: - #133589 (Remove `hir::ArrayLen`) - #133672 (Remove a bunch of unnecessary const stability noise) - #133678 (Stabilize `ptr::fn_addr_eq`) - #133727 (Update mailmap) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-02Auto merge of #133566 - lcnr:fast-reject-perf, r=compiler-errorsbors-17/+53
fast-reject: add cache slightly modified version of #133524 I tried a few alternatives: - simply bail after recursion for a certain amount of times, however, looking at the number of steps taken while compiling different crates we get the following results[^1]: - add a cache: results in a bigger performance impact typenum ```rust 1098842 counts ( 1) 670511 (61.0%, 61.0%): dropping after 1 ( 2) 358785 (32.7%, 93.7%): dropping after 0 ( 3) 25191 ( 2.3%, 96.0%): dropping after 2 ( 4) 10912 ( 1.0%, 97.0%): dropping after 4 ( 5) 6461 ( 0.6%, 97.5%): dropping after 3 ( 6) 5239 ( 0.5%, 98.0%): dropping after 5 ( 7) 2528 ( 0.2%, 98.3%): dropping after 8 ( 8) 2188 ( 0.2%, 98.5%): dropping after 1094 ( 9) 2097 ( 0.2%, 98.6%): dropping after 6 ( 10) 1179 ( 0.1%, 98.7%): dropping after 34 ( 11) 1148 ( 0.1%, 98.9%): dropping after 7 ( 12) 822 ( 0.1%, 98.9%): dropping after 10 ``` bitmaps ```rust 533346 counts ( 1) 526166 (98.7%, 98.7%): dropping after 1 ( 2) 4562 ( 0.9%, 99.5%): dropping after 0 ( 3) 2072 ( 0.4%, 99.9%): dropping after 1024 ( 4) 305 ( 0.1%,100.0%): dropping after 2 ( 5) 106 ( 0.0%,100.0%): dropping after 4 ( 6) 30 ( 0.0%,100.0%): dropping after 8 ( 7) 18 ( 0.0%,100.0%): dropping after 3 ( 8) 17 ( 0.0%,100.0%): dropping after 44 ( 9) 15 ( 0.0%,100.0%): dropping after 168 ( 10) 8 ( 0.0%,100.0%): dropping after 14 ( 11) 7 ( 0.0%,100.0%): dropping after 13 ( 12) 7 ( 0.0%,100.0%): dropping after 24 ``` stage 2 compiler is mostly trivial, but has a few cases where we get >5000 ```rust 12987156 counts ( 1) 9280476 (71.5%, 71.5%): dropping after 0 ( 2) 2277841 (17.5%, 89.0%): dropping after 1 ( 3) 724888 ( 5.6%, 94.6%): dropping after 2 ( 4) 204005 ( 1.6%, 96.2%): dropping after 4 ( 5) 146537 ( 1.1%, 97.3%): dropping after 3 ( 6) 64287 ( 0.5%, 97.8%): dropping after 5 ( 7) 43938 ( 0.3%, 98.1%): dropping after 6 ( 8) 43758 ( 0.3%, 98.4%): dropping after 8 ( 9) 27220 ( 0.2%, 98.7%): dropping after 7 ( 10) 17374 ( 0.1%, 98.8%): dropping after 9 ( 11) 16015 ( 0.1%, 98.9%): dropping after 10 ( 12) 12855 ( 0.1%, 99.0%): dropping after 12 ( 13) 10494 ( 0.1%, 99.1%): dropping after 11 ( 14) 7553 ( 0.1%, 99.2%): dropping after 14 ``` [^1]: i've incremented a counter in the place I now decrement the depth at and then printed it on drop r? `@compiler-errors`
2024-12-02Auto merge of #133723 - jhpratt:rollup-pyfespf, r=jhprattbors-156/+163
Rollup of 5 pull requests Successful merges: - #131416 (Mark `slice::copy_from_slice` unstably const) - #131784 (Stabilize unsigned and float variants of `num_midpoint` feature) - #133446 (coverage: Use a query to identify which counter/expression IDs are used) - #133711 (add isatty doc alias for `is_terminal`) - #133712 (rust_analyzer_settings: force use of 'nightly' toolchain) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-01Rollup merge of #133727 - jhpratt:mailmap, r=jhprattJacob Pratt-0/+1
Update mailmap
2024-12-01Rollup merge of #133678 - Urgau:stabilize-ptr_fn_addr_eq, r=jhprattJacob Pratt-3/+1
Stabilize `ptr::fn_addr_eq` This PR stabilize the `ptr::fn_addr_eq` function. FCP completed in https://github.com/rust-lang/rust/issues/129322#issuecomment-2508304516 Closes https://github.com/rust-lang/rust/issues/129322
2024-12-01Rollup merge of #133672 - RalfJung:const-stability-cleanup, r=jhprattJacob Pratt-47/+1
Remove a bunch of unnecessary const stability noise
2024-12-01Rollup merge of #133589 - voidc:remove-array-len, r=boxyuwuJacob Pratt-182/+105
Remove `hir::ArrayLen` This refactoring removes `hir::ArrayLen`, replacing it with `hir::ConstArg`. To represent inferred array lengths (previously `hir::ArrayLen::Infer`), a new variant `ConstArgKind::Infer` is added. r? `@BoxyUwU`
2024-12-01Update mailmapJacob Pratt-0/+1
2024-12-01Rollup merge of #133712 - RalfJung:rust_analyzer_settings, r=jieyouxuJacob Pratt-0/+4
rust_analyzer_settings: force use of 'nightly' toolchain The cranelift folder contains a rust-toolchain file. That means when RA opens `compiler/rustc_codegen_cranelift/Cargo.toml`, it will try to use that toolchain or fail. (Maybe that toolchain gets auto-installed for others? On my system, it just fails, but I also run vscodium in a sandbox.) However, it shouldn't be necessary to use more than one toolchain for the rustc workspace. So we can set the `RUSTUP_TOOLCHAIN` variable on the server side to force the same toolchain to be used everywhere. Suggested by `@ChayimFriedman2` in https://github.com/rust-lang/rust-analyzer/issues/18585.
2024-12-01Rollup merge of #133711 - cod10129:master, r=NoratriebJacob Pratt-0/+1
add isatty doc alias for `is_terminal` (first Rust contribution!) This adds `isatty` as a doc alias for [`std::io::IsTerminal::is_terminal`](https://doc.rust-lang.org/stable/std/io/trait.IsTerminal.html#tymethod.is_terminal). I think this change does meet the [doc alias policy](https://std-dev-guide.rust-lang.org/policy/doc-alias.html). This would be especially useful because searching "rust isatty" gets you the `isatty` crate which is deprecated in favor of `atty`. `atty` is unmaintained and you might get to `is-terminal`, which will finally tell you that the function you're looking for has been in `std` all along. The Windows implementation of `is_terminal()` doesn't use `isatty`, but that hasn't been a problem for the analogous cases of `create_dir()`'s alias `mkdir` or `remove_dir()`/`rmdir`.
2024-12-01Rollup merge of #133446 - Zalathar:querify, r=cjgillotJacob Pratt-113/+114
coverage: Use a query to identify which counter/expression IDs are used Given that we already have a query to identify the highest-numbered counter ID in a MIR body, we can extend that query to also build bitsets of used counter/expression IDs. That lets us avoid some messy coverage bookkeeping during the main MIR traversal for codegen. This does mean that we fail to treat some IDs as used in certain MIR-inlining scenarios, but I think that's fine, because it means that the results will be consistent across all instantiations of a function. --- There's some more cleanup I want to do in the function coverage collector, since it isn't really collecting anything any more, but I'll leave that for future work.
2024-12-01Rollup merge of #131784 - Urgau:stabilize-midpoint, r=dtolnayJacob Pratt-37/+34
Stabilize unsigned and float variants of `num_midpoint` feature This PR proposes that we stabilize the unsigned variants of the [`num_midpoint`](https://github.com/rust-lang/rust/issues/110840#issue-1684506201) feature as well as the floats variants, since they are not subject to any unresolved questions, which is equivalent to doing `(a + b) / 2` (and `(a + b) >> 1`) in a sufficiently large number. The stabilized API surface would be: ```rust /// Calculates the middle point of `self` and `rhs`. /// /// `midpoint(a, b)` is `(a + b) / 2` as if it were performed in a sufficiently-large unsigned integral type. /// This implies that the result is always rounded towards negative infinity and that no overflow will ever occur. impl u{8,16,32,64,128,size} { pub const fn midpoint(self, rhs: Self) -> Self; } impl NonZeroU{8,16,32,64,size} { pub const fn midpoint(self, rhs: Self) -> Self; } impl f{32,64} { pub const fn midpoint(self, rhs: Self) -> Self; } ``` The signed variants `u{8,16,32,64,128,size}` would remain gated, until a decision is made about the rounding mode, in other words that the [unresolved questions](https://github.com/rust-lang/rust/issues/110840#issue-1684506201) are resolved. cc `@rust-lang/libs-api` cc `@scottmcm` r? libs-api
2024-12-01Rollup merge of #131416 - okaneco:const_copy, r=RalfJungJacob Pratt-6/+10
Mark `slice::copy_from_slice` unstably const Tracking issue #131415 I used `const_eval_select` for runtime and const panic functions because const formatting isn't available yet.
2024-12-01Auto merge of #133345 - GuillaumeGomez:stop-cloning-context, ↵bors-285/+355
r=notriddle,aDotInTheVoid Stop cloning `Context` so much This is a first step for https://github.com/rust-lang/rust/issues/82381. It's already big enough so I'll continue in a follow-up once this PR is merged. Next step will be to get rid of `SharedContext` by inlining it directly into `Context`. cc `@camelid` r? `@notriddle`
2024-12-01rust_analyzer_settings: force use of 'nightly' toolchainRalf Jung-0/+4
2024-12-01rustdoc-json: Include safety of `static`sAlona Enraght-Moony-14/+74
2024-12-01Mark `slice::copy_from_slice` unstably constokaneco-6/+10
2024-12-01rustdoc-json: Add tests for `static`sAlona Enraght-Moony-0/+10
2024-12-01Fix link to `FormatRenderer` methodGuillaume Gomez-1/+1
2024-12-01Rename `FormatRenderer::InfoType` into `ModuleData` and rename ↵Guillaume Gomez-13/+13
`FormatRenderer::make_child_renderer` into `save_module_data`
2024-12-01Add `unreachable!` in new `FormatRenderer` methods for `JsonRenderer` ↵Guillaume Gomez-2/+7
implementation
2024-12-01Add documentation for new `FormatRenderer` trait itemsGuillaume Gomez-2/+30
2024-12-01Move `SharedContext` out of `Rc`Guillaume Gomez-162/+171
2024-12-01Store default ID map in a staticGuillaume Gomez-3/+7
2024-12-01Split ID maps in two parts: the constant one and the updated oneGuillaume Gomez-67/+57
2024-12-01Stop cloning `Context` so muchGuillaume Gomez-120/+154
2024-12-01add isatty alias for is_terminalcod10129-0/+1
2024-12-01Auto merge of #133703 - matthiaskrgr:rollup-fwlw0mc, r=matthiaskrgrbors-333/+704
Rollup of 7 pull requests Successful merges: - #132974 (Properly pass linker arguments that contain commas) - #133403 (Make `adjust_fulfillment_errors` work with `HostEffectPredicate` and `const_conditions`) - #133482 (Only error raw lifetime followed by `\'` in edition 2021+) - #133595 (Do not emit `missing_doc_code_examples` rustdoc lint on module and a few other items) - #133669 (Move some functions out of const_swap feature gate) - #133674 (Fix chaining `carrying_add`s) - #133691 (Check let source before suggesting annotation) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-01Auto merge of #133532 - rami3l:ci/bump-ubuntu, r=Kobzolbors-5/+6
Bump unsupported `ubuntu` CI images to 24.04 LTS Closes #133531. try-job: arm-android try-job: dist-android try-job: dist-ohos
2024-12-01Rollup merge of #133691 - compiler-errors:let-source, r=lqdMatthias Krüger-1/+62
Check let source before suggesting annotation Make sure we don't annotate nonsense type annotations on locals that come from desugarings. fixes #133688
2024-12-01Rollup merge of #133674 - scottmcm:chain-carrying-add, r=AmanieuMatthias Krüger-1/+34
Fix chaining `carrying_add`s Something about the MIR lowering for `||` ended up breaking this, but it's fixed by changing the code to use `|` instead. I also added an assembly test to ensure it *keeps* being [`adc`](https://www.felixcloutier.com/x86/adc). cc https://github.com/rust-lang/rust/issues/85532#issuecomment-2495119815, which noticed this.
2024-12-01Rollup merge of #133669 - RalfJung:const_swap_splitup, r=dtolnayMatthias Krüger-4/+24
Move some functions out of const_swap feature gate - `swap_unchecked` is still unstable as a regular fn, so that feature gate can also cover its constness. - `swap_nonoverlapping` isn't ready to be stabilized yet, so make it a different feature gate. Part of https://github.com/rust-lang/rust/issues/83163, https://github.com/rust-lang/rust/issues/88539, https://github.com/rust-lang/rust/issues/133668
2024-12-01Rollup merge of #133595 - GuillaumeGomez:missing_doc_code_examples, r=notriddleMatthias Krüger-64/+39
Do not emit `missing_doc_code_examples` rustdoc lint on module and a few other items It doesn't make sense to expect modules to have code examples. Same goes for: * Trait aliases * Foreign items * Associated types and constants Should make the use of this lint a bit nicer. r? ``@notriddle``
2024-12-01Rollup merge of #133482 - compiler-errors:raw-lt-tick, r=estebankMatthias Krüger-16/+29
Only error raw lifetime followed by `\'` in edition 2021+ Fixes #133479 cc #132341 I think this fixes a purely theoretical regression since it only affects edition 2015 (who is using that?) and only in the very rare case of a raw lifetime followed immediately by a lifetime like `'r#a'r`.
2024-12-01Rollup merge of #133403 - compiler-errors:adjust-host-effect-preds, ↵Matthias Krüger-186/+434
r=fee1-dead,lcnr Make `adjust_fulfillment_errors` work with `HostEffectPredicate` and `const_conditions` Greatly improves the spans for reporting unsatisfied `~const` bounds :) r? project-const-traits or maybe ``@lcnr`` (if you want to deal with a diagnostics PR lmao)
2024-12-01Rollup merge of #132974 - madsmtm:linker-arguments-with-commas, r=petrochenkovMatthias Krüger-61/+82
Properly pass linker arguments that contain commas When linking with the system C compiler, we sometimes want to forward certain arguments unchanged to the linker. This can be done with `-Wl,arg1,arg2` or `-Xlinker arg1 -Xlinker arg2`. `-Wl` is used when possible, since it is more compact, but it does not support commas in the argument itself - in those cases, we need to use `-Xlinker`, and that is what this PR implements. This also fixes using sanitizers on macOS with `-Clinker-flavor=ld`, as those were previously manually using `-Wl`/`-Xlinker` (probably since the support wasn't present in the `link_args` function). Note that there has been [a previous PR for this](https://github.com/rust-lang/rust/pull/38798), but it only implemented this in certain cases when passing `-rpath`. r? compiler
2024-12-01Auto merge of #132390 - RalfJung:diagnostics-root-dir, ↵bors-10/+15
r=albertlarsan68,weihanglo bootstrap: show diagnostics relative to rustc src dir Fixes https://github.com/rust-lang/rust/issues/128726 Depends on https://github.com/rust-lang/cargo/pull/14752 propagating to bootstrap cargo
2024-12-01Stabilize unsigned `num_midpoint` featureUrgau-37/+34
2024-12-01fix cargo path logicRalf Jung-3/+4
2024-12-01Auto merge of #133694 - matthiaskrgr:rollup-s6xj4rf, r=matthiaskrgrbors-699/+670
Rollup of 8 pull requests Successful merges: - #128184 (std: refactor `pthread`-based synchronization) - #132047 (Robustify and genericize return-type-notation resolution in `resolve_bound_vars`) - #133515 (fix: hurd build, stat64.st_fsid was renamed to st_dev) - #133602 (fix: fix codeblocks in `PathBuf` example) - #133622 (update link to "C++ Exceptions under the hood" blog) - #133660 (Do not create trait object type if missing associated types) - #133686 (Add diagnostic item for `std::ops::ControlFlow`) - #133689 (Fixed typos by changing `happend` to `happened`) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-01Rollup merge of #133689 - HomelikeBrick42:master, r=jieyouxuMatthias Krüger-15/+15
Fixed typos by changing `happend` to `happened` I just noticed this typo before and decided to fix it :3
2024-12-01Rollup merge of #133686 - samueltardieu:push-xkxwxzxqokuu, r=compiler-errorsMatthias Krüger-0/+2
Add diagnostic item for `std::ops::ControlFlow` This will be used in Clippy to detect useless conversions done through `ControlFlow::map_break()` and `ControlFlow::map_continue()`.
2024-12-01Rollup merge of #133660 - compiler-errors:trait-obj-missing-assoc, r=lcnrMatthias Krüger-205/+35
Do not create trait object type if missing associated types r? lcnr
2024-12-01Rollup merge of #133622 - mkroening:exception-blog, r=cuviperMatthias Krüger-2/+2
update link to "C++ Exceptions under the hood" blog The link was introduced in 0ec321f7b541fcbfbf20286beb497e6d9d3352b2. For the old link, see https://web.archive.org/web/20170409223244/https://monoinfinito.wordpress.com/series/exception-handling-in-c/. The blog has migrated from WordPress to Blogger in 2021 and to GitHub pages in 2024.
2024-12-01Rollup merge of #133602 - SanchithHegde:fix-pathbuf-example-codeblocks, ↵Matthias Krüger-0/+2
r=cuviper fix: fix codeblocks in `PathBuf` example This PR adds missing codeblocks around an example included in the `PathBuf` documentation.
2024-12-01Rollup merge of #133515 - SteveLauC:fix/hurd, r=ChrisDentonMatthias Krüger-4/+6
fix: hurd build, stat64.st_fsid was renamed to st_dev On hurd, `stat64.st_fsid` was renamed to `st_dev` in https://github.com/rust-lang/libc/pull/3785, so if you have a new libc with this patch included, and you build std from source, you get this error: ```sh error[E0609]: no field `st_fsid` on type `&stat64` --> /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/os/hurd/fs.rs:301:36 | 301 | self.as_inner().as_inner().st_fsid as u64 | ^^^^^^^ unknown field | help: a field with a similar name exists | 301 | self.as_inner().as_inner().st_uid as u64 | ~~~~~~ ``` Full CI log: https://github.com/nix-rust/nix/actions/runs/12033180710/job/33546728266?pr=2544
2024-12-01Rollup merge of #132047 - compiler-errors:rbv-rtn-cleanup, r=cjgillotMatthias Krüger-35/+143
Robustify and genericize return-type-notation resolution in `resolve_bound_vars` #129629 implemented return-type-notation (RTN) in its path form, like `where T::method(..): Bound`. As part of lowering, we must record the late-bound vars for the where clause introduced by the method (namely, its early- and late-bound lifetime arguments, since `where T::method(..)` turns into a higher-ranked where clause over all of the lifetimes according to [RFC 3654](https://rust-lang.github.io/rfcs/3654-return-type-notation.html#converting-to-higher-ranked-trait-bounds)). However, this logic was only looking at the where clauses of the parent item that the `T::method(..)` bound was written on, and not any parent items. This PR generalizes that logic to look at the parent item (i.e. the outer impl or trait) instead and fixes a (debug only) assertion as an effect. This logic is also more general and likely easier to adapt to more interesting (though likely very far off) cases like non-lifetime binder `for<T: Trait> T::method(..): Send` bounds. Tracking: - https://github.com/rust-lang/rust/issues/109417
2024-12-01Rollup merge of #128184 - joboet:refactor_pthread_sync, r=workingjubileeMatthias Krüger-438/+465
std: refactor `pthread`-based synchronization The non-trivial code for `pthread_condvar` is duplicated across the thread parking and the `Mutex`/`Condvar` implementations. This PR moves that code into `sys::pal`, which now exposes an `unsafe` wrapper type for `pthread_mutex_t` and `pthread_condvar_t`.