Skip to content

Commit 3f58677

Browse files
authored
Merge branch 'master' into kkysen/c2rust-forward
2 parents 4ee2582 + 38d1803 commit 3f58677

File tree

22 files changed

+466
-184
lines changed

22 files changed

+466
-184
lines changed

Cargo.lock

Lines changed: 63 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ members = [
1111
"analysis/runtime",
1212
"dynamic_instrumentation",
1313
"pdg",
14-
"rustc-private-link",
14+
"c2rust-build-paths",
1515
]
1616
exclude = [
1717
"c2rust-macros",

analysis/runtime/src/mir_loc.rs

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use serde::{Deserialize, Serialize};
2+
use std::cmp::Ordering;
23
use std::fmt::Debug;
34
use std::fmt::{self, Display, Formatter};
45
use std::hash::{Hash, Hasher};
@@ -94,7 +95,7 @@ impl Debug for MirPlace {
9495

9596
pub type MirLocId = u32;
9697

97-
#[derive(Serialize, Deserialize, PartialEq, Eq, Hash, Copy, Clone, Debug)]
98+
#[derive(Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash, Copy, Clone, Debug)]
9899
pub struct Fingerprint(pub u64, pub u64);
99100

100101
impl From<(u64, u64)> for Fingerprint {
@@ -109,7 +110,7 @@ impl From<Fingerprint> for (u64, u64) {
109110
}
110111
}
111112

112-
#[derive(Serialize, Deserialize, PartialEq, Eq, Hash, Copy, Clone, Debug)]
113+
#[derive(Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash, Copy, Clone, Debug)]
113114
pub struct DefPathHash(pub Fingerprint);
114115

115116
impl From<(u64, u64)> for DefPathHash {
@@ -130,15 +131,33 @@ pub struct Func {
130131
pub name: String,
131132
}
132133

134+
impl Func {
135+
fn cmp_fields(&self) -> impl Eq + Hash + Ord + '_ {
136+
self.def_path_hash
137+
}
138+
}
139+
133140
impl PartialEq for Func {
134141
fn eq(&self, other: &Self) -> bool {
135-
self.def_path_hash == other.def_path_hash
142+
self.cmp_fields() == other.cmp_fields()
136143
}
137144
}
138145

139146
impl Hash for Func {
140147
fn hash<H: Hasher>(&self, state: &mut H) {
141-
self.def_path_hash.hash(state);
148+
self.cmp_fields().hash(state);
149+
}
150+
}
151+
152+
impl PartialOrd for Func {
153+
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
154+
self.cmp_fields().partial_cmp(&other.cmp_fields())
155+
}
156+
}
157+
158+
impl Ord for Func {
159+
fn cmp(&self, other: &Self) -> Ordering {
160+
self.cmp_fields().cmp(&other.cmp_fields())
142161
}
143162
}
144163

@@ -167,7 +186,7 @@ impl Default for TransferKind {
167186
}
168187
}
169188

170-
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Hash, Clone, Default)]
189+
#[derive(Debug, Serialize, Deserialize, Eq, Clone, Default)]
171190
pub struct EventMetadata {
172191
/// Input [`Local`]s for an [`Event`](crate::events::Event).
173192
pub source: Option<MirPlace>,
@@ -179,6 +198,30 @@ pub struct EventMetadata {
179198
pub debug_info: String,
180199
}
181200

201+
impl EventMetadata {
202+
fn eq_fields(&self) -> impl Eq + Hash + '_ {
203+
let Self {
204+
source,
205+
destination,
206+
transfer_kind,
207+
debug_info: _,
208+
} = self;
209+
(source, destination, transfer_kind)
210+
}
211+
}
212+
213+
impl PartialEq for EventMetadata {
214+
fn eq(&self, other: &Self) -> bool {
215+
self.eq_fields() == other.eq_fields()
216+
}
217+
}
218+
219+
impl Hash for EventMetadata {
220+
fn hash<H: Hasher>(&self, state: &mut H) {
221+
self.eq_fields().hash(state);
222+
}
223+
}
224+
182225
#[derive(Serialize, Deserialize, PartialEq, Eq, Hash)]
183226
pub struct MirLoc {
184227
pub func: Func,

c2rust-analyze/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ rustc-hash = "1.1.0"
1111
bitflags = "1.3.2"
1212

1313
[build-dependencies]
14-
rustc-private-link = { path = "../rustc-private-link" }
14+
c2rust-build-paths = { path = "../c2rust-build-paths" }
1515
print_bytes = "0.6"
1616

1717
[package.metadata.rust-analyzer]

c2rust-analyze/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_private_link::SysRoot;
1+
use c2rust_build_paths::SysRoot;
22

33
fn main() {
44
let sysroot = SysRoot::resolve();

c2rust-ast-exporter/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ clang-sys = "1.3"
2626
# Fixed by https://github.com/rust-lang/cmake-rs/pull/146 on 5/12/2022; waiting for next release.
2727
cmake = "=0.1.45"
2828
env_logger = "0.9"
29+
c2rust-build-paths = { path = "../c2rust-build-paths" }
2930

3031
[features]
3132
default = []

0 commit comments

Comments
 (0)