diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2014-06-12 14:08:44 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-06-13 13:53:55 -0700 |
| commit | c9f3f47702602d196de414aa4f10bb2c2148ab9a (patch) | |
| tree | 9a1b3943e8b6f01f77750333547178f2b92ce7ee /src/librustc/plugin | |
| parent | 8c4a10a159a021a586a8a35552cbbe4f60e644a2 (diff) | |
| download | rust-c9f3f47702602d196de414aa4f10bb2c2148ab9a.tar.gz rust-c9f3f47702602d196de414aa4f10bb2c2148ab9a.zip | |
librustc: Forbid `transmute` from being called on types whose size is
only known post-monomorphization, and report `transmute` errors before
the code is generated for that `transmute`.
This can break code that looked like:
unsafe fn f<T>(x: T) {
let y: int = transmute(x);
}
Change such code to take a type parameter that has the same size as the
type being transmuted to.
Closes #12898.
[breaking-change]
Diffstat (limited to 'src/librustc/plugin')
| -rw-r--r-- | src/librustc/plugin/load.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/librustc/plugin/load.rs b/src/librustc/plugin/load.rs index 97ffcf279ae..7d74b8c7296 100644 --- a/src/librustc/plugin/load.rs +++ b/src/librustc/plugin/load.rs @@ -126,9 +126,11 @@ impl<'a> PluginLoader<'a> { }; unsafe { - let registrar: PluginRegistrarFun = + let registrar = match lib.symbol(symbol.as_slice()) { - Ok(registrar) => registrar, + Ok(registrar) => { + mem::transmute::<*u8,PluginRegistrarFun>(registrar) + } // again fatal if we can't register macros Err(err) => self.sess.span_fatal(vi.span, err.as_slice()) }; |
