about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2020-05-03Auto merge of #71631 - RalfJung:miri-unleash-the-gates, r=oli-obkbors-223/+333
Miri: unleash all feature gates IMO it is silly to unleash features that do not even have a feature gate yet, but not unleash features that do. The only thing this achieves is making unleashed mode annoying to use as we have to figure out the feature flags to enable (and not always do the error messages say what that flag is). Given that the point of `-Z unleash-the-miri-inside-of-you` is to debug the Miri internals, I see no good reason for this extra hurdle. I cannot imagine a situation where we'd use that flag, realize the program also requires some feature gate, and then be like "oh I guess if this feature is unstable I will do something else". Instead, we'll always just add that flag to the code as well, so requiring the flag achieves nothing. r? @oli-obk @ecstatic-morse Fixes https://github.com/rust-lang/rust/issues/71630
2020-05-03Auto merge of #71006 - ecstatic-morse:dataflow-bidi, r=ecstatic-morsebors-0/+38
Use existing framework for backward dataflow analyses This PR adds support for backward analyses to the dataflow framework and adds a new live variable analysis (based on the existing one in `librustc_mir/util/liveness.rs`). By adding these to the framework instead of having a separate API, all newly implemented backward dataflow analyses get cursors/visitors, `rustc_peek` tests, and graphviz visualizations for free. In the near-term, this makes it much easier to implement global dead-store elimination, and I believe that this will enable even more MIR optimizations in the future. This PR makes many changes to the dataflow API, since some concepts and terminology only make sense in forward dataflow. Below is a list of the important changes. - ~~`entry_set` -> `fixpoint` (the fixpoint for backward dataflow problems is after the block's terminator)~~ - `seek_{before,after}` -> `seek_{before,after}_primary_effect` (the unprefixed dataflow effect is now referred to as the "primary" effect instead of the "after" effect. The "before" effect remains the same, although I considered changing it to the "antecedent" effect. In both backward and forward dataflow, the "before" effect is applied prior to the "primary" effect. I feel very strongly that this is the correct choice, as it means consumers don't have to switch between `seek_before` and `seek_after` based on the direction of their analysis. - `seek_after_assume_call_returns` is now gone. Users can use `ResultsCursor::apply_custom_effect` to emulate it. - `visit_{statement,terminator}_exit` -> `visit_{statement,terminator}_after_primary_effect` - `visit_{statement,terminator}` -> `visit_{statement,terminator}_before_primary_effect` Implementing this also required refactoring the dataflow cursor implementation so it could work in both directions. This is a large percentage of the diff, since the cursor code is rather complex. The fact that the cursor is exhaustively tested in both directions should reassure whomever is unlucky enough to review this :rofl:. In order to avoid computing the reverse CFG for forward dataflow analyses, I've added some hacks to the existing `mir::BodyAndCache` interface. I've requested changes to this interface that would let me implement this more efficiently. r? @eddyb (feel free to reassign) cc @rust-lang/wg-mir-opt
2020-05-03Add `rustc_peek` test for liveness with borrowsDylan MacKenzie-0/+38
2020-05-03Rollup merge of #71808 - unexge:long-err-expl-for-e0539, r=GuillaumeGomezDylan DPC-1/+2
Add long error explanation for E0539 since this error is similar to [E0551](https://github.com/rust-lang/rust/blob/master/src/librustc_error_codes/error_codes/E0551.md) most of the content was copied from it. part of #61137.
2020-05-03Rollup merge of #71726 - ldm0:ref2ptr, r=oli-obkDylan DPC-2/+221
Suggest deref when coercing `ty::Ref` to `ty::RawPtr` with arbitrary mutability Fixes #71676 1. Implement dereference suggestion when coercing `ty::Ref` to `ty::RawPtr` with arbitrary mutability. 2. Extract the dereference steps into `deref_steps()`, which removes all the `use` and `pub` noise introduced by last PR #71540, and makes the code more readable. 3. Use the `remove_prefix()` closure which makes the prefix removal more readable. 4. Introduce `Applicability` as a return value of `check_ref` to suggest `Applicability::Unspecified` suggestion. **Special**: I found it is not possible to genereate `Applicability::MachineApplicable` suggestion for situation like this: ```rust use std::ops::Deref; use std::ops::DerefMut; struct Bar(u8); struct Foo(Bar); struct Emm(Foo); impl Deref for Bar{ type Target = u8; fn deref(&self) -> &Self::Target { &self.0 } } impl Deref for Foo { type Target = Bar; fn deref(&self) -> &Self::Target { &self.0 } } impl Deref for Emm { type Target = Foo; fn deref(&self) -> &Self::Target { &self.0 } } impl DerefMut for Bar{ fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } } impl DerefMut for Foo { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } } impl DerefMut for Emm { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } } fn main() { let a = Emm(Foo(Bar(0))); let _: *mut u8 = &a; //~ ERROR mismatched types } ``` We may suggest `&mut ***a` here, but the `a` is not declared as mutable variable. And also when processing HIR, it's not possible to check if `a` is declared as a mutable variable (currently we do borrow checking with MIR). So we cannot ensure that suggestion when coercing immutable reference to mutable pointer is always machine applicable. Therefore I added a `Applicability` return value in `check_ref()`. And move the `immutable reference -> mutable pointer` situation into a sperate test file without `run-rustfix`. (It seems that `run-rustfix` will also adopt `Applicability::Unspecified` suggestion, which is strange)
2020-05-03Rollup merge of #71663 - jumbatm:caller-handles-validation-error, r=RalfJungDylan DPC-180/+197
Fix exceeding bitshifts not emitting for assoc. consts (properly this time, I swear!) Fixes #69021 and fixes #71353. As described in https://github.com/rust-lang/rust/issues/71353#issuecomment-617901923, this PR: - adds a variant of `try_validation!` called `try_validation_pat!` that allows specific failures to be turned into validation failures (but returns the rest, unchanged), and - allows `InvalidProgram` to be returned out of validation r? @RalfJung
2020-05-03Rollup merge of #71398 - ThinkChaos:feat_refcell_take, r=LukasKalbertodtDylan DPC-3/+3
Add `RefCell::take` Add `RefCell::take` to match `Cell` and `Option`. I also changed a couple of calls to `.replace` to `.take`. Tracking issue is #71395. This is my first contribution, please tell me if there's anything I could improve, thanks!
2020-05-03bless caller-location testRalf Jung-8/+6
2020-05-03remove unneeded flags; exlain why we still have const_if_matchRalf Jung-27/+56
2020-05-03warn about each skipped feature gateRalf Jung-317/+315
2020-05-03Auto merge of #70825 - eddyb:enum-discr-correct-generics-parent, r=nikomatsakisbors-0/+79
typeck: always expose explicit enum discriminant `AnonConst`s' parent in `generics_of`. This is similar to #70452 but for explicit `enum` discriminant constant expressions. However, unlike #70452, this PR should have no effect on stable code, as while it alleviates #43408 errors, there is no way to actually compile an `enum` with generic parameters *and* explicit discriminants, without `#![feature(arbitrary_enum_discriminant)]`, as explicit discriminant expression don't count as uses of parameters (if they did, they would count as invariant uses). <hr/> There's also 2 other commits here, both related to #70453: * "ty: use `delay_span_bug` in `ty::AdtDef::eval_explicit_discr`." - hides the ICEs demonstrated on #70453, when there are other errors (which the next commit adds) * "typeck/wfcheck: require that explicit enum discriminants const-evaluate succesfully." - closes #70453 by picking alternative "2", i.e. erroring when a discriminant doesn't fully const-evaluate from the perspective of the `enum` definition In the future, it might be possible to allow `enum` discriminants to actually depend on parameters, but that will likely require #68436 + some way to restrict the values so no two variants can end up with overlapping discriminants. As this PR would close #70453, it shouldn't be merged until a decision is reached there. r? @nikomatsakis
2020-05-03Rollup merge of #71813 - ecstatic-morse:issue-71734, r=tmandryDylan DPC-3/+41
Decode qualifs for associated const defaults Fixes #71734. We encode qualifs for associated constants, but never expected to decode the qualifs for defaulted associated consts. Fix this, and test that associated const defaults have the correct qualifs cross-crate. r? @tmandry
2020-05-03Rollup merge of #71542 - crlf0710:confusable_idents, r=petrochenkovDylan DPC-0/+26
Implement `confusable_idents` lint. This collects all identifier symbols into `ParseSession` and examines them within the non-ascii-idents lint. The skeleton generation part needs to be added to `unicode-security` crate. Will update this PR when the crate is updated. r? @petrochenkov EDIT: also included the `concat_idents` part.
2020-05-03Add more tests for cfg(version)mibac138-3/+52
2020-05-03Change cfg(version) error message wordingmibac138-6/+9
2020-05-03Implement RFC 2523, `#[cfg(version(..))]`mibac138-0/+121
2020-05-02Test associated const default qualifs cross-crateDylan MacKenzie-3/+41
This also tests for the ICE in #71734
2020-05-02Auto merge of #69274 - LeSeulArtichaut:target-feature-11, r=hanna-kruppebors-12/+286
Implement RFC 2396: `#[target_feature]` 1.1 Tracking issue: #69098 r? @nikomatsakis cc @gnzlbg @joshtriplett
2020-05-03Implement `confusable_idents` lint.Charles Lew-0/+26
2020-05-02Add long error explanation for E0539unexge-1/+2
2020-05-02typeck: always expose explicit enum discriminant `AnonConst`s' parent in ↵Eduard-Mihai Burtescu-0/+79
`generics_of`.
2020-05-02fix miri-unleash delayed sanity checkingRalf Jung-9/+7
2020-05-02make sure the miri-unleash-flag is not used to circumvent feature gatesRalf Jung-17/+10
2020-05-02Rollup merge of #71782 - cuviper:leave-dev-null-alone, r=Mark-SimulacrumRalf Jung-4/+8
Use a non-existent test path instead of clobbering /dev/null Fixes #71502. r? @Mark-Simulacrum
2020-05-02Rollup merge of #71781 - estebank:box-pin-test, r=tmandryRalf Jung-16/+95
Uncomment test code for failure to use `Box::pin` Close #69083.
2020-05-02Replace convenient function `remove_prefix()` with `replace_prefix()`Donough Liu-2/+0
2020-05-02Suggestion for immutable reference -> mutable pointer should be emittedDonough Liu-2/+1
as `Applicability::Unspecified`
2020-05-02Suggest deref when coercing `ty::Ref` to `ty::RawPtr` with arbitraryDonough Liu-2/+224
mutability
2020-05-02Auto merge of #71716 - alexcrichton:bitcode-follow-up, r=nnethercotebors-2/+2
Rename `bitcode-in-rlib` option to `embed-bitcode` This commit finishes work first pioneered in #70458 and started in #71528. The `-C bitcode-in-rlib` option, which has not yet reached stable, is renamed to `-C embed-bitcode` since that more accurately reflects what it does now anyway. Various tests and such are updated along the way as well. This'll also need to be backported to the beta channel to ensure we don't accidentally stabilize `-Cbitcode-in-rlib` as well.
2020-05-01Uncomment test code for failure to use `Box::pin`Esteban Küber-16/+95
Close #69083.
2020-05-01Use a non-existent test path instead of clobbering /dev/nullJosh Stone-4/+8
2020-05-01Rollup merge of #71018 - lcnr:custom-const-param, r=eddybDylan DPC-0/+53
handle ConstValue::ByRef in relate fixes #68615 r? @eddyb
2020-05-01Rename `bitcode-in-rlib` option to `embed-bitcode`Alex Crichton-2/+2
This commit finishes work first pioneered in #70458 and started in #71528. The `-C bitcode-in-rlib` option, which has not yet reached stable, is renamed to `-C embed-bitcode` since that more accurately reflects what it does now anyway. Various tests and such are updated along the way as well. This'll also need to be backported to the beta channel to ensure we don't accidentally stabilize `-Cbitcode-in-rlib` as well.
2020-05-01Add new tests and bless old testsLeSeulArtichaut-12/+286
2020-05-01Update stderrs.jumbatm-75/+75
2020-05-01Partially unrevert #70566.jumbatm-111/+128
This partially reverts commit 4b5b6cbe60a8dd1822cfa46c41cf1ad58c113e18, reversing some changes made to 62b362472dbf8bdf43b252ac5ea53b527a8dbee3.
2020-05-01rename InvalidIntPtrUsageRalf Jung-4/+4
2020-05-01bless youRalf Jung-2/+2
2020-05-01Auto merge of #70674 - cjgillot:query-arena-all, r=matthewjasperbors-1/+1
Have the per-query caches store the results on arenas This PR leverages the cache for each query to serve as storage area for the query results. It introduces a new cache `ArenaCache`, which moves the result to an arena, and only stores the reference in the hash map. This allows to remove a sizeable part of the usage of the global `TyCtxt` arena. I only migrated queries that already used arenas before.
2020-04-30Rollup merge of #71688 - ecstatic-morse:const-downcast, r=oli-obkTyler Mandry-29/+4
Allow `Downcast` projections unconditionally in const-checking `ProjectionElem::Downcast` sounds scary, but it's really just the projection we use to access a particular enum variant. They usually appear in the lowering of a `match` statement, so they have been associated with control flow in const-checking, but they don't do any control flow by themselves. We already have a HIR pass that looks for `if` and `match` (even ones that have 1 or fewer reachable branches). That pass is double-checked by a MIR pass that looks for `SwitchInt`s and `FakeRead`s for match scrutinees. In my opinion, there's no need to look for `Downcast` as well. r? @oli-obk
2020-04-30Rollup merge of #71590 - RalfJung:mir-dump-pointers, r=oli-obkTyler Mandry-73/+74
MIR dump: print pointers consistently with Miri output This makes MIR allocation dump pointer printing consistent with Miri output: both use hexadecimal offsets with a `0x` prefix. To save some space, MIR dump replaces the `alloc` prefix by `a` when necessary. I also made AllocId/Pointer printing more consistent in their Debug/Display handling, and adjusted Display printing for Scalar a bit to avoid using decimal printing when we do not know the sign with which to interpret the value (IMO using decimal then is misleading).
2020-04-30Rollup merge of #71465 - oli-obk:is_thread_local_cleanup, r=matthewjasperTyler Mandry-1/+1
Add a convenience method on `TyCtxt` for checking for thread locals This PR extracts the cleanup part of #71192 r? @bjorn3
2020-04-30Rollup merge of #71597 - CohenArthur:refactor-unique-empty, r=shepmasterDylan DPC-2/+2
Rename Unique::empty() -> Unique::dangling() A `FIXME` comment in `src/libcore/ptr/unique.rs` suggested refactoring `Unique::empty()` to `Unique::dangling()` which this PR does.
2020-04-30Rollup merge of #71433 - antoyo:error/missing-right-operand, r=Dylan-DPCDylan DPC-0/+2
Add help message for missing right operand in condition closes #30035
2020-04-30Rollup merge of #70950 - nikomatsakis:leak-check-nll-2, r=matthewjasperDylan DPC-171/+276
extend NLL checker to understand `'empty` combined with universes This PR extends the NLL region checker to understand `'empty` combined with universes. In particular, it means that the NLL region checker no longer considers `exists<R2> { forall<R1> { R1: R2 } }` to be provable. This is work towards https://github.com/rust-lang/rust/issues/59490, but we're not all the way there. One thing in particular it does not address is error messages. The modifications to the NLL region inference code turned out to be simpler than expected. The main change is to require that if `R1: R2` then `universe(R1) <= universe(R2)`. This constraint follows from the region lattice (shown below), because we assume then that `R2` is "at least" `empty(Universe(R2))`, and hence if `R1: R2` (i.e., `R1 >= R2` on the lattice) then `R1` must be in some universe that can name `'empty(Universe(R2))`, which requires that `Universe(R1) <= Universe(R2)`. ``` static ----------+-----...------+ (greatest) | | | early-bound and | | free regions | | | | | scope regions | | | | | empty(root) placeholder(U1) | | / | | / placeholder(Un) empty(U1) -- / | / ... / | / empty(Un) -------- (smallest) ``` I also made what turned out to be a somewhat unrelated change to add a special region to represent `'empty(U0)`, which we use (somewhat hackily) to indicate well-formedness checks in some parts of the compiler. This fixes #68550. I did some investigation into fixing the error message situation. That's a bit trickier: the existing "nice region error" code around placeholders relies on having better error tracing than NLL currently provides, so that it knows (e.g.) that the constraint arose from applying a trait impl and things like that. I feel like I was hoping *not* to do such fine-grained tracing in NLL, and it seems like we...largely...got away with that. I'm not sure yet if we'll have to add more tracing information or if there is some sort of alternative. It's worth pointing out though that I've not kind of shifted my opinion on whose job it should be to enforce lifetimes: I tend to think we ought to be moving back towards *something like* the leak-check (just not the one we *had*). If we took that approach, it would actually resolve this aspect of the error message problem, because we would be resolving 'higher-ranked errors' in the trait solver itself, and hence we wouldn't have to thread as much causal information back to the region checker. I think it would also help us with removing the leak check while not breaking some of the existing crates out there. Regardless, I think it's worth landing this change, because it was relatively simple and it aligns the set of programs that NLL accepts with those that are accepted by the main region checker, and hence should at least *help* us in migration (though I guess we still also have to resolve the existing crates that rely on leak check for coherence). r? @matthewjasper
2020-04-30deduplicate warningsRalf Jung-226/+234
2020-04-30remove no longer needed feature flagsRalf Jung-42/+128
2020-04-30handle ByRef in relateBastian Kauschke-0/+53
2020-04-30A test now fails during check instead of buildOliver Scherer-1/+1
2020-04-30Rollup merge of #71655 - RalfJung:const-pattern-soundness, r=oli-obkDylan DPC-14/+221
Miri: better document and fix dynamic const pattern soundness checks https://github.com/rust-lang/const-eval/issues/42 got me thinking about soundness for consts being used in patterns, and I found a hole in our existing dynamic checks: a const referring to a mutable static *in a different crate* was not caught. This PR fixes that. It also adds some comments that explain which invariants are crucial for soundness of const-patterns. Curiously, trying to weaponize this soundness hole failed: pattern matching compilation ICEd when encountering the cross-crate static, saying "expected allocation ID alloc0 to point to memory". I don't know why that would happen, statics *should* be entirely normal memory for pattern matching to access. r? @oli-obk Cc @rust-lang/wg-const-eval