Skip to content

Commit 4cb92cc

Browse files
committed
Auto merge of rust-lang#109966 - JohnTitor:rollup-eoqjr5j, r=JohnTitor
Rollup of 6 pull requests Successful merges: - rust-lang#107236 (Add T-bootstrap label to tools) - rust-lang#109847 (Only create graphviz nodes for reachable MIR bb's) - rust-lang#109848 (submodule detection for proper fix on rust-lang#96188) - rust-lang#109932 (Source code scrollbar) - rust-lang#109952 (Move comment about python2 closer to the place it's used) - rust-lang#109956 (Tweak debug outputs to make debugging new solver easier) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 383c1d7 + 038ece0 commit 4cb92cc

File tree

18 files changed

+145
-67
lines changed

18 files changed

+145
-67
lines changed

compiler/rustc_middle/src/infer/canonical.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ use std::ops::Index;
3535
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, TyDecodable, TyEncodable)]
3636
#[derive(HashStable, TypeFoldable, TypeVisitable, Lift)]
3737
pub struct Canonical<'tcx, V> {
38+
pub value: V,
3839
pub max_universe: ty::UniverseIndex,
3940
pub variables: CanonicalVarInfos<'tcx>,
40-
pub value: V,
4141
}
4242

4343
pub type CanonicalVarInfos<'tcx> = &'tcx List<CanonicalVarInfo<'tcx>>;

compiler/rustc_middle/src/traits/solve.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ pub type EvaluationCache<'tcx> = Cache<CanonicalGoal<'tcx>, QueryResult<'tcx>>;
2020
/// we're currently typechecking while the `predicate` is some trait bound.
2121
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, TypeFoldable, TypeVisitable)]
2222
pub struct Goal<'tcx, P> {
23-
pub param_env: ty::ParamEnv<'tcx>,
2423
pub predicate: P,
24+
pub param_env: ty::ParamEnv<'tcx>,
2525
}
2626

2727
impl<'tcx, P> Goal<'tcx, P> {
@@ -41,10 +41,10 @@ impl<'tcx, P> Goal<'tcx, P> {
4141

4242
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, TypeFoldable, TypeVisitable)]
4343
pub struct Response<'tcx> {
44+
pub certainty: Certainty,
4445
pub var_values: CanonicalVarValues<'tcx>,
4546
/// Additional constraints returned by this query.
4647
pub external_constraints: ExternalConstraints<'tcx>,
47-
pub certainty: Certainty,
4848
}
4949

5050
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, TypeFoldable, TypeVisitable)]

compiler/rustc_mir_dataflow/src/framework/graphviz.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use std::{io, ops, str};
66

77
use regex::Regex;
88
use rustc_graphviz as dot;
9+
use rustc_index::bit_set::BitSet;
910
use rustc_middle::mir::graphviz_safe_def_name;
1011
use rustc_middle::mir::{self, BasicBlock, Body, Location};
1112

@@ -34,14 +35,16 @@ where
3435
body: &'a Body<'tcx>,
3536
results: &'a Results<'tcx, A>,
3637
style: OutputStyle,
38+
reachable: BitSet<BasicBlock>,
3739
}
3840

3941
impl<'a, 'tcx, A> Formatter<'a, 'tcx, A>
4042
where
4143
A: Analysis<'tcx>,
4244
{
4345
pub fn new(body: &'a Body<'tcx>, results: &'a Results<'tcx, A>, style: OutputStyle) -> Self {
44-
Formatter { body, results, style }
46+
let reachable = mir::traversal::reachable_as_bitset(body);
47+
Formatter { body, results, style, reachable }
4548
}
4649
}
4750

@@ -108,7 +111,12 @@ where
108111
type Edge = CfgEdge;
109112

110113
fn nodes(&self) -> dot::Nodes<'_, Self::Node> {
111-
self.body.basic_blocks.indices().collect::<Vec<_>>().into()
114+
self.body
115+
.basic_blocks
116+
.indices()
117+
.filter(|&idx| self.reachable.contains(idx))
118+
.collect::<Vec<_>>()
119+
.into()
112120
}
113121

114122
fn edges(&self) -> dot::Edges<'_, Self::Edge> {

compiler/rustc_trait_selection/src/solve/assembly.rs

+7
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
270270
/// To deal with this, we first try to normalize the self type and add the candidates for the normalized
271271
/// self type to the list of candidates in case that succeeds. We also have to consider candidates with the
272272
/// projection as a self type as well
273+
#[instrument(level = "debug", skip_all)]
273274
fn assemble_candidates_after_normalizing_self_ty<G: GoalKind<'tcx>>(
274275
&mut self,
275276
goal: Goal<'tcx, G>,
@@ -315,6 +316,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
315316
}
316317
}
317318

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

338+
#[instrument(level = "debug", skip_all)]
336339
fn assemble_builtin_impl_candidates<G: GoalKind<'tcx>>(
337340
&mut self,
338341
goal: Goal<'tcx, G>,
@@ -390,6 +393,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
390393
}
391394
}
392395

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

412+
#[instrument(level = "debug", skip_all)]
408413
fn assemble_alias_bound_candidates<G: GoalKind<'tcx>>(
409414
&mut self,
410415
goal: Goal<'tcx, G>,
@@ -452,6 +457,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
452457
}
453458
}
454459

460+
#[instrument(level = "debug", skip_all)]
455461
fn assemble_object_bound_candidates<G: GoalKind<'tcx>>(
456462
&mut self,
457463
goal: Goal<'tcx, G>,
@@ -514,6 +520,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
514520
}
515521
}
516522

523+
#[instrument(level = "debug", skip_all)]
517524
fn assemble_coherence_unknowable_candidates<G: GoalKind<'tcx>>(
518525
&mut self,
519526
goal: Goal<'tcx, G>,

compiler/rustc_trait_selection/src/solve/eval_ctxt.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ pub trait InferCtxtEvalExt<'tcx> {
106106
}
107107

108108
impl<'tcx> InferCtxtEvalExt<'tcx> for InferCtxt<'tcx> {
109-
#[instrument(level = "debug", skip(self))]
109+
#[instrument(level = "debug", skip(self), ret)]
110110
fn evaluate_root_goal(
111111
&self,
112112
goal: Goal<'tcx, ty::Predicate<'tcx>>,
@@ -552,7 +552,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
552552
///
553553
/// If possible, try using `eq` instead which automatically handles nested
554554
/// goals correctly.
555-
#[instrument(level = "debug", skip(self, param_env), ret)]
555+
#[instrument(level = "trace", skip(self, param_env), ret)]
556556
pub(super) fn eq_and_get_goals<T: ToTrace<'tcx>>(
557557
&self,
558558
param_env: ty::ParamEnv<'tcx>,

compiler/rustc_trait_selection/src/solve/mod.rs

+21-5
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,22 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
153153
) -> QueryResult<'tcx> {
154154
let tcx = self.tcx();
155155
// We may need to invert the alias relation direction if dealing an alias on the RHS.
156+
#[derive(Debug)]
156157
enum Invert {
157158
No,
158159
Yes,
159160
}
160161
let evaluate_normalizes_to =
161162
|ecx: &mut EvalCtxt<'_, 'tcx>, alias, other, direction, invert| {
162-
debug!("evaluate_normalizes_to(alias={:?}, other={:?})", alias, other);
163+
let span = tracing::span!(
164+
tracing::Level::DEBUG,
165+
"compute_alias_relate_goal(evaluate_normalizes_to)",
166+
?alias,
167+
?other,
168+
?direction,
169+
?invert
170+
);
171+
let _enter = span.enter();
163172
let result = ecx.probe(|ecx| {
164173
let other = match direction {
165174
// This is purely an optimization.
@@ -184,7 +193,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
184193
));
185194
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
186195
});
187-
debug!("evaluate_normalizes_to({alias}, {other}, {direction:?}) -> {result:?}");
196+
debug!(?result);
188197
result
189198
};
190199

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

212221
(Some(alias_lhs), Some(alias_rhs)) => {
213-
debug!("compute_alias_relate_goal: both sides are aliases");
222+
debug!("both sides are aliases");
214223

215224
let candidates = vec![
216225
// LHS normalizes-to RHS
@@ -219,9 +228,14 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
219228
evaluate_normalizes_to(self, alias_rhs, lhs, direction, Invert::Yes),
220229
// Relate via substs
221230
self.probe(|ecx| {
222-
debug!(
223-
"compute_alias_relate_goal: alias defids are equal, equating substs"
231+
let span = tracing::span!(
232+
tracing::Level::DEBUG,
233+
"compute_alias_relate_goal(relate_via_substs)",
234+
?alias_lhs,
235+
?alias_rhs,
236+
?direction
224237
);
238+
let _enter = span.enter();
225239

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

292+
#[instrument(level = "debug", skip(self, responses))]
278293
fn try_merge_responses(
279294
&mut self,
280295
responses: impl Iterator<Item = QueryResult<'tcx>>,
@@ -304,6 +319,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
304319
});
305320
// FIXME(-Ztrait-solver=next): We should take the intersection of the constraints on all the
306321
// responses and use that for the constraints of this ambiguous response.
322+
debug!(">1 response, bailing with {certainty:?}");
307323
let response = self.evaluate_added_goals_and_make_canonical_response(certainty);
308324
if let Ok(response) = &response {
309325
assert!(response.has_no_inference_or_external_constraints());

compiler/rustc_trait_selection/src/solve/search_graph/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ impl<'tcx> SearchGraph<'tcx> {
209209
) -> QueryResult<'tcx> {
210210
if self.should_use_global_cache() {
211211
if let Some(result) = tcx.new_solver_evaluation_cache.get(&canonical_goal, tcx) {
212+
debug!(?canonical_goal, ?result, "cache hit");
212213
return result;
213214
}
214215
}

src/bootstrap/builder.rs

+40-10
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ use std::collections::BTreeSet;
44
use std::env;
55
use std::ffi::OsStr;
66
use std::fmt::{Debug, Write};
7-
use std::fs::{self};
7+
use std::fs::{self, File};
88
use std::hash::Hash;
9+
use std::io::{BufRead, BufReader};
910
use std::ops::Deref;
1011
use std::path::{Component, Path, PathBuf};
1112
use std::process::Command;
@@ -28,8 +29,11 @@ use crate::{clean, dist};
2829
use crate::{Build, CLang, DocTests, GitRepo, Mode};
2930

3031
pub use crate::Compiler;
31-
// FIXME: replace with std::lazy after it gets stabilized and reaches beta
32-
use once_cell::sync::Lazy;
32+
// FIXME:
33+
// - use std::lazy for `Lazy`
34+
// - use std::cell for `OnceCell`
35+
// Once they get stabilized and reach beta.
36+
use once_cell::sync::{Lazy, OnceCell};
3337

3438
pub struct Builder<'a> {
3539
pub build: &'a Build,
@@ -484,17 +488,43 @@ impl<'a> ShouldRun<'a> {
484488

485489
// multiple aliases for the same job
486490
pub fn paths(mut self, paths: &[&str]) -> Self {
491+
static SUBMODULES_PATHS: OnceCell<Vec<String>> = OnceCell::new();
492+
493+
let init_submodules_paths = |src: &PathBuf| {
494+
let file = File::open(src.join(".gitmodules")).unwrap();
495+
496+
let mut submodules_paths = vec![];
497+
for line in BufReader::new(file).lines() {
498+
if let Ok(line) = line {
499+
let line = line.trim();
500+
501+
if line.starts_with("path") {
502+
let actual_path =
503+
line.split(' ').last().expect("Couldn't get value of path");
504+
submodules_paths.push(actual_path.to_owned());
505+
}
506+
}
507+
}
508+
509+
submodules_paths
510+
};
511+
512+
let submodules_paths =
513+
SUBMODULES_PATHS.get_or_init(|| init_submodules_paths(&self.builder.src));
514+
487515
self.paths.insert(PathSet::Set(
488516
paths
489517
.iter()
490518
.map(|p| {
491-
// FIXME(#96188): make sure this is actually a path.
492-
// This currently breaks for paths within submodules.
493-
//assert!(
494-
// self.builder.src.join(p).exists(),
495-
// "`should_run.paths` should correspond to real on-disk paths - use `alias` if there is no relevant path: {}",
496-
// p
497-
//);
519+
// assert only if `p` isn't submodule
520+
if !submodules_paths.iter().find(|sm_p| p.contains(*sm_p)).is_some() {
521+
assert!(
522+
self.builder.src.join(p).exists(),
523+
"`should_run.paths` should correspond to real on-disk paths - use `alias` if there is no relevant path: {}",
524+
p
525+
);
526+
}
527+
498528
TaskPath { path: p.into(), kind: Some(self.kind) }
499529
})
500530
.collect(),

src/ci/docker/host-x86_64/mingw-check-tidy/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
FROM ubuntu:22.04
22

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

34+
# NOTE: intentionally uses python2 for x.py so we can test it still works.
35+
# validate-toolstate only runs in our CI, so it's ok for it to only support python3.
3636
ENV SCRIPT python2.7 ../x.py test --stage 0 src/tools/tidy tidyselftest

src/librustdoc/html/static/css/rustdoc.css

+4
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ img {
392392
overflow-x: hidden;
393393
/* The sidebar is by default hidden */
394394
overflow-y: hidden;
395+
z-index: 1;
395396
}
396397

397398
.sidebar, .mobile-topbar, .sidebar-menu-toggle,
@@ -535,6 +536,9 @@ ul.block, .block li {
535536
.rustdoc .example-wrap > pre {
536537
margin: 0;
537538
flex-grow: 1;
539+
}
540+
541+
.rustdoc:not(.source) .example-wrap > pre {
538542
overflow: auto hidden;
539543
}
540544

0 commit comments

Comments
 (0)