about summary refs log tree commit diff
path: root/src/test
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-16Rollup merge of #78678 - Nemo157:doc-cfg-w-traits, r=jyn514,GuillaumeGomezMara Bos-0/+124
Add tests and improve rendering of cfgs on traits Shows the additional features required to get the trait implementation, suppressing any already shown on the current page. One interesting effect from this is if you have a cfg-ed type, implementing a cfg-ed trait (so the implementation depends on both cfgs), you will get the inverted pair of cfgs shown on each page: ![image](https://user-images.githubusercontent.com/81079/97904671-207bdc00-1d41-11eb-8144-707e8017d2b6.png) ![image](https://user-images.githubusercontent.com/81079/97904700-27a2ea00-1d41-11eb-8b9f-e925ba339044.png) The hidden items on the trait implementation also now get the correct cfgs displayed on them. Tests are blocked on #78673. fixes #68100 cc #43781
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 #78980 - thiolliere:gui-fix-qpath, r=estebankDylan DPC-0/+16
Fix rustc_ast_pretty print_qpath resulting in invalid macro input related https://github.com/rust-lang/rust/issues/76874 (third case) ### Issue: The input for a procedural macro is incorrect, for the rust code: ```rust mod m { pub trait Tr { type Ts: super::Tu; } } trait Tu { fn dummy() { } } #[may_proc_macro] fn foo() { <T as m::Tr>::Ts::dummy(); } ``` the macro will get the input: ```rust fn foo() { <T as m::Tr>::dummy(); } ``` Thus `Ts` has disappeared. ### Fix: This is due to invalid pretty print of qpath. This PR fix it.
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 #78966 - tmiasko:inline-never, r=oli-obkDylan DPC-39/+219
Never inline C variadics, cold functions, functions with incompatible attributes ... ... and fix generator inlining. Closes #67863. Closes #78859.
2020-11-15Rollup merge of #78962 - poliorcetics:rustdoc-raw-ident-test, r=jyn514Dylan DPC-0/+22
Add a test for r# identifiers I'm not entirely sure I properly ran the test locally (I think so though), waiting for CI to confirm. :) ```````@rustbot``````` modify labels: T-rustdoc r? ```````@jyn514```````
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-3/+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/+263
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-14Add tests and improve rendering of features on traitsWim Looman-0/+124
2020-11-14Auto merge of #78809 - vn-ki:fix-issue-76064, r=oli-obkbors-130/+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/+263
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-13Auto merge of #78683 - Nemo157:issue-78673, r=lcnrbors-0/+24
Check predicates from blanket trait impls while testing if they apply fixes #78673
2020-11-13Log closure as wellAman Arora-215/+716
2020-11-13Auto merge of #78888 - richkadel:llvm-coverage-tests, r=tmandrybors-35/+23
Fix and re-enable two coverage tests on MacOS Note, in the coverage-reports test, the comment about MacOS was wrong. The setting is based on config.toml llvm `optimize` setting. There doesn't appear to be any environment variable I can check, and I don't think we should add one. Testing the binary itself is a more reliable way to check anyway. For the coverage-spanview test, I removed the dependency on sed altogether, which is much less ugly than trying to work around the MacOS sed differences. I tested these changes on Linux, Windows, and Mac. r? `@tmandry` FYI `@wesleywiser`
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 #78984 - GuillaumeGomez:rustdoc-check-option, r=jyn514Guillaume Gomez-0/+143
Rustdoc check option The ultimate goal behind this option would be to have `rustdoc --check` being run when you use `cargo check` as a second step. r? `@jyn514`
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-13Fix wrong XPathAlexis Bourget-4/+6
2020-11-12Ensure that INVALID_CODEBLOCK_ATTRIBUTES lint is emittedGuillaume Gomez-28/+47
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-12./x.py test --blessTomasz MiÄ…sko-36/+184
2020-11-12Never inline C variadic functionsTomasz MiÄ…sko-0/+18
2020-11-12Fix generator inlining by checking for rust-call abi and spread argTomasz MiÄ…sko-0/+16
2020-11-12Never inline when `no_sanitize` attributes differTomasz MiÄ…sko-3/+1
The inliner looks if a sanitizer is enabled before considering `no_sanitize` attribute as possible source of incompatibility. The MIR inlining could happen in a crate with sanitizer disabled, but code generation in a crate with sanitizer enabled, thus the attribute would be incorrectly ignored. To avoid the issue never inline functions with different `no_sanitize` attributes.
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-64/+411
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-12Rollup merge of #76730 - ebkalderon:rustdoc-fix-mut-args-async-fn, r=tmandryMara Bos-2/+15
Fix rustdoc rendering of by-value mutable arguments in async fn r? `@jyn514` Fixes #76517.
2020-11-12cg: add explicit test for const param promotionBastian Kauschke-0/+11
2020-11-12Handle and test wildcard argumentsJoshua Nelson-2/+7
2020-11-12Don't reuse bindings for `ref mut`Joshua Nelson-0/+8
Reusing bindings causes errors later in lowering: ``` error[E0596]: cannot borrow `vec` as mutable, as it is not declared as mutable --> /checkout/src/test/ui/async-await/argument-patterns.rs:12:20 | LL | async fn b(n: u32, ref mut vec: A) { | ^^^^^^^^^^^ | | | cannot borrow as mutable | help: consider changing this to be mutable: `mut vec` ```
2020-11-12check mir exists before validation; fix testsVishnunarayan K I-90/+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-12Auto merge of #76256 - tgnottingham:issue-74890, r=nikomatsakisbors-0/+48
incr-comp: hash and serialize span end line/column Hash both the length and the end location (line/column) of a span. If we hash only the length, for example, then two otherwise equal spans with different end locations will have the same hash. This can cause a problem during incremental compilation wherein a previous result for a query that depends on the end location of a span will be incorrectly reused when the end location of the span it depends on has changed. A similar analysis applies if some query depends specifically on the length of the span, but we only hash the end location. So hash both. Fix #46744, fix #59954, fix #63161, fix #73640, fix #73967, fix #74890, fix #75900 --- See #74890 for a more in-depth analysis. I haven't thought about what other problems this root cause could be responsible for. Please let me know if anything springs to mind. I believe the issue has existed since the inception of incremental compilation.
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-12Add tests for rustdoc --check optionGuillaume Gomez-0/+124