Skip to content

Commit 9a158d3

Browse files
committed
Auto merge of rust-lang#124271 - GuillaumeGomez:rollup-7st9wd7, r=GuillaumeGomez
Rollup of 7 pull requests Successful merges: - rust-lang#115913 (checked_ilog: improve performance) - rust-lang#124178 ([cleanup] [llvm backend] Prevent creating the same `Instance::mono` multiple times) - rust-lang#124183 (Stop taking `ParamTy`/`ParamConst`/`EarlyParamRegion`/`AliasTy` by ref) - rust-lang#124217 (coverage: Prepare for improved branch coverage) - rust-lang#124230 (Stabilize generic `NonZero`.) - rust-lang#124252 (Improve ICE message for forbidden dep-graph reads.) - rust-lang#124268 (Update books) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 7f2fc33 + 000d0f9 commit 9a158d3

File tree

116 files changed

+1241
-278
lines changed

Some content is hidden

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

116 files changed

+1241
-278
lines changed

compiler/rustc_attr/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#![allow(internal_features)]
88
#![feature(rustdoc_internals)]
99
#![doc(rust_logo)]
10-
#![feature(generic_nonzero)]
1110
#![feature(let_chains)]
1211

1312
#[macro_use]

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1320,7 +1320,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
13201320
.into_iter()
13211321
.map(|err| match err.obligation.predicate.kind().skip_binder() {
13221322
PredicateKind::Clause(ty::ClauseKind::Trait(predicate)) => {
1323-
match predicate.self_ty().kind() {
1323+
match *predicate.self_ty().kind() {
13241324
ty::Param(param_ty) => Ok((
13251325
generics.type_param(param_ty, tcx),
13261326
predicate.trait_ref.print_only_trait_path().to_string(),

compiler/rustc_borrowck/src/diagnostics/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
10701070
// LL | blk();
10711071
// | ----- this value implements `FnOnce`, which causes it to be moved when called
10721072
// ```
1073-
if let ty::Param(param_ty) = self_ty.kind()
1073+
if let ty::Param(param_ty) = *self_ty.kind()
10741074
&& let generics = self.infcx.tcx.generics_of(self.mir_def_id())
10751075
&& let param = generics.type_param(param_ty, self.infcx.tcx)
10761076
&& let Some(hir_generics) = self

compiler/rustc_codegen_llvm/src/consts.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,8 @@ impl<'ll> CodegenCx<'ll, '_> {
260260

261261
#[instrument(level = "debug", skip(self, llty))]
262262
pub(crate) fn get_static_inner(&self, def_id: DefId, llty: &'ll Type) -> &'ll Value {
263-
if let Some(&g) = self.instances.borrow().get(&Instance::mono(self.tcx, def_id)) {
263+
let instance = Instance::mono(self.tcx, def_id);
264+
if let Some(&g) = self.instances.borrow().get(&instance) {
264265
trace!("used cached value");
265266
return g;
266267
}
@@ -273,7 +274,7 @@ impl<'ll> CodegenCx<'ll, '_> {
273274
statics defined in the same CGU, but did not for `{def_id:?}`"
274275
);
275276

276-
let sym = self.tcx.symbol_name(Instance::mono(self.tcx, def_id)).name;
277+
let sym = self.tcx.symbol_name(instance).name;
277278
let fn_attrs = self.tcx.codegen_fn_attrs(def_id);
278279

279280
debug!(?sym, ?fn_attrs);
@@ -363,7 +364,7 @@ impl<'ll> CodegenCx<'ll, '_> {
363364
}
364365
}
365366

366-
self.instances.borrow_mut().insert(Instance::mono(self.tcx, def_id), g);
367+
self.instances.borrow_mut().insert(instance, g);
367368
g
368369
}
369370

compiler/rustc_const_eval/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Rust MIR: a lowered representation of Rust.
1111
#![feature(assert_matches)]
1212
#![feature(box_patterns)]
1313
#![feature(decl_macro)]
14-
#![feature(generic_nonzero)]
1514
#![feature(let_chains)]
1615
#![feature(slice_ptr_get)]
1716
#![feature(strict_provenance)]

compiler/rustc_data_structures/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#![feature(cfg_match)]
2121
#![feature(core_intrinsics)]
2222
#![feature(extend_one)]
23-
#![feature(generic_nonzero)]
2423
#![feature(hash_raw_entry)]
2524
#![feature(hasher_prefixfree_extras)]
2625
#![feature(lazy_cell)]

compiler/rustc_errors/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#![feature(box_patterns)]
1616
#![feature(error_reporter)]
1717
#![feature(extract_if)]
18-
#![feature(generic_nonzero)]
1918
#![feature(let_chains)]
2019
#![feature(negative_impls)]
2120
#![feature(never_type)]

compiler/rustc_feature/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
//! symbol to the `accepted` or `removed` modules respectively.
1313
1414
#![allow(internal_features)]
15-
#![feature(generic_nonzero)]
1615
#![feature(rustdoc_internals)]
1716
#![doc(rust_logo)]
1817
#![feature(lazy_cell)]

compiler/rustc_hir_analysis/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ This API is completely unstable and subject to change.
6363
#![feature(rustdoc_internals)]
6464
#![allow(internal_features)]
6565
#![feature(control_flow_enum)]
66-
#![feature(generic_nonzero)]
6766
#![feature(if_let_guard)]
6867
#![feature(is_sorted)]
6968
#![feature(iter_intersperse)]

compiler/rustc_hir_typeck/src/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2697,7 +2697,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
26972697

26982698
fn point_at_param_definition(&self, err: &mut Diag<'_>, param: ty::ParamTy) {
26992699
let generics = self.tcx.generics_of(self.body_id);
2700-
let generic_param = generics.type_param(&param, self.tcx);
2700+
let generic_param = generics.type_param(param, self.tcx);
27012701
if let ty::GenericParamDefKind::Type { synthetic: true, .. } = generic_param.kind {
27022702
return;
27032703
}

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2144,7 +2144,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
21442144
let callee_ty = callee_ty.peel_refs();
21452145
match *callee_ty.kind() {
21462146
ty::Param(param) => {
2147-
let param = self.tcx.generics_of(self.body_id).type_param(&param, self.tcx);
2147+
let param = self.tcx.generics_of(self.body_id).type_param(param, self.tcx);
21482148
if param.kind.is_synthetic() {
21492149
// if it's `impl Fn() -> ..` then just fall down to the def-id based logic
21502150
def_id = param.def_id;

compiler/rustc_hir_typeck/src/method/suggest.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
125125
let Some(arg_ty) = args[0].as_type() else {
126126
return false;
127127
};
128-
let ty::Param(param) = arg_ty.kind() else {
128+
let ty::Param(param) = *arg_ty.kind() else {
129129
return false;
130130
};
131131
// Is `generic_param` the same as the arg for this trait predicate?
132-
generic_param.index == generics.type_param(&param, tcx).index
132+
generic_param.index == generics.type_param(param, tcx).index
133133
} else {
134134
false
135135
}
@@ -156,10 +156,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
156156
return false;
157157
}
158158

159-
match ty.peel_refs().kind() {
159+
match *ty.peel_refs().kind() {
160160
ty::Param(param) => {
161161
let generics = self.tcx.generics_of(self.body_id);
162-
let generic_param = generics.type_param(&param, self.tcx);
162+
let generic_param = generics.type_param(param, self.tcx);
163163
for unsatisfied in unsatisfied_predicates.iter() {
164164
// The parameter implements `IntoIterator`
165165
// but it has called a method that requires it to implement `Iterator`
@@ -3232,9 +3232,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
32323232
.sort_by_key(|&info| (!info.def_id.is_local(), self.tcx.def_path_str(info.def_id)));
32333233
candidates.dedup();
32343234

3235-
let param_type = match rcvr_ty.kind() {
3235+
let param_type = match *rcvr_ty.kind() {
32363236
ty::Param(param) => Some(param),
3237-
ty::Ref(_, ty, _) => match ty.kind() {
3237+
ty::Ref(_, ty, _) => match *ty.kind() {
32383238
ty::Param(param) => Some(param),
32393239
_ => None,
32403240
},
@@ -3429,7 +3429,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
34293429
} else {
34303430
param_type.map_or_else(
34313431
|| "implement".to_string(), // FIXME: it might only need to be imported into scope, not implemented.
3432-
ToString::to_string,
3432+
|p| p.to_string(),
34333433
)
34343434
},
34353435
},

compiler/rustc_infer/src/infer/error_reporting/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2371,7 +2371,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
23712371

23722372
// type_param_sugg_span is (span, has_bounds)
23732373
let (type_scope, type_param_sugg_span) = match bound_kind {
2374-
GenericKind::Param(ref param) => {
2374+
GenericKind::Param(param) => {
23752375
let generics = self.tcx.generics_of(generic_param_scope);
23762376
let def_id = generics.type_param(param, self.tcx).def_id.expect_local();
23772377
let scope = self.tcx.local_def_id_to_hir_id(def_id).owner.def_id;

compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
2828

2929
match err {
3030
ArgumentSorts(values, _) | Sorts(values) => {
31-
match (values.expected.kind(), values.found.kind()) {
31+
match (*values.expected.kind(), *values.found.kind()) {
3232
(ty::Closure(..), ty::Closure(..)) => {
3333
diag.note("no two closures, even if identical, have the same type");
3434
diag.help("consider boxing your closure and/or using it as a trait object");
@@ -452,7 +452,7 @@ impl<T> Trait<T> for X {
452452
}
453453
(ty::FnPtr(sig), ty::FnDef(def_id, _))
454454
| (ty::FnDef(def_id, _), ty::FnPtr(sig)) => {
455-
if tcx.fn_sig(*def_id).skip_binder().unsafety() < sig.unsafety() {
455+
if tcx.fn_sig(def_id).skip_binder().unsafety() < sig.unsafety() {
456456
diag.note(
457457
"unsafe functions cannot be coerced into safe function pointers",
458458
);
@@ -527,7 +527,7 @@ impl<T> Trait<T> for X {
527527
diag: &mut Diag<'_>,
528528
msg: impl Fn() -> String,
529529
body_owner_def_id: DefId,
530-
proj_ty: &ty::AliasTy<'tcx>,
530+
proj_ty: ty::AliasTy<'tcx>,
531531
ty: Ty<'tcx>,
532532
) -> bool {
533533
let tcx = self.tcx;
@@ -541,7 +541,7 @@ impl<T> Trait<T> for X {
541541
};
542542
// Get the `DefId` for the type parameter corresponding to `A` in `<A as T>::Foo`.
543543
// This will also work for `impl Trait`.
544-
let ty::Param(param_ty) = proj_ty.self_ty().kind() else {
544+
let ty::Param(param_ty) = *proj_ty.self_ty().kind() else {
545545
return false;
546546
};
547547
let generics = tcx.generics_of(body_owner_def_id);
@@ -598,7 +598,7 @@ impl<T> Trait<T> for X {
598598
fn expected_projection(
599599
&self,
600600
diag: &mut Diag<'_>,
601-
proj_ty: &ty::AliasTy<'tcx>,
601+
proj_ty: ty::AliasTy<'tcx>,
602602
values: ExpectedFound<Ty<'tcx>>,
603603
body_owner_def_id: DefId,
604604
cause_code: &ObligationCauseCode<'_>,
@@ -709,7 +709,7 @@ fn foo(&self) -> Self::T { String::new() }
709709
&self,
710710
diag: &mut Diag<'_>,
711711
msg: impl Fn() -> String,
712-
proj_ty: &ty::AliasTy<'tcx>,
712+
proj_ty: ty::AliasTy<'tcx>,
713713
ty: Ty<'tcx>,
714714
) -> bool {
715715
let tcx = self.tcx;

compiler/rustc_interface/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![feature(decl_macro)]
2-
#![feature(generic_nonzero)]
32
#![feature(lazy_cell)]
43
#![feature(let_chains)]
54
#![feature(thread_spawn_unchecked)]

compiler/rustc_lint/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#![feature(box_patterns)]
3333
#![feature(control_flow_enum)]
3434
#![feature(extract_if)]
35-
#![feature(generic_nonzero)]
3635
#![feature(if_let_guard)]
3736
#![feature(iter_order_by)]
3837
#![feature(let_chains)]

compiler/rustc_metadata/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#![feature(error_iter)]
77
#![feature(extract_if)]
88
#![feature(coroutines)]
9-
#![feature(generic_nonzero)]
109
#![feature(iter_from_coroutine)]
1110
#![feature(let_chains)]
1211
#![feature(if_let_guard)]

compiler/rustc_middle/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#![feature(const_type_name)]
3636
#![feature(discriminant_kind)]
3737
#![feature(coroutines)]
38-
#![feature(generic_nonzero)]
3938
#![feature(if_let_guard)]
4039
#![feature(inline_const)]
4140
#![feature(iter_from_coroutine)]

compiler/rustc_middle/src/mir/coverage.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,9 @@ impl Default for ConditionInfo {
314314
#[derive(TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable, TypeVisitable)]
315315
pub struct MCDCBranchSpan {
316316
pub span: Span,
317-
pub condition_info: ConditionInfo,
317+
/// If `None`, this actually represents a normal branch span inserted for
318+
/// code that was too complex for MC/DC.
319+
pub condition_info: Option<ConditionInfo>,
318320
pub true_marker: BlockMarkerId,
319321
pub false_marker: BlockMarkerId,
320322
}

compiler/rustc_middle/src/mir/pretty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ fn write_coverage_branch_info(
491491
writeln!(
492492
w,
493493
"{INDENT}coverage mcdc branch {{ condition_id: {:?}, true: {true_marker:?}, false: {false_marker:?} }} => {span:?}",
494-
condition_info.condition_id
494+
condition_info.map(|info| info.condition_id)
495495
)?;
496496
}
497497

compiler/rustc_middle/src/ty/generics.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ impl<'tcx> Generics {
263263
/// Returns the `GenericParamDef` associated with this `EarlyParamRegion`.
264264
pub fn region_param(
265265
&'tcx self,
266-
param: &ty::EarlyParamRegion,
266+
param: ty::EarlyParamRegion,
267267
tcx: TyCtxt<'tcx>,
268268
) -> &'tcx GenericParamDef {
269269
let param = self.param_at(param.index as usize, tcx);
@@ -274,7 +274,7 @@ impl<'tcx> Generics {
274274
}
275275

276276
/// Returns the `GenericParamDef` associated with this `ParamTy`.
277-
pub fn type_param(&'tcx self, param: &ParamTy, tcx: TyCtxt<'tcx>) -> &'tcx GenericParamDef {
277+
pub fn type_param(&'tcx self, param: ParamTy, tcx: TyCtxt<'tcx>) -> &'tcx GenericParamDef {
278278
let param = self.param_at(param.index as usize, tcx);
279279
match param.kind {
280280
GenericParamDefKind::Type { .. } => param,
@@ -286,7 +286,7 @@ impl<'tcx> Generics {
286286
/// `Generics`.
287287
pub fn opt_type_param(
288288
&'tcx self,
289-
param: &ParamTy,
289+
param: ParamTy,
290290
tcx: TyCtxt<'tcx>,
291291
) -> Option<&'tcx GenericParamDef> {
292292
let param = self.opt_param_at(param.index as usize, tcx)?;
@@ -297,7 +297,7 @@ impl<'tcx> Generics {
297297
}
298298

299299
/// Returns the `GenericParamDef` associated with this `ParamConst`.
300-
pub fn const_param(&'tcx self, param: &ParamConst, tcx: TyCtxt<'tcx>) -> &GenericParamDef {
300+
pub fn const_param(&'tcx self, param: ParamConst, tcx: TyCtxt<'tcx>) -> &GenericParamDef {
301301
let param = self.param_at(param.index as usize, tcx);
302302
match param.kind {
303303
GenericParamDefKind::Const { .. } => param,

compiler/rustc_middle/src/ty/print/pretty.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
12761276

12771277
fn pretty_print_inherent_projection(
12781278
&mut self,
1279-
alias_ty: &ty::AliasTy<'tcx>,
1279+
alias_ty: ty::AliasTy<'tcx>,
12801280
) -> Result<(), PrintError> {
12811281
let def_key = self.tcx().def_key(alias_ty.def_id);
12821282
self.path_generic_args(
@@ -3204,7 +3204,7 @@ define_print_and_forward_display! {
32043204

32053205
ty::AliasTy<'tcx> {
32063206
if let DefKind::Impl { of_trait: false } = cx.tcx().def_kind(cx.tcx().parent(self.def_id)) {
3207-
p!(pretty_print_inherent_projection(self))
3207+
p!(pretty_print_inherent_projection(*self))
32083208
} else {
32093209
// If we're printing verbosely, or don't want to invoke queries
32103210
// (`is_impl_trait_in_trait`), then fall back to printing the def path.

compiler/rustc_middle/src/ty/sty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1379,7 +1379,7 @@ impl<'tcx> ParamTy {
13791379
Ty::new_param(tcx, self.index, self.name)
13801380
}
13811381

1382-
pub fn span_from_generics(&self, tcx: TyCtxt<'tcx>, item_with_generics: DefId) -> Span {
1382+
pub fn span_from_generics(self, tcx: TyCtxt<'tcx>, item_with_generics: DefId) -> Span {
13831383
let generics = tcx.generics_of(item_with_generics);
13841384
let type_param = generics.type_param(self, tcx);
13851385
tcx.def_span(type_param.def_id)

compiler/rustc_middle/src/ty/util.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -432,19 +432,19 @@ impl<'tcx> TyCtxt<'tcx> {
432432
.filter(|&(_, k)| {
433433
match k.unpack() {
434434
GenericArgKind::Lifetime(region) => match region.kind() {
435-
ty::ReEarlyParam(ref ebr) => {
435+
ty::ReEarlyParam(ebr) => {
436436
!impl_generics.region_param(ebr, self).pure_wrt_drop
437437
}
438438
// Error: not a region param
439439
_ => false,
440440
},
441-
GenericArgKind::Type(ty) => match ty.kind() {
442-
ty::Param(ref pt) => !impl_generics.type_param(pt, self).pure_wrt_drop,
441+
GenericArgKind::Type(ty) => match *ty.kind() {
442+
ty::Param(pt) => !impl_generics.type_param(pt, self).pure_wrt_drop,
443443
// Error: not a type param
444444
_ => false,
445445
},
446446
GenericArgKind::Const(ct) => match ct.kind() {
447-
ty::ConstKind::Param(ref pc) => {
447+
ty::ConstKind::Param(pc) => {
448448
!impl_generics.const_param(pc, self).pure_wrt_drop
449449
}
450450
// Error: not a const param

0 commit comments

Comments
 (0)