about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2019-06-25Auto merge of #61572 - Aaron1011:fix/generator-ref, r=varkorbors-0/+34
Fix HIR visit order Fixes #61442 When rustc::middle::region::ScopeTree computes its yield_in_scope field, it relies on the HIR visitor order to properly compute which types must be live across yield points. In order for the computed scopes to agree with the generated MIR, we must ensure that expressions evaluated before a yield point are visited before the 'yield' expression. However, the visitor order for ExprKind::AssignOp was incorrect. The left-hand side of a compund assignment expression is evaluated before the right-hand side, but the right-hand expression was being visited before the left-hand expression. If the left-hand expression caused a new type to be introduced (e.g. through a deref-coercion), the new type would be incorrectly seen as occuring *after* the yield point, instead of before. This leads to a mismatch between the computed generator types and the MIR, since the MIR will correctly see the type as being live across the yield point. To fix this, we correct the visitor order for ExprKind::AssignOp to reflect the actual evaulation order.
2019-06-24Auto merge of #62081 - RalfJung:miri-pointer-checks, r=oli-obkbors-3/+3
Refactor miri pointer checks Centralize bounds, alignment and NULL checking for memory accesses in one function: `memory.check_ptr_access`. That function also takes care of converting a `Scalar` to a `Pointer`, should that be needed. Not all accesses need that though: if the access has size 0, `None` is returned. Everyone accessing memory based on a `Scalar` should use this method to get the `Pointer` they need. All operations on the `Allocation` work on `Pointer` inputs and expect all the checks to have happened (and will ICE if the bounds are violated). The operations on `Memory` work on `Scalar` inputs and do the checks themselves. The only other public method to check pointers is `memory.ptr_may_be_null`, which is needed in a few places. No need for `check_align` or similar methods. That makes the public API surface much easier to use and harder to mis-use. This should be largely no-functional-change, except that ZST accesses to a "true" pointer that is dangling or out-of-bounds are now considered UB. This is to be conservative wrt. whatever LLVM might be doing. While I am at it, this also removes the assumption that the vtable part of a `dyn Trait`-fat-pointer is a `Pointer` (as opposed to a pointer cast to an integer, stored as raw bits). r? @oli-obk
2019-06-23Auto merge of #61778 - petrochenkov:pass, r=Mark-Simulacrumbors-429/+330
compiletest: Introduce `// {check,build,run}-pass` pass modes Pass UI tests now have three modes ``` // check-pass // build-pass // run-pass ``` mirroring equivalent well-known `cargo` commands. `// check-pass` will compile the test skipping codegen (which is expensive and isn't supposed to fail in most cases). `// build-pass` will compile and link the test without running it. `// run-pass` will compile, link and run the test. Tests without a "pass" annotation are still considered "fail" tests. Most UI tests would probably want to switch to `check-pass`. Tests validating codegen would probably want to run the generated code as well and use `run-pass`. `build-pass` should probably be rare (linking tests?). https://github.com/rust-lang/rust/pull/61755 will provide a way to run the tests with any mode, e.g. bump `check-pass` tests to `run-pass` to satisfy especially suspicious people, and be able to make sure that codegen doesn't breaks in some entirely unexpected way. Tests marked with any mode are expected to pass with any other mode, if that's not the case for some legitimate reason, then the test should be made a "fail" test rather than a "pass" test. Perhaps some secondary CI can verify this invariant, but that's not super urgent. `// compile-pass` still works and is equivalent to `build-pass`. Why is `// compile-pass` bad - 1) it gives an impression that the test is only compiled, but not linked, 2) it doesn't mirror a cargo command. It can be removed some time in the future in a separate PR. cc https://github.com/rust-lang/rust/issues/61712
2019-06-23comment tweaks, better validation errors, update UI testsRalf Jung-3/+3
2019-06-23Auto merge of #60861 - Centril:let-chains-ast-intro, r=petrochenkovbors-215/+2007
[let_chains, 2/6] Introduce `Let(..)` in AST, remove IfLet + WhileLet and parse let chains Here we remove `ast::ExprKind::{IfLet, WhileLet}` and introduce `ast::ExprKind::Let`. Moreover, we also: + connect the parsing logic for let chains + introduce the feature gate + rewire HIR lowering a bit. However, this does not connect the new syntax to semantics in HIR. That will be the subject of a subsequent PR. Per https://github.com/rust-lang/rust/issues/53667#issuecomment-471583239. Next step after https://github.com/rust-lang/rust/pull/59288. cc @Manishearth re. Clippy. r? @oli-obk
2019-06-23Rollup merge of #62068 - ia0:fix_meta_var, r=petrochenkovMazdak Farrokhzad-1/+1
Fix meta-variable binding errors in macros The errors are either: - The meta-variable used in the right-hand side is not bound (or defined) in the left-hand side. - The meta-variable used in the right-hand side does not repeat with the same kleene operator as its binder in the left-hand side. Either it does not repeat enough, or it uses a different operator somewhere. This change should have no semantic impact. Found by https://github.com/rust-lang/rust/pull/62008
2019-06-23Rollup merge of #62051 - Centril:unused-derive-, r=petrochenkovMazdak Farrokhzad-14/+14
Lint empty `#[derive()]` as unused attribute. Closes https://github.com/rust-lang/rust/issues/54651. cc https://github.com/rust-lang/rust/issues/55112 r? @petrochenkov
2019-06-23Rollup merge of #62047 - Centril:cfg-attr-empty-lint, r=estebankMazdak Farrokhzad-0/+34
Trigger `unused_attribute` lint on `#[cfg_attr($pred,)]` Lint on `#[cfg_attr($pred,)]` as decided in https://github.com/rust-lang/rust/issues/54881#issuecomment-441442173. Closes https://github.com/rust-lang/rust/issues/54881. r? @estebank
2019-06-23Fix meta-variable binding errors in macrosJulien Cretin-1/+1
The errors are either: - The meta-variable used in the right-hand side is not bound (or defined) in the left-hand side. - The meta-variable used in the right-hand side does not repeat with the same kleene operator as its binder in the left-hand side. Either it does not repeat enough, or it uses a different operator somewhere. This change should have no semantic impact.
2019-06-23let_chains: Add test cases to pprust-expr-roundtrip.Mazdak Farrokhzad-23/+32
2019-06-23let_chains: --bless tests due to recovery in lowering.Mazdak Farrokhzad-94/+905
2019-06-23let_chains: Adjust tests for pre-expansion gating.Mazdak Farrokhzad-62/+103
2019-06-23let_chains: Account for const generics in validation tests.Mazdak Farrokhzad-54/+123
2019-06-23let_chains: scrutinee -> head expression.Mazdak Farrokhzad-4/+4
2019-06-23let_chains: Comment out Let in ident_can_begin_expr.Mazdak Farrokhzad-5/+6
2019-06-23let_chains: Test pretty output for simple stable if-let.Mazdak Farrokhzad-0/+16
2019-06-23let_chains: Remove redundant tests in syntax-ambiguity-*.rs.Mazdak Farrokhzad-188/+0
2019-06-23let_chains: Add test protecting the precedence of && in relation to other ↵Mazdak Farrokhzad-0/+18
things.
2019-06-23let_chains: Adjust unnecessary parens tests.Mazdak Farrokhzad-4/+4
2019-06-23let_chains: Add feature gate tests.Mazdak Farrokhzad-0/+380
2019-06-23let_chains: Add tests for places where let expressions aren't allowed.Mazdak Farrokhzad-0/+635
2019-06-22Move run-pass test to run-pass/generatorAaron Hill-0/+6
2019-06-22Change how we compute yield_in_scopeAaron Hill-0/+16
Compound operators (e.g. 'a += b') have two different possible evaluation orders. When the left-hand side is a primitive type, the expression is evaluated right-to-left. However, when the left-hand side is a non-primitive type, the expression is evaluated left-to-right. This causes problems when we try to determine if a type is live across a yield point. Since we need to perform this computation before typecheck has run, we can't simply check the types of the operands. This commit calculates the most 'pessimistic' scenario - that is, erring on the side of treating more types as live, rather than fewer. This is perfectly safe - in fact, this initial liveness computation is already overly conservative (e.g. issue #57478). The important thing is that we compute a superset of the types that are actually live across yield points. When we generate MIR, we'll determine which types actually need to stay live across a given yield point, and which ones cam actually be dropped. Concretely, we force the computed HIR traversal index for right-hand-side yield expression to be equal to the maximum index for the left-hand side. This covers both possible execution orders: * If the expression is evalauted right-to-left, our 'pessismitic' index is unecessary, but safe. We visit the expressions in an ExprKind::AssignOp from right to left, so it actually would have been safe to do nothing. However, while increasing the index of a yield point might cause the compiler to reject code that could actually compile, it will never cause incorrect code to be accepted. * If the expression is evaluated left-to-right, our 'pessimistic' index correctly ensures that types in the left-hand-side are seen as occuring before the yield - which is exactly what we want
2019-06-22Fix HIR visit orderAaron Hill-0/+12
Fixes #61442 When rustc::middle::region::ScopeTree ccomputes its yield_in_scope field, it relies on the HIR visitor order to properly compute which types must be live across yield points. In order for the computed scopes to agree with the generated MIR, we must ensure that expressions evaluated before a yield point are visited before the 'yield' expression. However, the visitor order for ExprKind::AssignOp was incorrect. The left-hand side of a compund assignment expression is evaluated before the right-hand side, but the right-hand expression was being visited before the left-hand expression. If the left-hand expression caused a new type to be introduced (e.g. through a deref-coercion), the new type would be incorrectly seen as occuring *after* the yield point, instead of before. This leads to a mismatch between the computed generator types and the MIR, since the MIR will correctly see the type as being live across the yield point. To fix this, we correct the visitor order for ExprKind::AssignOp to reflect the actual evaulation order.
2019-06-22Lint empty 'derive()' as unused attribute.Mazdak Farrokhzad-14/+14
2019-06-22Add test for linting on 'cfg_attr(,)'.Mazdak Farrokhzad-0/+34
2019-06-22Auto merge of #62010 - ecstatic-morse:kill-borrows-of-proj, r=pnkfelixbors-0/+164
Kill conflicting borrows of places with projections. Resolves #62007. Due to a bug, the previous version of this check did not actually kill all conflicting borrows unless the borrowed place had no projections. Specifically, `sets.on_entry` will always be empty when `statement_effect` is called. It does not contain the set of borrows which are live at this point in the program. @pnkfelix describes why this was not caught before in #62007, and created an example where the current borrow checker failed unnecessarily. This PR adds their example as a test, but they will likely want to add some additional ones. r? @pnkfelix
2019-06-22Rollup merge of #62016 - JohnTitor:add-test-for-issue-27697, r=alexcrichtonMazdak Farrokhzad-0/+21
Add test for issue-27697 Closes #27697
2019-06-22Rollup merge of #61984 - ljedrz:more_node_id_pruning, r=ZoxcMazdak Farrokhzad-1/+1
More NodeId pruning Just another round of the `HirId`ification initiative. r? @Zoxc
2019-06-22Rollup merge of #61681 - asfreitas:addSendTrait, r=estebankMazdak Farrokhzad-14/+14
Changed the error message to more clearly explain what is allowed This is in regard to #61634. I changed the language to make it more clear what is allowed.
2019-06-22adding in these files that didn't get added in previous commitAndrew-7/+7
2019-06-21changed expected output in tests so it now passes with changed outputAndrew-7/+7
2019-06-21Add test checking our behavior for assigning over a `ConstIndex` projection.Felix S. Klock II-0/+59
2019-06-21Add test that our handling of projections hasn't gone too far:Felix S. Klock II-0/+52
overwriting one field should not allow reborrow of an unrelated field.
2019-06-21Added test for deref projection.Felix S. Klock II-0/+27
2019-06-21add comment outlining test.Felix S. Klock II-0/+5
2019-06-21rename file because I found the old filename too long and unwieldy.Felix S. Klock II-0/+0
2019-06-21Auto merge of #61959 - oli-obk:const_field_ice, r=eddybbors-0/+17
Fix a hash collision issue on the `const_field` query fixes #61530
2019-06-21Add test for issue-27697Yuki Okushi-0/+21
2019-06-20Auto merge of #60293 - nagisa:rustdoc-all-the-auto-traits, r=eddybbors-3/+15
rustdoc: generate implementors for all auto traits Previously we would only generate a list of synthetic implementations for two well known traits – Send and Sync. With this patch all the auto traits known to rustc are considered. This includes such traits like Unpin and user’s own traits. Sadly the implementation still iterates through the list of crate items and checks them against the traits, which for non-std crates containing their own auto-traits will still not include types defined in std/core. It is an improvement nontheless.
2019-06-20Kill conflicting borrows of places with projections.Dylan MacKenzie-0/+21
Resolves #62007. Due to a bug, the previous version of this check did not actually kill any conflicting borrows unless the borrowed place had no projections. Specifically, `entry_set` will always be empty when `statement_effect` is called. It does not contain the set of borrows which are live at this point in the program.
2019-06-20Rollup merge of #62000 - JohnTitor:add-test-issue-54189, r=cramertjMazdak Farrokhzad-0/+15
Add test for issue-54189 Closes #54189
2019-06-21Add test for issue-54189Yuki Okushi-0/+15
2019-06-20rustc_mir: support type parameters by printing them as `_`.Eduard-Mihai Burtescu-0/+19
2019-06-20rustdoc: generate implementors for all auto traitsSimonas Kazlauskas-3/+15
Previously we would only generate a list of synthetic implementations for two well known traits – Send and Sync. With this patch all the auto traits known to rustc are considered. This includes such traits like Unpin and user’s own traits. Sadly the implementation still iterates through the list of crate items and checks them against the traits, which for non-std crates containing their own auto-traits will still not include types defined in std/core. It is an improvement nontheless.
2019-06-20rename hir::map::get_by_hir_id to getljedrz-1/+1
2019-06-20Rollup merge of #61782 - Electron-libre:suggest_tuple_struct_syntax, r=estebankMazdak Farrokhzad-4/+12
suggest tuple struct syntax refs #57242
2019-06-20Auto merge of #60341 - mtak-:macos-tlv-workaround, r=alexcrichtonbors-14/+12
macos tlv workaround fixes: #60141 Includes: * remove dead code: `requires_move_before_drop`. This hasn't been needed for a while now (oops I should have removed it in #57655) * redox had a copy of `fast::Key` (not sure why?). That has been removed. * Perform a `read_volatile` on OSX to reduce `tlv_get_addr` calls per `__getit` from (4-2 depending on context) to 1. `tlv_get_addr` is relatively expensive (~1.5ns on my machine). Previously, in contexts where `__getit` was inlined, 4 calls to `tlv_get_addr` were performed per lookup. For some reason when `__getit` is not inlined this is reduced to 2x - and performance improves to match. After this PR, I have only ever seen 1x call to `tlv_get_addr` per `__getit`, and macos now benefits from situations where `__getit` is inlined. I'm not sure if the `read_volatile(&&__KEY)` trick is working around an LLVM bug, or a rustc bug, or neither. r? @alexcrichton
2019-06-19Auto merge of #61947 - estebank:ice-ice-revolution, r=matthewjasperbors-0/+33
Fix ICE involving mut references Fix #61623, fix #61944, fix #61751.
2019-06-19fix compile-fail test for targets without thread localstyler-4/+3