about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2024-05-12Auto merge of #125051 - dtolnay:printletelse, r=compiler-errorsbors-0/+41
Pretty-print let-else with added parenthesization when needed Rustc used to produce invalid syntax for the following code, which is problematic because it means we cannot apply rustfmt to the output of `-Zunpretty=expanded`. ```rust macro_rules! expr { ($e:expr) => { $e }; } fn main() { let _ = expr!(loop {}) else { return; }; } ``` ```console $ rustc repro.rs -Zunpretty=expanded | rustfmt error: `loop...else` loops are not supported --> <stdin>:9:29 | 9 | fn main() { let _ = loop {} else { return; }; } | ---- ^^^^^^^^^^^^^^^^ | | | `else` is attached to this loop | = note: consider moving this `else` clause to a separate `if` statement and use a `bool` variable to control if it should run ```
2024-05-12Pretty-print let-else with added parenthesization when neededDavid Tolnay-1/+1
2024-05-12Add AST pretty-printer tests for let-elseDavid Tolnay-0/+41
2024-05-12Auto merge of #124639 - ↵bors-47/+223
Jules-Bertholet:match-ergonomics-2024-migration-lint, r=Nadrieril Match ergonomics 2024: migration lint Depends on #124567 r? `@Nadrieril` cc https://github.com/rust-lang/rust/issues/123076 `@rustbot` label A-edition-2024 A-patterns
2024-05-12Propagate errors rather than using return_if_errMichael Goulet-8/+28
2024-05-12Apply nitsMichael Goulet-0/+4
2024-05-12Try structurally resolveMichael Goulet-0/+15
2024-05-12Match ergonomics 2024: migration lintJules Bertholet-47/+223
Unfortunately, we can't always offer a machine-applicable suggestion when there are subpatterns from macro expansion. Co-Authored-By: Guillaume Boisseau <Nadrieril@users.noreply.github.com>
2024-05-12Rollup merge of #125030 - saethlin:ui-test-false-positives, r=compiler-errorsGuillaume Gomez-38/+13
Fix some minor issues from the ui-test auto-porting I'm not sure if these count as false positives, because well, starting a comment with `// incremental` was probably a valid compiletest directive. But anyway, these tests directives became clearly goofy and now with the better syntax we can straighten things out. r? jieyouxu
2024-05-12Rollup merge of #125022 - ↵Guillaume Gomez-5/+55
GuillaumeGomez:migrate-rustdoc-scrape-examples-ordering, r=jieyouxu Migrate rustdoc scrape examples ordering Part of https://github.com/rust-lang/rust/issues/121876. This one adds a lot of utility methods/functions. To prevent having too much changes at once, I didn't make the existing rmake tests use these yet but I'll send a follow-up so they all use it. r? `@jieyouxu`
2024-05-12Migrate `rustdoc-scrape-examples-ordering` to `rmake`Guillaume Gomez-5/+55
2024-05-12Auto merge of #125012 - RalfJung:format-error, r=Mark-Simulacrum,workingjubileebors-11/+18
io::Write::write_fmt: panic if the formatter fails when the stream does not fail Follow-up to https://github.com/rust-lang/rust/pull/124954
2024-05-12Auto merge of #119427 - dtolnay:maccall, r=compiler-errorsbors-24/+332
Fix, document, and test parser and pretty-printer edge cases related to braced macro calls _Review note: this is a deceptively small PR because it comes with 145 lines of docs and 196 lines of tests, and only 25 lines of compiler code changed. However, I recommend reviewing it 1 commit at a time because much of the effect of the code changes is non-local i.e. affecting code that is not visible in the final state of the PR. I have paid attention that reviewing the PR one commit at a time is as easy as I can make it. All of the code you need to know about is touched in those commits, even if some of those changes disappear by the end of the stack._ This is a follow-up to https://github.com/rust-lang/rust/pull/119105. One case that is not relevant to `-Zunpretty=expanded`, but which came up as I'm porting #119105 and #118726 into `syn`'s printer and `prettyplease`'s printer where it **is** relevant, and is also relevant to rustc's `stringify!`, is statement boundaries in the vicinity of braced macro calls. Rustc's AST pretty-printer produces invalid syntax for statements that begin with a braced macro call: ```rust macro_rules! stringify_item { ($i:item) => { stringify!($i) }; } macro_rules! repro { ($e:expr) => { stringify_item!(fn main() { $e + 1; }) }; } fn main() { println!("{}", repro!(m! {})); } ``` **Before this PR:** output is not valid Rust syntax. ```console fn main() { m! {} + 1; } ``` ```console error: leading `+` is not supported --> <anon>:1:19 | 1 | fn main() { m! {} + 1; } | ^ unexpected `+` | help: try removing the `+` | 1 - fn main() { m! {} + 1; } 1 + fn main() { m! {} 1; } | ``` **After this PR:** valid syntax. ```console fn main() { (m! {}) + 1; } ```
2024-05-11Fix redundant parens around braced macro call in match armsDavid Tolnay-1/+1
2024-05-11Fix some minor issues from the ui-test auto-portingBen Kimock-38/+13
2024-05-11Remove MacCall special case from recovery after missing 'if' after 'else'David Tolnay-6/+4
The change to the test is a little goofy because the compiler was guessing "correctly" before that `falsy! {}` is the condition as opposed to the else body. But I believe this change is fundamentally correct. Braced macro invocations in statement position are most often item-like (`thread_local! {...}`) as opposed to parenthesized macro invocations which are condition-like (`cfg!(...)`).
2024-05-11Add macro calls to else-no-if parser testDavid Tolnay-5/+83
2024-05-11Add parser tests for statement boundary insertionDavid Tolnay-0/+104
2024-05-11Add test of unused_parens lint involving macro callsDavid Tolnay-19/+117
2024-05-11Fix pretty printer statement boundaries after braced macro callDavid Tolnay-2/+2
2024-05-11Add ExprKind::MacCall statement boundary testsDavid Tolnay-0/+30
2024-05-11Auto merge of #125028 - matthiaskrgr:rollup-3qk782d, r=matthiaskrgrbors-175/+109
Rollup of 6 pull requests Successful merges: - #124096 (Clean up users of rust_dbg_call) - #124829 (Enable profiler for armv7-unknown-linux-gnueabihf.) - #124939 (Always hide private fields in aliased type) - #124963 (Migrate `run-make/rustdoc-shared-flags` to rmake) - #124981 (Relax allocator requirements on some Rc/Arc APIs.) - #125008 (Add test for #122775) r? `@ghost` `@rustbot` modify labels: rollup
2024-05-11Rollup merge of #125008 - Dirbaio:test-issue-122775, r=compiler-errorsMatthias Krüger-0/+17
Add test for #122775 Closes #122775
2024-05-11Rollup merge of #124963 - GuillaumeGomez:migrate-rustdoc-shared-flags, ↵Matthias Krüger-18/+14
r=jieyouxu Migrate `run-make/rustdoc-shared-flags` to rmake Part of https://github.com/rust-lang/rust/issues/121876. r? ```@jieyouxu```
2024-05-11Rollup merge of #124939 - Urgau:hide-private-fields-aliased-type, ↵Matthias Krüger-0/+22
r=GuillaumeGomez Always hide private fields in aliased type This PR adds a new rustdoc pass that unconditionally always strips all private fields in aliased type, since showing them, even with `--document-private-items`, is confusing, unhelpful, and run backwards to the "Aliased type" feature, which is to show the type as it would be seen by the user. r? ```@GuillaumeGomez``` Fixes #124938 Fixes #123860
2024-05-11Rollup merge of #124096 - saethlin:rust-dbg-call, r=NilstriebMatthias Krüger-157/+56
Clean up users of rust_dbg_call `rust_dbg_call` is a C test helper that until this PR was declared in C with `void*` arguments and used in Rust _mostly_ with `libc::uintptr_t` arguments. Nearly every user just wants to pass integers around, so I've changed all users to `uint64_t` or `u64`. The single test that actually used the pointer-ness of the argument is a test for ensuring that Rust can make extern calls outside of tasks. Rust hasn't had tasks for quite a few years now, so I'm deleting that test under the same logic as the test deleted in https://github.com/rust-lang/rust/pull/124073
2024-05-11Auto merge of #124988 - compiler-errors:name-span, r=lcnrbors-6/+41
Consolidate obligation cause codes for where clauses Removes some unncessary redundancy between `SpannedWhereClause`/`WhereClause` r? lcnr
2024-05-11Auto merge of #125007 - klensy:filecheckty, r=Mark-Simulacrumbors-8/+8
fix few typos in filecheck annotations Inspired by https://github.com/rust-lang/rust/pull/123886#discussion_r1597358732 `rg -g '*.rs' '//\s+?[\w-]+(-[\w]+):' -r '$1' -oNI | sort -u` Should https://llvm.org/docs/CommandGuide/FileCheck.html#cmdoption-FileCheck-ignore-case be used for case-insensetive match for filecheck?
2024-05-11io::Write::write_fmt: panic if the formatter fails when the stream does not failRalf Jung-11/+18
2024-05-11Auto merge of #125010 - matthiaskrgr:rollup-270pck3, r=matthiaskrgrbors-0/+7
Rollup of 5 pull requests Successful merges: - #124928 (Stabilize `byte_slice_trim_ascii` for `&[u8]`/`&str`) - #124954 (Document proper usage of `fmt::Error` and `fmt()`'s `Result`.) - #124969 (check if `x test tests` missing any test directory) - #124978 (Handle Deref expressions in invalid_reference_casting) - #125005 (Miri subtree update) r? `@ghost` `@rustbot` modify labels: rollup
2024-05-11Rollup merge of #124978 - saethlin:ref-casting_derefs, r=Urgau,NilstriebMatthias Krüger-0/+7
Handle Deref expressions in invalid_reference_casting Similar to https://github.com/rust-lang/rust/pull/124908 See https://github.com/rust-lang/rust/issues/124951 for context; this PR fixes the last of the known false postiive cases with this lint that we encounter in Crater.
2024-05-11Always hide private fields in aliased typeUrgau-0/+22
2024-05-11Add test for #122775Dario Nieuwenhuis-0/+17
2024-05-11Migrate `run-make/rustdoc-shared-flags` to rmakeGuillaume Gomez-18/+14
2024-05-11Auto merge of #124567 - Jules-Bertholet:and-eats-andmut, r=Nadrierilbors-73/+201
Match ergonomics 2024: let `&` patterns eat `&mut` r? `@Nadrieril` cc https://github.com/rust-lang/rust/issues/123076 `@rustbot` label A-edition-2024 A-patterns
2024-05-11fix few typo in filecheck annotationsklensy-8/+8
2024-05-11Consolidate obligation cause codes for where clausesMichael Goulet-6/+41
2024-05-11Rollup merge of #124930 - compiler-errors:consume-arg, r=petrochenkov许杰友 Jieyou Xu (Joe)-0/+20
Make sure we consume a generic arg when checking mistyped turbofish When recovering un-turbofish-ed args in expr position (e.g. `let x = a<T, U>();` in `check_mistyped_turbofish_with_multiple_type_params`, we used `parse_seq_to_before_end` to parse the fake generic args; however, it used `parse_generic_arg` which *optionally* parses a generic arg. If it doesn't end up parsing an arg, it returns `Ok(None)` and consumes no tokens. If we don't find a delimiter after this (`,`), we try parsing *another* element. In this case, we just infinitely loop looking for a subsequent element. We can fix this by making sure that we either parse a generic arg or error in `parse_seq_to_before_end`'s callback. Fixes #124897
2024-05-11Rollup merge of #124318 - bvanjoi:fix-123911, r=petrochenkov许杰友 Jieyou Xu (Joe)-41/+58
ignore generics args in attribute paths Fixes #97006 Fixes #123911 Fixes #123912 This patch ensures that we no longer have to handle invalid generic arguments in attribute paths. r? `@petrochenkov`
2024-05-10Auto merge of #123886 - scottmcm:more-rvalue-operands, r=matthewjasperbors-0/+123
Avoid `alloca`s in codegen for simple `mir::Aggregate` statements The core idea here is to remove the abstraction penalty of simple newtypes in codegen. Even something simple like constructing a ```rust #[repr(transparent)] struct Foo(u32); ``` forces an `alloca` to be generated in nightly right now. Certainly LLVM can optimize that away, but it would be nice if it didn't have to. Quick example: ```rust #[repr(transparent)] pub struct Transparent32(u32); #[no_mangle] pub fn make_transparent(x: u32) -> Transparent32 { let a = Transparent32(x); a } ``` on nightly we produce <https://rust.godbolt.org/z/zcvoM79ae> ```llvm define noundef i32 `@make_transparent(i32` noundef %x) unnamed_addr #0 { %a = alloca i32, align 4 store i32 %x, ptr %a, align 4 %0 = load i32, ptr %a, align 4, !noundef !3 ret i32 %0 } ``` but after this PR we produce ```llvm define noundef i32 `@make_transparent(i32` noundef %x) unnamed_addr #0 { start: ret i32 %x } ``` (even before the optimizer runs).
2024-05-10Comments and fixesJules Bertholet-42/+108
2024-05-10Fix spans when macros are involvedJules Bertholet-4/+3
2024-05-10Various fixes:Jules Bertholet-24/+41
- Only show error when move-check would not be triggered - Add structured suggestion
2024-05-10Match ergonomics 2024: let `&` patterns eat `&mut`Jules Bertholet-69/+115
2024-05-10Handle Deref expressions in invalid_reference_castingBen Kimock-0/+7
2024-05-11ignore generics args in attribute pathsbohan-41/+58
2024-05-10Rollup merge of #124888 - GuillaumeGomez:migrate-rustdoc-output-path, r=jieyouxuMatthias Krüger-4/+9
Migrate `run-make/rustdoc-output-path` to rmake Part of https://github.com/rust-lang/rust/issues/121876. r? ``@jieyouxu``
2024-05-10Rollup merge of #124797 - beetrees:primitive-float, r=davidtwcoMatthias Krüger-1/+3
Refactor float `Primitive`s to a separate `Float` type Now there are 4 of them, it makes sense to refactor `F16`, `F32`, `F64` and `F128` out of `Primitive` and into a separate `Float` type (like integers already are). This allows patterns like `F16 | F32 | F64 | F128` to be simplified into `Float(_)`, and is consistent with `ty::FloatTy`. As a side effect, this PR also makes the `Ty::primitive_size` method work with `f16` and `f128`. Tracking issue: #116909 `@rustbot` label +F-f16_and_f128
2024-05-10Rollup merge of #124778 - fmease:fix-diag-msg-parse-meta-item, r=nnethercoteMatthias Krüger-37/+58
Fix parse error message for meta items Addresses https://github.com/rust-lang/rust/issues/122796#issuecomment-2010803906, cc [``@]Thomasdezeeuw.`` For attrs inside of a macro like `#[doc(alias = $ident)]` or `#[cfg(feature = $ident)]` where `$ident` is a macro metavariable of fragment kind `ident`, we used to say the following when expanded (with `$ident` ⟼ `ident`): ``` error: expected unsuffixed literal or identifier, found `ident` --> weird.rs:6:19 | 6 | #[cfg(feature = $ident)] | ^^^^^^ ... 11 | m!(id); | ------ in this macro invocation | = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) ``` This was incorrect and caused confusion, justifiably so (see #122796). In this position, we only accept/expect *unsuffixed literals* which consist of numeric & string literals as well as the boolean literals / the keywords / the reserved identifiers `false` & `true` **but not** arbitrary identifiers. Furthermore, we used to suggest garbage when encountering unexpected non-identifier tokens: ``` error: expected unsuffixed literal, found `-` --> weird.rs:16:17 | 16 | #[cfg(feature = -1)] | ^ | help: surround the identifier with quotation marks to parse it as a string | 16 | #[cfg(feature =" "-1)] | + + ``` Now we no longer do.
2024-05-10Auto merge of #124774 - the8472:subnanosecond-benches, r=jhprattbors-1/+1
Display walltime benchmarks with subnanosecond precision With modern CPUs running at more than one cycle per nanosecond the current precision is insufficient to resolve differences worth several cycles per iteration. Granted, walltime benchmarks often are noisy but occasionally, especially when no allocations are involved, the difference really is just a few cycles. example results when benchmarking 1-4 serialized ADD instructions and an empty bench body ``` running 4 tests test add ... bench: 0.24 ns/iter (+/- 0.00) test add2 ... bench: 0.48 ns/iter (+/- 0.01) test add3 ... bench: 0.72 ns/iter (+/- 0.01) test add4 ... bench: 0.96 ns/iter (+/- 0.01) test empty ... bench: 0.24 ns/iter (+/- 0.00) ```