about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2020-11-24Apply suggestions from code reviewRich Kadel-1/+1
Co-authored-by: Wesley Wiser <wwiser@gmail.com>
2020-11-24Check for LLVM 11+ when using `-Z instrument-coverage`Rich Kadel-2/+30
* `rustc` should now compile under LLVM 9 or 10 * Compiler generates an error if `-Z instrument-coverage` is specified but LLVM version is less than 11 * Coverage tests that require `-Z instrument-coverage` and run codegen should be skipped if LLVM version is less than 11
2020-11-23Upgrades the coverage map to Version 4Rich Kadel-1/+10
Changes the coverage map injected into binaries compiled with `-Zinstrument-coverage` to LLVM Coverage Mapping Format, Version 4 (from Version 3). Note, binaries compiled with this version will require LLVM tools from at least LLVM Version 11.
2020-11-23Auto merge of #79345 - jonas-schievink:rollup-1yhhzx9, r=jonas-schievinkbors-1/+144
Rollup of 10 pull requests Successful merges: - #76829 (stabilize const_int_pow) - #79080 (MIR visitor: Don't treat debuginfo field access as a use of the struct) - #79236 (const_generics: assert resolve hack causes an error) - #79287 (Allow using generic trait methods in `const fn`) - #79324 (Use Option::and_then instead of open-coding it) - #79325 (Reduce boilerplate with the `?` operator) - #79330 (Fix typo in comment) - #79333 (doc typo) - #79337 (Use Option::map instead of open coding it) - #79343 (Add my (`@flip1995)` work mail to the mailmap) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2020-11-23Rollup merge of #79287 - jonas-schievink:const-trait-impl, r=oli-obkJonas Schievink-0/+144
Allow using generic trait methods in `const fn` Next step for https://github.com/rust-lang/rust/issues/67792, this now also allows code like the following: ```rust struct S; impl const PartialEq for S { fn eq(&self, _: &S) -> bool { true } } const fn equals_self<T: PartialEq>(t: &T) -> bool { *t == *t } pub const EQ: bool = equals_self(&S); ``` This works by threading const-ness of trait predicates through trait selection, in particular through `ParamCandidate`, and exposing it in the resulting `ImplSource`. Since this change makes two bounds `T: Trait` and `T: ?const Trait` that only differ in their const-ness be treated like different bounds, candidate winnowing has been changed to drop the `?const` candidate in favor of the const candidate, to avoid ambiguities when both a const and a non-const bound is present.
2020-11-23Rollup merge of #76829 - tspiteri:const-int-pow, r=oli-obkJonas Schievink-1/+0
stabilize const_int_pow This also requires stabilizing constctlz for const ctlz_nonzero.
2020-11-23Auto merge of #79186 - JulianKnodt:str_from, r=Mark-Simulacrumbors-0/+10
Change slice::to_vec to not use extend_from_slice I saw this [Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/String.3A.3Afrom%28.26str%29.20wonky.20codegen/near/216164455), and didn't see any update from it, so I thought I'd try to fix it. This converts `to_vec` to no longer use `extend_from_slice`, but relies on knowing that the allocated capacity is the same size as the input. [Godbolt new v1](https://rust.godbolt.org/z/1bcWKG) [Godbolt new v2 w/ drop guard](https://rust.godbolt.org/z/5jn76K) [Godbolt old version](https://rust.godbolt.org/z/e4ePav) After some amount of iteration, there are now two specializations for `to_vec`, one for `Copy` types that use memcpy, and one for clone types which is the original from this PR. This is then used inside of `impl<T: Clone> FromIterator<Iter::Slice<T>> for Vec<T>` which is essentially equivalent to `&[T] -> Vec<T>`, instead of previous specialization of the `extend` function. This is because extend has to reason more about existing capacity by calling `reserve` on an existing vec, and thus produces worse asm. Downsides: This allocates the exact capacity, so I think if many items are added to this `Vec` after, it might need to allocate whereas extending may not. I also noticed the number of faults went up in the benchmarks, but not sure where from exactly.
2020-11-23Auto merge of #76226 - CDirkx:const-ipaddr, r=dtolnaybors-0/+13
Stabilize `IpAddr::is_ipv4` and `is_ipv6` as const Insta-stabilize the methods `is_ipv4` and `is_ipv6` of `std::net::IpAddr` as const, in the same way as [PR#76198](https://github.com/rust-lang/rust/pull/76198). Possible because of the recent stabilization of const control flow. Part of #76225 and #76205.
2020-11-23stabilize const_int_powTrevor Spiteri-1/+0
Also stabilize constctlz for const ctlz_nonzero. The public methods stabilized const by this commit are: * `{i*,u*}::checked_pow` * `{i*,u*}::saturating_pow` * `{i*,u*}::wrapping_pow` * `{i*,u*}::overflowing_pow` * `{i*,u*}::pow` * `u*::next_power_of_two` * `u*::checked_next_power_of_two` * `u*::wrapping_next_power_of_two` (the method itself is still unstable)
2020-11-23Stabilize `IpAddr::is_ipv4` and `is_ipv6` as constChristiaan Dirkx-0/+13
Insta-stabilize the methods `is_ipv4` and `is_ipv6` of `IpAddr`. Possible because of the recent stabilization of const control flow. Also adds a test for these methods in a const context.
2020-11-22Change slice::to_vec to not use extend_from_slicekadmin-0/+10
This also required adding a loop guard in case clone panics Add specialization for copy There is a better version for copy, so I've added specialization for that function and hopefully that should speed it up even more. Switch FromIter<slice::Iter> to use `to_vec` Test different unrolling version for to_vec Revert to impl From benchmarking, it appears this version is faster
2020-11-22Rollup merge of #79293 - Havvy:test-eval-order-compound-assign, ↵Mara Bos-0/+76
r=Mark-Simulacrum Add test for eval order for a+=b Yes, the order of evaluation *does* change depending on the types of the operands. Cursed, I know. I've elected to place this test into `expr/compound-assignment` creating both the `expr` directory and the `compound-assignment` directory. I plan in a future PR to also move the `if` directory and the loose `if` tests into `expr/if` and other similar cleanups of the `test/ui` directory. Future work: Test more than just `+=`, but all operators. I don't know if using a macro to generate these tests cases would be okay or not, but it'd be boilerplatey without it. I'm also confident you cannot change the evaluation order of one operator without changing all of them. Future work: Additionally, test more than just `i32 += i32` for the primitive version. I don't actually know the full set of primitive implementations, but I imagine there's enough to cause a combinatorial explosion with the previous future work item. Somewhere on the order of one to two hundred individual functions.
2020-11-22Rollup merge of #77697 - WaffleLapkin:iter_split_adaptors, r=m-ou-seMara Bos-3/+5
Split each iterator adapter and source into individual modules This PR creates individual modules for each iterator adapter and iterator source. This is done to enhance the readability of corresponding modules (`adapters/mod.rs` and `sources.rs`) which were hard to navigate and read because of lots of repeated lines (e.g.: `adapters/mod.rs` was 3k lines long). This is also in line with some adapters which already had their own modules (`Flatten`, `FlatMap`, `Chain`, `Zip`, `Fuse`). This PR also makes `Take`s adapter fields private (I have no idea why they were `pub(super)` before). r? ``@LukasKalbertodt``
2020-11-22Auto merge of #79243 - Nadrieril:consolidate-tests, r=varkorbors-665/+907
Consolidate exhaustiveness-related tests I hunted for tests that only exercised the match exhaustiveness algorithm and regrouped them. I also improved integer-range tests since I had found them lacking while hacking around. The interest is mainly so that one can pass `--test-args patterns` and catch most relevant tests. r? `@varkor` `@rustbot` modify labels: +A-exhaustiveness-checking
2020-11-22Rollup merge of #79302 - est31:issue_73899_test, r=lcnrGuillaume Gomez-0/+21
Add regression test for issue 73899 Closes #73899
2020-11-22Rollup merge of #78670 - sasurau4:test/check-pass-incremental, r=jyn514Guillaume Gomez-6/+6
Remove FIXME comment in some incremental test suite Helps with #62277 I removed FIXME comment in some incremental tests with [rustc_partition_codegened](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_incremental/assert_module_sources/index.html). This seems using codegen process. So it uses intentionally `build-pass`
2020-11-22Add some more testsJonas Schievink-0/+51
2020-11-22Add regression test for issue 73899est31-0/+21
Adds regression test for https://github.com/rust-lang/rust/issues/73899
2020-11-22Add test for eval order for a+=bHavvy (Ryan Scheel)-0/+76
Yes, the order of evaluation *does* change depending on the types of the operands. Cursed, I know. I've elected to place this test into `expr/compound-assignment` creating both the `expr` directory and the `compound-assignment` directory. I plan in a future PR to also move the `if` directory and the loose `if` tests into `expr/if` and other similar cleanups of the `test/ui` directory. Future work: Test more than just `+=`, but all operators. I don't know if using a macro to generate these tests cases would be okay or not, but it'd be boilerplatey without it. I'm also confident you cannot change the evaluation order of one operator without changing all of them. Future work: Additionally, test more than just `i32 += i32` for the primitive version. I don't actually know the full set of primitive implementations, but I imagine there's enough to cause a combinatorial explosion with the previous future work item. Somewhere on the order of one to two hundred individual functions.
2020-11-22const fn: allow use of trait impls from boundsJonas Schievink-0/+93
2020-11-22Fix UI testsWaffle-3/+5
Some UI tests started failing after moving iterator adapters to different modules.
2020-11-21Auto merge of #78461 - TimDiekmann:vec-alloc, r=Amanieubors-14/+17
Add support for custom allocators in `Vec` This follows the [roadmap](https://github.com/rust-lang/wg-allocators/issues/7) of the allocator WG to add custom allocators to collections. r? `@Amanieu` This pull request requires a crater run. ### Prior work: - #71873: Crater-test to solve rust-lang/wg-allocators#1 - [`alloc-wg`](https://github.com/TimDiekmann/alloc-wg)-crate
2020-11-21Rollup merge of #79272 - tmiasko:array-clone, r=jonas-schievinkDylan DPC-0/+13
Support building clone shims for arrays with generic size Fixes #79269.
2020-11-21Rollup merge of #79264 - jyn514:less-doctree, r=GuillaumeGomezDylan DPC-93/+105
Get rid of some doctree items They can be derived directly from the `hir::Item`, there's no special logic. - TypeDef - OpaqueTy - Constant - Static - TraitAlias - Enum - Union - Struct Part of #78082 (the easiest part, I'm still debugging some other changes). r? `@GuillaumeGomez`
2020-11-21Rollup merge of #79231 - wusyong:issue-79137, r=lcnrDylan DPC-0/+52
Exhaustively match in variant count instrinsic Fix #79137
2020-11-21Rollup merge of #79182 - lochsh:78777-fix-extern-types-ref, r=jyn514Dylan DPC-0/+18
Fix links to extern types in rustdoc (fixes #78777) r? `@jyn514` Fixes #78777. The initial fix we tried was: ```diff diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 8be9482acff..c4b7086fdb1 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs `@@` -433,8 +433,9 `@@` impl<'a, 'tcx> LinkCollector<'a, 'tcx> { Res::PrimTy(prim) => Some( self.resolve_primitive_associated_item(prim, ns, module_id, item_name, item_str), ), - Res::Def(DefKind::Struct | DefKind::Union | DefKind::Enum | DefKind::TyAlias, did) => { + Res::Def(kind, did) if kind.ns() == Some(Namespace::TypeNS) => { debug!("looking for associated item named {} for item {:?}", item_name, did); + // Checks if item_name belongs to `impl SomeItem` let assoc_item = cx .tcx ``` However, this caused traits to be matched, resulting in a panic when `resolve_associated_trait_item` is called further down in this function. This PR also adds an error message for that panic. Currently it will look something like: ```rust thread 'rustc' panicked at 'Not a type: DefIndex(8624)', compiler/rustc_metadata/src/rmeta/decoder.rs:951:32 ``` I wasn't sure how to get a better debug output than `DefIndex(...)`, and am open to suggestions.
2020-11-21x.py test --blessJoshua Nelson-93/+93
2020-11-21Add more tests for renamed itemsJoshua Nelson-0/+12
2020-11-21Auto merge of #77805 - JohnTitor:non-standard-char-sugg, r=Dylan-DPCbors-0/+56
lint: Do not provide suggestions for non standard characters Fixes #77273 Only provide suggestions if the case-fixed result is different than the original.
2020-11-21Auto merge of #79003 - petrochenkov:innertest, r=estebankbors-3/+20
rustc_expand: Mark inner `#![test]` attributes as soft-unstable Custom inner attributes are feature gated (https://github.com/rust-lang/rust/issues/54726) except for attributes having name `test` literally, which are not gated for historical reasons. `#![test]` is an inner proc macro attribute, so it has all the issues described in https://github.com/rust-lang/rust/issues/54726 too. This PR gates it with the `soft_unstable` lint.
2020-11-21Fix comments of toogeneris testNgo Iok Ui-5/+3
2020-11-21Improve integer range testsNadrieril-665/+907
2020-11-21Support building clone shims for arrays with generic sizeTomasz Miąsko-0/+13
2020-11-20rustc_expand: Mark inner `#![test]` attributes as soft-unstableVadim Petrochenkov-3/+20
2020-11-20Auto merge of #78104 - ssomers:btree_root_redux, r=Mark-Simulacrumbors-2/+2
BTreeMap: replace Root with NodeRef<Owned, ...> `NodeRef<marker::Owned, …>` already exists as a representation of root nodes, and it makes more sense to alias `Root` to that than to reuse the space-efficient `BoxedNode` that is oblivious to height, where height is required. r? `@Mark-Simulacrum`
2020-11-20Exhaustively match in variant count instrinsicNgo Iok Ui-0/+54
2020-11-20Remove FIXME comment from incrementalDaiki Ihara-6/+6
2020-11-20Auto merge of #79192 - tmiasko:naked-noinline, r=oli-obkbors-0/+30
Never inline naked functions The `#[naked]` attribute disabled prologue / epilogue emission for the function and it is responsibility of a developer to provide them. The compiler is no position to inline such functions correctly. Disable inlining of naked functions at LLVM and MIR level. Closes #60919.
2020-11-20Auto merge of #78088 - fusion-engineering-forks:panic-fmt-lint, r=estebankbors-5/+151
Add lint for panic!("{}") This adds a lint that warns about `panic!("{}")`. `panic!(msg)` invocations with a single argument use their argument as panic payload literally, without using it as a format string. The same holds for `assert!(expr, msg)`. This lints checks if `msg` is a string literal (after expansion), and warns in case it contained braces. It suggests to insert `"{}", ` to use the message literally, or to add arguments to use it as a format string. ![image](https://user-images.githubusercontent.com/783247/96643867-79eb1080-1328-11eb-8d4e-a5586837c70a.png) This lint is also a good starting point for adding warnings about `panic!(not_a_string)` later, once [`panic_any()`](https://github.com/rust-lang/rust/pull/74622) becomes a stable alternative.
2020-11-20Never inline naked functionsTomasz Miąsko-0/+30
The `#[naked]` attribute disabled prologue / epilogue emission for the function and it is responsibility of a developer to provide them. The compiler is no position to inline such functions correctly. Disable inlining of naked functions at LLVM and MIR level.
2020-11-19Rollup merge of #79193 - tmiasko:revert-78969-normalize, r=davidtwcoDylan DPC-14/+8
Revert #78969 "Normalize function type during validation" Closes #79066. Reopens #78442.
2020-11-19Rollup merge of #79185 - petrochenkov:derattr2, r=Aaron1011Dylan DPC-267/+204
expand/resolve: Pre-requisites to "Turn `#[derive]` into a regular macro attribute" Miscellaneous refactorings and error reporting changes extracted from https://github.com/rust-lang/rust/pull/79078. Unlike https://github.com/rust-lang/rust/pull/79078 this PR doesn't make any observable changes to the language or library. r? ```@Aaron1011```
2020-11-19Rollup merge of #79181 - aDotInTheVoid:provided-method-source-link, ↵Dylan DPC-0/+26
r=jyn514,GuillaumeGomez rustdoc: add [src] links to methods on a trait's page Closes #45150 ![image](https://user-images.githubusercontent.com/28781354/99565541-aba4d500-29c3-11eb-99c7-11c1f91584e9.png) ### Caveats - The way I've implemented it, links are also provided for required methods, that just link to the signature in the code. I'm not sure if this is the desired behaviour. ![image](https://user-images.githubusercontent.com/28781354/99566222-849ad300-29c4-11eb-9897-08cc5842954f.png) - I'm not sure if the css changes are correct. I inspected them visualy on firefox on desktop, and they seem to be fine. - I can't tell how `src/librustdoc/html/render/mod.rs` is structured, so I probably
2020-11-19Rollup merge of #79177 - fanzier:drop-order-test, r=RalfJungDylan DPC-0/+44
Test drop order for (destructuring) assignments Add a test that checks whether the drop order of `let` bindings is consistent with the drop order of the corresponding destructuring assignments. Thanks to ```@RalfJung``` for the suggesting this test ([here](https://github.com/rust-lang/rust/pull/79016#issuecomment-727608732)) and an implementation! r? ```@RalfJung```
2020-11-19Regroup many usefulness-related test in the same folderNadrieril-0/+0
2020-11-19expand: Stop derive expansion un unexpected targets earlyVadim Petrochenkov-63/+6
Collect derive placeholders using `collect` instead of `push`
2020-11-19resolve: Centralize some error reporting for unexpected macro resolutionsVadim Petrochenkov-196/+196
2020-11-19expand: Tell built-in macros whether we are currently in forced expansion modeVadim Petrochenkov-8/+2
2020-11-19Rollup merge of #79164 - varkor:unbraced-single-segment-const-arguments, ↵Dylan DPC-21/+36
r=petrochenkov Permit standalone generic parameters as const generic arguments in macros Fixes https://github.com/rust-lang/rust/issues/79127. r? ```@petrochenkov```
2020-11-19Rollup merge of #79117 - cjkenn:mir-fuel, r=oli-obkDylan DPC-2/+2
add optimization fuel checks to some mir passes Fixes #77402 Inserts a bunch of calls to `consider_optimizing`. Note that `consider_optimizing` is the method that actually decrements the fuel count, so the point at which it's called is when the optimization takes place, from a fuel perspective. This means that where we call it has some thought behind it: 1. We probably don't want to decrement the fuel count before other simple checks, otherwise we count an optimization as being performed even if nothing was mutated (ie. it returned early). 2. In cases like `InstCombine`, where we gather optimizations in a pass and then mutate values, we probably would rather skip the gathering pass for performance reasons rather than skip the mutations afterwards.