Background: this is something that I stumbled across while researching #24.
The Paths section has distinct syntax for PathInExpression and QualifiedPathInExpression. What isn't clear is the semantic difference between, say, T::func and <T>::func where T is a type.
I think T in <T>::func is not subject to inference, and therefore all of its generic type arguments must be explicitly specified, or defaulted. I'm not quite able to conclusively show it to my satisfaction, though.
It is clear that <Trait>::func isn't valid, and possibly this should be documented (even though it's implied by the production names).
#[derive(Debug)]
struct S(u8);
trait Tr {
fn foo() -> Self;
}
impl Tr for S {
fn foo() -> Self { Self(1) }
}
fn main() {
// The following is an error, because Tr is a trait, not a type.
// let x: S = <Tr>::foo();
let x: S = Tr::foo();
println!("{:?}", x);
}
https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=c7f60a975096972761bcaaa58f692379
Background: this is something that I stumbled across while researching #24.
The Paths section has distinct syntax for PathInExpression and QualifiedPathInExpression. What isn't clear is the semantic difference between, say,
T::funcand<T>::funcwhereTis a type.I think
Tin<T>::funcis not subject to inference, and therefore all of its generic type arguments must be explicitly specified, or defaulted. I'm not quite able to conclusively show it to my satisfaction, though.It is clear that
<Trait>::funcisn't valid, and possibly this should be documented (even though it's implied by the production names).https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=c7f60a975096972761bcaaa58f692379