Skip to content

Commit 1481fd9

Browse files
committed
Auto merge of rust-lang#103471 - JohnTitor:rollup-tfmy6ab, r=JohnTitor
Rollup of 7 pull requests Successful merges: - rust-lang#99578 (Remove redundant lifetime bound from `impl Borrow for Cow`) - rust-lang#99939 (Sort tests at compile time, not at startup) - rust-lang#102271 (Stabilize `duration_checked_float`) - rust-lang#102766 (Don't link to `libresolv` in libstd on Darwin) - rust-lang#103277 (Update libstd's libc to 0.2.135 (to make `libstd` no longer pull in `libiconv.dylib` on Darwin)) - rust-lang#103437 (Sync rustc_codegen_cranelift) - rust-lang#103466 (Fix grammar in docs for std::io::Read) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 4b5fcae + a710f56 commit 1481fd9

Some content is hidden

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

66 files changed

+1199
-731
lines changed

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -1935,9 +1935,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
19351935

19361936
[[package]]
19371937
name = "libc"
1938-
version = "0.2.131"
1938+
version = "0.2.135"
19391939
source = "registry+https://github.com/rust-lang/crates.io-index"
1940-
checksum = "04c3b4822ccebfa39c02fc03d1534441b22ead323fa0f48bb7ddd8e6ba076a40"
1940+
checksum = "68783febc7782c6c5cb401fbda4de5a9898be1762314da0bb2c10ced61f18b0c"
19411941
dependencies = [
19421942
"rustc-std-workspace-core",
19431943
]

compiler/rustc_builtin_macros/src/test.rs

+25-12
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,22 @@ pub fn expand_test_case(
3636
let sp = ecx.with_def_site_ctxt(attr_sp);
3737
let mut item = anno_item.expect_item();
3838
item = item.map(|mut item| {
39+
let test_path_symbol = Symbol::intern(&item_path(
40+
// skip the name of the root module
41+
&ecx.current_expansion.module.mod_path[1..],
42+
&item.ident,
43+
));
3944
item.vis = ast::Visibility {
4045
span: item.vis.span,
4146
kind: ast::VisibilityKind::Public,
4247
tokens: None,
4348
};
4449
item.ident.span = item.ident.span.with_ctxt(sp.ctxt());
45-
item.attrs.push(ecx.attribute(ecx.meta_word(sp, sym::rustc_test_marker)));
50+
item.attrs.push(ecx.attribute(attr::mk_name_value_item_str(
51+
Ident::new(sym::rustc_test_marker, sp),
52+
test_path_symbol,
53+
sp,
54+
)));
4655
item
4756
});
4857

@@ -215,6 +224,12 @@ pub fn expand_test_or_bench(
215224
)
216225
};
217226

227+
let test_path_symbol = Symbol::intern(&item_path(
228+
// skip the name of the root module
229+
&cx.current_expansion.module.mod_path[1..],
230+
&item.ident,
231+
));
232+
218233
let mut test_const = cx.item(
219234
sp,
220235
Ident::new(item.ident.name, sp),
@@ -224,9 +239,14 @@ pub fn expand_test_or_bench(
224239
Ident::new(sym::cfg, attr_sp),
225240
vec![attr::mk_nested_word_item(Ident::new(sym::test, attr_sp))],
226241
)),
227-
// #[rustc_test_marker]
228-
cx.attribute(cx.meta_word(attr_sp, sym::rustc_test_marker)),
229-
],
242+
// #[rustc_test_marker = "test_case_sort_key"]
243+
cx.attribute(attr::mk_name_value_item_str(
244+
Ident::new(sym::rustc_test_marker, attr_sp),
245+
test_path_symbol,
246+
attr_sp,
247+
)),
248+
]
249+
.into(),
230250
// const $ident: test::TestDescAndFn =
231251
ast::ItemKind::Const(
232252
ast::Defaultness::Final,
@@ -250,14 +270,7 @@ pub fn expand_test_or_bench(
250270
cx.expr_call(
251271
sp,
252272
cx.expr_path(test_path("StaticTestName")),
253-
vec![cx.expr_str(
254-
sp,
255-
Symbol::intern(&item_path(
256-
// skip the name of the root module
257-
&cx.current_expansion.module.mod_path[1..],
258-
&item.ident,
259-
)),
260-
)],
273+
vec![cx.expr_str(sp, test_path_symbol)],
261274
),
262275
),
263276
// ignore: true | false

compiler/rustc_builtin_macros/src/test_harness.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ use thin_vec::thin_vec;
1818

1919
use std::{iter, mem};
2020

21+
#[derive(Clone)]
2122
struct Test {
2223
span: Span,
2324
ident: Ident,
25+
name: Symbol,
2426
}
2527

2628
struct TestCtxt<'a> {
@@ -120,10 +122,10 @@ impl<'a> MutVisitor for TestHarnessGenerator<'a> {
120122

121123
fn flat_map_item(&mut self, i: P<ast::Item>) -> SmallVec<[P<ast::Item>; 1]> {
122124
let mut item = i.into_inner();
123-
if is_test_case(&self.cx.ext_cx.sess, &item) {
125+
if let Some(name) = get_test_name(&self.cx.ext_cx.sess, &item) {
124126
debug!("this is a test item");
125127

126-
let test = Test { span: item.span, ident: item.ident };
128+
let test = Test { span: item.span, ident: item.ident, name };
127129
self.tests.push(test);
128130
}
129131

@@ -357,9 +359,12 @@ fn mk_tests_slice(cx: &TestCtxt<'_>, sp: Span) -> P<ast::Expr> {
357359
debug!("building test vector from {} tests", cx.test_cases.len());
358360
let ecx = &cx.ext_cx;
359361

362+
let mut tests = cx.test_cases.clone();
363+
tests.sort_by(|a, b| a.name.as_str().cmp(&b.name.as_str()));
364+
360365
ecx.expr_array_ref(
361366
sp,
362-
cx.test_cases
367+
tests
363368
.iter()
364369
.map(|test| {
365370
ecx.expr_addr_of(test.span, ecx.expr_path(ecx.path(test.span, vec![test.ident])))
@@ -368,8 +373,8 @@ fn mk_tests_slice(cx: &TestCtxt<'_>, sp: Span) -> P<ast::Expr> {
368373
)
369374
}
370375

371-
fn is_test_case(sess: &Session, i: &ast::Item) -> bool {
372-
sess.contains_name(&i.attrs, sym::rustc_test_marker)
376+
fn get_test_name(sess: &Session, i: &ast::Item) -> Option<Symbol> {
377+
sess.first_attr_value_str_by_name(&i.attrs, sym::rustc_test_marker)
373378
}
374379

375380
fn get_test_runner(

compiler/rustc_codegen_cranelift/.github/workflows/main.yml

+68-31
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ jobs:
2929
matrix:
3030
include:
3131
- os: ubuntu-latest
32+
env:
33+
TARGET_TRIPLE: x86_64-unknown-linux-gnu
3234
- os: macos-latest
35+
env:
36+
TARGET_TRIPLE: x86_64-apple-darwin
3337
# cross-compile from Linux to Windows using mingw
3438
- os: ubuntu-latest
3539
env:
@@ -112,7 +116,7 @@ jobs:
112116
if: matrix.env.TARGET_TRIPLE != 'x86_64-pc-windows-gnu'
113117
uses: actions/upload-artifact@v2
114118
with:
115-
name: cg_clif-${{ runner.os }}
119+
name: cg_clif-${{ matrix.env.TARGET_TRIPLE }}
116120
path: cg_clif.tar.xz
117121

118122
- name: Upload prebuilt cg_clif (cross compile)
@@ -122,56 +126,89 @@ jobs:
122126
name: cg_clif-${{ runner.os }}-cross-x86_64-mingw
123127
path: cg_clif.tar.xz
124128

125-
build_windows:
126-
runs-on: windows-latest
129+
windows:
130+
runs-on: ${{ matrix.os }}
127131
timeout-minutes: 60
128132

133+
strategy:
134+
fail-fast: false
135+
matrix:
136+
include:
137+
# Native Windows build with MSVC
138+
- os: windows-latest
139+
env:
140+
TARGET_TRIPLE: x86_64-pc-windows-msvc
141+
# cross-compile from Windows to Windows MinGW
142+
- os: windows-latest
143+
env:
144+
TARGET_TRIPLE: x86_64-pc-windows-gnu
145+
129146
steps:
130147
- uses: actions/checkout@v3
131148

132-
#- name: Cache cargo installed crates
133-
# uses: actions/cache@v2
134-
# with:
135-
# path: ~/.cargo/bin
136-
# key: ${{ runner.os }}-cargo-installed-crates
137-
138-
#- name: Cache cargo registry and index
139-
# uses: actions/cache@v2
140-
# with:
141-
# path: |
142-
# ~/.cargo/registry
143-
# ~/.cargo/git
144-
# key: ${{ runner.os }}-cargo-registry-and-index-${{ hashFiles('**/Cargo.lock') }}
145-
146-
#- name: Cache cargo target dir
147-
# uses: actions/cache@v2
148-
# with:
149-
# path: target
150-
# key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }}
149+
- name: Cache cargo installed crates
150+
uses: actions/cache@v2
151+
with:
152+
path: ~/.cargo/bin
153+
key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-cargo-installed-crates
154+
155+
- name: Cache cargo registry and index
156+
uses: actions/cache@v2
157+
with:
158+
path: |
159+
~/.cargo/registry
160+
~/.cargo/git
161+
key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-cargo-registry-and-index-${{ hashFiles('**/Cargo.lock') }}
162+
163+
- name: Cache cargo target dir
164+
uses: actions/cache@v2
165+
with:
166+
path: target
167+
key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }}
168+
169+
- name: Set MinGW as the default toolchain
170+
if: matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
171+
run: rustup set default-host x86_64-pc-windows-gnu
151172

152173
- name: Prepare dependencies
153174
run: |
154175
git config --global user.email "[email protected]"
155176
git config --global user.name "User"
156177
git config --global core.autocrlf false
157-
rustup set default-host x86_64-pc-windows-gnu
158178
rustc y.rs -o y.exe -g
159179
./y.exe prepare
160180
181+
- name: Build without unstable features
182+
env:
183+
TARGET_TRIPLE: ${{ matrix.env.TARGET_TRIPLE }}
184+
# This is the config rust-lang/rust uses for builds
185+
run: ./y.rs build --no-unstable-features
186+
161187
- name: Build
162-
#name: Test
188+
run: ./y.rs build --sysroot none
189+
190+
- name: Test
163191
run: |
164192
# Enable backtraces for easier debugging
165-
#$Env:RUST_BACKTRACE=1
193+
$Env:RUST_BACKTRACE=1
166194
167195
# Reduce amount of benchmark runs as they are slow
168-
#$Env:COMPILE_RUNS=2
169-
#$Env:RUN_RUNS=2
196+
$Env:COMPILE_RUNS=2
197+
$Env:RUN_RUNS=2
170198
171199
# Enable extra checks
172-
#$Env:CG_CLIF_ENABLE_VERIFIER=1
173-
174-
./y.exe build
200+
$Env:CG_CLIF_ENABLE_VERIFIER=1
201+
202+
# WIP Disable some tests
203+
204+
# This fails due to some weird argument handling by hyperfine, not an actual regression
205+
# more of a build system issue
206+
(Get-Content config.txt) -replace '(bench.simple-raytracer)', '# $1' | Out-File config.txt
207+
208+
# This fails with a different output than expected
209+
(Get-Content config.txt) -replace '(test.regex-shootout-regex-dna)', '# $1' | Out-File config.txt
210+
211+
./y.exe test
175212
176213
- name: Package prebuilt cg_clif
177214
# don't use compression as xzip isn't supported by tar on windows and bzip2 hangs
@@ -180,5 +217,5 @@ jobs:
180217
- name: Upload prebuilt cg_clif
181218
uses: actions/upload-artifact@v2
182219
with:
183-
name: cg_clif-${{ runner.os }}
220+
name: cg_clif-${{ matrix.env.TARGET_TRIPLE }}
184221
path: cg_clif.tar

compiler/rustc_codegen_cranelift/.gitignore

+1-5
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,4 @@ perf.data.old
1515
/build_sysroot/compiler-builtins
1616
/build_sysroot/rustc_version
1717
/rust
18-
/rand
19-
/regex
20-
/simple-raytracer
21-
/portable-simd
22-
/abi-checker
18+
/download

compiler/rustc_codegen_cranelift/.vscode/settings.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"rust-analyzer.cargo.features": ["unstable-features"],
88
"rust-analyzer.linkedProjects": [
99
"./Cargo.toml",
10-
//"./build_sysroot/sysroot_src/src/libstd/Cargo.toml",
10+
//"./build_sysroot/sysroot_src/library/std/Cargo.toml",
1111
{
1212
"roots": [
1313
"./example/mini_core.rs",
@@ -36,10 +36,10 @@
3636
]
3737
},
3838
{
39-
"roots": ["./scripts/filter_profile.rs"],
39+
"roots": ["./example/std_example.rs"],
4040
"crates": [
4141
{
42-
"root_module": "./scripts/filter_profile.rs",
42+
"root_module": "./example/std_example.rs",
4343
"edition": "2018",
4444
"deps": [{ "crate": 1, "name": "std" }],
4545
"cfg": [],

0 commit comments

Comments
 (0)