Commit graph

143499 commits

Author SHA1 Message Date
Guillaume Gomez cb91c6f24d Fix indent in JS files 2021-05-12 11:28:00 +02:00
Guillaume Gomez d8b10692a0 Remove unused CSS rules 2021-05-12 11:27:59 +02:00
Guillaume Gomez e150aebbdc Remove "loading content" which is now unnecessary 2021-05-12 11:27:59 +02:00
Kornel 3773740719 #[inline(always)] on basic pointer methods 2021-05-12 10:10:28 +01:00
bors ac923d94f8 Auto merge of #83610 - bjorn3:driver_cleanup, r=cjgillot
rustc_driver cleanup

Best reviewed one commit at a time.
2021-05-12 08:38:03 +00:00
bors c1e7e361f7 Auto merge of #84278 - Aaron1011:feature/new-proc-macro-meta-span, r=estebank
Implement span quoting for proc-macros

This PR implements span quoting, allowing proc-macros to produce spans
pointing *into their own crate*. This is used by the unstable
`proc_macro::quote!` macro, allowing us to get error messages like this:

```
error[E0412]: cannot find type `MissingType` in this scope
  --> $DIR/auxiliary/span-from-proc-macro.rs:37:20
   |
LL | pub fn error_from_attribute(_args: TokenStream, _input: TokenStream) -> TokenStream {
   | ----------------------------------------------------------------------------------- in this expansion of procedural macro `#[error_from_attribute]`
...
LL |             field: MissingType
   |                    ^^^^^^^^^^^ not found in this scope
   |
  ::: $DIR/span-from-proc-macro.rs:8:1
   |
LL | #[error_from_attribute]
   | ----------------------- in this macro invocation
```

Here, `MissingType` occurs inside the implementation of the proc-macro
`#[error_from_attribute]`. Previosuly, this would always result in a
span pointing at `#[error_from_attribute]`

This will make many proc-macro-related error message much more useful -
when a proc-macro generates code containing an error, users will get an
error message pointing directly at that code (within the macro
definition), instead of always getting a span pointing at the macro
invocation site.

This is implemented as follows:
* When a proc-macro crate is being *compiled*, it causes the `quote!`
  macro to get run. This saves all of the sapns in the input to `quote!`
  into the metadata of *the proc-macro-crate* (which we are currently
  compiling). The `quote!` macro then expands to a call to
  `proc_macro::Span::recover_proc_macro_span(id)`, where `id` is an
opaque identifier for the span in the crate metadata.
* When the same proc-macro crate is *run* (e.g. it is loaded from disk
  and invoked by some consumer crate), the call to
`proc_macro::Span::recover_proc_macro_span` causes us to load the span
from the proc-macro crate's metadata. The proc-macro then produces a
`TokenStream` containing a `Span` pointing into the proc-macro crate
itself.

The recursive nature of 'quote!' can be difficult to understand at
first. The file `src/test/ui/proc-macro/quote-debug.stdout` shows
the output of the `quote!` macro, which should make this eaier to
understand.

This PR also supports custom quoting spans in custom quote macros (e.g.
the `quote` crate). All span quoting goes through the
`proc_macro::quote_span` method, which can be called by a custom quote
macro to perform span quoting. An example of this usage is provided in
`src/test/ui/proc-macro/auxiliary/custom-quote.rs`

Custom quoting currently has a few limitations:

In order to quote a span, we need to generate a call to
`proc_macro::Span::recover_proc_macro_span`. However, proc-macros
support renaming the `proc_macro` crate, so we can't simply hardcode
this path. Previously, the `quote_span` method used the path
`crate::Span` - however, this only works when it is called by the
builtin `quote!` macro in the same crate. To support being called from
arbitrary crates, we need access to the name of the `proc_macro` crate
to generate a path. This PR adds an additional argument to `quote_span`
to specify the name of the `proc_macro` crate. Howver, this feels kind
of hacky, and we may want to change this before stabilizing anything
quote-related.

Additionally, using `quote_span` currently requires enabling the
`proc_macro_internals` feature. The builtin `quote!` macro
has an `#[allow_internal_unstable]` attribute, but this won't work for
custom quote implementations. This will likely require some additional
tricks to apply `allow_internal_unstable` to the span of
`proc_macro::Span::recover_proc_macro_span`.
2021-05-12 05:59:28 +00:00
Aaron Hill dbf49102aa
Update stderr
The spans generated by `quote!` are (intentionally) no longer all the
same, so I removed that check entirely.
2021-05-12 00:51:31 -04:00
Aaron Hill f916b0474a
Implement span quoting for proc-macros
This PR implements span quoting, allowing proc-macros to produce spans
pointing *into their own crate*. This is used by the unstable
`proc_macro::quote!` macro, allowing us to get error messages like this:

```
error[E0412]: cannot find type `MissingType` in this scope
  --> $DIR/auxiliary/span-from-proc-macro.rs:37:20
   |
LL | pub fn error_from_attribute(_args: TokenStream, _input: TokenStream) -> TokenStream {
   | ----------------------------------------------------------------------------------- in this expansion of procedural macro `#[error_from_attribute]`
...
LL |             field: MissingType
   |                    ^^^^^^^^^^^ not found in this scope
   |
  ::: $DIR/span-from-proc-macro.rs:8:1
   |
LL | #[error_from_attribute]
   | ----------------------- in this macro invocation
```

Here, `MissingType` occurs inside the implementation of the proc-macro
`#[error_from_attribute]`. Previosuly, this would always result in a
span pointing at `#[error_from_attribute]`

This will make many proc-macro-related error message much more useful -
when a proc-macro generates code containing an error, users will get an
error message pointing directly at that code (within the macro
definition), instead of always getting a span pointing at the macro
invocation site.

This is implemented as follows:
* When a proc-macro crate is being *compiled*, it causes the `quote!`
  macro to get run. This saves all of the sapns in the input to `quote!`
  into the metadata of *the proc-macro-crate* (which we are currently
  compiling). The `quote!` macro then expands to a call to
  `proc_macro::Span::recover_proc_macro_span(id)`, where `id` is an
opaque identifier for the span in the crate metadata.
* When the same proc-macro crate is *run* (e.g. it is loaded from disk
  and invoked by some consumer crate), the call to
`proc_macro::Span::recover_proc_macro_span` causes us to load the span
from the proc-macro crate's metadata. The proc-macro then produces a
`TokenStream` containing a `Span` pointing into the proc-macro crate
itself.

The recursive nature of 'quote!' can be difficult to understand at
first. The file `src/test/ui/proc-macro/quote-debug.stdout` shows
the output of the `quote!` macro, which should make this eaier to
understand.

This PR also supports custom quoting spans in custom quote macros (e.g.
the `quote` crate). All span quoting goes through the
`proc_macro::quote_span` method, which can be called by a custom quote
macro to perform span quoting. An example of this usage is provided in
`src/test/ui/proc-macro/auxiliary/custom-quote.rs`

Custom quoting currently has a few limitations:

In order to quote a span, we need to generate a call to
`proc_macro::Span::recover_proc_macro_span`. However, proc-macros
support renaming the `proc_macro` crate, so we can't simply hardcode
this path. Previously, the `quote_span` method used the path
`crate::Span` - however, this only works when it is called by the
builtin `quote!` macro in the same crate. To support being called from
arbitrary crates, we need access to the name of the `proc_macro` crate
to generate a path. This PR adds an additional argument to `quote_span`
to specify the name of the `proc_macro` crate. Howver, this feels kind
of hacky, and we may want to change this before stabilizing anything
quote-related.

Additionally, using `quote_span` currently requires enabling the
`proc_macro_internals` feature. The builtin `quote!` macro
has an `#[allow_internal_unstable]` attribute, but this won't work for
custom quote implementations. This will likely require some additional
tricks to apply `allow_internal_unstable` to the span of
`proc_macro::Span::recover_proc_macro_span`.
2021-05-12 00:51:31 -04:00
bors 9f6717c15e Auto merge of #85206 - ehuss:update-cargo, r=ehuss
Update cargo

8 commits in e51522ab3db23b0d8f1de54eb1f0113924896331..070e459c2d8b79c5b2ac5218064e7603329c92ae
2021-05-07 21:29:52 +0000 to 2021-05-11 18:12:23 +0000
- Fix rustdoc warnings (rust-lang/cargo#9468)
- Improve performance of git status check in `cargo package`. (rust-lang/cargo#9478)
- Link to the new rustc tests chapter. (rust-lang/cargo#9477)
- Bump index cache version to deal with semver metadata version mismatch. (rust-lang/cargo#9476)
- Fix Url::into_string deprecation warning (rust-lang/cargo#9475)
- Fix rust-lang/cargo#4482 and rust-lang/cargo#9449: set Fossil ignore and clean settings locally (rust-lang/cargo#9469)
- Improve two error messages (rust-lang/cargo#9472)
- Fix `cargo install` with a semver metadata version. (rust-lang/cargo#9467)
2021-05-12 03:32:53 +00:00
Esteban Küber 7697ce4560 Recover from invalid struct item syntax
Parse unsupported "default field const values":

```rust
struct S {
    field: Type = const_val,
}
```

Recover from small `:` typo and provide suggestion:

```rust
struct S {
    field; Type,
    field2= Type,
}
```
2021-05-11 18:48:57 -07:00
Andrew Halle 3c06f00985 Fix typo in comment
missing space in "rootseparator"
2021-05-11 18:13:01 -07:00
bors ea3068efe4 Auto merge of #85192 - klensy:bump-deps, r=Mark-Simulacrum
updated deps

filetime v0.2.12 -> v0.2.14
https://github.com/alexcrichton/filetime/compare/0.2.12...0.2.14

socket2 v0.3.16 -> v0.3.19
https://github.com/rust-lang/socket2/commits/v0.3.x

tar v0.4.29 -> v0.4.33
https://github.com/alexcrichton/tar-rs/compare/0.4.29...0.4.33

this drops dependency on redox_syscall 0.1.*

---
measureme v9.1.0 -> v9.1.1
https://github.com/rust-lang/measureme/compare/9.1.0...9.1.1

this drops dependency on memmap v0.7.0

---
version_check v0.9.1 -> v0.9.3
https://github.com/SergioBenitez/version_check/compare/v0.9.1...v0.9.3
fixes version parse
2021-05-12 01:09:33 +00:00
Eric Huss f3287a68b1 Update cargo 2021-05-11 17:39:51 -07:00
Eric Huss 62c358d554 Update books 2021-05-11 17:21:03 -07:00
Dr. Chat b1bb5d662c Add initial asm!() support for PowerPC
This includes GPRs and FPRs only
2021-05-11 19:04:16 -05:00
Mateusz Mikuła b04fd78d66 update cc crate
To pull in this fix: 801a87bf2f
2021-05-12 00:55:03 +02:00
bors 890803d372 Auto merge of #85199 - JohnTitor:rollup-gz5m06c, r=JohnTitor
Rollup of 8 pull requests

Successful merges:

 - #83501 (rustdoc: Add unstable CLI option to show basic type layout information)
 - #85018 (shrinking the deprecated method span)
 - #85124 (rustdoc: remove explicit boolean comparisons.)
 - #85136 (Change param name (k to key and v to value) in std::env module)
 - #85162 (Fix typo in variable name)
 - #85187 (Use .name_str() to format primitive types in error messages)
 - #85191 (Improve rustdoc gui tester)
 - #85196 (Revert "Auto merge of #84797 - richkadel:cover-unreachable-statements…)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-05-11 22:39:48 +00:00
Yuki Okushi e27f20a9a2
Rollup merge of #85196 - richkadel:reverts-cover-unreachable-statements, r=tmandry
Revert "Auto merge of #84797 - richkadel:cover-unreachable-statements…

This reverts commit e5f83d24ae, reversing
changes made to ac888e8675.

See https://github.com/rust-lang/rust/pull/84797#issuecomment-839068132

r? `@tmandry`
2021-05-12 07:18:06 +09:00
Yuki Okushi 8f3c2cce36
Rollup merge of #85191 - GuillaumeGomez:improve-rustdoc-gui-tester, r=Mark-Simulacrum
Improve rustdoc gui tester

I cherry-picked the commit from https://github.com/rust-lang/rust/pull/84834 (and modified it a bit). I also used this opportunity to update it to last version (forgot to update GUI test in https://github.com/rust-lang/rust/pull/85074, really can't wait to make https://github.com/rust-lang/rust/pull/84586 finally work).

cc `@Mark-Simulacrum` for the changes in bootstrap.

r? `@jsha`
2021-05-12 07:18:05 +09:00
Yuki Okushi c4c654f422
Rollup merge of #85187 - FabianWolff:issue-84976, r=jackh726
Use .name_str() to format primitive types in error messages

This pull request fixes #84976. The problem described there is caused by this code
506e75cbf8/compiler/rustc_middle/src/ty/error.rs (L161-L166)
using `Debug` formatting (`{:?}`), while the proper solution is to call `name_str()` of `ty::IntTy`, `ty::UintTy` and `ty::FloatTy`, respectively.
2021-05-12 07:18:04 +09:00
Yuki Okushi 9ad5c4d8ea
Rollup merge of #85162 - LingMan:patch-1, r=varkor
Fix typo in variable name

All other sibling functions call this variable "slot", so "slote" was most likely a typo.
2021-05-12 07:18:03 +09:00
Yuki Okushi 6ec4f91610
Rollup merge of #85136 - shirshak55:master, r=dtolnay
Change param name (k to key and v to value) in std::env module

1. When I was reading code the ide displayed `k` and `v`, so I
thought it would be better to show key and value?

2. I noticed var method already uses `key` instead of `k` so it
is more consistent to use `key` instead of `k`?

Thanks
2021-05-12 07:18:02 +09:00
Yuki Okushi 4ab305031c
Rollup merge of #85124 - jsha:trust-the-bool, r=GuillaumeGomez
rustdoc: remove explicit boolean comparisons.

For boolean variables it's shorter and more readable to check the value directly, or negate it with `!`.

In a couple of cases I reordered an if/else pair because it made the initial `if` statement simpler.

An example of a style guide recommending this: https://airbnb.io/javascript/#comparison--shortcuts

r? `@GuillaumeGomez`
2021-05-12 07:18:01 +09:00
Yuki Okushi 649b385471
Rollup merge of #85018 - hi-rustin:rustin-patch-84637, r=estebank
shrinking the deprecated method span

close https://github.com/rust-lang/rust/issues/84637
2021-05-12 07:18:00 +09:00
Yuki Okushi 40be1d3152
Rollup merge of #83501 - camelid:rustdoc-layout, r=jyn514,GuillaumeGomez
rustdoc: Add unstable CLI option to show basic type layout information

Closes #75988.

Right now it just shows the size.
2021-05-12 07:17:59 +09:00
Jacob Hoffman-Andrews 09454513d1 Move global click handlers to per-element ones.
In rustdoc's main.js, we had an onclick handler for the whole document
that would dispatch to handlers for various elements. This change
attaches the handlers to the elements that trigger them, instead.
This simplfies the code and avoids reimplementing the browser's bubbling
functionality.

As part of this change, change from a class to an id for help button.

Move the handlers and associated code for highlighting source lines into
source-script.js (and factor out a shared regex).
2021-05-11 13:45:08 -07:00
Fabian Wolff 69a4ae2030 Add explanatory comment to the issue-84976.rs test case 2021-05-11 21:51:58 +02:00
Rich Kadel bea112ba07 Revert "Auto merge of #84797 - richkadel:cover-unreachable-statements, r=tmandry"
This reverts commit e5f83d24ae, reversing
changes made to ac888e8675.
2021-05-11 12:47:08 -07:00
Mark Rousskov e400595190 Store VariantIdx to distinguish enum variants
This saves ~24% of the instructions on the match-stress-enum benchmark.
2021-05-11 15:44:56 -04:00
bors 5c02926546 Auto merge of #84904 - ssomers:btree_drop_kv_in_place, r=Mark-Simulacrum
BTree: no longer copy keys and values before dropping them

When dropping BTreeMap or BTreeSet instances, keys-value pairs are up to now each copied and then dropped, at least according to source code. This is because the code for dropping and for iterators is shared.

This PR postpones the treatment of doomed key-value pairs from the intermediate functions `deallocating_next`(`_back`) to the last minute, so the we can drop the keys and values in place. According to the library/alloc benchmarks, this does make a difference, (and a positive difference with an `#[inline]` on `drop_key_val`). It does not change anything for #81444 though.

r? `@Mark-Simulacrum`
2021-05-11 19:36:54 +00:00
klensy 73b39c84a7 fix tidy 2021-05-11 22:25:10 +03:00
Guillaume Gomez 6b9499085b Make rustdoc-gui test suite able to run with different sub directories 2021-05-11 21:14:40 +02:00
klensy dcdc308641 updated deps 2021-05-11 22:03:59 +03:00
Guillaume Gomez 1b0976c42f Update toggle-docs GUI test to last version 2021-05-11 20:56:16 +02:00
Guillaume Gomez d5a24b0a33 Move rustdoc-gui rust libraries into their own folder and prepare the field for more libraries 2021-05-11 20:56:16 +02:00
LeSeulArtichaut 985fb4caa0 Add helper for switching safety contexts 2021-05-11 20:35:44 +02:00
LeSeulArtichaut d5ea294114 Test -Zthir-unsafeck for unused unsafe blocks 2021-05-11 20:35:44 +02:00
LeSeulArtichaut a95b342f02 Test -Zthir-unsafeck for unsafe function calls 2021-05-11 20:35:38 +02:00
Roxane 564b4de626 use the correct attributes and add helper function 2021-05-11 14:01:33 -04:00
Jacob Hoffman-Andrews f510e412e9 rustdoc: remove explicit boolean comparisons.
For boolean variables it's shorter and more readable to check the value
directly, or negate it with `!`.

In a couple of cases I reordered an if/else pair because it made the
initial `if` statement simpler.

Removed unused isType parameter from two functions.
2021-05-11 10:50:09 -07:00
Camelid d43701caa0 Disable layout docs for type aliases for now
There are issues with computing layout for type aliases; see #85103.
Once the issues are fixed, we should re-enable layout docs for them.
2021-05-11 10:19:46 -07:00
Camelid 9b89d01bbb Enable --show-type-layout for the rustdoc API docs 2021-05-11 09:55:32 -07:00
Camelid 8b9298bbaa Add note to docs when layout cannot be computed
This should prevent confusion about why generic types don't have layout
docs.
2021-05-11 09:55:32 -07:00
Camelid 879a914eea Add test case for zero-sized types 2021-05-11 09:55:31 -07:00
Camelid 61a8479472 Make test more specific 2021-05-11 09:55:31 -07:00
Camelid bcbc727672 Apply suggestions from code review
Co-authored-by: Ivan Tham <pickfire@riseup.net>
2021-05-11 09:55:31 -07:00
Camelid 8048c70568 Add tcx local variable 2021-05-11 09:55:31 -07:00
Camelid db3a06d01e Fix a few small things 2021-05-11 09:55:31 -07:00
Camelid 9615d6dd48 Enable --show-type-layout for the rustc API docs 2021-05-11 09:55:31 -07:00
Camelid 12ee920a7c Only show type layout info if --show-type-layout is passed 2021-05-11 09:55:31 -07:00