Skip to content

add test for dyn call issue #2446

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2fdbf075cf502431ca9fee6616331b32e34f25de
a86705942c4cfaaee60f2e7308ca2bca703a710f
19 changes: 19 additions & 0 deletions tests/fail/issue-miri-2432.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#![allow(where_clauses_object_safety)]

trait Trait {}

trait X {
fn foo(&self)
where
Self: Trait;
}

impl X for () {
fn foo(&self) {}
}

impl Trait for dyn X {}

pub fn main() {
<dyn X as X>::foo(&()); //~ERROR: trying to call something that is not a method
}
15 changes: 15 additions & 0 deletions tests/fail/issue-miri-2432.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
error: Undefined Behavior: `dyn` call trying to call something that is not a method
--> $DIR/issue-miri-2432.rs:LL:CC
|
LL | <dyn X as X>::foo(&());
| ^^^^^^^^^^^^^^^^^^^^^^ `dyn` call trying to call something that is not a method
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
= note: backtrace:
= note: inside `main` at $DIR/issue-miri-2432.rs:LL:CC

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

error: aborting due to previous error