Dylan DPC [Tue, 22 Jun 2021 22:20:24 +0000 (00:20 +0200)]
Rollup merge of #86557 - ehuss:update-books, r=ehuss
Update books
## nomicon
10 commits in 55de6fa3c1f331774da19472c9ee57d2ae9eb039..b9ca313e687c991223e23e5520529815dc281205
2021-05-12 00:31:01 +0900 to 2021-06-22 12:02:20 -0400
- The #[repr(C)] attribute on the callback example is not necessary, since the type is not used in C.
- Reorganize some chapters (rust-lang-nursery/nomicon#282)
- Mention "extern types" on the opaque structs section (rust-lang-nursery/nomicon#273)
- Clarify the conditions on the aliasing section (rust-lang-nursery/nomicon#272)
- Upgrade to edition 2018 (rust-lang-nursery/nomicon#280)
- Update some wording making reference to issues/RFCs (rust-lang-nursery/nomicon#271)
- Some improvements on the "subtyping" chapter (rust-lang-nursery/nomicon#278)
- Clarify casting between the same size fixed ints (rust-lang-nursery/nomicon#277)
- Add a link to show why unused lifetimes on structs are forbidden (rust-lang-nursery/nomicon#276)
- Fix small typo in the Drop Check chapter (rust-lang-nursery/nomicon#275)
## reference
8 commits in 8f598e2af6c25b4a7ee88ef6a8196d9b8ea50ca8..d9699fa8f3186440fdaadd703d63d8d42322c176
2021-06-01 19:00:46 +0100 to 2021-06-21 12:23:10 -0700
- Make explicit reference to scrutinee expression in grammar snippet (rust-lang-nursery/reference#1044)
- Document sub-namespaces. (rust-lang-nursery/reference#1043)
- Default all examples to 2018 edition. (rust-lang-nursery/reference#1041)
- Minor update to macros. (rust-lang-nursery/reference#1048)
- (rust-lang-nursery/reference#1049)
- Add a note why the same size int casting is a no-op (rust-lang-nursery/reference#1046)
- Add notes on `#[target_feature]` for wasm (rust-lang-nursery/reference#1047)
- Make statement about variable visibility more precise (rust-lang-nursery/reference#1045)
## rustc-dev-guide
8 commits in c8da5bfd1c7c71d90ef1646f5e0a9f6609d5c78a..fe34beddb41dea5cb891032512a8d5b842b99696
2021-06-04 09:08:56 +0200 to 2021-06-21 21:50:12 +0200
- Update "Inference variables" section (rust-lang/rustc-dev-guide#1145)
- Document how to run unit tests (rust-lang/rustc-dev-guide#1141)
- We stopped using allow_internal_unstable a while ago (rust-lang/rustc-dev-guide#1142)
- Change the feature used as an example of stabilizing lib features (rust-lang/rustc-dev-guide#1143)
- We use HIR to do type inference, trait solving and type checking (rust-lang/rustc-dev-guide#1139)
- Add suggested settings note for coc (rust-lang/rustc-dev-guide#1144)
- move 7/8 to prose
- Add a section on keeping things up to date in the git section
Dylan DPC [Tue, 22 Jun 2021 22:20:22 +0000 (00:20 +0200)]
Rollup merge of #86542 - GuillaumeGomez:line-numbers-aligned-with-content, r=jyn514
Line numbers aligned with content
We had the issue a few times in the past where the source code pages' content wasn't aligned with the line numbers but completely below. This test will prevent this change to go unnoticed.
The first commit comes from https://github.com/rust-lang/rust/pull/86541 so it needs it to be merged first.
Dylan DPC [Tue, 22 Jun 2021 22:20:21 +0000 (00:20 +0200)]
Rollup merge of #86523 - LeSeulArtichaut:macros-disambiguators, r=jyn514
Improvements to intra-doc link macro disambiguators
A few small improvements around macro disambiguators:
- display the link text as it was entered: previously `[macro!()]` would be displayed without the parantheses (fixes #86309)
- support `!{}` and `![]` as macro disambiguators (fixes #86310)
Dylan DPC [Tue, 22 Jun 2021 22:20:20 +0000 (00:20 +0200)]
Rollup merge of #86521 - the8472:add-footgun-comments, r=RalfJung
Add comments around code where ordering is important due for panic-safety
Iterators contain arbitrary code which may panic. Unsafe code has to be
careful to do its state updates at the right point between calls that may panic.
As requested in https://github.com/rust-lang/rust/pull/86452#discussion_r655153948
bors [Tue, 22 Jun 2021 17:34:55 +0000 (17:34 +0000)]
Auto merge of #86045 - jsgf:fix-emit-path-hashing, r=bjorn3
Fix emit path hashing
With `--emit KIND=PATH`, the PATH should not affect hashes used for dependency tracking. It does not with other ways of specifying output paths (`-o` or `--out-dir`).
Also updates `rustc -Zls` to print more info about crates, which is used here to implement a `run-make` test.
It seems there was already a test explicitly checking that `OutputTypes` hash *is* affected by the path. I think this behaviour is wrong, so I updated the test.
The8472 [Mon, 21 Jun 2021 19:29:43 +0000 (21:29 +0200)]
Add comments around code where ordering is important due for panic-safety
Iterators contain arbitrary code which may panic. Unsafe code has to be
careful to do its state updates at the right point between calls
that may panic.
bors [Tue, 22 Jun 2021 14:53:58 +0000 (14:53 +0000)]
Auto merge of #86368 - michaelwoerister:lexing-ice, r=davidtwco
Disambiguate between SourceFiles from different crates even if they have the same path
This PR fixes an ICE that can occur when the compiler encounters a source file that is part of both the local crate and an upstream crate:
1. While importing source files from an upstream crate the compiler creates a `SourceFile` entry for `foo.rs` in the `SourceMap`. Since this is an imported source file its `src` field is `None`.
2. At a later point the parser encounters `foo.rs` again. It tells the `SourceMap` to load the file but because we already have an entry for `foo.rs` the `SourceMap` will return the existing version with `src == None`.
3. The parser proceeds under the assumption that `src.is_some()` and panics when actually trying to use the file's contents.
This PR fixes the issue by adding the source file's associated `CrateNum` to the `SourceMap`'s interning key. As a consequence the two instances of the file will each have a separate entry in the `SourceMap`. They just happen to share the same file path. This approach seemed less problematic to me than trying to mutate the `SourceFile` after it had already been created.
Another, more involved, approach might be to merge the `src` and the `external_src` field.
Yuki Okushi [Tue, 22 Jun 2021 11:01:06 +0000 (20:01 +0900)]
Rollup merge of #86537 - inquisitivecrystal:mark-edition-tests-check-pass, r=JohnTitor
Mark some edition tests as check-pass
## Overview
This helps with #62277. In short, there are some tests that were marked as `build-pass` when it was unclear whether `check-pass` might be more appropriate. This PR marks some of those tests as `compile-pass`, in addition to making some incidental formatting improvements.
## A brief explanation of why this is correct
These tests fall into a few buckets.
These test a lint for a keyword added in a new edition and the corresponding changes in keyword rules.
`src/test/ui/editions/edition-feature-ok.rs`
This checks that a feature related to an edition transition is valid.
`src/test/ui/editions/edition-imports-virtual-2015-ambiguity.rs`
This checks that imports between editions work correctly.
`src/test/ui/editions/edition-keywords-2015-2015-expansion.rs`
`src/test/ui/editions/edition-keywords-2018-2015-expansion.rs`
This checks the interaction between a change in keyword status over editions and macros.
All of the things being tested come before linking and codegen, so it is safe to use `check-pass` for them.
Yuki Okushi [Tue, 22 Jun 2021 11:01:05 +0000 (20:01 +0900)]
Rollup merge of #86517 - camsteffen:unused-unsafe-async, r=LeSeulArtichaut
Fix `unused_unsafe` around `await`
Enables `unused_unsafe` lint for `unsafe { future.await }`.
The existing test for this is `unsafe { println!() }`, so I assume that `println!` used to contain compiler-generated unsafe but this is no longer true, and so the existing test is broken. I replaced the test with `unsafe { ...await }`. I believe `await` is currently the only instance of compiler-generated unsafe.
Reverts some parts of #85421, but the issue predates that PR.
Yuki Okushi [Tue, 22 Jun 2021 11:01:04 +0000 (20:01 +0900)]
Rollup merge of #86501 - jyn514:doctest-cleanup, r=CraftSpider
Cleanup handling of `crate_name` for doctests
- Remove unnecessary reallocation
- Remove unnecessary messing around with `queries` for the crate name; it's simpler and faster to go through the TyCtxt instead
- Rename `cratename` -> `crate_name` for consistency with the rest of the compiler
Yuki Okushi [Tue, 22 Jun 2021 11:01:01 +0000 (20:01 +0900)]
Rollup merge of #86402 - tspiteri:source-woff2, r=jsha
rustdoc: add optional woff2 versions of Source Serif and Source Code
This provides woff2 versions of Source Serif and Source Code similar to how #82545 provides woff2 versions of Fira Sans. The total byte count for the six files (three for each font family) is reduced by 25% from 476 KiB to 358 KiB.
bors [Tue, 22 Jun 2021 09:30:15 +0000 (09:30 +0000)]
Auto merge of #84910 - eopb:stabilize_int_error_matching, r=yaahc
stabilize `int_error_matching`
closes #22639
> It has been over half a year since https://github.com/rust-lang/rust/pull/77640#pullrequestreview-511263516, and the indexing question is rejected in https://github.com/rust-lang/rust/pull/79728#pullrequestreview-633030341, so I guess we can submit another stabilization attempt? 😉
_Originally posted by `@kennytm` in https://github.com/rust-lang/rust/issues/22639#issuecomment-831738266_
bors [Tue, 22 Jun 2021 07:01:54 +0000 (07:01 +0000)]
Auto merge of #85707 - jam1garner:future_prelude_collision_lint, r=nikomatsakis
Add `future_prelude_collision` lint
Implements #84594. (RFC rust-lang/rfcs#3114 ([rendered](https://github.com/rust-lang/rfcs/blob/master/text/3114-prelude-2021.md))) Not entirely complete but wanted to have my progress decently available while I finish off the last little bits.
Things left to implement:
* [x] UI tests for lints
* [x] Only emit lint for 2015 and 2018 editions
* [ ] Lint name/message bikeshedding
* [x] Implement for `FromIterator` (from best I can tell, the current approach as mentioned from [this comment](https://github.com/rust-lang/rust/issues/84594#issuecomment-847288288) won't work due to `FromIterator` instances not using dot-call syntax, but if I'm correct about this then that would also need to be fixed for `TryFrom`/`TryInto`)*
* [x] Add to `rust-2021-migration` group? (See #85512) (added to `rust-2021-compatibility` group)
* [ ] Link to edition guide in lint docs
*edit: looked into it, `lookup_method` will also not be hit for `TryFrom`/`TryInto` for non-dotcall syntax. If anyone who is more familiar with typecheck knows the equivalent for looking up associated functions, feel free to chime in.
bors [Tue, 22 Jun 2021 01:14:31 +0000 (01:14 +0000)]
Auto merge of #86527 - JohnTitor:rollup-cbu78g4, r=JohnTitor
Rollup of 11 pull requests
Successful merges:
- #85054 (Revert SGX inline asm syntax)
- #85182 (Move `available_concurrency` implementation to `sys`)
- #86037 (Add `io::Cursor::{remaining, remaining_slice, is_empty}`)
- #86114 (Reopen #79692 (Format symbols under shared frames))
- #86297 (Allow to pass arguments to rustdoc-gui tool)
- #86334 (Resolve type aliases to the type they point to in intra-doc links)
- #86367 (Fix comment about rustc_inherit_overflow_checks in abs().)
- #86381 (Add regression test for issue #39161)
- #86387 (Remove `#[allow(unused_lifetimes)]` which is now unnecessary)
- #86398 (Add regression test for issue #54685)
- #86493 (Say "this enum variant takes"/"this struct takes" instead of "this function takes")
Yuki Okushi [Mon, 21 Jun 2021 22:37:56 +0000 (07:37 +0900)]
Rollup merge of #86493 - Smittyvb:ctor-typeck-error, r=davidtwco
Say "this enum variant takes"/"this struct takes" instead of "this function takes"
This makes error messages for functions with incorrect argument counts adapt if they refer to a struct or enum variant:
```
error[E0061]: this enum variant takes 1 argument but 0 arguments were supplied
--> $DIR/struct-enum-wrong-args.rs:7:13
|
LL | let _ = Ok();
| ^^-- supplied 0 arguments
| |
| expected 1 argument
error[E0061]: this struct takes 1 argument but 0 arguments were supplied
--> $DIR/struct-enum-wrong-args.rs:8:13
|
LL | let _ = Wrapper();
| ^^^^^^^-- supplied 0 arguments
| |
| expected 1 argument
```
Yuki Okushi [Mon, 21 Jun 2021 22:37:54 +0000 (07:37 +0900)]
Rollup merge of #86398 - yerke:add-test-for-issue-54685, r=Mark-Simulacrum
Add regression test for issue #54685
Closes #54685
Took the test from #54685 and modified it a bit to use assertion. Made sure that the updated test catches the original issue on 1.50 by running on Compiler Explorer (https://godbolt.org/z/E64onYeT5).
I came across an inconvenience when answering the following [Stack Overflow](https://stackoverflow.com/questions/67831170) question.
To get the remaining slice you have to call `buff.fill_buf().unwrap()`. Which in my opinion doesn't really tell you what is returned (in the context of Cursor). To improve readability and convenience when using Cursor i propose adding the method `remaining`.
The next thing i found inconvenient (unnecessary long) was detecting if the cursor reached the end. There are a few ways this can be achieved right now:
- `buff.fill_buf().unwrap().is_empty()`
- `buff.position() >= buff.get_ref().len()`
- `buff.bytes().next().is_none()`
Which all seem a bit unintuitive, hidden in trait documentations or just a bit long for such a simple task.
Therefor i propose another method called `is_empty`, maybe with another name, since this one may leave room for interpretation on what really is empty (the underlying slice, the remaining slice or maybe the position).
Since it seemed easier to create this PR instead of an RFC i did that, if an RFC is wanted, i can close this PR and write an RFC first.
Yuki Okushi [Mon, 21 Jun 2021 22:37:46 +0000 (07:37 +0900)]
Rollup merge of #85182 - CDirkx:available_concurrency, r=JohnTitor
Move `available_concurrency` implementation to `sys`
This splits out the platform-specific implementation of `available_concurrency` to the corresponding platforms under `sys`. No changes are made to the implementation.
Tidy didn't lint against this code being originally added outside of `sys` because of a bug (see #84677), this PR also reverts the exclusion that was introduced in that bugfix.
bors [Mon, 21 Jun 2021 22:24:13 +0000 (22:24 +0000)]
Auto merge of #86383 - shamatar:slice_len_lowering, r=bjorn3
Add MIR pass to lower call to `core::slice::len` into `Len` operand
During some larger experiment with range analysis I've found that code like `let l = slice.len()` produces different MIR then one found in bound checks. This optimization pass replaces terminators that are calls to `core::slice::len` with just a MIR operand and Goto terminator.
It uses some heuristics to remove the outer borrow that is made to call `core::slice::len`, but I assume it can be eliminated, just didn't find how.
Would like to express my gratitude to `@oli-obk` who helped me a lot on Zullip
Yuki Okushi [Mon, 21 Jun 2021 15:00:45 +0000 (00:00 +0900)]
Rollup merge of #86503 - ehuss:rustc.css-fonts, r=jyn514,GuillaumeGomez
Fix rust.css fonts.
The `rust.css` file (used for all non-rustdoc and non-mdbook pages) has gotten out of sync with rustdoc's css. The two share the same fonts, so this updates them to match what rustdoc uses.
It would be ideal not to need this at all, but that's for another time.
Yuki Okushi [Mon, 21 Jun 2021 15:00:42 +0000 (00:00 +0900)]
Rollup merge of #86472 - Mark-Simulacrum:fix-ci-beta, r=pietroalbini
Fix CI to fetch master on beta channel
This forward-ports a fix from the beta channel (landing in #86413, hopefully) to master so that we don't need to apply it on each round of backports.
This bug also demonstrates that our channel-checking is a bit insufficient -- stable is checked, but beta has some of its own peculiarities currently and isn't checked. But this does not attempt to adjust for that; we likely can't afford to run both beta and stable channels by CI and the current state here seems OK for now.
Yuki Okushi [Mon, 21 Jun 2021 15:00:41 +0000 (00:00 +0900)]
Rollup merge of #86424 - calebcartwright:rustfmt-mod-resolution, r=Mark-Simulacrum
rustfmt: load nested out-of-line mods correctly
This should address https://github.com/rust-lang/rustfmt/issues/4874
r? `@Mark-Simulacrum`
Decided to make the change directly in tree here for expediency/to minimize any potential backporting issues, and because there's some subtree sync items I need to get resolved before pulling from r-l/rustfmt
Yuki Okushi [Mon, 21 Jun 2021 15:00:40 +0000 (00:00 +0900)]
Rollup merge of #86349 - yerke:add-test-for-issue-78632, r=Mark-Simulacrum
Add regression test for issue #78632
Add regression test for issue #78632
Closes #78632
Took this test from #78632 (what was committed to glacier in https://github.com/rust-lang/rust/issues/78632#issuecomment-731843345).
Tested that the we get ICE on 1.52.1 on the playground (https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=b86d51fee4cded9d24b50d8ecbc48c6a).
bors [Mon, 21 Jun 2021 12:21:19 +0000 (12:21 +0000)]
Auto merge of #86210 - ehuss:rustfix-update, r=Mark-Simulacrum
Rustfix update
This updates to rustfix 0.6.0. One of the key changes here is https://github.com/rust-lang/rustfix/pull/195 which changes rustfix to apply multi-part suggestions. One of the tests needs to updated because there are some overlapping suggestions which rustfix cannot handle. The solution is to only apply the machine-applicable suggestions to avoid the overlapping issue.
This also includes a minor change to compiletest to provide better error messages with rustfix.
bors [Mon, 21 Jun 2021 09:40:34 +0000 (09:40 +0000)]
Auto merge of #86157 - jsha:tera, r=jyn514,GuillaumeGomez
Use Tera templates for rustdoc.
Replaces a format!() call in layout::render with a template
expansion. Introduces a `templates` field in SharedContext so parts
of rustdoc can share pre-rendered templates.
This currently builds in a copy of the single template available, like
with static files. However, future work can make this live-loadable with
a perma-unstable flag, to make rustdoc developers' work easier.
Part of #84419.
Demo at https://hoffman-andrews.com/rust/tera/std/string/struct.String.html.
bors [Mon, 21 Jun 2021 06:56:51 +0000 (06:56 +0000)]
Auto merge of #85775 - adamrk:warn-unused-target-fields, r=nagisa
Emit warnings for unused fields in custom targets.
Add a warning which lists any fields in a custom target `json` file that aren't used. Currently unrecognized fields are ignored so, for example, a typo in the `json` will silently produce a target which isn't the one intended.
Replaces a format!() call in layout::render with a template
expansion. Introduces a `templates` field in SharedContext so parts
of rustdoc can share pre-rendered templates.
This currently builds in a copy of the single template available, like
with static files. However, future work can make this live-loadable with
a perma-unstable flag, to make rustdoc developers' work easier.
bors [Mon, 21 Jun 2021 01:16:15 +0000 (01:16 +0000)]
Auto merge of #86502 - JohnTitor:rollup-wge0f3x, r=JohnTitor
Rollup of 8 pull requests
Successful merges:
- #83739 (Account for bad placeholder errors on consts/statics with trait objects)
- #85637 (document PartialEq, PartialOrd, Ord requirements more explicitly)
- #86152 (Lazify is_really_default condition in the RustdocGUI bootstrap step)
- #86156 (Fix a bug in the linkchecker)
- #86427 (Updated release note)
- #86452 (fix panic-safety in specialized Zip::next_back)
- #86484 (Do not set depth to 0 in fully_expand_fragment)
- #86491 (expand: Move some more derive logic to rustc_builtin_macros)
Yuki Okushi [Mon, 21 Jun 2021 00:42:17 +0000 (09:42 +0900)]
Rollup merge of #86452 - the8472:fix-zip-drop-safety, r=m-ou-se
fix panic-safety in specialized Zip::next_back
This was unsound since a panic in a.next_back() would result in the
length not being updated which would then lead to the same element
being revisited in the side-effect preserving code.
Yuki Okushi [Mon, 21 Jun 2021 00:42:15 +0000 (09:42 +0900)]
Rollup merge of #86156 - ehuss:linkchecker-fixes, r=Mark-Simulacrum
Fix a bug in the linkchecker
There was a small typo in the linkchecker (in #85652) that caused it to report a `#` fragment link error pointing to the wrong file (it was displaying the path to the source file, not the target of the link).
This also includes a few other changes:
- Fixes the tests due to some changes in the redirect handling in #84703.
- Adds the tests to rustbuild to run whenever the linkchecker itself is run.
- Updates the tests to validate more of the output (so that a mistake like this would have been caught).
Yuki Okushi [Mon, 21 Jun 2021 00:42:15 +0000 (09:42 +0900)]
Rollup merge of #86152 - the8472:lazify-npm-queries, r=Mark-Simulacrum
Lazify is_really_default condition in the RustdocGUI bootstrap step
The `RustdocGUI::should_run` condition spawns `npm list` several times which adds up to seconds of wall-time.
Evaluate the condition lazily to to keep `./x.py test tidy` and similar short-running tasks fast.
Yuki Okushi [Mon, 21 Jun 2021 00:42:13 +0000 (09:42 +0900)]
Rollup merge of #85637 - RalfJung:partial-ord, r=m-ou-se
document PartialEq, PartialOrd, Ord requirements more explicitly
This is the result of discussion in https://github.com/rust-lang/rust/issues/50230, in particular [this summary comment](https://github.com/rust-lang/rust/issues/50230#issuecomment-392819364).