]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/lint/builtin.rs
auto merge of #15999 : Kimundi/rust/fix_folder, r=nikomatsakis
[rust.git] / src / librustc / lint / builtin.rs
index 0f799e26cc7414bca4545549ccf3471ebb29136c..1667f2b6d5f0a7ec9cc17f1cc5e6f3ec27bc4661 100644 (file)
@@ -358,9 +358,9 @@ fn check_ty(cx: &Context, ty: &ast::Ty) {
                         def::DefTy(def_id) => {
                             if !adt::is_ffi_safe(cx.tcx, def_id) {
                                 cx.span_lint(CTYPES, ty.span,
-                                             "found enum type without foreign-function-safe \
-                                              representation annotation in foreign module");
-                                // hmm... this message could be more helpful
+                                             "found enum type without foreign-function-safe
+                                             representation annotation in foreign module, consider \
+                                             adding a #[repr(...)] attribute to the enumeration");
                             }
                         }
                         _ => ()
@@ -758,6 +758,11 @@ fn check_case(cx: &Context, sort: &str, ident: ast::Ident, span: Span) {
             }
         }
 
+        let has_extern_repr = it.attrs.iter().fold(attr::ReprAny, |acc, attr| {
+            attr::find_repr_attr(cx.tcx.sess.diagnostic(), attr, acc)
+        }) == attr::ReprExtern;
+        if has_extern_repr { return }
+
         match it.node {
             ast::ItemTy(..) | ast::ItemStruct(..) => {
                 check_case(cx, "type", it.ident, it.span)
@@ -1428,6 +1433,9 @@ fn get_lints(&self) -> LintArray {
     }
 
     fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
+        // if the expression was produced by a macro expansion,
+        if e.span.expn_info.is_some() { return }
+
         let id = match e.node {
             ast::ExprPath(..) | ast::ExprStruct(..) => {
                 match cx.tcx.def_map.borrow().find(&e.id) {
@@ -1443,6 +1451,9 @@ fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
                             typeck::MethodStatic(def_id) => {
                                 def_id
                             }
+                            typeck::MethodStaticUnboxedClosure(def_id) => {
+                                def_id
+                            }
                             typeck::MethodParam(typeck::MethodParam {
                                 trait_id: trait_id,
                                 method_num: index,