Instead of just switching to a probe, check for different matches, and see how many there are.
If one, unify it, otherwise return true and let it be unified later.
Rework `Bounds` collection
I think it's weird for the `Bounds` struct in astconv to store its predicates *almost* converted into real predicates... so we do this eagerly, instead of lazily.
remove unreachable error code `E0313`
Fixes#103742
Makes #103433 redundant
Implements removal of `E0313`. I agree with the linked issue that this error code is unreachable but if someone could confirm that would be great, are crater runs done for this sort of thing?
Also removed a redundant `// ignore-tidy-filelength` that I found while reading code.
cc ``@GuillaumeGomez`` #61137
Add some UI tests and reword error-code docs
Added UI tests for `E0013` and `E0015`. Error code docs for `E0015` were a bit unclear (they referred to all non-const errors in const context, when only non-const functions applied), so I touched them up a bit.
I also fixed up some issues in the new `error_codes.rs` tidy check (linked #106341), that I overlooked previously.
r? ``@GuillaumeGomez``
Suggest `mut self: &mut Self` for `?Sized` impls
Closes#106325Closes#93078
The suggestion is _probably_ not what the user wants (hence `MaybeIncorrect`) but at least makes the problem in the above issues clearer. It might be better to add a note explaining why this is the case, but I'm not sure how best to word that so this is a start.
``@rustbot`` label +A-diagnostics
Point out span where we could introduce higher-ranked lifetime
Somewhat addresses #105422, but not really. We don't have that much useful information here since we're still in resolution :^(
Maybe this suggestion isn't worth it. If the reviewer has an idea how we can get a more succinct binder information for a structured suggestion, it would be appreciated.
Migrate `codegen_ssa` to diagnostics structs - [Part 3]
Completes migrating `codegen_ssa` module except 2 outstanding errors that depend on other crates:
1. [`rustc_middle::mir::interpret::InterpError`](b6097f2e1b/compiler/rustc_middle/src/mir/interpret/error.rs (L475)): I saw `rustc_middle` is unassigned, I am open to take this work.
2. `codegen_llvm`'s use of `fn span_invalid_monomorphization_error`, which I started to replace in the [last commit](9a31b3cdda) of this PR, but would like to know the team's preference on how we should keep replacing the other macros:
2.1. Update macros to expect a `Diagnostic`
2.2. Remove macros and expand the code on each use.
See [some examples of the different options in this experimental commit](64aee83e80)
_Part 2 - https://github.com/rust-lang/rust/pull/103792_
r? ``@davidtwco``
Cc ``@compiler-errors``
Migrating rustc_infer to session diagnostics (part 3)
``@rustbot`` label +A-translation
r? rust-lang/diagnostics
cc https://github.com/rust-lang/rust/issues/100717
Seems like a part of static_impl_trait.rs emits suggestions in a loop, and note.rs needs to have two instances of the same subdiagnostic, so these will need to wait until we have eager translation/list support.
Other than that, there is only error_reporting/mod.rs left to migrate.
Projection types in user annotations may contain inference variables.
This makes the normalization depend on the unification with the actual
type and thus requires a separate TypeOp to track the obligations.
Otherwise simply calling `TypeChecker::normalize` would ICE with
"unexpected ambiguity"
We delay projection normalization to further stages in order to
register user type annotations before normalization in HIR typeck.
There are two consumers of astconv: ItemCtxt and FnCtxt.
The former already expects unnormalized types from astconv, see its
AstConv trait impl.
The latter needs `RawTy` for a cleaner interface.
Unfortunately astconv still needs the normalization machinery in
order to resolve enum variants that have projections in the self type,
e.g. `<<T as Trait>::Assoc>::StructVariant {}`.
This is why `AstConv::normalize_ty_2` is necessary.
Add help diag. for `const = Enum` missing braces around `Enum`
Previously it was not clear why this errored or if it was even supported, as there was no diagnostic that suggested wrapping it in braces.
Thus, add a simple diagnostic that suggests wrapping enum variants in braces.
Fixes#105927
Add default and latest stable edition to --edition in rustc (attempt 2)
Fixes#106041
No longer leaks string like my first attempt PR, #106094 - uses LazyLock to construct a `&'static str`
It will now output the default edition and latest stable edition in the help message for the `--edition` flag.
Going to request the same reviewer as the first attempt for continuity - r? `@Nilstrieb`
refactor: clean up `errors.rs` and `error_codes_check.rs`
`errors.rs` is basically unused now, `error_codes_check.rs` is useful but not well commented, etc. It also doesn't check certain things which are certainly not correct. For example, `E0505` has a UI test in `src/test/ui/error-codes/` but that test actually outputs `E0504`?! Other issues like these exist. I've implemented these with "warnings" which are a bit rough around the edges but should be removed eventually.
r? `@GuillaumeGomez` (again not sure if you want to review but its relevant to you)
Suggest adding named lifetime when the return contains value borrowed from more than one lifetimes of function inputs
fix for #105227.
The problem: The suggestion of adding an explicit `'_` lifetime bound is **incorrect** when the function's return type contains a value which could be borrowed from more than one lifetimes of the function's inputs. Instead, a named lifetime parameter can be introduced in such a case.
The solution: Checking the number of elided lifetimes in the function signature. If more than one lifetimes found in the function inputs when the suggestion of adding explicit `'_` lifetime, change it to using named lifetime parameter `'a` instead.
Rollup of 5 pull requests
Successful merges:
- #106400 (Point at expressions where inference refines an unexpected type)
- #106491 (Fix error-index redirect to work with the back button.)
- #106494 (Add regression test for #58355)
- #106499 (fix [type error] for error E0029 and E0277)
- #106502 (rustdoc: remove legacy user-select CSS)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
fix [type error] for error E0029 and E0277
check explicitly for the type references error
if ty.references_error() is true change the error to be err.delay_as_bug() and prevent the error E0029 and E0277 from emitting out this fix#105946
Point at expressions where inference refines an unexpected type
Fix#106355. Fix#14007. (!)
```
error[E0308]: mismatched types
--> src/test/ui/type/type-check/point-at-inference.rs:12:9
|
9 | foo.push(i);
| - this is of type `&{integer}`, which makes `foo` to be inferred as `Vec<&{integer}>`
...
12 | bar(foo);
| --- ^^^ expected `i32`, found `&{integer}`
| |
| arguments to this function are incorrect
|
= note: expected struct `Vec<i32>`
found struct `Vec<&{integer}>`
note: function defined here
--> src/test/ui/type/type-check/point-at-inference.rs:2:4
|
2 | fn bar(_: Vec<i32>) {}
| ^^^ -----------
help: consider dereferencing the borrow
|
9 | foo.push(*i);
| +
```
Add vendor to Fuchsia's target triple
Historically, Rust's Fuchsia targets have been labeled x86_64-fuchsia and aarch64-fuchsia. However, they should technically contain vendor information. This CL changes Fuchsia's target triples to include the "unknown" vendor since Clang now does normalization and handles all triple spellings.
This was previously attempted in #90510, which was closed due to inactivity.
check explicitly for the type references error
if ty.references_error() is true change the error to be err.delay_as_bug()
and prevent the error E0029 and E0277 from emitting out
this fix#105946
Fix `uninlined_format_args` in compiler crates with the diagnostic migration completed
Convert all the crates that have had their diagnostic migration completed (except save_analysis because that will be deleted soon and apfloat because of the licensing problem).
Some of them have been reviewed by myself and they were all correct (though I still recommend going over all of them again for review).
A recent PR increased the size, which caused regressions. This uses the
existing generic infrastructure to differentiate between the hot path
and the diagnostics path.
Convert all the crates that have had their diagnostic migration
completed (except save_analysis because that will be deleted soon and
apfloat because of the licensing problem).
```rust
fn main() {
let v = Vec::new();
v.push(0);
v.push(0);
v.push("");
}
```
now produces
```
error[E0308]: mismatched types
--> $DIR/point-at-inference-3.rs:6:12
|
LL | v.push(0);
| - this is of type `{integer}`, which makes `v` to be inferred as `Vec<{integer}>`
...
LL | v.push("");
| ---- ^^ expected integer, found `&str`
| |
| arguments to this function are incorrect
|
note: associated function defined here
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
```
- Only point at a the single expression where the found type was first
inferred.
- Find method call argument that might have caused the found type to be
inferred.
- Provide structured suggestion.
- Apply some review comments.
- Tweak wording.
Historically, Rust's Fuchsia targets have been labeled x86_64-fuchsia
and aarch64-fuchsia. However, they should technically contain vendor
information. This CL changes Fuchsia's target triples to include the
"unknown" vendor since Clang now does normalization and handles all
triple spellings.
This was previously attempted in #90510, which was closed due to
inactivity.
Rollup of 6 pull requests
Successful merges:
- #105846 (Account for return-position `impl Trait` in trait in `opt_suggest_box_span`)
- #106385 (Split `-Zchalk` flag into `-Ztrait-solver=(classic|chalk|next)` flag)
- #106403 (Rename `hir::Map::{get_,find_}parent_node` to `hir::Map::{,opt_}parent_id`, and add `hir::Map::{get,find}_parent`)
- #106462 (rustdoc: remove unnecessary wrapper around sidebar and mobile logos)
- #106464 (Update Fuchsia walkthrough with new configs)
- #106478 (Tweak wording of fn call with wrong number of args)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup