Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 86d69c7

Browse files
committed
Auto merge of #132035 - matthiaskrgr:rollup-ty1e4q0, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #125205 (Fixup Windows verbatim paths when used with the `include!` macro) - #131049 (Validate args are correct for `UnevaluatedConst`, `ExistentialTraitRef`/`ExistentialProjection`) - #131549 (Add a note for `?` on a `impl Future<Output = Result<..>>` in sync function) - #131731 (add `TestFloatParse` to `tools.rs` for bootstrap) - #131732 (Add doc(plugins), doc(passes), etc. to INVALID_DOC_ATTRIBUTES) - #132006 (don't stage-off to previous compiler when CI rustc is available) - #132022 (Move `cmp_in_dominator_order` out of graph dominator computation) - #132033 (compiletest: Make `line_directive` return a `DirectiveLine`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents bca5fde + 6db5f33 commit 86d69c7

File tree

35 files changed

+473
-253
lines changed

35 files changed

+473
-253
lines changed

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

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
//! Thomas Lengauer and Robert Endre Tarjan.
1010
//! <https://www.cs.princeton.edu/courses/archive/spr03/cs423/download/dominators.pdf>
1111
12-
use std::cmp::Ordering;
13-
1412
use rustc_index::{Idx, IndexSlice, IndexVec};
1513

1614
use super::ControlFlowGraph;
@@ -64,9 +62,6 @@ fn is_small_path_graph<G: ControlFlowGraph>(g: &G) -> bool {
6462
}
6563

6664
fn dominators_impl<G: ControlFlowGraph>(graph: &G) -> Inner<G::Node> {
67-
// compute the post order index (rank) for each node
68-
let mut post_order_rank = IndexVec::from_elem_n(0, graph.num_nodes());
69-
7065
// We allocate capacity for the full set of nodes, because most of the time
7166
// most of the nodes *are* reachable.
7267
let mut parent: IndexVec<PreorderIndex, PreorderIndex> =
@@ -83,12 +78,10 @@ fn dominators_impl<G: ControlFlowGraph>(graph: &G) -> Inner<G::Node> {
8378
pre_order_to_real.push(graph.start_node());
8479
parent.push(PreorderIndex::ZERO); // the parent of the root node is the root for now.
8580
real_to_pre_order[graph.start_node()] = Some(PreorderIndex::ZERO);
86-
let mut post_order_idx = 0;
8781

8882
// Traverse the graph, collecting a number of things:
8983
//
9084
// * Preorder mapping (to it, and back to the actual ordering)
91-
// * Postorder mapping (used exclusively for `cmp_in_dominator_order` on the final product)
9285
// * Parents for each vertex in the preorder tree
9386
//
9487
// These are all done here rather than through one of the 'standard'
@@ -104,8 +97,6 @@ fn dominators_impl<G: ControlFlowGraph>(graph: &G) -> Inner<G::Node> {
10497
continue 'recurse;
10598
}
10699
}
107-
post_order_rank[pre_order_to_real[frame.pre_order_idx]] = post_order_idx;
108-
post_order_idx += 1;
109100

110101
stack.pop();
111102
}
@@ -282,7 +273,7 @@ fn dominators_impl<G: ControlFlowGraph>(graph: &G) -> Inner<G::Node> {
282273

283274
let time = compute_access_time(start_node, &immediate_dominators);
284275

285-
Inner { post_order_rank,immediate_dominators, time }
276+
Inner { immediate_dominators, time }
286277
}
287278

288279
/// Evaluate the link-eval virtual forest, providing the currently minimum semi
@@ -348,7 +339,6 @@ fn compress(
348339
/// Tracks the list of dominators for each node.
349340
#[derive(Clone, Debug)]
350341
struct Inner<N: Idx> {
351-
post_order_rank: IndexVec<N, usize>,
352342
// Even though we track only the immediate dominator of each node, it's
353343
// possible to get its full list of dominators by looking up the dominator
354344
// of each dominator.
@@ -379,17 +369,6 @@ impl<Node: Idx> Dominators<Node> {
379369
}
380370
}
381371

382-
/// Provide deterministic ordering of nodes such that, if any two nodes have a dominator
383-
/// relationship, the dominator will always precede the dominated. (The relative ordering
384-
/// of two unrelated nodes will also be consistent, but otherwise the order has no
385-
/// meaning.) This method cannot be used to determine if either Node dominates the other.
386-
pub fn cmp_in_dominator_order(&self, lhs: Node, rhs: Node) -> Ordering {
387-
match &self.kind {
388-
Kind::Path => lhs.index().cmp(&rhs.index()),
389-
Kind::General(g) => g.post_order_rank[rhs].cmp(&g.post_order_rank[lhs]),
390-
}
391-
}
392-
393372
/// Returns true if `a` dominates `b`.
394373
///
395374
/// # Panics

‎compiler/rustc_expand/src/base.rs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::default::Default;
22
use std::iter;
3+
use std::path::Component::Prefix;
34
use std::path::{Path, PathBuf};
45
use std::rc::Rc;
56

@@ -1293,7 +1294,12 @@ pub fn resolve_path(sess: &Session, path: impl Into<PathBuf>, span: Span) -> PRe
12931294
base_path.push(path);
12941295
Ok(base_path)
12951296
} else {
1296-
Ok(path)
1297+
// This ensures that Windows verbatim paths are fixed if mixed path separators are used,
1298+
// which can happen when `concat!` is used to join paths.
1299+
match path.components().next() {
1300+
Some(Prefix(prefix)) if prefix.kind().is_verbatim() => Ok(path.components().collect()),
1301+
_ => Ok(path),
1302+
}
12971303
}
12981304
}
12991305

‎compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
259259
}
260260
})
261261
.collect();
262-
let args = tcx.mk_args(&args);
263262

264263
let span = i.bottom().1;
265264
let empty_generic_args = hir_trait_bounds.iter().any(|hir_bound| {
@@ -292,7 +291,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
292291
.emit();
293292
}
294293

295-
ty::ExistentialTraitRef{def_id: trait_ref.def_id, args}
294+
ty::ExistentialTraitRef::new(tcx, trait_ref.def_id, args)
296295
})
297296
});
298297

‎compiler/rustc_hir_typeck/src/expr.rs‎

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ use rustc_data_structures::stack::ensure_sufficient_stack;
1010
use rustc_data_structures::unord::UnordMap;
1111
use rustc_errors::codes::*;
1212
use rustc_errors::{
13-
Applicability, Diag, ErrorGuaranteed, StashKey, Subdiagnostic, pluralize, struct_span_code_err,
13+
Applicability, Diag, ErrorGuaranteed, MultiSpan, StashKey, Subdiagnostic, pluralize,
14+
struct_span_code_err,
1415
};
1516
use rustc_hir::def::{CtorKind, DefKind, Res};
1617
use rustc_hir::def_id::DefId;
@@ -2763,12 +2764,25 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
27632764
field_ident.span,
27642765
"field not available in `impl Future`, but it is available in its `Output`",
27652766
);
2766-
err.span_suggestion_verbose(
2767-
base.span.shrink_to_hi(),
2768-
"consider `await`ing on the `Future` and access the field of its `Output`",
2769-
".await",
2770-
Applicability::MaybeIncorrect,
2771-
);
2767+
match self.tcx.coroutine_kind(self.body_id) {
2768+
Some(hir::CoroutineKind::Desugared(hir::CoroutineDesugaring::Async, _)) => {
2769+
err.span_suggestion_verbose(
2770+
base.span.shrink_to_hi(),
2771+
"consider `await`ing on the `Future` to access the field",
2772+
".await",
2773+
Applicability::MaybeIncorrect,
2774+
);
2775+
}
2776+
_ => {
2777+
let mut span: MultiSpan = base.span.into();
2778+
span.push_span_label(self.tcx.def_span(self.body_id), "this is not `async`");
2779+
err.span_note(
2780+
span,
2781+
"this implements `Future` and its output type has the field, \
2782+
but the future cannot be awaited in a synchronous function",
2783+
);
2784+
}
2785+
}
27722786
}
27732787

27742788
fn ban_nonexisting_field(

‎compiler/rustc_middle/src/ty/consts.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ impl<'tcx> Const<'tcx> {
109109

110110
#[inline]
111111
pub fn new_unevaluated(tcx: TyCtxt<'tcx>, uv: ty::UnevaluatedConst<'tcx>) -> Const<'tcx> {
112+
tcx.debug_assert_args_compatible(uv.def, uv.args);
112113
Const::new(tcx, ty::ConstKind::Unevaluated(uv))
113114
}
114115

‎compiler/rustc_middle/src/ty/context.rs‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,26 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
279279
self.debug_assert_args_compatible(def_id, args);
280280
}
281281

282+
/// Assert that the args from an `ExistentialTraitRef` or `ExistentialProjection`
283+
/// are compatible with the `DefId`. Since we're missing a `Self` type, stick on
284+
/// a dummy self type and forward to `debug_assert_args_compatible`.
285+
fn debug_assert_existential_args_compatible(
286+
self,
287+
def_id: Self::DefId,
288+
args: Self::GenericArgs,
289+
) {
290+
// FIXME: We could perhaps add a `skip: usize` to `debug_assert_args_compatible`
291+
// to avoid needing to reintern the set of args...
292+
if cfg!(debug_assertions) {
293+
self.debug_assert_args_compatible(
294+
def_id,
295+
self.mk_args_from_iter(
296+
[self.types.trait_object_dummy_self.into()].into_iter().chain(args.iter()),
297+
),
298+
);
299+
}
300+
}
301+
282302
fn mk_type_list_from_iter<I, T>(self, args: I) -> T::Output
283303
where
284304
I: Iterator<Item = T>,

‎compiler/rustc_mir_transform/src/coverage/graph.rs‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ pub(crate) struct CoverageGraph {
2121
pub(crate) successors: IndexVec<BasicCoverageBlock, Vec<BasicCoverageBlock>>,
2222
pub(crate) predecessors: IndexVec<BasicCoverageBlock, Vec<BasicCoverageBlock>>,
2323
dominators: Option<Dominators<BasicCoverageBlock>>,
24+
/// Allows nodes to be compared in some total order such that _if_
25+
/// `a` dominates `b`, then `a < b`. If neither node dominates the other,
26+
/// their relative order is consistent but arbitrary.
27+
dominator_order_rank: IndexVec<BasicCoverageBlock, u32>,
2428
}
2529

2630
impl CoverageGraph {
@@ -54,10 +58,27 @@ impl CoverageGraph {
5458
}
5559
}
5660

57-
let mut this = Self { bcbs, bb_to_bcb, successors, predecessors, dominators: None };
61+
let num_nodes = bcbs.len();
62+
let mut this = Self {
63+
bcbs,
64+
bb_to_bcb,
65+
successors,
66+
predecessors,
67+
dominators: None,
68+
dominator_order_rank: IndexVec::from_elem_n(0, num_nodes),
69+
};
70+
assert_eq!(num_nodes, this.num_nodes());
5871

5972
this.dominators = Some(dominators::dominators(&this));
6073

74+
// The dominator rank of each node is just its index in a reverse-postorder traversal.
75+
let reverse_post_order = graph::iterate::reverse_post_order(&this, this.start_node());
76+
// The coverage graph is created by traversal, so all nodes are reachable.
77+
assert_eq!(reverse_post_order.len(), this.num_nodes());
78+
for (rank, bcb) in (0u32..).zip(reverse_post_order) {
79+
this.dominator_order_rank[bcb] = rank;
80+
}
81+
6182
// The coverage graph's entry-point node (bcb0) always starts with bb0,
6283
// which never has predecessors. Any other blocks merged into bcb0 can't
6384
// have multiple (coverage-relevant) predecessors, so bcb0 always has
@@ -162,7 +183,7 @@ impl CoverageGraph {
162183
a: BasicCoverageBlock,
163184
b: BasicCoverageBlock,
164185
) -> Ordering {
165-
self.dominators.as_ref().unwrap().cmp_in_dominator_order(a, b)
186+
self.dominator_order_rank[a].cmp(&self.dominator_order_rank[b])
166187
}
167188

168189
/// Returns the source of this node's sole in-edge, if it has exactly one.

‎compiler/rustc_passes/messages.ftl‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,19 @@ passes_doc_test_unknown_include =
245245
unknown `doc` attribute `{$path}`
246246
.suggestion = use `doc = include_str!` instead
247247
248+
passes_doc_test_unknown_passes =
249+
unknown `doc` attribute `{$path}`
250+
.note = `doc` attribute `{$path}` no longer functions; see issue #44136 <https://github.com/rust-lang/rust/issues/44136>
251+
.label = no longer functions
252+
.help = you may want to use `doc(document_private_items)`
253+
.no_op_note = `doc({$path})` is now a no-op
254+
255+
passes_doc_test_unknown_plugins =
256+
unknown `doc` attribute `{$path}`
257+
.note = `doc` attribute `{$path}` no longer functions; see issue #44136 <https://github.com/rust-lang/rust/issues/44136> and CVE-2018-1000622 <https://nvd.nist.gov/vuln/detail/CVE-2018-1000622>
258+
.label = no longer functions
259+
.no_op_note = `doc({$path})` is now a no-op
260+
248261
passes_doc_test_unknown_spotlight =
249262
unknown `doc` attribute `{$path}`
250263
.note = `doc(spotlight)` was renamed to `doc(notable_trait)`

‎compiler/rustc_passes/src/check_attr.rs‎

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,15 +1183,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
11831183

11841184
sym::masked => self.check_doc_masked(attr, meta, hir_id, target),
11851185

1186-
// no_default_passes: deprecated
1187-
// passes: deprecated
1188-
// plugins: removed, but rustdoc warns about it itself
1189-
sym::cfg
1190-
| sym::hidden
1191-
| sym::no_default_passes
1192-
| sym::notable_trait
1193-
| sym::passes
1194-
| sym::plugins => {}
1186+
sym::cfg | sym::hidden | sym::notable_trait => {}
11951187

11961188
sym::rust_logo => {
11971189
if self.check_attr_crate_level(attr, meta, hir_id)
@@ -1240,6 +1232,22 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
12401232
sugg: (attr.meta().unwrap().span, applicability),
12411233
},
12421234
);
1235+
} else if i_meta.has_name(sym::passes)
1236+
|| i_meta.has_name(sym::no_default_passes)
1237+
{
1238+
self.tcx.emit_node_span_lint(
1239+
INVALID_DOC_ATTRIBUTES,
1240+
hir_id,
1241+
i_meta.span,
1242+
errors::DocTestUnknownPasses { path, span: i_meta.span },
1243+
);
1244+
} else if i_meta.has_name(sym::plugins) {
1245+
self.tcx.emit_node_span_lint(
1246+
INVALID_DOC_ATTRIBUTES,
1247+
hir_id,
1248+
i_meta.span,
1249+
errors::DocTestUnknownPlugins { path, span: i_meta.span },
1250+
);
12431251
} else {
12441252
self.tcx.emit_node_span_lint(
12451253
INVALID_DOC_ATTRIBUTES,

‎compiler/rustc_passes/src/errors.rs‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,27 @@ pub(crate) struct DocTestUnknownSpotlight {
323323
pub span: Span,
324324
}
325325

326+
#[derive(LintDiagnostic)]
327+
#[diag(passes_doc_test_unknown_passes)]
328+
#[note]
329+
#[help]
330+
#[note(passes_no_op_note)]
331+
pub(crate) struct DocTestUnknownPasses {
332+
pub path: String,
333+
#[label]
334+
pub span: Span,
335+
}
336+
337+
#[derive(LintDiagnostic)]
338+
#[diag(passes_doc_test_unknown_plugins)]
339+
#[note]
340+
#[note(passes_no_op_note)]
341+
pub(crate) struct DocTestUnknownPlugins {
342+
pub path: String,
343+
#[label]
344+
pub span: Span,
345+
}
346+
326347
#[derive(LintDiagnostic)]
327348
#[diag(passes_doc_test_unknown_include)]
328349
pub(crate) struct DocTestUnknownInclude {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /