Skip to content

Commit d1389b9

Browse files
committed
Auto merge of #113484 - matthiaskrgr:rollup-goq2u0d, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #112931 (Enable zlib in LLVM on aarch64-apple-darwin) - #113158 (tests: unset `RUSTC_LOG_COLOR` in a test) - #113173 (CI: include workflow name in concurrency group) - #113335 (Reveal opaques in new solver) - #113390 (CGU formation tweaks) - #113399 (Structurally normalize again for byte string lit pat checking) - #113412 (Add basic types to SMIR) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 4353b1e + 39f558f commit d1389b9

File tree

22 files changed

+181
-89
lines changed

22 files changed

+181
-89
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ defaults:
3131
run:
3232
shell: bash
3333
concurrency:
34-
group: "${{ ((github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.sha) || github.ref }}"
34+
group: "${{ github.workflow }}-${{ ((github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.sha) || github.ref }}"
3535
cancel-in-progress: true
3636
jobs:
3737
pr:

compiler/rustc_hir_typeck/src/pat.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
394394
let mut pat_ty = ty;
395395
if let hir::ExprKind::Lit(Spanned { node: ast::LitKind::ByteStr(..), .. }) = lt.kind {
396396
let expected = self.structurally_resolve_type(span, expected);
397-
if let ty::Ref(_, inner_ty, _) = expected.kind()
398-
&& matches!(inner_ty.kind(), ty::Slice(_))
397+
if let ty::Ref(_, inner_ty, _) = *expected.kind()
398+
&& self.try_structurally_resolve_type(span, inner_ty).is_slice()
399399
{
400400
let tcx = self.tcx;
401401
trace!(?lt.hir_id.local_id, "polymorphic byte string lit");

compiler/rustc_monomorphize/src/collector.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ impl<'tcx> UsageMap<'tcx> {
231231
assert!(self.used_map.insert(user_item, used_items).is_none());
232232
}
233233

234-
pub fn get_user_items(&self, item: MonoItem<'tcx>) -> Option<&[MonoItem<'tcx>]> {
235-
self.user_map.get(&item).map(|items| items.as_slice())
234+
pub fn get_user_items(&self, item: MonoItem<'tcx>) -> &[MonoItem<'tcx>] {
235+
self.user_map.get(&item).map(|items| items.as_slice()).unwrap_or(&[])
236236
}
237237

238238
/// Internally iterate over all inlined items used by `item`.

compiler/rustc_monomorphize/src/partitioning.rs

+22-22
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,9 @@ fn merge_codegen_units<'tcx>(
427427
// zero-padded suffixes, which means they are automatically sorted by
428428
// names. The numeric suffix width depends on the number of CGUs, which
429429
// is always greater than zero:
430-
// - [1,9] CGUS: `0`, `1`, `2`, ...
431-
// - [10,99] CGUS: `00`, `01`, `02`, ...
432-
// - [100,999] CGUS: `000`, `001`, `002`, ...
430+
// - [1,9] CGUs: `0`, `1`, `2`, ...
431+
// - [10,99] CGUs: `00`, `01`, `02`, ...
432+
// - [100,999] CGUs: `000`, `001`, `002`, ...
433433
// - etc.
434434
//
435435
// If we didn't zero-pad the sorted-by-name order would be `XYZ-cgu.0`,
@@ -458,29 +458,29 @@ fn internalize_symbols<'tcx>(
458458
/// used to keep track of that.
459459
#[derive(Clone, PartialEq, Eq, Debug)]
460460
enum MonoItemPlacement {
461-
SingleCgu { cgu_name: Symbol },
461+
SingleCgu(Symbol),
462462
MultipleCgus,
463463
}
464464

465465
let mut mono_item_placements = FxHashMap::default();
466466
let single_codegen_unit = codegen_units.len() == 1;
467467

468468
if !single_codegen_unit {
469-
for cgu in codegen_units.iter_mut() {
469+
for cgu in codegen_units.iter() {
470470
for item in cgu.items().keys() {
471471
// If there is more than one codegen unit, we need to keep track
472472
// in which codegen units each monomorphization is placed.
473473
match mono_item_placements.entry(*item) {
474474
Entry::Occupied(e) => {
475475
let placement = e.into_mut();
476476
debug_assert!(match *placement {
477-
MonoItemPlacement::SingleCgu { cgu_name } => cgu_name != cgu.name(),
477+
MonoItemPlacement::SingleCgu(cgu_name) => cgu_name != cgu.name(),
478478
MonoItemPlacement::MultipleCgus => true,
479479
});
480480
*placement = MonoItemPlacement::MultipleCgus;
481481
}
482482
Entry::Vacant(e) => {
483-
e.insert(MonoItemPlacement::SingleCgu { cgu_name: cgu.name() });
483+
e.insert(MonoItemPlacement::SingleCgu(cgu.name()));
484484
}
485485
}
486486
}
@@ -490,7 +490,7 @@ fn internalize_symbols<'tcx>(
490490
// For each internalization candidates in each codegen unit, check if it is
491491
// used from outside its defining codegen unit.
492492
for cgu in codegen_units {
493-
let home_cgu = MonoItemPlacement::SingleCgu { cgu_name: cgu.name() };
493+
let home_cgu = MonoItemPlacement::SingleCgu(cgu.name());
494494

495495
for (item, linkage_and_visibility) in cgu.items_mut() {
496496
if !internalization_candidates.contains(item) {
@@ -501,20 +501,20 @@ fn internalize_symbols<'tcx>(
501501
if !single_codegen_unit {
502502
debug_assert_eq!(mono_item_placements[item], home_cgu);
503503

504-
if let Some(user_items) = cx.usage_map.get_user_items(*item) {
505-
if user_items
506-
.iter()
507-
.filter_map(|user_item| {
508-
// Some user mono items might not have been
509-
// instantiated. We can safely ignore those.
510-
mono_item_placements.get(user_item)
511-
})
512-
.any(|placement| *placement != home_cgu)
513-
{
514-
// Found a user from another CGU, so skip to the next item
515-
// without marking this one as internal.
516-
continue;
517-
}
504+
if cx
505+
.usage_map
506+
.get_user_items(*item)
507+
.iter()
508+
.filter_map(|user_item| {
509+
// Some user mono items might not have been
510+
// instantiated. We can safely ignore those.
511+
mono_item_placements.get(user_item)
512+
})
513+
.any(|placement| *placement != home_cgu)
514+
{
515+
// Found a user from another CGU, so skip to the next item
516+
// without marking this one as internal.
517+
continue;
518518
}
519519
}
520520

compiler/rustc_smir/src/rustc_smir/mod.rs

+27-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
//!
88
//! For now, we are developing everything inside `rustc`, thus, we keep this module private.
99
10-
use crate::stable_mir::{self, ty::TyKind, Context};
10+
use crate::stable_mir::ty::{FloatTy, IntTy, RigidTy, TyKind, UintTy};
11+
use crate::stable_mir::{self, Context};
1112
use rustc_middle::mir;
1213
use rustc_middle::ty::{self, Ty, TyCtxt};
1314
use rustc_span::def_id::{CrateNum, DefId, LOCAL_CRATE};
@@ -69,11 +70,28 @@ pub struct Tables<'tcx> {
6970
impl<'tcx> Tables<'tcx> {
7071
fn rustc_ty_to_ty(&mut self, ty: Ty<'tcx>) -> TyKind {
7172
match ty.kind() {
72-
ty::Bool => TyKind::Bool,
73-
ty::Char => todo!(),
74-
ty::Int(_) => todo!(),
75-
ty::Uint(_) => todo!(),
76-
ty::Float(_) => todo!(),
73+
ty::Bool => TyKind::RigidTy(RigidTy::Bool),
74+
ty::Char => TyKind::RigidTy(RigidTy::Char),
75+
ty::Int(int_ty) => match int_ty {
76+
ty::IntTy::Isize => TyKind::RigidTy(RigidTy::Int(IntTy::Isize)),
77+
ty::IntTy::I8 => TyKind::RigidTy(RigidTy::Int(IntTy::I8)),
78+
ty::IntTy::I16 => TyKind::RigidTy(RigidTy::Int(IntTy::I16)),
79+
ty::IntTy::I32 => TyKind::RigidTy(RigidTy::Int(IntTy::I32)),
80+
ty::IntTy::I64 => TyKind::RigidTy(RigidTy::Int(IntTy::I64)),
81+
ty::IntTy::I128 => TyKind::RigidTy(RigidTy::Int(IntTy::I128)),
82+
},
83+
ty::Uint(uint_ty) => match uint_ty {
84+
ty::UintTy::Usize => TyKind::RigidTy(RigidTy::Uint(UintTy::Usize)),
85+
ty::UintTy::U8 => TyKind::RigidTy(RigidTy::Uint(UintTy::U8)),
86+
ty::UintTy::U16 => TyKind::RigidTy(RigidTy::Uint(UintTy::U16)),
87+
ty::UintTy::U32 => TyKind::RigidTy(RigidTy::Uint(UintTy::U32)),
88+
ty::UintTy::U64 => TyKind::RigidTy(RigidTy::Uint(UintTy::U64)),
89+
ty::UintTy::U128 => TyKind::RigidTy(RigidTy::Uint(UintTy::U128)),
90+
},
91+
ty::Float(float_ty) => match float_ty {
92+
ty::FloatTy::F32 => TyKind::RigidTy(RigidTy::Float(FloatTy::F32)),
93+
ty::FloatTy::F64 => TyKind::RigidTy(RigidTy::Float(FloatTy::F64)),
94+
},
7795
ty::Adt(_, _) => todo!(),
7896
ty::Foreign(_) => todo!(),
7997
ty::Str => todo!(),
@@ -90,9 +108,9 @@ impl<'tcx> Tables<'tcx> {
90108
ty::GeneratorWitness(_) => todo!(),
91109
ty::GeneratorWitnessMIR(_, _) => todo!(),
92110
ty::Never => todo!(),
93-
ty::Tuple(fields) => {
94-
TyKind::Tuple(fields.iter().map(|ty| self.intern_ty(ty)).collect())
95-
}
111+
ty::Tuple(fields) => TyKind::RigidTy(RigidTy::Tuple(
112+
fields.iter().map(|ty| self.intern_ty(ty)).collect(),
113+
)),
96114
ty::Alias(_, _) => todo!(),
97115
ty::Param(_) => todo!(),
98116
ty::Bound(_, _) => todo!(),

compiler/rustc_smir/src/stable_mir/ty.rs

+36
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,43 @@ impl Ty {
99
}
1010
}
1111

12+
#[derive(Clone, Debug)]
1213
pub enum TyKind {
14+
RigidTy(RigidTy),
15+
}
16+
17+
#[derive(Clone, Debug)]
18+
pub enum RigidTy {
1319
Bool,
20+
Char,
21+
Int(IntTy),
22+
Uint(UintTy),
23+
Float(FloatTy),
1424
Tuple(Vec<Ty>),
1525
}
26+
27+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
28+
pub enum IntTy {
29+
Isize,
30+
I8,
31+
I16,
32+
I32,
33+
I64,
34+
I128,
35+
}
36+
37+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
38+
pub enum UintTy {
39+
Usize,
40+
U8,
41+
U16,
42+
U32,
43+
U64,
44+
U128,
45+
}
46+
47+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
48+
pub enum FloatTy {
49+
F32,
50+
F64,
51+
}

compiler/rustc_trait_selection/src/solve/normalize.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,7 @@ impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for NormalizationFolder<'_, 'tcx> {
167167
// We don't normalize opaque types unless we have
168168
// `Reveal::All`, even if we're in the defining scope.
169169
let data = match *ty.kind() {
170-
ty::Alias(kind, alias_ty) if kind != ty::Opaque || reveal == Reveal::UserFacing => {
171-
alias_ty
172-
}
170+
ty::Alias(kind, alias_ty) if kind != ty::Opaque || reveal == Reveal::All => alias_ty,
173171
_ => return ty.try_super_fold_with(self),
174172
};
175173

src/bootstrap/download-ci-llvm-stamp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Change this file to make users of the `download-ci-llvm` configuration download
22
a new version of LLVM from CI, even if the LLVM submodule hasn’t changed.
33

4-
Last change is for: https://github.com/rust-lang/rust/pull/96971
4+
Last change is for: https://github.com/rust-lang/rust/pull/112931

src/bootstrap/llvm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ impl Step for Llvm {
352352
// Disable zstd to avoid a dependency on libzstd.so.
353353
cfg.define("LLVM_ENABLE_ZSTD", "OFF");
354354

355-
if target != "aarch64-apple-darwin" && !target.contains("windows") {
355+
if !target.contains("windows") {
356356
cfg.define("LLVM_ENABLE_ZLIB", "ON");
357357
} else {
358358
cfg.define("LLVM_ENABLE_ZLIB", "OFF");

src/ci/github-actions/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ concurrency:
302302
# For a given workflow, if we push to the same branch, cancel all previous builds on that branch.
303303
# We add an exception for try builds (try branch) and unrolled rollup builds (try-perf), which
304304
# are all triggered on the same branch, but which should be able to run concurrently.
305-
group: ${{ ((github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.sha) || github.ref }}
305+
group: ${{ github.workflow }}-${{ ((github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.sha) || github.ref }}
306306
cancel-in-progress: true
307307

308308
jobs:

tests/ui-fulldeps/stable-mir/crate-info.rs

+36
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
// edition: 2021
88

99
#![feature(rustc_private)]
10+
#![feature(assert_matches)]
1011

1112
extern crate rustc_driver;
1213
extern crate rustc_hir;
@@ -21,6 +22,7 @@ use rustc_interface::{interface, Queries};
2122
use rustc_middle::ty::TyCtxt;
2223
use rustc_session::EarlyErrorHandler;
2324
use rustc_smir::{rustc_internal, stable_mir};
25+
use std::assert_matches::assert_matches;
2426
use std::io::Write;
2527

2628
const CRATE_NAME: &str = "input";
@@ -65,6 +67,36 @@ fn test_stable_mir(tcx: TyCtxt<'_>) {
6567
other => panic!("{other:?}"),
6668
}
6769

70+
let types = get_item(tcx, &items, (DefKind::Fn, "types")).unwrap();
71+
let body = types.body();
72+
assert_eq!(body.locals.len(), 6);
73+
assert_matches!(
74+
body.locals[0].kind(),
75+
stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Bool)
76+
);
77+
assert_matches!(
78+
body.locals[1].kind(),
79+
stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Bool)
80+
);
81+
assert_matches!(
82+
body.locals[2].kind(),
83+
stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Char)
84+
);
85+
assert_matches!(
86+
body.locals[3].kind(),
87+
stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Int(stable_mir::ty::IntTy::I32))
88+
);
89+
assert_matches!(
90+
body.locals[4].kind(),
91+
stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Uint(stable_mir::ty::UintTy::U64))
92+
);
93+
assert_matches!(
94+
body.locals[5].kind(),
95+
stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Float(
96+
stable_mir::ty::FloatTy::F64
97+
))
98+
);
99+
68100
let drop = get_item(tcx, &items, (DefKind::Fn, "drop")).unwrap();
69101
let body = drop.body();
70102
assert_eq!(body.blocks.len(), 2);
@@ -156,6 +188,10 @@ fn generate_input(path: &str) -> std::io::Result<()> {
156188
x_64.wrapping_add(y_64)
157189
}}
158190
191+
pub fn types(b: bool, _: char, _: i32, _: u64, _: f64) -> bool {{
192+
b
193+
}}
194+
159195
pub fn drop(_: String) {{}}
160196
161197
pub fn assert(x: i32) -> i32 {{

tests/ui/async-await/in-trait/async-associated-types2.rs

-30
This file was deleted.

tests/ui/consts/const_in_pattern/issue-73431.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// run-pass
2+
// unset-rustc-env:RUSTC_LOG_COLOR
23

34
// Regression test for https://github.com/rust-lang/rust/issues/73431.
45

tests/ui/dyn-star/param-env-region-infer.current.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0282]: type annotations needed
2-
--> $DIR/param-env-region-infer.rs:16:10
2+
--> $DIR/param-env-region-infer.rs:18:10
33
|
44
LL | t as _
55
| ^ cannot infer type
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
error[E0391]: cycle detected when computing type of `make_dyn_star::{opaque#0}`
2+
--> $DIR/param-env-region-infer.rs:16:60
3+
|
4+
LL | fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
note: ...which requires type-checking `make_dyn_star`...
8+
--> $DIR/param-env-region-infer.rs:16:1
9+
|
10+
LL | fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a {
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
= note: ...which requires computing layout of `make_dyn_star::{opaque#0}`...
13+
= note: ...which requires normalizing `make_dyn_star::{opaque#0}`...
14+
= note: ...which again requires computing type of `make_dyn_star::{opaque#0}`, completing the cycle
15+
note: cycle used when checking item types in top-level module
16+
--> $DIR/param-env-region-infer.rs:10:1
17+
|
18+
LL | / #![feature(dyn_star, pointer_like_trait)]
19+
LL | | #![allow(incomplete_features)]
20+
LL | |
21+
LL | | use std::fmt::Debug;
22+
... |
23+
LL | |
24+
LL | | fn main() {}
25+
| |____________^
26+
27+
error: aborting due to previous error
28+
29+
For more information about this error, try `rustc --explain E0391`.

0 commit comments

Comments
 (0)