about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2024-12-21Revert "Auto merge of #133902 - Kobzol:ci-dist-arm-runner, r=MarcoIeni"Jakub Beránek-5/+5
This reverts commit b597d2a099a1b5b79acef05175a9ac847047f8a1, reversing changes made to ff7906bfe1ed264bf9c4d3abe1940e357b7e61dd.
2024-12-21Auto merge of #134604 - RalfJung:miri-sync, r=RalfJungbors-998/+1473
Miri subtree update r? `@ghost`
2024-12-21Auto merge of #134605 - jhpratt:rollup-quiss71, r=jhprattbors-110/+379
Rollup of 7 pull requests Successful merges: - #133087 (Detect missing `.` in method chain in `let` bindings and statements) - #134575 (Handle `DropKind::ForLint` in coroutines correctly) - #134576 (Improve prose around basic examples of Iter and IterMut) - #134577 (Improve prose around `as_slice` example of Iter) - #134579 (Improve prose around into_slice example of IterMut) - #134593 (Less unwrap() in documentation) - #134600 (Fix parenthesization of chained comparisons by pretty-printer) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-21Rollup merge of #134600 - dtolnay:chainedcomparison, r=oli-obkJacob Pratt-17/+16
Fix parenthesization of chained comparisons by pretty-printer Example: ```rust macro_rules! repro { () => { 1 < 2 }; } fn main() { let _ = repro!() == false; } ``` Previously `-Zunpretty=expanded` would pretty-print this syntactically invalid output: `fn main() { let _ = 1 < 2 == false; }` ```console error: comparison operators cannot be chained --> <anon>:8:23 | 8 | fn main() { let _ = 1 < 2 == false; } | ^ ^^ | help: parenthesize the comparison | 8 | fn main() { let _ = (1 < 2) == false; } | + + ``` With the fix, it will print `fn main() { let _ = (1 < 2) == false; }`. Making `-Zunpretty=expanded` consistently produce syntactically valid Rust output is important because that is what makes it possible for `cargo expand` to format and perform filtering on the expanded code. ## Review notes According to `rg '\.fixity\(\)' compiler/` the `fixity` function is called only 3 places: - https://github.com/rust-lang/rust/blob/13170cd787cb733ed24842ee825bcbd98dc01476/compiler/rustc_ast_pretty/src/pprust/state/expr.rs#L283-L287 - https://github.com/rust-lang/rust/blob/13170cd787cb733ed24842ee825bcbd98dc01476/compiler/rustc_hir_pretty/src/lib.rs#L1295-L1299 - https://github.com/rust-lang/rust/blob/13170cd787cb733ed24842ee825bcbd98dc01476/compiler/rustc_parse/src/parser/expr.rs#L282-L289 The 2 pretty printers definitely want to treat comparisons using `Fixity::None`. That's the whole bug being fixed. Meanwhile, the parser's `Fixity::None` codepath is previously unreachable as indicated by the comment, so as long as `Fixity::None` here behaves exactly the way that `Fixity::Left` used to behave, you can tell that this PR definitely does not constitute any behavior change for the parser. My guess for why comparison operators were set to `Fixity::Left` instead of `Fixity::None` is that it's a very old workaround for giving a good chained comparisons diagnostic (like what I pasted above). Nowadays that is handled by a different dedicated codepath.
2024-12-21Rollup merge of #134593 - kornelski:less-unwrap, r=jhprattJacob Pratt-50/+76
Less unwrap() in documentation I think the common use of `.unwrap()` in examples makes it overrepresented, looking like a more typical way of error handling than it really is in real programs. Therefore, this PR changes a bunch of examples to use different error handling methods, primarily the `?` operator. Additionally, `unwrap()` docs warn that it might abort the program.
2024-12-21Rollup merge of #134579 - hkBst:patch-6, r=jhprattJacob Pratt-20/+13
Improve prose around into_slice example of IterMut Having a part without modification and one with seems redundant, since `into_slice` is only called for the part without. I have brought the modification into the remaining part, although it perhaps does not add much (or only distracts?).
2024-12-21Rollup merge of #134577 - hkBst:patch-5, r=jhprattJacob Pratt-5/+11
Improve prose around `as_slice` example of Iter
2024-12-21Rollup merge of #134576 - hkBst:patch-4, r=jhprattJacob Pratt-6/+12
Improve prose around basic examples of Iter and IterMut
2024-12-21Rollup merge of #134575 - compiler-errors:drop-lint-coro, r=nikomatsakisJacob Pratt-10/+91
Handle `DropKind::ForLint` in coroutines correctly Fixes #134566 Fixes #134541
2024-12-21Rollup merge of #133087 - estebank:stmt-misparse, r=chenyukangJacob Pratt-2/+160
Detect missing `.` in method chain in `let` bindings and statements On parse errors where an ident is found where one wasn't expected, see if the next elements might have been meant as method call or field access. ``` error: expected one of `.`, `;`, `?`, `else`, or an operator, found `map` --> $DIR/missing-dot-on-statement-expression.rs:7:29 | LL | let _ = [1, 2, 3].iter()map(|x| x); | ^^^ expected one of `.`, `;`, `?`, `else`, or an operator | help: you might have meant to write a method call | LL | let _ = [1, 2, 3].iter().map(|x| x); | + ```
2024-12-21Merge pull request #4102 from rust-lang/rustup-2024-12-21Oli Scherer-772/+1148
Automatic Rustup
2024-12-21Merge from rustcThe Miri Cronjob Bot-771/+1147
2024-12-21Preparing for merge from rustcThe Miri Cronjob Bot-1/+1
2024-12-20Change comparison operators to have Fixity::NoneDavid Tolnay-17/+8
2024-12-20Add some parenthesization test cases with operators that are not ↵David Tolnay-0/+8
left-associative
2024-12-21Auto merge of #134594 - weihanglo:update-cargo, r=weihanglobors-0/+0
Update cargo 10 commits in 99dff6d77db779716dda9ca3b29c26addd02c1be..652623b779c88fe44afede28bf7f1c9c07812511 2024-12-18 00:55:17 +0000 to 2024-12-20 15:44:42 +0000 - fix(package): use relpath to cwd for vcs dirtiness report (rust-lang/cargo#14970) - Enable triagebot merge conflict notifications (rust-lang/cargo#14972) - fixed the error message for a user to open the crate (rust-lang/cargo#14969) - fix(package): show dirty filepaths relative to git workdir (rust-lang/cargo#14968) - Add the `test` cfg as a well known cfg before of compiler change (rust-lang/cargo#14963) - refactor(cargo-package): let-else to flatten code (rust-lang/cargo#14959) - fix(cargo-package): add more traces (rust-lang/cargo#14960) - Do not hash absolute sysroot path into stdlib crates metadata. (rust-lang/cargo#14951) - docs: add missing argument to Rustup Cargo workaround (rust-lang/cargo#14954) - fix(cargo-rustc): stabilize higher precedence trailing flags (rust-lang/cargo#14900)
2024-12-21Do not suggest `foo.Bar`Esteban Küber-11/+6
2024-12-21Account for missing `.` in macros to avoid incorrect suggestionEsteban Küber-4/+4
2024-12-21Detect missing `.` in method chain in let bindings and statementsEsteban Küber-2/+165
On parse errors where an ident is found where one wasn't expected, see if the next elements might have been meant as method call or field access. ``` error: expected one of `.`, `;`, `?`, `else`, or an operator, found `map` --> $DIR/missing-dot-on-statement-expression.rs:7:29 | LL | let _ = [1, 2, 3].iter()map(|x| x); | ^^^ expected one of `.`, `;`, `?`, `else`, or an operator | help: you might have meant to write a method call | LL | let _ = [1, 2, 3].iter().map(|x| x); | + ```
2024-12-20Update cargoWeihang Lo-0/+0
2024-12-21Less unwrap() in documentationKornel-50/+76
2024-12-21Auto merge of #134590 - matthiaskrgr:rollup-8lz2s62, r=matthiaskrgrbors-186/+779
Rollup of 7 pull requests Successful merges: - #123604 (Abstract `ProcThreadAttributeList` into its own struct) - #128780 (Add `--doctest-compilation-args` option to add compilation flags to doctest compilation) - #133782 (Precedence improvements: closures and jumps) - #134509 (Arbitrary self types v2: niche deshadowing test) - #134524 (Arbitrary self types v2: no deshadow pre feature.) - #134539 (Restrict `#[non_exaustive]` on structs with default field values) - #134586 (Also lint on option of function pointer comparisons) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-21Rollup merge of #134586 - Urgau:fn-ptr-lint-option, r=compiler-errorsMatthias Krüger-2/+50
Also lint on option of function pointer comparisons This PR is the first part of #134536, ie. the linting on `Option<{fn ptr}>` in the `unpredictable_function_pointer_comparisons` lint, which isn't part of the lang nomination that the second part is going trough, and so should be able to be approved independently. Related to https://github.com/rust-lang/rust/issues/134527 r? `@compiler-errors`
2024-12-21Rollup merge of #134539 - estebank:restrict-non_exhaustive, r=jieyouxuMatthias Krüger-3/+78
Restrict `#[non_exaustive]` on structs with default field values Do not allow users to apply `#[non_exaustive]` to a struct when they have also used default field values.
2024-12-21Rollup merge of #134524 - adetaylor:getref, r=compiler-errorsMatthias Krüger-0/+50
Arbitrary self types v2: no deshadow pre feature. The arbitrary self types v2 work introduces a check for shadowed methods, whereby a method in some "outer" smart pointer type may called in preference to a method in the inner referent. This is bad if the outer pointer adds a method later, as it may change behavior, so we ensure we error in this circumstance. It was intended that this new shadowing detection system only comes into play for users who enable the `arbitrary_self_types` feature (or of course everyone later if it's stabilized). It was believed that the new deshadowing code couldn't be reached without building the custom smart pointers that `arbitrary_self_types` enables, and therefore there was no risk of this code impacting existing users. However, it turns out that cunning use of `Pin::get_ref` can cause this type of shadowing error to be emitted now. This commit adds a test for this case. As we want this test to pass without arbitrary_self_types, but fail with it, I've split it into two files (one with run-pass and one without). If there's a better way I can amend it. Part of #44874 r? ```@wesleywiser```
2024-12-21Rollup merge of #134509 - adetaylor:niche-deshadowing-tests, r=wesleywiserMatthias Krüger-0/+63
Arbitrary self types v2: niche deshadowing test Arbitrary self types v2 attempts to detect cases where methods in an "outer" type (e.g. a smart pointer) might "shadow" methods in the referent. There are a couple of cases where the current code makes no attempt to detect such shadowing. Both of these cases only apply if other unstable features are enabled. Add a test, mostly for illustrative purposes, so we can see the shadowing cases that can occur. Part of #44874 r? ```@wesleywiser```
2024-12-21Rollup merge of #133782 - dtolnay:closuresjumps, r=spastorino,traviscrossMatthias Krüger-9/+24
Precedence improvements: closures and jumps This PR fixes some cases where rustc's pretty printers would redundantly parenthesize expressions that didn't need it. <table> <tr><th>Before</th><th>After</th></tr> <tr><td><code>return (|x: i32| x)</code></td><td><code>return |x: i32| x</code></td></tr> <tr><td><code>(|| -> &mut () { std::process::abort() }).clone()</code></td><td><code>|| -> &mut () { std::process::abort() }.clone()</code></td></tr> <tr><td><code>(continue) + 1</code></td><td><code>continue + 1</code></td></tr> </table> Tested by `echo "fn main() { let _ = $AFTER; }" | rustc -Zunpretty=expanded /dev/stdin`. The pretty-printer aims to render the syntax tree as it actually exists in rustc, as faithfully as possible, in Rust syntax. It can insert parentheses where forced by Rust's grammar in order to preserve the meaning of a macro-generated syntax tree, for example in the case of `a * $rhs` where $rhs is `b + c`. But for any expression parsed from source code, without a macro involved, there should never be a reason for inserting additional parentheses not present in the original. For closures and jumps (return, break, continue, yield, do yeet, become) the unneeded parentheses came from the precedence of some of these expressions being misidentified. In the same order as the table above: - Jumps and closures are supposed to have equal precedence. The [Rust Reference](https://doc.rust-lang.org/1.83.0/reference/expressions.html#expression-precedence) says so, and in Syn they do. There is no Rust syntax that would require making a precedence distinction between jumps and closures. But in rustc these were previously 2 distinct levels with the closure being lower, hence the parentheses around a closure inside a jump (but not a jump inside a closure). - When a closure is written with an explicit return type, the grammar [requires](https://doc.rust-lang.org/1.83.0/reference/expressions/closure-expr.html) that the closure body consists of exactly one block expression, not any other arbitrary expression as usual for closures. Parsing of the closure body does not continue after the block expression. So in `|| { 0 }.clone()` the clone is inside the closure body and applies to `{ 0 }`, whereas in `|| -> _ { 0 }.clone()` the clone is outside and applies to the closure as a whole. - Continue never needs parentheses. It was previously marked as having the lowest possible precedence but it should have been the highest, next to paths and loops and function calls, not next to jumps.
2024-12-21Rollup merge of #128780 - GuillaumeGomez:rustflags-doctests, r=rustdocMatthias Krüger-21/+220
Add `--doctest-compilation-args` option to add compilation flags to doctest compilation Fixes #67533. Tracking issue: https://github.com/rust-lang/rust/issues/134172 It's been something I meant to take a look at for a long time and actually completely forgot... The idea is to allow to give more control over how doctests are compiled to users. To do so, this PR adds a new `--doctest-compilation-args` option which provides extra compilation flags. r? `@notriddle`
2024-12-21Rollup merge of #123604 - michaelvanstraten:proc_thread_attribute_list, ↵Matthias Krüger-151/+294
r=ChrisDenton Abstract `ProcThreadAttributeList` into its own struct As extensively discussed in issue #114854, the current implementation of the unstable `windows_process_extensions_raw_attribute` features lacks support for passing a raw pointer. This PR wants to explore the opportunity to abstract away the `ProcThreadAttributeList` into its own struct to for one improve safety and usability and secondly make it possible to maybe also use it to spawn new threads. try-job: x86_64-mingw
2024-12-20Also lint on option of function pointer comparisonsUrgau-2/+50
2024-12-20Add test to ensure passing `--doctest_compilation_args` multiple times workGuillaume Gomez-1/+24
2024-12-20Move test into the `tests.rs` fileGuillaume Gomez-23/+22
2024-12-20Add explanations on how arguments are splitGuillaume Gomez-0/+19
2024-12-20Split arguments from `--doctest-compilation-args` like a shell wouldGuillaume Gomez-8/+64
2024-12-20Update `run-make/rustdoc-default-output` testGuillaume Gomez-2/+4
2024-12-20Auto merge of #134582 - matthiaskrgr:rollup-i0oyqjw, r=matthiaskrgrbors-299/+297
Rollup of 8 pull requests Successful merges: - #134556 ([tiny] fix missing ns units in bootstrap's benchmark rendering) - #134560 (mri: add track_caller to thread spawning methods for better backtraces) - #134561 (Reduce the amount of explicit FatalError.raise()) - #134562 (tests/codegen/asm: Remove uses of rustc_attrs and lang_items features by using minicore) - #134567 (Remove some dead code around import library generation) - #134570 (remove reference to dangling from slice::Iter) - #134573 (unimplement `PointerLike` for trait objects) - #134574 (next-solver: disable unnecessary hack) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-20Rollup merge of #134574 - lcnr:opaque-ty-hack-yeet, r=compiler-errorsMatthias Krüger-11/+14
next-solver: disable unnecessary hack the new solver never constrains inference variables to normalizeable aliases, so this is no longer necessary.
2024-12-20Rollup merge of #134573 - lukas-code:unimpl-dyn-pointerlike, r=compiler-errorsMatthias Krüger-93/+217
unimplement `PointerLike` for trait objects Values of type `dyn* PointerLike` or `dyn PointerLike` are not pointer-like so these types should not implement `PointerLike`. After https://github.com/rust-lang/rust/pull/133226, `PointerLike` allows user implementations, so we can't just mark it with `#[rustc_deny_explicit_impl(implement_via_object = false)]`. Instead, this PR splits the `#[rustc_deny_explicit_impl(implement_via_object = ...)]` attribute into two separate attributes `#[rustc_deny_explicit_impl]` and `#[rustc_do_not_implement_via_object]` so that we opt out of the automatic `impl PointerLike for dyn PointerLike` and still allow user implementations. For traits that are marked with `#[do_not_implement_via_object]` but not `#[rustc_deny_explicit_impl]` I've also made it possible to add a manual `impl Trait for dyn Trait`. There is no immediate need for this, but it was one line to implement and seems nice to have. fixes https://github.com/rust-lang/rust/issues/134545 fixes https://github.com/rust-lang/rust/issues/134543 r? `@compiler-errors`
2024-12-20Rollup merge of #134570 - hkBst:patch-3, r=joboetMatthias Krüger-1/+1
remove reference to dangling from slice::Iter This aligns the comment with reality and with IterMut. Also dangling does not seem to take any arguments.
2024-12-20Rollup merge of #134567 - bjorn3:remove_unused_code, r=compiler-errorsMatthias Krüger-78/+0
Remove some dead code around import library generation This was missed when replacing the usage of LLVM for generating import libraries. ``@bors`` rollup
2024-12-20Rollup merge of #134562 - taiki-e:codegen-asm-minicore, r=jieyouxuMatthias Krüger-74/+36
tests/codegen/asm: Remove uses of rustc_attrs and lang_items features by using minicore Similar to https://github.com/rust-lang/rust/pull/134385 (for tests/ui/asm) and https://github.com/rust-lang/rust/pull/134436 (for tests/assembly/asm), but for tests/codegen/asm. r? jieyouxu
2024-12-20Rollup merge of #134561 - bjorn3:less_fatal_error_raise, r=compiler-errorsMatthias Krüger-41/+22
Reduce the amount of explicit FatalError.raise() Instead use dcx.abort_if_error() or guar.raise_fatal() instead. These guarantee that an error actually happened previously and thus we don't silently abort.
2024-12-20Rollup merge of #134560 - RalfJung:miri-thread-spawn, r=jhprattMatthias Krüger-0/+6
mri: add track_caller to thread spawning methods for better backtraces This is in preparation for https://github.com/rust-lang/miri/pull/4093
2024-12-20Rollup merge of #134556 - the8472:restore-ns-units, r=jieyouxuMatthias Krüger-1/+1
[tiny] fix missing ns units in bootstrap's benchmark rendering
2024-12-20Improve prose around into_slice example of IterMutMarijn Schouten-20/+13
2024-12-20Improve prose around `as_slice` example of IterMarijn Schouten-5/+11
2024-12-20Handle DropKind::ForLint in coroutines correctlyMichael Goulet-10/+91
2024-12-20Auto merge of #134564 - Kobzol:revert-aarch64-runner, r=nikicbors-129/+99
Revert "Auto merge of #133809 - mrkajetanp:ci-aarch64-dist, r=Kobzol" This reverts https://github.com/rust-lang/rust/pull/133809, as it produced broken aarch64 artifacts (https://github.com/rust-lang/rust/issues/134563). `@bors` p=1
2024-12-20Improve prose around basic examples of Iter and IterMutMarijn Schouten-6/+12
2024-12-20next-solver: rm opaque type hacklcnr-11/+14