-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Omitting return type of trait method to use () doesn't work with associated_type_defaults when default is () #54182
Copy link
Copy link
Closed
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)C-bugCategory: This is a bug.Category: This is a bug.F-associated_type_defaults`#![feature(associated_type_defaults)]``#![feature(associated_type_defaults)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.This issue requires a nightly compiler in some way. When possible, use a F-* label instead.
Metadata
Metadata
Assignees
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)C-bugCategory: This is a bug.Category: This is a bug.F-associated_type_defaults`#![feature(associated_type_defaults)]``#![feature(associated_type_defaults)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.This issue requires a nightly compiler in some way. When possible, use a F-* label instead.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Omitting the return type of a trait method to use
()doesn't work withassociated_type_defaultswhen the default is()(type R = ();):https://play.rust-lang.org/?gist=2b56fc463679d93f1c24a8af3495c776&version=nightly&mode=debug&edition=2015
Even when I uncomment both occurrences of
/*-> Self::R*/, it doesn't work:I also have to uncomment both occurrences of
// type R = ();to get it to compile.Which defeats the purpose of using
associated_type_defaultshere :/I think this should work as intended though.
And when the default type is not
()(e.g.type R = i32;), it should still work to only writefn overload(self) -> Self::R {without overridingtype Rin thisimpl(if one wants to use the defaultRhere).