Closed
Description
In-scope trait aliases bring into scope (methods of) the aliased trait and all of its supertraits. I can understand the rationale for bringing (methods of) the aliased trait into scope (namely to fix #56485), but also bringing into scope (methods of) that trait's supertraits is both inconsistent (compared with bringing the aliased trait itself into scope) and surprising:
#![feature(trait_alias)]
use std::fmt;
trait Foo: fmt::Debug {}
// uncommenting the following line brings Debug into scope, which
// in turn causes the (unrelated) Display impl below to become ambiguous
// trait Bar = Foo;
#[derive(Debug)]
struct Qux(bool);
impl fmt::Display for Qux {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
}
}
(For the avoidance of doubt, only the methods are brought into scope—not the trait itself: thus, in the above example with the Bar
alias uncommented, one cannot use an unqualified Debug
).
cc #41517
@rustbot label A-resolve A-traits C-bug F-trait_alias