Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit b6abb33

Browse files
committed
handle cfg bootstrap on compiler and compiler tools
Signed-off-by: onur-ozkan <work@onurozkan.dev>
1 parent f223071 commit b6abb33

File tree

9 files changed

+33
-3
lines changed

9 files changed

+33
-3
lines changed

compiler/rustc_lint/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
2222
// tidy-alphabetical-start
2323
#![allow(internal_features)]
24+
#![cfg_attr(bootstrap, feature(extract_if))]
2425
#![cfg_attr(doc, recursion_limit = "256")] // FIXME(nnethercote): will be removed by #124141
2526
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
2627
#![doc(rust_logo)]

compiler/rustc_metadata/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// tidy-alphabetical-start
22
#![allow(internal_features)]
3+
#![cfg_attr(bootstrap, feature(extract_if))]
34
#![cfg_attr(doc, recursion_limit = "256")] // FIXME(nnethercote): will be removed by #124141
45
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
56
#![doc(rust_logo)]

compiler/rustc_middle/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#![allow(rustc::diagnostic_outside_of_impl)]
3030
#![allow(rustc::potential_query_instability)]
3131
#![allow(rustc::untranslatable_diagnostic)]
32+
#![cfg_attr(bootstrap, feature(extract_if))]
3233
#![cfg_attr(doc, recursion_limit = "256")] // FIXME(nnethercote): will be removed by #124141
3334
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
3435
#![doc(rust_logo)]

compiler/rustc_resolve/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#![allow(rustc::diagnostic_outside_of_impl)]
1212
#![allow(rustc::potential_query_instability)]
1313
#![allow(rustc::untranslatable_diagnostic)]
14+
#![cfg_attr(bootstrap, feature(extract_if))]
1415
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
1516
#![doc(rust_logo)]
1617
#![feature(assert_matches)]

compiler/rustc_serialize/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// tidy-alphabetical-start
44
#![allow(internal_features)]
55
#![allow(rustc::internal)]
6+
#![cfg_attr(bootstrap, feature(ptr_sub_ptr))]
67
#![cfg_attr(test, feature(test))]
78
#![doc(
89
html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",

compiler/rustc_serialize/src/opaque.rs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,13 +280,27 @@ impl<'a> MemDecoder<'a> {
280280
#[inline]
281281
pub fn len(&self) -> usize {
282282
// SAFETY: This recovers the length of the original slice, only using members we never modify.
283-
unsafe { self.end.offset_from_unsigned(self.start) }
283+
#[cfg(bootstrap)]
284+
unsafe {
285+
return self.end.sub_ptr(self.start);
286+
}
287+
#[cfg(not(bootstrap))]
288+
unsafe {
289+
self.end.offset_from_unsigned(self.start)
290+
}
284291
}
285292

286293
#[inline]
287294
pub fn remaining(&self) -> usize {
288295
// SAFETY: This type guarantees current <= end.
289-
unsafe { self.end.offset_from_unsigned(self.current) }
296+
#[cfg(bootstrap)]
297+
unsafe {
298+
return self.end.sub_ptr(self.current);
299+
}
300+
#[cfg(not(bootstrap))]
301+
unsafe {
302+
self.end.offset_from_unsigned(self.current)
303+
}
290304
}
291305

292306
#[cold]
@@ -400,7 +414,14 @@ impl<'a> Decoder for MemDecoder<'a> {
400414
#[inline]
401415
fn position(&self) -> usize {
402416
// SAFETY: This type guarantees start <= current
403-
unsafe { self.current.offset_from_unsigned(self.start) }
417+
#[cfg(bootstrap)]
418+
unsafe {
419+
return self.current.sub_ptr(self.start);
420+
}
421+
#[cfg(not(bootstrap))]
422+
unsafe {
423+
self.current.offset_from_unsigned(self.start)
424+
}
404425
}
405426
}
406427

compiler/rustc_trait_selection/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#![allow(internal_features)]
1515
#![allow(rustc::diagnostic_outside_of_impl)]
1616
#![allow(rustc::untranslatable_diagnostic)]
17+
#![cfg_attr(bootstrap, feature(extract_if))]
1718
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
1819
#![doc(rust_logo)]
1920
#![feature(assert_matches)]

src/librustdoc/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#![allow(clippy::collapsible_if, clippy::collapsible_else_if)]
2323
#![allow(rustc::diagnostic_outside_of_impl)]
2424
#![allow(rustc::untranslatable_diagnostic)]
25+
#![cfg_attr(bootstrap, feature(os_str_display))]
2526

2627
extern crate thin_vec;
2728

src/tools/miri/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg_attr(bootstrap, feature(extract_if))]
2+
#![cfg_attr(bootstrap, feature(unsigned_is_multiple_of))]
13
#![feature(rustc_private)]
24
#![feature(cfg_match)]
35
#![feature(cell_update)]

0 commit comments

Comments
 (0)