Skip to content
Merged
Changes from 2 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7cdcdb5
Update reference of rlibc crate to compiler-builtins crate
king6cong Jan 2, 2019
5581207
Remove outdated comment
king6cong Jan 9, 2019
87f5a98
Use `to_ne_bytes` for converting IPv4Address to octets
JakubOnderka Jan 18, 2019
b4d3c87
Tiny improvement to docs for `core::convert`.
icefoxen Jan 26, 2019
bd4df0c
Add Cargo.lock automatically adding message
h-michael Feb 4, 2019
4deb595
display sugared return types for async functions
euclio Feb 5, 2019
1d05f81
Add #[must_use] message to Fn* traits
taiki-e Feb 7, 2019
541503a
std::sys::unix::stdio: explain why we do into_raw
RalfJung Feb 8, 2019
b962ecc
Cleanup JS a bit
GuillaumeGomez Feb 8, 2019
caf7126
Some writing improvement, conciseness of intro
hayekr Feb 9, 2019
66adf52
miri: give non-generic functions a stable address
RalfJung Feb 9, 2019
a01efbc
operand-to-place copies should never be overlapping
RalfJung Feb 9, 2019
3a3691f
when there are multiple filenames, print what got interpreted as 2nd …
RalfJung Feb 10, 2019
adb3300
rpath computation: explain why we pop()
RalfJung Feb 10, 2019
55f90c7
Fix failing tidy (line endings on Windows)
petrochenkov Feb 10, 2019
74e97f3
Add trait alias support in rustdoc
GuillaumeGomez Feb 5, 2019
29354dd
Add style for trait aliases
GuillaumeGomez Feb 7, 2019
c20357a
Add trait aliases to js types
GuillaumeGomez Feb 7, 2019
eaf81c2
miri value visitor: use in macro
RalfJung Feb 10, 2019
b1d82ac
Remove spotlight for trait aliases and fix nits
GuillaumeGomez Feb 10, 2019
e917f8b
Rollup merge of #57259 - king6cong:master, r=alexcrichton
GuillaumeGomez Feb 10, 2019
d9f9780
Rollup merge of #57740 - JakubOnderka:ipv4addr-to_ne_bytes, r=scottmcm
GuillaumeGomez Feb 10, 2019
82e051b
Rollup merge of #57926 - icefoxen:test-doc-pr, r=frewsxcv
GuillaumeGomez Feb 10, 2019
a74e4f7
Rollup merge of #58157 - h-michael:cargo-lock, r=alexcrichton
GuillaumeGomez Feb 10, 2019
cdbd07c
Rollup merge of #58203 - euclio:rustdoc-async, r=GuillaumeGomez
GuillaumeGomez Feb 10, 2019
adf516b
Rollup merge of #58243 - GuillaumeGomez:trait-alias-docs, r=Manishearth
GuillaumeGomez Feb 10, 2019
112629b
Rollup merge of #58262 - taiki-e:must_use, r=estebank
GuillaumeGomez Feb 10, 2019
d59ca59
Rollup merge of #58295 - RalfJung:stdio, r=alexcrichton
GuillaumeGomez Feb 10, 2019
d5a8b24
Rollup merge of #58297 - GuillaumeGomez:cleanup-js, r=QuietMisdreavus
GuillaumeGomez Feb 10, 2019
f4e7bc5
Rollup merge of #58317 - hayekr:patch-1, r=frewsxcv
GuillaumeGomez Feb 10, 2019
a09aa0f
Rollup merge of #58324 - RalfJung:fn-ptr-eq, r=oli-obk
GuillaumeGomez Feb 10, 2019
c3aa847
Rollup merge of #58332 - RalfJung:miri-copy-nonoverlapping, r=oli-obk
GuillaumeGomez Feb 10, 2019
53e9a65
Rollup merge of #58345 - RalfJung:2nd-filename, r=matthewjasper
GuillaumeGomez Feb 10, 2019
9ccfb74
Rollup merge of #58346 - RalfJung:rpath-pop, r=Mark-Simulacrum
GuillaumeGomez Feb 10, 2019
585f9a7
Rollup merge of #58350 - petrochenkov:embed, r=frewsxcv
GuillaumeGomez Feb 10, 2019
d792cef
Rollup merge of #58352 - RalfJung:macro, r=oli-obk
GuillaumeGomez Feb 10, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions src/librustc/mir/interpret/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub use self::pointer::{Pointer, PointerArithmetic};
use std::fmt;
use crate::mir;
use crate::hir::def_id::DefId;
use crate::ty::{self, TyCtxt, Instance};
use crate::ty::{self, TyCtxt, Instance, subst::UnpackedKind};
use crate::ty::layout::{self, Size};
use std::io;
use crate::rustc_serialize::{Encoder, Decodable, Encodable};
Expand Down Expand Up @@ -318,14 +318,29 @@ impl<'tcx> AllocMap<'tcx> {
id
}

/// Functions cannot be identified by pointers, as asm-equal functions can get deduplicated
/// by the linker and functions can be duplicated across crates.
/// We thus generate a new `AllocId` for every mention of a function. This means that
/// `main as fn() == main as fn()` is false, while `let x = main as fn(); x == x` is true.
pub fn create_fn_alloc(&mut self, instance: Instance<'tcx>) -> AllocId {
let id = self.reserve();
self.id_to_kind.insert(id, AllocKind::Function(instance));
id
// Functions cannot be identified by pointers, as asm-equal functions can get deduplicated
// by the linker (we set the "unnamed_addr" attribute for LLVM) and functions can be
// duplicated across crates.
// We thus generate a new `AllocId` for every mention of a function. This means that
// `main as fn() == main as fn()` is false, while `let x = main as fn(); x == x` is true.
// However, formatting code relies on function identity (see #58320), so we only do
// this for generic functions. Lifetime parameters are ignored.
let is_generic = instance.substs.into_iter().any(|kind| {
match kind.unpack() {
UnpackedKind::Lifetime(_) => false,
_ => true,
}
});
if is_generic {
// Get a fresh ID
let id = self.reserve();
self.id_to_kind.insert(id, AllocKind::Function(instance));
id
} else {
// Deduplicate
self.intern(AllocKind::Function(instance))
}
}

/// Returns `None` in case the `AllocId` is dangling. An `EvalContext` can still have a
Expand Down