about summary refs log tree commit diff
path: root/src/test/ui/consts
AgeCommit message (Collapse)AuthorLines
2022-07-05Rollup merge of #98860 - RalfJung:dangling-int-ptr, r=davidtwcoMatthias Krüger-21/+21
adjust dangling-int-ptr error message based on suggestions by `@saethlin` in https://github.com/rust-lang/miri/issues/2163 Fixes https://github.com/rust-lang/miri/issues/2163 I also did a bit of refactoring on this, so we have a helper method to create a `Pointer` with `None` provenance.
2022-07-05adjust dangling-int-ptr error messageRalf Jung-21/+21
2022-07-05Rollup merge of #98624 - davidtwco:translation-on-lints, r=compiler-errorsDylan DPC-2/+2
lints: mostly translatable diagnostics As lints are created slightly differently than other diagnostics, intended to try make them translatable first and then look into the applicability of diagnostic structs but ended up just making most of the diagnostics in the crate translatable (which will still be useful if I do make a lot of them structs later anyway). r? ``@compiler-errors``
2022-07-02Rollup merge of #98701 - TaKO8Ki:add-regression-test-for-50439, ↵Ralf Jung-0/+39
r=Mark-Simulacrum Add regression test for #50439 closes #50439
2022-07-01Shorten def_span for more items.Camille GILLOT-1439/+829
2022-06-30lint: port non-fmt-panic diagnosticsDavid Wood-2/+2
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30add regression test for #50439Takayuki Maeda-0/+39
2022-06-29fix stderr by hand since that test is not run on my systemRalf Jung-4/+4
2022-06-29interpret: adjust error from constructing an invalid valueRalf Jung-164/+164
2022-06-28Rollup merge of #98560 - TaKO8Ki:add-regression-test-for-85907, ↵Matthias Krüger-0/+17
r=Mark-Simulacrum Add regression test for #85907 closes #85907
2022-06-27add regression test for #85907Takayuki Maeda-0/+17
2022-06-26Rollup merge of #97743 - RalfJung:const-err-future-breakage, r=estebankMatthias Krüger-0/+2697
make const_err show up in future breakage reports As tracked in https://github.com/rust-lang/rust/issues/71800, const_err should become a hard error Any Day Now (TM). I'd love to move forward with that sooner rather than later; it has been deny-by-default for many years and a future incompat lint since https://github.com/rust-lang/rust/pull/80394 (landed more than a year ago). Some CTFE errors are already hard errors since https://github.com/rust-lang/rust/pull/86194. But before we truly make it a hard error in all cases, we now have one more intermediate step we can take -- to make it show up in future breakage reports. Cc `````@rust-lang/wg-const-eval`````
2022-06-25bless after rebaseRalf Jung-23/+711
2022-06-25bless remaining testsRalf Jung-0/+53
2022-06-25make const_err show up in future breakage reportsRalf Jung-0/+1956
2022-06-25Rollup merge of #98298 - TaKO8Ki:point-to-type-param-definition, ↵Matthias Krüger-1/+1
r=compiler-errors Point to type parameter definition when not finding variant, method and associated item fixes #77391
2022-06-22point to type param definition when not finding variant, method and assoc typeTakayuki Maeda-1/+1
use `def_ident_span` , `body_owner_def_id` instead of `in_progress_typeck_results`, `guess_head_span` use `body_id.owner` directly add description to label
2022-06-19Mention formatting macros when encountering ArgumentV1::new in constMichael Goulet-0/+99
2022-06-19Bless 32bit ui tests.Camille GILLOT-12/+12
2022-06-19Make some lints incremental.Camille GILLOT-15/+41
2022-06-15Rollup merge of #98026 - c410-f3r:z-errors, r=petrochenkovYuki Okushi-0/+20
Move some tests to more reasonable directories r? ```@petrochenkov```
2022-06-14rebaseb-naber-32/+104
2022-06-14address reviewb-naber-1/+1
2022-06-14bless 32-bit ui testsb-naber-4/+10
2022-06-14address reviewb-naber-5/+5
2022-06-14implement valtrees as the type-system representation for constant valuesb-naber-78/+260
2022-06-13Move testsCaio-0/+20
2022-06-09interpret: unify offset_from check with offset checkRalf Jung-13/+13
2022-06-09Auto merge of #97740 - RalfJung:ctfe-cycle-spans, r=lcnrbors-6/+6
use precise spans for recursive const evaluation This fixes https://github.com/rust-lang/rust/issues/73283 by using a `TyCtxtAt` with a more precise span when the interpreter recursively calls itself. Hopefully such calls are sufficiently rare that this does not cost us too much performance. (In theory, cycles can also arise through layout computation, as layout can depend on consts -- but layout computation happens all the time so we'd have to do something to not make this terrible for performance.)
2022-06-08Stabilize `const_intrinsic_copy`Yuki Okushi-7/+7
2022-06-07Auto merge of #95565 - jackh726:remove-borrowck-mode, r=nikomatsakisbors-10/+4
Remove migrate borrowck mode Closes #58781 Closes #43234 # Stabilization proposal This PR proposes the stabilization of `#![feature(nll)]` and the removal of `-Z borrowck`. Current borrow checking behavior of item bodies is currently done by first infering regions *lexically* and reporting any errors during HIR type checking. If there *are* any errors, then MIR borrowck (NLL) never occurs. If there *aren't* any errors, then MIR borrowck happens and any errors there would be reported. This PR removes the lexical region check of item bodies entirely and only uses MIR borrowck. Because MIR borrowck could never *not* be run for a compiled program, this should not break any programs. It does, however, change diagnostics significantly and allows a slightly larger set of programs to compile. Tracking issue: #43234 RFC: https://github.com/rust-lang/rfcs/blob/master/text/2094-nll.md Version: 1.63 (2022-06-30 => beta, 2022-08-11 => stable). ## Motivation Over time, the Rust borrow checker has become "smarter" and thus allowed more programs to compile. There have been three different implementations: AST borrowck, MIR borrowck, and polonius (well, in progress). Additionally, there is the "lexical region resolver", which (roughly) solves the constraints generated through HIR typeck. It is not a full borrow checker, but does emit some errors. The AST borrowck was the original implementation of the borrow checker and was part of the initially stabilized Rust 1.0. In mid 2017, work began to implement the current MIR borrow checker and that effort ompleted by the end of 2017, for the most part. During 2018, efforts were made to migrate away from the AST borrow checker to the MIR borrow checker - eventually culminating into "migrate" mode - where HIR typeck with lexical region resolving following by MIR borrow checking - being active by default in the 2018 edition. In early 2019, migrate mode was turned on by default in the 2015 edition as well, but with MIR borrowck errors emitted as warnings. By late 2019, these warnings were upgraded to full errors. This was followed by the complete removal of the AST borrow checker. In the period since, various errors emitted by the MIR borrow checker have been improved to the point that they are mostly the same or better than those emitted by the lexical region resolver. While there do remain some degradations in errors (tracked under the [NLL-diagnostics tag](https://github.com/rust-lang/rust/issues?q=is%3Aopen+is%3Aissue+label%3ANLL-diagnostics), those are sufficiently small and rare enough that increased flexibility of MIR borrow check-only is now a worthwhile tradeoff. ## What is stabilized As said previously, this does not fundamentally change the landscape of accepted programs. However, there are a [few](https://github.com/rust-lang/rust/issues?q=is%3Aopen+is%3Aissue+label%3ANLL-fixed-by-NLL) cases where programs can compile under `feature(nll)`, but not otherwise. There are two notable patterns that are "fixed" by this stabilization. First, the `scoped_threads` feature, which is a continutation of a pre-1.0 API, can sometimes emit a [weird lifetime error](https://github.com/rust-lang/rust/issues/95527) without NLL. Second, actually seen in the standard library. In the `Extend` impl for `HashMap`, there is an implied bound of `K: 'a` that is available with NLL on but not without - this is utilized in the impl. As mentioned before, there are a large number of diagnostic differences. Most of them are better, but some are worse. None are serious or happen often enough to need to block this PR. The biggest change is the loss of error code for a number of lifetime errors in favor of more general "lifetime may not live long enough" error. While this may *seem* bad, the former error codes were just attempts to somewhat-arbitrarily bin together lifetime errors of the same type; however, on paper, they end up being roughly the same with roughly the same kinds of solutions. ## What isn't stabilized This PR does not completely remove the lexical region resolver. In the future, it may be possible to remove that (while still keeping HIR typeck) or to remove it together with HIR typeck. ## Tests Many test outputs get updated by this PR. However, there are number of tests specifically geared towards NLL under `src/test/ui/nll` ## History * On 2017-07-14, [tracking issue opened](https://github.com/rust-lang/rust/issues/43234) * On 2017-07-20, [initial empty MIR pass added](https://github.com/rust-lang/rust/pull/43271) * On 2017-08-29, [RFC opened](https://github.com/rust-lang/rfcs/pull/2094) * On 2017-11-16, [Integrate MIR type-checker with NLL](https://github.com/rust-lang/rust/pull/45825) * On 2017-12-20, [NLL feature complete](https://github.com/rust-lang/rust/pull/46862) * On 2018-07-07, [Don't run AST borrowck on mir mode](https://github.com/rust-lang/rust/pull/52083) * On 2018-07-27, [Add migrate mode](https://github.com/rust-lang/rust/pull/52681) * On 2019-04-22, [Enable migrate mode on 2015 edition](https://github.com/rust-lang/rust/pull/59114) * On 2019-08-26, [Don't downgrade errors on 2015 edition](https://github.com/rust-lang/rust/pull/64221) * On 2019-08-27, [Remove AST borrowck](https://github.com/rust-lang/rust/pull/64790)
2022-06-06Auto merge of #97684 - RalfJung:better-provenance-control, r=oli-obkbors-357/+390
interpret: better control over whether we read data with provenance The resolution in https://github.com/rust-lang/unsafe-code-guidelines/issues/286 seems to be that when we load data at integer type, we implicitly strip provenance. So let's implement that in Miri at least for scalar loads. This makes use of the fact that `Scalar` layouts distinguish pointer-sized integers and pointers -- so I was expecting some wild bugs where layouts set this incorrectly, but so far that does not seem to happen. This does not entirely implement the solution to https://github.com/rust-lang/unsafe-code-guidelines/issues/286; we still do the wrong thing for integers in larger types: we will `copy_op` them and then do validation, and validation will complain about the provenance. To fix that we need mutating validation; validation needs to strip the provenance rather than complaining about it. This is a larger undertaking (but will also help resolve https://github.com/rust-lang/miri/issues/845 since we can reset padding to `Uninit`). The reason this is useful is that we can now implement `addr` as a `transmute` from a pointer to an integer, and actually get the desired behavior of stripping provenance without exposing it!
2022-06-05interpret: better control over whether we read data with provenance, and ↵Ralf Jung-357/+390
implicit provenance stripping where possible
2022-06-04use precise spans for recursive const evaluationRalf Jung-6/+6
2022-06-03Fully stabilize NLLJack Huey-10/+4
2022-06-03Auto merge of #89862 - lcnr:path-generics-diagnostics, r=estebankbors-10/+8
rewrite error handling for unresolved inference vars Pretty much completely rewrites `fn emit_inference_failure_err`. This new setup should hopefully be easier to extend and is already a lot better when looking for generic arguments. Because this is a rewrite there are still some parts which are lacking, these are tracked in #94483 and will be fixed in later PRs. r? `@estebank` `@petrochenkov`
2022-06-02add new `emit_inference_failure_err`lcnr-10/+8
2022-05-28Move some tests to more reasonable placesCaio-0/+12
2022-05-24Add the transmute and asm checks to typeck as deferred checksOli Scherer-34/+4
2022-05-24trait selection errors should poison the typeck results, too, so that const ↵Oli Scherer-10/+17
eval can avoid running at all
2022-05-23Refactor call terminator to always hold a destination placeJakob Degen-2/+2
2022-05-22Auto merge of #97177 - oli-obk:const-stability, r=davidtwcobors-4/+3
Implement proper stability check for const impl Trait, fall back to unstable const when undeclared Continuation of #93960 `@jhpratt` it looks to me like the test was simply not testing for the failure you were looking for? Your checks actually do the right thing for const traits?
2022-05-20Rollup merge of #97109 - ↵Matthias Krüger-0/+12
TaKO8Ki:fix-misleading-cannot-infer-type-for-type-parameter-error, r=oli-obk Fix misleading `cannot infer type for type parameter` error closes #93198
2022-05-20report ambiguous type parameters when their parents are impl or fnTakayuki Maeda-0/+12
fix ci error emit err for `impl_item`
2022-05-19bless 32bitRalf Jung-11/+11
2022-05-19interpret/validity: separately control checking numbers for being init and ↵Ralf Jung-24/+24
non-ptr
2022-05-19Proper const stability check, default to unstableJacob Pratt-4/+3
Rather than deferring to const eval for checking if a trait is const, we now check up-front. This allows the error to be emitted earlier, notably at the same time as other stability checks. Also included in this commit is a change of the default const stability level to UNstable. Previously, an item that was `const` but did not explicitly state it was unstable was implicitly stable.
2022-05-18Rollup merge of #97116 - RalfJung:ref-validity, r=oli-obkYuki Okushi-4/+4
interpret/validity: reject references to uninhabited types According to https://doc.rust-lang.org/reference/behavior-considered-undefined.html, this is definitely UB. And we can check this without actually looking up anything in memory, we just need the reference value and its type, making this a great candidate for a validity invariant IMO and my favorite resolution of https://github.com/rust-lang/unsafe-code-guidelines/issues/77. With this PR, Miri with `-Zmiri-check-number-validity` implements all my preferred options for what the validity invariants of our types could be. :) CTFE has been doing recursive checking anyway, so this is backwards compatible but might change the error output. I will submit a PR with the new Miri tests soon. r? `@oli-obk`
2022-05-17bless 32bitRalf Jung-2/+2
2022-05-17interpret/validity: reject references to uninhabited typesRalf Jung-2/+2