about summary refs log tree commit diff
path: root/src/test/ui
AgeCommit message (Collapse)AuthorLines
2020-11-17Auto merge of #78801 - sexxi-goose:min_capture, r=nikomatsakisbors-2/+1630
RFC-2229: Implement Precise Capture Analysis ### This PR introduces - Feature gate for RFC-2229 (incomplete) `capture_disjoint_field` - Rustc Attribute to print out the capture analysis `rustc_capture_analysis` - Precise capture analysis ### Description of the analysis 1. If the feature gate is not set then all variables that are not local to the closure will be added to the list of captures. (This is for backcompat) 2. The rest of the analysis is based entirely on how the captured `Place`s are used within the closure. Precise information (i.e. projections) about the `Place` is maintained throughout. 3. To reduce the amount of information we need to keep track of, we do a minimization step. In this step, we determine a list such that no Place within this list represents an ancestor path to another entry in the list. Check rust-lang/project-rfc-2229#9 for more detailed examples. 4. To keep the compiler functional as before we implement a Bridge between the results of this new analysis to existing data structures used for closure captures. Note the new capture analysis results are only part of MaybeTypeckTables that is the information is only available during typeck-ing. ### Known issues - Statements like `let _ = x` will make the compiler ICE when used within a closure with the feature enabled. More generally speaking the issue is caused by `let` statements that create no bindings and are init'ed using a Place expression. ### Testing We removed the code that would handle the case where the feature gate is not set, to enable the feature as default and did a bors try and perf run. More information here: #78762 ### Thanks This has been slowly in the works for a while now. I want to call out `@Azhng` `@ChrisPardy` `@null-sleep` `@jenniferwills` `@logmosier` `@roxelo` for working on this and the previous PRs that led up to this, `@nikomatsakis` for guiding us. Closes rust-lang/project-rfc-2229#7 Closes rust-lang/project-rfc-2229#9 Closes rust-lang/project-rfc-2229#6 Closes rust-lang/project-rfc-2229#19 r? `@nikomatsakis`
2020-11-16Rollup merge of #79032 - lcnr:arg-count, r=varkorMara Bos-199/+123
improve type const mismatch errors Doesn't completely remove `check_generic_arg_count` as that would have required some more complex changes but instead checks type and const params in only one step. Also moved the help added by `@JulianKnodt` in #75611 to `generic_arg_mismatch_err`. r? `@varkor` cc `@petrochenkov`
2020-11-16Rollup merge of #78714 - m-ou-se:simplify-local-streams, r=KodrAusMara Bos-37/+11
Simplify output capturing This is a sequence of incremental improvements to the unstable/internal `set_panic` and `set_print` mechanism used by the `test` crate: 1. Remove the `LocalOutput` trait and use `Arc<Mutex<dyn Write>>` instead of `Box<dyn LocalOutput>`. In practice, all implementations of `LocalOutput` were just `Arc<Mutex<..>>`. This simplifies some logic and removes all custom `Sink` implementations such as `library/test/src/helpers/sink.rs`. Also removes a layer of indirection, as the outermost `Box` is now gone. It also means that locking now happens per `write_fmt`, not per individual `write` within. (So `"{} {}\n"` now results in one `lock()`, not four or more.) 2. Since in all cases the `dyn Write`s were just `Vec<u8>`s, replace the type with `Arc<Mutex<Vec<u8>>>`. This simplifies things more, as error handling and flushing can be removed now. This also removes the hack needed in the default panic handler to make this work with `::realstd`, as (unlike `Write`) `Vec<u8>` is from `alloc`, not `std`. 3. Replace the `RefCell`s by regular `Cell`s. The `RefCell`s were mostly used as `mem::replace(&mut *cell.borrow_mut(), something)`, which is just `Cell::replace`. This removes an unecessary bookkeeping and makes the code a bit easier to read. 4. Merge `set_panic` and `set_print` into a single `set_output_capture`. Neither the test crate nor rustc (the only users of this feature) have a use for using these separately. Merging them simplifies things even more. This uses a new function name and feature name, to make it clearer this is internal and not supposed to be used by other crates. Might be easier to review per commit.
2020-11-16improve error message for const ty param mismatchBastian Kauschke-195/+119
2020-11-15Rollup merge of #79016 - fanzier:underscore-expressions, r=petrochenkovJonas Schievink-43/+210
Make `_` an expression, to discard values in destructuring assignments This is the third and final step towards implementing destructuring assignment (RFC: rust-lang/rfcs#2909, tracking issue: #71126). This PR is the third and final part of #71156, which was split up to allow for easier review. With this PR, an underscore `_` is parsed as an expression but is allowed *only* on the left-hand side of a destructuring assignment. There it simply discards a value, similarly to the wildcard `_` in patterns. For instance, ```rust (a, _) = (1, 2) ``` will simply assign 1 to `a` and discard the 2. Note that for consistency, ``` _ = foo ``` is also allowed and equivalent to just `foo`. Thanks to ````@varkor```` who helped with the implementation, particularly around pre-expansion gating. r? ````@petrochenkov````
2020-11-15Rollup merge of #78969 - tmiasko:normalize, r=davidtwcoDylan DPC-8/+14
Normalize function type during validation During inlining, the callee body is normalized and has types revealed, but some of locals corresponding to the arguments might come from the caller body which is not. As a result the caller body does not pass validation without additional normalization. Closes #78442.
2020-11-15Rollup merge of #78948 - slanterns:master, r=varkorDylan DPC-0/+7
test: add `()=()=()=...` to weird-exprs.rs Idea from https://github.com/rust-lang/rust/pull/71156#discussion_r410953972 😄 Builds on nightly since https://github.com/rust-lang/rust/pull/78748 has been merged.
2020-11-15Rollup merge of #78856 - mark-i-m:fix-or-pat-ice, r=matthewjasperDylan DPC-0/+65
Explicitly checking for or-pattern before test Fixes https://github.com/rust-lang/rust/issues/72680 cc https://github.com/rust-lang/rust/issues/54883 r? ````@varkor````
2020-11-15Rollup merge of #78848 - DevJPM:ci-llvm-9, r=nikicDylan DPC-1/+0
Bump minimal supported LLVM version to 9 This bumps the minimal tested llvm version to 9. This should enable supporting newer LLVM features (and CPU extensions). This was motived by #78361 having to drop features because of LLVM 8 not supporting certain CPU extensions yet. This was declared relatively uncontroversial on [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Min.20Supported.20LLVM.20Upgrade.20Process.3F/near/215957859). Paging ````@eddyb```` because there was a comment in the [dockerfile](https://github.com/rust-lang/rust/blob/master/src/ci/docker/host-x86_64/x86_64-gnu-llvm-8/Dockerfile#L42) describing a hack (which I don't quite understand) which was also blocked by not having LLVM 9.
2020-11-15Rollup merge of #78590 - DeveloperC286:issue_60302, r=varkorDylan DPC-1/+1
refactor: removing alloc::collections::vec_deque ignore-tidy-filelength This PR removes the need for ignore-tidy-filelength for alloc::collections::vec_deque which is part of the issue https://github.com/rust-lang/rust/issues/60302 It is probably easiest to review this PR by looking at it commit by commit rather than looking at the overall diff.
2020-11-14Auto merge of #79049 - tmiasko:lower-intrinsics, r=jonas-schievinkbors-5/+0
Lower intrinsics calls: forget, size_of, unreachable, wrapping_* This allows constant propagation to evaluate `size_of` and `wrapping_*`, and unreachable propagation to propagate a call to `unreachable`. The lowering is performed as a MIR optimization, rather than during MIR building to preserve the special status of intrinsics with respect to unsafety checks and promotion. Currently enabled by default to determine the performance impact (no significant impact expected). In practice only useful when combined with inlining since intrinsics are rarely used directly (with exception of `unreachable` and `discriminant_value` used by built-in derive macros). Closes #32716.
2020-11-14Auto merge of #78809 - vn-ki:fix-issue-76064, r=oli-obkbors-129/+42
add error_occured field to ConstQualifs, fix #76064 I wasn't sure what `in_return_place` actually did and not sure why it returns `ConstQualifs` while it's sibling functions return `bool`. So I tried to make as minimal changes to the structure as possible. Please point out whether I have to refactor it or not. r? `@oli-obk` cc `@RalfJung`
2020-11-14Add underscore expressions for destructuring assignmentsFabian Zaiser-43/+210
Co-authored-by: varkor <github@varkor.com>
2020-11-14Style nitWho? Me?!-1/+1
Co-authored-by: matthewjasper <20113453+matthewjasper@users.noreply.github.com>
2020-11-14Lower intrinsics calls: forget, size_of, unreachable, wrapping_*Tomasz MiÄ…sko-5/+0
This allows constant propagation to evaluate `size_of` and `wrapping_*`, and unreachable propagation to propagate a call to `unreachable`. The lowering is performed as a MIR optimization, rather than during MIR building to preserve the special status of intrinsics with respect to unsafety checks and promotion.
2020-11-13Log closure as wellAman Arora-215/+716
2020-11-13lessen restriction in `check_kind_count`Bastian Kauschke-8/+8
2020-11-13refactor: vec_deque ignore-tidy-filelengthC-1/+1
commit c547d5fabcd756515afa7263ee5304965bb4c497 Author: C <DeveloperC@protonmail.com> Date: Sat Oct 31 11:22:23 2020 +0000 test: updating ui/hygiene/panic-location.rs expected commit 2af03769c4ffdbbbad75197a1ad0df8c599186be Author: C <DeveloperC@protonmail.com> Date: Sat Oct 31 10:43:30 2020 +0000 fix: documentation unresolved link commit c4b0df361ce27d7392d8016229f2e0265af32086 Author: C <DeveloperC@protonmail.com> Date: Sat Oct 31 02:58:31 2020 +0000 style: compiling with Rust's style guidelines commit bdd2de5f3c09b49a18e3293f2457fcab25557c96 Author: C <DeveloperC@protonmail.com> Date: Sat Oct 31 02:56:31 2020 +0000 refactor: removing ignore-tidy-filelength commit fcc4b3bc41f57244c65ebb8e4efe4cbc9460b5a9 Author: C <DeveloperC@protonmail.com> Date: Sat Oct 31 02:51:35 2020 +0000 refactor: moving trait RingSlices to ring_slices.rs commit 2f0cc539c06d8841baf7f675168f68ca7c21e68e Author: C <DeveloperC@protonmail.com> Date: Sat Oct 31 02:46:09 2020 +0000 refactor: moving struct PairSlices to pair_slices.rs commit a55d3ef1dab4c3d85962b3a601ff8d1f7497faf2 Author: C <DeveloperC@protonmail.com> Date: Sat Oct 31 02:31:45 2020 +0000 refactor: moving struct Iter to iter.rs commit 76ab33a12442a03726f36f606b4e0fe70f8f246b Author: C <DeveloperC@protonmail.com> Date: Sat Oct 31 02:24:32 2020 +0000 refactor: moving struct IntoIter into into_iter.rs commit abe0d9eea2933881858c3b1bc09df67cedc5ada5 Author: C <DeveloperC@protonmail.com> Date: Sat Oct 31 02:19:07 2020 +0000 refactor: moving struct IterMut into iter_mut.rs commit 70ebd6420335e1895e2afa2763a0148897963e24 Author: C <DeveloperC@protonmail.com> Date: Sat Oct 31 01:49:15 2020 +0000 refactor: moved macros into macros.rs commit b08dd2add994b04ae851aa065800bd8bd6326134 Author: C <DeveloperC@protonmail.com> Date: Sat Oct 31 01:05:36 2020 +0000 refactor: moving vec_deque.rs to vec_deque/mod.rs
2020-11-13Rollup merge of #78996 - lcnr:cg-promotion, r=RalfJungGuillaume Gomez-0/+11
add explicit test for const param promotion r? `@RalfJung`
2020-11-13Rollup merge of #78985 - lcnr:cg-drop-test, r=nikomatsakisGuillaume Gomez-28/+61
add dropck test for const params r? `@nikomatsakis` or `@varkor`
2020-11-13Rollup merge of #77151 - rust-lang:LeSeulArtichaut-patch-1, r=pnkfelixGuillaume Gomez-0/+16
Add regression test for issue #76042 Originally posted in https://github.com/rust-lang/rust/issues/76042#issuecomment-683272710. r? `@pnkfelix`
2020-11-12Normalize function type during validationTomasz MiÄ…sko-8/+14
During inlining, the callee body is normalized and has types revealed, but some of locals corresponding to the arguments might come from the caller body which is not. As a result the caller body does not pass validation without additional normalization.
2020-11-12Rollup merge of #78987 - lcnr:integer-sizes, r=varkorMara Bos-5/+94
extend min_const_generics param ty tests Apparently we never tested for `u128` and `i128` before this, so I added a test for all types which are allowed. r? ``@varkor``
2020-11-12Rollup merge of #78836 - fanzier:struct-and-slice-destructuring, r=petrochenkovMara Bos-63/+410
Implement destructuring assignment for structs and slices This is the second step towards implementing destructuring assignment (RFC: rust-lang/rfcs#2909, tracking issue: #71126). This PR is the second part of #71156, which was split up to allow for easier review. Note that the first PR (#78748) is not merged yet, so it is included as the first commit in this one. I thought this would allow the review to start earlier because I have some time this weekend to respond to reviews. If ``@petrochenkov`` prefers to wait until the first PR is merged, I totally understand, of course. This PR implements destructuring assignment for (tuple) structs and slices. In order to do this, the following *parser change* was necessary: struct expressions are not required to have a base expression, i.e. `Struct { a: 1, .. }` becomes legal (in order to act like a struct pattern). Unfortunately, this PR slightly regresses the diagnostics implemented in #77283. However, it is only a missing help message in `src/test/ui/issues/issue-77218.rs`. Other instances of this diagnostic are not affected. Since I don't exactly understand how this help message works and how to fix it yet, I was hoping it's OK to regress this temporarily and fix it in a follow-up PR. Thanks to ``@varkor`` who helped with the implementation, particularly around the struct rest changes. r? ``@petrochenkov``
2020-11-12cg: add explicit test for const param promotionBastian Kauschke-0/+11
2020-11-12check mir exists before validation; fix testsVishnunarayan K I-89/+18
2020-11-12fix tests and formattingVishnunarayan K I-40/+8
2020-11-12add error_occured field to ConstQualifs, fix #76064Vishnunarayan K I-0/+16
2020-11-12extend min_const_generics param ty testsBastian Kauschke-5/+94
2020-11-12check `Drop` specialization of const paramsBastian Kauschke-28/+61
2020-11-12move dropck tests from ui -> ui/dropckBastian Kauschke-0/+0
2020-11-12fully exploited the dropped support of LLVM 8DevJPM-1/+0
This commit grepped for LLVM_VERSION_GE, LLVM_VERSION_LT, get_major_version and min-llvm-version and statically evaluated every expression possible (and sensible) assuming that the LLVM version is >=9 now
2020-11-12Rollup merge of #78960 - ethanboxx:const-gen-test-default-error, r=lcnrGuillaume Gomez-0/+28
Test default values for const parameters. The last topic on #78433 I originally intended to place these tests in a single file, however, due to them being parser errors that are fatal, they must be in separate files to be detected. Thanks, ``@lcnr`` for mentoring me on this PR. r? ``@lcnr``
2020-11-12Rollup merge of #78916 - lcnr:const-generics-tests, r=varkorGuillaume Gomez-0/+954
extend const generics test suite should implement most of #78433, especially all parts of [the hackmd](https://hackmd.io/WnFmN4MjRCqAjGmYfYcu2A?view) which I did not explicitly mention in that issue. r? ``@varkor``
2020-11-12Rename empty_tuple_assignment to monkey_barrelSlanterns-2/+2
2020-11-12Auto merge of #78782 - petrochenkov:nodoctok, r=Aaron1011bors-2/+2
Do not collect tokens for doc comments Doc comment is a single token and AST has all the information to re-create it precisely. Doc comments are also responsible for majority of calls to `collect_tokens` (with `num_calls == 1` and `num_calls == 0`, cc https://github.com/rust-lang/rust/pull/78736). (I also moved token collection into `fn parse_attribute` to deduplicate code a bit.) r? `@Aaron1011`
2020-11-11default_trait_paramEthan Brierley-0/+14
2020-11-11Add test `default_function_param`Ethan Brierley-0/+14
2020-11-11Rollup merge of #78832 - lcnr:const-evaluatable-unevaluated, r=oli-obkJonas Schievink-0/+61
look at assoc ct, check the type of nodes an example where types matter are function objects, see the added test which previously passed. Now does a shallow comparison of unevaluated constants. r? ```@oli-obk```
2020-11-11test: add `()=()=()=...` to weird-exprs.rsSlanterns-0/+7
2020-11-11Implement destructuring assignment for structs and slicesFabian Zaiser-63/+410
Co-authored-by: varkor <github@varkor.com>
2020-11-10Add test for capturing enumsAman Arora-0/+134
2020-11-10Address review comments 2Aman Arora-27/+27
2020-11-10More pattern testcasesAman Arora-63/+314
2020-11-10Reduce verbosity of capture analysis logsRoxane Fruytier-876/+218
Co-authored-by: Jenny Wills <wills.jenniferg@gmail.com> Co-authored-by: Aman Arora <me@aman-arora.com>
2020-11-10Update tests with min capture informationAman Arora-0/+454
Co-authored-by: Chris Pardy <chrispardy36@gmail.com> Co-authored-by: Logan Mosier <logmosier@gmail.com>
2020-11-10Add helper function for Capture Esclations and expressionsAman Arora-2/+9
Co-authored-by: Dhruv Jauhar <dhruvjhr@gmail.com>
2020-11-10Add initial set of testcases for RFC 2229Aman Arora-2/+907
Co-authored-by: Dhruv Jauhar <dhruvjhr@gmail.com>
2020-11-10Indroduce feature flag for RFC-2229Aman Arora-0/+34
Signed-off-by: Aman Arora <me@aman-arora.com>
2020-11-10Use Places to express closure/generator CapturesAman Arora-2/+2
Co-authored-by: Archer Zhang <archer.xn@gmail.com>