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.
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`)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
update test for inductive canonical cycles
the previous test always resulted in a cycle 😅 cc https://github.com/rust-lang/chalk/pull/787.
I checked with #102713 and this is the only test which fails with that PR.
r? ``@jackh726``
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.
r? ``@tmandry``
Revert "bootstrap: Get rid of `tail_args` in `stream_cargo`"
This reverts commit 9dfe50440e. (Note: that merged as part of https://github.com/rust-lang/rust/pull/106305, but https://github.com/rust-lang/rust/pull/106305/ contains more commits than just 9dfe50440e6d48bd2fd40a4b7b3992998e55eace.)
Fixes `x clippy`. It turns out `clippy` was the only one using `tail_args` 🤦 sorry for not testing this earlier.
r? `@Mark-Simulacrum`
Fix bad import suggestion with nested `use` tree
Fixes#105566Fixes#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.
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.
Colorize `cargo check` diagnostics in VSCode via text decorations
Fixes#13648
![colored-rustc-diagnostics](https://user-images.githubusercontent.com/11131775/209479884-10eef8ca-37b4-4aae-88f7-3591ac01b25e.gif)
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)?
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` library 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 if desired.
add dtors_in_dtors_in_dtors
That's a pretty neat test from the standard library. Sadly not enough to check for https://github.com/rust-lang/miri/issues/2754, but still worth having here.
Rename `checkOnSave` settings to `check`
Now that flychecks can be triggered without saving the setting name doesn't make that much sense anymore. This PR renames it to just `check`, but keeps `checkOnSave` as the enabling setting.
error-code docs improvements (No. 2)
- Added empty error-code docs for `E0208`, `E0640` and `E0717` with the "internal" header as discussed on Discord.
- Wrote docs and UI test for `E0711`, again with the header.
- `tidy` changes are common-sense and make everything pass, `style.rs` hack is annoying though.
r? ```@GuillaumeGomez```
Use FxIndexSet when updating obligation causes in `adjust_fulfillment_errors_for_expr_obligation`
I have no idea how to test this reliably, but I've **manually** verified it fixes the instability in #106417 that isn't due to dtolnay/trybuild#212.
Fixes#106417
Simplify some canonical type alias names
* delete the `Canonicalized<'tcx>` type alias in favor for `Canonical<'tcx>`
* `CanonicalizedQueryResponse` -> `CanonicalQueryResponse`
I don't particularly care about the latter, but it should be consistent. We could alternatively delete the first alias and rename the struct to `Canonicalized`, and then keep the name of `CanonicalizedQueryResponse` untouched.
Move `check_region_obligations_and_report_errors` to `TypeErrCtxt`
Makes sense for this function to live with its sibling `resolve_regions_and_report_errors`, around which it's basically just a wrapper.
Enable Shadow Call Stack for Fuchsia on AArch64
Fuchsia already uses SCS by default for C/C++ code on ARM hardware. This patch allows SCS to be used for Rust code as well.
Fix ui constant tests for big-endian platforms
A number of tests under ui/const-ptr and ui/consts are currently failing on big-endian platforms as the binary encoding of some constants is hard-coded in the stderr test files.
Fix this by a combination of two types of changes:
- Where possible (i.e. where the particular value of a constant does not affect the purpose of the test), choose constant values that have the same encoding on big- and little-endian platforms.
- Where this is not possible, provide a normalize-stderr-test rule that transforms the printed big-endian encoding of such constants into the corresponding little-endian form.
Fixes part of https://github.com/rust-lang/rust/issues/105383.
Remove invalid case for mutable borrow suggestion
If we have a call such as `foo(&mut buf)` and after reference
collapsing the type is inferred as `&T` where-as the required type is
`&mut T`, don't suggest `foo(&mut mut buf)`. This is wrong syntactically
and the issue lies elsewhere, not in the borrow.
Fixes#105645
Change a commit_if_ok call to probe
Removes an over-eager `commit_if_ok` which makes inference worse.
I'm not entirely sure whether it's ok to remove the check that types are the same, because casting seems to cause equality checks with incorrect types?
Fixes#105037
r? ```@BoxyUwU```