From 71126227fa265c1b64cdbcbae2fd7352f7bff3f9 Mon Sep 17 00:00:00 2001 From: apiraino Date: Wed, 26 Jul 2023 12:36:24 +0200 Subject: [PATCH] add UI test for issue #35144 --- src/tools/cargo | 2 +- src/tools/tidy/src/ui_tests.rs | 6 +++-- tests/ui/type_id/auxiliary/a.rs | 23 ++++++++++++++++++ tests/ui/type_id/auxiliary/b.rs | 3 +++ .../auxiliary/issue-13507.rs | 7 +++--- .../auxiliary/typeid-intrinsic-aux1.rs | 0 .../auxiliary/typeid-intrinsic-aux2.rs | 0 ...-13507-fixed-hashing-DefId-for-ty_enum.rs} | 3 ++- ...ue-35144-typeid-output-same-ignore-cfgs.rs | 24 +++++++++++++++++++ .../ui/{ => type_id}/type-id-higher-rank-2.rs | 0 tests/ui/{ => type_id}/typeid-intrinsic.rs | 0 11 files changed, 61 insertions(+), 7 deletions(-) create mode 100644 tests/ui/type_id/auxiliary/a.rs create mode 100644 tests/ui/type_id/auxiliary/b.rs rename tests/ui/{issues => type_id}/auxiliary/issue-13507.rs (92%) rename tests/ui/{ => type_id}/auxiliary/typeid-intrinsic-aux1.rs (100%) rename tests/ui/{ => type_id}/auxiliary/typeid-intrinsic-aux2.rs (100%) rename tests/ui/{issues/issue-13507-2.rs => type_id/issue-13507-fixed-hashing-DefId-for-ty_enum.rs} (91%) create mode 100644 tests/ui/type_id/issue-35144-typeid-output-same-ignore-cfgs.rs rename tests/ui/{ => type_id}/type-id-higher-rank-2.rs (100%) rename tests/ui/{ => type_id}/typeid-intrinsic.rs (100%) diff --git a/src/tools/cargo b/src/tools/cargo index c91a693e7977e..7ac9416d82cd4 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit c91a693e7977e33a1064b63a5daf5fb689f01651 +Subproject commit 7ac9416d82cd4fc5e707c9ec3574d22dff6466e5 diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index a1822c839865e..252f32ee88fd7 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -10,8 +10,10 @@ use std::path::{Path, PathBuf}; const ENTRY_LIMIT: usize = 900; // FIXME: The following limits should be reduced eventually. -const ISSUES_ENTRY_LIMIT: usize = 1893; -const ROOT_ENTRY_LIMIT: usize = 872; +// Max number of files under "./ui/issues" +const ISSUES_ENTRY_LIMIT: usize = 1892; +// Max number of files under "./ui" +const ROOT_ENTRY_LIMIT: usize = 871; const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[ "rs", // test source files diff --git a/tests/ui/type_id/auxiliary/a.rs b/tests/ui/type_id/auxiliary/a.rs new file mode 100644 index 0000000000000..fc10c26741f59 --- /dev/null +++ b/tests/ui/type_id/auxiliary/a.rs @@ -0,0 +1,23 @@ +pub mod a { + use std::cell::RefCell; + + pub struct Arena { + chunks: RefCell>, + } + + struct ChunkList { + current: Vec, + rest: Vec>, + } + + impl Arena { + pub fn new() -> Arena { + Arena { + chunks: RefCell::new(ChunkList { + current: Vec::with_capacity(12), + rest: Vec::new(), + }), + } + } + } +} diff --git a/tests/ui/type_id/auxiliary/b.rs b/tests/ui/type_id/auxiliary/b.rs new file mode 100644 index 0000000000000..14b7bf32f88f3 --- /dev/null +++ b/tests/ui/type_id/auxiliary/b.rs @@ -0,0 +1,3 @@ +pub mod b { + pub struct Unused {} +} diff --git a/tests/ui/issues/auxiliary/issue-13507.rs b/tests/ui/type_id/auxiliary/issue-13507.rs similarity index 92% rename from tests/ui/issues/auxiliary/issue-13507.rs rename to tests/ui/type_id/auxiliary/issue-13507.rs index c91013043eb77..1e96986b27a56 100644 --- a/tests/ui/issues/auxiliary/issue-13507.rs +++ b/tests/ui/type_id/auxiliary/issue-13507.rs @@ -1,3 +1,4 @@ +// #13507: Fixed hashing of DefId for ty_enum pub mod testtypes { use std::any::TypeId; @@ -18,7 +19,7 @@ pub mod testtypes { TypeId::of::(), TypeId::of::(), TypeId::of::(), - TypeId::of::() + TypeId::of::(), ] } @@ -66,13 +67,13 @@ pub mod testtypes { // Tests struct pub struct FooStruct { pub pub_foo_field: usize, - foo_field: usize + foo_field: usize, } // Tests enum pub enum FooEnum { VarA(usize), - VarB(usize, usize) + VarB(usize, usize), } // Tests Tuple diff --git a/tests/ui/auxiliary/typeid-intrinsic-aux1.rs b/tests/ui/type_id/auxiliary/typeid-intrinsic-aux1.rs similarity index 100% rename from tests/ui/auxiliary/typeid-intrinsic-aux1.rs rename to tests/ui/type_id/auxiliary/typeid-intrinsic-aux1.rs diff --git a/tests/ui/auxiliary/typeid-intrinsic-aux2.rs b/tests/ui/type_id/auxiliary/typeid-intrinsic-aux2.rs similarity index 100% rename from tests/ui/auxiliary/typeid-intrinsic-aux2.rs rename to tests/ui/type_id/auxiliary/typeid-intrinsic-aux2.rs diff --git a/tests/ui/issues/issue-13507-2.rs b/tests/ui/type_id/issue-13507-fixed-hashing-DefId-for-ty_enum.rs similarity index 91% rename from tests/ui/issues/issue-13507-2.rs rename to tests/ui/type_id/issue-13507-fixed-hashing-DefId-for-ty_enum.rs index 63f3589c6cc63..55a3644d4b118 100644 --- a/tests/ui/issues/issue-13507-2.rs +++ b/tests/ui/type_id/issue-13507-fixed-hashing-DefId-for-ty_enum.rs @@ -1,3 +1,4 @@ +// #13507: Fixed hashing of DefId for ty_enum // run-pass #![allow(unused_imports)] // aux-build:issue-13507.rs @@ -25,7 +26,7 @@ pub fn type_ids() -> Vec { TypeId::of::(), TypeId::of::(), TypeId::of::(), - TypeId::of::() + TypeId::of::(), ] } diff --git a/tests/ui/type_id/issue-35144-typeid-output-same-ignore-cfgs.rs b/tests/ui/type_id/issue-35144-typeid-output-same-ignore-cfgs.rs new file mode 100644 index 0000000000000..b8241249ec778 --- /dev/null +++ b/tests/ui/type_id/issue-35144-typeid-output-same-ignore-cfgs.rs @@ -0,0 +1,24 @@ +// #35144: output should be the same with or without enabling the feature +// +// edition:2021 +// aux-build:a.rs +// aux-build:b.rs +// run-pass +// compile-flags: --extern a --extern b --cfg feature="afirst" -A unused_imports -A dead_code +#![feature(core_intrinsics, rustc_private)] + +#[cfg(afirst)] +use a; +use b; +#[cfg(not(afirst))] +use a; + +use std::intrinsics::type_id; + +fn main() { + println!( + "{:?} {:?}", + type_id::>(), + type_id::>>() + ); +} diff --git a/tests/ui/type-id-higher-rank-2.rs b/tests/ui/type_id/type-id-higher-rank-2.rs similarity index 100% rename from tests/ui/type-id-higher-rank-2.rs rename to tests/ui/type_id/type-id-higher-rank-2.rs diff --git a/tests/ui/typeid-intrinsic.rs b/tests/ui/type_id/typeid-intrinsic.rs similarity index 100% rename from tests/ui/typeid-intrinsic.rs rename to tests/ui/type_id/typeid-intrinsic.rs