Skip to content

Commit

Permalink
Keep object-size-dependent tests failing
Browse files Browse the repository at this point in the history
These tests depend on the internal logic of rustc regarding handling
very large objects. Fix them to reflect rustc_abi::obj_size_bound diffs.
  • Loading branch information
workingjubilee committed Sep 19, 2024
1 parent d6383b4 commit f4cb6ef
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 29 deletions.
2 changes: 1 addition & 1 deletion tests/crashes/125476.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ known-bug: rust-lang/rust#125476
//@ only-x86_64
pub struct Data([u8; usize::MAX >> 16]);
pub struct Data([u8; usize::MAX >> 2]);
const _: &'static [Data] = &[];
30 changes: 6 additions & 24 deletions tests/ui/extern/extern-static-size-overflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,13 @@ struct ReallyBig {
}

// The limit for "too big for the current architecture" is dependent on the target pointer size
// however it's artificially limited on 64 bits
// logic copied from rustc_target::abi::TargetDataLayout::obj_size_bound()
// but is artificially limited due to LLVM's internal architecture
// logic based on rustc_target::abi::TargetDataLayout::obj_size_bound()
const fn max_size() -> usize {
#[cfg(target_pointer_width = "16")]
{
1 << 15
}

#[cfg(target_pointer_width = "32")]
{
1 << 31
}

#[cfg(target_pointer_width = "64")]
{
1 << 47
}

#[cfg(not(any(
target_pointer_width = "16",
target_pointer_width = "32",
target_pointer_width = "64"
)))]
{
isize::MAX as usize
if usize::BITS < 61 {
1 << (usize::BITS - 1)
} else {
1 << 61
}
}

Expand Down
6 changes: 3 additions & 3 deletions tests/ui/extern/extern-static-size-overflow.stderr
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
error: extern static is too large for the current architecture
--> $DIR/extern-static-size-overflow.rs:38:5
--> $DIR/extern-static-size-overflow.rs:20:5
|
LL | static BAZ: [u8; max_size()];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: extern static is too large for the current architecture
--> $DIR/extern-static-size-overflow.rs:39:5
--> $DIR/extern-static-size-overflow.rs:21:5
|
LL | static UWU: [usize; usize::MAX];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: extern static is too large for the current architecture
--> $DIR/extern-static-size-overflow.rs:40:5
--> $DIR/extern-static-size-overflow.rs:22:5
|
LL | static A: ReallyBig;
| ^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/limits/huge-enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
type BIG = Option<[u32; (1<<29)-1]>;

#[cfg(target_pointer_width = "64")]
type BIG = Option<[u32; (1<<45)-1]>;
type BIG = Option<[u32; (1<<59)-1]>;

fn main() {
let big: BIG = None;
Expand Down

0 comments on commit f4cb6ef

Please sign in to comment.