Commit Graph

135077 Commits

Author SHA1 Message Date
Yuki Okushi 89051d81b9
Rollup merge of #79834 - m-ou-se:bye-linked-list-extras, r=Mark-Simulacrum
Remove deprecated linked_list_extras methods.

https://github.com/rust-lang/rust/issues/27794#issuecomment-667524201:
> I'd say give it about 2 weeks then remove them.

It's been 18 weeks. Time to remove them. :)

Closes #27794.
2020-12-13 11:05:32 +09:00
Yuki Okushi d559bb6707
Rollup merge of #79398 - pickfire:keyword, r=Dylan-DPC
Link loop/for keyword

Even though the reference already have all of these, I am just adding related keywords in the see also to let others easily click on the related keyword.
2020-12-13 11:05:30 +09:00
Yuki Okushi 1698773263
Rollup merge of #79360 - wchargin:wchargin-doc-iter-by-reference, r=m-ou-se
std::iter: document iteration over `&T` and `&mut T`

A colleague of mine is new to Rust, and mentioned that it was “slightly
confusing” to figure out what `&mut` does in iterating over `&mut foo`:

```rust
for value in &mut self.my_vec {
    // ...
}
```

My colleague had read the `std::iter` docs and not found the answer
there. There is a brief section at the top about “the three forms of
iteration”, which mentions `iter_mut`, but it doesn’t cover the purpose
of `&mut coll` for a collection `coll`. This patch adds an explanatory
section to the docs. I opted to create a new section so that it can
appear after the note that `impl<I: Iterator> IntoIterator for I`, and
it’s nice for the existing “three forms of iteration” to appear near the
top.

Test Plan:
Ran `./x.py doc library/core`, and the result looked good, including
links. Manually copy-pasted the two doctests into the playground and ran
them.

wchargin-branch: doc-iter-by-reference
2020-12-13 11:05:22 +09:00
bors dd11f45a68 Auto merge of #79988 - ssomers:btree_cleanup_5, r=Mark-Simulacrum
BTreeMap: capture a recurring use pattern as replace_kv

r? `@Mark-Simulacrum`
2020-12-13 01:28:59 +00:00
Stein Somers 0ae4c95eff BTreeMap: capture a recurring use pattern as replace_kv 2020-12-13 00:44:00 +01:00
Stein Somers ad75a96b34 BTreeMap: detect bulk_steal's count-1 underflow in release builds too 2020-12-13 00:37:30 +01:00
Arlie Davis 201a833eef Improve error handling in `symbols` proc-macro
This improves how the `symbols` proc-macro handles errors.
If it finds an error in its input, the macro does not panic.
Instead, it still produces an output token stream. That token
stream will contain `compile_error!(...)` macro invocations.
This will still cause compilation to fail (which is what we want),
but it will prevent meaningless errors caused by the output not
containing symbols that the macro normally generates.

This solves a small (but annoying) problem. When you're editing
rustc_span/src/symbol.rs, and you get something wrong (dup
symbol name, misordered symbol), you want to get only the errors
that are relevant, not a burst of errors that are irrelevant.
This change also uses the correct Span when reporting errors,
so you get errors that point to the correct place in
rustc_span/src/symbol.rs where something is wrong.

This also adds several unit tests which test the `symbols` proc-macro.

This commit also makes it easy to run the `symbols` proc-macro
as an ordinary Cargo test. Just run `cargo test`. This makes it
easier to do development on the macro itself, such as running it
under a debugger.

This commit also uses the `Punctuated` type in `syn` for parsing
comma-separated lists, rather than doing it manually.

The output of the macro is not changed at all by this commit,
so rustc should be completely unchanged. This just improves
quality of life during development.
2020-12-12 15:29:12 -08:00
Guillaume Gomez 98118bbde4 Fixes submit event of the search input
In HTML, when a button follows an input, if the enter keep is pressed on the input, instead of sending the submit event to the input, it'll create a click event on the button following it, which in this case made the help popup show up whenever "enter" was pressed.
2020-12-13 00:25:06 +01:00
bors f61e5cab76 Auto merge of #79976 - jyn514:assertion-failure, r=jyn514
Remove incorrect assert

Fixes an assertion failure when resolving `::std` (or any other crate that uses the `::` style, see https://github.com/rust-lang/rust/pull/79809/files#r541776478, https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Perf.20failing).

Unblocks https://github.com/rust-lang/rustc-perf/pull/806.

r? `@ghost` - this is a trivial fix and breaking rustc-perf so I'm going to approve it unilaterally. cc `@Mark-Simulacrum` `@Eric-Arellano`
2020-12-12 23:01:25 +00:00
Joshua Nelson 9df0348299 Fix building compiler docs with stage 0 2020-12-12 17:31:35 -05:00
Nadrieril 600efe7f10 Remove an unused dependency that made `rustdoc` crash 2020-12-12 22:13:03 +00:00
Camelid 5ce3f4c166 Resolve enum field visibility correctly
Previously, this code treated enum fields' visibility as if they were
struct fields. However, that's not correct because the visibility of a
struct field with `ast::VisibilityKind::Inherited` is private to the
module it's defined in, whereas the visibility of an *enum* field with
`ast::VisibilityKind::Inherited` is the visibility of the enum it
belongs to.
2020-12-12 14:04:59 -08:00
Aaron Hill e6fa6334dd
Properly capture trailing 'unglued' token
If we try to capture the `Vec<u8>` in `Option<Vec<u8>>`, we'll
need to capture a `>` token which was 'unglued' from a `>>` token.
The processing of unglueing a token for parsing purposes bypasses the
usual capturing infrastructure, so we currently lose the trailing `>`.
As a result, we fall back to the reparsed `TokenStream`, causing us to
lose spans.

This commit makes token capturing keep track of a trailing 'unglued'
token. Note that we don't need to care about unglueing except at the end
of the captured tokens - if we capture both the first and second unglued
tokens, then we'll end up capturing the full 'glued' token, which
already works correctly.
2020-12-12 16:28:13 -05:00
Noah 1e27b65d8e
Recover on `const impl<> X for Y` 2020-12-12 14:45:54 -06:00
Joshua Nelson 130dbe4642 Remove incorrect assert 2020-12-12 15:40:58 -05:00
Camelid 2b455aa7d8 rustdoc light theme: Fix CSS for selected buttons
The background was dark before, which made the text impossible to read.
Now the background is white, which is how selected `div`s are rendered.

As a result, the search results tabs now look identical to how they
used to look (before #79896).
2020-12-12 11:59:52 -08:00
bors 7efc097c4f Auto merge of #79957 - jyn514:smaller-span, r=GuillaumeGomez
[rustdoc] Calculate span information on demand instead of storing it ahead of time

This brings `size_of<clean::types::Span>()` down from over 100 bytes (!!) to only 12, the same as rustc. It brings `Item` down even more, from `784` to `680`.

~~TODO: I need to figure out how to do this for the JSON backend too. That uses `From` impls everywhere, which don't allow passing in the `Session` as an argument. `@P1n3appl3,` `@tmandry,` maybe one of you have ideas?~~ Figured it out, fortunately only two functions needed to be changed. I like the `convert_x()` format better than `From` everywhere but I'm open to feedback.

Helps with #79103
2020-12-12 19:41:56 +00:00
Stein Somers 50576420f5 BTreeMap: clarify comments and panics surrounding choose_parent_kv 2020-12-12 20:35:15 +01:00
bors 388eb24b6c Auto merge of #79969 - petrochenkov:outestidy, r=Mark-Simulacrum
tidy: Re-enable check for inline unit tests

It regressed in https://github.com/rust-lang/rust/pull/73265 and compiler crates are no longer checked.
2020-12-12 17:24:29 +00:00
bjorn3 d79e19f332 Don't require cmake and ninja when the LLVM backend is not used 2020-12-12 18:13:04 +01:00
bjorn3 16f69b5430 Don't checkout llvm-project when the LLVM backend isn't built 2020-12-12 18:06:07 +01:00
Vadim Petrochenkov 05b557cfc9 Remove some no longer necessary `#[cfg(test)]`s
With https://github.com/rust-lang/rust/pull/69838 inner modules are never touched in the outer module is unconfigured.
2020-12-12 19:20:37 +03:00
Vadim Petrochenkov ec09616078 tidy: Re-enable check for inline unit tests 2020-12-12 19:18:44 +03:00
LeSeulArtichaut 6a1f92b896 Fix typo in `DebruijnIndex` documentation
Co-authored-by: Rémy Rakic <lqd@users.noreply.github.com>
2020-12-12 16:13:06 +01:00
bors 4c5c4aa002 Auto merge of #79370 - jyn514:tidy-error, r=GuillaumeGomez
Don't abort rustdoc tests if `tidy` isn't installed

Follow-up to https://github.com/rust-lang/rust/pull/78752.

Before:

```
Check compiletest suite=rustdoc mode=rustdoc (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)

running 396 tests
..................................................2020-11-23T12:12:37.735649Z ERROR compiletest::runtest: fatal error, panic: "failed to run tidy - is it installed? - No such file or directory (os error 2)"
F................................................. 100/396
.................................................................................................... 200/396
.................................................................................................... 300/396
...............................i...............2020-11-23T12:15:00.271271Z ERROR compiletest::runtest: fatal error, panic: "failed to run tidy - is it installed? - No such file or directory (os error 2)"
F................................................
```

After:

```
Check compiletest suite=rustdoc mode=rustdoc (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)

running 4 tests
.FFF
failures:

---- [rustdoc] rustdoc/fn-pointer-arg-name.rs stdout ----

error: htmldocck failed!
status: exit code: 1
command: "/usr/bin/python" "/home/joshua/rustc/src/etc/htmldocck.py" "/home/joshua/rustc/build/x86_64-unknown-linux-gnu/test/rustdoc/fn-pointer-arg-name" "/home/joshua/rustc/src/test/rustdoc/fn-pointer-arg-name.rs"
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------
4: `@has` check failed
	`XPATH PATTERN` did not match
	// `@has` - '//*[`@class="rust` fn"]' 'pub fn f(callback: fn(len: usize, foo: u32))'

Encountered 1 errors

------------------------------------------

info: generating a diff against nightly rustdoc
failed to run tidy - is it installed? - Permission denied (os error 13)
failed to run tidy - is it installed? - Permission denied (os error 13)
 # a diff without running `tidy`
```

r? `@GuillaumeGomez`
2020-12-12 15:03:00 +00:00
Joshua Nelson 9684557c8f Small cleanups
- Use a tuple struct instead of a single field
- Enforce calling `source_callsite()` by making the inner span private
- Rename `empty` to `dummy`
2020-12-12 09:40:34 -05:00
Joshua Nelson f9b97a8e45 Ignore .css files in the diff
These are always static and never autogenerated, so the diffs aren't
useful.
2020-12-12 08:39:38 -05:00
Joshua Nelson 804b72af4a If tidy isn't installed, only give one error, not many 2020-12-12 08:38:13 -05:00
Joshua Nelson 409382dd3c Don't abort rustdoc tests if `tidy` isn't installed
Before:

```
Check compiletest suite=rustdoc mode=rustdoc (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)

running 396 tests
..................................................2020-11-23T12:12:37.735649Z ERROR compiletest::runtest: fatal error, panic: "failed to run tidy - is it installed? - No such file or directory (os error 2)"
F................................................. 100/396
.................................................................................................... 200/396
.................................................................................................... 300/396
...............................i...............2020-11-23T12:15:00.271271Z ERROR compiletest::runtest: fatal error, panic: "failed to run tidy - is it installed? - No such file or directory (os error 2)"
F................................................
```

After:

```
Check compiletest suite=rustdoc mode=rustdoc (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)

running 4 tests
.FFF
failures:

---- [rustdoc] rustdoc/fn-pointer-arg-name.rs stdout ----

error: htmldocck failed!
status: exit code: 1
command: "/usr/bin/python" "/home/joshua/rustc/src/etc/htmldocck.py" "/home/joshua/rustc/build/x86_64-unknown-linux-gnu/test/rustdoc/fn-pointer-arg-name" "/home/joshua/rustc/src/test/rustdoc/fn-pointer-arg-name.rs"
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------
4: @has check failed
	`XPATH PATTERN` did not match
	// @has - '//*[@class="rust fn"]' 'pub fn f(callback: fn(len: usize, foo: u32))'

Encountered 1 errors

------------------------------------------

info: generating a diff against nightly rustdoc
failed to run tidy - is it installed? - Permission denied (os error 13)
failed to run tidy - is it installed? - Permission denied (os error 13)
 # a diff without running `tidy`
```
2020-12-12 08:38:13 -05:00
bors 3f2088aa60 Auto merge of #79169 - LeSeulArtichaut:ty-lib, r=nikomatsakis
Create `rustc_type_ir`

Decided to start small 😄

This PR creates a `rustc_type_ir` crate as part of the WG-Traits plan to create a shared type library.
~~There already exists a `rustc_ty` crate, so I named the new crate `rustc_ty_library`. However I think it would make sense to rename the current `rustc_ty` to something else (e.g. `rustc_ty_passes`) to free the name for this new crate.~~

r? `@jackh726`
2020-12-12 12:36:18 +00:00
bors c3ed6681ff Auto merge of #79937 - RalfJung:miri, r=RalfJung
update Miri

Fixes https://github.com/rust-lang/rust/issues/79897
Cc `@rust-lang/miri` r? `@ghost`
2020-12-12 10:14:34 +00:00
Rich Kadel eb963ffe45 Fixes reported bugs in Rust Coverage
Fixes: #79569

Fixes: #79566
Fixes: #79565

For the first issue (#79569), I got hit a `debug_assert!()` before
encountering the reported error message (because I have `debug = true`
enabled in my config.toml).

The assertion showed me that some `SwitchInt`s can have more than one
target pointing to the same `BasicBlock`.

I had thought that was invalid, but since it seems to be possible, I'm
allowing this now.

I added a new test for this.

----

In the last two cases above, both tests (intentionally) fail to compile,
but the `InstrumentCoverage` pass is invoked anyway.

The MIR starts with an `Unreachable` `BasicBlock`, which I hadn't
encountered before. (I had assumed the `InstrumentCoverage` pass
would only be invoked with MIRs from successful compilations.)

I don't have test infrastructure set up to test coverage on files that
fail to compile, so I didn't add a new test.
2020-12-11 21:40:22 -08:00
Joshua Nelson 0e574fb39a Fix the JSON backend
This was simpler than expected.
2020-12-12 00:01:25 -05:00
Joshua Nelson 4fa95b3a07 Calculate span info on-demand instead of ahead of time
This should *vastly* reduce memory usage.
2020-12-12 00:01:01 -05:00
Joshua Nelson af6aa9f431 Pass Session into renderer 2020-12-12 00:00:09 -05:00
bors 602899cd01 Auto merge of #79931 - RalfJung:no-redundant-storage-live, r=oli-obk
make redundant StorageLive UB

The interesting behavior of StorageLive in loops (https://github.com/rust-lang/rust/issues/42371) has been fixed, so we can now finally make it a hard error to mark a local as live that is already live. :)

r? `@oli-obk`
Fixes https://github.com/rust-lang/rust/issues/42371
2020-12-12 02:40:17 +00:00
bors 5bd9b60333 Auto merge of #79553 - sexxi-goose:mir_min_cap_writeback, r=nikomatsakis
Capture precise paths in THIR and MIR

This PR allows THIR and MIR to use the result of the new capture analysis to actually capture precise paths

To achieve we:
- Writeback min capture results to TypeckResults
- Move handling upvars to PlaceBuilder in mir_build
- Lower precise paths in THIR build by reading min_captures
- Search for ancestors in min_capture when trying to build a MIR place which starts off of an upvar

Closes: https://github.com/rust-lang/project-rfc-2229/issues/10

Partly implements: rust-lang/project-rfc-2229#18

Work that remains (not in this PR):
- [ ] [Known bugs when feature gate is enabled](https://github.com/rust-lang/project-rfc-2229/projects/1?card_filter_query=label%3Abug)
- [ ] Use min_capure_map for
  - [ ] Liveness analysis
  - [ ] rustc_mir/interpret/validity.rs
  - [ ] regionck
- [ ] rust-lang/project-rfc-2229#8
- [ ] remove closure_captures and upvar_capture_map

r? `@ghost`
2020-12-12 00:23:29 +00:00
Matthias Krüger cf10a0abf2 fix clippy::unnecessary_filter_map 2020-12-11 23:02:19 +01:00
Matthias Krüger 5833f74a9c use if let Some(x) = .. instead of ...map(|x|) to conditionally run fns that return () (clippy::option_map_unit_fn) 2020-12-11 23:02:19 +01:00
Matthias Krüger b7795e135a fix clippy::{needless_bool, manual_unwrap_or} 2020-12-11 23:02:19 +01:00
Matthias Krüger db6c50998c don't clone types that are copy (clippy::clone_on_copy) 2020-12-11 23:02:19 +01:00
Matthias Krüger 82fe5c1662 don't convert types into identical types with .into() (clippy::useless_conversion) 2020-12-11 23:02:19 +01:00
Matthias Krüger 5c8de1cf49 use strip_prefix over slicing (clippy::manual_strip) 2020-12-11 23:02:17 +01:00
bors 9eb3a7ceaf Auto merge of #79349 - Nemo157:issue-79201, r=jyn514
Apply `doc(cfg)` from parent items while collecting trait impls

Because trait impls bypass the standard `clean` hierarchy they do not participate in the `propagate_doc_cfg` pass, so instead we need to pre-collect all possible `doc(cfg)` attributes that will apply to them when cleaning.

fixes #79201
2020-12-11 22:00:00 +00:00
Jack Huey ed80815bf2 Move binder for dyn to each list item 2020-12-11 15:02:46 -05:00
JCTyblaidd 175226a01c Rustfmt 2020-12-11 19:28:20 +00:00
JCTyblaidd 6ce29906f1
Fix rustfmt failure 2020-12-11 19:11:39 +00:00
Guillaume Gomez 9c36491538 Fix main section position so that the search input remains clickable 2020-12-11 20:07:24 +01:00
JCTyblaidd 56d89364a5 Add post-initialization hook for static memory initialized using the interpereter. 2020-12-11 18:42:36 +00:00
Ralf Jung 17230b4068 update Miri 2020-12-11 18:08:44 +01:00