diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index 61f05ca347358..a526967aff0aa 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -2139,6 +2139,7 @@ register_diagnostics! { E0657, // `impl Trait` can only capture lifetimes bound at the fn level E0687, // in-band lifetimes cannot be used in `fn`/`Fn` syntax E0688, // in-band lifetimes cannot be mixed with explicit lifetime binders + E0689, // `#[repr]` must have a hint E0906, // closures cannot be static } diff --git a/src/librustc/hir/check_attr.rs b/src/librustc/hir/check_attr.rs index 591cb9d5ad6c2..1e642b98e18ce 100644 --- a/src/librustc/hir/check_attr.rs +++ b/src/librustc/hir/check_attr.rs @@ -154,7 +154,22 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> { let hints: Vec<_> = item.attrs .iter() .filter(|attr| attr.name() == "repr") - .filter_map(|attr| attr.meta_item_list()) + .filter_map(|attr| { + let list = attr.meta_item_list(); + let mut has_hints = false; + if let Some(ref list) = list { + has_hints = !list.is_empty(); + } + if !has_hints { + span_warn!( + self.tcx.sess, + item.span, + E0689, + "`repr` attribute cannot be empty", + ); + } + list + }) .flat_map(|hints| hints) .collect();