Skip to content

Commit 79734f1

Browse files
committed
Auto merge of rust-lang#124629 - matthiaskrgr:rollup-gttvzrg, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#124138 (Ignore LLVM ABI in dlltool tests since those targets don't use dlltool) - rust-lang#124414 (remove extraneous note on `UnableToRunDsymutil` diagnostic) - rust-lang#124579 (Align: add bytes_usize and bits_usize) - rust-lang#124622 (Cleanup: Rid the `rmake` test runners of `extern crate run_make_support;`) - rust-lang#124623 (shallow resolve in orphan check) - rust-lang#124624 (Use `tcx.types.unit` instead of `Ty::new_unit(tcx)`) - rust-lang#124627 (interpret: hide some reexports in rustdoc) r? `@ghost` `@rustbot` modify labels: rollup
2 parents a8773d5 + a248411 commit 79734f1

File tree

65 files changed

+135
-203
lines changed

Some content is hidden

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

65 files changed

+135
-203
lines changed

compiler/rustc_abi/src/lib.rs

+10
Original file line numberDiff line numberDiff line change
@@ -742,11 +742,21 @@ impl Align {
742742
1 << self.pow2
743743
}
744744

745+
#[inline]
746+
pub fn bytes_usize(self) -> usize {
747+
self.bytes().try_into().unwrap()
748+
}
749+
745750
#[inline]
746751
pub fn bits(self) -> u64 {
747752
self.bytes() * 8
748753
}
749754

755+
#[inline]
756+
pub fn bits_usize(self) -> usize {
757+
self.bits().try_into().unwrap()
758+
}
759+
750760
/// Computes the best alignment possible for the given offset
751761
/// (the largest power of two that the offset is a multiple of).
752762
///

compiler/rustc_codegen_gcc/src/intrinsic/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,7 @@ fn get_rust_try_fn<'a, 'gcc, 'tcx>(
12231223
tcx,
12241224
ty::Binder::dummy(tcx.mk_fn_sig(
12251225
iter::once(i8p),
1226-
Ty::new_unit(tcx),
1226+
tcx.types.unit,
12271227
false,
12281228
rustc_hir::Unsafety::Unsafe,
12291229
Abi::Rust,
@@ -1234,7 +1234,7 @@ fn get_rust_try_fn<'a, 'gcc, 'tcx>(
12341234
tcx,
12351235
ty::Binder::dummy(tcx.mk_fn_sig(
12361236
[i8p, i8p].iter().cloned(),
1237-
Ty::new_unit(tcx),
1237+
tcx.types.unit,
12381238
false,
12391239
rustc_hir::Unsafety::Unsafe,
12401240
Abi::Rust,

compiler/rustc_codegen_llvm/src/intrinsic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ fn get_rust_try_fn<'ll, 'tcx>(
984984
tcx,
985985
ty::Binder::dummy(tcx.mk_fn_sig(
986986
[i8p],
987-
Ty::new_unit(tcx),
987+
tcx.types.unit,
988988
false,
989989
hir::Unsafety::Unsafe,
990990
Abi::Rust,
@@ -995,7 +995,7 @@ fn get_rust_try_fn<'ll, 'tcx>(
995995
tcx,
996996
ty::Binder::dummy(tcx.mk_fn_sig(
997997
[i8p, i8p],
998-
Ty::new_unit(tcx),
998+
tcx.types.unit,
999999
false,
10001000
hir::Unsafety::Unsafe,
10011001
Abi::Rust,

compiler/rustc_codegen_ssa/src/errors.rs

-1
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,6 @@ pub struct ProcessingDymutilFailed {
431431

432432
#[derive(Diagnostic)]
433433
#[diag(codegen_ssa_unable_to_run_dsymutil)]
434-
#[note]
435434
pub struct UnableToRunDsymutil {
436435
pub error: Error,
437436
}

compiler/rustc_const_eval/src/interpret/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ mod util;
1818
mod validity;
1919
mod visitor;
2020

21+
#[doc(no_inline)]
2122
pub use rustc_middle::mir::interpret::*; // have all the `interpret` symbols in one place: here
2223

2324
pub use self::eval_context::{format_interp_error, Frame, FrameInfo, InterpCx, StackPopCleanup};

compiler/rustc_hir_analysis/src/check/intrinsic.rs

+22-22
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,11 @@ pub fn check_intrinsic_type(
208208
Ty::new_tup(tcx, &[param(0), tcx.types.bool]),
209209
),
210210
"load" => (1, vec![Ty::new_imm_ptr(tcx, param(0))], param(0)),
211-
"store" => (1, vec![Ty::new_mut_ptr(tcx, param(0)), param(0)], Ty::new_unit(tcx)),
211+
"store" => (1, vec![Ty::new_mut_ptr(tcx, param(0)), param(0)], tcx.types.unit),
212212

213213
"xchg" | "xadd" | "xsub" | "and" | "nand" | "or" | "xor" | "max" | "min" | "umax"
214214
| "umin" => (1, vec![Ty::new_mut_ptr(tcx, param(0)), param(0)], param(0)),
215-
"fence" | "singlethreadfence" => (0, Vec::new(), Ty::new_unit(tcx)),
215+
"fence" | "singlethreadfence" => (0, Vec::new(), tcx.types.unit),
216216
op => {
217217
tcx.dcx().emit_err(UnrecognizedAtomicOperation { span, op });
218218
return;
@@ -224,7 +224,7 @@ pub fn check_intrinsic_type(
224224
let (n_tps, n_cts, inputs, output) = match intrinsic_name {
225225
sym::abort => (0, 0, vec![], tcx.types.never),
226226
sym::unreachable => (0, 0, vec![], tcx.types.never),
227-
sym::breakpoint => (0, 0, vec![], Ty::new_unit(tcx)),
227+
sym::breakpoint => (0, 0, vec![], tcx.types.unit),
228228
sym::size_of | sym::pref_align_of | sym::min_align_of | sym::variant_count => {
229229
(1, 0, vec![], tcx.types.usize)
230230
}
@@ -235,14 +235,14 @@ pub fn check_intrinsic_type(
235235
sym::caller_location => (0, 0, vec![], tcx.caller_location_ty()),
236236
sym::assert_inhabited
237237
| sym::assert_zero_valid
238-
| sym::assert_mem_uninitialized_valid => (1, 0, vec![], Ty::new_unit(tcx)),
239-
sym::forget => (1, 0, vec![param(0)], Ty::new_unit(tcx)),
238+
| sym::assert_mem_uninitialized_valid => (1, 0, vec![], tcx.types.unit),
239+
sym::forget => (1, 0, vec![param(0)], tcx.types.unit),
240240
sym::transmute | sym::transmute_unchecked => (2, 0, vec![param(0)], param(1)),
241241
sym::prefetch_read_data
242242
| sym::prefetch_write_data
243243
| sym::prefetch_read_instruction
244244
| sym::prefetch_write_instruction => {
245-
(1, 0, vec![Ty::new_imm_ptr(tcx, param(0)), tcx.types.i32], Ty::new_unit(tcx))
245+
(1, 0, vec![Ty::new_imm_ptr(tcx, param(0)), tcx.types.i32], tcx.types.unit)
246246
}
247247
sym::needs_drop => (1, 0, vec![], tcx.types.bool),
248248

@@ -270,7 +270,7 @@ pub fn check_intrinsic_type(
270270
Ty::new_mut_ptr(tcx, param(0)),
271271
tcx.types.usize,
272272
],
273-
Ty::new_unit(tcx),
273+
tcx.types.unit,
274274
),
275275
sym::volatile_copy_memory | sym::volatile_copy_nonoverlapping_memory => (
276276
1,
@@ -280,7 +280,7 @@ pub fn check_intrinsic_type(
280280
Ty::new_imm_ptr(tcx, param(0)),
281281
tcx.types.usize,
282282
],
283-
Ty::new_unit(tcx),
283+
tcx.types.unit,
284284
),
285285
sym::compare_bytes => {
286286
let byte_ptr = Ty::new_imm_ptr(tcx, tcx.types.u8);
@@ -290,7 +290,7 @@ pub fn check_intrinsic_type(
290290
1,
291291
0,
292292
vec![Ty::new_mut_ptr(tcx, param(0)), tcx.types.u8, tcx.types.usize],
293-
Ty::new_unit(tcx),
293+
tcx.types.unit,
294294
),
295295

296296
sym::sqrtf16 => (0, 0, vec![tcx.types.f16], tcx.types.f16),
@@ -409,7 +409,7 @@ pub fn check_intrinsic_type(
409409
(1, 0, vec![Ty::new_imm_ptr(tcx, param(0))], param(0))
410410
}
411411
sym::volatile_store | sym::unaligned_volatile_store => {
412-
(1, 0, vec![Ty::new_mut_ptr(tcx, param(0)), param(0)], Ty::new_unit(tcx))
412+
(1, 0, vec![Ty::new_mut_ptr(tcx, param(0)), param(0)], tcx.types.unit)
413413
}
414414

415415
sym::ctpop | sym::ctlz | sym::ctlz_nonzero | sym::cttz | sym::cttz_nonzero => {
@@ -440,7 +440,7 @@ pub fn check_intrinsic_type(
440440
0,
441441
1,
442442
vec![Ty::new_mut_ptr(tcx, tcx.types.u8), tcx.types.usize, tcx.types.usize],
443-
Ty::new_unit(tcx),
443+
tcx.types.unit,
444444
),
445445

446446
sym::ptr_offset_from => (
@@ -477,16 +477,16 @@ pub fn check_intrinsic_type(
477477
| sym::frem_algebraic => (1, 0, vec![param(0), param(0)], param(0)),
478478
sym::float_to_int_unchecked => (2, 0, vec![param(0)], param(1)),
479479

480-
sym::assume => (0, 1, vec![tcx.types.bool], Ty::new_unit(tcx)),
480+
sym::assume => (0, 1, vec![tcx.types.bool], tcx.types.unit),
481481
sym::likely => (0, 1, vec![tcx.types.bool], tcx.types.bool),
482482
sym::unlikely => (0, 1, vec![tcx.types.bool], tcx.types.bool),
483483

484484
sym::read_via_copy => (1, 0, vec![Ty::new_imm_ptr(tcx, param(0))], param(0)),
485485
sym::write_via_move => {
486-
(1, 0, vec![Ty::new_mut_ptr(tcx, param(0)), param(0)], Ty::new_unit(tcx))
486+
(1, 0, vec![Ty::new_mut_ptr(tcx, param(0)), param(0)], tcx.types.unit)
487487
}
488488

489-
sym::typed_swap => (1, 1, vec![Ty::new_mut_ptr(tcx, param(0)); 2], Ty::new_unit(tcx)),
489+
sym::typed_swap => (1, 1, vec![Ty::new_mut_ptr(tcx, param(0)); 2], tcx.types.unit),
490490

491491
sym::discriminant_value => {
492492
let assoc_items = tcx.associated_item_def_ids(
@@ -511,14 +511,14 @@ pub fn check_intrinsic_type(
511511
let mut_u8 = Ty::new_mut_ptr(tcx, tcx.types.u8);
512512
let try_fn_ty = ty::Binder::dummy(tcx.mk_fn_sig(
513513
[mut_u8],
514-
Ty::new_unit(tcx),
514+
tcx.types.unit,
515515
false,
516516
hir::Unsafety::Normal,
517517
Abi::Rust,
518518
));
519519
let catch_fn_ty = ty::Binder::dummy(tcx.mk_fn_sig(
520520
[mut_u8, mut_u8],
521-
Ty::new_unit(tcx),
521+
tcx.types.unit,
522522
false,
523523
hir::Unsafety::Normal,
524524
Abi::Rust,
@@ -532,14 +532,14 @@ pub fn check_intrinsic_type(
532532
}
533533

534534
sym::va_start | sym::va_end => match mk_va_list_ty(hir::Mutability::Mut) {
535-
Some((va_list_ref_ty, _)) => (0, 0, vec![va_list_ref_ty], Ty::new_unit(tcx)),
535+
Some((va_list_ref_ty, _)) => (0, 0, vec![va_list_ref_ty], tcx.types.unit),
536536
None => bug!("`va_list` lang item needed for C-variadic intrinsics"),
537537
},
538538

539539
sym::va_copy => match mk_va_list_ty(hir::Mutability::Not) {
540540
Some((va_list_ref_ty, va_list_ty)) => {
541541
let va_list_ptr_ty = Ty::new_mut_ptr(tcx, va_list_ty);
542-
(0, 0, vec![va_list_ptr_ty, va_list_ref_ty], Ty::new_unit(tcx))
542+
(0, 0, vec![va_list_ptr_ty, va_list_ref_ty], tcx.types.unit)
543543
}
544544
None => bug!("`va_list` lang item needed for C-variadic intrinsics"),
545545
},
@@ -550,7 +550,7 @@ pub fn check_intrinsic_type(
550550
},
551551

552552
sym::nontemporal_store => {
553-
(1, 0, vec![Ty::new_mut_ptr(tcx, param(0)), param(0)], Ty::new_unit(tcx))
553+
(1, 0, vec![Ty::new_mut_ptr(tcx, param(0)), param(0)], tcx.types.unit)
554554
}
555555

556556
sym::raw_eq => {
@@ -570,7 +570,7 @@ pub fn check_intrinsic_type(
570570
sym::const_eval_select => (4, 1, vec![param(0), param(1), param(2)], param(3)),
571571

572572
sym::vtable_size | sym::vtable_align => {
573-
(0, 0, vec![Ty::new_imm_ptr(tcx, Ty::new_unit(tcx))], tcx.types.usize)
573+
(0, 0, vec![Ty::new_imm_ptr(tcx, tcx.types.unit)], tcx.types.usize)
574574
}
575575

576576
// This type check is not particularly useful, but the `where` bounds
@@ -623,8 +623,8 @@ pub fn check_intrinsic_type(
623623
sym::simd_fma => (1, 0, vec![param(0), param(0), param(0)], param(0)),
624624
sym::simd_gather => (3, 0, vec![param(0), param(1), param(2)], param(0)),
625625
sym::simd_masked_load => (3, 0, vec![param(0), param(1), param(2)], param(2)),
626-
sym::simd_masked_store => (3, 0, vec![param(0), param(1), param(2)], Ty::new_unit(tcx)),
627-
sym::simd_scatter => (3, 0, vec![param(0), param(1), param(2)], Ty::new_unit(tcx)),
626+
sym::simd_masked_store => (3, 0, vec![param(0), param(1), param(2)], tcx.types.unit),
627+
sym::simd_scatter => (3, 0, vec![param(0), param(1), param(2)], tcx.types.unit),
628628
sym::simd_insert => (2, 0, vec![param(0), tcx.types.u32, param(1)], param(0)),
629629
sym::simd_extract => (2, 0, vec![param(0), tcx.types.u32], param(1)),
630630
sym::simd_cast

compiler/rustc_hir_analysis/src/coherence/orphan.rs

+1
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ fn orphan_check<'tcx>(
330330
};
331331

332332
let Ok(result) = traits::orphan_check_trait_ref::<!>(
333+
&infcx,
333334
trait_ref,
334335
traits::InCrate::Local { mode },
335336
lazily_normalize_ty,

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2370,7 +2370,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
23702370
self.lower_ty(output)
23712371
}
23722372
}
2373-
hir::FnRetTy::DefaultReturn(..) => Ty::new_unit(tcx),
2373+
hir::FnRetTy::DefaultReturn(..) => tcx.types.unit,
23742374
};
23752375

23762376
debug!(?output_ty);

compiler/rustc_hir_typeck/src/_match.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
6666
// us to give better error messages (pointing to a usually better
6767
// arm for inconsistent arms or to the whole match when a `()` type
6868
// is required).
69-
Expectation::ExpectHasType(ety) if ety != Ty::new_unit(self.tcx) => ety,
69+
Expectation::ExpectHasType(ety) if ety != tcx.types.unit => ety,
7070
_ => self.next_ty_var(TypeVariableOrigin { param_def_id: None, span: expr.span }),
7171
};
7272
CoerceMany::with_coercion_sites(coerce_first, arms)

compiler/rustc_hir_typeck/src/coercion.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
14621462
fcx,
14631463
cause,
14641464
None,
1465-
Ty::new_unit(fcx.tcx),
1465+
fcx.tcx.types.unit,
14661466
augment_error,
14671467
label_unit_as_expected,
14681468
)

compiler/rustc_hir_typeck/src/expr.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
654654
} else {
655655
// Otherwise, this is a break *without* a value. That's
656656
// always legal, and is equivalent to `break ()`.
657-
e_ty = Ty::new_unit(tcx);
657+
e_ty = tcx.types.unit;
658658
cause = self.misc(expr.span);
659659
}
660660

@@ -1133,7 +1133,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11331133
// The expected type is `bool` but this will result in `()` so we can reasonably
11341134
// say that the user intended to write `lhs == rhs` instead of `lhs = rhs`.
11351135
// The likely cause of this is `if foo = bar { .. }`.
1136-
let actual_ty = Ty::new_unit(self.tcx);
1136+
let actual_ty = self.tcx.types.unit;
11371137
let mut err = self.demand_suptype_diag(expr.span, expected_ty, actual_ty).unwrap();
11381138
let lhs_ty = self.check_expr(lhs);
11391139
let rhs_ty = self.check_expr(rhs);
@@ -1256,7 +1256,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12561256
if let Err(guar) = (lhs_ty, rhs_ty).error_reported() {
12571257
Ty::new_error(self.tcx, guar)
12581258
} else {
1259-
Ty::new_unit(self.tcx)
1259+
self.tcx.types.unit
12601260
}
12611261
}
12621262

@@ -1319,7 +1319,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13191319
if ctxt.coerce.is_none() && !ctxt.may_break {
13201320
self.dcx().span_bug(body.span, "no coercion, but loop may not break");
13211321
}
1322-
ctxt.coerce.map(|c| c.complete(self)).unwrap_or_else(|| Ty::new_unit(self.tcx))
1322+
ctxt.coerce.map(|c| c.complete(self)).unwrap_or_else(|| self.tcx.types.unit)
13231323
}
13241324

13251325
/// Checks a method call.
@@ -3174,7 +3174,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
31743174
self.dcx().emit_err(YieldExprOutsideOfCoroutine { span: expr.span });
31753175
// Avoid expressions without types during writeback (#78653).
31763176
self.check_expr(value);
3177-
Ty::new_unit(self.tcx)
3177+
self.tcx.types.unit
31783178
}
31793179
}
31803180
}

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1660,7 +1660,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16601660
hir::StmtKind::Item(_) => {}
16611661
hir::StmtKind::Expr(ref expr) => {
16621662
// Check with expected type of `()`.
1663-
self.check_expr_has_type_or_error(expr, Ty::new_unit(self.tcx), |err| {
1663+
self.check_expr_has_type_or_error(expr, self.tcx.types.unit, |err| {
16641664
if expr.can_have_side_effects() {
16651665
self.suggest_semicolon_at_end(expr.span, err);
16661666
}
@@ -1676,7 +1676,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16761676
}
16771677

16781678
pub fn check_block_no_value(&self, blk: &'tcx hir::Block<'tcx>) {
1679-
let unit = Ty::new_unit(self.tcx);
1679+
let unit = self.tcx.types.unit;
16801680
let ty = self.check_block_with_expected(blk, ExpectHasType(unit));
16811681

16821682
// if the block produces a `!` value, that can always be
@@ -1794,7 +1794,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
17941794
blk.span,
17951795
blk.hir_id,
17961796
expected_ty,
1797-
Ty::new_unit(self.tcx),
1797+
self.tcx.types.unit,
17981798
);
17991799
}
18001800
if !self.err_ctxt().consider_removing_semicolon(

compiler/rustc_hir_typeck/src/op.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
3939
let ty =
4040
if !lhs_ty.is_ty_var() && !rhs_ty.is_ty_var() && is_builtin_binop(lhs_ty, rhs_ty, op) {
4141
self.enforce_builtin_binop_types(lhs.span, lhs_ty, rhs.span, rhs_ty, op);
42-
Ty::new_unit(self.tcx)
42+
self.tcx.types.unit
4343
} else {
4444
return_ty
4545
};

compiler/rustc_lint/src/unit_bindings.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use crate::lints::UnitBindingsDiag;
22
use crate::{LateLintPass, LintContext};
33
use rustc_hir as hir;
4-
use rustc_middle::ty::Ty;
54
use rustc_session::{declare_lint, declare_lint_pass};
65

76
declare_lint! {
@@ -57,8 +56,8 @@ impl<'tcx> LateLintPass<'tcx> for UnitBindings {
5756
&& let Some(init) = local.init
5857
&& let init_ty = tyck_results.expr_ty(init)
5958
&& let local_ty = tyck_results.node_type(local.hir_id)
60-
&& init_ty == Ty::new_unit(cx.tcx)
61-
&& local_ty == Ty::new_unit(cx.tcx)
59+
&& init_ty == cx.tcx.types.unit
60+
&& local_ty == cx.tcx.types.unit
6261
&& local.ty.is_none()
6362
&& !matches!(init.kind, hir::ExprKind::Tup([]))
6463
&& !matches!(local.pat.kind, hir::PatKind::Tuple([], ..))

compiler/rustc_middle/src/ty/layout.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl Primitive {
125125
F64 => tcx.types.f64,
126126
F128 => tcx.types.f128,
127127
// FIXME(erikdesjardins): handle non-default addrspace ptr sizes
128-
Pointer(_) => Ty::new_mut_ptr(tcx, Ty::new_unit(tcx)),
128+
Pointer(_) => Ty::new_mut_ptr(tcx, tcx.types.unit),
129129
}
130130
}
131131

@@ -775,7 +775,7 @@ where
775775
// (which may have no non-DST form), and will work as long
776776
// as the `Abi` or `FieldsShape` is checked by users.
777777
if i == 0 {
778-
let nil = Ty::new_unit(tcx);
778+
let nil = tcx.types.unit;
779779
let unit_ptr_ty = if this.ty.is_unsafe_ptr() {
780780
Ty::new_mut_ptr(tcx, nil)
781781
} else {

0 commit comments

Comments
 (0)