Skip to content

Commit

Permalink
Add test for issue rust-lang#51892
Browse files Browse the repository at this point in the history
  • Loading branch information
marmeladema committed Apr 23, 2021
1 parent a657e17 commit 9b430df
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/test/ui/specialization/issue-51892.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#![allow(incomplete_features)]
#![feature(const_generics)]
#![feature(const_evaluatable_checked)]
#![feature(specialization)]

pub trait Trait {
type Type;
}

impl<T: ?Sized> Trait for T {
default type Type = [u8; 1];
}

impl<T: Trait> Trait for *const T {
type Type = [u8; std::mem::size_of::<<T as Trait>::Type>()];
//~^ ERROR: unconstrained generic constant
}

fn main() {}
10 changes: 10 additions & 0 deletions src/test/ui/specialization/issue-51892.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error: unconstrained generic constant
--> $DIR/issue-51892.rs:15:5
|
LL | type Type = [u8; std::mem::size_of::<<T as Trait>::Type>()];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: try adding a `where` bound using this expression: `where [(); std::mem::size_of::<<T as Trait>::Type>()]:`

error: aborting due to previous error

0 comments on commit 9b430df

Please sign in to comment.