diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:03 +0000 |
commit | 64d98f8ee037282c35007b64c2649055c56af1db (patch) | |
tree | 5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /tests/ui/debuginfo | |
parent | Adding debian version 1.67.1+dfsg1-1. (diff) | |
download | rustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/debuginfo')
9 files changed, 131 insertions, 0 deletions
diff --git a/tests/ui/debuginfo/debuginfo-box-with-large-allocator.rs b/tests/ui/debuginfo/debuginfo-box-with-large-allocator.rs new file mode 100644 index 000000000..761539227 --- /dev/null +++ b/tests/ui/debuginfo/debuginfo-box-with-large-allocator.rs @@ -0,0 +1,23 @@ +// build-pass +// compile-flags: -Cdebuginfo=2 +// fixes issue #94725 + +#![feature(allocator_api)] + +use std::alloc::{AllocError, Allocator, Layout}; +use std::ptr::NonNull; + +struct ZST; + +unsafe impl Allocator for &ZST { + fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> { + todo!() + } + unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout) { + todo!() + } +} + +fn main() { + let _ = Box::<i32, &ZST>::new_in(43, &ZST); +} diff --git a/tests/ui/debuginfo/debuginfo-emit-llvm-ir-and-split-debuginfo.rs b/tests/ui/debuginfo/debuginfo-emit-llvm-ir-and-split-debuginfo.rs new file mode 100644 index 000000000..ff764015d --- /dev/null +++ b/tests/ui/debuginfo/debuginfo-emit-llvm-ir-and-split-debuginfo.rs @@ -0,0 +1,8 @@ +// build-pass +// only-linux +// +// compile-flags: -g --emit=llvm-ir -Csplit-debuginfo=unpacked +// +// Make sure that we don't explode with an error if we don't actually end up emitting any `dwo`s, +// as would be the case if we don't actually codegen anything. +#![crate_type="rlib"] diff --git a/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-1.rs b/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-1.rs new file mode 100644 index 000000000..78bda2848 --- /dev/null +++ b/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-1.rs @@ -0,0 +1,16 @@ +// Make sure the compiler does not ICE when trying to generate the debuginfo name of a type that +// causes a layout error. See https://github.com/rust-lang/rust/issues/94961. + +// compile-flags:-C debuginfo=2 +// build-fail +// error-pattern: too big for the current architecture +// normalize-stderr-64bit "18446744073709551615" -> "SIZE" +// normalize-stderr-32bit "4294967295" -> "SIZE" + +#![crate_type = "rlib"] + +pub struct Foo<T>([T; usize::MAX]); + +pub fn foo() -> usize { + std::mem::size_of::<Foo<u8>>() +} diff --git a/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-1.stderr b/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-1.stderr new file mode 100644 index 000000000..d5991bcf5 --- /dev/null +++ b/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-1.stderr @@ -0,0 +1,4 @@ +error: values of the type `[u8; usize::MAX]` are too big for the current architecture + +error: aborting due to previous error + diff --git a/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-2.rs b/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-2.rs new file mode 100644 index 000000000..fdc088dc0 --- /dev/null +++ b/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-2.rs @@ -0,0 +1,20 @@ +// Make sure the compiler does not ICE when trying to generate the debuginfo name of a type that +// causes a layout error. +// This version of the test already ICE'd before the commit that introduce the ICE described in +// https://github.com/rust-lang/rust/issues/94961. + +// compile-flags:-C debuginfo=2 +// build-fail +// error-pattern: too big for the current architecture +// normalize-stderr-64bit "18446744073709551615" -> "SIZE" +// normalize-stderr-32bit "4294967295" -> "SIZE" + +#![crate_type = "rlib"] + +pub enum Foo<T> { + Bar([T; usize::MAX]), +} + +pub fn foo() -> usize { + std::mem::size_of::<Foo<u8>>() +} diff --git a/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-2.stderr b/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-2.stderr new file mode 100644 index 000000000..d5991bcf5 --- /dev/null +++ b/tests/ui/debuginfo/debuginfo-type-name-layout-ice-94961-2.stderr @@ -0,0 +1,4 @@ +error: values of the type `[u8; usize::MAX]` are too big for the current architecture + +error: aborting due to previous error + diff --git a/tests/ui/debuginfo/debuginfo_with_uninhabitable_field_and_unsized.rs b/tests/ui/debuginfo/debuginfo_with_uninhabitable_field_and_unsized.rs new file mode 100644 index 000000000..b3f22ecf5 --- /dev/null +++ b/tests/ui/debuginfo/debuginfo_with_uninhabitable_field_and_unsized.rs @@ -0,0 +1,29 @@ +// build-pass +// compile-flags: -Cdebuginfo=2 +// fixes issue #94149 + +#![allow(dead_code)] + +pub fn main() { + let _ = Foo::<dyn FooTrait>::new(); +} + +pub struct Foo<T: FooTrait + ?Sized> { + base: FooBase, + value: T, +} + +impl<T: FooTrait + ?Sized> Foo<T> { + pub fn new() -> Box<Foo<T>> { + todo!() + } +} + +pub trait FooTrait {} + +pub struct FooBase { + cls: Bar, +} + +// Bar *must* be a fieldless enum +pub enum Bar {} diff --git a/tests/ui/debuginfo/issue-105386-debuginfo-ub.rs b/tests/ui/debuginfo/issue-105386-debuginfo-ub.rs new file mode 100644 index 000000000..6c6eb5d4e --- /dev/null +++ b/tests/ui/debuginfo/issue-105386-debuginfo-ub.rs @@ -0,0 +1,20 @@ +// run-pass +// compile-flags: --edition 2021 -Copt-level=3 -Cdebuginfo=2 -Zmir-opt-level=3 + +fn main() { + TranslatorI.visit_pre(); +} + +impl TranslatorI { + fn visit_pre(self) { + Some(()) + .map(|_| self.flags()) + .unwrap_or_else(|| self.flags()); + } +} + +struct TranslatorI; + +impl TranslatorI { + fn flags(&self) {} +} diff --git a/tests/ui/debuginfo/late-bound-projection.rs b/tests/ui/debuginfo/late-bound-projection.rs new file mode 100644 index 000000000..601807845 --- /dev/null +++ b/tests/ui/debuginfo/late-bound-projection.rs @@ -0,0 +1,7 @@ +// build-pass +// compile-flags: -Cdebuginfo=2 --crate-type=rlib +// Fixes issue #94998 + +pub trait Trait {} + +pub fn run(_: &dyn FnOnce(&()) -> Box<dyn Trait + '_>) {} |