Skip to content

Commit c8e6a9e

Browse files
committed
Auto merge of #107220 - JohnTitor:rollup-5pvuz0z, r=JohnTitor
Rollup of 7 pull requests Successful merges: - #106796 (BPF: Disable atomic CAS) - #106886 (Make stage2 rustdoc and proc-macro-srv disableable in x.py install) - #107101 (Filter param-env predicates for errors before calling `to_opt_poly_trait_pred`) - #107109 (ThinBox: Add intra-doc-links for Metadata) - #107148 (remove error code from `E0789`, add UI test/docs) - #107151 (Instantiate dominators algorithm only once) - #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

+1-1
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

+1-1
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
}
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

-1
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

+1-1
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

+3-3
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

+7-7
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

+6-6
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

+1-1
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

+2-2
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 =

config.toml.example

+18-5
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,24 @@ changelog-seen = 2
285285
# be built if `extended = true`.
286286
#extended = false
287287

288-
# Installs chosen set of extended tools if `extended = true`. By default builds
289-
# all extended tools except `rust-demangler`, unless the target is also being
290-
# built with `profiler = true`. If chosen tool failed to build the installation
291-
# fails. If `extended = false`, this option is ignored.
292-
#tools = ["cargo", "rls", "clippy", "rustfmt", "analysis", "src"] # + "rust-demangler" if `profiler`
288+
# Set of tools to be included in the installation.
289+
#
290+
# If `extended = false`, the only one of these built by default is rustdoc.
291+
#
292+
# If `extended = true`, they're all included, with the exception of
293+
# rust-demangler which additionally requires `profiler = true` to be set.
294+
#
295+
# If any enabled tool fails to build, the installation fails.
296+
#tools = [
297+
# "cargo",
298+
# "clippy",
299+
# "rustdoc",
300+
# "rustfmt",
301+
# "rust-analyzer",
302+
# "analysis",
303+
# "src",
304+
# "rust-demangler", # if profiler = true
305+
#]
293306

294307
# Verbosity level: 0 == not verbose, 1 == verbose, 2 == very verbose
295308
#verbose = 0

library/alloc/src/boxed/thin.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ unsafe impl<T: ?Sized + Sync> Sync for ThinBox<T> {}
4848

4949
#[unstable(feature = "thin_box", issue = "92791")]
5050
impl<T> ThinBox<T> {
51-
/// Moves a type to the heap with its `Metadata` stored in the heap allocation instead of on
51+
/// Moves a type to the heap with its [`Metadata`] stored in the heap allocation instead of on
5252
/// the stack.
5353
///
5454
/// # Examples
@@ -59,6 +59,8 @@ impl<T> ThinBox<T> {
5959
///
6060
/// let five = ThinBox::new(5);
6161
/// ```
62+
///
63+
/// [`Metadata`]: core::ptr::Pointee::Metadata
6264
#[cfg(not(no_global_oom_handling))]
6365
pub fn new(value: T) -> Self {
6466
let meta = ptr::metadata(&value);
@@ -69,7 +71,7 @@ impl<T> ThinBox<T> {
6971

7072
#[unstable(feature = "thin_box", issue = "92791")]
7173
impl<Dyn: ?Sized> ThinBox<Dyn> {
72-
/// Moves a type to the heap with its `Metadata` stored in the heap allocation instead of on
74+
/// Moves a type to the heap with its [`Metadata`] stored in the heap allocation instead of on
7375
/// the stack.
7476
///
7577
/// # Examples
@@ -80,6 +82,8 @@ impl<Dyn: ?Sized> ThinBox<Dyn> {
8082
///
8183
/// let thin_slice = ThinBox::<[i32]>::new_unsize([1, 2, 3, 4]);
8284
/// ```
85+
///
86+
/// [`Metadata`]: core::ptr::Pointee::Metadata
8387
#[cfg(not(no_global_oom_handling))]
8488
pub fn new_unsize<T>(value: T) -> Self
8589
where

src/bootstrap/dist.rs

+16-6
Original file line numberDiff line numberDiff line change
@@ -392,19 +392,29 @@ impl Step for Rustc {
392392
t!(fs::create_dir_all(image.join("bin")));
393393
builder.cp_r(&src.join("bin"), &image.join("bin"));
394394

395-
builder.install(&builder.rustdoc(compiler), &image.join("bin"), 0o755);
395+
if builder
396+
.config
397+
.tools
398+
.as_ref()
399+
.map_or(true, |tools| tools.iter().any(|tool| tool == "rustdoc"))
400+
{
401+
let rustdoc = builder.rustdoc(compiler);
402+
builder.install(&rustdoc, &image.join("bin"), 0o755);
403+
}
396404

397-
let ra_proc_macro_srv = builder
398-
.ensure(tool::RustAnalyzerProcMacroSrv {
405+
if let Some(ra_proc_macro_srv) = builder.ensure_if_default(
406+
tool::RustAnalyzerProcMacroSrv {
399407
compiler: builder.compiler_for(
400408
compiler.stage,
401409
builder.config.build,
402410
compiler.host,
403411
),
404412
target: compiler.host,
405-
})
406-
.expect("rust-analyzer-proc-macro-server always builds");
407-
builder.install(&ra_proc_macro_srv, &image.join("libexec"), 0o755);
413+
},
414+
builder.kind,
415+
) {
416+
builder.install(&ra_proc_macro_srv, &image.join("libexec"), 0o755);
417+
}
408418

409419
let libdir_relative = builder.libdir_relative(compiler);
410420

src/bootstrap/tool.rs

+6
Original file line numberDiff line numberDiff line change
@@ -765,9 +765,15 @@ impl Step for RustAnalyzerProcMacroSrv {
765765
const ONLY_HOSTS: bool = true;
766766

767767
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
768+
let builder = run.builder;
768769
// Allow building `rust-analyzer-proc-macro-srv` both as part of the `rust-analyzer` and as a stand-alone tool.
769770
run.path("src/tools/rust-analyzer")
770771
.path("src/tools/rust-analyzer/crates/proc-macro-srv-cli")
772+
.default_condition(builder.config.tools.as_ref().map_or(true, |tools| {
773+
tools
774+
.iter()
775+
.any(|tool| tool == "rust-analyzer" || tool == "rust-analyzer-proc-macro-srv")
776+
}))
771777
}
772778

773779
fn make_run(run: RunConfig<'_>) {

src/tools/tidy/src/error_codes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const IGNORE_DOCTEST_CHECK: &[&str] = &["E0464", "E0570", "E0601", "E0602", "E06
3131

3232
// Error codes that don't yet have a UI test. This list will eventually be removed.
3333
const IGNORE_UI_TEST_CHECK: &[&str] =
34-
&["E0461", "E0465", "E0476", "E0514", "E0523", "E0554", "E0640", "E0717", "E0729", "E0789"];
34+
&["E0461", "E0465", "E0476", "E0514", "E0523", "E0554", "E0640", "E0717", "E0729"];
3535

3636
macro_rules! verbose_print {
3737
($verbose:expr, $($fmt:tt)*) => {

tests/ui/error-codes/E0789.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// compile-flags: --crate-type lib
2+
3+
#![feature(rustc_attrs)]
4+
#![feature(staged_api)]
5+
#![unstable(feature = "foo_module", reason = "...", issue = "123")]
6+
7+
#[rustc_allowed_through_unstable_modules]
8+
// #[stable(feature = "foo", since = "1.0")]
9+
struct Foo;
10+
//~^ ERROR `rustc_allowed_through_unstable_modules` attribute must be paired with a `stable` attribute
11+
//~^^ ERROR `rustc_allowed_through_unstable_modules` attribute must be paired with a `stable` attribute
12+
// FIXME: we shouldn't have two errors here, only occurs when using `-Zdeduplicate-diagnostics=no`

tests/ui/error-codes/E0789.stderr

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0789]: `rustc_allowed_through_unstable_modules` attribute must be paired with a `stable` attribute
2+
--> $DIR/E0789.rs:9:1
3+
|
4+
LL | struct Foo;
5+
| ^^^^^^^^^^^
6+
7+
error[E0789]: `rustc_allowed_through_unstable_modules` attribute must be paired with a `stable` attribute
8+
--> $DIR/E0789.rs:9:1
9+
|
10+
LL | struct Foo;
11+
| ^^^^^^^^^^^
12+
13+
error: aborting due to 2 previous errors
14+
15+
For more information about this error, try `rustc --explain E0789`.

0 commit comments

Comments
 (0)