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]
This commit is contained in:
Patrick Walton
2014-06-12 14:08:44 -07:00
committed by Alex Crichton
parent 8c4a10a159
commit c9f3f47702
13 changed files with 323 additions and 31 deletions

View File

@@ -134,7 +134,7 @@ impl DynamicLibrary {
}
/// Access the value at the symbol of the dynamic library
pub unsafe fn symbol<T>(&self, symbol: &str) -> Result<T, String> {
pub unsafe fn symbol<T>(&self, symbol: &str) -> Result<*T, String> {
// This function should have a lifetime constraint of 'a on
// T but that feature is still unimplemented