Skip to content

Commit

Permalink
Rollup merge of rust-lang#113020 - AnthonyKalaitzis:add-tests-impl-vi…
Browse files Browse the repository at this point in the history
…a-obj-unless-denied, r=compiler-errors

Add tests impl via obj unless denied

Fixes rust-lang#112737

Add simple tests to check feature change in rust-lang#112320 is performing as expected.

Note:

- Unsure about filenames, locations & function signature names (tried to make them something sensible)
  • Loading branch information
matthiaskrgr committed Jun 27, 2023
2 parents 9ec676d + 09f0548 commit db11b77
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/ui/traits/ice-with-dyn-pointee-errors.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#![feature(ptr_metadata)]
// Address issue #112737 -- ICE with dyn Pointee
extern crate core;
use core::ptr::Pointee;

fn unknown_sized_object_ptr_in(_: &(impl Pointee<Metadata = ()> + ?Sized)) {}

fn raw_pointer_in(x: &dyn Pointee<Metadata = ()>) {
unknown_sized_object_ptr_in(x)
//~^ ERROR type mismatch resolving `<dyn Pointee<Metadata = ()> as Pointee>::Metadata == ()`
}

fn main() {
raw_pointer_in(&42)
}
19 changes: 19 additions & 0 deletions tests/ui/traits/ice-with-dyn-pointee-errors.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error[E0271]: type mismatch resolving `<dyn Pointee<Metadata = ()> as Pointee>::Metadata == ()`
--> $DIR/ice-with-dyn-pointee-errors.rs:9:33
|
LL | unknown_sized_object_ptr_in(x)
| --------------------------- ^ expected `()`, found `DynMetadata<dyn Pointee<Metadata = ...>>`
| |
| required by a bound introduced by this call
|
= note: expected unit type `()`
found struct `DynMetadata<dyn Pointee<Metadata = ()>>`
note: required by a bound in `unknown_sized_object_ptr_in`
--> $DIR/ice-with-dyn-pointee-errors.rs:6:50
|
LL | fn unknown_sized_object_ptr_in(_: &(impl Pointee<Metadata = ()> + ?Sized)) {}
| ^^^^^^^^^^^^^ required by this bound in `unknown_sized_object_ptr_in`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0271`.
11 changes: 11 additions & 0 deletions tests/ui/traits/ice-with-dyn-pointee.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// run-pass
#![feature(ptr_metadata)]
// Address issue #112737 -- ICE with dyn Pointee
extern crate core;
use core::ptr::Pointee;

fn raw_pointer_in(_: &dyn Pointee<Metadata = ()>) {}

fn main() {
raw_pointer_in(&42)
}

0 comments on commit db11b77

Please sign in to comment.