In #50882, adding an Alloc parameter to the Box type, that defaults to Global induces changes to UI tests that are indicative of something that seemed to need improvement in the compiler, namely that when you have a type Foo<A, B = Bar>, errors should present Foo<A> instead of Foo<A, Bar> when they can.
It turns out, the compiler does. But not consistently. The following is derived from src/test/compile-fail/terr-sorts.rs:
#![crate_type = "lib"]
trait Alloc {}
struct Global;
impl Alloc for Global {}
struct Foo<T, A: Alloc = Global>(T, A);
struct foo {
a: isize,
b: isize,
}
type bar = Foo<foo>;
type baz = Foo<usize>;
fn want_foo(f: foo) {}
fn have_bar(b: bar) {
want_foo(b);
}
fn want_usize(f: usize) {}
fn have_baz(b: baz) {
want_usize(b);
}
(Playground version)
This yields the following errors:
error[E0308]: mismatched types
--> src/lib.rs:18:14
|
18 | want_foo(b);
| ^ expected struct `foo`, found struct `Foo`
|
= note: expected type `foo`
found type `Foo<foo, Global>`
error[E0308]: mismatched types
--> src/lib.rs:22:16
|
22 | want_usize(b);
| ^ expected usize, found struct `Foo`
|
= note: expected type `usize`
found type `Foo<usize>`
See how it prints Foo<foo, Global> instead of the (imho) desired Foo<foo>, but Foo<usize>, not Foo<usize, Global>.
In #50882, adding an
Allocparameter to theBoxtype, that defaults toGlobalinduces changes to UI tests that are indicative of something that seemed to need improvement in the compiler, namely that when you have a typeFoo<A, B = Bar>, errors should presentFoo<A>instead ofFoo<A, Bar>when they can.It turns out, the compiler does. But not consistently. The following is derived from
src/test/compile-fail/terr-sorts.rs:(Playground version)
This yields the following errors:
See how it prints
Foo<foo, Global>instead of the (imho) desiredFoo<foo>, butFoo<usize>, notFoo<usize, Global>.