Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 7 pull requests #107220

Merged
merged 14 commits into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_data_structures/src/graph/dominators/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ impl<Node: Idx> Dominators<Node> {
Iter { dominators: self, node: Some(node) }
}

pub fn is_dominated_by(&self, node: Node, dom: Node) -> bool {
pub fn dominates(&self, dom: Node, node: Node) -> bool {
// FIXME -- could be optimized by using post-order-rank
self.dominators(node).any(|n| n == dom)
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_error_codes/src/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ E0785: include_str!("./error_codes/E0785.md"),
E0786: include_str!("./error_codes/E0786.md"),
E0787: include_str!("./error_codes/E0787.md"),
E0788: include_str!("./error_codes/E0788.md"),
E0789: include_str!("./error_codes/E0789.md"),
E0790: include_str!("./error_codes/E0790.md"),
E0791: include_str!("./error_codes/E0791.md"),
E0792: include_str!("./error_codes/E0792.md"),
Expand Down Expand Up @@ -645,5 +646,4 @@ E0792: include_str!("./error_codes/E0792.md"),
// E0721, // `await` keyword
// E0723, // unstable feature in `const` context
// E0738, // Removed; errored on `#[track_caller] fn`s in `extern "Rust" { ... }`.
E0789, // rustc_allowed_through_unstable_modules without stability attribute
}
30 changes: 30 additions & 0 deletions compiler/rustc_error_codes/src/error_codes/E0789.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#### This error code is internal to the compiler and will not be emitted with normal Rust code.

The internal `rustc_allowed_through_unstable_modules` attribute must be used
on an item with a `stable` attribute.

Erroneous code example:

```compile_fail,E0789
// NOTE: both of these attributes are perma-unstable and should *never* be
// used outside of the compiler and standard library.
#![feature(rustc_attrs)]
#![feature(staged_api)]

#![unstable(feature = "foo_module", reason = "...", issue = "123")]

#[rustc_allowed_through_unstable_modules]
// #[stable(feature = "foo", since = "1.0")]
struct Foo;
// ^^^ error: `rustc_allowed_through_unstable_modules` attribute must be
// paired with a `stable` attribute
```

Typically when an item is marked with a `stable` attribute, the modules that
enclose the item must also be marked with `stable` attributes, otherwise the
item becomes *de facto* unstable. `#[rustc_allowed_through_unstable_modules]`
is a workaround which allows an item to "escape" its unstable parent modules.
This error occurs when an item is marked with
`#[rustc_allowed_through_unstable_modules]` but no supplementary `stable`
attribute exists. See [#99288](https://github.com/rust-lang/rust/pull/99288)
for an example of `#[rustc_allowed_through_unstable_modules]` in use.
1 change: 0 additions & 1 deletion compiler/rustc_middle/src/mir/basic_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ impl<'tcx> BasicBlocks<'tcx> {
*self.cache.is_cyclic.get_or_init(|| graph::is_cyclic(self))
}

#[inline]
pub fn dominators(&self) -> Dominators<BasicBlock> {
dominators(&self)
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3046,7 +3046,7 @@ impl Location {
if self.block == other.block {
self.statement_index <= other.statement_index
} else {
dominators.is_dominated_by(other.block, self.block)
dominators.dominates(self.block, other.block)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_mir_transform/src/coverage/counters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ impl<'a> BcbCounters<'a> {
let mut found_loop_exit = false;
for &branch in branches.iter() {
if backedge_from_bcbs.iter().any(|&backedge_from_bcb| {
self.bcb_is_dominated_by(backedge_from_bcb, branch.target_bcb)
self.bcb_dominates(branch.target_bcb, backedge_from_bcb)
}) {
if let Some(reloop_branch) = some_reloop_branch {
if reloop_branch.counter(&self.basic_coverage_blocks).is_none() {
Expand Down Expand Up @@ -603,8 +603,8 @@ impl<'a> BcbCounters<'a> {
}

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

#[inline]
Expand Down
14 changes: 7 additions & 7 deletions compiler/rustc_mir_transform/src/coverage/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ impl CoverageGraph {
}

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

#[inline(always)]
Expand Down Expand Up @@ -312,7 +312,7 @@ rustc_index::newtype_index! {
/// to the BCB's primary counter or expression).
///
/// The BCB CFG is critical to simplifying the coverage analysis by ensuring graph path-based
/// queries (`is_dominated_by()`, `predecessors`, `successors`, etc.) have branch (control flow)
/// queries (`dominates()`, `predecessors`, `successors`, etc.) have branch (control flow)
/// significance.
#[derive(Debug, Clone)]
pub(super) struct BasicCoverageBlockData {
Expand Down Expand Up @@ -594,7 +594,7 @@ impl TraverseCoverageGraphWithLoops {
// branching block would have given an `Expression` (or vice versa).
let (some_successor_to_add, some_loop_header) =
if let Some((_, loop_header)) = context.loop_backedges {
if basic_coverage_blocks.is_dominated_by(successor, loop_header) {
if basic_coverage_blocks.dominates(loop_header, successor) {
(Some(successor), Some(loop_header))
} else {
(None, None)
Expand Down Expand Up @@ -666,15 +666,15 @@ pub(super) fn find_loop_backedges(
//
// The overall complexity appears to be comparable to many other MIR transform algorithms, and I
// don't expect that this function is creating a performance hot spot, but if this becomes an
// issue, there may be ways to optimize the `is_dominated_by` algorithm (as indicated by an
// issue, there may be ways to optimize the `dominates` algorithm (as indicated by an
// existing `FIXME` comment in that code), or possibly ways to optimize it's usage here, perhaps
// by keeping track of results for visited `BasicCoverageBlock`s if they can be used to short
// circuit downstream `is_dominated_by` checks.
// circuit downstream `dominates` checks.
//
// For now, that kind of optimization seems unnecessarily complicated.
for (bcb, _) in basic_coverage_blocks.iter_enumerated() {
for &successor in &basic_coverage_blocks.successors[bcb] {
if basic_coverage_blocks.is_dominated_by(bcb, successor) {
if basic_coverage_blocks.dominates(successor, bcb) {
let loop_header = successor;
let backedge_from_bcb = bcb;
debug!(
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_mir_transform/src/coverage/spans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl CoverageStatement {
/// Note: A `CoverageStatement` merged into another CoverageSpan may come from a `BasicBlock` that
/// is not part of the `CoverageSpan` bcb if the statement was included because it's `Span` matches
/// or is subsumed by the `Span` associated with this `CoverageSpan`, and it's `BasicBlock`
/// `is_dominated_by()` the `BasicBlock`s in this `CoverageSpan`.
/// `dominates()` the `BasicBlock`s in this `CoverageSpan`.
#[derive(Debug, Clone)]
pub(super) struct CoverageSpan {
pub span: Span,
Expand Down Expand Up @@ -705,12 +705,12 @@ impl<'a, 'tcx> CoverageSpans<'a, 'tcx> {
fn hold_pending_dups_unless_dominated(&mut self) {
// Equal coverage spans are ordered by dominators before dominated (if any), so it should be
// impossible for `curr` to dominate any previous `CoverageSpan`.
debug_assert!(!self.span_bcb_is_dominated_by(self.prev(), self.curr()));
debug_assert!(!self.span_bcb_dominates(self.curr(), self.prev()));

let initial_pending_count = self.pending_dups.len();
if initial_pending_count > 0 {
let mut pending_dups = self.pending_dups.split_off(0);
pending_dups.retain(|dup| !self.span_bcb_is_dominated_by(self.curr(), dup));
pending_dups.retain(|dup| !self.span_bcb_dominates(dup, self.curr()));
self.pending_dups.append(&mut pending_dups);
if self.pending_dups.len() < initial_pending_count {
debug!(
Expand All @@ -721,7 +721,7 @@ impl<'a, 'tcx> CoverageSpans<'a, 'tcx> {
}
}

if self.span_bcb_is_dominated_by(self.curr(), self.prev()) {
if self.span_bcb_dominates(self.prev(), self.curr()) {
debug!(
" different bcbs but SAME spans, and prev dominates curr. Discard prev={:?}",
self.prev()
Expand Down Expand Up @@ -787,8 +787,8 @@ impl<'a, 'tcx> CoverageSpans<'a, 'tcx> {
}
}

fn span_bcb_is_dominated_by(&self, covspan: &CoverageSpan, dom_covspan: &CoverageSpan) -> bool {
self.basic_coverage_blocks.is_dominated_by(covspan.bcb, dom_covspan.bcb)
fn span_bcb_dominates(&self, dom_covspan: &CoverageSpan, covspan: &CoverageSpan) -> bool {
self.basic_coverage_blocks.dominates(dom_covspan.bcb, covspan.bcb)
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/bpf_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub fn opts(endian: Endian) -> TargetOptions {
allow_asm: true,
endian,
linker_flavor: LinkerFlavor::Bpf,
atomic_cas: true,
atomic_cas: false,
dynamic_linking: true,
no_builtins: true,
panic_strategy: PanicStrategy::Abort,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
.param_env
.caller_bounds()
.iter()
.filter_map(|p| p.to_opt_poly_trait_pred())
.filter(|p| !p.references_error());
.filter(|p| !p.references_error())
.filter_map(|p| p.to_opt_poly_trait_pred());

// Micro-optimization: filter out predicates relating to different traits.
let matching_bounds =
Expand Down
23 changes: 18 additions & 5 deletions config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,24 @@ changelog-seen = 2
# be built if `extended = true`.
#extended = false

# Installs chosen set of extended tools if `extended = true`. By default builds
# all extended tools except `rust-demangler`, unless the target is also being
# built with `profiler = true`. If chosen tool failed to build the installation
# fails. If `extended = false`, this option is ignored.
#tools = ["cargo", "rls", "clippy", "rustfmt", "analysis", "src"] # + "rust-demangler" if `profiler`
# Set of tools to be included in the installation.
#
# If `extended = false`, the only one of these built by default is rustdoc.
#
# If `extended = true`, they're all included, with the exception of
# rust-demangler which additionally requires `profiler = true` to be set.
#
# If any enabled tool fails to build, the installation fails.
#tools = [
# "cargo",
# "clippy",
# "rustdoc",
# "rustfmt",
# "rust-analyzer",
# "analysis",
# "src",
# "rust-demangler", # if profiler = true
#]

# Verbosity level: 0 == not verbose, 1 == verbose, 2 == very verbose
#verbose = 0
Expand Down
8 changes: 6 additions & 2 deletions library/alloc/src/boxed/thin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ unsafe impl<T: ?Sized + Sync> Sync for ThinBox<T> {}

#[unstable(feature = "thin_box", issue = "92791")]
impl<T> ThinBox<T> {
/// Moves a type to the heap with its `Metadata` stored in the heap allocation instead of on
/// Moves a type to the heap with its [`Metadata`] stored in the heap allocation instead of on
/// the stack.
///
/// # Examples
Expand All @@ -59,6 +59,8 @@ impl<T> ThinBox<T> {
///
/// let five = ThinBox::new(5);
/// ```
///
/// [`Metadata`]: core::ptr::Pointee::Metadata
#[cfg(not(no_global_oom_handling))]
pub fn new(value: T) -> Self {
let meta = ptr::metadata(&value);
Expand All @@ -69,7 +71,7 @@ impl<T> ThinBox<T> {

#[unstable(feature = "thin_box", issue = "92791")]
impl<Dyn: ?Sized> ThinBox<Dyn> {
/// Moves a type to the heap with its `Metadata` stored in the heap allocation instead of on
/// Moves a type to the heap with its [`Metadata`] stored in the heap allocation instead of on
/// the stack.
///
/// # Examples
Expand All @@ -80,6 +82,8 @@ impl<Dyn: ?Sized> ThinBox<Dyn> {
///
/// let thin_slice = ThinBox::<[i32]>::new_unsize([1, 2, 3, 4]);
/// ```
///
/// [`Metadata`]: core::ptr::Pointee::Metadata
#[cfg(not(no_global_oom_handling))]
pub fn new_unsize<T>(value: T) -> Self
where
Expand Down
22 changes: 16 additions & 6 deletions src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,19 +392,29 @@ impl Step for Rustc {
t!(fs::create_dir_all(image.join("bin")));
builder.cp_r(&src.join("bin"), &image.join("bin"));

builder.install(&builder.rustdoc(compiler), &image.join("bin"), 0o755);
if builder
.config
.tools
.as_ref()
.map_or(true, |tools| tools.iter().any(|tool| tool == "rustdoc"))
{
let rustdoc = builder.rustdoc(compiler);
builder.install(&rustdoc, &image.join("bin"), 0o755);
}

let ra_proc_macro_srv = builder
.ensure(tool::RustAnalyzerProcMacroSrv {
if let Some(ra_proc_macro_srv) = builder.ensure_if_default(
tool::RustAnalyzerProcMacroSrv {
compiler: builder.compiler_for(
compiler.stage,
builder.config.build,
compiler.host,
),
target: compiler.host,
})
.expect("rust-analyzer-proc-macro-server always builds");
builder.install(&ra_proc_macro_srv, &image.join("libexec"), 0o755);
},
builder.kind,
) {
builder.install(&ra_proc_macro_srv, &image.join("libexec"), 0o755);
}

let libdir_relative = builder.libdir_relative(compiler);

Expand Down
6 changes: 6 additions & 0 deletions src/bootstrap/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -765,9 +765,15 @@ impl Step for RustAnalyzerProcMacroSrv {
const ONLY_HOSTS: bool = true;

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

fn make_run(run: RunConfig<'_>) {
Expand Down
2 changes: 1 addition & 1 deletion src/tools/tidy/src/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const IGNORE_DOCTEST_CHECK: &[&str] = &["E0464", "E0570", "E0601", "E0602", "E06

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

macro_rules! verbose_print {
($verbose:expr, $($fmt:tt)*) => {
Expand Down
12 changes: 12 additions & 0 deletions tests/ui/error-codes/E0789.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// compile-flags: --crate-type lib

#![feature(rustc_attrs)]
#![feature(staged_api)]
#![unstable(feature = "foo_module", reason = "...", issue = "123")]

#[rustc_allowed_through_unstable_modules]
// #[stable(feature = "foo", since = "1.0")]
struct Foo;
//~^ ERROR `rustc_allowed_through_unstable_modules` attribute must be paired with a `stable` attribute
//~^^ ERROR `rustc_allowed_through_unstable_modules` attribute must be paired with a `stable` attribute
// FIXME: we shouldn't have two errors here, only occurs when using `-Zdeduplicate-diagnostics=no`
15 changes: 15 additions & 0 deletions tests/ui/error-codes/E0789.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
error[E0789]: `rustc_allowed_through_unstable_modules` attribute must be paired with a `stable` attribute
--> $DIR/E0789.rs:9:1
|
LL | struct Foo;
| ^^^^^^^^^^^

error[E0789]: `rustc_allowed_through_unstable_modules` attribute must be paired with a `stable` attribute
--> $DIR/E0789.rs:9:1
|
LL | struct Foo;
| ^^^^^^^^^^^

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0789`.