Skip to content

Commit f57d5ad

Browse files
committed
check inherent impls of traits for overlap as well
1 parent 8780962 commit f57d5ad

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/librustc_typeck/coherence/overlap.rs

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OverlapChecker<'cx, 'tcx> {
102102
match item.node {
103103
hir::ItemEnum(..) |
104104
hir::ItemStruct(..) |
105+
hir::ItemTrait(..) |
105106
hir::ItemUnion(..) => {
106107
let type_def_id = self.tcx.map.local_def_id(item.id);
107108
self.check_for_overlapping_inherent_impls(type_def_id);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2016 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+
#![allow(dead_code)]
12+
#![deny(overlapping_inherent_impls)]
13+
14+
trait C {}
15+
impl C { fn f() {} } //~ ERROR duplicate definitions with name `f`
16+
impl C { fn f() {} }
17+
fn main() { }

0 commit comments

Comments
 (0)