Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit c8e6a9e

Browse files
committed
Auto merge of rust-lang#107220 - JohnTitor:rollup-5pvuz0z, r=JohnTitor
Rollup of 7 pull requests Successful merges: - rust-lang#106796 (BPF: Disable atomic CAS) - rust-lang#106886 (Make stage2 rustdoc and proc-macro-srv disableable in x.py install) - rust-lang#107101 (Filter param-env predicates for errors before calling `to_opt_poly_trait_pred`) - rust-lang#107109 (ThinBox: Add intra-doc-links for Metadata) - rust-lang#107148 (remove error code from `E0789`, add UI test/docs) - rust-lang#107151 (Instantiate dominators algorithm only once) - rust-lang#107153 (Consistently use dominates instead of is_dominated_by) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 5bef91c + eae7f94 commit c8e6a9e

File tree

17 files changed

+126
-37
lines changed

17 files changed

+126
-37
lines changed

compiler/rustc_data_structures/src/graph/dominators/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ impl<Node: Idx> Dominators<Node> {
285285
Iter { dominators: self, node: Some(node) }
286286
}
287287

288-
pub fn is_dominated_by(&self, node: Node, dom: Node) -> bool {
288+
pub fn dominates(&self, dom: Node, node: Node) -> bool {
289289
// FIXME -- could be optimized by using post-order-rank
290290
self.dominators(node).any(|n| n == dom)
291291
}

compiler/rustc_error_codes/src/error_codes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,7 @@ E0785: include_str!("./error_codes/E0785.md"),
506506
E0786: include_str!("./error_codes/E0786.md"),
507507
E0787: include_str!("./error_codes/E0787.md"),
508508
E0788: include_str!("./error_codes/E0788.md"),
509+
E0789: include_str!("./error_codes/E0789.md"),
509510
E0790: include_str!("./error_codes/E0790.md"),
510511
E0791: include_str!("./error_codes/E0791.md"),
511512
E0792: include_str!("./error_codes/E0792.md"),
@@ -645,5 +646,4 @@ E0792: include_str!("./error_codes/E0792.md"),
645646
// E0721, // `await` keyword
646647
// E0723, // unstable feature in `const` context
647648
// E0738, // Removed; errored on `#[track_caller] fn`s in `extern "Rust" { ... }`.
648-
E0789, // rustc_allowed_through_unstable_modules without stability attribute
649649
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#### This error code is internal to the compiler and will not be emitted with normal Rust code.
2+
3+
The internal `rustc_allowed_through_unstable_modules` attribute must be used
4+
on an item with a `stable` attribute.
5+
6+
Erroneous code example:
7+
8+
```compile_fail,E0789
9+
// NOTE: both of these attributes are perma-unstable and should *never* be
10+
// used outside of the compiler and standard library.
11+
#![feature(rustc_attrs)]
12+
#![feature(staged_api)]
13+
14+
#![unstable(feature = "foo_module", reason = "...", issue = "123")]
15+
16+
#[rustc_allowed_through_unstable_modules]
17+
// #[stable(feature = "foo", since = "1.0")]
18+
struct Foo;
19+
// ^^^ error: `rustc_allowed_through_unstable_modules` attribute must be
20+
// paired with a `stable` attribute
21+
```
22+
23+
Typically when an item is marked with a `stable` attribute, the modules that
24+
enclose the item must also be marked with `stable` attributes, otherwise the
25+
item becomes *de facto* unstable. `#[rustc_allowed_through_unstable_modules]`
26+
is a workaround which allows an item to "escape" its unstable parent modules.
27+
This error occurs when an item is marked with
28+
`#[rustc_allowed_through_unstable_modules]` but no supplementary `stable`
29+
attribute exists. See [#99288](https://github.com/rust-lang/rust/pull/99288)
30+
for an example of `#[rustc_allowed_through_unstable_modules]` in use.

compiler/rustc_middle/src/mir/basic_blocks.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ impl<'tcx> BasicBlocks<'tcx> {
4141
*self.cache.is_cyclic.get_or_init(|| graph::is_cyclic(self))
4242
}
4343

44-
#[inline]
4544
pub fn dominators(&self) -> Dominators<BasicBlock> {
4645
dominators(&self)
4746
}

compiler/rustc_middle/src/mir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3046,7 +3046,7 @@ impl Location {
30463046
if self.block == other.block {
30473047
self.statement_index <= other.statement_index
30483048
} else {
3049-
dominators.is_dominated_by(other.block, self.block)
3049+
dominators.dominates(self.block, other.block)
30503050
}
30513051
}
30523052
}

compiler/rustc_mir_transform/src/coverage/counters.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ impl<'a> BcbCounters<'a> {
520520
let mut found_loop_exit = false;
521521
for &branch in branches.iter() {
522522
if backedge_from_bcbs.iter().any(|&backedge_from_bcb| {
523-
self.bcb_is_dominated_by(backedge_from_bcb, branch.target_bcb)
523+
self.bcb_dominates(branch.target_bcb, backedge_from_bcb)
524524
}) {
525525
if let Some(reloop_branch) = some_reloop_branch {
526526
if reloop_branch.counter(&self.basic_coverage_blocks).is_none() {
@@ -603,8 +603,8 @@ impl<'a> BcbCounters<'a> {
603603
}
604604

605605
#[inline]
606-
fn bcb_is_dominated_by(&self, node: BasicCoverageBlock, dom: BasicCoverageBlock) -> bool {
607-
self.basic_coverage_blocks.is_dominated_by(node, dom)
606+
fn bcb_dominates(&self, dom: BasicCoverageBlock, node: BasicCoverageBlock) -> bool {
607+
self.basic_coverage_blocks.dominates(dom, node)
608608
}
609609

610610
#[inline]

compiler/rustc_mir_transform/src/coverage/graph.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ impl CoverageGraph {
209209
}
210210

211211
#[inline(always)]
212-
pub fn is_dominated_by(&self, node: BasicCoverageBlock, dom: BasicCoverageBlock) -> bool {
213-
self.dominators.as_ref().unwrap().is_dominated_by(node, dom)
212+
pub fn dominates(&self, dom: BasicCoverageBlock, node: BasicCoverageBlock) -> bool {
213+
self.dominators.as_ref().unwrap().dominates(dom, node)
214214
}
215215

216216
#[inline(always)]
@@ -312,7 +312,7 @@ rustc_index::newtype_index! {
312312
/// to the BCB's primary counter or expression).
313313
///
314314
/// The BCB CFG is critical to simplifying the coverage analysis by ensuring graph path-based
315-
/// queries (`is_dominated_by()`, `predecessors`, `successors`, etc.) have branch (control flow)
315+
/// queries (`dominates()`, `predecessors`, `successors`, etc.) have branch (control flow)
316316
/// significance.
317317
#[derive(Debug, Clone)]
318318
pub(super) struct BasicCoverageBlockData {
@@ -594,7 +594,7 @@ impl TraverseCoverageGraphWithLoops {
594594
// branching block would have given an `Expression` (or vice versa).
595595
let (some_successor_to_add, some_loop_header) =
596596
if let Some((_, loop_header)) = context.loop_backedges {
597-
if basic_coverage_blocks.is_dominated_by(successor, loop_header) {
597+
if basic_coverage_blocks.dominates(loop_header, successor) {
598598
(Some(successor), Some(loop_header))
599599
} else {
600600
(None, None)
@@ -666,15 +666,15 @@ pub(super) fn find_loop_backedges(
666666
//
667667
// The overall complexity appears to be comparable to many other MIR transform algorithms, and I
668668
// don't expect that this function is creating a performance hot spot, but if this becomes an
669-
// issue, there may be ways to optimize the `is_dominated_by` algorithm (as indicated by an
669+
// issue, there may be ways to optimize the `dominates` algorithm (as indicated by an
670670
// existing `FIXME` comment in that code), or possibly ways to optimize it's usage here, perhaps
671671
// by keeping track of results for visited `BasicCoverageBlock`s if they can be used to short
672-
// circuit downstream `is_dominated_by` checks.
672+
// circuit downstream `dominates` checks.
673673
//
674674
// For now, that kind of optimization seems unnecessarily complicated.
675675
for (bcb, _) in basic_coverage_blocks.iter_enumerated() {
676676
for &successor in &basic_coverage_blocks.successors[bcb] {
677-
if basic_coverage_blocks.is_dominated_by(bcb, successor) {
677+
if basic_coverage_blocks.dominates(successor, bcb) {
678678
let loop_header = successor;
679679
let backedge_from_bcb = bcb;
680680
debug!(

compiler/rustc_mir_transform/src/coverage/spans.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl CoverageStatement {
6363
/// Note: A `CoverageStatement` merged into another CoverageSpan may come from a `BasicBlock` that
6464
/// is not part of the `CoverageSpan` bcb if the statement was included because it's `Span` matches
6565
/// or is subsumed by the `Span` associated with this `CoverageSpan`, and it's `BasicBlock`
66-
/// `is_dominated_by()` the `BasicBlock`s in this `CoverageSpan`.
66+
/// `dominates()` the `BasicBlock`s in this `CoverageSpan`.
6767
#[derive(Debug, Clone)]
6868
pub(super) struct CoverageSpan {
6969
pub span: Span,
@@ -705,12 +705,12 @@ impl<'a, 'tcx> CoverageSpans<'a, 'tcx> {
705705
fn hold_pending_dups_unless_dominated(&mut self) {
706706
// Equal coverage spans are ordered by dominators before dominated (if any), so it should be
707707
// impossible for `curr` to dominate any previous `CoverageSpan`.
708-
debug_assert!(!self.span_bcb_is_dominated_by(self.prev(), self.curr()));
708+
debug_assert!(!self.span_bcb_dominates(self.curr(), self.prev()));
709709

710710
let initial_pending_count = self.pending_dups.len();
711711
if initial_pending_count > 0 {
712712
let mut pending_dups = self.pending_dups.split_off(0);
713-
pending_dups.retain(|dup| !self.span_bcb_is_dominated_by(self.curr(), dup));
713+
pending_dups.retain(|dup| !self.span_bcb_dominates(dup, self.curr()));
714714
self.pending_dups.append(&mut pending_dups);
715715
if self.pending_dups.len() < initial_pending_count {
716716
debug!(
@@ -721,7 +721,7 @@ impl<'a, 'tcx> CoverageSpans<'a, 'tcx> {
721721
}
722722
}
723723

724-
if self.span_bcb_is_dominated_by(self.curr(), self.prev()) {
724+
if self.span_bcb_dominates(self.prev(), self.curr()) {
725725
debug!(
726726
" different bcbs but SAME spans, and prev dominates curr. Discard prev={:?}",
727727
self.prev()
@@ -787,8 +787,8 @@ impl<'a, 'tcx> CoverageSpans<'a, 'tcx> {
787787
}
788788
}
789789

790-
fn span_bcb_is_dominated_by(&self, covspan: &CoverageSpan, dom_covspan: &CoverageSpan) -> bool {
791-
self.basic_coverage_blocks.is_dominated_by(covspan.bcb, dom_covspan.bcb)
790+
fn span_bcb_dominates(&self, dom_covspan: &CoverageSpan, covspan: &CoverageSpan) -> bool {
791+
self.basic_coverage_blocks.dominates(dom_covspan.bcb, covspan.bcb)
792792
}
793793
}
794794

compiler/rustc_target/src/spec/bpf_base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub fn opts(endian: Endian) -> TargetOptions {
66
allow_asm: true,
77
endian,
88
linker_flavor: LinkerFlavor::Bpf,
9-
atomic_cas: true,
9+
atomic_cas: false,
1010
dynamic_linking: true,
1111
no_builtins: true,
1212
panic_strategy: PanicStrategy::Abort,

compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
174174
.param_env
175175
.caller_bounds()
176176
.iter()
177-
.filter_map(|p| p.to_opt_poly_trait_pred())
178-
.filter(|p| !p.references_error());
177+
.filter(|p| !p.references_error())
178+
.filter_map(|p| p.to_opt_poly_trait_pred());
179179

180180
// Micro-optimization: filter out predicates relating to different traits.
181181
let matching_bounds =

0 commit comments

Comments
 (0)