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

Comments

Projects
None yet
4 participants
@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.

@michaelwu

This comment has been minimized.

Copy link
Contributor

michaelwu commented Jul 17, 2015

@brson

This comment has been minimized.

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

This comment has been minimized.

Copy link
Contributor

brson commented Jan 12, 2017

Works as expected with a corrected test case.

@brson brson closed this Jan 12, 2017

@michaelwu

This comment has been minimized.

Copy link
Contributor

michaelwu commented Jan 12, 2017

For reference, fixed by #30446

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.