Skip to content

Commit 1d68e6d

Browse files
committed
Auto merge of rust-lang#127546 - workingjubilee:5-level-paging-exists, r=saethlin
Correct outdated object size limit The comment here about 48 bit addresses being enough was written in 2016 but was made incorrect in 2019 by 5-level paging, and then persisted for another 5 years before being noticed and corrected. The bolding of the "exclusive" part is merely to call attention to something I missed when reading it and doublechecking the math. try-job: i686-msvc try-job: test-various
2 parents 2836482 + cf78f26 commit 1d68e6d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+103
-120
lines changed

compiler/rustc_abi/src/lib.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -337,23 +337,21 @@ impl TargetDataLayout {
337337
Ok(dl)
338338
}
339339

340-
/// Returns exclusive upper bound on object size.
340+
/// Returns **exclusive** upper bound on object size in bytes.
341341
///
342342
/// The theoretical maximum object size is defined as the maximum positive `isize` value.
343343
/// This ensures that the `offset` semantics remain well-defined by allowing it to correctly
344344
/// index every address within an object along with one byte past the end, along with allowing
345345
/// `isize` to store the difference between any two pointers into an object.
346346
///
347-
/// The upper bound on 64-bit currently needs to be lower because LLVM uses a 64-bit integer
348-
/// to represent object size in bits. It would need to be 1 << 61 to account for this, but is
349-
/// currently conservatively bounded to 1 << 47 as that is enough to cover the current usable
350-
/// address space on 64-bit ARMv8 and x86_64.
347+
/// LLVM uses a 64-bit integer to represent object size in *bits*, but we care only for bytes,
348+
/// so we adopt such a more-constrained size bound due to its technical limitations.
351349
#[inline]
352350
pub fn obj_size_bound(&self) -> u64 {
353351
match self.pointer_size.bits() {
354352
16 => 1 << 15,
355353
32 => 1 << 31,
356-
64 => 1 << 47,
354+
64 => 1 << 61,
357355
bits => panic!("obj_size_bound: unknown pointer bit size {bits}"),
358356
}
359357
}

compiler/rustc_hir_analysis/messages.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ hir_analysis_tait_forward_compat2 = item does not constrain `{$opaque_type}`, bu
478478
479479
hir_analysis_target_feature_on_main = `main` function is not allowed to have `#[target_feature]`
480480
481-
hir_analysis_too_large_static = extern static is too large for the current architecture
481+
hir_analysis_too_large_static = extern static is too large for the target architecture
482482
483483
hir_analysis_track_caller_on_main = `main` function is not allowed to be `#[track_caller]`
484484
.suggestion = remove this annotation

compiler/rustc_hir_typeck/src/intrinsicck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
9595
format!("{v} bits")
9696
} else {
9797
// `u128` should definitely be able to hold the size of different architectures
98-
// larger sizes should be reported as error `are too big for the current architecture`
98+
// larger sizes should be reported as error `are too big for the target architecture`
9999
// otherwise we have a bug somewhere
100100
bug!("{:?} overflow for u128", size)
101101
}

compiler/rustc_middle/messages.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,5 @@ middle_unknown_layout =
103103
the type `{$ty}` has an unknown layout
104104
105105
middle_values_too_big =
106-
values of the type `{$ty}` are too big for the current architecture
106+
values of the type `{$ty}` are too big for the target architecture
107107
middle_written_to_path = the full type name has been written to '{$path}'

compiler/rustc_middle/src/ty/layout.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ impl<'tcx> fmt::Display for LayoutError<'tcx> {
264264
match *self {
265265
LayoutError::Unknown(ty) => write!(f, "the type `{ty}` has an unknown layout"),
266266
LayoutError::SizeOverflow(ty) => {
267-
write!(f, "values of the type `{ty}` are too big for the current architecture")
267+
write!(f, "values of the type `{ty}` are too big for the target architecture")
268268
}
269269
LayoutError::NormalizationFailure(t, e) => write!(
270270
f,

compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2269,12 +2269,12 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
22692269
}
22702270
rustc_transmute::Reason::SrcSizeOverflow => {
22712271
format!(
2272-
"values of the type `{src}` are too big for the current architecture"
2272+
"values of the type `{src}` are too big for the target architecture"
22732273
)
22742274
}
22752275
rustc_transmute::Reason::DstSizeOverflow => {
22762276
format!(
2277-
"values of the type `{dst}` are too big for the current architecture"
2277+
"values of the type `{dst}` are too big for the target architecture"
22782278
)
22792279
}
22802280
rustc_transmute::Reason::DstHasStricterAlignment {

src/tools/miri/tests/fail/type-too-large.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error: post-monomorphization error: values of the type `[u8; 2305843011361177600]` are too big for the current architecture
1+
error: post-monomorphization error: values of the type `[u8; 2305843011361177600]` are too big for the target architecture
22
--> tests/fail/type-too-large.rs:LL:CC
33
|
44
LL | _fat = [0; (1u64 << 61) as usize + (1u64 << 31) as usize];
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ values of the type `[u8; 2305843011361177600]` are too big for the current architecture
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ values of the type `[u8; 2305843011361177600]` are too big for the target architecture
66
|
77
= note: BACKTRACE:
88
= note: inside `main` at tests/fail/type-too-large.rs:LL:CC

src/tools/tidy/src/issues.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,6 @@ ui/const-generics/infer/issue-77092.rs
552552
ui/const-generics/issue-102124.rs
553553
ui/const-generics/issue-105689.rs
554554
ui/const-generics/issue-106419-struct-with-multiple-const-params.rs
555-
ui/const-generics/issue-112505-overflow.rs
556555
ui/const-generics/issue-46511.rs
557556
ui/const-generics/issue-66451.rs
558557
ui/const-generics/issue-70408.rs
@@ -2717,7 +2716,6 @@ ui/limits/issue-15919-32.rs
27172716
ui/limits/issue-15919-64.rs
27182717
ui/limits/issue-17913.rs
27192718
ui/limits/issue-55878.rs
2720-
ui/limits/issue-56762.rs
27212719
ui/limits/issue-69485-var-size-diffs-too-large.rs
27222720
ui/limits/issue-75158-64.rs
27232721
ui/linkage-attr/auxiliary/issue-12133-dylib.rs

tests/crashes/125476.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
//@ known-bug: rust-lang/rust#125476
22
//@ only-x86_64
3-
pub struct Data([u8; usize::MAX >> 16]);
3+
pub struct Data([u8; usize::MAX >> 2]);
44
const _: &'static [Data] = &[];

tests/ui/const-generics/issue-112505-overflow.rs

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)