Skip to content

Commit 0be1e43

Browse files
committed
Fix error codes
1 parent 40fffc9 commit 0be1e43

File tree

4 files changed

+33
-4
lines changed

4 files changed

+33
-4
lines changed

src/librustc_typeck/coherence/orphan.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl<'cx, 'tcx,'v> visit::Visitor<'v> for OrphanChecker<'cx, 'tcx> {
101101
debug!("coherence2::orphan check: default trait impl {}", item.repr(self.tcx));
102102
let trait_ref = ty::node_id_to_trait_ref(self.tcx, ast_trait_ref.ref_id);
103103
if trait_ref.def_id.krate != ast::LOCAL_CRATE {
104-
span_err!(self.tcx.sess, item.span, E0316,
104+
span_err!(self.tcx.sess, item.span, E0318,
105105
"cannot create default implementations for traits outside the \
106106
crate they're defined in; define a new trait instead.");
107107
}

src/librustc_typeck/coherence/overlap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl<'cx, 'tcx,'v> visit::Visitor<'v> for OverlapChecker<'cx, 'tcx> {
141141
ty::ty_struct(..) | ty::ty_enum(..) => {},
142142
_ => {
143143
let impl_def_id = ast_util::local_def(item.id);
144-
span_err!(self.tcx.sess, self.span_of_impl(impl_def_id), E0317,
144+
span_err!(self.tcx.sess, self.span_of_impl(impl_def_id), E0319,
145145
"implementations for traits providing default \
146146
implementations are only allowed on structs and enums");
147147

src/librustc_typeck/diagnostics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ register_diagnostics! {
172172
E0248, // found value name used as a type
173173
E0249, // expected constant expr for array length
174174
E0250, // expected constant expr for array length
175-
E0316, // can't create default impls for traits outside their crates
176-
E0317
175+
E0318, // can't create default impls for traits outside their crates
176+
E0319 // trait impls for defaulted traits allowed just for structs/enums
177177
}
178178

179179
__build_diagnostic_array! { DIAGNOSTICS }
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Test that when a `..` impl applies, we also check that any
12+
// supertrait conditions are met.
13+
14+
#![feature(optin_builtin_traits)]
15+
16+
trait NotImplemented { }
17+
18+
trait MyTrait : NotImplemented {}
19+
20+
impl MyTrait for .. {}
21+
22+
fn foo<T:MyTrait>() { bar::<T>() }
23+
24+
fn bar<T:NotImplemented>() { }
25+
26+
fn main() {
27+
foo::<i32>(); //~ ERROR XXX
28+
bar::<i32>(); //~ ERROR XXX
29+
}

0 commit comments

Comments
 (0)