Skip to content

Commit

Permalink
Auto merge of #109966 - JohnTitor:rollup-eoqjr5j, r=JohnTitor
Browse files Browse the repository at this point in the history
Rollup of 6 pull requests

Successful merges:

 - #107236 (Add T-bootstrap label to tools)
 - #109847 (Only create graphviz nodes for reachable MIR bb's)
 - #109848 (submodule detection for proper fix on #96188)
 - #109932 (Source code scrollbar)
 - #109952 (Move comment about python2 closer to the place it's used)
 - #109956 (Tweak debug outputs to make debugging new solver easier)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Apr 5, 2023
2 parents 383c1d7 + 038ece0 commit 4cb92cc
Show file tree
Hide file tree
Showing 18 changed files with 145 additions and 67 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/infer/canonical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ use std::ops::Index;
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, TyDecodable, TyEncodable)]
#[derive(HashStable, TypeFoldable, TypeVisitable, Lift)]
pub struct Canonical<'tcx, V> {
pub value: V,
pub max_universe: ty::UniverseIndex,
pub variables: CanonicalVarInfos<'tcx>,
pub value: V,
}

pub type CanonicalVarInfos<'tcx> = &'tcx List<CanonicalVarInfo<'tcx>>;
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/traits/solve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ pub type EvaluationCache<'tcx> = Cache<CanonicalGoal<'tcx>, QueryResult<'tcx>>;
/// we're currently typechecking while the `predicate` is some trait bound.
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, TypeFoldable, TypeVisitable)]
pub struct Goal<'tcx, P> {
pub param_env: ty::ParamEnv<'tcx>,
pub predicate: P,
pub param_env: ty::ParamEnv<'tcx>,
}

impl<'tcx, P> Goal<'tcx, P> {
Expand All @@ -41,10 +41,10 @@ impl<'tcx, P> Goal<'tcx, P> {

#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, TypeFoldable, TypeVisitable)]
pub struct Response<'tcx> {
pub certainty: Certainty,
pub var_values: CanonicalVarValues<'tcx>,
/// Additional constraints returned by this query.
pub external_constraints: ExternalConstraints<'tcx>,
pub certainty: Certainty,
}

#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, TypeFoldable, TypeVisitable)]
Expand Down
12 changes: 10 additions & 2 deletions compiler/rustc_mir_dataflow/src/framework/graphviz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::{io, ops, str};

use regex::Regex;
use rustc_graphviz as dot;
use rustc_index::bit_set::BitSet;
use rustc_middle::mir::graphviz_safe_def_name;
use rustc_middle::mir::{self, BasicBlock, Body, Location};

Expand Down Expand Up @@ -34,14 +35,16 @@ where
body: &'a Body<'tcx>,
results: &'a Results<'tcx, A>,
style: OutputStyle,
reachable: BitSet<BasicBlock>,
}

impl<'a, 'tcx, A> Formatter<'a, 'tcx, A>
where
A: Analysis<'tcx>,
{
pub fn new(body: &'a Body<'tcx>, results: &'a Results<'tcx, A>, style: OutputStyle) -> Self {
Formatter { body, results, style }
let reachable = mir::traversal::reachable_as_bitset(body);
Formatter { body, results, style, reachable }
}
}

Expand Down Expand Up @@ -108,7 +111,12 @@ where
type Edge = CfgEdge;

fn nodes(&self) -> dot::Nodes<'_, Self::Node> {
self.body.basic_blocks.indices().collect::<Vec<_>>().into()
self.body
.basic_blocks
.indices()
.filter(|&idx| self.reachable.contains(idx))
.collect::<Vec<_>>()
.into()
}

fn edges(&self) -> dot::Edges<'_, Self::Edge> {
Expand Down
7 changes: 7 additions & 0 deletions compiler/rustc_trait_selection/src/solve/assembly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
/// To deal with this, we first try to normalize the self type and add the candidates for the normalized
/// self type to the list of candidates in case that succeeds. We also have to consider candidates with the
/// projection as a self type as well
#[instrument(level = "debug", skip_all)]
fn assemble_candidates_after_normalizing_self_ty<G: GoalKind<'tcx>>(
&mut self,
goal: Goal<'tcx, G>,
Expand Down Expand Up @@ -315,6 +316,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
}
}

#[instrument(level = "debug", skip_all)]
fn assemble_impl_candidates<G: GoalKind<'tcx>>(
&mut self,
goal: Goal<'tcx, G>,
Expand All @@ -333,6 +335,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
);
}

#[instrument(level = "debug", skip_all)]
fn assemble_builtin_impl_candidates<G: GoalKind<'tcx>>(
&mut self,
goal: Goal<'tcx, G>,
Expand Down Expand Up @@ -390,6 +393,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
}
}

#[instrument(level = "debug", skip_all)]
fn assemble_param_env_candidates<G: GoalKind<'tcx>>(
&mut self,
goal: Goal<'tcx, G>,
Expand All @@ -405,6 +409,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
}
}

#[instrument(level = "debug", skip_all)]
fn assemble_alias_bound_candidates<G: GoalKind<'tcx>>(
&mut self,
goal: Goal<'tcx, G>,
Expand Down Expand Up @@ -452,6 +457,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
}
}

#[instrument(level = "debug", skip_all)]
fn assemble_object_bound_candidates<G: GoalKind<'tcx>>(
&mut self,
goal: Goal<'tcx, G>,
Expand Down Expand Up @@ -514,6 +520,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
}
}

#[instrument(level = "debug", skip_all)]
fn assemble_coherence_unknowable_candidates<G: GoalKind<'tcx>>(
&mut self,
goal: Goal<'tcx, G>,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_trait_selection/src/solve/eval_ctxt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pub trait InferCtxtEvalExt<'tcx> {
}

impl<'tcx> InferCtxtEvalExt<'tcx> for InferCtxt<'tcx> {
#[instrument(level = "debug", skip(self))]
#[instrument(level = "debug", skip(self), ret)]
fn evaluate_root_goal(
&self,
goal: Goal<'tcx, ty::Predicate<'tcx>>,
Expand Down Expand Up @@ -552,7 +552,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
///
/// If possible, try using `eq` instead which automatically handles nested
/// goals correctly.
#[instrument(level = "debug", skip(self, param_env), ret)]
#[instrument(level = "trace", skip(self, param_env), ret)]
pub(super) fn eq_and_get_goals<T: ToTrace<'tcx>>(
&self,
param_env: ty::ParamEnv<'tcx>,
Expand Down
26 changes: 21 additions & 5 deletions compiler/rustc_trait_selection/src/solve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,22 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
) -> QueryResult<'tcx> {
let tcx = self.tcx();
// We may need to invert the alias relation direction if dealing an alias on the RHS.
#[derive(Debug)]
enum Invert {
No,
Yes,
}
let evaluate_normalizes_to =
|ecx: &mut EvalCtxt<'_, 'tcx>, alias, other, direction, invert| {
debug!("evaluate_normalizes_to(alias={:?}, other={:?})", alias, other);
let span = tracing::span!(
tracing::Level::DEBUG,
"compute_alias_relate_goal(evaluate_normalizes_to)",
?alias,
?other,
?direction,
?invert
);
let _enter = span.enter();
let result = ecx.probe(|ecx| {
let other = match direction {
// This is purely an optimization.
Expand All @@ -184,7 +193,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
));
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
});
debug!("evaluate_normalizes_to({alias}, {other}, {direction:?}) -> {result:?}");
debug!(?result);
result
};

Expand All @@ -210,7 +219,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
}

(Some(alias_lhs), Some(alias_rhs)) => {
debug!("compute_alias_relate_goal: both sides are aliases");
debug!("both sides are aliases");

let candidates = vec![
// LHS normalizes-to RHS
Expand All @@ -219,9 +228,14 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
evaluate_normalizes_to(self, alias_rhs, lhs, direction, Invert::Yes),
// Relate via substs
self.probe(|ecx| {
debug!(
"compute_alias_relate_goal: alias defids are equal, equating substs"
let span = tracing::span!(
tracing::Level::DEBUG,
"compute_alias_relate_goal(relate_via_substs)",
?alias_lhs,
?alias_rhs,
?direction
);
let _enter = span.enter();

match direction {
ty::AliasRelationDirection::Equate => {
Expand Down Expand Up @@ -275,6 +289,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
debug!("added_goals={:?}", &self.nested_goals.goals[current_len..]);
}

#[instrument(level = "debug", skip(self, responses))]
fn try_merge_responses(
&mut self,
responses: impl Iterator<Item = QueryResult<'tcx>>,
Expand Down Expand Up @@ -304,6 +319,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
});
// FIXME(-Ztrait-solver=next): We should take the intersection of the constraints on all the
// responses and use that for the constraints of this ambiguous response.
debug!(">1 response, bailing with {certainty:?}");
let response = self.evaluate_added_goals_and_make_canonical_response(certainty);
if let Ok(response) = &response {
assert!(response.has_no_inference_or_external_constraints());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ impl<'tcx> SearchGraph<'tcx> {
) -> QueryResult<'tcx> {
if self.should_use_global_cache() {
if let Some(result) = tcx.new_solver_evaluation_cache.get(&canonical_goal, tcx) {
debug!(?canonical_goal, ?result, "cache hit");
return result;
}
}
Expand Down
50 changes: 40 additions & 10 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ use std::collections::BTreeSet;
use std::env;
use std::ffi::OsStr;
use std::fmt::{Debug, Write};
use std::fs::{self};
use std::fs::{self, File};
use std::hash::Hash;
use std::io::{BufRead, BufReader};
use std::ops::Deref;
use std::path::{Component, Path, PathBuf};
use std::process::Command;
Expand All @@ -28,8 +29,11 @@ use crate::{clean, dist};
use crate::{Build, CLang, DocTests, GitRepo, Mode};

pub use crate::Compiler;
// FIXME: replace with std::lazy after it gets stabilized and reaches beta
use once_cell::sync::Lazy;
// FIXME:
// - use std::lazy for `Lazy`
// - use std::cell for `OnceCell`
// Once they get stabilized and reach beta.
use once_cell::sync::{Lazy, OnceCell};

pub struct Builder<'a> {
pub build: &'a Build,
Expand Down Expand Up @@ -484,17 +488,43 @@ impl<'a> ShouldRun<'a> {

// multiple aliases for the same job
pub fn paths(mut self, paths: &[&str]) -> Self {
static SUBMODULES_PATHS: OnceCell<Vec<String>> = OnceCell::new();

let init_submodules_paths = |src: &PathBuf| {
let file = File::open(src.join(".gitmodules")).unwrap();

let mut submodules_paths = vec![];
for line in BufReader::new(file).lines() {
if let Ok(line) = line {
let line = line.trim();

if line.starts_with("path") {
let actual_path =
line.split(' ').last().expect("Couldn't get value of path");
submodules_paths.push(actual_path.to_owned());
}
}
}

submodules_paths
};

let submodules_paths =
SUBMODULES_PATHS.get_or_init(|| init_submodules_paths(&self.builder.src));

self.paths.insert(PathSet::Set(
paths
.iter()
.map(|p| {
// FIXME(#96188): make sure this is actually a path.
// This currently breaks for paths within submodules.
//assert!(
// self.builder.src.join(p).exists(),
// "`should_run.paths` should correspond to real on-disk paths - use `alias` if there is no relevant path: {}",
// p
//);
// assert only if `p` isn't submodule
if !submodules_paths.iter().find(|sm_p| p.contains(*sm_p)).is_some() {
assert!(
self.builder.src.join(p).exists(),
"`should_run.paths` should correspond to real on-disk paths - use `alias` if there is no relevant path: {}",
p
);
}

TaskPath { path: p.into(), kind: Some(self.kind) }
})
.collect(),
Expand Down
4 changes: 2 additions & 2 deletions src/ci/docker/host-x86_64/mingw-check-tidy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
FROM ubuntu:22.04

ARG DEBIAN_FRONTEND=noninteractive
# NOTE: intentionally uses python2 for x.py so we can test it still works.
# validate-toolstate only runs in our CI, so it's ok for it to only support python3.
RUN apt-get update && apt-get install -y --no-install-recommends \
g++ \
make \
Expand Down Expand Up @@ -33,4 +31,6 @@ RUN pip3 install --no-deps --no-cache-dir --require-hashes -r /tmp/reuse-require
COPY host-x86_64/mingw-check/validate-toolstate.sh /scripts/
COPY host-x86_64/mingw-check/validate-error-codes.sh /scripts/

# NOTE: intentionally uses python2 for x.py so we can test it still works.
# validate-toolstate only runs in our CI, so it's ok for it to only support python3.
ENV SCRIPT python2.7 ../x.py test --stage 0 src/tools/tidy tidyselftest
4 changes: 4 additions & 0 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ img {
overflow-x: hidden;
/* The sidebar is by default hidden */
overflow-y: hidden;
z-index: 1;
}

.sidebar, .mobile-topbar, .sidebar-menu-toggle,
Expand Down Expand Up @@ -535,6 +536,9 @@ ul.block, .block li {
.rustdoc .example-wrap > pre {
margin: 0;
flex-grow: 1;
}

.rustdoc:not(.source) .example-wrap > pre {
overflow: auto hidden;
}

Expand Down
Loading

0 comments on commit 4cb92cc

Please sign in to comment.