Associated types with a default type in a trait can't be relied upon to
remain of that default type when in use, so literals of that type can't
be used in the trait's items. Point at the associated type and state
that information.
Reduce verbosity for associated consts of the wrong type.
When an associated type is found when a specific type was expected, if
possible provide a structured suggestion constraining the associated
type in a bound.
```
error[E0271]: type mismatch resolving `<T as Foo>::Y == i32`
--> $DIR/associated-types-multiple-types-one-trait.rs:13:5
|
LL | want_y(t);
| ^^^^^^ expected `i32`, found associated type
...
LL | fn want_y<T:Foo<Y=i32>>(t: &T) { }
| ----- required by this bound in `want_y`
|
= note: expected type `i32`
found associated type `<T as Foo>::Y`
help: consider constraining the associated type `<T as Foo>::Y` to `i32`
|
LL | fn have_x_want_y<T:Foo<X=u32, Y = i32>>(t: &T)
| ^^^^^^^^^
```
```
error[E0308]: mismatched types
--> $DIR/trait-with-missing-associated-type-restriction.rs:12:9
|
LL | qux(x.func())
| ^^^^^^^^ expected `usize`, found associated type
|
= note: expected type `usize`
found associated type `<impl Trait as Trait>::A`
help: consider constraining the associated type `<impl Trait as Trait>::A` to `usize`
|
LL | fn foo(x: impl Trait<A = usize>) {
| ^^^^^^^^^^
```
The extracted function can be used by the rest of bootstrap to detect if we've
already built an up-to-date LLVM (and so it's safe for us to either request it
or pretend it exists).
Rollup of 6 pull requests
Successful merges:
- #71712 (Miri: port error backtraces to std::backtrace)
- #71736 (bootstrap: also apply unused-attributes hack without deny_warnings)
- #71738 (remove AllocId generalization of Pointer)
- #71739 (remove obsolete comment)
- #71781 (Uncomment test code for failure to use `Box::pin`)
- #71782 (Use a non-existent test path instead of clobbering /dev/null)
Failed merges:
r? @ghost
bootstrap: also apply unused-attributes hack without deny_warnings
This is a follow-up to https://github.com/rust-lang/rust/pull/70881 that also silences these warnings when deny_warnings is off. They otherwise spam my screen during development and make it hard to see actual warnings.
Cc @eddyb r? @Mark-Simulacrum
Miri: port error backtraces to std::backtrace
No need to pull in an external dependency if libstd already includes this feature (using the same dependency internally, but... still).
r? @oli-obk