]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #34198 - eddyb:you're-a-bad-transmute-and-you-should-feel-bad, r=nikoma...
authorbors <bors@rust-lang.org>
Wed, 1 Mar 2017 10:03:44 +0000 (10:03 +0000)
committerbors <bors@rust-lang.org>
Wed, 1 Mar 2017 10:03:44 +0000 (10:03 +0000)
Make transmuting from fn item types to pointer-sized types a hard error.

Closes #19925 by removing the future compatibility lint and the associated workarounds.
This is a `[breaking-change]` if you `transmute` from a function item without casting first.
For more information on how to fix your code, see https://github.com/rust-lang/rust/issues/19925.

1  2 
src/librustc/lint/builtin.rs
src/librustc_lint/lib.rs

index b2f508ff26d6f46b888d183b32678eeefc3fdd95,6c2730f2d1a5fa5408740528cb87945577d8b525..e681d55cf94b893db2fd37f65eb7e5a422bc4dda
@@@ -155,12 -155,6 +155,6 @@@ declare_lint! 
      "uses of #[derive] with raw pointers are rarely correct"
  }
  
- declare_lint! {
-     pub TRANSMUTE_FROM_FN_ITEM_TYPES,
-     Deny,
-     "transmute from function item type to pointer-sized type erroneously allowed"
- }
  declare_lint! {
      pub HR_LIFETIME_IN_ASSOC_TYPE,
      Deny,
@@@ -236,12 -230,6 +230,12 @@@ declare_lint! 
      "detects use of struct constructors that would be invisible with new visibility rules"
  }
  
 +declare_lint! {
 +    pub MISSING_FRAGMENT_SPECIFIER,
 +    Warn,
 +    "detects missing fragment specifiers in unused `macro_rules!` patterns"
 +}
 +
  declare_lint! {
      pub DEPRECATED,
      Warn,
@@@ -279,7 -267,6 +273,6 @@@ impl LintPass for HardwiredLints 
              ILLEGAL_STRUCT_OR_ENUM_CONSTANT_PATTERN,
              CONST_ERR,
              RAW_POINTER_DERIVE,
-             TRANSMUTE_FROM_FN_ITEM_TYPES,
              OVERLAPPING_INHERENT_IMPLS,
              RENAMED_AND_REMOVED_LINTS,
              SUPER_OR_SELF_IN_GLOBAL_PATH,
              LEGACY_DIRECTORY_OWNERSHIP,
              LEGACY_IMPORTS,
              LEGACY_CONSTRUCTOR_VISIBILITY,
 +            MISSING_FRAGMENT_SPECIFIER,
              DEPRECATED
          )
      }
diff --combined src/librustc_lint/lib.rs
index b87edf548232492007482b4b2df53796e5f39554,091bc9cfdfaecc88bd6abe4b16eafd11513e4e70..443a219928f1c04229ed0f728fb9b2c436fafcd3
@@@ -195,10 -195,6 +195,6 @@@ pub fn register_builtins(store: &mut li
              id: LintId::of(SUPER_OR_SELF_IN_GLOBAL_PATH),
              reference: "issue #36888 <https://github.com/rust-lang/rust/issues/36888>",
          },
-         FutureIncompatibleInfo {
-             id: LintId::of(TRANSMUTE_FROM_FN_ITEM_TYPES),
-             reference: "issue #19925 <https://github.com/rust-lang/rust/issues/19925>",
-         },
          FutureIncompatibleInfo {
              id: LintId::of(OVERLAPPING_INHERENT_IMPLS),
              reference: "issue #36889 <https://github.com/rust-lang/rust/issues/36889>",
              id: LintId::of(LEGACY_CONSTRUCTOR_VISIBILITY),
              reference: "issue #39207 <https://github.com/rust-lang/rust/issues/39207>",
          },
 +        FutureIncompatibleInfo {
 +            id: LintId::of(MISSING_FRAGMENT_SPECIFIER),
 +            reference: "issue #40107 <https://github.com/rust-lang/rust/issues/40107>",
 +        },
          ]);
  
      // Register renamed and removed lints
      store.register_removed("raw_pointer_deriving",
                             "using derive with raw pointers is ok");
      store.register_removed("drop_with_repr_extern", "drop flags have been removed");
+     store.register_removed("transmute_from_fn_item_types",
+         "always cast functions before transmuting them");
  }