bors [Tue, 3 Jan 2023 20:44:40 +0000 (20:44 +0000)]
Auto merge of #105752 - chenyukang:yukang/refactor-method-error, r=compiler-errors
Refactoring report_method_error
While working on #105732, I found it's hard to follow this long function,
so I tried to make it shorter.
It's not easy for code reviewing, since so many lines of code changes,
but only the positions are changed.
Generally, I extract two sub-methods from `report_method_error`:
https://github.com/rust-lang/rust/blob/397b66e77b279de5006facf87979f9ecff5c7f87/compiler/rustc_hir_typeck/src/method/suggest.rs#L117
to `note_candidates_on_method_error`
bors [Tue, 3 Jan 2023 17:08:17 +0000 (17:08 +0000)]
Auto merge of #106409 - matthiaskrgr:rollup-b58z1hz, r=matthiaskrgr
Rollup of 8 pull requests
Successful merges:
- #104552 (warn newer available version of the x tool)
- #105681 (some fixes/improvements to mir::visit module)
- #106005 (Test the borrowck behavior of if-let guards)
- #106356 (clean: Remove `ctor_kind` from `VariantStruct`.)
- #106365 (Grammar : Missing "is" in format specifier diagnostic)
- #106388 (rustdoc: remove legacy box-sizing CSS)
- #106392 (`has_overflow` only if value is *not* within limit)
- #106402 (Fix dupe word typos)
Matthias Krüger [Tue, 3 Jan 2023 16:12:12 +0000 (17:12 +0100)]
Rollup merge of #106388 - notriddle:notriddle/box-sizing, r=camelid
rustdoc: remove legacy box-sizing CSS
According to [caniuse], these vendor prefixes aren't needed in any supported web browsers as defined in [RFC 1985]
* The last version of Chrome that required a vendor prefix was version 9. The current version is 108.
* Firefox 28 is the last version that required a vendor prefix. The [current Firefox ESR] is version 102.
* The last version of Safari that required a vendor prefix was version 5. The current version is 16.
* The last version of Safari/iOS that required a vendor prefix was version 4. The current version is 16.
* Edge never required vendor prefixes.
* UCAndroid never required vendor prefixes.
Matthias Krüger [Tue, 3 Jan 2023 16:12:11 +0000 (17:12 +0100)]
Rollup merge of #106005 - LeSeulArtichaut:if-let-guard-borrowck-test, r=Nilstrieb
Test the borrowck behavior of if-let guards
Add some tests to make sure that if-let guards behave the same as if guards with respect to borrow-checking. Most of them are a naive adaptation, replacing an `if` guard with `if let Some(())`.
This includes regression tests for notable issues that arose for if guards (#24535, #27282, #29723, #31287) as suggested in https://github.com/rust-lang/rust/issues/51114#issuecomment-900470419.
cc `@pnkfelix` are there any other tests that you would want to see?
cc tracking issue #51114
Matthias Krüger [Tue, 3 Jan 2023 16:12:10 +0000 (17:12 +0100)]
Rollup merge of #104552 - DebugSteven:warn-newer-x, r=jyn514
warn newer available version of the x tool
This PR adds a check to `tidy` to assert that the installed version of `x` is equal to the version in `src/tools/x/Cargo.toml`. It adds a `--wrapper-version` argument to `x` to determine the version at runtime, .
It does not warn if `x` has not yet been installed, on the assumption that the user isn't interested in using it.
bors [Tue, 3 Jan 2023 14:05:44 +0000 (14:05 +0000)]
Auto merge of #101792 - lqd:rust-lld, r=petrochenkov
Only specify `--target` by default for `-Zgcc-ld=lld` on wasm
On macOS, it's not yet clear which cases of clang/OS/target/SDK version impact how to find ld/lld/rust-lld. The `--target` argument is not needed on our current targets with a vanilla config to do so, but may be in some cases ?
That is, things look to be different and more subtle than suggested in https://github.com/rust-lang/rust/issues/97402#issuecomment-1147404520.
Specifying this argument unconditionally currently breaks `-Zgcc-ld=lld` on the 10.7+ targets on x64 macOS. Vanilla configs on x64 and aarch64 don't seem to need it to be able to find `rust-lld`.
This fixes #101653 on macOS (I've tried on x64 and aarch64: vanilla installs with the most recent command line tools available for each of the OS versions I have access to, `run-make/issue-71519` passes).
I didn't expect the previous PRs to fail because of the existing tests, but CI does not actually run those tests yet, which explains the regressions. I was hoping to fix those in this PR but it's more involved (building lld is required for the tests to run, llvm/lld is not built on the test builders but on the dist builders, the dist builders don't run tests). This PR is just to unblock current users on macOS who have reported issues, but a regression could happen in the future by mistake until then.
bors [Tue, 3 Jan 2023 11:06:08 +0000 (11:06 +0000)]
Auto merge of #95644 - WaffleLapkin:str_split_as_str_refactor_take2, r=Amanieu
`Split*::as_str` refactor
I've made this patch almost a year ago, so the rename and the behavior change are in one commit, sorry 😅
This fixes #84974, as it's required to make other changes work.
This PR
- Renames `as_str` method of string `Split*` iterators to `remainder` (it seems like the `as_str` name was confusing to users)
- Makes `remainder` return `Option<&str>`, to distinguish between "the iterator is exhausted" and "the tail is empty", this was [required on the tracking issue](https://github.com/rust-lang/rust/issues/77998#issuecomment-832696619)
bors [Tue, 3 Jan 2023 04:54:03 +0000 (04:54 +0000)]
Auto merge of #106371 - RalfJung:no-ret-position-noalias, r=nikic
do not add noalias in return position
`noalias` as a return attribute in LLVM indicates that the returned pointer does not alias anything else that is reachable from the caller, *including things reachable before this function call*. This is clearly not the case with a function like `fn id(Box<T>) -> Box<T>`, so we cannot use this attribute.
Fixes https://github.com/rust-lang/unsafe-code-guidelines/issues/385 (including an actual miscompilation that `@comex` managed to produce).
bors [Tue, 3 Jan 2023 01:45:33 +0000 (01:45 +0000)]
Auto merge of #106386 - compiler-errors:rollup-dxjv18b, r=compiler-errors
Rollup of 8 pull requests
Successful merges:
- #95985 (Add PhantomData marker to Context to make Context !Send and !Sync)
- #104298 (Add notes and examples about non-intuitive `PathBuf::set_extension` behavior)
- #105558 (Reduce HIR debug output)
- #106315 (Cleanup `mingw-tidy` docker job)
- #106354 (Rustdoc-Json: Report discriminant on all kinds of enum variant.)
- #106366 (Fix rustdoc ICE on bad typedef with mismatching types)
- #106376 (Update books)
- #106383 (Document some of the AST nodes)
Failed merges:
- #106356 (clean: Remove `ctor_kind` from `VariantStruct`.)
- Add help for when you update a submodule by accident (rust-lang/rustc-dev-guide#1537)
- Simplify "how to build and run" section (rust-lang/rustc-dev-guide#1528)
- Replace `$TARGET` with `host` (rust-lang/rustc-dev-guide#1514)
- Add more rebasing help (rust-lang/rustc-dev-guide#1536)
- Fix rustc_borrowck crate name typo (rust-lang/rustc-dev-guide#1535)
Michael Goulet [Mon, 2 Jan 2023 23:39:17 +0000 (15:39 -0800)]
Rollup merge of #106315 - jyn514:cleanup-mingw-tidy, r=fee1-dead
Cleanup `mingw-tidy` docker job
Fixes a couple small regressions from https://github.com/rust-lang/rust/pull/106048 and https://github.com/rust-lang/rust/pull/105714.
- Avoid `/checkout/src/ci/run.sh: line 187: [: =: unary operator expected`: https://github.com/rust-lang/rust/actions/runs/3809902408/jobs/6481611301#step:26:1701
- Avoid running `x check` in the tidy test, to get faster feedback. It's already run on the normal `mingw-check` job.
Michael Goulet [Mon, 2 Jan 2023 23:39:17 +0000 (15:39 -0800)]
Rollup merge of #105558 - Nilstrieb:less-spam-hir-tree, r=cjgillot
Reduce HIR debug output
HIR debug output is currently very verbose, especially when used with the alternate (`#`) flag. This commit reduces the amount of noisy newlines by forcing a few small key types to stay on one line, which makes the output easier to read and scroll by.
Michael Goulet [Mon, 2 Jan 2023 23:39:16 +0000 (15:39 -0800)]
Rollup merge of #104298 - tbu-:pr_set_extension_caveats, r=m-ou-se
Add notes and examples about non-intuitive `PathBuf::set_extension` behavior
Basically, passing the empty string will actually remove the extension instead of setting it to the empty string. This might change what is considered to be an extension. Additionally, passing an extension that contains dots will make the path only consider the last part of it to be the new extension.
Michael Goulet [Mon, 2 Jan 2023 23:39:16 +0000 (15:39 -0800)]
Rollup merge of #95985 - jihiggins:issue-66481, r=dtolnay
Add PhantomData marker to Context to make Context !Send and !Sync
Adds `PhantomData<*mut ()>` to `Context` in order to allow for future `!Send` or `!Sync` additions to `Context`'s fields. This would allow for things like future single threaded async executor optimizations, or (re)adding `LocalWaker`, etc.
Closes #66481.
Per https://github.com/rust-lang/rust/issues/66481#issuecomment-561289725, this is a breaking change that needs a Crater run as the next step.
(So far have tested the change locally with `cargotest` on WSL)
only specify --target by default for -Zgcc-ld=lld on wasm
On macOS, it's not yet clear which cases of clang/OS/target/SDK version impact
how to find ld/lld/rust-lld. The --target is not needed on our current targets with
a vanilla config, but may be in some cases. Specifying it all the time breaks the 10.7+
targets on x64 macOS.
We try to only specify it on macOS if the linker flavors are different,
for possible cases of cross-compilation with `-Zgcc-ld=lld` but the
expectation is that it should be passed manually when needed in these
situations.
bors [Mon, 2 Jan 2023 22:52:58 +0000 (22:52 +0000)]
Auto merge of #106364 - JakobDegen:top-down-inlining, r=cjgillot
Reenable limited top-down MIR inlining
Reverts most of #105119 and uses an alternative strategy to prevent exponential blowup. Specifically, we allow doing top-down inlining up to depth at most five, and for at most one call site per nested body.
Michael Howell [Mon, 2 Jan 2023 20:12:45 +0000 (13:12 -0700)]
rustdoc: remove legacy box-sizing CSS
According to [caniuse], these vendor prefixes aren't needed in any
supported web browsers as defined in [RFC 1985]
* The last version of Chrome that required a vendor prefix was version 9.
The current version is 108.
* Firefox 28 is the last version that required a vendor prefix. The
[current Firefox ESR] is version 102.
* The last version of Safari that required a vendor prefix was version 5.
The current version is 16.
* The last version of Safari/iOS that required a vendor prefix was version 4.
The current version is 16.
* Edge never required vendor prefixes.
* UCAndroid never required vendor prefixes.
bors [Mon, 2 Jan 2023 20:12:16 +0000 (20:12 +0000)]
Auto merge of #106307 - Nilstrieb:dynamic->static, r=cjgillot
Abolish `QueryVTable` in favour of more assoc items on `QueryConfig`
This may introduce additional mono _but_ may help const fold things better and especially may help not constructing a `QueryVTable` anymore which is cheap but not free.
Nilstrieb [Fri, 30 Dec 2022 22:25:19 +0000 (23:25 +0100)]
Abolish `QueryVTable` in favour of more assoc items on `QueryConfig`
This may introduce additional mono _but_ may help const fold things
better and especially may help not constructing a `QueryVTable` anymore
which is cheap but not free.
Nilstrieb [Sun, 11 Dec 2022 11:10:55 +0000 (12:10 +0100)]
Reduce HIR debug output
HIR debug output is currently very verbose, especially when used with
the alternate (`#`) flag. This commit reduces the amount of noisy
newlines by forcing a few small key types to stay on one line, which
makes the output easier to read and scroll by.
David Tolnay [Mon, 2 Jan 2023 18:31:50 +0000 (10:31 -0800)]
Remove test of static Context
Context is no longer Sync so this doesn't work.
error[E0277]: `*mut ()` cannot be shared between threads safely
--> library/core/tests/task.rs:24:21
|
24 | static CONTEXT: Context<'static> = Context::from_waker(&WAKER);
| ^^^^^^^^^^^^^^^^ `*mut ()` cannot be shared between threads safely
|
= help: within `Context<'static>`, the trait `Sync` is not implemented for `*mut ()`
= note: required because it appears within the type `PhantomData<*mut ()>`
= note: required because it appears within the type `Context<'static>`
= note: shared static variables must have a type that implements `Sync`
bors [Mon, 2 Jan 2023 13:10:16 +0000 (13:10 +0000)]
Auto merge of #84762 - cjgillot:resolve-span-opt, r=petrochenkov
Encode spans relative to the enclosing item -- enable on nightly
Follow-up to #84373 with the flag `-Zincremental-relative-spans` set by default.
This PR seeks to remove one of the main shortcomings of incremental: the handling of spans.
Changing the contents of a function may require redoing part of the compilation process for another function in another file because of span information is changed.
Within one file: all the spans in HIR change, so typechecking had to be re-done.
Between files: spans of associated types/consts/functions change, so type-based resolution needs to be re-done (hygiene information is stored in the span).
The flag `-Zincremental-relative-spans` encodes local spans relative to the span of an item, stored inside the `source_span` query.
Trap: stashed diagnostics are referenced by the "raw" span, so stealing them requires to remove the span's parent.
In order to avoid too much traffic in the span interner, span encoding uses the `ctxt_or_tag` field to encode:
- the parent when the `SyntaxContext` is 0;
- the `SyntaxContext` when the parent is `None`.
Even with this, the PR creates a lot of traffic to the Span interner, when a Span has both a LocalDefId parent and a non-root SyntaxContext. They appear in lowering, when we add a parent to all spans, including those which come from macros, and during inlining when we mark inlined spans.
The last commit changes how queries of `LocalDefId` manage their cache. I can put this in a separate PR if required.
Possible future directions:
- validate that all spans are marked in HIR validation;
- mark macro-expanded spans relative to the def-site and not the use-site.
bors [Mon, 2 Jan 2023 10:21:53 +0000 (10:21 +0000)]
Auto merge of #106301 - notriddle:notriddle/dir-entry, r=GuillaumeGomez
rustdoc: use the regular arrow indicator for dir-entry CSS
This mostly reverts 468acca108e65101b802821bded17149dc1d86c9, while still fixing the problem it fixed by using an internal list-style-position. It results in a slight change in the hover indicator, but nothing misleading.
bors [Mon, 2 Jan 2023 01:15:25 +0000 (01:15 +0000)]
Auto merge of #106352 - kornelski:read_line-doc, r=scottmcm
Document read_line gotchas
1. The "You do not need to clear the buffer before appending" advice is ambiguous, because it depends what you use this function for. For a rather common case of reading individual lines in a loop, it _is_ necessary to clear the buffer.
2. The docs warn about a DoS risk. I've added a hint how to mitigate unbounded memory growth.
Joshua Nelson [Sat, 31 Dec 2022 01:02:10 +0000 (01:02 +0000)]
Cleanup `mingw-tidy` docker job
- Avoid `/checkout/src/ci/run.sh: line 187: [: =: unary operator expected`: https://github.com/rust-lang/rust/actions/runs/3809902408/jobs/6481611301#step:26:1701
- Avoid running `x check` in the tidy test, to get faster feedback. It's
already run on the normal `mingw-check` job.
bors [Sun, 1 Jan 2023 05:20:48 +0000 (05:20 +0000)]
Auto merge of #106312 - tgross35:update-book-target, r=JohnTitor
Added link from Targets to Platform Support in the book
If you search the web for "rust targets", the first result is the [targets page](https://doc.rust-lang.org/nightly/rustc/targets/index.html). However, usually when searching for this I'm interested in seeing the available triples with host information, so I just added a link to the correct page.
The entire `Targets` chapter could probably be combined into one page, since its three subchapters each only have a tiny section (I'll do this if requested)
bors [Sat, 31 Dec 2022 23:22:06 +0000 (23:22 +0000)]
Auto merge of #106336 - matthiaskrgr:rollup-4p6bgwf, r=matthiaskrgr
Rollup of 4 pull requests
Successful merges:
- #106280 (docs: add link to `Path::join` in `PathBuf::push`)
- #106297 (rustdoc: merge scrape-help CSS)
- #106328 (Add comment explaining what the GUI scrape-examples-fonts test is about)
- #106334 (Fix tidy unittest.)
bors [Sat, 31 Dec 2022 20:10:02 +0000 (20:10 +0000)]
Auto merge of #106282 - Ezrashaw:merge-e0465, r=estebank
refactor: merge error code `E0465` into `E0464`
`E0465` is an undocumented and untested error code that is functionally identical to `E0464`. This PR merges `E0465` into `E0464`, thus documenting and testing another error code (#61137).
r? `@GuillaumeGomez` (not sure if you want to review this but it's relevant to my other PRs that you have reviewed)