diff options
| author | Sean Patrick Santos <SeanPatrickSantos@gmail.com> | 2015-05-21 21:12:49 -0600 |
|---|---|---|
| committer | Sean Patrick Santos <SeanPatrickSantos@gmail.com> | 2015-05-21 21:12:49 -0600 |
| commit | 8db699d18d263bf779f260ba55221a8c0ff2f5d8 (patch) | |
| tree | 5347a4b7c8c518773545fe51995864810454a70c | |
| parent | 98f41ff3555dba80b47ebee6f6bc8a7df697240c (diff) | |
| download | rust-8db699d18d263bf779f260ba55221a8c0ff2f5d8.tar.gz rust-8db699d18d263bf779f260ba55221a8c0ff2f5d8.zip | |
Add diagnostic code for generic associated const error.
| -rw-r--r-- | src/librustc_typeck/check/mod.rs | 6 | ||||
| -rw-r--r-- | src/librustc_typeck/diagnostics.rs | 1 | ||||
| -rw-r--r-- | src/test/compile-fail/associated-const-type-parameters.rs | 6 |
3 files changed, 7 insertions, 6 deletions
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index c9ef9351959..77aded3ccdb 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -3773,9 +3773,9 @@ pub fn resolve_ty_and_def_ufcs<'a, 'b, 'tcx>(fcx: &FnCtxt<'b, 'tcx>, match def { def::DefAssociatedConst(..) => { if ty::type_has_params(ty) || ty::type_has_self(ty) { - fcx.sess().span_err(span, - "Associated consts cannot depend \ - on type parameters or Self."); + span_err!(fcx.sess(), span, E0329, + "Associated consts cannot depend \ + on type parameters or Self."); fcx.write_error(node_id); return true; } diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 58d09632741..200a7bee833 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -771,6 +771,7 @@ register_diagnostics! { E0326, // associated const implemented with different type from trait E0327, // referred to method instead of constant in match pattern E0328, // cannot implement Unsize explicitly + E0329, // associated const depends on type parameter or Self. E0366, // dropck forbid specialization to concrete type or region E0367, // dropck forbid specialization to predicate not in struct/enum E0369, // binary operation `<op>` cannot be applied to types diff --git a/src/test/compile-fail/associated-const-type-parameters.rs b/src/test/compile-fail/associated-const-type-parameters.rs index bbe252fc151..e48ff59d1dc 100644 --- a/src/test/compile-fail/associated-const-type-parameters.rs +++ b/src/test/compile-fail/associated-const-type-parameters.rs @@ -14,13 +14,13 @@ pub trait Foo { const MIN: i32; fn get_min() -> i32 { - Self::MIN //~ Associated consts cannot depend on type parameters or Self. + Self::MIN //~ ERROR E0329 } } fn get_min<T: Foo>() -> i32 { - T::MIN; //~ Associated consts cannot depend on type parameters or Self. - <T as Foo>::MIN //~ Associated consts cannot depend on type parameters or Self. + T::MIN; //~ ERROR E0329 + <T as Foo>::MIN //~ ERROR E0329 } fn main() {} |
