Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Associated consts cannot depend on type parameters or Self #26524

Closed
yongqli opened this issue Jun 23, 2015 · 4 comments
Closed

Associated consts cannot depend on type parameters or Self #26524

yongqli opened this issue Jun 23, 2015 · 4 comments
Labels
A-associated-items Area: Associated items such as associated types and consts.

Comments

@yongqli
Copy link

yongqli commented Jun 23, 2015

This fails to compile

trait Matrix {
    const EYE: f64;
}

fn get_EYE<M: Matrix>(t: M) {
    M::EYE
}

with error: Associated consts cannot depend on type parameters or Self. [E0329], but it should work.

@steveklabnik steveklabnik added the A-associated-items Area: Associated items such as associated types and consts. label Jun 23, 2015
@michaelwu
Copy link
Contributor

rust-lang/rfcs#1062

@brson
Copy link
Contributor

brson commented Jan 12, 2017

Error is different now:



rustc 1.16.0-nightly (47c8d9fdc 2017-01-08)
error[E0308]: mismatched types
 --> <anon>:8:5
  |
8 |     M::EYE
  |     ^^^^^^ expected (), found f64
  |
  = note: expected type `()`
  = note:    found type `f64`

error: aborting due to previous error

From this updated case:

#![feature(associated_consts)]

trait Matrix {
    const EYE: f64;
}

fn get_EYE<M: Matrix>(t: M) {
    M::EYE
}

fn main() { }

@brson
Copy link
Contributor

brson commented Jan 12, 2017

Works as expected with a corrected test case.

@brson brson closed this as completed Jan 12, 2017
@michaelwu
Copy link
Contributor

For reference, fixed by #30446

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items such as associated types and consts.
Projects
None yet
Development

No branches or pull requests

4 participants