Skip to content

Commit 4f22692

Browse files
committed
Auto merge of rust-lang#116006 - GuillaumeGomez:rollup-elrbjd4, r=GuillaumeGomez
Rollup of 5 pull requests Successful merges: - rust-lang#115566 (clean up unneeded `ToPredicate` impls) - rust-lang#115962 (coverage: Remove debug code from the instrumentor) - rust-lang#115988 (rustdoc: add test cases, and fix, search tabs layout jank) - rust-lang#115991 (Ensure `build/tmp` exists in `rustdoc_themes::get_themes`) - rust-lang#115997 (RELEASES.md: Add missing patch releases) r? `@ghost` `@rustbot` modify labels: rollup
2 parents e3811a7 + 70076c5 commit 4f22692

File tree

20 files changed

+177
-1153
lines changed

20 files changed

+177
-1153
lines changed

RELEASES.md

+10
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,16 @@ Compatibility Notes
113113
to a registry.
114114
[#12291](https://github.com/rust-lang/cargo/pull/12291)
115115

116+
Version 1.71.1 (2023-08-03)
117+
===========================
118+
119+
- [Fix CVE-2023-38497: Cargo did not respect the umask when extracting dependencies](https://github.com/rust-lang/cargo/security/advisories/GHSA-j3xp-wfr4-hx87)
120+
- [Fix bash completion for users of Rustup](https://github.com/rust-lang/rust/pull/113579)
121+
- [Do not show `suspicious_double_ref_op` lint when calling `borrow()`](https://github.com/rust-lang/rust/pull/112517)
122+
- [Fix ICE: substitute types before checking inlining compatibility](https://github.com/rust-lang/rust/pull/113802)
123+
- [Fix ICE: don't use `can_eq` in `derive(..)` suggestion for missing method](https://github.com/rust-lang/rust/pull/111516)
124+
- [Fix building Rust 1.71.0 from the source tarball](https://github.com/rust-lang/rust/issues/113678)
125+
116126
Version 1.71.0 (2023-07-13)
117127
==========================
118128

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use rustc_middle::ty::util::ExplicitSelf;
1818
use rustc_middle::ty::{
1919
self, GenericArgs, Ty, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitableExt,
2020
};
21-
use rustc_middle::ty::{GenericParamDefKind, ToPredicate, TyCtxt};
21+
use rustc_middle::ty::{GenericParamDefKind, TyCtxt};
2222
use rustc_span::{Span, DUMMY_SP};
2323
use rustc_trait_selection::traits::error_reporting::TypeErrCtxtExt;
2424
use rustc_trait_selection::traits::outlives_bounds::InferCtxtExt as _;
@@ -2196,16 +2196,16 @@ pub(super) fn check_type_bounds<'tcx>(
21962196
//
21972197
// impl<T> X for T where T: X { type Y = <T as X>::Y; }
21982198
}
2199-
_ => predicates.push(
2199+
_ => predicates.push(ty::Clause::from_projection_clause(
2200+
tcx,
22002201
ty::Binder::bind_with_vars(
22012202
ty::ProjectionPredicate {
22022203
projection_ty: tcx.mk_alias_ty(trait_ty.def_id, rebased_args),
22032204
term: normalize_impl_ty.into(),
22042205
},
22052206
bound_vars,
2206-
)
2207-
.to_predicate(tcx),
2208-
),
2207+
),
2208+
)),
22092209
};
22102210
ty::ParamEnv::new(tcx.mk_clauses(&predicates), Reveal::UserFacing)
22112211
};

compiler/rustc_middle/src/ty/mod.rs

+5-39
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,11 @@ impl rustc_errors::IntoDiagnosticArg for Clause<'_> {
566566
pub struct Clause<'tcx>(Interned<'tcx, WithCachedTypeInfo<ty::Binder<'tcx, PredicateKind<'tcx>>>>);
567567

568568
impl<'tcx> Clause<'tcx> {
569+
pub fn from_projection_clause(tcx: TyCtxt<'tcx>, pred: PolyProjectionPredicate<'tcx>) -> Self {
570+
let pred: Predicate<'tcx> = pred.to_predicate(tcx);
571+
pred.expect_clause()
572+
}
573+
569574
pub fn as_predicate(self) -> Predicate<'tcx> {
570575
Predicate(self.0)
571576
}
@@ -1253,14 +1258,6 @@ impl<'tcx> ToPredicate<'tcx, Clause<'tcx>> for TraitRef<'tcx> {
12531258
}
12541259
}
12551260

1256-
impl<'tcx> ToPredicate<'tcx, Clause<'tcx>> for TraitPredicate<'tcx> {
1257-
#[inline(always)]
1258-
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Clause<'tcx> {
1259-
let p: Predicate<'tcx> = self.to_predicate(tcx);
1260-
p.expect_clause()
1261-
}
1262-
}
1263-
12641261
impl<'tcx> ToPredicate<'tcx> for Binder<'tcx, TraitRef<'tcx>> {
12651262
#[inline(always)]
12661263
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
@@ -1287,18 +1284,6 @@ impl<'tcx> ToPredicate<'tcx, PolyTraitPredicate<'tcx>> for Binder<'tcx, TraitRef
12871284
}
12881285
}
12891286

1290-
impl<'tcx> ToPredicate<'tcx, PolyTraitPredicate<'tcx>> for TraitRef<'tcx> {
1291-
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> PolyTraitPredicate<'tcx> {
1292-
ty::Binder::dummy(self).to_predicate(tcx)
1293-
}
1294-
}
1295-
1296-
impl<'tcx> ToPredicate<'tcx, PolyTraitPredicate<'tcx>> for TraitPredicate<'tcx> {
1297-
fn to_predicate(self, _tcx: TyCtxt<'tcx>) -> PolyTraitPredicate<'tcx> {
1298-
ty::Binder::dummy(self)
1299-
}
1300-
}
1301-
13021287
impl<'tcx> ToPredicate<'tcx> for PolyTraitPredicate<'tcx> {
13031288
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
13041289
self.map_bound(|p| PredicateKind::Clause(ClauseKind::Trait(p))).to_predicate(tcx)
@@ -1312,12 +1297,6 @@ impl<'tcx> ToPredicate<'tcx, Clause<'tcx>> for PolyTraitPredicate<'tcx> {
13121297
}
13131298
}
13141299

1315-
impl<'tcx> ToPredicate<'tcx> for OutlivesPredicate<ty::Region<'tcx>, ty::Region<'tcx>> {
1316-
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
1317-
ty::Binder::dummy(PredicateKind::Clause(ClauseKind::RegionOutlives(self))).to_predicate(tcx)
1318-
}
1319-
}
1320-
13211300
impl<'tcx> ToPredicate<'tcx> for PolyRegionOutlivesPredicate<'tcx> {
13221301
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
13231302
self.map_bound(|p| PredicateKind::Clause(ClauseKind::RegionOutlives(p))).to_predicate(tcx)
@@ -1330,12 +1309,6 @@ impl<'tcx> ToPredicate<'tcx> for OutlivesPredicate<Ty<'tcx>, ty::Region<'tcx>> {
13301309
}
13311310
}
13321311

1333-
impl<'tcx> ToPredicate<'tcx> for PolyTypeOutlivesPredicate<'tcx> {
1334-
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
1335-
self.map_bound(|p| PredicateKind::Clause(ClauseKind::TypeOutlives(p))).to_predicate(tcx)
1336-
}
1337-
}
1338-
13391312
impl<'tcx> ToPredicate<'tcx> for ProjectionPredicate<'tcx> {
13401313
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
13411314
ty::Binder::dummy(PredicateKind::Clause(ClauseKind::Projection(self))).to_predicate(tcx)
@@ -1355,13 +1328,6 @@ impl<'tcx> ToPredicate<'tcx, Clause<'tcx>> for ProjectionPredicate<'tcx> {
13551328
}
13561329
}
13571330

1358-
impl<'tcx> ToPredicate<'tcx, Clause<'tcx>> for PolyProjectionPredicate<'tcx> {
1359-
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Clause<'tcx> {
1360-
let p: Predicate<'tcx> = self.to_predicate(tcx);
1361-
p.expect_clause()
1362-
}
1363-
}
1364-
13651331
impl<'tcx> ToPredicate<'tcx> for TraitPredicate<'tcx> {
13661332
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
13671333
PredicateKind::Clause(ClauseKind::Trait(self)).to_predicate(tcx)

compiler/rustc_middle/src/ty/sty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ impl<'tcx> PolyExistentialPredicate<'tcx> {
725725
self.rebind(tr).with_self_ty(tcx, self_ty).to_predicate(tcx)
726726
}
727727
ExistentialPredicate::Projection(p) => {
728-
self.rebind(p.with_self_ty(tcx, self_ty)).to_predicate(tcx)
728+
ty::Clause::from_projection_clause(tcx, self.rebind(p.with_self_ty(tcx, self_ty)))
729729
}
730730
ExistentialPredicate::AutoTrait(did) => {
731731
let generics = tcx.generics_of(did);

compiler/rustc_mir_transform/src/coverage/counters.rs

+26-75
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
use super::Error;
22

3-
use super::debug;
43
use super::graph;
54
use super::spans;
65

7-
use debug::{DebugCounters, NESTED_INDENT};
86
use graph::{BasicCoverageBlock, BcbBranch, CoverageGraph, TraverseCoverageGraphWithLoops};
97
use spans::CoverageSpan;
108

@@ -16,6 +14,8 @@ use rustc_middle::mir::coverage::*;
1614

1715
use std::fmt::{self, Debug};
1816

17+
const NESTED_INDENT: &str = " ";
18+
1919
/// The coverage counter or counter expression associated with a particular
2020
/// BCB node or BCB edge.
2121
#[derive(Clone)]
@@ -75,8 +75,6 @@ pub(super) struct CoverageCounters {
7575
/// BCB/edge, but are needed as operands to more complex expressions.
7676
/// These are always [`BcbCounter::Expression`].
7777
pub(super) intermediate_expressions: Vec<BcbCounter>,
78-
79-
pub debug_counters: DebugCounters,
8078
}
8179

8280
impl CoverageCounters {
@@ -91,17 +89,9 @@ impl CoverageCounters {
9189
bcb_edge_counters: FxHashMap::default(),
9290
bcb_has_incoming_edge_counters: BitSet::new_empty(num_bcbs),
9391
intermediate_expressions: Vec::new(),
94-
95-
debug_counters: DebugCounters::new(),
9692
}
9793
}
9894

99-
/// Activate the `DebugCounters` data structures, to provide additional debug formatting
100-
/// features when formatting [`BcbCounter`] (counter) values.
101-
pub fn enable_debug(&mut self) {
102-
self.debug_counters.enable();
103-
}
104-
10595
/// Makes [`BcbCounter`] `Counter`s and `Expressions` for the `BasicCoverageBlock`s directly or
10696
/// indirectly associated with `CoverageSpans`, and accumulates additional `Expression`s
10797
/// representing intermediate values.
@@ -113,44 +103,18 @@ impl CoverageCounters {
113103
MakeBcbCounters::new(self, basic_coverage_blocks).make_bcb_counters(coverage_spans)
114104
}
115105

116-
fn make_counter<F>(&mut self, debug_block_label_fn: F) -> BcbCounter
117-
where
118-
F: Fn() -> Option<String>,
119-
{
120-
let counter = BcbCounter::Counter { id: self.next_counter() };
121-
if self.debug_counters.is_enabled() {
122-
self.debug_counters.add_counter(&counter, (debug_block_label_fn)());
123-
}
124-
counter
106+
fn make_counter(&mut self) -> BcbCounter {
107+
let id = self.next_counter();
108+
BcbCounter::Counter { id }
125109
}
126110

127-
fn make_expression<F>(
128-
&mut self,
129-
lhs: Operand,
130-
op: Op,
131-
rhs: Operand,
132-
debug_block_label_fn: F,
133-
) -> BcbCounter
134-
where
135-
F: Fn() -> Option<String>,
136-
{
111+
fn make_expression(&mut self, lhs: Operand, op: Op, rhs: Operand) -> BcbCounter {
137112
let id = self.next_expression();
138-
let expression = BcbCounter::Expression { id, lhs, op, rhs };
139-
if self.debug_counters.is_enabled() {
140-
self.debug_counters.add_counter(&expression, (debug_block_label_fn)());
141-
}
142-
expression
113+
BcbCounter::Expression { id, lhs, op, rhs }
143114
}
144115

145116
pub fn make_identity_counter(&mut self, counter_operand: Operand) -> BcbCounter {
146-
let some_debug_block_label = if self.debug_counters.is_enabled() {
147-
self.debug_counters.some_block_label(counter_operand).cloned()
148-
} else {
149-
None
150-
};
151-
self.make_expression(counter_operand, Op::Add, Operand::Zero, || {
152-
some_debug_block_label.clone()
153-
})
117+
self.make_expression(counter_operand, Op::Add, Operand::Zero)
154118
}
155119

156120
/// Counter IDs start from one and go up.
@@ -367,12 +331,8 @@ impl<'a> MakeBcbCounters<'a> {
367331
branch_counter_operand,
368332
Op::Add,
369333
sumup_counter_operand,
370-
|| None,
371-
);
372-
debug!(
373-
" [new intermediate expression: {}]",
374-
self.format_counter(&intermediate_expression)
375334
);
335+
debug!(" [new intermediate expression: {:?}]", intermediate_expression);
376336
let intermediate_expression_operand = intermediate_expression.as_operand();
377337
self.coverage_counters.intermediate_expressions.push(intermediate_expression);
378338
some_sumup_counter_operand.replace(intermediate_expression_operand);
@@ -394,9 +354,8 @@ impl<'a> MakeBcbCounters<'a> {
394354
branching_counter_operand,
395355
Op::Subtract,
396356
sumup_counter_operand,
397-
|| Some(format!("{expression_branch:?}")),
398357
);
399-
debug!("{:?} gets an expression: {}", expression_branch, self.format_counter(&expression));
358+
debug!("{:?} gets an expression: {:?}", expression_branch, expression);
400359
let bcb = expression_branch.target_bcb;
401360
if expression_branch.is_only_path_to_target() {
402361
self.coverage_counters.set_bcb_counter(bcb, expression)?;
@@ -418,10 +377,10 @@ impl<'a> MakeBcbCounters<'a> {
418377
// If the BCB already has a counter, return it.
419378
if let Some(counter_kind) = &self.coverage_counters.bcb_counters[bcb] {
420379
debug!(
421-
"{}{:?} already has a counter: {}",
380+
"{}{:?} already has a counter: {:?}",
422381
NESTED_INDENT.repeat(debug_indent_level),
423382
bcb,
424-
self.format_counter(counter_kind),
383+
counter_kind,
425384
);
426385
return Ok(counter_kind.as_operand());
427386
}
@@ -431,22 +390,22 @@ impl<'a> MakeBcbCounters<'a> {
431390
// program results in a tight infinite loop, but it should still compile.
432391
let one_path_to_target = self.bcb_has_one_path_to_target(bcb);
433392
if one_path_to_target || self.bcb_predecessors(bcb).contains(&bcb) {
434-
let counter_kind = self.coverage_counters.make_counter(|| Some(format!("{bcb:?}")));
393+
let counter_kind = self.coverage_counters.make_counter();
435394
if one_path_to_target {
436395
debug!(
437-
"{}{:?} gets a new counter: {}",
396+
"{}{:?} gets a new counter: {:?}",
438397
NESTED_INDENT.repeat(debug_indent_level),
439398
bcb,
440-
self.format_counter(&counter_kind),
399+
counter_kind,
441400
);
442401
} else {
443402
debug!(
444403
"{}{:?} has itself as its own predecessor. It can't be part of its own \
445-
Expression sum, so it will get its own new counter: {}. (Note, the compiled \
404+
Expression sum, so it will get its own new counter: {:?}. (Note, the compiled \
446405
code will generate an infinite loop.)",
447406
NESTED_INDENT.repeat(debug_indent_level),
448407
bcb,
449-
self.format_counter(&counter_kind),
408+
counter_kind,
450409
);
451410
}
452411
return self.coverage_counters.set_bcb_counter(bcb, counter_kind);
@@ -481,12 +440,11 @@ impl<'a> MakeBcbCounters<'a> {
481440
sumup_edge_counter_operand,
482441
Op::Add,
483442
edge_counter_operand,
484-
|| None,
485443
);
486444
debug!(
487-
"{}new intermediate expression: {}",
445+
"{}new intermediate expression: {:?}",
488446
NESTED_INDENT.repeat(debug_indent_level),
489-
self.format_counter(&intermediate_expression)
447+
intermediate_expression
490448
);
491449
let intermediate_expression_operand = intermediate_expression.as_operand();
492450
self.coverage_counters.intermediate_expressions.push(intermediate_expression);
@@ -497,13 +455,12 @@ impl<'a> MakeBcbCounters<'a> {
497455
first_edge_counter_operand,
498456
Op::Add,
499457
some_sumup_edge_counter_operand.unwrap(),
500-
|| Some(format!("{bcb:?}")),
501458
);
502459
debug!(
503-
"{}{:?} gets a new counter (sum of predecessor counters): {}",
460+
"{}{:?} gets a new counter (sum of predecessor counters): {:?}",
504461
NESTED_INDENT.repeat(debug_indent_level),
505462
bcb,
506-
self.format_counter(&counter_kind)
463+
counter_kind
507464
);
508465
self.coverage_counters.set_bcb_counter(bcb, counter_kind)
509466
}
@@ -534,24 +491,23 @@ impl<'a> MakeBcbCounters<'a> {
534491
self.coverage_counters.bcb_edge_counters.get(&(from_bcb, to_bcb))
535492
{
536493
debug!(
537-
"{}Edge {:?}->{:?} already has a counter: {}",
494+
"{}Edge {:?}->{:?} already has a counter: {:?}",
538495
NESTED_INDENT.repeat(debug_indent_level),
539496
from_bcb,
540497
to_bcb,
541-
self.format_counter(counter_kind)
498+
counter_kind
542499
);
543500
return Ok(counter_kind.as_operand());
544501
}
545502

546503
// Make a new counter to count this edge.
547-
let counter_kind =
548-
self.coverage_counters.make_counter(|| Some(format!("{from_bcb:?}->{to_bcb:?}")));
504+
let counter_kind = self.coverage_counters.make_counter();
549505
debug!(
550-
"{}Edge {:?}->{:?} gets a new counter: {}",
506+
"{}Edge {:?}->{:?} gets a new counter: {:?}",
551507
NESTED_INDENT.repeat(debug_indent_level),
552508
from_bcb,
553509
to_bcb,
554-
self.format_counter(&counter_kind)
510+
counter_kind
555511
);
556512
self.coverage_counters.set_bcb_edge_counter(from_bcb, to_bcb, counter_kind)
557513
}
@@ -710,9 +666,4 @@ impl<'a> MakeBcbCounters<'a> {
710666
fn bcb_dominates(&self, dom: BasicCoverageBlock, node: BasicCoverageBlock) -> bool {
711667
self.basic_coverage_blocks.dominates(dom, node)
712668
}
713-
714-
#[inline]
715-
fn format_counter(&self, counter_kind: &BcbCounter) -> String {
716-
self.coverage_counters.debug_counters.format_counter(counter_kind)
717-
}
718669
}

0 commit comments

Comments
 (0)