forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#84243 - Soveu:fix-derive-macro-const-defaul…
…t, r=petrochenkov Builtin derive macros: fix error with const generics default This fixes a bug where builtin derive macros (like Clone, Debug) would basically copy-paste the default from a const generic, causing a compile error with very confusing message - it would say defaults are not allowed in impl blocks, while pointing at struct/enum/union definition.
- Loading branch information
Showing
2 changed files
with
27 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// check-pass | ||
#![allow(incomplete_features)] | ||
#![feature(const_generics_defaults)] | ||
|
||
#[derive(Clone, PartialEq, Debug)] | ||
struct Example<T, const N: usize = 1usize>([T; N]); | ||
|
||
fn main() { | ||
let a = Example([(); 16]); | ||
let b = a.clone(); | ||
if a != b { | ||
let _c = format!("{:?}", a); | ||
} | ||
} |