From fbb5b90fe0c541ba1cf866e775e7e27bd9081377 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Thu, 5 Dec 2024 10:30:23 -0500 Subject: [PATCH] test(build-std): make mock-std closer to real world `test_std_on_unsupported_target` never really succeed to build those targets, due to * local rustup may not have `{aarch64,x86_64}-unknown-none` installed. * `core` and `compiler-builtins` mock crate are not `no_std` nor `no_core` * the dummy `main.rs` uses `println!` and is not `no_std`. This commit make it compile, if you have those targets installed. --- .../mock-std/library/compiler_builtins/src/lib.rs | 2 +- tests/testsuite/mock-std/library/core/src/lib.rs | 1 + tests/testsuite/standard_lib.rs | 11 ++++++----- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/testsuite/mock-std/library/compiler_builtins/src/lib.rs b/tests/testsuite/mock-std/library/compiler_builtins/src/lib.rs index 65e2cc34045..0c9ac1ac8e4 100644 --- a/tests/testsuite/mock-std/library/compiler_builtins/src/lib.rs +++ b/tests/testsuite/mock-std/library/compiler_builtins/src/lib.rs @@ -1 +1 @@ -// intentionally blank +#![no_std] diff --git a/tests/testsuite/mock-std/library/core/src/lib.rs b/tests/testsuite/mock-std/library/core/src/lib.rs index b90ed091414..fd317cb1d69 100644 --- a/tests/testsuite/mock-std/library/core/src/lib.rs +++ b/tests/testsuite/mock-std/library/core/src/lib.rs @@ -1,3 +1,4 @@ +#![no_std] #![feature(staged_api)] #![stable(since = "1.0.0", feature = "dummy")] diff --git a/tests/testsuite/standard_lib.rs b/tests/testsuite/standard_lib.rs index afcc79f750b..214df036561 100644 --- a/tests/testsuite/standard_lib.rs +++ b/tests/testsuite/standard_lib.rs @@ -395,12 +395,13 @@ fn test_std_on_unsupported_target() { let p = project() .file( - "src/main.rs", + "src/lib.rs", r#" - fn main() { - println!("hello"); - } - "#, + #![no_std] + pub fn foo() { + assert_eq!(u8::MIN, 0); + } + "#, ) .build();