Commit graph

152437 commits

Author SHA1 Message Date
Yuki Okushi
f3c59a8df6
Move the unused dir to lints subdir 2021-07-31 06:12:42 +09:00
Yuki Okushi
eaff0fc25b
Add a hint that the expressions produce a value 2021-07-31 06:12:42 +09:00
Flying-Toast
9a2e3f3a8e Recommend swap_remove in Vec::remove docs 2021-07-30 16:01:49 -04:00
bors
1f0a591b3a Auto merge of #87640 - JohnTitor:rollup-yq24nq5, r=JohnTitor
Rollup of 9 pull requests

Successful merges:

 - #86072 (Cross compiling rustc_llvm on Darwin requires zlib.)
 - #87385 (Make `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` warn by default)
 - #87547 (Add missing examples for NonNull)
 - #87557 (Fix issue with autofix for ambiguous associated function from Rust 2021 prelude when struct is generic)
 - #87559 (Tweak borrowing suggestion in `for` loop)
 - #87596 (Add warning when whitespace is not skipped after an escaped newline)
 - #87606 (Add some TAIT-related regression tests)
 - #87609 (Add docs about performance and `Iterator::map` to `[T; N]::map`)
 - #87616 (Fix missing word in rustdoc book)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-07-30 19:45:55 +00:00
Yuki Okushi
8d5291c7cd
Rollup merge of #87616 - Wilfred:patch-1, r=jyn514
Fix missing word in rustdoc book
2021-07-31 04:09:34 +09:00
Yuki Okushi
f4dfb76ea1
Rollup merge of #87609 - LukasKalbertodt:improve-array-map-docs, r=m-ou-se
Add docs about performance and `Iterator::map` to `[T; N]::map`

This suboptimal code gen for some usages of array::map got a bit of
attention by multiple people throughout the community. Some cases:

- https://github.com/rust-lang/rust/issues/75243#issuecomment-866051086
- https://github.com/rust-lang/rust/issues/75243#issuecomment-874732134
- https://www.reddit.com/r/rust/comments/oeqqf7/unexpected_high_stack_usage/

My *guess* is that this gets the attention it gets because in JavaScript
(and potentially other languages), a `map` function on arrays is very
commonly used since in those languages, arrays basically take the role
of Rust's iterator. I considered explicitly naming JavaScript in the
first paragraph I added, but I couldn't find precedence of mentioning
other languages in standard library doc, so I didn't add it.

When array::map was stabilized, we still wanted to add docs, but that
somehow did not happen in time. So here we are. Not sure if this sounds
crazy but maybe it is worth considering beta backporting this? Only if
it's not a lot of work, of course! But yeah, stabilized array::map is
already in beta and if this problem is really as big as it sometimes seems,
might be worth having the docs in place when 1.55 is released.

CC ``@CryZe``

r? ``@m-ou-se`` (since you were involved in that discussion and the stabilization)
2021-07-31 04:09:33 +09:00
Yuki Okushi
2bdc54fb45
Rollup merge of #87606 - JohnTitor:tait-tests, r=oli-obk
Add some TAIT-related regression tests

Closes #74280, closes #77179.
r? ``@oli-obk``
2021-07-31 04:09:32 +09:00
Yuki Okushi
aa9e6aa8ad
Rollup merge of #87596 - jesyspa:issue-87318-hidden-whitespace, r=estebank
Add warning when whitespace is not skipped after an escaped newline

Fixes issue #87318, also simplifies issue #87319.

* Add support to the lexer to emit warnings as well as errors.
* Emit a warning when a string literal contains an escaped newline, but when (some of) the whitespace on the next line is not skipped due to it being non-ASCII.
2021-07-31 04:09:31 +09:00
Yuki Okushi
5e2655d27f
Rollup merge of #87559 - estebank:consider-borrowing, r=oli-obk
Tweak borrowing suggestion in `for` loop
2021-07-31 04:09:30 +09:00
Yuki Okushi
fb27c4cc70
Rollup merge of #87557 - rylev:fix-invalid-prelude-collision-error, r=nikomatsakis
Fix issue with autofix for ambiguous associated function from Rust 2021 prelude when struct is generic

Fixes #86940

The test cases and associated issue should make it clear what specifically this is meant to fix. The fix is slightly hacky in that we check against the literal source code of the call site for the presence of `<` in order to determine if the user has included the generics for the struct (meaning we don't need to include them for them).

r? ``@nikomatsakis``
2021-07-31 04:09:29 +09:00
Yuki Okushi
f7a2a22815
Rollup merge of #87547 - GuillaumeGomez:nonnull-examples, r=kennytm
Add missing examples for NonNull
2021-07-31 04:09:26 +09:00
Yuki Okushi
f6bc738433
Rollup merge of #87385 - Aaron1011:final-enable-semi, r=petrochenkov
Make `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` warn by default

This PR makes the `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` lint warn by default.

To avoid showing a large number of un-actionable warnings to users, we only enable the lint for macros defined in the same crate. This ensures that users will be able to fix the warning by simply removing a semicolon.

In the future, I'd like to enable this lint unconditionally, and eventually make it into a hard error in a future edition. This PR is a step towards that goal.
2021-07-31 04:09:20 +09:00
Yuki Okushi
9391d55204
Rollup merge of #86072 - MarcusCalhoun-Lopez:llvm_cross, r=nagisa
Cross compiling rustc_llvm on Darwin requires zlib.
2021-07-31 04:09:19 +09:00
Hans Kratz
2aa1996329 Add regression test for issue #87450. 2021-07-30 18:32:22 +00:00
David Tolnay
60fa568c31
Fix some broken rustdoc links in core::panic documentation 2021-07-30 10:42:20 -07:00
David Tolnay
701e3a45a9
Fix comment referring to formerly-above code 2021-07-30 10:42:19 -07:00
David Tolnay
6d988dc1e3
Fix undocumented unsafe in AssertUnwindSafe impls 2021-07-30 10:42:18 -07:00
David Tolnay
4e17994b2c
Move UnwindSafe, RefUnwindSafe, AssertUnwindSafe to core 2021-07-30 10:42:15 -07:00
David Tolnay
76e73b74a6
Fix separation of public vs internal parts of Location 2021-07-30 10:40:02 -07:00
David Tolnay
d7c82ba4a1
Split core::panic module to subdirectory 2021-07-30 10:39:56 -07:00
bors
ef9549b6c0 Auto merge of #87421 - estebank:perf-run, r=oli-obk
Do not discard `?Sized` type params and suggest their removal
2021-07-30 17:18:50 +00:00
Amanieu d'Antras
12017f9e2b Update compiler_builtins to fix i128 shift/mul on thumbv6m
Fixes #86063
2021-07-30 18:56:48 +02:00
Charles Lew
fb4e0a0972 Implement trait upcasting coercion type-checking. 2021-07-31 00:51:39 +08:00
Charles Lew
ac354cf5ce Add feature gate tests. 2021-07-31 00:51:38 +08:00
Alexander Regueiro
2dc86a6450 Added feature gate. 2021-07-31 00:51:38 +08:00
Esteban Küber
0b8f192cfe Use multispan suggestions more often
* Use more accurate span for `async move` suggestion
* Use more accurate span for deref suggestion
* Use `multipart_suggestion` more often
2021-07-30 09:26:31 -07:00
Esteban Küber
17b2f92e44 Tweak borrowing suggestion in for loop 2021-07-30 08:59:42 -07:00
Esteban Küber
15a40c7ee8 Do not discard ?Sized type params and suggest their removal 2021-07-30 08:44:31 -07:00
Frank Steffahn
8d2bb9389a Consistent spelling of "adapter" in the standard library
Change all occurrences of "(A|a)daptor" to "(A|a)dapter".
2021-07-30 17:23:07 +02:00
Ryan Levick
578fcbdb3c Fix error with suggestion for how to disambiguate associated function when struct is generic 2021-07-30 17:18:43 +02:00
bors
f3f8e758f2 Auto merge of #85971 - FabianWolff:issue-85586, r=davidtwco
Use more precise span for E0282 in cast expressions

This pull request fixes #85586. The example code given there:
```rust
fn main() {
    let a = [1, 2, 3].iter().sum();
    let b = (a + 1) as usize;
}
```
currently produces
```
error[E0282]: type annotations needed
 --> issue-85586.rs:3:13
  |
3 |     let b = (a + 1) as usize;
  |             ^^^^^^^^^^^^^^^^ cannot infer type
  |
  = note: type must be known at this point

error: aborting due to previous error
```
even though the type of the entire cast expression quite clearly should be `usize`. The error is in the cast's left-hand side, which is made explicit by the changes in this PR:
```
error[E0282]: type annotations needed
 --> issue-85586.rs:3:13
  |
3 |     let b = (a + 1) as usize;
  |             ^^^^^^^ cannot infer type
  |
  = note: type must be known at this point

error: aborting due to previous error
```
2021-07-30 14:38:00 +00:00
Anton Golov
5d59b4412e Add warning when whitespace is not skipped after an escaped newline. 2021-07-30 16:26:39 +02:00
bors
87dc824248 Auto merge of #87237 - jonas-schievink:const-for-and-try, r=oli-obk
Add feature gates for `for` and `?` in consts

These operations seems *relatively* straightforward to support, and only seem to be blocked on `impl const Trait`.

I have included a working test for `const_try`, but `const_for` is currently unusable without reimplementing *every single* defaulted `Iterator` method, so I didn't do that.

(both features still need tracking issues before this is merged)
2021-07-30 12:05:48 +00:00
Niels Sascha Reedijk
dfff6994ea Update libz-sys to 1.1.3 2021-07-30 12:56:45 +01:00
bors
1195bea5a7 Auto merge of #87615 - JohnTitor:rollup-t5jpmrg, r=JohnTitor
Rollup of 10 pull requests

Successful merges:

 - #87052 (Optimize fmt::PadAdapter::wrap)
 - #87522 (Fix assert in diy_float)
 - #87553 (Fix typo in rustc_driver::version)
 - #87554 (2229: Discr should be read when PatKind is Range)
 - #87564 (min_type_alias_impl_trait is going to be removed in 1.56)
 - #87574 (Update the examples in `String` and `VecDeque::retain`)
 - #87583 (Refactor compression cache in v0 symbol mangler)
 - #87585 (Add missing links for core::char types)
 - #87594 (fs File get_path procfs usage for netbsd same as linux.)
 - #87602 ([backtraces]: look for the `begin` symbol only after seeing `end`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-07-30 09:43:32 +00:00
Guillaume Gomez
1bbe6188d2 Add missing examples for NonNull 2021-07-30 11:30:34 +02:00
Wilfred Hughes
c2a365d3d4
Fix missing word in comment 2021-07-30 00:58:48 -07:00
Yuki Okushi
84e18828d4
Rollup merge of #87602 - wesleywiser:partially_fix_short_backtraces_windows_optimized, r=dtolnay
[backtraces]: look for the `begin` symbol only after seeing `end`

On `x86_64-pc-windows-msvc`, we often get backtraces which look like
    this:

    ```
    10:     0x7ff77e0e9be5 - std::panicking::rust_panic_with_hook
    11:     0x7ff77e0e11b4 - std::sys_common::backtrace::__rust_begin_short_backtrace::h5769736bdb11136c
    12:     0x7ff77e0e116f - std::sys_common::backtrace::__rust_end_short_backtrace::h61c7ecb1b55338ae
    13:     0x7ff77e0f89dd - std::panicking::begin_panic::h8e60ef9f82a41805
    14:     0x7ff77e0e108c - d
    15:     0x7ff77e0e1069 - c
    16:     0x7ff77e0e1059 - b
    17:     0x7ff77e0e1049 - a
    18:     0x7ff77e0e1039 - core::ptr::drop_in_place<std::rt::lang_start<()>::{{closure}}>::h1bfcd14d5e15ba81
    19:     0x7ff77e0e1186 - std::sys_common::backtrace::__rust_begin_short_backtrace::h5769736bdb11136c
    20:     0x7ff77e0e100c - std::rt::lang_start::{{closure}}::ha054184bbf9921e3
    ```

Notice that `__rust_begin_short_backtrace` appears on frame 11 before
    `__rust_end_short_backtrace` on frame 12. This is because in typical
    release binaries without debug symbols, dbghelp.dll, which we use to walk
    and symbolize the stack, does not know where CGU internal functions
    start or end and so the closure invoked by `__rust_end_short_backtrace`
    is incorrectly described as `__rust_begin_short_backtrace` because it
    happens to be near that symbol.

While that can obviously change, this has been happening quite
    consistently since #75048. Since this is a very small change to the std
    and the change makes sense by itself, I think this is worth doing.

This doesn't completely resolve the situation for release binaries on
    Windows, since without debug symbols, the stack printed can still show
    incorrect symbol names (this is why the test uses `#[no_mangle]`) but it
    does slightly improve the situation in that you see the same backtrace
    you would see with `RUST_BACKTRACE=full` or in a debugger (without the
    uninteresting bits at the top and bottom).

Fixes part of #87481
2021-07-30 16:27:01 +09:00
Yuki Okushi
0180d4ca07
Rollup merge of #87594 - devnexen:netbsd_fs_getfiledescriptor_path, r=joshtriplett
fs File get_path procfs usage for netbsd same as linux.
2021-07-30 16:27:00 +09:00
Yuki Okushi
6e61383b66
Rollup merge of #87585 - GuillaumeGomez:char-types-doc, r=joshtriplett
Add missing links for core::char types
2021-07-30 16:26:59 +09:00
Yuki Okushi
1757d6b34d
Rollup merge of #87583 - tmiasko:compression-cache, r=wesleywiser
Refactor compression cache in v0 symbol mangler

* Remove redundant option around compression caches (they are always present).
* Flatten compression caches into symbol mangler to avoid dynamic memory allocation.
* Implement printer for `&mut SymbolMangler` instead of `SymbolMangler` to avoid passing now slightly larger symbol mangler by value.
2021-07-30 16:26:58 +09:00
Yuki Okushi
3bc6c28376
Rollup merge of #87574 - cuviper:retain-examples, r=joshtriplett
Update the examples in `String` and `VecDeque::retain`

The examples added in #60396 used a "clever" post-increment hack,
unrelated to the actual point of the examples. That hack was found
[confusing] in the users forum, and #81811 already changed the `Vec`
example to use a more direct iterator. This commit changes `String` and
`VecDeque` in the same way for consistency.

[confusing]: https://users.rust-lang.org/t/help-understand-strange-expression/62858
2021-07-30 16:26:57 +09:00
Yuki Okushi
55ce7ed5f2
Rollup merge of #87564 - spastorino:adjust-min-tait-removed-version, r=jackh726
min_type_alias_impl_trait is going to be removed in 1.56

#87501 removed `min_type_alias_impl_trait` but meanwhile that PR was approved in homu queue, a new beta was cut so we need to bump the version because it won't be removed in 1.55.

r? ```@oli-obk```

```@bors``` rollup=always
2021-07-30 16:26:56 +09:00
Yuki Okushi
aaef1a1649
Rollup merge of #87554 - sexxi-goose:fix-issue-87426, r=nikomatsakis
2229: Discr should be read when PatKind is Range

This PR fixes an issue related to pattern matching in closures when Edition 2021 is enabled.

- If any of the patterns the discr is being matched on is `PatKind::Range` then the discr should be read

r? ```@nikomatsakis```

Closes https://github.com/rust-lang/rust/issues/87426
2021-07-30 16:26:55 +09:00
Yuki Okushi
7e4b1737ff
Rollup merge of #87553 - bjorn3:fix_hotplug_codegen_version, r=wesleywiser
Fix typo in rustc_driver::version

This caused rustc `-Zcodegen-backend=foo.so -vV` to look for `oo.so` instead of `foo.so`
2021-07-30 16:26:54 +09:00
Yuki Okushi
fd79e7740b
Rollup merge of #87522 - frogtd:patch-1, r=yaahc
Fix assert in diy_float

The shifting should have gone the other way, the current incarnation is always true.
2021-07-30 16:26:53 +09:00
Yuki Okushi
c25b979db6
Rollup merge of #87052 - phlopsi:patch-1, r=jyn514
Optimize fmt::PadAdapter::wrap

After adding the first `write!` usage to my project and printing the result to the console, I noticed, that my binary contains the strings "called `Option::unwrap()` on a `None` value`" and more importantly "C:\Users\Patrick Fischer\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\fmt\builders.rs", with my release build being configured as follows:
```
[profile.release]
panic = "abort"
codegen-units = 1
strip = "symbols" # the important bit
lto = true
```
I am in a no_std environment and my custom panic handler is a simple `loop {}`. I did not expect the above information to be preserved. I heavily suspect the edited function to be the culprit. It contains the only direct use of `Option::unwrap` in the entire file and I tracked the symbols in the assembly to be used from the section `_ZN68_$LT$core..fmt..builders..PadAdapter$u20$as$u20$core..fmt..Write$GT$9write_str17ha1d5e5efe167202aE`.

Aside from me suspecting this function to be the culprit, the replaced code performs the same operation as `Option::insert`, but without the `unreachable_unchecked` optimization `Option::insert` provides. Therefore, it makes sense to me to use the more optimized version, instead.

As I don't change any semantics, I hope a simple pull request suffices.
2021-07-30 16:26:52 +09:00
bors
f739552870 Auto merge of #87483 - oli-obk:tait_ice, r=lqd
Mir borrowck does not generate lifetime variables for 'static lifetimes during opaque type resolution

Fixes #87455

This situation was unreachable before #87287 as we used to just grab the resolved opaque type from typeck and replaced all regions with new inference vars. After #87287 we let the `InferCx` in mir borrowck figure out the opaque type all by itself (which it already did before, but it only used the result to sanity check with the typeck result).
2021-07-30 07:02:34 +00:00
bors
fe1c942eee Auto merge of #87445 - amalik18:issue-83584-fix, r=kennytm
Fix may not to appropriate might not or must not

I went through and changed occurrences of `may not` to be more explicit with `might not` and `must not`.
2021-07-30 04:34:13 +00:00
Aaron Hill
4677efd01a
Bump LLVM for RegAllocFast bugfix
Fixes #83854
2021-07-29 19:23:41 -05:00