bors [Wed, 11 Jan 2023 23:05:58 +0000 (23:05 +0000)]
Auto merge of #106743 - matthiaskrgr:rollup-q5dpxms, r=matthiaskrgr
Rollup of 6 pull requests
Successful merges:
- #106620 (Detect struct literal needing parentheses)
- #106622 (Detect out of bounds range pattern value)
- #106703 (Note predicate span on `ImplDerivedObligation`)
- #106705 (Report fulfillment errors in new trait solver)
- #106726 (Fix some typos in code comments.)
- #106734 (Deny having src/test exisiting in tidy)
nils [Wed, 11 Jan 2023 16:30:53 +0000 (17:30 +0100)]
Rollup merge of #106397 - compiler-errors:new-solver-impl-wc, r=lcnr
Check `impl`'s `where` clauses in `consider_impl_candidate` in experimental solver
Check impl's nested predicates as part of the recursive evaluate in `consider_impl_candidate`.
<sub>Unless, for some reason, these are intentionally **not** checked here -- in which case, I really don't understand where they're being checked...<sub>
nils [Wed, 11 Jan 2023 16:30:53 +0000 (17:30 +0100)]
Rollup merge of #106321 - compiler-errors:delayed-bug-backtrace, r=Nilstrieb
Collect and emit proper backtraces for `delay_span_bug`s
This is a follow-up to #106317, which addresses this comment (https://github.com/rust-lang/rust/issues/106267#issuecomment-1367507507) which notes that `delay_span_bug`s' backtraces are nonsense.
Captures and emits the backtrace of the delayed span bug when it's *created*, rather than using the backtrace of the place where delayed bugs are flushed.
---
To test, I delayed a span bug during HIR typeck, specifically in `typeck_with_fallback`...
Before, note `flush_delayed` on frame 18. This is at the end of the compilation session, far from where the bug is being delayed.
bors [Wed, 11 Jan 2023 11:17:22 +0000 (11:17 +0000)]
Auto merge of #106458 - albertlarsan68:move-tests, r=jyn514
Move src/test to the root
See MCP at rust-lang/compiler-team#573
There may be more changes needed.
The first commit is just the move of the files:
You can check that the first commit did not do anything else than renames by running
```
git diff --diff-filter=r -M100% <rust-lang remote>/master <first commit hash>
```
The output should be empty, because the filter excludes renames, and the match threshold for qualifying a rename is 100%.
The second one is mostly a "find and replace" of `src/test` to `tests` and whatever is needed to make CI pass.
What is left to do:
---
- [x] Move directory
- [ ] Change references to `src/test`
- [x] Change references in-tree
- [ ] Change references in submodules / out-of-tree docs
- [x] Make CI pass:
- [x] Fix tidy
- [x] Fix tests
- [x] Bless tests if needed (shouldn't normally)
- [ ] Merge it !
bors [Wed, 11 Jan 2023 08:50:38 +0000 (08:50 +0000)]
Auto merge of #105919 - uweigand:s390x-stack-overflow, r=Nilstrieb
Fix stack overflow in recursive AST walk in early lint
The src/test/ui/issues/issue-74564-if-expr-stack-overflow.rs test case added to verify https://github.com/rust-lang/rust/issues/74564 still crashes with a stack overflow on s390x-ibm-linux.
Symptom is a very deep recursion in compiler/rustc_lint/src/early.rs:
fn visit_expr(&mut self, e: &'a ast::Expr) {
self.with_lint_attrs(e.id, &e.attrs, |cx| {
lint_callback!(cx, check_expr, e);
ast_visit::walk_expr(cx, e);
})
}
(where walk_expr recursively calls back into visit_expr). The crash happens at a nesting depth of over 17000 stack frames when using the default 8 MB stack size on s390x.
This patch fixes the problem by adding a ensure_sufficient_stack call to the with_lint_attrs routine (which also should take care of all the other mutually recursive visitors here).
Fixes part of https://github.com/rust-lang/rust/issues/105383.
Yuki Okushi [Wed, 11 Jan 2023 05:18:58 +0000 (14:18 +0900)]
Rollup merge of #106689 - GuillaumeGomez:rustdoc-gui-files-array, r=notriddle
Fix invalid files array re-creation in rustdoc-gui tester
It fixes the error <code>expected `runTest` first argument to be a string</code>:
```
{
file_name: {
file_name: '/home/imperio/rust/rust/src/test/rustdoc-gui/type-declation-overflow.goml',
output: 'type-declation-overflow... FAILED\n' +
'...'
},
output: Error: expected `runTest` first argument to be a string
at runTest (/home/imperio/rust/rust/node_modules/browser-ui-test/src/index.js:591:15)
at runTests (/home/imperio/rust/rust/src/tools/rustdoc-gui/tester.js:144:26)
at main (/home/imperio/rust/rust/src/tools/rustdoc-gui/tester.js:278:15)
} Error: expected `runTest` first argument to be a string
at runTest (/home/imperio/rust/rust/node_modules/browser-ui-test/src/index.js:591:15)
at runTests (/home/imperio/rust/rust/src/tools/rustdoc-gui/tester.js:144:26)
at main (/home/imperio/rust/rust/src/tools/rustdoc-gui/tester.js:278:15)
```
The problem was that I concatenated two arrays of object whereas `files` is supposed to be an array of string.
Yuki Okushi [Wed, 11 Jan 2023 05:18:56 +0000 (14:18 +0900)]
Rollup merge of #106662 - Ezrashaw:specialize-bool-tostring, r=cuviper
specialize impl of `ToString` on `bool`
Fixes #106611
Specialize `bool`s `ToString` impl by copying it from `Display`. This is a significant optimization as we avoid lots of dynamic dispatch. AFAIK, this doesn't require a API Change Proposal as this doesn't regress existing code and can be undone without regressing code.
Yuki Okushi [Wed, 11 Jan 2023 05:18:55 +0000 (14:18 +0900)]
Rollup merge of #106645 - c410-f3r:rfc-2397-1, r=oli-obk
[RFC 2397] Initial implementation
cc #51992
Because of previous experiences where ppl didn't have the time to review large PRs (or any at all), the implementation of this feature will be delivered in small chunks to hopefully make things faster.
In this initial PR, only the attribute is being declared and gated with ordinary tests.
Yuki Okushi [Wed, 11 Jan 2023 05:18:53 +0000 (14:18 +0900)]
Rollup merge of #106628 - GuillaumeGomez:rm-itemid-primitive, r=notriddle
Remove unneeded ItemId::Primitive variant
As I mentioned [here](https://github.com/rust-lang/rust/pull/106412#issuecomment-1371405115), I wondered if `ItemId::Primitive` was actually used for anything. Apparently, it seems so because removing it led to no changes as far as I and tests could see.
Yuki Okushi [Wed, 11 Jan 2023 05:18:53 +0000 (14:18 +0900)]
Rollup merge of #106521 - oskgo:remove-E0280, r=jackh726
remove E0280
After looking at #61137 I tried my hand at E0280. I'm unable to find a reasonable example that emits the error. There are a couple of old examples that compile with the current compiler ([#26217](https://github.com/rust-lang/rust/issues/26217), [#42114](https://github.com/rust-lang/rust/issues/42114), [#27113](https://github.com/rust-lang/rust/issues/27113)) and there is a [bug with chalk](https://github.com/rust-lang/rust/blob/b7cdb635c4b973572307ad288466fba64533369c/src/test/ui/chalkify/bugs/async.rs) that makes it emit the error, with a couple more chalk bugs on zulip.
It seems like the error is supposed to be emitted from unfulfilled where bounds, of which two are related to borrow checking (error in where T: 'a or where 'a: 'b) and thus tend to emit errors like "lifetime may not live long enough" from borrow checking instead. The final case is with type equality constraints (where <T as Iterator>::Item == u32), which is unimplemented ([#20041](https://github.com/rust-lang/rust/issues/20041)). That such different problems are supposed to have the same error code also seems strange to me.
Since the error seems to only be emitted when using chalk I propose to remove it and replace it with an ICE instead. A crater run might be warranted.
Pinging `@jackh726` due to removal of chalk test that now ICEs.
bors [Tue, 10 Jan 2023 06:22:01 +0000 (06:22 +0000)]
Auto merge of #106607 - compiler-errors:be-more-accurate-abt-method-suggestions, r=oli-obk
Consider return type when giving various method suggestions
1. Fix a bug in method probe where we weren't normalizing `xform_ret_ty` for non-`impl` method candidates. This shouldn't affect happy-path code, since we only use `xform_ret_ty` when probing methods for diagnostics (I think).
2. Pass the return type expectation down to `lookup_probe`/`probe_for_name` usages in diagnostics. Added a few UI tests to gate against bad suggestions.
3. Make a `FnCtxt::lookup_probe_for_diagnostic` which properly passes down `IsSuggestion(true)`. Should help suppress other weird notes in some corner cases.
bors [Tue, 10 Jan 2023 03:26:29 +0000 (03:26 +0000)]
Auto merge of #106656 - JohnTitor:rollup-rk2qltg, r=JohnTitor
Rollup of 9 pull requests
Successful merges:
- #105034 (Add example for iterator_flatten)
- #105708 (Enable atomic cas for bpf targets)
- #106175 (Fix bad import suggestion with nested `use` tree)
- #106204 (No need to take opaques in `check_type_bounds`)
- #106387 (Revert "bootstrap: Get rid of `tail_args` in `stream_cargo`")
- #106636 (Accept old spelling of Fuchsia target triples)
- #106639 (update Miri)
- #106640 (update test for inductive canonical cycles)
- #106647 (rustdoc: merge common CSS for `a`)
Yuki Okushi [Mon, 9 Jan 2023 23:05:35 +0000 (08:05 +0900)]
Rollup merge of #106636 - djkoloski:accept_old_fuchsia_triple, r=tmandry
Accept old spelling of Fuchsia target triples
The old spelling of Fuchsia target triples was changed in #106429 to add a proper vendor. Because the old spelling is widely used, some projects may need time to migrate their uses to the new triple spelling. The old spelling may eventually be removed altogether.
Yuki Okushi [Mon, 9 Jan 2023 23:05:34 +0000 (08:05 +0900)]
Rollup merge of #106175 - compiler-errors:bad-import-sugg, r=oli-obk
Fix bad import suggestion with nested `use` tree
Fixes #105566
Fixes #105373
Ideally, we'd find some way to turn these into structured suggestions -- perhaps on a separate line as a different `use` statement, but I have no idea how to access the span for the whole `use` from this point in the import resolution code.
bors [Mon, 9 Jan 2023 18:20:00 +0000 (18:20 +0000)]
Auto merge of #106637 - fee1-dead-contrib:rollup-ticvmsd, r=fee1-dead
Rollup of 10 pull requests
Successful merges:
- #105292 (Change a commit_if_ok call to probe)
- #105655 (Remove invalid case for mutable borrow suggestion)
- #106047 (Fix ui constant tests for big-endian platforms)
- #106061 (Enable Shadow Call Stack for Fuchsia on AArch64)
- #106164 (Move `check_region_obligations_and_report_errors` to `TypeErrCtxt`)
- #106291 (Fix incorrect suggestion for extra `&` in pattern)
- #106389 (Simplify some canonical type alias names)
- #106468 (Use FxIndexSet when updating obligation causes in `adjust_fulfillment_errors_for_expr_obligation`)
- #106549 (Use fmt named parameters in rustc_borrowck)
- #106614 (error-code docs improvements (No. 2))
David Koloski [Mon, 9 Jan 2023 15:22:08 +0000 (10:22 -0500)]
Accept old spelling of Fuchsia target triples
Because the old spelling is widely used, some projects may need time to
migrate their uses to the new triple spelling. The old spelling may
eventually be removed altogether.
Use ANSI control characters to display text decorations matching the VScode terminal theme, and strip them out when providing text content for rustc diagnostics.
This adds the small [`anser`](https://www.npmjs.com/package/anser) library (MIT license, no dependencies) to parse the control codes, and it also supports HTML output so it should be fairly easy to switch to a rendered HTML/webview implementation in the future
I also updated the default `cargo check` command to use the rendered ANSI diagnostics, although I'm not sure if it makes sense to put this kind of thing behind a feature flag, or whether it might have any issues on Windows (as I believe ANSI codes are not used for colorization there)?