Commit graph

156851 commits

Author SHA1 Message Date
Samuel E. Moelius III
c9599d79a3 Add format_in_format_args and to_string_in_format_args lints
Fixes #7667 and #7729
2021-10-15 12:44:38 -04:00
Yuki Okushi
a51798a27b
Add some GATs related regression tests 2021-10-16 01:38:49 +09:00
jackh726
2b5b456e23 Move some outlives bounds things from rustc_trait_selection to rustc_typeck 2021-10-15 12:14:19 -04:00
jackh726
d3fa07c72e Use LocalDefId directly in more places in wfcheck 2021-10-15 12:14:02 -04:00
jackh726
a7c132de55 Move push_outlives_components to rustc_infer 2021-10-15 12:13:35 -04:00
bors
265fef45f2 Auto merge of #89337 - mbrubeck:vec-leak, r=m-ou-se
Avoid allocations and copying in Vec::leak

The [`Vec::leak`] method (#62195) is currently implemented by calling `Vec::into_boxed_slice` and `Box::leak`.  This shrinks the vector before leaking it, which potentially causes a reallocation and copies the vector's contents.

By avoiding the conversion to `Box`, we can instead leak the vector without any expensive operations, just by returning a slice reference and forgetting the `Vec`.  Users who *want* to shrink the vector first can still do so by calling `shrink_to_fit` explicitly.

**Note:**  This could break code that uses `Box::from_raw` to “un-leak” the slice returned by `Vec::leak`.  However, the `Vec::leak` docs explicitly forbid this, so such code is already incorrect.

[`Vec::leak`]: https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.leak
2021-10-15 15:55:08 +00:00
jackh726
c4f9eb1e5a Emit impl difference error for GenericBoundFailure too 2021-10-15 11:41:39 -04:00
David Wood
d2dc0f3b0f emitter: current substitution can be multi-line
In `splice_lines`, there is some arithmetic to compute the required
alignment such that future substitutions in a suggestion are aligned
correctly. However, this assumed that the current substitution's span
was only on a single line. In circumstances where this was not true, it
could result in a arithmetic overflow when the substitution's end
column was less than the substitution's start column.

Signed-off-by: David Wood <david.wood@huawei.com>
2021-10-15 15:30:43 +00:00
Loïc BRANSTETT
db5b64a484 Rework the equivalent test to work with sidebar-items.js 2021-10-15 16:54:31 +02:00
Cameron Steffen
ffdd5a04a4 Fix clippy with for loop span change 2021-10-15 08:04:51 -05:00
Cameron Steffen
a697aa63d6 Use more lowered spans in for loop 2021-10-15 08:04:51 -05:00
Cameron Steffen
bd1a1e4f0d Don't mark for loop head span with desugaring 2021-10-15 08:04:50 -05:00
bors
af9b508e1d Auto merge of #88717 - tabokie:vecdeque-fast-append, r=m-ou-se
Optimize VecDeque::append

Optimize `VecDeque::append` to do unsafe copy rather than iterating through each element.

On my `Intel(R) Xeon(R) CPU E5-2630 v4 @ 2.20GHz`, the benchmark shows 37% improvements:
```
Master:
custom-bench vec_deque_append 583164 ns/iter
custom-bench vec_deque_append 550040 ns/iter

Patched:
custom-bench vec_deque_append 349204 ns/iter
custom-bench vec_deque_append 368164 ns/iter
```

Additional notes on the context: this is the third attempt to implement a non-trivial version of `VecDeque::append`, the last two are reverted due to unsoundness or regression, see:
- https://github.com/rust-lang/rust/pull/52553, reverted in https://github.com/rust-lang/rust/pull/53571
- https://github.com/rust-lang/rust/pull/53564, reverted in https://github.com/rust-lang/rust/pull/54851

Both cases are covered by existing tests.

Signed-off-by: tabokie <xy.tao@outlook.com>
2021-10-15 12:51:31 +00:00
bors
db403bb889 Auto merge of #7823 - mikerite:match-overlapping-arm-20211015, r=xFrednet
Some small improvements to the `match_overlapping_arm` tests

changelog: none
2021-10-15 12:42:16 +00:00
Mara Bos
acee39e5c5 Add missing bcrypt.lib to make-fulldeps Makefile. 2021-10-15 13:25:39 +02:00
Mara Bos
1ed123828c Use BCryptGenRandom instead of RtlGenRandom on Windows.
BCryptGenRandom isn't available on XP, but we dropped XP support a while
ago.
2021-10-15 13:22:28 +02:00
bors
70f36e0454 Auto merge of #7824 - dswij:unnecessary_sort_by, r=llogiq
`unnecessary_sort_by` checks if argument implements `Ord` trait

closes #7822

changelog: [`unnecessary_sort_by`] now checks if argument implements `Ord` trait
2021-10-15 11:16:57 +00:00
Loïc BRANSTETT
e259cc46a6 Add equivalent test in src/test/rustdoc 2021-10-15 12:56:47 +02:00
Urgau
55fad29903
Apply documentation suggestions from code review
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2021-10-15 12:21:25 +02:00
dswij
e4ac4c2e1a Add test on unnecessary_sort_by when argument does not implement Ord 2021-10-15 18:12:47 +08:00
dswij
ec5071931e unnecessary_sort_by only warns if argument impl Ord trait 2021-10-15 18:10:55 +08:00
bors
1dafe6d1c3 Auto merge of #88540 - ibraheemdev:swap-unchecked, r=kennytm
add `slice::swap_unchecked`

An unsafe version of `slice::swap` that does not do bounds checking.
2021-10-15 09:35:45 +00:00
Matthias Krüger
4457014398 Revert "Auto merge of #89709 - clemenswasser:apply_clippy_suggestions_2, r=petrochenkov"
The PR had some unforseen perf regressions that are not as easy to find.
Revert the PR for now.

This reverts commit 6ae8912a3e, reversing
changes made to 86d6d2b738.
2021-10-15 11:28:23 +02:00
Yuval Dolev
43f4ef5c6a Moved format-version constant to rustdoc-json-types 2021-10-15 12:27:42 +03:00
Cameron Steffen
0a23fff82d Fix clippy with changed macro statement spans 2021-10-15 02:36:58 -05:00
Cameron Steffen
cc4bc571f4 Fix clippy with changed macro statement spans 2021-10-15 02:36:58 -05:00
Cameron Steffen
90f4521cfd Bless tests 2021-10-15 02:36:58 -05:00
Cameron Steffen
f005e9fe96 Guess semicolon span for macro statements 2021-10-15 02:24:48 -05:00
Cameron Steffen
1333ae67f4 Remove trailing semicolon from macro call span 2021-10-15 02:24:48 -05:00
Cameron Steffen
c75a734a43 Remove redundant matching 2021-10-15 02:24:48 -05:00
bors
72d66064e7 Auto merge of #89903 - matthiaskrgr:rollup-s0c69xl, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #86011 (move implicit `Sized` predicate to end of list)
 - #89821 (Add a strange test for `unsafe_code` lint.)
 - #89859 (add dedicated error variant for writing the discriminant of an uninhabited enum variant)
 - #89870 (Suggest Box::pin when Pin::new is used instead)
 - #89880 (Use non-checking TLS relocation in aarch64 asm! sym test.)
 - #89885 (add long explanation for E0183)
 - #89894 (Remove unused dependencies from rustc_const_eval)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-15 05:59:49 +00:00
Hans Kratz
ac298c9181 Make rust.download-ci-llvm="if-available" work for tier 2 platforms. 2021-10-15 07:45:27 +02:00
Matthias Krüger
e45c222793
Rollup merge of #89894 - camsteffen:unused-deps, r=Mark-Simulacrum
Remove unused dependencies from rustc_const_eval
2021-10-15 07:44:50 +02:00
Matthias Krüger
e3099e7d8c
Rollup merge of #89885 - cameron1024:long-explanation-E0183, r=GuillaumeGomez
add long explanation for E0183

Addresses #61137
2021-10-15 07:44:49 +02:00
Matthias Krüger
f0555cefae
Rollup merge of #89880 - adamgemmell:dev/nc-relocation, r=Amanieu
Use non-checking TLS relocation in aarch64 asm! sym test.

The checking variant ensures that the offset required is not larger than 12 bits - hence we wouldn't ever need the upper 12 bits.

It's unlikely to ever fail in this small test but this is technically correct.

This was noticed incidentally when we found that LLD doesn't support the `tprel_lo12` relocation, even though LLVM can apparently generate it when using `-mtls-size=12`.
2021-10-15 07:44:48 +02:00
Matthias Krüger
e2c28ad1e7
Rollup merge of #89870 - tmandry:box-pin, r=estebank
Suggest Box::pin when Pin::new is used instead

This fixes an incorrect diagnostic.

**Based on #89390**; only the last commit is specific to this PR. "Ignore whitespace changes" also helps here.
2021-10-15 07:44:47 +02:00
Matthias Krüger
345d483e95
Rollup merge of #89859 - RalfJung:write-discriminant, r=oli-obk
add dedicated error variant for writing the discriminant of an uninhabited enum variant

This is conceptually different from hitting an `Unreachable` terminator. Also add some sanity check making sure we don't write discriminants of things that do not have discriminants.

r? ``@oli-obk``
2021-10-15 07:44:47 +02:00
Matthias Krüger
b74ae0487b
Rollup merge of #89821 - crlf0710:unsafe_code_lint_test, r=Mark-Simulacrum
Add a strange test for `unsafe_code` lint.

The current behavior is a little surprising to me. I'm not sure whether people would change it, but at least let me document the current behavior with a test.

I learnt about this from the [totally-speedy-transmute](https://docs.rs/totally-speedy-transmute) crate.

cc #10599 the original implementation pr.
2021-10-15 07:44:45 +02:00
Matthias Krüger
36a1076d24
Rollup merge of #86011 - tlyu:correct-sized-bound-spans, r=estebank
move implicit `Sized` predicate to end of list

In `Bounds::predicates()`, move the implicit `Sized` predicate to the
end of the generated list. This means that if there is an explicit
`Sized` bound, it will be checked first, and any resulting
diagnostics will have a more useful span.

Fixes #85998, at least partially. ~~Based on #85979, but only the last 2 commits are new for this pull request.~~ (edit: rebased) A full fix would need to deal with where-clauses, and that seems difficult. Basically, predicates are being collected in multiple stages, and there are two places where implicit `Sized` predicates can be inserted: once for generic parameters, and once for where-clauses. I think this insertion is happening too early, and we should actually do it only at points where we collect all of the relevant trait bounds for a type parameter.

I could use some help interpreting the changes to the stderr output. It looks like reordering the predicates changed some diagnostics that don't obviously have anything to do with `Sized` bounds. Possibly some error reporting code is making assumptions about ordering of predicates? The diagnostics for src/test/ui/derives/derives-span-Hash-*.rs seem to have improved, no longer pointing at the type parameter identifier, but src/test/ui/type-alias-impl-trait/generic_duplicate_param_use9.rs became less verbose for some reason.

I also ran into an instance of #84970 while working on this, but I kind of expected that could happen, because I'm reordering predicates. I can open a separate issue on that if it would be helpful.

``@estebank`` this seems likely to conflict (slightly?) with your work on #85947; how would you like to resolve that?
2021-10-15 07:44:44 +02:00
Michael Wright
28a249b53e Add unbounded pats to match_overlapping_arm tests 2021-10-15 06:25:11 +02:00
Michael Wright
e664a76add Refactor overlapping arm tests
Make the `println!`s match the patterns. Currently they are using the
deprecated syntax for inclusive ranges and extra spacing.
2021-10-15 06:20:28 +02:00
Hans Kratz
2a1fbb86eb test fix: aarch64 atomics are only outlined on Linux. 2021-10-15 06:19:08 +02:00
bors
313e71a253 Auto merge of #89884 - Mark-Simulacrum:revert-enum-discr, r=wesleywiser
Revert enum discriminants

Reverts stabilization of arbitrary enum discriminants per https://github.com/rust-lang/rust/issues/88621#issuecomment-929482371.

Reopens #60553.
2021-10-15 02:55:58 +00:00
Amanieu d'Antras
8007dfa3b2 Remove alloc::prelude
As per the libs team decision in #58935.

Closes #58935
2021-10-15 01:41:31 +02:00
Camille GILLOT
1e2dbb5f4a Document structs. 2021-10-14 22:59:30 +02:00
Cameron Steffen
64d18d4c51 Remove unused dependencies from rustc_const_eval 2021-10-14 15:42:42 -05:00
Cameron Steffen
7166df4b59 Inline on_mir_pass and add inline to dump_mir 2021-10-14 15:26:59 -05:00
Camille GILLOT
394f7198ca Allow to hash HIR for coverage. 2021-10-14 22:24:43 +02:00
Cameron Steffen
cf1d702411 Remove redundant dump_enabled check 2021-10-14 15:10:13 -05:00
Mark Rousskov
86608f1796 Switch to clang v13 as the C/C++ compiler used for bootstrap 2021-10-14 15:21:14 -04:00