-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyArea: Name/path resolution done by `rustc_resolve` specificallyP-mediumMedium priorityMedium priorityT-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.
Description
associated constants should support references to outer type parameters
Here is an example, adapted from the Zeroable
trait from core::non_zero
(playpen):
#![feature(associated_consts)]
trait Zble { const Z: Self; }
impl Zble for i32 { const Z: i32 = 0; }
impl<T> Zble for *const T { const Z: *const T = ::std::ptr::null(); }
fn main() { }
An attempt to compile this yields the error:
<anon>:5:45: 5:46 error: cannot use an outer type parameter in this context [E0402]
<anon>:5 impl<T> Zble for *const T { const Z: *const T = ::std::ptr::null(); }
^
<anon>:5:45: 5:46 error: use of undeclared type name `T` [E0412]
<anon>:5 impl<T> Zble for *const T { const Z: *const T = ::std::ptr::null(); }
^
Metadata
Metadata
Assignees
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyArea: Name/path resolution done by `rustc_resolve` specificallyP-mediumMedium priorityMedium priorityT-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.