mirror of
				https://github.com/rust-lang/rust.git
				synced 2025-10-31 04:57:19 +00:00 
			
		
		
		
	 b3cc9b9620
			
		
	
	
		b3cc9b9620
		
	
	
	
	
		
			
			Do not allow users to apply `#[non_exaustive]` to a struct when they have also used default field values.
		
			
				
	
	
		
			19 lines
		
	
	
		
			367 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			19 lines
		
	
	
		
			367 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
| #![feature(default_field_values)]
 | |
| 
 | |
| #[derive(Default)]
 | |
| #[non_exhaustive] //~ ERROR `#[non_exhaustive]` can't be used to annotate items with default field values
 | |
| struct Foo {
 | |
|     x: i32 = 42 + 3,
 | |
| }
 | |
| 
 | |
| #[derive(Default)]
 | |
| enum Bar {
 | |
|     #[non_exhaustive]
 | |
|     #[default]
 | |
|     Baz { //~ ERROR default variant must be exhaustive
 | |
|         x: i32 = 42 + 3,
 | |
|     }
 | |
| }
 | |
| 
 | |
| fn main () {}
 |