Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delegation: fix ICE on duplicated associative items
- Loading branch information
Showing
4 changed files
with
72 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
tests/ui/delegation/duplicate-definition-inside-trait-impl.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#![feature(fn_delegation)] | ||
//~^ WARN the feature `fn_delegation` is incomplete | ||
|
||
trait Trait { | ||
fn foo(&self) -> u32 { 0 } | ||
} | ||
|
||
struct F; | ||
struct S; | ||
|
||
mod to_reuse { | ||
use crate::S; | ||
|
||
pub fn foo(_: &S) -> u32 { 0 } | ||
} | ||
|
||
impl Trait for S { | ||
reuse to_reuse::foo { self } | ||
reuse Trait::foo; | ||
//~^ ERROR duplicate definitions with name `foo` | ||
} | ||
|
||
fn main() {} |
23 changes: 23 additions & 0 deletions
23
tests/ui/delegation/duplicate-definition-inside-trait-impl.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
error[E0201]: duplicate definitions with name `foo`: | ||
--> $DIR/duplicate-definition-inside-trait-impl.rs:19:5 | ||
| | ||
LL | fn foo(&self) -> u32 { 0 } | ||
| -------------------------- item in trait | ||
... | ||
LL | reuse to_reuse::foo { self } | ||
| ---------------------------- previous definition here | ||
LL | reuse Trait::foo; | ||
| ^^^^^^^^^^^^^^^^^ duplicate definition | ||
|
||
warning: the feature `fn_delegation` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/duplicate-definition-inside-trait-impl.rs:1:12 | ||
| | ||
LL | #![feature(fn_delegation)] | ||
| ^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
||
error: aborting due to 1 previous error; 1 warning emitted | ||
|
||
For more information about this error, try `rustc --explain E0201`. |