about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2025-04-29Wf is not coinductiveMichael Goulet-3/+19
2025-04-28Auto merge of #140388 - GuillaumeGomez:rollup-aj9o3ch, r=GuillaumeGomezbors-743/+874
Rollup of 7 pull requests Successful merges: - #140056 (Fix a wrong error message in 2024 edition) - #140220 (Fix detection of main function if there are expressions around it) - #140249 (Remove `weak` alias terminology) - #140316 (Introduce `BoxMarker` to improve pretty-printing correctness) - #140347 (ci: clean more disk space in codebuild) - #140349 (ci: use aws codebuild for the `dist-x86_64-linux` job) - #140379 (rustc-dev-guide subtree update) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-28Auto merge of #123948 - azhogin:azhogin/async-drop, r=oli-obkbors-1904/+4091
Async drop codegen Async drop implementation using templated coroutine for async drop glue generation. Scopes changes to generate `async_drop_in_place()` awaits, when async droppable objects are out-of-scope in async context. Implementation details: https://github.com/azhogin/posts/blob/main/async-drop-impl.md New fields in Drop terminator (drop & async_fut). Processing in codegen/miri must validate that those fields are empty (in full version async Drop terminator will be expanded at StateTransform pass or reverted to sync version). Changes in terminator visiting to consider possible new successor (drop field). ResumedAfterDrop messages for panic when coroutine is resumed after it is started to be async drop'ed. Lang item for generated coroutine for async function async_drop_in_place. `async fn async_drop_in_place<T>()::{{closure0}}`. Scopes processing for generate async drop preparations. Async drop is a hidden Yield, so potentially async drops require the same dropline preparation as for Yield terminators. Processing in StateTransform: async drops are expanded into yield-point. Generation of async drop of coroutine itself added. Shims for AsyncDropGlueCtorShim, AsyncDropGlue and FutureDropPoll. ```rust #[lang = "async_drop"] pub trait AsyncDrop { #[allow(async_fn_in_trait)] async fn drop(self: Pin<&mut Self>); } impl Drop for Foo { fn drop(&mut self) { println!("Foo::drop({})", self.my_resource_handle); } } impl AsyncDrop for Foo { async fn drop(self: Pin<&mut Self>) { println!("Foo::async drop({})", self.my_resource_handle); } } ``` First async drop glue implementation re-worked to use the same drop elaboration code as for sync drop. `async_drop_in_place` changed to be `async fn`. So both `async_drop_in_place` ctor and produced coroutine have their lang items (`AsyncDropInPlace`/`AsyncDropInPlacePoll`) and shim instances (`AsyncDropGlueCtorShim`/`AsyncDropGlue`). ``` pub async unsafe fn async_drop_in_place<T: ?Sized>(_to_drop: *mut T) { } ``` AsyncDropGlue shim generation uses `elaborate_drops::elaborate_drop` to produce drop ladder (in the similar way as for sync drop glue) and then `coroutine::StateTransform` to convert function into coroutine poll. AsyncDropGlue coroutine's layout can't be calculated for generic T, it requires known final dropee type to be generated (in StateTransform). So, `templated coroutine` was introduced here (`templated_coroutine_layout(...)` etc). Such approach overrides the first implementation using mixing language-level futures in https://github.com/rust-lang/rust/pull/121801.
2025-04-28Rollup merge of #140379 - tshepang:rdg-push, r=jieyouxuGuillaume Gomez-39/+49
rustc-dev-guide subtree update
2025-04-28Rollup merge of #140349 - marcoieni:codebuild-linux-large-runners, r=KobzolGuillaume Gomez-2/+2
ci: use aws codebuild for the `dist-x86_64-linux` job try-job: dist-x86_64-linux
2025-04-28Rollup merge of #140347 - marcoieni:free-disk-codebuild, r=jdnoGuillaume Gomez-50/+81
ci: clean more disk space in codebuild try-job: dist-arm-linux
2025-04-28Rollup merge of #140316 - nnethercote:BoxMarker, r=dtolnayGuillaume Gomez-421/+468
Introduce `BoxMarker` to improve pretty-printing correctness Box opening/closing is really easy to get wrong in the pretty-printers. This PR makes it much harder to get wrong. r? `@Urgau`
2025-04-28Rollup merge of #140249 - BoxyUwU:remove_weak_alias_terminology, r=oli-obkGuillaume Gomez-106/+106
Remove `weak` alias terminology I find the "weak" alias terminology to be quite confusing. It implies the existence of "strong" aliases (which do not exist) and I'm not really sure what about weak aliases is "weak". I much prefer "free alias" as the term. I think it's much more obvious what it means as "free function" is a well defined term that already exists in rust. It's also a little confusing given "weak alias" is already a term in linker/codegen spaces which are part of the compiler too. Though I'm not particularly worried about that as it's usually very obvious if you're talking about the type system or not lol. I'm also currently trying to write documentation about aliases and it's somewhat awkward/confusing to be talking about *weak* aliases, when I'm not really sure what the basis for that as the term actually *is*. I would also be happy to just find out there's a nice meaning behind calling them "weak" aliases :-) r? `@oli-obk` maybe we want a types MCP to decide on a specific naming here? or maybe we think its just too late to go back on this naming decision ^^'
2025-04-28Rollup merge of #140220 - GuillaumeGomez:doctest-main-wrapping, r=fmeaseGuillaume Gomez-32/+77
Fix detection of main function if there are expressions around it Fixes #140162. Fixes #139651. Once this is merged, we can backport and I'll send a follow-up to emit a warning in case a `main` function is about to be "wrapped" (and therefore not run). r? `@fmease` try-job: x86_64-mingw-1
2025-04-28Rollup merge of #140056 - yuk1ty:fix-static-mut-error-message, r=jieyouxuGuillaume Gomez-93/+91
Fix a wrong error message in 2024 edition Fixes https://github.com/rust-lang/rust/issues/139952
2025-04-28AsyncDrop implementation using shim codegen of ↵Andrew Zhogin-1878/+4053
async_drop_in_place::{closure}, scoped async drop added.
2025-04-28Auto merge of #123239 - Urgau:dangerous_implicit_autorefs, ↵bors-3/+626
r=jdonszelmann,traviscross Implement a lint for implicit autoref of raw pointer dereference - take 2 *[t-lang nomination comment](https://github.com/rust-lang/rust/pull/123239#issuecomment-2727551097)* This PR aims at implementing a lint for implicit autoref of raw pointer dereference, it is based on #103735 with suggestion and improvements from https://github.com/rust-lang/rust/pull/103735#issuecomment-1370420305. The goal is to catch cases like this, where the user probably doesn't realise it just created a reference. ```rust pub struct Test { data: [u8], } pub fn test_len(t: *const Test) -> usize { unsafe { (*t).data.len() } // this calls <[T]>::len(&self) } ``` Since #103735 already went 2 times through T-lang, where they T-lang ended-up asking for a more restricted version (which is what this PR does), I would prefer this PR to be reviewed first before re-nominating it for T-lang. ---- Compared to the PR it is as based on, this PR adds 3 restrictions on the outer most expression, which must either be: 1. A deref followed by any non-deref place projection (that intermediate deref will typically be auto-inserted) 2. A method call annotated with `#[rustc_no_implicit_refs]`. 3. A deref followed by a `addr_of!` or `addr_of_mut!`. See bottom of post for details. There are several points that are not 100% clear to me when implementing the modifications: - ~~"4. Any number of automatically inserted deref/derefmut calls." I as never able to trigger this. Am I missing something?~~ Fixed - Are "index" and "field" enough? ---- cc `@JakobDegen` `@WaffleLapkin` r? `@RalfJung` try-job: dist-various-1 try-job: dist-various-2
2025-04-28ci: use aws codebuild for the `dist-x86_64-linux` jobMarcoIeni-2/+2
2025-04-28Inline and remove three pretty-printer methods.Nicholas Nethercote-67/+37
They all have a single call site, aren't that big, and removing them avoids having to pass some `BoxMarker`s.
2025-04-28Use `PrintState::head` in `PrintState::block_to_string`.Nicholas Nethercote-4/+1
2025-04-28Introduce `BoxMarker` to pretty-printing.Nicholas Nethercote-375/+455
The pretty-printers open and close "boxes" of text a lot. The open and close operations must be matched. The matching is currently all implicit and very easy to get wrong. (#140280 and #140246 are two recent pretty-printing fixes that both involved unclosed boxes.) This commit introduces `BoxMarker`, a marker type that represents an open box. It makes box opening/closing explicit, which makes it much easier to understand and harder to get wrong. The commit also removes many comments are on `end` calls saying things like "end outer head-block", "Close the outer-box". These demonstrate how confusing the implicit approach was, but aren't necessary any more.
2025-04-28Auto merge of #136316 - GrigorenkoPV:generic_atomic, r=Mark-Simulacrumbors-265/+370
Create `Atomic<T>` type alias (rebase) Rebase of #130543. Additional changes: - Switch from `allow` to `expect` for `private_bounds` on `AtomicPrimitive` - Unhide `AtomicPrimitive::AtomicInner` from docs, because rustdoc shows the definition `pub type Atomic<T> = <T as AtomicPrimitive>::AtomicInner;` and generated links for it. - `NonZero` did not have this issue, because they kept the new alias private before the direction was changed. - Use `Atomic<_>` in more places, including inside `Once`'s `Futex`. This is possible thanks to https://github.com/rust-lang/rust-clippy/pull/14125 The rest will either get moved back to #130543 or #130543 will be closed in favor of this instead. --- * ACP: https://github.com/rust-lang/libs-team/issues/443#event-14293381061 * Tracking issue: #130539
2025-04-28Merge pull request #2358 from rust-lang/rustc-pullTshepang Mbambo-3041/+5188
Rustc pull update
2025-04-28Merge from rustcThe rustc-dev-guide Cronjob Bot-3040/+5187
2025-04-28Preparing for merge from rustcThe rustc-dev-guide Cronjob Bot-1/+1
2025-04-28Auto merge of #140378 - ChrisDenton:rollup-3mj0wp9, r=ChrisDentonbors-33/+118
Rollup of 8 pull requests Successful merges: - #138395 (Download GCC from CI on test builders) - #138737 (uefi: Update r-efi) - #138939 (Add `Arc::is_unique`) - #139224 (fix(test): Expose '--no-capture' in favor of `--nocapture`) - #139546 (std(docs): clarify how std::fs::set_permisions works with symlinks) - #140345 (Avoid re-interning in `LateContext::get_def_path`) - #140351 (docs: fix incorrect stability markers on `std::{todo, matches}`) - #140359 (specify explicit safety guidance for from_utf8_unchecked) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-28Rollup merge of #140359 - DiuDiu777:str-fix, r=NoratriebChris Denton-2/+2
specify explicit safety guidance for from_utf8_unchecked The PR addresses missing safety guidelines in two APIs by adding explicit text to the cross-linked reference.
2025-04-28Rollup merge of #140351 - rust-lang:notriddle/stability-use, r=thomccChris Denton-2/+8
docs: fix incorrect stability markers on `std::{todo, matches}` This regression appeared in 916cfbcd3ed95a737b5a62103bbc4118ffe1eb2b. The change is behaving as expected (a non-glob re-export uses the stability marker on the `use` item, not the original one), but this part of the standard library didn't follow it. Fixes https://github.com/rust-lang/rust/issues/140344
2025-04-28Rollup merge of #140345 - DaniPopes:get-def-path, r=UrgauChris Denton-1/+4
Avoid re-interning in `LateContext::get_def_path` The def path printer in `get_def_path` essentially calls `Symbol::intern(&symbol.to_string())` for simple symbols in a path. This accounts for ~30% of the runtime of get_def_path. We can avoid this by simply appending the symbol directly when available.
2025-04-28Rollup merge of #139546 - lolbinarycat:std-set_permissions-75942, r=thomccChris Denton-0/+15
std(docs): clarify how std::fs::set_permisions works with symlinks fixes https://github.com/rust-lang/rust/issues/75942 fixes https://github.com/rust-lang/rust/issues/124201
2025-04-28Rollup merge of #139224 - epage:nocapture, r=thomccChris Denton-9/+14
fix(test): Expose '--no-capture' in favor of `--nocapture` This improves consistency with commonly expected CLI conventions, avoiding a common stutter people make when running tests (trying what they expect and then having to check the docs to then user whats accepted). An alternative could have been to take a value, like `--capture <value>` (e.g. `pytest` does this). Overall, we're shifting focus for features to custom test harnesses (see #134283). Most of `pytest`s modes will likely be irrelevant in that situation. As for the rest, its too early to tell which, if any, may be relevant, so we're sticking with this small, quality of life improvement. I expect we'll warn about `--nocapture` being deprecated in the future after a sufficient transition period has been allowed. By deprecating `--nocapture`, we intend that custom test harnesses do not need to support it for reasons outside of their own compatibility requirements, much like the deprecation in #134283 I'm punting for now on the naming of `RUST_TEST_NOCAPTURE`. I feel like T-testing-devex should do a wider look at environment variables role in lib`test` before evaluating whether to - Deprecate it in favor of the user passing CLI flags or the test runner providing its own config - Deprecate in favor of `RUST_TEST_NO_CAPTURE` - Deprecate in favor of `RUST_TEST_CAPTURE` Other CLI flags were evaluated for casing consistency: - `--logfile` has the same problem but was deprecated in #134283 Regarding the implementation, I moved `--nocapture` out of `optgroups()`, into `parse_opts()`, out of an abundance of caution in passing the options without a deprecated value to the usage generation. However, the usage does not actually show optional flags, so this could potentially be dropped, simplifying the PR. Note: `compiletest` added `--no-capture` instead of `--nocapture` in #134809 T-testing-devex FCP: https://github.com/rust-lang/rust/issues/133073#issuecomment-2486921104 Fixes #133073
2025-04-28Rollup merge of #138939 - SabrinaJewson:arc-is-unique, r=tgross35Chris Denton-8/+61
Add `Arc::is_unique` Adds ```rs impl<T> Arc<T> { pub fn is_unique(this: &Self) -> bool; } ``` Tracking issue: #138938 ACP: https://github.com/rust-lang/libs-team/issues/560
2025-04-28Rollup merge of #138737 - Ayush1325:r-efi-update, r=tgross35Chris Denton-10/+10
uefi: Update r-efi - Bump up the version to 5.2.0 try-job: x86_64-gnu-distcheck try-job: x86_64-gnu try-job: test-various
2025-04-28Rollup merge of #138395 - Kobzol:ci-download-gcc, r=Mark-SimulacrumChris Denton-1/+4
Download GCC from CI on test builders This should reduce the duration of the `x86_64-gnu-llvm-18` job, which runs on PR CI, which is currently the only one that builds GCC (outside of the x64 dist builder). Since we handle the GCC download in the GCC step, and not eagerly in config, we can set this flag globally across all test builders, as it won't do anything unless they actually try to build GCC. Opening as a draft to test if it works on CI, because I still need to implement logic to avoid the download if there are any local modifications to GCC (essentially the "if-unchanged" mode, although I want to try something a bit different). r? ```@ghost```
2025-04-27Auto merge of #140362 - weihanglo:update-cargo, r=weihanglobors-0/+0
Update cargo 10 commits in d811228b14ae2707323f37346aee3f4147e247e6..7918c7eb59614c39f1c4e27e99d557720976bdd7 2025-04-15 15:18:42 +0000 to 2025-04-27 09:44:23 +0000 - overriding-dependencies.md: better readability (rust-lang/cargo#15459) - source-replacement.md: fix typo (rust-lang/cargo#15458) - Stabilize automatic garbage collection. (rust-lang/cargo#14287) - Update doctest xcompile flags (rust-lang/cargo#15455) - fix: Suggest similar looking feature names when feature is missing (rust-lang/cargo#15454) - fix(unit-graph): switch to Package ID Spec (rust-lang/cargo#15447) - chore(deps): update cargo-semver-checks to v0.41.0 (rust-lang/cargo#15446) - Implement RFC3695: Allow boolean literals as cfg predicates (rust-lang/cargo#14649) - chore: remove duplicate word in comment (rust-lang/cargo#15437) - Fix formatting of CliUnstable parsing (rust-lang/cargo#15434) r? ghost
2025-04-28dropee_emit_retag function separated in drop glue buildAndrew Zhogin-26/+38
2025-04-27Auto merge of #140366 - matthiaskrgr:rollup-zd3q1oy, r=matthiaskrgrbors-108/+368
Rollup of 4 pull requests Successful merges: - #140246 (Fix never pattern printing) - #140280 (Improve if/else pretty printing) - #140348 (Update lint-docs to default to Rust 2024) - #140358 (Use `search_for_cycle_permutation` to look for `variances_of`) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-27Rollup merge of #140358 - Zoxc:variance-cycle, r=oli-obkMatthias Krüger-12/+20
Use `search_for_cycle_permutation` to look for `variances_of` This uses `search_for_cycle_permutation` to look for `variances_of` in case `variances_of` is not the first query in the cycle. This may fix https://github.com/rust-lang/rust/issues/124423 and https://github.com/rust-lang/rust/issues/127971. r? `@oli-obk`
2025-04-27Rollup merge of #140348 - ehuss:lint-docs-edition, r=compiler-errorsMatthias Krüger-18/+12
Update lint-docs to default to Rust 2024 This updates the lint-docs tool to default to the 2024 edition. The lint docs are supposed to illustrate the code with the latest edition, and I just forgot to update this in https://github.com/rust-lang/rust/pull/133349. Some docs needed to add the `edition` attribute since they were assuming a particular edition, but were missing the explicit annotation. This also includes a commit to simplify the edition handling in lint-docs.
2025-04-27Rollup merge of #140280 - nnethercote:improve-if-else-printing, r=UrgauMatthias Krüger-78/+302
Improve if/else pretty printing AST/HIR pretty printing of if/else is currently pretty bad. This PR improves it a lot. r? `@Nadrieril`
2025-04-27Rollup merge of #140246 - nnethercote:fix-never-pattern-printing, r=NadrierilMatthias Krüger-0/+34
Fix never pattern printing It's currently broken, but there's an easy fix. r? `@Nadrieril`
2025-04-27Add `Arc::is_unique`SabrinaJewson-8/+61
2025-04-27Update cargoWeihang Lo-0/+0
2025-04-27Auto merge of #140360 - matthiaskrgr:rollup-savbr84, r=matthiaskrgrbors-143/+89
Rollup of 8 pull requests Successful merges: - #137439 (Stabilise `std::ffi::c_str`) - #137714 (Update safety documentation for `CString::from_ptr` and `str::from_boxed_utf8_unchecked`) - #139031 (Use char::is_whitespace directly in str::trim*) - #139090 (fix docs for `Peekable::next_if{_eq}`) - #140297 (Update example to use CStr::to_string_lossy) - #140330 (Clarified bootstrap optimization "true" argument) - #140339 (session: Cleanup `CanonicalizedPath::new`) - #140346 (rustc_span: Some hygiene cleanups) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-27Fix SGX library code implicit auto-refUrgau-1/+1
2025-04-27Rollup merge of #140346 - petrochenkov:cleanhyg, r=compiler-errorsMatthias Krüger-118/+54
rustc_span: Some hygiene cleanups Mostly enabled by #139241 and #139281.
2025-04-27Rollup merge of #140339 - petrochenkov:capanew, r=lqdMatthias Krüger-9/+8
session: Cleanup `CanonicalizedPath::new` It wants an owned path, so pass an owned path.
2025-04-27Rollup merge of #140330 - Kivooeo:new-fix-five, r=clubby789Matthias Krüger-1/+1
Clarified bootstrap optimization "true" argument fixes #140328
2025-04-27Rollup merge of #140297 - shepmaster:cstr-lossy, r=joboetMatthias Krüger-2/+3
Update example to use CStr::to_string_lossy
2025-04-27Rollup merge of #139090 - yotamofek:pr/peekable-next-if-docs, r=tgross35Matthias Krüger-3/+3
fix docs for `Peekable::next_if{_eq}` These seem like copy-paste errors (except `saves the value of` 👉 `retains` which just sounds better to me)
2025-04-27Rollup merge of #139031 - DaniPopes:str-trim-closure, r=tgross35Matthias Krüger-3/+3
Use char::is_whitespace directly in str::trim* Use the method directly instead of wrapping it in a closure.
2025-04-27Rollup merge of #137714 - DiuDiu777:doc-fix, r=tgross35Matthias Krüger-3/+12
Update safety documentation for `CString::from_ptr` and `str::from_boxed_utf8_unchecked` ## PR Description​ This PR addresses missing safety documentation for two APIs: ​**1. alloc::ffi::CStr::from_raw**​ - ​`Alias`: The pointer ​must not be aliased​ (accessed via other pointers) during the reconstructed CString's lifetime. - `Owning`: Calling this function twice on the same pointer and creating two objects with overlapping lifetimes, introduces two alive owners of the same memory. This may result in a double-free. - `Dangling`: The prior documentation required the pointer to originate from CString::into_raw, but this constraint is incomplete. A validly sourced pointer can also cause undefined behavior (UB) if it becomes dangling. A simple Poc for this situation: ``` use std::ffi::CString; use std::os::raw::c_char; fn create_dangling() -> *mut c_char { let local_ptr: *mut c_char = { let valid_data = CString::new("valid").unwrap(); valid_data.into_raw() }; unsafe { let _x = CString::from_raw(local_ptr); } local_ptr } fn main() { let dangling = create_dangling(); unsafe {let _y = CString::from_raw(dangling);} // Cause UB! } ``` ​**2. alloc::str::from_boxed_utf8_unchecked**​ - `ValidStr`: Bytes must contain a ​valid UTF-8 sequence.
2025-04-27Rollup merge of #137439 - clarfonthey:c-str-module, r=tgross35Matthias Krüger-4/+5
Stabilise `std::ffi::c_str` This finished FCP in #112134 but never actually got a stabilisation PR. Since the FCP in #120048 recently passed to add the `os_str` module, it would be nice to also merge this too, to ensure that both get added in the next version. Note: The added stability attributes which *somehow* were able to be omitted before (rustc bug?) were added based on the fact that they were added in 302551388b1942bb4216bb5a15d9d55cee3643a8, which ended up in 1.85.0. Closes: https://github.com/rust-lang/rust/issues/112134 r? libs-api
2025-04-27Merge pull request #2351 from rust-lang/rustc-pullYuki Okushi-10984/+20283
2025-04-27ci: clean more disk space in codebuildMarcoIeni-50/+81