about summary refs log tree commit diff
path: root/src/test/ui
AgeCommit message (Collapse)AuthorLines
2022-07-07Auto merge of #98360 - estebank:uninit-binding, r=oli-obkbors-403/+771
On partial uninit error point at where we need init When a binding is declared without a value, borrowck verifies that all codepaths have *one* assignment to them to initialize them fully. If there are any cases where a condition can be met that leaves the binding uninitialized or we attempt to initialize a field of an uninitialized binding, we emit E0381. We now look at all the statements that initialize the binding, and use them to explore branching code paths that *don't* and point at them. If we find *no* potential places where an assignment to the binding might be missing, we display the spans of all the existing initializers to provide some context. Fix https://github.com/rust-lang/rust/issues/97956.
2022-07-07diagnostics: suggest naming a field after failing to parseMichael Howell-5/+14
2022-07-07diagnostics: mention the `:` token when struct fields fail to parseMichael Howell-7/+7
2022-07-07fix arm testEsteban Küber-6/+10
2022-07-07Wording tweakEsteban Küber-18/+24
2022-07-07Fix label on uninit binding field assignmentEsteban Küber-6/+6
2022-07-07Avoid misleading message/label in `match-cfg-fake-edges.rs` testEsteban Küber-2/+5
2022-07-07Add test for `for` loop maybe initializing bindingEsteban Küber-0/+20
2022-07-07Review comments: wordingEsteban Küber-31/+34
2022-07-07Tweak wording and spansEsteban Küber-302/+300
2022-07-07On partial uninit error point at where we need initEsteban Küber-397/+731
When a binding is declared without a value, borrowck verifies that all codepaths have *one* assignment to them to initialize them fully. If there are any cases where a condition can be met that leaves the binding uninitialized or we attempt to initialize a field of an unitialized binding, we emit E0381. We now look at all the statements that initialize the binding, and use them to explore branching code paths that *don't* and point at them. If we find *no* potential places where an assignment to the binding might be missing, we display the spans of all the existing initializers to provide some context.
2022-07-07Track implicit `Sized` obligations in type paramsEsteban Küber-112/+174
Suggest adding a `?Sized` bound if appropriate on E0599 by inspecting the HIR Generics. (Fix #98539)
2022-07-07Rollup merge of #99004 - TaKO8Ki:add-test-for-70408, r=Mark-SimulacrumMatthias Krüger-0/+13
Add a test for #70408 closes #70408
2022-07-07Rollup merge of #99002 - fee1-dead-contrib:sugg_derive, r=michaelwoeristerMatthias Krüger-5/+5
suggest adding a derive for #[default] applied to variants cc ``@TaKO8Ki`` as followup to #98873.
2022-07-07Rollup merge of #98995 - TaKO8Ki:add-test-for-80471, r=Mark-SimulacrumMatthias Krüger-0/+31
Add a test for #80471 Tests #80471, but doesn't close it, see https://github.com/rust-lang/rust/issues/80471#issuecomment-1177658967.
2022-07-07Rollup merge of #98979 - RalfJung:more-alloc-range, r=oli-obkMatthias Krüger-1/+1
interpret: use AllocRange in UninitByteAccess also use nice new format string syntax in `interpret/error.rs`, and use the `#` flag to add `0x` prefixes where applicable. r? ``@oli-obk``
2022-07-07Rollup merge of #98844 - cjgillot:deep-visit, r=jyn514Matthias Krüger-60/+60
Reword comments and rename HIR visiting methods. Sparked by this discussion in [zulip](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Confused.20by.20comment.20on.20.60deep_visit_item_likes_in_module.60) r? ``@jyn514`` ``@camsteffen``
2022-07-07Add test for #98539Esteban Küber-0/+69
2022-07-07Reword comments and rename HIR visiting methods.Camille GILLOT-60/+60
2022-07-07Rollup merge of #96856 - DrMeepster:fix_projection_validation, r=IcnrDylan DPC-2/+2
Fix ProjectionElem validation `TypeChecker::visit_projection_elem` was not actually being called.
2022-07-07`UnsafeCell` now has no niches, ever.Oli Scherer-442/+22
2022-07-07Bless aarch64 test.Camille GILLOT-1/+1
2022-07-07Fix borrowck closure span.Camille GILLOT-35/+82
2022-07-07Shorten span for closures.Camille GILLOT-1238/+808
2022-07-07add a test for #70408Takayuki Maeda-0/+13
2022-07-07suggest adding a derive for #[default] applied to variantsDeadbeef-5/+5
2022-07-07Auto merge of #98827 - aDotInTheVoid:suggest-extern-block, r=nagisabors-0/+38
Suggest using block for `extern "abi" fn` with no body `@rustbot` modify labels: +A-diagnostics
2022-07-07add a test for #80471Takayuki Maeda-0/+31
2022-07-06update testMiguel Guarniz-6/+6
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-07-06Auto merge of #98831 - RalfJung:no-more-unsized-locals, r=oli-obkbors-7/+7
interpret: remove support for unsized_locals I added support for unsized_locals in https://github.com/rust-lang/rust/pull/59780 but the current implementation is a crude hack and IMO definitely not the right way to have unsized locals in MIR. It also [causes problems](https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/Missing.20Layout.20Check.20in.20.60interpret.2Foperand.2Ers.60.3F). and what codegen does is unsound and has been for years since clearly nobody cares (so I hope nobody actually relies on that implementation and I'll be happy if Miri ensures they do not). I think if we want to have unsized locals in Miri/MIR we should add them properly, either by having a `StorageLive` that takes metadata or by having an `alloca` that returns a pointer (making the ptr indirection explicit) or something like that. So, this PR removes the `LocalValue::Unallocated` hack. It adds `Immediate::Uninit`, for several reasons: - This lets us still do fairly little work in `push_stack_frame`, in particular we do not actually have to create any allocations. - If/when I remove `ScalarMaybeUninit`, we will need something like this to have an "optimized" representation of uninitialized locals. Without this we'd have to put uninitialized integers into the heap! - const-prop needs some way to indicate "I don't know the value of this local'; it used to use `LocalValue::Unallocated` for that, now it can use `Immediate::Uninit`. There is still a fundamental difference between `LocalValue::Unallocated` and `Immediate::Uninit`: the latter is considered a regular local that you can read from and write to, it just has a more optimized representation when compared with an actual `Allocation` that is fully uninit. In contrast, `LocalValue::Unallocated` had this really odd behavior where you would write to it but not read from it. (This is in fact what caused the problems mentioned above.) While at it I also did two drive-by cleanups/improvements: - In `pop_stack_frame`, do the return value copying and local deallocation while the frame is still on the stack. This leads to better error locations being reported. The old errors were [sometimes rather confusing](https://rust-lang.zulipchat.com/#narrow/stream/269128-miri/topic/Cron.20Job.20Failure.202022-06-24/near/287445522). - Deduplicate `copy_op` and `copy_op_transmute`. r? `@oli-obk`
2022-07-06Rollup merge of #98519 - TaKO8Ki:add-head-span-field-to-item-and-impl-item, ↵Guillaume Gomez-44/+39
r=cjgillot Replace some `guess_head_span` with `def_span` This patch fixes a part of #97417. r? `@cjgillot`
2022-07-06blessRalf Jung-7/+7
2022-07-06fix ICE in ConstPropRalf Jung-0/+18
2022-07-06session: `output-width` -> `diagnostic-width`David Wood-3/+3
Rename the `--output-width` flag to `--diagnostic-width` as this appears to be the preferred name within the compiler team. Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-06session: `terminal-width` -> `output-width`David Wood-19/+19
Rename the `--terminal-width` flag to `--output-width` as the behaviour doesn't just apply to terminals (and so is slightly less accurate). Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-06sess: stabilize `--terminal-width`David Wood-3/+3
Formerly `-Zterminal-width`, `--terminal-width` allows the user or build tool to inform rustc of the width of the terminal so that diagnostics can be truncated. Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-06interpret: use AllocRange in UninitByteAccessRalf Jung-1/+1
also use nice new format string syntax in interpret/error.rs
2022-07-06experiment: trying to encode the end-to-end test as a ui test via ↵Felix S. Klock II-0/+38
rust_test_helpers. This instance is almost certainly insufficient because we need to force optimization flags for both the C and Rust sides of the code. but lets find out for sure.
2022-07-06Suggest using block for `extern "abi" fn` with no bodyNixon Enraght-Moony-0/+38
2022-07-06suggest adding a missing zero to a floating point numberTakayuki Maeda-0/+50
2022-07-06use `named_span` in case of tuple variantTakayuki Maeda-24/+24
2022-07-06replace `guess_head_span` with `def_span`Takayuki Maeda-20/+15
2022-07-06Rollup merge of #98968 - RalfJung:scalar-sanity, r=oli-obkDylan DPC-0/+15
assert Scalar sanity With https://github.com/rust-lang/rust/pull/96814 having landed, finally our `Scalar` layouts have the invariants they deserve. :)
2022-07-06Rollup merge of #98967 - ↵Dylan DPC-0/+44
ClementTsang:fix_inaccessible_type_alias_plural_typo, r=lcnr fix typo in note about multiple inaccessible type aliases Mainly intended as a small typo fix ("aliass" -> "aliases") for the case where a type cannot be found in scope but there are multiple inaccessible type aliases that match the missing type. In general this change would use the correct plural form in this scenario for base words that end with 's'.
2022-07-06fix projectionelem validationDrMeepster-2/+2
2022-07-05add testRalf Jung-0/+15
2022-07-05fix typo in note about multiple inaccessible type aliasesClementTsang-0/+44
Mainly intended as a small typo fix ("aliass" -> "aliases") for the case where a type cannot be found in scope, and there are multiple inaccessible type aliases that match the missing type. In general this change would use the correct plural form in this scenario for words that end with 's'.
2022-07-05Rollup merge of #96814 - RalfJung:enum-repr-align, r=oli-obkGuillaume Gomez-1/+202
Fix repr(align) enum handling `enum`, for better or worse, supports `repr(align)`. That has already caused a bug in https://github.com/rust-lang/rust/issues/92464, which was "fixed" in https://github.com/rust-lang/rust/pull/92932, but it turns out that that fix is wrong and caused https://github.com/rust-lang/rust/issues/96185. So this reverts #92932 (which fixes #96185), and attempts another strategy for fixing #92464: special-case enums when doing a cast, re-using the code to load the discriminant rather than assuming that the enum has scalar layout. This works fine for the interpreter. However, #92464 contained another testcase that was previously not in the test suite -- and after adding it, it ICEs again. This is not surprising; codegen needs the same patch that I did in the interpreter. Probably this has to happen [around here](https://github.com/rust-lang/rust/blob/d32ce37a171663048a4c4a536803434e40f52bd6/compiler/rustc_codegen_ssa/src/mir/rvalue.rs#L276). Unfortunately I don't know how to do that -- the interpreter can load a discriminant from an operand, but codegen can only do that from a place. `@oli-obk` `@eddyb` `@bjorn3` any idea?
2022-07-05add assertsRalf Jung-0/+2
2022-07-05fix the layout of repr(align) enumsRalf Jung-1/+200