This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +63
-0
lines changed Expand file tree Collapse file tree 3 files changed +63
-0
lines changed Original file line number Diff line number Diff line change @@ -990,6 +990,7 @@ pub trait Tuple {}
990990 message = "`{Self}` needs to have the same ABI as a pointer" ,
991991 label = "`{Self}` needs to be a pointer-like type"
992992) ]
993+ #[ cfg_attr( not( bootstrap) , rustc_do_not_implement_via_object) ]
993994pub trait PointerLike { }
994995
995996#[ cfg( not( bootstrap) ) ]
Original file line number Diff line number Diff line change 1+ // Test that `dyn PointerLike` and `dyn* PointerLike` do not implement `PointerLike`.
2+ // This used to ICE during codegen.
3+
4+ #![ crate_type = "lib" ]
5+
6+ #![ feature( pointer_like_trait, dyn_star) ]
7+ #![ feature( unsized_fn_params) ]
8+ #![ expect( incomplete_features) ]
9+ #![ expect( internal_features) ]
10+
11+ use std:: marker:: PointerLike ;
12+
13+ pub fn lol ( x : dyn * PointerLike ) {
14+ foo ( x) ; //~ ERROR `dyn* PointerLike` needs to have the same ABI as a pointer
15+ }
16+
17+ pub fn uwu ( x : dyn PointerLike ) {
18+ foo ( x) ; //~ ERROR `dyn PointerLike` needs to have the same ABI as a pointer
19+ }
20+
21+ fn foo < T : PointerLike + ?Sized > ( x : T ) {
22+ let _: dyn * PointerLike = x;
23+ }
Original file line number Diff line number Diff line change 1+ error[E0277]: `dyn* PointerLike` needs to have the same ABI as a pointer
2+ --> $DIR/dyn-pointer-like.rs:14:9
3+ |
4+ LL | foo(x);
5+ | --- ^ the trait `PointerLike` is not implemented for `dyn* PointerLike`
6+ | |
7+ | required by a bound introduced by this call
8+ |
9+ = note: the trait bound `dyn* PointerLike: PointerLike` is not satisfied
10+ note: required by a bound in `foo`
11+ --> $DIR/dyn-pointer-like.rs:21:11
12+ |
13+ LL | fn foo<T: PointerLike + ?Sized>(x: T) {
14+ | ^^^^^^^^^^^ required by this bound in `foo`
15+ help: consider borrowing here
16+ |
17+ LL | foo(&x);
18+ | +
19+ LL | foo(&mut x);
20+ | ++++
21+
22+ error[E0277]: `dyn PointerLike` needs to have the same ABI as a pointer
23+ --> $DIR/dyn-pointer-like.rs:18:9
24+ |
25+ LL | foo(x);
26+ | --- ^ `dyn PointerLike` needs to be a pointer-like type
27+ | |
28+ | required by a bound introduced by this call
29+ |
30+ = help: the trait `PointerLike` is not implemented for `dyn PointerLike`
31+ note: required by a bound in `foo`
32+ --> $DIR/dyn-pointer-like.rs:21:11
33+ |
34+ LL | fn foo<T: PointerLike + ?Sized>(x: T) {
35+ | ^^^^^^^^^^^ required by this bound in `foo`
36+
37+ error: aborting due to 2 previous errors
38+
39+ For more information about this error, try `rustc --explain E0277`.
You can’t perform that action at this time.
0 commit comments