mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 15:23:46 +00:00
parent
1f4c63049e
commit
1607871dc2
@ -48,6 +48,8 @@ use util::ppaux::Repr;
|
||||
use std::rc::Rc;
|
||||
use std::vec_ng::Vec;
|
||||
use std::vec_ng;
|
||||
use collections::HashSet;
|
||||
|
||||
use syntax::abi::AbiSet;
|
||||
use syntax::ast::{RegionTyParamBound, TraitTyParamBound};
|
||||
use syntax::ast;
|
||||
@ -478,7 +480,12 @@ fn convert_methods(ccx: &CrateCtxt,
|
||||
rcvr_visibility: ast::Visibility)
|
||||
{
|
||||
let tcx = ccx.tcx;
|
||||
let mut seen_methods = HashSet::new();
|
||||
for m in ms.iter() {
|
||||
if !seen_methods.insert(m.ident.repr(ccx.tcx)) {
|
||||
tcx.sess.span_err(m.span, "duplicate method in trait impl");
|
||||
}
|
||||
|
||||
let num_rcvr_ty_params = rcvr_ty_generics.type_param_defs().len();
|
||||
let m_ty_generics = ty_generics_for_fn_or_method(ccx, &m.generics,
|
||||
num_rcvr_ty_params);
|
||||
|
26
src/test/compile-fail/issue-8153.rs
Normal file
26
src/test/compile-fail/issue-8153.rs
Normal file
@ -0,0 +1,26 @@
|
||||
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// Test that duplicate methods in impls are not allowed
|
||||
|
||||
struct Foo;
|
||||
|
||||
trait Bar {
|
||||
fn bar(&self) -> int;
|
||||
}
|
||||
|
||||
impl Bar for Foo {
|
||||
fn bar(&self) -> int {1}
|
||||
fn bar(&self) -> int {2} //~ ERROR duplicate method
|
||||
}
|
||||
|
||||
fn main() {
|
||||
println!("{}", Foo.bar());
|
||||
}
|
Loading…
Reference in New Issue
Block a user