Skip to content

Commit

Permalink
Remove the return_address intrinsic.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Jun 26, 2016
1 parent 15e8a67 commit b30134d
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 125 deletions.
6 changes: 0 additions & 6 deletions src/libcore/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,6 @@ extern "rust-intrinsic" {
#[stable(feature = "rust1", since = "1.0.0")]
pub fn transmute<T, U>(e: T) -> U;

/// Gives the address for the return value of the enclosing function.
///
/// Using this intrinsic in a function that does not use an out pointer
/// will trigger a compiler error.
pub fn return_address() -> *const u8;

/// Returns `true` if the actual type given as `T` requires drop
/// glue; returns `false` if the actual type provided for `T`
/// implements `Copy`.
Expand Down
38 changes: 0 additions & 38 deletions src/librustc_trans/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,44 +12,6 @@

register_long_diagnostics! {

E0510: r##"
`return_address` was used in an invalid context. Erroneous code example:
```ignore
#![feature(intrinsics)]
extern "rust-intrinsic" {
fn return_address() -> *const u8;
}
unsafe fn by_value() -> i32 {
let _ = return_address();
// error: invalid use of `return_address` intrinsic: function does
// not use out pointer
0
}
```
Return values may be stored in a return register(s) or written into a so-called
out pointer. In case the returned value is too big (this is
target-ABI-dependent and generally not portable or future proof) to fit into
the return register(s), the compiler will return the value by writing it into
space allocated in the caller's stack frame. Example:
```
#![feature(intrinsics)]
extern "rust-intrinsic" {
fn return_address() -> *const u8;
}
unsafe fn by_pointer() -> String {
let _ = return_address();
String::new() // ok!
}
```
"##,

E0511: r##"
Invalid monomorphization of an intrinsic function was used. Erroneous code
example:
Expand Down
12 changes: 0 additions & 12 deletions src/librustc_trans/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,18 +617,6 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,

},


(_, "return_address") => {
if !fcx.fn_ty.ret.is_indirect() {
span_err!(tcx.sess, span, E0510,
"invalid use of `return_address` intrinsic: function \
does not use out pointer");
C_null(Type::i8p(ccx))
} else {
PointerCast(bcx, llvm::get_param(fcx.llfn, 0), Type::i8p(ccx))
}
}

(_, "discriminant_value") => {
let val_ty = substs.types.get(FnSpace, 0);
match val_ty.sty {
Expand Down
2 changes: 0 additions & 2 deletions src/librustc_typeck/check/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,6 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &hir::ForeignItem) {
"fadd_fast" | "fsub_fast" | "fmul_fast" | "fdiv_fast" | "frem_fast" =>
(1, vec![param(ccx, 0), param(ccx, 0)], param(ccx, 0)),

"return_address" => (0, vec![], tcx.mk_imm_ptr(tcx.types.u8)),

"assume" => (0, vec![tcx.types.bool], tcx.mk_nil()),

"discriminant_value" => (1, vec![
Expand Down
24 changes: 0 additions & 24 deletions src/test/compile-fail/intrinsic-return-address.rs

This file was deleted.

43 changes: 0 additions & 43 deletions src/test/run-pass/intrinsic-return-address.rs

This file was deleted.

0 comments on commit b30134d

Please sign in to comment.