about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2025-02-19Rollup merge of #137251 - Zalathar:holes-visitor, r=jieyouxuMatthias Krüger-17/+88
coverage: Get hole spans from nested items without fully visiting them This is a small simplification to the code that collects the spans of nested items within a function, so that those spans can be treated as “holes” to be avoided by the current function's coverage mappings. The old code was using `nested_filter::All` to ensure that the visitor would see nested items. But we don't need the actual items themselves; we just need their spans, which we can obtain via a custom implementation of `visit_nested_item`. This avoids the more expansive queries required by `nested_filter::All`.
2025-02-19Rollup merge of #137232 - estebank:from-residual-note, r=petrochenkovMatthias Krüger-6/+4
Don't mention `FromResidual` on bad `?` Unless `try_trait_v2` is enabled, don't mention that `FromResidual` isn't implemented for a specific type when the implicit `From` conversion of a `?` fails. For the end user on stable, `?` might as well be a compiler intrinsic, so we remove that note to avoid further confusion and allowing other parts of the error to be more prominent. ``` error[E0277]: `?` couldn't convert the error to `u8` --> $DIR/bad-interconversion.rs:4:20 | LL | fn result_to_result() -> Result<u64, u8> { | --------------- expected `u8` because of this LL | Ok(Err(123_i32)?) | ------------^ the trait `From<i32>` is not implemented for `u8` | | | this can't be annotated with `?` because it has type `Result<_, i32>` | = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait = help: the following other types implement trait `From<T>`: `u8` implements `From<Char>` `u8` implements `From<bool>` ```
2025-02-19Rollup merge of #137094 - RalfJung:softfloat-means-no-simd, r=tgross35Matthias Krüger-15/+49
x86_win64 ABI: do not use xmm0 with softfloat ABI This adjusts https://github.com/rust-lang/rust/pull/134290 to not apply the new logic to targets marked as "softfloat". That fixes most instances of the issue brought up [here](https://github.com/rust-lang/rust/issues/116558#issuecomment-2661027437). r? `@tgross35`
2025-02-19Tweak "expected ident" parse error to avoid talking about doc commentsEsteban Küber-0/+29
When encountering a doc comment without an identifier after, we'd unconditionally state "this doc comment doesn't document anything", swallowing the *actual* error which is that the thing *after* the doc comment wasn't expected. Added a check that the found token is something that "conceptually" closes the previous item before emitting that error, otherwise just complain about the missing identifier. In both of the following cases, the syntax error follows a doc comment: ``` error: expected identifier, found keyword `Self` --> $DIR/doc-before-bad-variant.rs:4:5 | LL | enum TestEnum { | -------- while parsing this enum ... LL | Self, | ^^^^ expected identifier, found keyword | = help: enum variants can be `Variant`, `Variant = <integer>`, `Variant(Type, ..., TypeN)` or `Variant { fields: Types }` ``` ``` error: expected identifier, found `<` --> $DIR/doc-before-syntax-error.rs:2:1 | LL | <> | ^ expected identifier ``` Fix #71982.
2025-02-19Also use gep inbounds nuw for index projectionsNikita Popov-2/+2
2025-02-19Emit getelementptr inbounds nuw for pointer::add()Nikita Popov-5/+5
2025-02-19don't get trapped inside of expansions when trimming labelsdianne-6/+3
2025-02-19add a failing testdianne-1/+34
2025-02-19Auto merge of #136539 - matthewjasper:late-normalize-errors, r=compiler-errorsbors-61/+154
Emit dropck normalization errors in borrowck Borrowck generally assumes that any queries it runs for type checking will succeed, thinking that HIR typeck will have errored first if there was a problem. However as of #98641, dropck isn't run on HIR, so there's no direct guarantee that it doesn't error. While a type being well-formed might be expected to ensure that its fields are well-formed, this is not the case for types containing a type projection: ```rust pub trait AuthUser { type Id; } pub trait AuthnBackend { type User: AuthUser; } pub struct AuthSession<Backend: AuthnBackend> { data: Option<<<Backend as AuthnBackend>::User as AuthUser>::Id>, } pub trait Authz: Sized { type AuthnBackend: AuthnBackend<User = Self>; } pub fn run_query<User: Authz>(auth: AuthSession<User::AuthnBackend>) {} // ^ No User: AuthUser bound is required or inferred. ``` While improvements to trait solving might fix this in the future, for now we go for a pragmatic solution of emitting an error from borrowck (by rerunning dropck outside of a query) and making drop elaboration check if an error has been emitted previously before panicking for a failed normalization. Closes #103899 Closes #135039 r? `@compiler-errors` (feel free to re-assign)
2025-02-19x86_win64 ABI: do not use xmm0 with softfloat ABIRalf Jung-15/+49
2025-02-19Auto merge of #137248 - matthiaskrgr:rollup-s18zjau, r=matthiaskrgrbors-71/+87
Rollup of 9 pull requests Successful merges: - #136936 (Use 'yes' instead of 'while-echo' in tests/ui/process/process-sigpipe.rs except 'nto') - #137026 (Stabilize (and const-stabilize) `integer_sign_cast`) - #137059 (fix: Alloc new errorcode E0803 for E0495) - #137177 (Update `minifier-rs` version to `0.3.5`) - #137210 (compiler: Stop reexporting stuff in cg_llvm::abi) - #137213 (Remove `rustc_middle::mir::tcx` module.) - #137216 (eval_outlives: bail out early if both regions are in the same SCC) - #137228 (Fix typo in hidden internal docs of `TrustedRandomAccess`) - #137242 (Add reference annotations for the `do_not_recommend` attribute) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-19Restrict bevy hackMichael Goulet-0/+2
2025-02-19coverage: Add some more cases to `tests/coverage/holes.rs`Zalathar-17/+88
2025-02-18"classic2021" ruleset: experimentally add fallback-to-outer (eat both)dianne-116/+54
My reasoning: the ruleset implemented by the same feature gate in Edition 2024 always tries to eat the inherited reference first. For consistency, it makes sense to me to say across all editions that users should consider the inherited reference's mutability when wondering if a `&mut` pattern will type.
2025-02-18add mixed-edition testsdianne-0/+486
2025-02-18"structural2021" ruleset: add fallback-to-outer (eat both) deref ruledianne-173/+114
2025-02-18"classic2021" and "structural2021" rulesets: add eat-inherited-ref-alone ↵dianne-514/+163
deref rules
2025-02-18remove old edition-2021-specific testsdianne-187/+0
These are superseded by the old-edition revisions on the shared tests.
2025-02-18add test revisions for old-edition behavior of feature gatesdianne-322/+1783
This also adds `#[cfg]` attributes to tests for bindings' types, to make it visually clearer which revisions type successfully.
2025-02-19Auto merge of #135408 - RalfJung:x86-sse2, r=workingjubileebors-104/+188
x86: use SSE2 to pass float and SIMD types This builds on the new X86Sse2 ABI landed in https://github.com/rust-lang/rust/pull/137037 to actually make it a separate ABI from the default x86 ABI, and use SSE2 registers. Specifically, we use it in two ways: to return `f64` values in a register rather than by-ptr, and to pass vectors of size up to 128bit in a register (or, well, whatever LLVM does when passing `<4 x float>` by-val, I don't actually know if this ends up in a register). Cc `@workingjubilee` Fixes #133611 try-job: aarch64-apple try-job: aarch64-gnu try-job: aarch64-gnu-debug try-job: test-various try-job: x86_64-gnu-nopt try-job: dist-i586-gnu-i586-i686-musl try-job: x86_64-msvc-1
2025-02-19Add custom sort for link in rustdocyukang-0/+33
2025-02-19Rollup merge of #137242 - ehuss:reference-do_not_recommend, r=compiler-errorsMatthias Krüger-50/+59
Add reference annotations for the `do_not_recommend` attribute This adds reference rule identifiers for the tests of the `diagnostic::do_not_recommend` attribute.
2025-02-19Rollup merge of #137059 - xizheyin:issue-136827, r=davidtwcoMatthias Krüger-16/+16
fix: Alloc new errorcode E0803 for E0495 As discussion in #136827, I alloc a new errorcode.
2025-02-19Rollup merge of #136936 - xingxue-ibm:sigpipe-test, r=workingjubileeMatthias Krüger-5/+12
Use 'yes' instead of 'while-echo' in tests/ui/process/process-sigpipe.rs except 'nto' The `sh` of AIX prints a message about a broken pipe when using the `while-echo` command. It works as expected when using the `yes` command instead. `yes` was originally used in this test but was later replaced with `while-echo` because QNX Neutrino does not have `yes` ([Replace yes command by while-echo in test tests/ui/process/process-sigpipe.rs](https://github.com/rust-lang/rust/pull/109379)). This PR updates the test to use `while-echo` for QNX Neutrino while reverting to `yes` for other platforms.
2025-02-18Pre-commit unpretty HIR testUrgau-0/+51
2025-02-18Update `.` -> `::` tests for new diff suggestion format.Zachary S-46/+64
2025-02-18Lint `#[must_use]` attributes applied to methods in trait implsSamuel Tardieu-15/+26
The `#[must_use]` attribute has no effect when applied to methods in trait implementations. This case was not linted before.
2025-02-18When giving a suggestion to use :: instead of . where the rhs is a macro ↵Zachary S-3/+136
giving a type, make it also work when the rhs is a type alias, not just a struct.
2025-02-18Suggest using :: instead of . for enums in some cases.Zachary S-0/+283
Suggest replacing `.` with `::` when encountering "expected value, found enum": - in a method-call expression and the method has the same name as a tuple variant - in a field-access expression and the field has the same name as a unit or tuple variant
2025-02-18Suggest using :: instead of . in more cases.Zachary S-9/+62
When `Foo.field` or `Foo.method()` exprs are encountered, suggest `Foo::field` or `Foo::method()` when Foo is a type alias, not just a struct, trait, or module. Also rename test for this suggestion from issue-22692.rs to something more meaningful.
2025-02-18Add reference annotations for the `do_not_recommend` attributeEric Huss-50/+59
2025-02-18Rollup merge of #137218 - lukas-code:layout_of_cleanup, r=compiler-errorsMatthias Krüger-1/+81
misc `layout_of` cleanup See individual commits for details. r? `@oli-obk` but feel free to reassign
2025-02-18Rollup merge of #137203 - nnethercote:improve-MIR-modification, ↵Matthias Krüger-0/+8
r=compiler-errors Improve MIR modification A few commits that simplify code that manipulates MIR bodies. r? `@tmiasko`
2025-02-18Rollup merge of #137161 - dianne:pat-migration-bookkeeping-for-macros, ↵Matthias Krüger-1/+36
r=Nadrieril Pattern Migration 2024: fix incorrect messages/suggestions when errors arise in macro expansions See the diff between the two commits for how this affected the error message and suggestion. In order to decide how to format those, the pattern migration diagnostic keeps track of which parts of the user's pattern cause problems in Edition 2024. However, it neglected to do some of this bookkeeping when pointing to macro expansion sites. This fixes that.
2025-02-18Rollup merge of #137000 - compiler-errors:deeply-normalize-item-bounds, r=lcnrMatthias Krüger-25/+65
Deeply normalize item bounds in new solver Built on #136863. Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/142. Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/151. cc https://github.com/rust-lang/trait-system-refactor-initiative/issues/116 First commit reworks candidate preference for projection bounds to prefer param-env projection clauses even if the corresponding trait ref doesn't come from the param-env. Second commit adjusts the associated type item bounds check to deeply normalize in the new solver. This causes some test fallout which I will point out. r? lcnr
2025-02-18Rollup merge of #135711 - estebank:issue-135649, r=davidtwcoMatthias Krüger-0/+29
Do not ICE on default_field_value const with lifetimes `#![feature(default_field_values)]` uses a `const` body that should be treated as inline `const`s, but is actually being detected otherwise. This is similar to the situation in #78174, so we take the same solution: we check if the const actually comes from a field, and if it does, we use that logic to get the appropriate lifetimes and not ICE during borrowck. Fix #135649.
2025-02-18Don't mention `FromResidual` on bad `?`Esteban Küber-6/+4
Unless `try_trait_v2` is enabled, don't mention that `FromResidual` isn't implemented for a specific type when the implicit `From` conversion of a `?` fails. For the end user on stable, `?` might as well be a compiler intrinsic, so we remove that note to avoid further confusion and allowing other parts of the error to be more prominent. ``` error[E0277]: `?` couldn't convert the error to `u8` --> $DIR/bad-interconversion.rs:4:20 | LL | fn result_to_result() -> Result<u64, u8> { | --------------- expected `u8` because of this LL | Ok(Err(123_i32)?) | ------------^ the trait `From<i32>` is not implemented for `u8` | | | this can't be annotated with `?` because it has type `Result<_, i32>` | = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait = help: the following other types implement trait `From<T>`: `u8` implements `From<Char>` `u8` implements `From<bool>` ```
2025-02-18Use `yes` except target_os = "nto".Xing Xue-5/+12
2025-02-18x86-sse2 ABI: use SSE registers for floats and SIMDRalf Jung-104/+188
2025-02-18clean up layout error diagnosticsLukas Markeffsky-2/+2
- group the fluent slugs together - reword (internal-only) "too generic" error to be more in line with the other errors
2025-02-18document and test all `LayoutError` variantsLukas Markeffsky-1/+81
2025-02-18Auto merge of #133852 - x17jiri:cold_path, r=saethlinbors-0/+123
improve cold_path() #120370 added a new instrinsic `cold_path()` and used it to fix `likely` and `unlikely` However, in order to limit scope, the information about cold code paths is only used in 2-target switch instructions. This is sufficient for `likely` and `unlikely`, but limits usefulness of `cold_path` for idiomatic rust. For example, code like this: ``` if let Some(x) = y { ... } ``` may generate 3-target switch: ``` switch y.discriminator: 0 => true branch 1 = > false branch _ => unreachable ``` and therefore marking a branch as cold will have no effect. This PR improves `cold_path()` to work with arbitrary switch instructions. Note that for 2-target switches, we can use `llvm.expect`, but for multiple targets we need to manually emit branch weights. I checked Clang and it also emits weights in this situation. The Clang's weight calculation is more complex that this PR, which I believe is mainly because `switch` in `C/C++` can have multiple cases going to the same target.
2025-02-18Use `MirPatch` in `EnumSizeOpt`.Nicholas Nethercote-0/+8
Instead of `expand_statements`. This makes the code shorter and consistent with other MIR transform passes. The tests require updating because there is a slight change in MIR output: - the old code replaced the original statement with twelve new statements. - the new code inserts converts the original statement to a `nop` and then insert twelve new statements in front of it. I.e. we now end up with an extra `nop`, which doesn't matter at all.
2025-02-17Update some comparison tests now that they pass in LLVM20Scott McMurray-21/+78
2025-02-17Deeply normalize associated type bounds before proving themMichael Goulet-25/+65
2025-02-17suggest swapping equality on e0277makai410-0/+35
2025-02-17Update tests for dropck normalization errorsMatthew Jasper-61/+154
Takes crash tests from #135039, #103899, #91985 and #105299 and turns them into ui tests
2025-02-17Auto merge of #137164 - matthiaskrgr:rollup-dj5826k, r=matthiaskrgrbors-167/+167
Rollup of 7 pull requests Successful merges: - #137095 (Replace some u64 hashes with Hash64) - #137100 (HIR analysis: Remove unnecessary abstraction over list of clauses) - #137105 (Restrict DerefPure for Cow<T> impl to T = impl Clone, [impl Clone], str.) - #137120 (Enable `relative-path-include-bytes-132203` rustdoc-ui test on Windows) - #137125 (Re-add missing empty lines in the releases notes) - #137145 (use add-core-stubs / minicore for a few more tests) - #137149 (Remove SSE ABI from i586-pc-windows-msvc) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-17improve cold_path()Jiri Bobek-0/+123
2025-02-17Rollup merge of #137145 - RalfJung:minicore, r=jieyouxuMatthias Krüger-164/+154
use add-core-stubs / minicore for a few more tests See https://github.com/rust-lang/rust/issues/131485 for context. These are some tests I worked on in the past so I figured I'd see if `minicore` works for them. :)