about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2023-06-09Auto merge of #112116 - compiler-errors:misc-hir-typeck-mismatch-tweaks, ↵bors-29/+92
r=WaffleLapkin Misc HIR typeck type mismatch tweaks These are all intended to improve #112104, but I couldn't get it to actually suggest adding `as_ref` to the LHS of the equality expr without some hacks that I may play around with some more. Each commit's title should explain what it's doing except for perhaps the last one, which addresses the bogus suggestion on #112104 itself.
2023-06-08Auto merge of #112068 - WaffleLapkin:move-discrim-tests, r=compiler-errorsbors-24/+24
Move tests from `ui/discrim` dir It seems that we already have a `enum-discriminant` with more tests, so it makes sense to merge them.
2023-06-08Peel borrows before suggesting as_ref/as_derefMichael Goulet-6/+9
2023-06-08Don't suggest cyclic associated type constraintMichael Goulet-0/+23
2023-06-08Point at correct exprs for assert_eq type mismatchMichael Goulet-12/+13
2023-06-08More robust as_ref/as_deref suggestionsMichael Goulet-16/+50
2023-06-08Suggest type mismatches even when using ref syntax on bindingMichael Goulet-1/+3
2023-06-08Auto merge of #112420 - matthiaskrgr:rollup-spiavw5, r=matthiaskrgrbors-0/+11
Rollup of 4 pull requests Successful merges: - #109953 (Use 128 bits for TypeId hash) - #112333 (Don't hold the active queries lock while calling `make_query`) - #112339 (Fix rust-analyzer proc macro server) - #112410 (Do `fix_*_builtin_expr` hacks on the writeback results) r? `@ghost` `@rustbot` modify labels: rollup
2023-06-08Move tests from `ui/discrim` dirMaybe Waffle-24/+24
2023-06-08Rollup merge of #112410 - compiler-errors:writeback, r=lcnrMatthias Krüger-0/+11
Do `fix_*_builtin_expr` hacks on the writeback results During writeback, we do `fix_{scalar,index}_builtin_expr` so that during MIR build we generate built-in MIR instructions instead of method calls for certain built-in arithmetic operations. We do this by checking the types of these built-in operations are scalar types, and remove the method def-id to essentially mark the operation as built-in and not "overloaded". For lazy norm and the new trait solver, this is a problem, because we don't actually normalize all the types we end up seeing in the typeck results until they're copied over writeback's copy of the typeck results. To fix this, delay these fixup calls until after this normalization has been done. This doesn't affect the old trait solver, but does simplify the code a bit IMO, since we can remove a few sets of calls to `resolve_vars_if_possible` and some `borrow_mut`s. r? `@lcnr`
2023-06-08Auto merge of #112415 - GuillaumeGomez:rollup-5pa9frd, r=GuillaumeGomezbors-5/+48
Rollup of 9 pull requests Successful merges: - #112034 (Migrate `item_opaque_ty` to Askama) - #112179 (Avoid passing --cpu-features when empty) - #112309 (bootstrap: remove dependency `is-terminal`) - #112388 (Migrate GUI colors test to original CSS color format) - #112389 (Add a test for #105709) - #112392 (Fix ICE for while loop with assignment condition with LHS place expr) - #112394 (Remove accidental comment) - #112396 (Track more diagnostics in `rustc_expand`) - #112401 (Don't `use compile_error as print`) r? `@ghost` `@rustbot` modify labels: rollup
2023-06-08Rollup merge of #112392 - jieyouxu:issue-112385, r=compiler-errorsGuillaume Gomez-2/+36
Fix ICE for while loop with assignment condition with LHS place expr Fixes #112385.
2023-06-08Rollup merge of #112389 - TaKO8Ki:issue-105709, r=compiler-errorsGuillaume Gomez-0/+9
Add a test for #105709 Closes #105709
2023-06-08Rollup merge of #112388 - GuillaumeGomez:migrate-gui-test-color-12, r=notriddleGuillaume Gomez-3/+3
Migrate GUI colors test to original CSS color format Follow-up of https://github.com/rust-lang/rust/pull/111459. r? `@notriddle`
2023-06-08Auto merge of #110040 - ndrewxie:issue-84447-partial-1, r=lcnr,michaelwoeristerbors-3/+3
Removed use of iteration through a HashMap/HashSet in rustc_incremental and replaced with IndexMap/IndexSet This allows for the `#[allow(rustc::potential_query_instability)]` in rustc_incremental to be removed, moving towards fixing #84447 (although a LOT more modules have to be changed to fully resolve it). Only HashMaps/HashSets that are being iterated through have been modified (although many structs and traits outside of rustc_incremental had to be modified as well, as they had fields/methods that involved a HashMap/HashSet that would be iterated through) I'm making a PR for just 1 module changed to test for performance regressions and such, for future changes I'll either edit this PR to reflect additional modules being converted, or batch multiple modules of changes together and make a PR for each group of modules.
2023-06-08add a test for #105709Takayuki Maeda-0/+9
replace build with check Co-authored-by: Michael Goulet <michael@errs.io> use appropriate test name
2023-06-08Do fix_*_builtin_expr hacks on the writeback resultsMichael Goulet-0/+11
2023-06-08Fix ICE for while loop with assignment condition with LHS place expr许杰友 Jieyou Xu (Joe)-2/+36
2023-06-07Auto merge of #109005 - Nilstrieb:dont-forgor-too-much-from-cfg, r=petrochenkovbors-0/+264
Remember names of `cfg`-ed out items to mention them in diagnostics # Examples ## `serde::Deserialize` without the `derive` feature (a classic beginner mistake) I had to slightly modify serde so that it uses explicit re-exports instead of a glob re-export. (Update: a serde PR was merged that adds the manual re-exports) ``` error[E0433]: failed to resolve: could not find `Serialize` in `serde` --> src/main.rs:1:17 | 1 | #[derive(serde::Serialize)] | ^^^^^^^^^ could not find `Serialize` in `serde` | note: crate `serde` has an item named `Serialize` but it is inactive because its cfg predicate evaluated to false --> /home/gh-Nilstrieb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde-1.0.160/src/lib.rs:343:1 | 343 | #[cfg(feature = "serde_derive")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 344 | pub use serde_derive::{Deserialize, Serialize}; | ^^^^^^^^^ = note: the item is gated behind the `serde_derive` feature = note: see https://doc.rust-lang.org/cargo/reference/features.html for how to activate a crate's feature ``` (the suggestion is not ideal but that's serde's fault) I already tested the metadata size impact locally by compiling the `windows` crate without any features. `800k` -> `809k` r? `@ghost`
2023-06-07Migrate GUI colors test to original CSS color formatGuillaume Gomez-3/+3
2023-06-07Rollup merge of #112345 - bvanjoi:fix-112342, r=nilstrieb,est31Dylan DPC-0/+176
fix(expand): prevent infinity loop in macro containing only "///" Fixes https://github.com/rust-lang/rust/issues/112342 Issue #112342 was caused by an infinity loop in `parse_tt_inner`, and the state of it is as follows: - `matcher`: `[Sequence, Token(Doc), SequenceKleeneOpNoSep(op: ZeroOrMore), Eof]` - loop: | Iteration | Action | | - | - | | 0 | enter `Sequence`| | 1 | enter `Token(Doc)` and `mp.idx += 1` had been executed | | 2 | enter `SequenceKleeneOpNoSep` and reset `mp.idx` to `1` | | 3 | enter `Token(Doc)` again| To prevent the infinite loop, a check for whether it only contains `DocComment` in `check_lhs_no_empty_seq` had been added.
2023-06-07Rollup merge of #112122 - compiler-errors:next-coherence, r=lcnrDylan DPC-2/+31
Add `-Ztrait-solver=next-coherence` Flag that conditionally uses the trait solver *only* during coherence, for more testing and/or eventual partial-migration onto the trait solver (in the medium- to long-term). * This still uses the selection context in some of the coherence methods I think, so it's not "complete". Putting this up for review and/or for further work in-tree. * I probably need to spend a bit more time making sure that we don't sneakily create any other infcx's during coherence that also need the new solver enabled. r? `@lcnr`
2023-06-07Rollup merge of #112076 - compiler-errors:bidirectional-alias-eq, r=lcnrDylan DPC-0/+73
Fall back to bidirectional normalizes-to if no subst-relate candidate in alias-relate goal Sometimes we get into the case where the choice of normalizes-to branch in alias-relate are both valid, but we cannot make a choice of which one to take because they are different -- either returning equivalent but permuted region constraints, or equivalent opaque type definitions but differing modulo normalization. In this case, we can make progress by considering a fourth candidate where we compute both normalizes-to branches together and canonicalize that as a response. This is essentially the AND intersection of both normalizes-to branches. In an ideal world, we'd be returning something more like the OR intersection of both branches, but we have no way of representing that either for regions (maybe eventually) or opaques (don't see that happening ever). This is incomplete, so like the subst-relate fallback it's only considered outside of coherence. But it doesn't seem like a dramatic strengthening of inference or anything, and is useful for helping opaque type inference succeed when the hidden type is a projection. ## Example Consider the goal - `AliasRelate(Tait, <[i32; 32] as IntoIterator>::IntoIter)`. We have three ways of currently solving this goal: 1. SubstRelate - fails because we can't directly equate the substs of different alias kinds. 2. NormalizesToRhs - `Tait normalizes-to <[i32; 32] as IntoIterator>::IntoIter` * Ends up infering opaque definition - `Tait := <[i32; 32] as IntoIterator>::IntoIter` 3. NormalizesToLhs - `<[i32; 32] as IntoIterator>::IntoIter normalizes-to Tait` * Find impl candidate, substitute the associated type - `std::array::IntoIter<i32, 32>` * Equate `std::array::IntoIter<i32, 32>` and `Tait` * Ends up infering opaque definition - `Tait := std::array::IntoIter<i32, 32>` The problem here is that 2 and 3 are essentially both valid, since we have aliases that normalize on both sides, but due to lazy norm, they end up inferring different opaque type definitions that are only equal *after* normalizing them further. --- r? `@lcnr`
2023-06-07Auto merge of #111047 - compiler-errors:rtn-no-ty-ct-params, r=spastorinobors-0/+49
Emit an error when return-type-notation is used with type/const params These are not intended to be supported initially, even though the compiler supports them internally...
2023-06-07feat(expand): emit note for doc comment in macro matcherbohan-1/+84
2023-06-06Auto merge of #112361 - matthiaskrgr:rollup-39zxrw1, r=matthiaskrgrbors-51/+35
Rollup of 8 pull requests Successful merges: - #111250 (Add Terminator conversion from MIR to SMIR, part #2) - #112310 (Add new Tier-3 targets: `loongarch64-unknown-none*`) - #112334 (Add myself to highfive rotation) - #112340 (remove `TyCtxt::has_error_field` helper method) - #112343 (Prevent emitting `missing_docs` for `pub extern crate`) - #112350 (Avoid duplicate type sanitization of local decls in borrowck) - #112356 (Fix comment for `get_region_var_origins`) - #112358 (Remove default visitor impl in region constraint generation) r? `@ghost` `@rustbot` modify labels: rollup
2023-06-06Rollup merge of #112343 - GuillaumeGomez:extern-crate-missing-docs, r=notriddleMatthias Krüger-26/+31
Prevent emitting `missing_docs` for `pub extern crate` Fixes #112308. r? `@notriddle`
2023-06-06Fall back to bidirectional normalizes-to if no subst-eq in alias-eq goalMichael Goulet-0/+73
2023-06-06bless coherence testMichael Goulet-2/+31
2023-06-06fix(expand): prevent infinity loop in macro containing only "///"bohan-0/+93
2023-06-06Rollup merge of #112325 - notriddle:notriddle/issue-111932, r=compiler-errorsMatthias Krüger-4/+36
diagnostics: do not suggest type name tweaks on type-inferred closure args Fixes #111932
2023-06-06Rollup merge of #112199 - jieyouxu:issue-112188, r=compiler-errorsMatthias Krüger-1/+66
Fix suggestion for matching struct with `..` on both ends ### Before This PR ``` error: expected `}`, found `,` --> src\main.rs:8:17 | 8 | Foo { .., x, .. } => (), | --^ | | | | | expected `}` | `..` must be at the end and cannot have a trailing comma | help: move the `..` to the end of the field list | 8 - Foo { .., x, .. } => (), 8 + Foo { .., x, , .. } => (), | ``` ### After This PR ``` error: expected `}`, found `,` --> tests/ui/parser/issue-112188.rs:11:17 | 11 | let Foo { .., x, .. } = f; //~ ERROR expected `}`, found `,` | --^- | | | | | expected `}` | `..` must be at the end and cannot have a trailing comma | help: remove the starting `..` ``` Fixes #112188.
2023-06-06Rollup merge of #112019 - jieyouxu:issue-111554, r=compiler-errorsMatthias Krüger-0/+57
Don't suggest changing `&self` and `&mut self` in function signature to be mutable when taking `&mut self` in closure Current suggestion for when taking a mutable reference to `self` in a closure (as an upvar) will produce a machine-applicable suggestion to change the `self` in the function signature to `mut self`, but does not account for the specialness of implicit self in that it can already have `&` and `&mut` (see #111554). This causes the function signature to become `test(&mut mut self)` which does not seem desirable. ``` error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable --> src/sound_player.rs:870:11 | 869 | pub fn test(&mut self) { | ---- help: consider changing this to be mutable: `mut self` 870 | || test2(&mut self); | ^^^^^^^^^ cannot borrow as mutable ``` This PR suppresses the "changing this to be mutable" suggestion if the implicit self is either `ImplicitSelfKind::ImmRef` or `ImplicitSelfKind::MutRef`. Fixes #111554.
2023-06-06Rollup merge of #111058 - fortanix:raoul/fix_lvi_mitigations, r=cuviperMatthias Krüger-4/+13
Correct fortanix LVI test print function A recent change resulted in a different machine code for the `print` function. This caused the LVI test for this function to fail. This PR: - Fixes the test for the `print` function - Simplified the test a bit so future modifications are more unlikely cc: ``@jethrogb``
2023-06-06Add regression test for #112308Guillaume Gomez-26/+31
2023-06-06remove `has_error_field` helper methodlcnr-25/+4
2023-06-05diagnostics: do not suggest type name tweaks on type-inferred closure argsMichael Howell-4/+36
Fixes #111932
2023-06-06Auto merge of #111999 - scottmcm:codegen-less-memcpy, r=compiler-errorsbors-5/+75
Use `load`+`store` instead of `memcpy` for small integer arrays I was inspired by #98892 to see whether, rather than making `mem::swap` do something smart in the library, we could update MIR assignments like `*_1 = *_2` to do something smarter than `memcpy` for sufficiently-small types that doing it inline is going to be better than a `memcpy` call in assembly anyway. After all, special code may help `mem::swap`, but if the "obvious" MIR can just result in the correct thing that helps everything -- other code like `mem::replace`, people doing it manually, and just passing around by value in general -- as well as makes MIR inlining happier since it doesn't need to deal with all the complicated library code if it just sees a couple assignments. LLVM will turn the short, known-length `memcpy`s into direct instructions in the backend, but that's too late for it to be able to remove `alloca`s. In general, replacing `memcpy`s with typed instructions is hard in the middle-end -- even for `memcpy.inline` where it knows it won't be a function call -- is hard [due to poison propagation issues](https://rust-lang.zulipchat.com/#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/memcpy.20vs.20load-store.20for.20MIR.20assignments/near/360376712). So because we know more about the type invariants -- these are typed copies -- rustc can emit something more specific, allowing LLVM to `mem2reg` away the `alloca`s in some situations. #52051 previously did something like this in the library for `mem::swap`, but it ended up regressing during enabling mir inlining (https://github.com/rust-lang/rust/commit/cbbf06b0cd39dc93033568f1e65f5363cbbdebcd), so this has been suboptimal on stable for ≈5 releases now. The code in this PR is narrowly targeted at just integer arrays in LLVM, but works via a new method on the [`LayoutTypeMethods`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_codegen_ssa/traits/trait.LayoutTypeMethods.html) trait, so specific backends based on cg_ssa can enable this for more situations over time, as we find them. I don't want to try to bite off too much in this PR, though. (Transparent newtypes and simple things like the 3×usize `String` would be obvious candidates for a follow-up.) Codegen demonstrations: <https://llvm.godbolt.org/z/fK8hT9aqv> Before: ```llvm define void `@swap_rgb48_old(ptr` noalias nocapture noundef align 2 dereferenceable(6) %x, ptr noalias nocapture noundef align 2 dereferenceable(6) %y) unnamed_addr #1 { %a.i = alloca [3 x i16], align 2 call void `@llvm.lifetime.start.p0(i64` 6, ptr nonnull %a.i) call void `@llvm.memcpy.p0.p0.i64(ptr` noundef nonnull align 2 dereferenceable(6) %a.i, ptr noundef nonnull align 2 dereferenceable(6) %x, i64 6, i1 false) tail call void `@llvm.memcpy.p0.p0.i64(ptr` noundef nonnull align 2 dereferenceable(6) %x, ptr noundef nonnull align 2 dereferenceable(6) %y, i64 6, i1 false) call void `@llvm.memcpy.p0.p0.i64(ptr` noundef nonnull align 2 dereferenceable(6) %y, ptr noundef nonnull align 2 dereferenceable(6) %a.i, i64 6, i1 false) call void `@llvm.lifetime.end.p0(i64` 6, ptr nonnull %a.i) ret void } ``` Note it going to stack: ```nasm swap_rgb48_old: # `@swap_rgb48_old` movzx eax, word ptr [rdi + 4] mov word ptr [rsp - 4], ax mov eax, dword ptr [rdi] mov dword ptr [rsp - 8], eax movzx eax, word ptr [rsi + 4] mov word ptr [rdi + 4], ax mov eax, dword ptr [rsi] mov dword ptr [rdi], eax movzx eax, word ptr [rsp - 4] mov word ptr [rsi + 4], ax mov eax, dword ptr [rsp - 8] mov dword ptr [rsi], eax ret ``` Now: ```llvm define void `@swap_rgb48(ptr` noalias nocapture noundef align 2 dereferenceable(6) %x, ptr noalias nocapture noundef align 2 dereferenceable(6) %y) unnamed_addr #0 { start: %0 = load <3 x i16>, ptr %x, align 2 %1 = load <3 x i16>, ptr %y, align 2 store <3 x i16> %1, ptr %x, align 2 store <3 x i16> %0, ptr %y, align 2 ret void } ``` still lowers to `dword`+`word` operations, but has no stack traffic: ```nasm swap_rgb48: # `@swap_rgb48` mov eax, dword ptr [rdi] movzx ecx, word ptr [rdi + 4] movzx edx, word ptr [rsi + 4] mov r8d, dword ptr [rsi] mov dword ptr [rdi], r8d mov word ptr [rdi + 4], dx mov word ptr [rsi + 4], cx mov dword ptr [rsi], eax ret ``` And as a demonstration that this isn't just `mem::swap`, a `mem::replace` on a small array (since replace doesn't use swap since #83022), which used to be `memcpy`s in LLVM changes in IR ```llvm define void `@replace_short_array(ptr` noalias nocapture noundef sret([3 x i32]) dereferenceable(12) %0, ptr noalias noundef align 4 dereferenceable(12) %r, ptr noalias nocapture noundef readonly dereferenceable(12) %v) unnamed_addr #0 { start: %1 = load <3 x i32>, ptr %r, align 4 store <3 x i32> %1, ptr %0, align 4 %2 = load <3 x i32>, ptr %v, align 4 store <3 x i32> %2, ptr %r, align 4 ret void } ``` but that lowers to reasonable `dword`+`qword` instructions still ```nasm replace_short_array: # `@replace_short_array` mov rax, rdi mov rcx, qword ptr [rsi] mov edi, dword ptr [rsi + 8] mov dword ptr [rax + 8], edi mov qword ptr [rax], rcx mov rcx, qword ptr [rdx] mov edx, dword ptr [rdx + 8] mov dword ptr [rsi + 8], edx mov qword ptr [rsi], rcx ret ```
2023-06-05Auto merge of #112324 - matthiaskrgr:rollup-qscmi3c, r=matthiaskrgrbors-52/+236
Rollup of 6 pull requests Successful merges: - #112081 (Avoid ICE on `#![doc(test(...)]` with literal parameter) - #112196 (Resolve vars in result from `scrape_region_constraints`) - #112303 (Normalize in infcx instead of globally for `Option::as_deref` suggestion) - #112316 (Ensure space is inserted after keyword in `unused_delims`) - #112318 (Merge method, type and const object safety checks) - #112322 (Don't mention `IMPLIED_BOUNDS_ENTAILMENT` if signatures reference error) Failed merges: - #112251 (rustdoc: convert `if let Some()` that always matches to variable) r? `@ghost` `@rustbot` modify labels: rollup
2023-06-05Rollup merge of #112322 - ↵Matthias Krüger-0/+31
compiler-errors:no-IMPLIED_BOUNDS_ENTAILMENT-if-errs, r=eholk Don't mention `IMPLIED_BOUNDS_ENTAILMENT` if signatures reference error Fixes #112321
2023-06-05Rollup merge of #112316 - clubby789:unused-parens-space, r=compiler-errorsMatthias Krüger-13/+89
Ensure space is inserted after keyword in `unused_delims` Fixes #112276
2023-06-05Rollup merge of #112303 - Nilstrieb:as-deref, r=compiler-errorsMatthias Krüger-37/+86
Normalize in infcx instead of globally for `Option::as_deref` suggestion fixes #112293 The projection may contain inference variables. These inference variables are local to the local inference context. Using `tcx.normalize_erasing_regions` doesn't work here because this method is global and does not have access to the inference context. It's therefore unable to deal with the inference variables. We normalize in the local inference context instead, which knowns about the inference variables. The test looks a little different than the issue example, I made it more minimal and verified that it still ICEs on nightly. Also contains a drive-by fix to properly compare the types. r? `@compiler-errors`
2023-06-05Rollup merge of #112196 - compiler-errors:new-solver-resolv, r=lcnrMatthias Krüger-2/+6
Resolve vars in result from `scrape_region_constraints` Since we perform `type_op::Normalize` in the local infcx when the new solver is enabled, vars aren't necessarily resolved, which triggers this ICE: https://github.com/rust-lang/rust/blob/f85ab544dfbbce7448993c490ad16c176339b939/compiler/rustc_infer/src/infer/nll_relate/mod.rs#L481 There are more tests that go from ICE -> pass due to this change, but I just added revisions to a few for CI. r? `@lcnr`
2023-06-05Rollup merge of #112081 - obeis:doc-test-literal, r=compiler-errorsMatthias Krüger-0/+24
Avoid ICE on `#![doc(test(...)]` with literal parameter Close #109066 r? `@compiler-errors`
2023-06-05Don't mention IMPLIED_BOUNDS_ENTAILMENT if signatures reference errorMichael Goulet-0/+31
2023-06-05Emit an error when RTN is used with ty/ct paramsMichael Goulet-0/+49
2023-06-05Resolve vars in result from scrape_region_constraintsMichael Goulet-2/+6
2023-06-05Better group RFC ui tests togetherMaybe Waffle-145/+145
2023-06-05Verify that (almost) all `ret` instructions have been replacedRaoul Strackx-0/+9
2023-06-05Ensure space is inserted after keyword in `unused_delims`clubby789-13/+89