about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2024-05-13Apply code review suggestionsEric Holk-4/+10
- use feature_err to report unstable expr_2021 - Update downlevel expr_2021 diagnostics Co-authored-by: León Orell Valerian Liehr <me@fmease.dev>
2024-05-13Macros: match const { ... } with expr nonterminal in edition 2024Vincenzo Palazzo-0/+72
Co-authored-by: Eric Holk <eric@theincredibleholk.org> Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2024-05-13expr_2021 should be allowed on edition 2021 and laterEric Holk-1/+1
2024-05-13Add test that expr_2021 only works on 2024 editionEric Holk-0/+38
Co-authored-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2024-05-13Add expr_2021 nonterminal and feature flagEric Holk-0/+19
This commit adds a new nonterminal `expr_2021` in macro patterns, and `expr_fragment_specifier_2024` feature flag. For now, `expr` and `expr_2021` are treated the same, but in future PRs we will update `expr` to match to new grammar. Co-authored-by: Vincezo Palazzo <vincenzopalazzodev@gmail.com>
2024-05-13Auto merge of #125024 - Oneirical:master, r=jieyouxubors-22/+45
Rewrite 3 very similar `run-make` alloc tests to rmake Part of #121876 #121918 attempted to port these 3 tests 2 months ago. However, since then, the structure of `run-make-support` has changed a bit and new helper functions were added. Since there has been no activity on the PR, they are good low-hanging fruit to knock down, using the new functions of the current library. There is also the removal of a useless import on a very similar test.
2024-05-13Auto merge of #124999 - scottmcm:unify-aggregate, r=nnethercotebors-1/+1
Unify `Rvalue::Aggregate` paths in cg_ssa In #123840 and #123886 I added two different codepaths for `Rvalue::Aggregate` in `cg_ssa`. This merges them into one, since raw pointers are also immediates that can be built from the immediates of their "fields".
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-11Unify `Rvalue::Aggregate` paths in cg_ssaScott McMurray-1/+1
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-11make tidy happyOneirical-3/+6
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-11rewrite alloc tests & remove importOneirical-22/+42
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).