Skip to content

Add regression test for #79495 #98618

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

Closed
Closed
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
16 changes: 16 additions & 0 deletions src/test/rustdoc-ui/issue-79495.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#![feature(arbitrary_enum_discriminant, core_intrinsics)]

extern crate core;
use core::intrinsics::discriminant_value;

#[repr(usize)]
enum MyWeirdOption<T> {
None = 0,
Some(T) = std::mem::size_of::<T>(),
//~^ ERROR generic parameters may not be used in const operations
}

fn main() {
assert_eq!(discriminant_value(&MyWeirdOption::<u8>::None), 0);
assert_eq!(discriminant_value(&MyWeirdOption::Some(0u8)), 1);
}
13 changes: 13 additions & 0 deletions src/test/rustdoc-ui/issue-79495.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
error: generic parameters may not be used in const operations
--> $DIR/issue-79495.rs:9:35
|
LL | Some(T) = std::mem::size_of::<T>(),
| ^ cannot perform const operation using `T`
|
= note: type parameters may not be used in const expressions
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a better test here would enable this feature -- that likely tests a larger section of code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding #![feature(generic_const_exprs)] still causes the same ICE, so I will close this pull request.


error: Compilation failed, aborting rustdoc

error: aborting due to 2 previous errors