Skip to content

Commit d583d31

Browse files
Remove core_intrinsics feature gate
1 parent 32ab238 commit d583d31

File tree

10 files changed

+67
-20
lines changed

10 files changed

+67
-20
lines changed

src/bootstrap/builder.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ pub trait Step<'a>: Serialize + Sized {
5656
/// somewhat harder.
5757
type Output: Serialize + Deserialize<'a> + 'a;
5858

59+
/// This type, but with a 'static bound. Used for caching the step.
60+
type Id: 'static;
61+
5962
const DEFAULT: bool = false;
6063

6164
/// Run this rule for all hosts without cross compiling.
@@ -190,6 +193,7 @@ impl<'a> Builder<'a> {
190193
target: &'a str,
191194
}
192195
impl<'a> Step<'a> for Libdir<'a> {
196+
type Id = Libdir<'static>;
193197
type Output = PathBuf;
194198
fn run(self, builder: &Builder) -> PathBuf {
195199
let compiler = self.compiler;

src/bootstrap/cache.rs

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010

1111
use serde_json;
1212
use serde::{Serialize, Deserialize};
13+
use std::any::TypeId;
14+
use builder::Step;
1315

1416
use std::fmt;
1517
use std::mem;
16-
use std::intrinsics;
1718
use std::collections::HashMap;
1819
use std::cell::RefCell;
1920

@@ -29,31 +30,20 @@ use std::cell::RefCell;
2930
pub struct Cache(RefCell<HashMap<Key, Box<str>>>);
3031

3132
fn to_json<T: Serialize>(element: &T) -> String {
32-
let type_id = unsafe {
33-
intrinsics::type_name::<T>()
34-
};
35-
36-
t!(serde_json::to_string(&(type_id, element)))
33+
t!(serde_json::to_string(element))
3734
}
3835

3936
fn from_json<'a, O: Deserialize<'a>>(data: &'a str) -> O {
40-
let type_id = unsafe {
41-
intrinsics::type_name::<O>()
42-
};
43-
44-
let (de_type_id, element): (&'a str, O) = t!(serde_json::from_str(data));
45-
46-
assert_eq!(type_id, de_type_id);
47-
48-
element
37+
t!(serde_json::from_str(data))
4938
}
5039

5140
#[derive(Clone, PartialEq, Eq, Hash)]
52-
pub struct Key(String);
41+
pub struct Key(TypeId, String);
5342

5443
impl fmt::Debug for Key {
5544
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
56-
fmt.write_str(&self.0)
45+
fmt.write_str(&format!("{:?}; ", self.0))?;
46+
fmt.write_str(&self.1)
5747
}
5848
}
5949

@@ -62,8 +52,8 @@ impl Cache {
6252
Cache(RefCell::new(HashMap::new()))
6353
}
6454

65-
pub fn to_key<K: Serialize>(key: &K) -> Key {
66-
Key(to_json(key))
55+
pub fn to_key<'a, K: Step<'a>>(key: &K) -> Key {
56+
Key(TypeId::of::<K::Id>(), to_json(key))
6757
}
6858

6959
/// Puts a value into the cache. Will panic if called more than once with

src/bootstrap/check.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ pub struct Linkcheck<'a> {
9898
}
9999

100100
impl<'a> Step<'a> for Linkcheck<'a> {
101+
type Id = Linkcheck<'static>;
101102
type Output = ();
102103
const ONLY_HOSTS: bool = true;
103104
const DEFAULT: bool = true;
@@ -147,6 +148,7 @@ pub struct Cargotest<'a> {
147148
}
148149

149150
impl<'a> Step<'a> for Cargotest<'a> {
151+
type Id = Cargotest<'static>;
150152
type Output = ();
151153
const ONLY_HOSTS: bool = true;
152154

@@ -197,6 +199,7 @@ pub struct Cargo<'a> {
197199
}
198200

199201
impl<'a> Step<'a> for Cargo<'a> {
202+
type Id = Cargo<'static>;
200203
type Output = ();
201204
const ONLY_HOSTS: bool = true;
202205

@@ -255,6 +258,7 @@ pub struct Tidy<'a> {
255258
}
256259

257260
impl<'a> Step<'a> for Tidy<'a> {
261+
type Id = Tidy<'static>;
258262
type Output = ();
259263
const DEFAULT: bool = true;
260264
const ONLY_HOSTS: bool = true;
@@ -457,6 +461,7 @@ static COMPILETESTS: &[Test] = &[
457461
];
458462

459463
impl<'a> Step<'a> for Compiletest<'a> {
464+
type Id = Compiletest<'static>;
460465
type Output = ();
461466
const DEFAULT: bool = true;
462467

@@ -723,6 +728,7 @@ pub struct Docs<'a> {
723728
// .host(true)
724729
// .run(move |s| check::docs(build, &s.compiler()));
725730
impl<'a> Step<'a> for Docs<'a> {
731+
type Id = Docs<'static>;
726732
type Output = ();
727733
const DEFAULT: bool = true;
728734
const ONLY_HOSTS: bool = true;
@@ -788,6 +794,7 @@ pub struct ErrorIndex<'a> {
788794
}
789795

790796
impl<'a> Step<'a> for ErrorIndex<'a> {
797+
type Id = ErrorIndex<'static>;
791798
type Output = ();
792799
const DEFAULT: bool = true;
793800
const ONLY_HOSTS: bool = true;
@@ -883,6 +890,7 @@ pub struct KrateLibrustc<'a> {
883890
}
884891

885892
impl<'a> Step<'a> for KrateLibrustc<'a> {
893+
type Id = KrateLibrustc<'static>;
886894
type Output = ();
887895
const DEFAULT: bool = true;
888896
const ONLY_HOSTS: bool = true;
@@ -993,6 +1001,7 @@ pub struct Krate<'a> {
9931001
}
9941002

9951003
impl<'a> Step<'a> for Krate<'a> {
1004+
type Id = Krate<'static>;
9961005
type Output = ();
9971006
const DEFAULT: bool = true;
9981007

@@ -1259,6 +1268,7 @@ pub struct RemoteCopyLibs<'a> {
12591268
}
12601269

12611270
impl<'a> Step<'a> for RemoteCopyLibs<'a> {
1271+
type Id = RemoteCopyLibs<'static>;
12621272
type Output = ();
12631273

12641274
fn run(self, builder: &Builder) {
@@ -1310,6 +1320,7 @@ impl<'a> Step<'a> for RemoteCopyLibs<'a> {
13101320
pub struct Distcheck;
13111321

13121322
impl<'a> Step<'a> for Distcheck {
1323+
type Id = Distcheck;
13131324
type Output = ();
13141325

13151326
/// Run "distcheck", a 'make check' from a tarball
@@ -1377,6 +1388,7 @@ impl<'a> Step<'a> for Distcheck {
13771388
pub struct Bootstrap;
13781389

13791390
impl<'a> Step<'a> for Bootstrap {
1391+
type Id = Bootstrap;
13801392
type Output = ();
13811393
const DEFAULT: bool = true;
13821394
const ONLY_HOSTS: bool = true;

src/bootstrap/compile.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ pub struct Std<'a> {
147147
}
148148

149149
impl<'a> Step<'a> for Std<'a> {
150+
type Id = Std<'static>;
150151
type Output = ();
151152
const DEFAULT: bool = true;
152153

@@ -268,6 +269,7 @@ struct StdLink<'a> {
268269
}
269270

270271
impl<'a> Step<'a> for StdLink<'a> {
272+
type Id = StdLink<'static>;
271273
type Output = ();
272274

273275
/// Link all libstd rlibs/dylibs into the sysroot location.
@@ -337,6 +339,7 @@ pub struct StartupObjects<'a> {
337339
}
338340

339341
impl<'a> Step<'a> for StartupObjects<'a> {
342+
type Id = StartupObjects<'static>;
340343
type Output = ();
341344

342345
fn should_run(_builder: &Builder, path: &Path) -> bool {
@@ -403,6 +406,7 @@ pub struct Test<'a> {
403406
}
404407

405408
impl<'a> Step<'a> for Test<'a> {
409+
type Id = Test<'static>;
406410
type Output = ();
407411
const DEFAULT: bool = true;
408412

@@ -485,6 +489,7 @@ pub struct TestLink<'a> {
485489
}
486490

487491
impl<'a> Step<'a> for TestLink<'a> {
492+
type Id = TestLink<'static>;
488493
type Output = ();
489494

490495
/// Same as `std_link`, only for libtest
@@ -519,6 +524,7 @@ pub struct Rustc<'a> {
519524
}
520525

521526
impl<'a> Step<'a> for Rustc<'a> {
527+
type Id = Rustc<'static>;
522528
type Output = ();
523529
const ONLY_HOSTS: bool = true;
524530
const DEFAULT: bool = true;
@@ -668,6 +674,7 @@ struct RustcLink<'a> {
668674
}
669675

670676
impl<'a> Step<'a> for RustcLink<'a> {
677+
type Id = RustcLink<'static>;
671678
type Output = ();
672679

673680
/// Same as `std_link`, only for librustc
@@ -720,6 +727,7 @@ pub struct Sysroot<'a> {
720727
}
721728

722729
impl<'a> Step<'a> for Sysroot<'a> {
730+
type Id = Sysroot<'static>;
723731
type Output = PathBuf;
724732

725733
/// Returns the sysroot for the `compiler` specified that *this build system
@@ -766,6 +774,7 @@ pub struct Assemble<'a> {
766774
}
767775

768776
impl<'a> Step<'a> for Assemble<'a> {
777+
type Id = Assemble<'static>;
769778
type Output = Compiler<'a>;
770779

771780
/// Prepare a new compiler from the artifacts in `stage`

src/bootstrap/dist.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ pub struct Docs<'a> {
7878
}
7979

8080
impl<'a> Step<'a> for Docs<'a> {
81+
type Id = Docs<'static>;
8182
type Output = Option<PathBuf>;
8283
const DEFAULT: bool = true;
8384
const ONLY_BUILD_TARGETS: bool = true;
@@ -287,6 +288,7 @@ pub struct Mingw<'a> {
287288
}
288289

289290
impl<'a> Step<'a> for Mingw<'a> {
291+
type Id = Mingw<'static>;
290292
type Output = Option<PathBuf>;
291293
const DEFAULT: bool = true;
292294
const ONLY_BUILD_TARGETS: bool = true;
@@ -355,6 +357,7 @@ pub struct Rustc<'a> {
355357
}
356358

357359
impl<'a> Step<'a> for Rustc<'a> {
360+
type Id = Rustc<'static>;
358361
type Output = PathBuf;
359362
const DEFAULT: bool = true;
360363
const ONLY_HOSTS: bool = true;
@@ -495,6 +498,7 @@ pub struct DebuggerScripts<'a> {
495498
}
496499

497500
impl<'a> Step<'a> for DebuggerScripts<'a> {
501+
type Id = DebuggerScripts<'static>;
498502
type Output = ();
499503

500504
fn should_run(_builder: &Builder, path: &Path) -> bool {
@@ -567,6 +571,7 @@ pub struct Std<'a> {
567571
}
568572

569573
impl<'a> Step<'a> for Std<'a> {
574+
type Id = Std<'static>;
570575
type Output = Option<PathBuf>;
571576
const DEFAULT: bool = true;
572577
const ONLY_BUILD_TARGETS: bool = true;
@@ -647,6 +652,7 @@ pub struct Analysis<'a> {
647652
}
648653

649654
impl<'a> Step<'a> for Analysis<'a> {
655+
type Id = Analysis<'static>;
650656
type Output = Option<PathBuf>;
651657
const DEFAULT: bool = true;
652658
const ONLY_BUILD_TARGETS: bool = true;
@@ -767,6 +773,7 @@ fn copy_src_dirs(build: &Build, src_dirs: &[&str], exclude_dirs: &[&str], dst_di
767773
pub struct Src;
768774

769775
impl<'a> Step<'a> for Src {
776+
type Id = Src;
770777
/// The output path of the src installer tarball
771778
type Output = PathBuf;
772779
const DEFAULT: bool = true;
@@ -864,6 +871,7 @@ const CARGO_VENDOR_VERSION: &str = "0.1.4";
864871
pub struct PlainSourceTarball;
865872

866873
impl<'a> Step<'a> for PlainSourceTarball {
874+
type Id = PlainSourceTarball;
867875
/// Produces the location of the tarball generated
868876
type Output = PathBuf;
869877
const DEFAULT: bool = true;
@@ -1018,6 +1026,7 @@ pub struct Cargo<'a> {
10181026
}
10191027

10201028
impl<'a> Step<'a> for Cargo<'a> {
1029+
type Id = Cargo<'static>;
10211030
type Output = PathBuf;
10221031
const ONLY_BUILD_TARGETS: bool = true;
10231032
const ONLY_HOSTS: bool = true;
@@ -1114,6 +1123,7 @@ pub struct Rls<'a> {
11141123
}
11151124

11161125
impl<'a> Step<'a> for Rls<'a> {
1126+
type Id = Rls<'static>;
11171127
type Output = PathBuf;
11181128
const ONLY_BUILD_TARGETS: bool = true;
11191129
const ONLY_HOSTS: bool = true;
@@ -1207,6 +1217,7 @@ pub struct Extended<'a> {
12071217
}
12081218

12091219
impl<'a> Step<'a> for Extended<'a> {
1220+
type Id = Extended<'static>;
12101221
type Output = ();
12111222
const DEFAULT: bool = true;
12121223
const ONLY_BUILD_TARGETS: bool = true;
@@ -1613,6 +1624,7 @@ fn add_env(build: &Build, cmd: &mut Command, target: &str) {
16131624
pub struct HashSign;
16141625

16151626
impl<'a> Step<'a> for HashSign {
1627+
type Id = HashSign;
16161628
type Output = ();
16171629
const ONLY_BUILD_TARGETS: bool = true;
16181630
const ONLY_HOSTS: bool = true;

0 commit comments

Comments
 (0)