Commit graph

136923 commits

Author SHA1 Message Date
Mara Bos
19f97802ca
Rollup merge of #80635 - sexxi-goose:use-place-instead-of-symbol, r=nikomatsakis`
Improve diagnostics when closure doesn't meet trait bound

Improves the diagnostics when closure doesn't meet trait bound by modifying `TypeckResuts::closure_kind_origins` such that `hir::Place` is used instead of `Symbol`. Using `hir::Place` to describe which capture influenced the decision of selecting a trait a closure satisfies to (Fn/FnMut/FnOnce, Copy) allows us to show precise path in the diagnostics when `capture_disjoint_field` feature is enabled.

Closes rust-lang/project-rfc-2229/issues/21

r? ```@nikomatsakis```
2021-01-17 12:24:44 +00:00
Mara Bos
152f425dcb
Rollup merge of #80201 - saethlin:bufreader-read-exact, r=KodrAus
Add benchmark and fast path for BufReader::read_exact

At work, we have a wrapper type that implements this optimization. It would be nice if the standard library were faster.

Before:
```
test io::buffered::tests::bench_buffered_reader_small_reads       ... bench:       7,670 ns/iter (+/- 45)
```
After:
```
test io::buffered::tests::bench_buffered_reader_small_reads       ... bench:       4,457 ns/iter (+/- 41)
```
2021-01-17 12:24:42 +00:00
Mara Bos
3d5e7e0f47
Rollup merge of #80031 - petrochenkov:builtina, r=estebank
resolve: Reject ambiguity built-in attr vs different built-in attr

Fixes https://github.com/rust-lang/rust/issues/79798.

Resolution ensures that inert attributes cannot be used through imports like this, but built-in attributes don't go through initial resolution (only through resolution validation), so we have to keep some extra data (the built-in attribute name) to prevent it from happening.
2021-01-17 12:24:41 +00:00
Mara Bos
f783871ab1
Rollup merge of #79298 - lcnr:new-elysium, r=matthewjasper
correctly deal with late-bound lifetimes in anon consts

adds support for using late bound lifetimes of the parent context in anon consts.
```rust
#![feature(const_generics)]
const fn inner<'a>() -> usize where &'a (): Sized { 3 }

fn test<'a>() {
    let _: [u8; inner::<'a>()];
}
```
The lifetime `'a` is late bound in `test` so it's not included in its generics but is instead dealt with separately in borrowck.
This didn't previously work for anon consts as they have to use the late bound lifetimes of their parent which has
to be explicitly handled.

r? ```@matthewjasper``` cc ```@varkor``` ```@eddyb```
2021-01-17 12:24:39 +00:00
bors
7d3818152d Auto merge of #81058 - Smittyvb:wasm-num-tests, r=Mark-Simulacrum
Re-enable all num tests on WASM

This was partially done by #47365, but a few tests were missed in that PR.
2021-01-17 11:51:47 +00:00
Dániel Buga
c127ed6e97 Force vec! to expressions only 2021-01-17 12:48:25 +01:00
Ryan Levick
f07dd6d41a Remove dead code 2021-01-17 12:45:48 +01:00
Mara Bos
ff5dcc2438 Remove unused alloc::std::ops re-export. 2021-01-17 12:08:38 +01:00
Jack Huey
c76f47832a Don't derive TyEncodable/TyDecodable for Binder 2021-01-17 04:13:51 -05:00
bors
d51cf9601c Auto merge of #81083 - ssomers:btree_drainy_refactor_1, r=Mark-Simulacrum
BTreeMap: expose new_internal function and sanitize from_new_internal

`new_internal` is the functional core of the imperative `push_internal_level`, and `from_new_internal` can easily do a proper job instead of returning a half-baked node.

r? `@Mark-Simulacrum`
2021-01-17 08:44:12 +00:00
Jack Huey
674735b109 Impl EncodableWithShorthand for PredicateKind 2021-01-17 02:49:30 -05:00
bors
49d7889da4 Auto merge of #78818 - scottmcm:as_rchunks, r=KodrAus
Add `as_rchunks` (and friends) to slices

`@est31` mentioned (https://github.com/rust-lang/rust/issues/76354#issuecomment-717027175) that, for completeness, there needed to be an `as_chunks`-like method that chunks from the end (with the remainder at the beginning) like `rchunks` does.

So here's a PR for `as_rchunks: &[T] -> (&[T], &[[T; N]])` and `as_rchunks_mut: &mut [T] -> (&mut [T], &mut [[T; N]])`.

But as I was doing this and copy-pasting `from_raw_parts` calls, I thought that I should extract that into an unsafe method.  It started out a private helper, but it seemed like `as_chunks_unchecked` could be reasonable as a "real" method, so I added docs and made it public.  Let me know if you think it doesn't pull its weight.
2021-01-17 05:43:55 +00:00
Scott McMurray
3e16e9211e Add NonZeroUn::is_power_of_two
This saves instructions on both new and old machines.
2021-01-16 19:27:51 -08:00
bors
95cbcad920 Auto merge of #80942 - c410-f3r:tests-tests-tests, r=petrochenkov
Move some tests to more reasonable directories - 2

All tests with a score equal or greater than 1.0 were moved to their respective directories by issuing

```bash
cat FILE | tr -s " " | tr -d '():' | sort -k3 | awk '$3 >= 1' | cut -d " " -f1-2 | sed 's;\\;/;g' | xargs -n2 git mv
```
**Observation**: The first column values is the only column with results greater zero

To attest the confidentiality of the model, some manual revision of at least of tests is needed and this process will be tracked in the following list:

* `src/test/ui/abi/issue-28676.rs` OK #28676
* `src/test/ui/array-slice-vec/issue-15730.rs` OK
* `src/test/ui/associated-types/issue-24338.rs` OK #54823
* `src/test/ui/associated-types/issue-48551.rs` Looks OK #48551
* `src/test/ui/associated-types/issue-50301.rs` Looks OK #63577

...

cc #73494
r? `@petrochenkov`
2021-01-17 02:48:07 +00:00
Ben Kimock
4e27ed3af1 Add benchmark and fast path for BufReader::read_exact 2021-01-17 12:10:39 +10:00
LingMan
0a74e17211 Initialize a few variables directly
Currently they are declared as `mut`, get initialized to a default value, and
then possibly overwritten.

By initializing to the final value directly, they don't need to be `mut` and
it's clear that they don't get mutated elsewhere later on.
2021-01-17 02:07:37 +01:00
Jack Huey
f2ed9a3a8c Can't use EncodableWithShorthand for Predicate 2021-01-16 19:17:59 -05:00
Zack M. Davis
14eb94fe7a don't suggest erroneous trailing comma after ..
In #76612, suggestions were added for missing fields in
patterns. However, the suggestions are being inserted just at the end
of the last field in the pattern—before any trailing comma after the
last field. This resulted in the "if you don't care about missing
fields" suggestion to recommend code with a trailing comma after the
field ellipsis (`..,`), which is actually not legal ("`..` must be at
the end and cannot have a trailing comma")!

Incidentally, the doc-comment on `error_unmentioned_fields` was using
`you_cant_use_this_field` as an example field name (presumably
copy-paste inherited from the description of Issue #76077), but
the present author found this confusing, because unmentioned fields
aren't necessarily unusable.

The suggested code in the diff this commit introduces to
`destructuring-assignment/struct_destructure_fail.stderr` doesn't
work, but it didn't work beforehand, either (because of the "found
reserved identifier `_`" thing), so you can't really call it a
regression; it could be fixed in a separate PR.

Resolves #78511.
2021-01-16 16:01:36 -08:00
Tomasz Miąsko
d0a756719f Visit only terminators when removing unneeded drops
No functional changes intended
2021-01-17 00:00:00 +00:00
Jack Huey
dcad9f1893 More review comments 2021-01-16 18:56:37 -05:00
Jack Huey
3dea68de1d Review changes 2021-01-16 18:56:37 -05:00
Jack Huey
66c179946b Use no_bound_vars 2021-01-16 18:50:34 -05:00
Jack Huey
476bd53058 Cleanup 2021-01-16 18:50:34 -05:00
Jack Huey
7f24c21a50 Use pred not binder 2021-01-16 18:40:47 -05:00
Jack Huey
e76476afe4 Cleanup 2021-01-16 18:40:47 -05:00
Jack Huey
876192e8cd fold_with not super_fold_with in TypeFoldable impl for Predicate 2021-01-16 18:40:47 -05:00
Jack Huey
4cd6f85a07 Remove PredicateKind 2021-01-16 18:40:47 -05:00
Jack Huey
4cb3d6f983 Intermediate formatting and such 2021-01-16 18:40:47 -05:00
Jack Huey
8278314a8b Remove PredicateKind::Atom 2021-01-16 18:40:47 -05:00
Bastian Kauschke
84b056d597 prevent potential bug in encode_with_shorthand. 2021-01-17 00:34:54 +01:00
bors
2e46cb38f1 Auto merge of #81093 - calebcartwright:update-rustfmt, r=Mark-Simulacrum
bump rustfmt to v1.4.32

Fixes an indentation bug with bounds reported in https://github.com/rust-lang/rust/pull/80843#discussion_r554476529

r? `@Mark-Simulacrum`
2021-01-16 23:15:35 +00:00
Scott McMurray
6bcaba9f51 Try ignore-debug in the codegen test
This fixed things the last time I had a problem like this.  And plausibly will here too -- the check it's failing on is for the high bit being set in the length of the slice, which is a check that's only in a debug_assert.
2021-01-16 14:52:48 -08:00
Vadim Petrochenkov
7f9a2cfa1b resolve: Reject ambiguity built-in attr vs different built-in attr 2021-01-17 01:48:17 +03:00
Caio
ad35979c50 Move some tests to more reasonable directories - 2
Address comments

Update limits
2021-01-16 19:46:54 -03:00
bors
8a6518427e Auto merge of #81089 - m-ou-se:rollup-z7iac6i, r=m-ou-se
Rollup of 17 pull requests

Successful merges:

 - #78455 (Introduce {Ref, RefMut}::try_map for optional projections in RefCell)
 - #80144 (Remove giant badge in README)
 - #80614 (Explain why borrows can't be held across yield point in async blocks)
 - #80670 (TrustedRandomAaccess specialization composes incorrectly for nested iter::Zips)
 - #80681 (Clarify what the effects of a 'logic error' are)
 - #80764 (Re-stabilize Weak::as_ptr and friends for unsized T)
 - #80901 (Make `x.py --color always` apply to logging too)
 - #80902 (Add a regression test for #76281)
 - #80941 (Do not suggest invalid code in pattern with loop)
 - #80968 (Stabilize the poll_map feature)
 - #80971 (Put all feature gate tests under `feature-gates/`)
 - #81021 (Remove doctree::Import)
 - #81040 (doctest: Reset errors before dropping the parse session)
 - #81060 (Add a regression test for #50041)
 - #81065 (codegen_cranelift: Fix redundant semicolon warn)
 - #81069 (Add sample code for Rc::new_cyclic)
 - #81081 (Add test for #34792)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-01-16 20:26:20 +00:00
Caleb Cartwright
13d77a3772 bump rustfmt to v1.4.32 2021-01-16 14:23:54 -06:00
LingMan
5a706cfc49 Use Option::unwrap_or instead of open-coding it 2021-01-16 20:13:06 +01:00
LingMan
76003f31f1 Use Option::map instead of open-coding it 2021-01-16 20:05:02 +01:00
flip1995
13728b8975
Deprecate unknown_clippy_lints
This is now handled by unknown_lints
2021-01-16 19:44:46 +01:00
flip1995
5e3df4266a
More advanced unknown lint suggestion
This copies the unknown_lints code clippy uses for its
unknown_clippy_lints lint to rustc. The unknown_clippy_lints code is
more advanced, because it doesn't suggest renamed or removed lints and
correctly suggest lower casing lints.
2021-01-16 19:44:46 +01:00
Bastian Kauschke
15f0921d0c correctly deal with late-bound lifetimes in anon consts 2021-01-16 19:27:42 +01:00
Stein Somers
bb61cc48b3 BTreeMap: offer merge in variants with more clarity 2021-01-16 18:56:03 +01:00
Mara Bos
a6b2e1f046
Rollup merge of #81081 - bugadani:double-partialeq, r=Mark-Simulacrum
Add test for #34792

Closes #34792
2021-01-16 17:30:17 +00:00
Mara Bos
dd86fc6228
Rollup merge of #81069 - ogoffart:rc_new_cyclic_doc, r=Mark-Simulacrum
Add sample code for Rc::new_cyclic
2021-01-16 17:30:15 +00:00
Mara Bos
61be4e8024
Rollup merge of #81065 - osa1:cranelift_semicolon_warning, r=jyn514
codegen_cranelift: Fix redundant semicolon warn
2021-01-16 17:30:13 +00:00
Mara Bos
b67689bdf5
Rollup merge of #81060 - nagisa:nagisa/regression-50041, r=Mark-Simulacrum
Add a regression test for #50041

AFAICT the test case never landed alongside the fix for the issue.
2021-01-16 17:30:12 +00:00
Mara Bos
9df8dcbcde
Rollup merge of #81040 - osa1:fix_80992, r=jyn514
doctest: Reset errors before dropping the parse session

The first parse is to collect whether the code contains macros, has
`main`, and uses other crates. In that pass we ignore errors as those
will be reported when the test file is actually built.

For that we need to reset errors in the `Diagnostic` otherwise when
dropping it unhandled errors will be reported as compiler bugs.

Fixes #80992
2021-01-16 17:30:10 +00:00
Mara Bos
1368e81bcb
Rollup merge of #81021 - CraftSpider:rustdoc-remove-import, r=jyn514
Remove doctree::Import

Per the title. Part of cleaning up doctree
2021-01-16 17:30:08 +00:00
Mara Bos
4a48651b0e
Rollup merge of #80971 - camelid:feature-gate-testsuite-organization, r=Mark-Simulacrum
Put all feature gate tests under `feature-gates/`

There was one directory that had only a single test and there was also a
test in the top-level directory. This moves both of them to
`feature-gates/`.
2021-01-16 17:30:06 +00:00
Mara Bos
dba6c9c6d1
Rollup merge of #80968 - KodrAus:stabilize/poll_map, r=Mark-Simulacrum
Stabilize the poll_map feature

Stabilizes the `poll_map` feature as tracked by #63514 (with a completed FCP).
2021-01-16 17:30:04 +00:00