Commit graph

159314 commits

Author SHA1 Message Date
Esteban Kuber 962b2197a5 Annotate derived spans and move span suggestion code
* Annotate `derive`d spans from the user's code with the appropciate context
* Add `Span::can_be_used_for_suggestion` to query if the underlying span
  at the users' code
2021-12-03 18:41:40 +00:00
Esteban Kuber 8bee2b88c0 Remove some unnecessarily verbose code 2021-12-03 18:41:39 +00:00
Esteban Kuber fa3eebb26e Modify bounds_span to ignore bounds coming from a derive macro 2021-12-03 18:41:39 +00:00
Esteban Kuber e70105f971 Keep spans for generics in #[derive(_)] desugaring
Keep the spans for generics coming from a `derive`d Item, so that errors
and suggestions have better detail.

Fix #84003.
2021-12-03 18:41:39 +00:00
Tom Farmer 3827b6451c Update invalid crate attributes, add help message
tidy run

update invalid crate attributes, improve error

update test outputs

de-capitalise error

update tests

Update invalid crate attributes, add help message

Update - generate span without using BytePos

Add correct dependancies

Update - generate suggestion without BytePos

Tidy run

update tests

Generate Suggestion without BytePos

Add all builtin attributes

add err builtin inner attr at top of crate

fix tests

add err builtin inner attr at top of crate

tidy fix

add err builtin inner attr at top of crate
2021-12-03 18:38:32 +00:00
xFrednet 11ad5a26a9
Add note about crate lint level attributes to pre-expansion lints 2021-12-03 19:29:57 +01:00
xFrednet 1c45d1edfd
Enable rustbot shortcuts for rust-clippy 2021-12-03 19:10:14 +01:00
Tobias Kortkamp e24045e587
Explain why libatomic is not needed on FreeBSD riscv64
From Jessica Clarke (jrtc27@)
2021-12-03 18:49:42 +01:00
bors ff2439b7b9 Auto merge of #91491 - spastorino:revert-91354, r=oli-obk
Revert "Auto merge of #91354 - fee1-dead:const_env, r=spastorino"

This reverts commit 18bb8c61a9, reversing
changes made to d9baa36190.

Reverts #91354 in order to address #91489. We would need to place this changes in a more granular way and would also be nice to address the small perf regression that was also introduced.

r? `@oli-obk`
cc `@fee1-dead`
2021-12-03 16:26:01 +00:00
Oli Scherer 9e5939ad92 Remove a code path that is neither documented nor can I see the reason it existed.
Also, no tests fail when turning that arm into an ICE
2021-12-03 15:23:43 +00:00
bors 2a9e0831d6 Auto merge of #91393 - Julian-Wollersberger:lexer_optimization, r=petrochenkov
Optimize `rustc_lexer`

The `cursor.first()` method in `rustc_lexer` now calls the `chars.next()` method instead of `chars.nth_char(0)`.

This allows LLVM to optimize the code better. The biggest win is that `eat_while()` is now fully inlined and generates better assembly. This improves the lexer's performance by 35% in a micro-benchmark I made (Lexing all 18MB of code in the compiler directory). But lexing is only a small part of the overall compilation time, so I don't know how significant it is.

Big thanks to criterion and `cargo asm`.
2021-12-03 13:20:14 +00:00
Santiago Pastorino 85b723c4e6
Revert "Auto merge of #91354 - fee1-dead:const_env, r=spastorino"
This reverts commit 18bb8c61a9, reversing
changes made to d9baa36190.
2021-12-03 10:11:21 -03:00
bors d47a6cc3f2 Auto merge of #91286 - scottmcm:residual-trait, r=joshtriplett
Make `array::{try_from_fn, try_map}` and `Iterator::try_find` generic over `Try`

Fixes #85115

This only updates unstable functions.

`array::try_map` didn't actually exist before; this adds it under the still-open tracking issue #79711 from the old PR #79713.

Tracking issue for the new trait: #91285

This would also solve the return type question in for the proposed `Iterator::try_reduce` in #87054
2021-12-03 10:15:11 +00:00
bors 3e21768a0a Auto merge of #91486 - matthiaskrgr:rollup-699fo18, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #88906 (Implement write() method for Box<MaybeUninit<T>>)
 - #90269 (Make `Option::expect` unstably const)
 - #90854 (Type can be unsized and uninhabited)
 - #91170 (rustdoc: preload fonts)
 - #91273 (Fix ICE #91268 by checking that the snippet ends with a `)`)
 - #91381 (Android: -ldl must appear after -lgcc when linking)
 - #91453 (Document Windows TLS drop behaviour)
 - #91462 (Use try_normalize_erasing_regions in needs_drop)
 - #91474 (suppress warning about set_errno being unused on DragonFly)
 - #91483 (Sync rustfmt subtree)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-03 07:12:36 +00:00
Michael Goulet 7c108ababc Fix ICE when yielding in fn returning impl Trait 2021-12-02 22:36:05 -08:00
Matthias Krüger a2160609c0
Rollup merge of #91483 - calebcartwright:sync-rustfmt-subtree, r=calebcartwright
Sync rustfmt subtree
2021-12-03 06:24:19 +01:00
Matthias Krüger aa6f2d9a79
Rollup merge of #91474 - rtzoeller:dfly_set_errno, r=cuviper
suppress warning about set_errno being unused on DragonFly

Other targets allow this function to be unused, DragonFly just misses out due to providing a specialization.

This fixes a build error for DragonFly.
2021-12-03 06:24:18 +01:00
Matthias Krüger f056f0d1b4
Rollup merge of #91462 - b-naber:use-try-normalize-erasing-regions, r=jackh726
Use try_normalize_erasing_regions in needs_drop

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

r? ``@jackh726``
2021-12-03 06:24:17 +01:00
Matthias Krüger 25474ed731
Rollup merge of #91453 - ChrisDenton:doc-win-tls-dtors, r=dtolnay
Document Windows TLS drop behaviour

The way Windows TLS destructors are run has some "interesting" properties. They should be documented.

Fixes #74875
2021-12-03 06:24:16 +01:00
Matthias Krüger 63da52af4a
Rollup merge of #91381 - Amanieu:android_libdl, r=petrochenkov
Android: -ldl must appear after -lgcc when linking

#90846 accidentally broke Android builds because it causes the standard library to no longer use `dlsym` on Android. This results in `libdl` being ignored by the linker since no symbols are needed from it. However, we later import `libgcc` for unwinding which *does* depend on `libdl` for `dl_iterate_phdr`. Since linkers don't revisit previous libraries when resolving symbols, this causes a linker error due to an undefined reference to `dl_iterate_phdr`.

This is resolved by adding a second `-ldl` after `-lgcc` in the linker command-line.
2021-12-03 06:24:15 +01:00
Matthias Krüger a5ee722f1e
Rollup merge of #91273 - Badel2:ice-index-str, r=estebank
Fix ICE #91268 by checking that the snippet ends with a `)`

Fix #91268

Previously it was assumed that the last character of `snippet` will be a `)`, so using `snippet.len() - 1` as an index should be safe. However as we see in the test, it is possible to enter that branch without a closing `)`, and it will trigger the panic if the last character happens to be multibyte.

The fix is to ensure that the snippet ends with `)`, and skip the suggestion otherwise.
2021-12-03 06:24:14 +01:00
Matthias Krüger 0ccd566825
Rollup merge of #91170 - jsha:preload-fonts, r=GuillaumeGomez
rustdoc: preload fonts

Follow-up from #82315.

I noticed that font loading was so slow that even when loading from local disk, we get a flash of unstyled text (FOUT) followed by a reflow when the fonts load. With this change, we reliably get the appropriate fonts in the first render pass when loading locally, and we get it some of the time when loading from a website.

This only preloads woff2 versions. According to https://caniuse.com/?search=preload and https://caniuse.com/?search=woff2, all browsers that support preload also support woff2, so this is fine; we will never load two copies of a font.

Don't preload italic font faces because they aren't used on all pages.

Demo: https://rustdoc.crud.net/jsha/preload-fonts/std/string/struct.String.html
2021-12-03 06:24:13 +01:00
Matthias Krüger 570dc70a2b
Rollup merge of #90854 - sanxiyn:unsized-and-uninhabited, r=estebank
Type can be unsized and uninhabited

Fix #88150.
2021-12-03 06:24:12 +01:00
Matthias Krüger 94cd0259f2
Rollup merge of #90269 - woppopo:const_option_expect, r=yaahc
Make `Option::expect` unstably const

Tracking issue: #67441
2021-12-03 06:24:11 +01:00
Matthias Krüger 31003a3089
Rollup merge of #88906 - Kixunil:box-maybe-uninit-write, r=dtolnay
Implement write() method for Box<MaybeUninit<T>>

This adds method similar to `MaybeUninit::write` main difference being
it returns owned `Box`. This can be used to elide copy from stack
safely, however it's not currently tested that the optimization actually
occurs.

Analogous methods are not provided for `Rc` and `Arc` as those need to
handle the possibility of sharing. Some version of them may be added in
the future.

This was discussed in #63291 which this change extends.
2021-12-03 06:24:11 +01:00
bors 190367ba2e Auto merge of #91339 - cbarrete:vecdeque-remove-grow-check, r=Mark-Simulacrum
Remove unnecessary check in VecDeque::grow

All callers already check that the buffer is full before calling
`grow()`. This is where it makes the most sense, since `grow()` is
`inline(never)` and we don't want to pay for a function call just for
that check.
It could also be argued that it would be correct to call `grow()` even
if the buffer wasn't full yet.
This change breaks no code since `grow()` is not `pub`.
2021-12-03 04:14:07 +00:00
Caleb Cartwright f6ade7ca36 Merge commit '8da837185714cefbb261e93e9846afb11c1dc60e' into sync-rustfmt-subtree 2021-12-02 21:35:30 -06:00
Caleb Cartwright 8da8371857
Merge pull request #5121 from calebcartwright/subtree-sync-2021-12-02
subtree sync
2021-12-02 21:29:47 -06:00
Jubilee Young eef4371a98 Force splatting in SIMD test 2021-12-02 19:22:00 -08:00
Caleb Cartwright e305322557 Merge remote-tracking branch 'upstream/master' into subtree-sync-2021-12-02 2021-12-02 21:02:14 -06:00
est31 bdc4b46221 Use let_else in some more places in rustc_lint 2021-12-03 03:51:47 +01:00
Jubilee Young 2ea27bf6ef Merge commit 'a8385522ade6f67853edac730b5bf164ddb298fd' into simd-remove-autosplats 2021-12-02 18:27:47 -08:00
Jubilee a8385522ad
Merge portable-simd#195 - portable-simd:trait-ops
Generic `core::ops` for `Simd<T, _>`

In order to maintain type soundness, we need to be sure we only implement an operation for `Simd<T, _> where T: SimdElement`... and also valid for that operation in general. While we could do this purely parametrically, it is more sound to implement the operators directly for the base scalar type arguments and then use type parameters to extend the operators to the "higher order" operations.

This implements that strategy and cleans up `simd::ops` into a few submodules:
- assign.rs: `core::ops::*Assign`
- deref.rs:  `core::ops` impls which "deref" borrowed versions of the arguments
- unary.rs: encloses the logic for unary operators on `Simd`, as unary ops are much simpler

This is possible since everything need not be nested in a single maze of macros anymore. The result simplifies the logic and allows reasoning about what operators are valid based on the expressed trait bounds, and also reduces the size of the trait implementation output in rustdoc, for a huge win of 4 MB off the size of `struct.Simd.html`! This addresses a common user complaint, as the original was over 5.5 MB and capable of crashing browsers!

This also carries a fix for a type-inference-related breakage, by removing the autosplatting (vector + scalar binop) impls, as unfortunately the presence of autosplatting was capable of busting type inference. We will likely need to see results from a Crater run before we can understand how to re-land autosplatting.
2021-12-02 17:41:30 -08:00
Dylan MacKenzie 7bc5eca93a EarlyOtherwiseBranch requires -Zunsound-mir-opts
The noopt test never actually ran the pass
2021-12-02 17:31:38 -08:00
Dylan MacKenzie dc5feeb1fa Don't "simplify" during optimizations if optimizations are disabled 2021-12-02 17:31:38 -08:00
Dylan MacKenzie 42e31fffc4 Skip shim passes if they've already been run
Looks like Generator drop shims already have `post_borrowck_cleanup` run
on them. That's a bit surprising, since it means they're getting const-
and maybe borrow-checked? This merits further investigation, but for now
just preserve the status quo.
2021-12-02 17:31:38 -08:00
Dylan MacKenzie 71dd5422ac Use new MIR pass manager 2021-12-02 17:31:38 -08:00
Dylan MacKenzie fca642c1c3 Add pass for simple phase change 2021-12-02 17:31:38 -08:00
Dylan MacKenzie fd18b45e11 Update passes with new interface 2021-12-02 17:31:38 -08:00
Dylan MacKenzie c1a501b131 Implement a pass manager 2021-12-02 17:31:38 -08:00
Dylan MacKenzie a0de6346de Move instrument coverage config getters to Options 2021-12-02 17:12:59 -08:00
Dylan MacKenzie 386b1c5f57 Move mir_opt_level getter into Options 2021-12-02 17:12:58 -08:00
Esteban Kuber 5b5df0fa17 Remove incorrect newline from float cast suggestion 2021-12-03 01:00:09 +00:00
bors be1a73b894 Auto merge of #8061 - vallentin:fix-same-name-method-desc, r=flip1995
Fixed same_name_method description

Noticed some odd phrasing, while checking out the new release.

changelog: none
2021-12-03 00:37:52 +00:00
bors fddef249a2 Auto merge of #8067 - frobiac:8060-backslash_escaped_in_single_char_pattern, r=giraffate
Escape backslash in single_char_pattern.rs

Escape backslash in single_char_pattern.

Previously, the proposed clippy fix for a single backslash in raw strings ```r"\"``` or ```r#"\"#``` was also only an unescaped, *single* ```'\'```:
```shell
warning: single-character string constant used as pattern
2 |     let s = r#"abc\xyz/"#.find(r"\");
  |                                ^^^^ help: try using a `char` instead: `'\'`
  |
  = note: `#[warn(clippy::single_char_pattern)]` on by default
```

This PR corrects this to a properly escaped *double* backslash ```'\\'```.
I haven't come up with any other problematic cases, a single quote was already handled.

Closes: #8060

changelog:  Escape backslash in ``[`single_char_pattern`]``
2021-12-03 00:23:59 +00:00
Eric Holk 3268bf1d31 Update .stderr files 2021-12-02 16:12:25 -08:00
frobiac 5cc451bc6c Escape backslash for singe_char_pattern.rs 2021-12-02 23:47:23 +01:00
b-naber a11994e423 use try_normalize_erasing_regions in needs_drop 2021-12-02 23:27:08 +01:00
Ryan Zoeller 0fdb109795 suppress warning about set_errno being unused on DragonFly
Other targets allow this function to be unused, DragonFly just
misses out due to providing a specialization.
2021-12-02 16:16:27 -06:00
bors ff23ad3179 Auto merge of #91469 - matthiaskrgr:rollup-xom3j55, r=matthiaskrgr
Rollup of 12 pull requests

Successful merges:

 - #89954 (Fix legacy_const_generic doc arguments display)
 - #91321 (Handle placeholder regions in NLL type outlive constraints)
 - #91329 (Fix incorrect usage of `EvaluatedToOk` when evaluating `TypeOutlives`)
 - #91364 (Improve error message for incorrect field accesses through raw pointers)
 - #91387 (Clarify and tidy up explanation of E0038)
 - #91410 (Move `#![feature(const_precise_live_drops)]` checks earlier in the pipeline)
 - #91435 (Improve diagnostic for missing half of binary operator in `if` condition)
 - #91444 (disable tests in Miri that take too long)
 - #91457 (Add additional test from rust issue number 91068)
 - #91460 (Document how `last_os_error` should be used)
 - #91464 (Document file path case sensitivity)
 - #91466 (Improve the comments in `Symbol::interner`.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-02 21:58:48 +00:00