about summary refs log tree commit diff
path: root/tests/ui
AgeCommit message (Collapse)AuthorLines
2024-11-28Rollup merge of #133560 - clubby789:mut-mut-space, r=jieyouxuGuillaume Gomez-12/+28
Trim extra space in 'repeated `mut`' diagnostic Trim an extra space when removing repeated `mut`. Also an extra test for even more repeated `mut`s
2024-11-28Rollup merge of #133487 - pitaj:reserve-guarded-strings, r=fee1-deadGuillaume Gomez-97/+97
fix confusing diagnostic for reserved `##` Closes #131615
2024-11-28Rollup merge of #133463 - taiki-e:aarch64-asm-x18, r=AmanieuGuillaume Gomez-2/+2
Fix handling of x18 in AArch64 inline assembly on ohos/trusty or with -Zfixed-x18 Currently AArch64 inline assembly allows using x18 on ohos/trusty or with -Zfixed-x18. https://github.com/rust-lang/rust/blob/7db7489f9bc274cb60c4956bfa56de0185eb1b9b/compiler/rustc_target/src/asm/aarch64.rs#L74-L76 However, x18 is reserved in these environments and should not be allowed in the input/output operands of inline assemblies as it is in Android, Windows, etc.. https://github.com/rust-lang/rust/blob/7db7489f9bc274cb60c4956bfa56de0185eb1b9b/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_ohos.rs#L19 https://github.com/rust-lang/rust/blob/7db7489f9bc274cb60c4956bfa56de0185eb1b9b/compiler/rustc_target/src/spec/targets/aarch64_unknown_trusty.rs#L18 https://github.com/rust-lang/rust/blob/7db7489f9bc274cb60c4956bfa56de0185eb1b9b/compiler/rustc_codegen_llvm/src/llvm_util.rs#L764-L771 (As for ohos, +reserve-x18 is [redundant](https://github.com/llvm/llvm-project/commit/c417b7a695704d5bc3be23f34d1bfa505f5172de#diff-0ddf23e0bf2b28b2d05f842f087d1e6f694e8e06d1765e8d0f10d47fddcdff9c) since https://github.com/rust-lang/rust/commit/7a966b918870485e9b364e77f50c511f8c2cc275 that starting using llvm's ohos targets. So removed it from target-spec.) This fix may potentially break the code for tier 2 target (aarch64-unknown-linux-ohos). (As for others, aarch64-unknown-trusty is tier 3 and -Zfixed-x18 is unstable so breaking them should be fine.) However, in any case, it seems suspicious that the code that is broken by this was sound. r? `@Amanieu` `@rustbot` label O-AArch64 +A-inline-assembly
2024-11-28Rollup merge of #133358 - compiler-errors:pin-coerce, r=eholkGuillaume Gomez-4/+25
Don't type error if we fail to coerce `Pin<T>` because it doesnt contain a ref Fixes https://github.com/rust-lang/rust/issues/133222. Also moves some tests into a directory for better bookkeeping. r? eholk or re-roll
2024-11-28Auto merge of #133561 - GuillaumeGomez:rollup-g4upmv4, r=GuillaumeGomezbors-24/+267
Rollup of 12 pull requests Successful merges: - #129409 (Expand std::os::unix::fs::chown() doc with a warning) - #133320 (Add release notes for Rust 1.83.0) - #133368 (Delay a bug when encountering an impl with unconstrained generics in `codegen_select`) - #133428 (Actually use placeholder regions for trait method late bound regions in `collect_return_position_impl_trait_in_trait_tys`) - #133512 (Add `as_array` and `as_mut_array` conversion methods to slices.) - #133519 (Check `xform_ret_ty` for WF in the new solver to improve method winnowing) - #133520 (Structurally resolve before applying projection in borrowck) - #133534 (extend group-forbid-always-trumps-cli test) - #133537 ([rustdoc] Fix new clippy lints) - #133543 ([AIX] create shim for lgammaf_r) - #133547 (rustc_span: Replace a `HashMap<_, ()>` with `HashSet`) - #133550 (print generated doc paths) r? `@ghost` `@rustbot` modify labels: rollup
2024-11-28Rollup merge of #133534 - RalfJung:cli-lint-flags, r=NadrierilGuillaume Gomez-7/+88
extend group-forbid-always-trumps-cli test Test it not just for a lint group, but also an individual lint, or when mixing the lint and the group. And test both orders in which the flags could be passed.
2024-11-28Rollup merge of #133520 - compiler-errors:structurally-resolve-mir-borrowck, ↵Guillaume Gomez-0/+32
r=lcnr Structurally resolve before applying projection in borrowck As far as I can tell, all other `.normalize` calls in borrowck are noops and can remain that way. This is the only one that actually requires structurally resolving the type. r? lcnr
2024-11-28Rollup merge of #133519 - compiler-errors:xform-ret-wf, r=lcnrGuillaume Gomez-0/+47
Check `xform_ret_ty` for WF in the new solver to improve method winnowing This is a bit interesting. Method probing in the old solver is stronger than the new solver because eagerly normalizing types causes us to check their corresponding trait goals. This is important because we don't end up checking all of the where clauses of a method when method probing; just the where clauses of the impl. i.e., for: ``` impl Foo where WC1, { fn method() where WC2, {} } ``` We only check WC1 and not WC2. This is because at this point in probing the method is instantiated w/ infer vars, and checking the where clauses in WC2 will lead to cycles if we were to check them (at least that's my understanding; I could investigate changing that in general, incl. in the old solver, but I don't have much confidence that it won't lead to really bad overflows.) This PR chooses to emulate the old solver by just checking that the return type is WF. This is theoretically stronger, but I'm not too worried about it. I think we alternatively have several approaches we can take here, though this one seems the simplest. Thoughts? r? lcnr
2024-11-28Rollup merge of #133428 - compiler-errors:rpitit-unsound, r=lcnrGuillaume Gomez-17/+71
Actually use placeholder regions for trait method late bound regions in `collect_return_position_impl_trait_in_trait_tys` So in https://github.com/rust-lang/rust/pull/113182, I introduced a "diagnostics improvement" in the form of 473c88dfb69f95b2e8c5f71ba7f6b7b448d22dc2, which changes which signature we end up instantiating with placeholder regions and which signature we end up instantiating with fresh region vars so that we have placeholders corresponding to the names of the late-bound regions coming from the *impl*. However, this is not sound, since now we're essentially no longer proving that *all* instantiations of the trait method are compatible with an instantiation of the impl method, but vice versa (which is weaker). Let's look at the example `tests/ui/impl-trait/in-trait/do-not-imply-from-trait-impl.rs`: ```rust trait MkStatic { fn mk_static(self) -> &'static str; } impl MkStatic for &'static str { fn mk_static(self) -> &'static str { self } } trait Foo { fn foo<'a: 'static, 'late>(&'late self) -> impl MkStatic; } impl Foo for str { fn foo<'a: 'static>(&'a self) -> impl MkStatic + 'static { self } } fn call_foo<T: Foo + ?Sized>(t: &T) -> &'static str { t.foo().mk_static() } fn main() { let s = call_foo(String::from("hello, world").as_str()); println!("> {s}"); } ``` To collect RPITITs, we were previously instantiating the trait signature with infer vars (`fn(&'?0 str) -> ?1t` where `?1t` is the variable we use to infer the RPITIT) and the impl signature with placeholders (there are no late-bound regions in that signature, so we just have `fn(&'a str) -> Opaque`). Equating the signatures works, since all we do is unify `?1t` with `Opaque` and `'?0` with `'a`. However, conceptually it *shouldn't* hold, since this definition is not valid for *all* instantiations of the trait method but just the one where `'0` (i.e. `'late`) is equal to `'a` :( ## So what This PR effectively reverts 473c88dfb69f95b2e8c5f71ba7f6b7b448d22dc2 to fix the unsoundness. Fixes #133427 Also fixes #133425, which is actually coincidentally another instance of this bug (but not one that is weaponized into UB, just one that causes an ICE in refinement checking).
2024-11-28Rollup merge of #133368 - ↵Guillaume Gomez-0/+29
compiler-errors:codegen-select-unconstrained-params, r=lcnr Delay a bug when encountering an impl with unconstrained generics in `codegen_select` Despite its name, `codegen_select` is what powers `Instance::try_resolve`, which is used in pre-codegen contexts to try to resolve a method where possible. One place that it's used is in the "recursion MIR lint" that detects recursive MIR bodies. If we encounter an impl in `codegen_select` that contains unconstrained generic parameters, we expect that impl to caused an error to be reported; however, there's no temporal guarantee that this error is reported *before* we call `codegen_select`. This is what a delayed bug is *for*, and this PR makes us use a delayed bug rather than asserting something about errors already having been emitted. Fixes #126646
2024-11-28Trim extra space in 'repeated `mut`' diagnosticclubby789-12/+28
2024-11-27Rollup merge of #133521 - compiler-errors:structurally-resolve-cat-proj, r=lcnrMatthias Krüger-0/+20
Structurally resolve before matching on type of projection Another missing structural resolve in closure upvar analysis. I think it's better to place the normalization here rather than trying to guarantee that all types returned by the expr use visitor are structurally normalized, which I don't think we do now. Thoughts? r? lcnr
2024-11-27Rollup merge of #133518 - compiler-errors:structurally-resolve-never, r=lcnrMatthias Krüger-45/+119
Structurally resolve before checking `!` in HIR typeck Some more missing structural resolves in HIR typeck :> r? lcnr
2024-11-27extend group-forbid-always-trumps-cli testRalf Jung-7/+88
2024-11-27Check xform_ret_ty for WF in the new solver to improve method winnowingMichael Goulet-0/+47
2024-11-27Structurally resolve before applying projection in borrowckMichael Goulet-0/+32
2024-11-27Auto merge of #133527 - matthiaskrgr:rollup-kyre1df, r=matthiaskrgrbors-119/+101
Rollup of 6 pull requests Successful merges: - #132979 (use `--exact` on `--skip` to avoid unintended substring matches) - #133248 (CI: split x86_64-msvc-ext job) - #133449 (std: expose `const_io_error!` as `const_error!`) - #133453 (Commit license-metadata.json to git and check it's correct in CI) - #133457 (miri: implement `TlsFree`) - #133493 (do not constrain infer vars in `find_best_leaf_obligation`) r? `@ghost` `@rustbot` modify labels: rollup
2024-11-27Rollup merge of #133493 - lcnr:fulfill-fudge, r=compiler-errorsMatthias Krüger-119/+101
do not constrain infer vars in `find_best_leaf_obligation` This ended up causing an ICE by making the following code path reachable by incorrectly constraining an inference variable while computing the best obligation for a preceding ambiguity. Closes #129444. https://github.com/rust-lang/rust/blob/f2abf827c128120ed7a874d02973947968c158b8/compiler/rustc_trait_selection/src/solve/fulfill.rs#L312-L314 I have to be honest, I don't fully understand how that change removes all the additional diagnostics :3 r? `@compiler-errors`
2024-11-27Auto merge of #133274 - ehuss:macro_rules-edition-from-pm, r=compiler-errorsbors-0/+108
Use edition of `macro_rules` when compiling the macro This changes the edition assigned to a macro_rules macro when it is compiled to use the edition of where the macro came from instead of the local crate's edition. This fixes a problem when a macro_rules macro is created by a proc-macro. Previously that macro would be tagged with the local edition, which would cause problems with using the correct edition behavior inside the macro. For example, the check for unsafe attributes would cause errors in 2024 when using proc-macros from older editions. This is partially related to https://github.com/rust-lang/rust/issues/132906. Unfortunately this is only a half fix for that issue. It fixes the error that happens in 2024, but does not fix the lint firing in 2021. I'm still trying to think of some way to fix that, but I'm running low on ideas.
2024-11-27Bless tests due to extra error reporting due to normalizing types that are ↵Michael Goulet-45/+99
not WF It's okay though b/c these are duplicated diagnostics.
2024-11-27Structurally resolve before matching on type of projectionMichael Goulet-0/+20
2024-11-27Structurally resolve before checking neverMichael Goulet-0/+20
2024-11-26Rollup merge of #133471 - lcnr:uwu-gamer, r=BoxyUwUMichael Goulet-0/+64
gce: fix typing_mode mismatch Fixes #133271 r? `@BoxyUwU`
2024-11-26Rollup merge of #133402 - compiler-errors:drop-and-destruct, r=lcnrMichael Goulet-674/+111
Constify `Drop` and `Destruct` r? `@lcnr` or `@fee1-dead`
2024-11-26Rollup merge of #115293 - cjgillot:no-fuel, r=wesleywiser,DianQKMichael Goulet-76/+0
Remove -Zfuel. I'm not sure this feature is used. I only found 2 references in a google search, both referring to its introduction. Meanwhile, it's a global mutable state, untracked by incremental compilation, so incompatible with it.
2024-11-26Auto merge of #133505 - compiler-errors:rollup-xjp8hdi, r=compiler-errorsbors-537/+85
Rollup of 12 pull requests Successful merges: - #133042 (btree: add `{Entry,VacantEntry}::insert_entry`) - #133070 (Lexer tweaks) - #133136 (Support ranges in `<[T]>::get_many_mut()`) - #133140 (Inline ExprPrecedence::order into Expr::precedence) - #133155 (Yet more `rustc_mir_dataflow` cleanups) - #133282 (Shorten the `MaybeUninit` `Debug` implementation) - #133326 (Remove the `DefinitelyInitializedPlaces` analysis.) - #133362 (No need to re-sort existential preds in relate impl) - #133367 (Simplify array length mismatch error reporting (to not try to turn consts into target usizes)) - #133394 (Bail on more errors in dyn ty lowering) - #133410 (target check_consistency: ensure target feature string makes some basic sense) - #133435 (miri: disable test_downgrade_observe test on macOS) r? `@ghost` `@rustbot` modify labels: rollup
2024-11-26Rollup merge of #133394 - compiler-errors:dyn-more-errors, r=lcnrMichael Goulet-438/+42
Bail on more errors in dyn ty lowering If we have more than one principal trait, or if we have a principal trait with errors in it, then bail with `TyKind::Error` rather than attempting lowering. Lowering a dyn trait with more than one principal just arbitrarily chooses the first one and drops the subsequent ones, and lowering a dyn trait path with errors in it is just kinda useless. This suppresses unnecessary errors which I think is net-good, but also is important to make sure that we don't end up leaking `{type error}` in https://github.com/rust-lang/rust/issues/133388 error messaging :) r? types
2024-11-26Rollup merge of #133367 - compiler-errors:array-len-mismatch, r=BoxyUwUMichael Goulet-20/+43
Simplify array length mismatch error reporting (to not try to turn consts into target usizes) This changes `TypeError::FixedArrayLen` to use `ExpectedFound<ty::Const<'tcx>>` (instead of `ExpectedFound<u64>`), and renames it to `TypeError::ArrayLen`. This allows us to avoid a `try_to_target_usize` call in the type relation, which ICEs when we have a scalar of the wrong bit length (i.e. u8). This also makes `structurally_relate_tys` to always use this type error kind any time we have a const mismatch resulting from relating the array-len part of `[T; N]`. This has the effect of changing the error message we issue for array length mismatches involving non-valtree consts. I actually quite like the change, though, since before: ``` LL | fn test<const N: usize, const M: usize>() -> [u8; M] { | ------- expected `[u8; M]` because of return type LL | [0; N] | ^^^^^^ expected `M`, found `N` | = note: expected array `[u8; M]` found array `[u8; N]` ``` and after, which I think is far less verbose: ``` LL | fn test<const N: usize, const M: usize>() -> [u8; M] { | ------- expected `[u8; M]` because of return type LL | [0; N] | ^^^^^^ expected an array with a size of M, found one with a size of N ``` The only questions I have are: 1. Should we do something about backticks here? Right now we don't backtick either fully evaluated consts like `2`, or rigid consts like `Foo::BAR`.... but maybe we should? It seems kinda verbose to do for numbers -- maybe we could intercept those specifically. 2. I guess we may still run the risk of leaking unevaluated consts into error reporting like `2 + 1`...? r? ``@BoxyUwU`` Fixes #126359 Fixes #131101
2024-11-26Rollup merge of #133326 - nnethercote:rm-DefinitelyInitializedPlaces, r=cjgillotMichael Goulet-79/+0
Remove the `DefinitelyInitializedPlaces` analysis. Its only use is in the `tests/ui/mir-dataflow/def_inits-1.rs` where it is tested via `rustc_peek_definite_init`. Also, it's probably buggy. It's supposed to be the inverse of `MaybeUninitializedPlaces`, and it mostly is, except that `apply_terminator_effect` is a little different, and `apply_switch_int_edge_effects` is missing. Unlike `MaybeUninitializedPlaces`, which is used extensively in borrow checking, any bugs in `DefinitelyInitializedPlaces` are easy to overlook because it is only used in one small test. This commit removes the analysis. It also removes `rustc_peek_definite_init`, `Dual` and `MeetSemiLattice`, all of which are no longer needed. r? ``@cjgillot``
2024-11-26Rollup merge of #133495 - lcnr:env-shadowing-tests, r=compiler-errorsGuillaume Gomez-0/+19
add test for alias-bound shadowing, rename folder r? `@BoxyUwU` `@compiler-errors`
2024-11-26Rollup merge of #133473 - Enselic:cow, r=nnethercoteGuillaume Gomez-0/+11
tests: Add regression test for recursive enum with Cow and Clone I could not find any existing test. `git grep "(Cow<'[^>]\+\["` gave no hits before this tests. Closes #100347
2024-11-26Rollup merge of #133470 - jieyouxu:ugly, r=compiler-errorsGuillaume Gomez-662/+23
Cleanup: delete `//@ pretty-expanded` directive This PR removes the `//@ pretty-expanded` directive support in compiletest and removes its usage inside ui tests because it does not actually do anything, and its existence is itself misleading. This PR is split into two commits: 1. The first commit just drops `pretty-expanded` directive support in compiletest. 2. The second commit is created by `sd '//@ pretty-expanded.*\n' '' tests/ui/**/*.rs`[^1], reblessing, and slightly adjusting some leading whitespace in a few tests. We can tell this is fully removed because compiletest doesn't complain about unknown directive when running the `ui` test suite. cc #23616 ### History Originally, there was some effort to introduce more test coverage for `-Z unpretty=expanded` (in 2015 this was called `--pretty=expanded`). In [Make it an error to not declare used features #23598][pr-23598], there was a flip from `//@ no-pretty-expanded` (opt-out of `-Z unpretty=expanded` test) to `//@ pretty-expanded` (opt-in to `-Z unpretty=expanded` test). This was needed because back then the dedicated `tests/pretty` ("pretty") test suite did not existed, and the pretty tests were grouped together under `run-pass` tests (I believe the `ui` test suite didn't exist back then either). Unfortunately, in this process the replacement `//@ pretty-expanded` directives contained a `FIXME #23616` linking to [There are very few tests for `-Z unpretty` expansion #23616][issue-23616]. But this was arguably backwards and somewhat misleading, as noted in [#23616](https://github.com/rust-lang/rust/issues/23616#issuecomment-484999901): The attribute is off by default and things just work if you don't test it, people have not been adding the `pretty-expanded` annotation to new tests even if it would work. Which basically renders this useless. ### Current status As of Nov 2024, we have a dedicated `pretty` test suite, and some time over the years the split between `run-pass` into `ui` and `pretty` test suites caused all the `//@ pretty-expanded` in `ui` tests to do absolutely nothing: the compiletest logic for `pretty-expanded` only triggers in the *pretty* test suite, but none of the pretty tests use it. Oops. Nobody remembers this, nobody uses this, it's misleading in ui tests. Let's get rid of this directive altogether. [pr-23598]: https://github.com/rust-lang/rust/pull/23598 [issue-23616]: https://github.com/rust-lang/rust/issues/23616 ### Follow-ups - [x] Yeet this directive from rustc-dev-guide docs. https://github.com/rust-lang/rustc-dev-guide/pull/2147 [^1]: https://github.com/chmln/sd r? compiler
2024-11-26Rollup merge of #133467 - Enselic:recurse-tests, r=lcnrGuillaume Gomez-0/+74
tests: Add recursive associated type bound regression tests Add regression tests for https://github.com/rust-lang/rust/issues/129541 as requested in https://github.com/rust-lang/rust/issues/129541#issuecomment-2498514488. Closes #129541 r? ``@lcnr``
2024-11-26Rollup merge of #133430 - compiler-errors:param-mismatch, r=WaffleLapkinGuillaume Gomez-14/+45
Tweak parameter mismatch explanation to not say `{unknown}` * Tweak parameter mismatch explanation not to call parameters with no identifier `{unknown}` * Say "both" when there are two parameters * Backtick a type parameter name for consistency
2024-11-26add test for alias-bound shadowing, rename folderlcnr-0/+19
2024-11-26update crasheslcnr-0/+89
2024-11-26Remove extra tests.Camille GILLOT-11/+0
2024-11-26Remove -Zfuel.Camille GILLOT-65/+0
2024-11-26do not constrain infer vars in `find_best_leaf_obligation`lcnr-119/+12
2024-11-25fix confusing diagnostic for reserved `##`Peter Jaszkowiak-97/+97
2024-11-26Auto merge of #132894 - frank-king:feature/where-refactor, r=cjgillotbors-23/+23
Refactor `where` predicates, and reserve for attributes support Refactor `WherePredicate` to `WherePredicateKind`, and reserve for attributes support in `where` predicates. This is a part of #115590 and is split from #132388. r? petrochenkov
2024-11-25tests: Add regression test for recursive enum with Cow and CloneMartin Nordholts-0/+11
2024-11-25fix gce typing_mode mismatchlcnr-0/+64
2024-11-26tests: remove `//@ pretty-expanded` usages许杰友 Jieyou Xu (Joe)-662/+23
Done with ```bash sd '//@ pretty-expanded.*\n' '' tests/ui/**/*.rs ``` and ``` sd '//@pretty-expanded.*\n' '' tests/ui/**/*.rs ```
2024-11-25tests: Add recursive associated type bound regression testsMartin Nordholts-0/+74
2024-11-26Fix handling of x18 in AArch64 inline assembly on ohos/trusty or with ↵Taiki Endo-2/+2
-Zfixed-x18
2024-11-25Constify Drop and DestructMichael Goulet-674/+111
2024-11-25Refactor `where` predicates, and reserve for attributes supportFrank King-23/+23
2024-11-25Rollup merge of #131664 - taiki-e:s390x-asm-vreg-inout, r=AmanieuMatthias Krüger-108/+1025
Support input/output in vector registers of s390x inline assembly (under asm_experimental_reg feature) This extends currently clobber-only vector registers (`vreg`) support to allow passing `#[repr(simd)]` types, floats (f32/f64/f128), and integers (i32/i64/i128) as input/output. This is unstable and gated under new `#![feature(asm_experimental_reg)]` (tracking issue: https://github.com/rust-lang/rust/issues/133416). If the feature is not enabled, only clober is supported as before. | Architecture | Register class | Target feature | Allowed types | | ------------ | -------------- | -------------- | -------------- | | s390x | `vreg` | `vector` | `i32`, `f32`, `i64`, `f64`, `i128`, `f128`, `i8x16`, `i16x8`, `i32x4`, `i64x2`, `f32x4`, `f64x2` | This matches the list of types that are supported by the vector registers in LLVM: https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/SystemZ/SystemZRegisterInfo.td#L301-L313 In addition to `core::simd` types and floats listed above, custom `#[repr(simd)]` types of the same size and type are also allowed. All allowed types other than i32/f32/i64/f64/i128, and relevant target features are currently unstable. Currently there is no SIMD type for s390x in `core::arch`, but this is tracked in https://github.com/rust-lang/rust/issues/130869. cc https://github.com/rust-lang/rust/issues/130869 about vector facility support in s390x cc https://github.com/rust-lang/rust/issues/125398 & https://github.com/rust-lang/rust/issues/116909 about f128 support in asm `@rustbot` label +O-SystemZ +A-inline-assembly
2024-11-25Rollup merge of #131523 - nbdd0121:asm, r=compiler-errorsMatthias Krüger-10/+84
Fix asm goto with outputs and move it to a separate feature gate Tracking issue: #119364 This PR addresses 3 aspects of asm goto with outputs: * Codegen is fixed. My initial implementation has an oversight which cause the output to be only stored in fallthrough path, but not in label blocks. * Outputs can now be used with `options(noreturn)` if a label block is given. * All of this is moved to a new feature gate, because we likely want to stabilise `asm_goto` before asm goto with outputs. `@rustbot` labels: +A-inline-assembly +F-asm