- AdtKind::Union => {
- err.note("no field of a union may have a dynamically sized type");
- }
- AdtKind::Enum => {
- err.note("no field of an enum variant may have a dynamically sized type");
- }
- },
+ err.help("change the field's type to have a statically known size");
+ err.span_suggestion(
+ span.shrink_to_lo(),
+ "borrowed types always have a statically known size",
+ "&".to_string(),
+ Applicability::MachineApplicable,
+ );
+ err.multipart_suggestion(
+ "heap allocated types always have a statically known size",
+ vec![
+ (span.shrink_to_lo(), "Box<".to_string()),
+ (span.shrink_to_hi(), ">".to_string()),
+ ],
+ Applicability::MachineApplicable,
+ );
+ }