Commit graph

139352 commits

Author SHA1 Message Date
Ömer Sinan Ağacan
fb631a55c2 Fix turbofish recovery with multiple generic args
check_mistyped_turbofish_with_multiple_type_params was previously
expecting type arguments between angle brackets, which is not right, as
we can also see const expressions. We now use generic argument parser
instead of type parser.

Test with one, two, and three generic arguments added to check
consistentcy between

1. check_no_chained_comparison: Called after parsing a nested binop
   application like `x < A > ...` where angle brackets are interpreted as
   binary operators and `A` is an expression.

2. check_mistyped_turbofish_with_multiple_type_params: called by
   `parse_full_stmt` when we expect to see a semicolon after parsing an
   expression but don't see it.

   (In `T2<1, 2>::C;`, the expression is `T2 < 1`)
2021-02-27 13:46:49 +03:00
Vincent Ambo
e026e18e3f Add ARIA role to sidebar toggle in Rustdoc
This indicates that the div is an interactive element, and makes the
sidebar toggle "clickable" in assistive technologies.

Fixes #82582
2021-02-27 12:37:05 +02:00
Tomasz Miąsko
500aeccc5b Use optional values for inlining thresholds
Turn inlining threshold into optional values to make it possible to
configure different defaults depending on the current mir-opt-level.
2021-02-27 10:19:19 +01:00
Tomasz Miąsko
f895f1c35a Add option enabling MIR inlining independently of mir-opt-level 2021-02-27 10:18:06 +01:00
bors
8e863eb59a Auto merge of #82448 - Aaron1011:merge-hastokens-hasattrs, r=petrochenkov
Combine HasAttrs and HasTokens into AstLike

When token-based attribute handling is implemeneted in #80689,
we will need to access tokens from `HasAttrs` (to perform
cfg-stripping), and we will to access attributes from `HasTokens` (to
construct a `PreexpTokenStream`).

This PR merges the `HasAttrs` and `HasTokens` traits into a new
`AstLike` trait. The previous `HasAttrs` impls from `Vec<Attribute>` and `AttrVec`
are removed - they aren't attribute targets, so the impls never really
made sense.
2021-02-27 07:52:11 +00:00
Aaron Hill
fb5fec017b
Combine HasAttrs and HasTokens into AstLike
When token-based attribute handling is implemeneted in #80689,
we will need to access tokens from `HasAttrs` (to perform
cfg-stripping), and we will to access attributes from `HasTokens` (to
construct a `PreexpTokenStream`).

This PR merges the `HasAttrs` and `HasTokens` traits into a new
`AstLike` trait. The previous `HasAttrs` impls from `Vec<Attribute>` and `AttrVec`
are removed - they aren't attribute targets, so the impls never really
made sense.
2021-02-27 00:14:13 -05:00
bors
0846043440 Auto merge of #82511 - jsha:fix-bfcache2, r=GuillaumeGomez
Fix back-forward cache in rustdoc frontend

Rustdoc's frontend set a no-op unload handler, specifically to disable
Firefox's back-forward cache because it caused a bug. It's nice to
allow the back-forward cache because it permits faster navigations.

This change addresses the issues that were caused by back-forward cache.

https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/1.5/Using_Firefox_1.5_caching
https://web.dev/bfcache/

Demo: https://jacob.hoffman-andrews.com/rust/fix-bfcache/std/string/struct.String.html

Related: #72272
2021-02-27 05:06:05 +00:00
Cameron Steffen
4a6e67ead7 Add missing diagnostic item Symbols 2021-02-26 22:12:36 -06:00
bors
9fa580b117 Auto merge of #82577 - Dylan-DPC:rollup-c3si8ju, r=Dylan-DPC
Rollup of 14 pull requests

Successful merges:

 - #81794 (update tracking issue for `relaxed_struct_unsize`)
 - #82057 (Replace const_cstr with cstr crate)
 - #82370 (Improve anonymous lifetime note to indicate the target span)
 - #82394 (⬆️ rust-analyzer)
 - #82396 (Add Future trait for doc_spotlight feature doc)
 - #82404 (Test hexagon-enum only when llvm target is present)
 - #82419 (expand: Preserve order of inert attributes during expansion)
 - #82420 (Enable API documentation for `std::os::wasi`.)
 - #82421 (Add a `size()` function to WASI's `MetadataExt`.)
 - #82442 (Skip emitting closure diagnostic when closure_kind_origins has no entry)
 - #82473 (Use libc::accept4 on Android instead of raw syscall.)
 - #82482 (Use small hash set in `mir_inliner_callees`)
 - #82490 (Update cargo)
 - #82494 (Substitute erased lifetimes on bad placeholder type)

Failed merges:

 - #82448 (Combine HasAttrs and HasTokens into AstLike)

r? `@ghost`
`@rustbot` modify labels: rollup
2021-02-27 02:18:11 +00:00
Dylan DPC
95b31cf949
Rollup merge of #82494 - estebank:issue-82455, r=petrochenkov
Substitute erased lifetimes on bad placeholder type

Fix #82455.
2021-02-27 02:34:35 +01:00
Dylan DPC
a1f75409a6
Rollup merge of #82490 - ehuss:update-cargo, r=ehuss
Update cargo

11 commits in bf5a5d5e5d3ae842a63bfce6d070dfd438cf6070..572e201536dc2e4920346e28037b63c0f4d88b3c
2021-02-18 15:49:14 +0000 to 2021-02-24 16:51:20 +0000
- Pass the error message format to rustdoc (rust-lang/cargo#9128)
- Fix test target_in_environment_contains_lower_case (rust-lang/cargo#9203)
- Fix hang on broken stderr. (rust-lang/cargo#9201)
- Make it more clear which module is being tested when running cargo test (rust-lang/cargo#9195)
- Updates to edition handling. (rust-lang/cargo#9184)
- Add --cfg and --rustc-cfg flags to output compiler configuration (rust-lang/cargo#9002)
- Run rustdoc doctests relative to the workspace (rust-lang/cargo#9105)
- Add support for [env] section in .cargo/config.toml (rust-lang/cargo#9175)
- Add schema field and `features2` to the index. (rust-lang/cargo#9161)
- Document the default location where cargo install emitting build artifacts (rust-lang/cargo#9189)
- Do not exit prematurely if anything failed installing. (rust-lang/cargo#9185)
2021-02-27 02:34:33 +01:00
Dylan DPC
2942cf5a1f
Rollup merge of #82482 - tmiasko:small-cycles, r=varkor
Use small hash set in `mir_inliner_callees`

Use small hash set in `mir_inliner_callees` to avoid temporary
allocation when possible and quadratic behaviour for large number of
callees.
2021-02-27 02:34:32 +01:00
Dylan DPC
b664e4bdb5
Rollup merge of #82473 - de-vri-es:android-x86-accept4, r=m-ou-se
Use libc::accept4 on Android instead of raw syscall.

This PR replaces the use of a raw `accept4` syscall with `libc::accept4`. This was originally added (by me) because `std` couldn't update to the latest `libc` with `accept4` support for android. By now, libc is already on 0.2.85, so the workaround can be removed.

`@rustbot` label +O-android +T-libs-impl
2021-02-27 02:34:31 +01:00
Dylan DPC
5c7b383e59
Rollup merge of #82442 - Aaron1011:fix/closure-mut-crash, r=matthewjasper
Skip emitting closure diagnostic when closure_kind_origins has no entry

Fixes #82438

This map is not guarnateed to have an entry for a closure.
2021-02-27 02:34:30 +01:00
Dylan DPC
d80033f048
Rollup merge of #82421 - sunfishcode:wasi-metadata-size, r=alexcrichton
Add a `size()` function to WASI's `MetadataExt`.

WASI's `filestat` type includes a size field, so expose it in
`MetadataExt` via a `size()` function, similar to the corresponding Unix
function.

r? ``````@alexcrichton``````
2021-02-27 02:34:28 +01:00
Dylan DPC
f5b68a4444
Rollup merge of #82420 - sunfishcode:wasi-docs, r=alexcrichton
Enable API documentation for `std::os::wasi`.

This adds API documentation support for `std::os::wasi` modeled after
how `std::os::unix` works, so that WASI can be documented [here] along
with the other platforms.

[here]: https://doc.rust-lang.org/stable/std/os/index.html

Two changes of particular interest:

 - This changes the `AsRawFd` for `io::Stdin` for WASI to return
   `libc::STDIN_FILENO` instead of `sys::stdio::Stdin.as_raw_fd()` (and
   similar for `Stdout` and `Stderr`), which matches how the `unix`
   version works. `STDIN_FILENO` etc. may not always be explicitly
   reserved at the WASI level, but as long as we have Rust's `std` and
   `libc`, I think it's reasonable to guarantee that we'll always use
   `libc::STDIN_FILENO` for stdin.

 - This duplicates the `osstr2str` utility function, rather than
   trying to share it across all the configurations that need it.

r? ```@alexcrichton```
2021-02-27 02:34:27 +01:00
Dylan DPC
76b40d27e2
Rollup merge of #82419 - petrochenkov:inertord, r=Aaron1011
expand: Preserve order of inert attributes during expansion

Fixes https://github.com/rust-lang/rust/issues/67839
Fixes https://github.com/rust-lang/rust/issues/81871
r? `````@Aaron1011`````
2021-02-27 02:34:26 +01:00
Dylan DPC
2d175bbd2c
Rollup merge of #82404 - nagisa:nagisa/hexagon-enums-llvm-comps, r=petrochenkov
Test hexagon-enum only when llvm target is present

See https://github.com/rust-lang/rust/pull/82379#issuecomment-783439754

r? ``````@petrochenkov``````

``````@bors`````` rollup
2021-02-27 02:34:25 +01:00
Dylan DPC
9f95666883
Rollup merge of #82396 - pickfire:patch-5, r=GuillaumeGomez
Add Future trait for doc_spotlight feature doc
2021-02-27 02:34:24 +01:00
Dylan DPC
b89357b409
Rollup merge of #82394 - lnicola:rust-analyzer-2021-02-22, r=jonas-schievink
⬆️ rust-analyzer
2021-02-27 02:34:23 +01:00
Dylan DPC
f0c98b15cc
Rollup merge of #82370 - 0yoyoyo:update-issue-81650-point-anonymous-lifetime, r=estebank
Improve anonymous lifetime note to indicate the target span

Improvement for  #81650
Cc #81995

Message after this improvement:
(Improve note in the middle)

```
error[E0311]: the parameter type `T` may not live long enough
  --> src/main.rs:25:11
   |
24 | fn play_with<T: Animal + Send>(scope: &Scope, animal: T) {
   |              -- help: consider adding an explicit lifetime bound...: `T: 'a +`
25 |     scope.spawn(move |_| {
   |           ^^^^^
   |
note: the parameter type `T` must be valid for the anonymous lifetime defined on the function body at 24:40...
  --> src/main.rs:24:40
   |
24 | fn play_with<T: Animal + Send>(scope: &Scope, animal: T) {
   |                                        ^^^^^
note: ...so that the type `[closure@src/main.rs:25:17: 27:6]` will meet its required lifetime bounds
  --> src/main.rs:25:11
   |
25 |     scope.spawn(move |_| {
   |           ^^^^^
```

r? ``````@estebank``````
2021-02-27 02:34:22 +01:00
Dylan DPC
cabe97272d
Rollup merge of #82057 - upsuper-forks:cstr, r=davidtwco,wesleywiser
Replace const_cstr with cstr crate

This PR replaces the `const_cstr` macro inside `rustc_data_structures` with `cstr` macro from [cstr](https://crates.io/crates/cstr) crate.

The two macros basically serve the same purpose, which is to generate `&'static CStr` from a string literal. `cstr` is better because it validates the literal at compile time, while the existing `const_cstr` does it at runtime when `debug_assertions` is enabled. In addition, the value `cstr` generates can be used in constant context (which is seemingly not needed anywhere currently, though).
2021-02-27 02:34:21 +01:00
Dylan DPC
db8ac16d00
Rollup merge of #81794 - lcnr:relaxed_adt_unsize-tracking-issue, r=camelid
update tracking issue for `relaxed_struct_unsize`

forgot to do this before #80726 got merged. The tracking issue is #81793
2021-02-27 02:34:20 +01:00
Lucas De Angelis
5835f6defa Move test file, add test of generated link 2021-02-27 01:08:05 +01:00
Lucas De Angelis
02cc85065e
Update src/librustdoc/passes/collect_intra_doc_links.rs
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2021-02-26 23:48:45 +01:00
bors
3da2dd3eae Auto merge of #82559 - tmiasko:inlined, r=petrochenkov
Miscellaneous inlining improvements

Inline a few small and hot functions.
2021-02-26 21:58:58 +00:00
Lucas De Angelis
d95b7b31c7 Fix formatting 2021-02-26 22:48:53 +01:00
Waffle
2f04a793ae Revert Vec::spare_capacity_mut impl to prevent pointers invalidation 2021-02-27 00:27:34 +03:00
Lucas De Angelis
5661fe3fa9 Fix intra-doc handling of Self in enum
Fixes #82209
2021-02-26 22:09:39 +01:00
bors
9c09c1f7cf Auto merge of #82552 - GuillaumeGomez:rollup-8dn1ztn, r=GuillaumeGomez
Rollup of 8 pull requests

Successful merges:

 - #81940 (Stabilize str_split_once)
 - #82165 (Reword labels on E0308 involving async fn return type)
 - #82456 (Replaced some unwrap_or and map_or with lazy variants)
 - #82491 (Consider inexpensive inlining criteria first)
 - #82506 (Properly account for non-shorthand pattern field in unused variable lint)
 - #82535 (Set codegen thread names)
 - #82545 (rustdoc: add optional woff2 versions of FiraSans.)
 - #82549 (Revert "Update normalize.css to 8.0.1")

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-02-26 19:17:00 +00:00
Trevor Spiteri
dd502cb343 doc: cube root, not cubic root
Like we say square root, not quadratic root.
2021-02-26 19:03:44 +01:00
Trevor Spiteri
4dcbc005c5 fix typo in RELEASES.md 2021-02-26 18:41:22 +01:00
Ivan Tham
27f7a2e18d
Add for example word to spotlight doc
As suggested by GuillaumeGomez
2021-02-27 01:29:56 +08:00
Guillaume Gomez
0da9b474de
Rollup merge of #82549 - rust-lang:revert-82313-update-normalize-css, r=apiraino
Revert "Update normalize.css to 8.0.1"

Reverts rust-lang/rust#82313

Fixes #82548
Fixes #82542

``@jsha:`` I'm reverting until we can come up with a new version which is fully working.

r? ``@jyn514``
2021-02-26 15:52:37 +01:00
Guillaume Gomez
b4ded5a07b
Rollup merge of #82545 - jsha:woff2, r=GuillaumeGomez
rustdoc: add optional woff2 versions of FiraSans.

For browsers that support woff2 (most modern ones:
https://caniuse.com/woff2), this offers a reduction in download size
for these two fonts from 362k to 257k (32% reduction). It decreases the
total page size for `struct.String.html` (counting all subresources) by
about 2.5%.

If this is interesting, I'm happy to apply the same treatment to the
other fonts, but these two are the biggest.
2021-02-26 15:52:36 +01:00
Guillaume Gomez
6b5e141999
Rollup merge of #82535 - wesleywiser:wip_codegen_thread_names, r=nagisa
Set codegen thread names

Set names on threads spawned during codegen. Various debugging and profiling tools can take advantage of this to show a more useful identifier for threads.

For example, gdb will show thread names in `info threads`:

```
(gdb) info threads
  Id   Target Id                                          Frame
  1    Thread 0x7fffefa7ec40 (LWP 2905) "rustc"           __pthread_clockjoin_ex (threadid=140737214134016, thread_return=0x0, clockid=<optimized out>, abstime=<optimized out>, block=<optimized out>)
    at pthread_join_common.c:145
  2    Thread 0x7fffefa7b700 (LWP 2957) "rustc"           0x00007ffff125eaa8 in llvm::X86_MC::initLLVMToSEHAndCVRegMapping(llvm::MCRegisterInfo*) ()
   from /home/wesley/.rustup/toolchains/stage1/lib/librustc_driver-f866439e29074957.so
  3    Thread 0x7fffeef0f700 (LWP 3116) "rustc"           futex_wait_cancelable (private=0, expected=0, futex_word=0x7fffe8602ac8) at ../sysdeps/nptl/futex-internal.h:183
* 4    Thread 0x7fffeed0e700 (LWP 3123) "rustc"           rustc_codegen_ssa:🔙:write::spawn_work (cgcx=..., work=...) at /home/wesley/code/rust/rust/compiler/rustc_codegen_ssa/src/back/write.rs:1573
  6    Thread 0x7fffe113b700 (LWP 3150) "opt foof.7rcbfp" 0x00007ffff2940e62 in llvm::CallGraph::populateCallGraphNode(llvm::CallGraphNode*) ()
   from /home/wesley/.rustup/toolchains/stage1/lib/librustc_driver-f866439e29074957.so
  8    Thread 0x7fffe0d39700 (LWP 3158) "opt foof.7rcbfp" 0x00007fffefe8998e in malloc_consolidate (av=av@entry=0x7ffe2c000020) at malloc.c:4492
  9    Thread 0x7fffe0f3a700 (LWP 3162) "opt foof.7rcbfp" 0x00007fffefef27c4 in __libc_open64 (file=0x7fffe0f38608 "foof.foof.7rcbfp3g-cgu.6.rcgu.o", oflag=524865) at ../sysdeps/unix/sysv/linux/open64.c:48
(gdb)
```

and Windows Performance Analyzer will also show this information when profiling:

![image](https://user-images.githubusercontent.com/831192/109231017-d311f780-7793-11eb-8072-ab836a830e90.png)
2021-02-26 15:52:35 +01:00
Guillaume Gomez
75959fb356
Rollup merge of #82506 - estebank:unused_variable_lint, r=lcnr
Properly account for non-shorthand pattern field in unused variable lint

Fix #82488
2021-02-26 15:52:33 +01:00
Guillaume Gomez
ee4129f70c
Rollup merge of #82491 - tmiasko:i, r=lcnr
Consider inexpensive inlining criteria first

Refactor inlining decisions so that inexpensive criteria are considered first:

1. Based on code generation attributes.
2. Based on MIR availability (examines call graph).
3. Based on MIR body.
2021-02-26 15:52:32 +01:00
Guillaume Gomez
039b1b62ac
Rollup merge of #82456 - klensy:or-else, r=estebank
Replaced some unwrap_or and map_or with lazy variants

Replaced some `unwrap_or` and `map_or` with `unwrap_or_else` and `map_or_else`.
2021-02-26 15:52:31 +01:00
Guillaume Gomez
a56bbb134f
Rollup merge of #82165 - nellshamrell:nell/fix-80658-B, r=estebank
Reword labels on E0308 involving async fn return type

Fix for #80658.

When someone writes code like this:

```rust
fn foo() -> u8 {
    async fn async_fn() -> () {}

    async_fn()
}
```

And they try to compile it, they will see an error that looks like this:

```bash
error[E0308]: mismatched types
 --> test.rs:4:5
  |
1 | fn foo() -> u8 {
  |             -- expected `u8` because of return type
2 |     async fn async_fn() -> () {}
  |                            -- checked the `Output` of this `async fn`, found opaque type
3 |
4 |     async_fn()
  |     ^^^^^^^^^^ expected `u8`, found opaque type
  |
  = note: while checking the return type of this `async fn`
  = note:     expected type `u8`
          found opaque type `impl Future`
```
2021-02-26 15:52:30 +01:00
Guillaume Gomez
0db8349fff
Rollup merge of #81940 - jhpratt:stabilize-str_split_once, r=m-ou-se
Stabilize str_split_once

Closes #74773
2021-02-26 15:52:29 +01:00
Guillaume Gomez
b0dc39ec12
Revert "Update normalize.css to 8.0.1" 2021-02-26 14:59:24 +01:00
bors
cecdb181ad Auto merge of #81458 - estebank:match-stmt-remove-semi, r=oli-obk
Detect match statement intended to be tail expression

CC #24157
2021-02-26 12:03:38 +00:00
Nikita Popov
c7091f5a07 Link crtbegin/crtend on musl to terminate .eh_frame
For some targets, rustc uses a "CRT fallback", where it links CRT
object files it ships instead of letting the host compiler link
them.

On musl, rustc currently links crt1, crti and crtn (provided by
libc), but does not link crtbegin and crtend (provided by libgcc).
In particular, crtend is responsible for terminating the .eh_frame
section. Lack of terminator may result in segfaults during
unwinding, as reported in #47551 and encountered by the LLVM 12
update in #81451.

This patch links crtbegin and crtend for musl as well, following
the table at the top of crt_objects.rs.
2021-02-26 11:02:51 +01:00
Jacob Hoffman-Andrews
ad7ed13eab Embed woff2 files in rustdoc binary. 2021-02-26 00:38:05 -08:00
Jacob Hoffman-Andrews
c47903f063 Add optional woff2 versions of FiraSans.
For browsers that support woff2 (most modern ones:
https://caniuse.com/woff2), this offers a reduction in download size
for these two fonts from 362k to 257k (32% reduction). It decreases the
total page size for `struct.String.html` (counting all subresources) by
about 2.5%.

If this is interesting, I'm happy to apply the same treatment to the
other fonts, but these two are the biggest.
2021-02-26 00:02:11 -08:00
lcnr
67f17342ee update tracking issue for relaxed_struct_unsize 2021-02-26 08:32:38 +01:00
klensy
16e08d223b fix env var name 2021-02-26 05:41:25 +03:00
Joshua Nelson
4d46735b8e Convert the rest of the standard library primitives to intra-doc links
Note that float methods in `core::intrinsics` weren't converted because
they are only defined in `std` (using language item hacks).
2021-02-25 20:32:49 -05:00
Joshua Nelson
9a75f4fed1 Convert primitives to use intra-doc links 2021-02-25 20:31:53 -05:00