Skip to content

Commit e54e708

Browse files
committed
Auto merge of #153761 - Zalathar:rollup-wOxhkyI, r=Zalathar
Rollup of 7 pull requests Successful merges: - #153736 (add test that an incomplete feature emits a warning) - #153160 (Fix relative extern URL depth on source pages) - #153432 (Fix some comments about dataflow analysis.) - #153694 (fix(query): Pass Query Key to `value_from_cycle_error`) - #153717 (unused_macro_rules switched used and unused comments) - #153748 (editorconfig: css uses tabs) - #153750 (rustc-dev-guide subtree update)
2 parents d1ee5e5 + b5f2b3e commit e54e708

File tree

30 files changed

+298
-127
lines changed

30 files changed

+298
-127
lines changed

‎.editorconfig‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ trim_trailing_whitespace = true
1212
indent_style = space
1313
indent_size = 4
1414

15+
[*.css]
16+
indent_style = tab
17+
1518
# some tests need trailing whitespace in output snapshots
1619
[tests/**]
1720
trim_trailing_whitespace = false

‎compiler/rustc_feature/src/unstable.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ declare_features! (
257257
(internal, rustc_attrs, "1.0.0", None),
258258
/// Allows using the `#[stable]` and `#[unstable]` attributes.
259259
(internal, staged_api, "1.0.0", None),
260+
/// Perma-unstable, only used to test the `incomplete_features` lint.
261+
(incomplete, test_incomplete_feature, "CURRENT_RUSTC_VERSION", None),
260262
/// Added for testing unstable lints; perma-unstable.
261263
(internal, test_unstable_lint, "1.60.0", None),
262264
/// Use for stable + negative coherence and strict coherence depending on trait's

‎compiler/rustc_lint_defs/src/builtin.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,8 +1033,8 @@ declare_lint! {
10331033
/// ```rust
10341034
/// #[warn(unused_macro_rules)]
10351035
/// macro_rules! unused_empty {
1036-
/// (hello) => { println!("Hello, world!") }; // This rule is unused
1037-
/// () => { println!("empty") }; // This rule is used
1036+
/// (hello) => { println!("Hello, world!") }; // This rule is used
1037+
/// () => { println!("empty") }; // This rule is unused
10381038
/// }
10391039
///
10401040
/// fn main() {

‎compiler/rustc_middle/src/mir/basic_blocks.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl<'tcx> BasicBlocks<'tcx> {
6565

6666
/// Returns basic blocks in a reverse postorder.
6767
///
68-
/// See [`traversal::reverse_postorder`]'s docs to learn what is preorder traversal.
68+
/// See [`traversal::reverse_postorder`]'s docs to learn what is postorder traversal.
6969
///
7070
/// [`traversal::reverse_postorder`]: crate::mir::traversal::reverse_postorder
7171
#[inline]

‎compiler/rustc_middle/src/query/plumbing.rs‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,12 @@ pub struct QueryVTable<'tcx, C: QueryCache> {
136136
/// For `no_hash` queries, this function pointer is None.
137137
pub hash_value_fn: Option<fn(&mut StableHashingContext<'_>, &C::Value) -> Fingerprint>,
138138

139-
pub value_from_cycle_error:
140-
fn(tcx: TyCtxt<'tcx>, cycle_error: CycleError, guar: ErrorGuaranteed) -> C::Value,
139+
pub value_from_cycle_error: fn(
140+
tcx: TyCtxt<'tcx>,
141+
key: C::Key,
142+
cycle_error: CycleError,
143+
guar: ErrorGuaranteed,
144+
) -> C::Value,
141145
pub format_value: fn(&C::Value) -> String,
142146

143147
/// Formats a human-readable description of this query and its key, as

‎compiler/rustc_mir_dataflow/src/impls/initialized.rs‎

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -109,21 +109,21 @@ impl<'tcx> MaybePlacesSwitchIntData<'tcx> {
109109
/// ```rust
110110
/// struct S;
111111
/// #[rustfmt::skip]
112-
/// fn foo(pred: bool) { // maybe-init:
113-
/// // {}
114-
/// let a = S; let mut b = S; let c; let d; // {a, b}
112+
/// fn foo(p: bool) { // maybe-init:
113+
/// // {p}
114+
/// let a = S; let mut b = S; let c; let d; // {p, a, b}
115115
///
116-
/// if pred {
117-
/// drop(a); // { b}
118-
/// b = S; // { b}
116+
/// if p {
117+
/// drop(a); // {p, b}
118+
/// b = S; // {p, b}
119119
///
120120
/// } else {
121-
/// drop(b); // {a}
122-
/// d = S; // {a, d}
121+
/// drop(b); // {p, a}
122+
/// d = S; // {p, a, d}
123123
///
124-
/// } // {a, b, d}
124+
/// } // {p, a, b, d}
125125
///
126-
/// c = S; // {a, b, c, d}
126+
/// c = S; // {p, a, b, c, d}
127127
/// }
128128
/// ```
129129
///
@@ -199,11 +199,11 @@ impl<'a, 'tcx> HasMoveData<'tcx> for MaybeInitializedPlaces<'a, 'tcx> {
199199
/// ```rust
200200
/// struct S;
201201
/// #[rustfmt::skip]
202-
/// fn foo(pred: bool) { // maybe-uninit:
202+
/// fn foo(p: bool) { // maybe-uninit:
203203
/// // {a, b, c, d}
204204
/// let a = S; let mut b = S; let c; let d; // { c, d}
205205
///
206-
/// if pred {
206+
/// if p {
207207
/// drop(a); // {a, c, d}
208208
/// b = S; // {a, c, d}
209209
///
@@ -279,34 +279,36 @@ impl<'tcx> HasMoveData<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
279279
}
280280
}
281281

282-
/// `EverInitializedPlaces` tracks all places that might have ever been
283-
/// initialized upon reaching a particular point in the control flow
284-
/// for a function, without an intervening `StorageDead`.
282+
/// `EverInitializedPlaces` tracks all initializations that may have occurred
283+
/// upon reaching a particular point in the control flow for a function,
284+
/// without an intervening `StorageDead`.
285285
///
286286
/// This dataflow is used to determine if an immutable local variable may
287287
/// be assigned to.
288288
///
289289
/// For example, in code like the following, we have corresponding
290-
/// dataflow information shown in the right-hand comments.
290+
/// dataflow information shown in the right-hand comments. Underscored indices
291+
/// are used to distinguish between multiple initializations of the same local
292+
/// variable, e.g. `b_0` and `b_1`.
291293
///
292294
/// ```rust
293295
/// struct S;
294296
/// #[rustfmt::skip]
295-
/// fn foo(pred: bool) { // ever-init:
296-
/// // { }
297-
/// let a = S; let mut b = S; let c; let d; // {a, b }
297+
/// fn foo(p: bool) { // ever-init:
298+
/// // {p, }
299+
/// let a = S; let mut b = S; let c; let d; // {p, a, b_0, }
298300
///
299-
/// if pred {
300-
/// drop(a); // {a, b, }
301-
/// b = S; // {a, b, }
301+
/// if p {
302+
/// drop(a); // {p, a, b_0, }
303+
/// b = S; // {p, a, b_0, b_1, }
302304
///
303305
/// } else {
304-
/// drop(b); // {a, b, }
305-
/// d = S; // {a, b, d }
306+
/// drop(b); // {p, a, b_0, b_1, }
307+
/// d = S; // {p, a, b_0, b_1, d}
306308
///
307-
/// } // {a, b, d }
309+
/// } // {p, a, b_0, b_1, d}
308310
///
309-
/// c = S; // {a, b, c, d }
311+
/// c = S; // {p, a, b_0, b_1, c, d}
310312
/// }
311313
/// ```
312314
pub struct EverInitializedPlaces<'a, 'tcx> {

‎compiler/rustc_query_impl/src/execution.rs‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,18 @@ where
125125
fn mk_cycle<'tcx, C: QueryCache>(
126126
query: &'tcx QueryVTable<'tcx, C>,
127127
tcx: TyCtxt<'tcx>,
128+
key: C::Key,
128129
cycle_error: CycleError,
129130
) -> C::Value {
130131
let error = report_cycle(tcx.sess, &cycle_error);
131132
match query.cycle_error_handling {
132133
CycleErrorHandling::Error => {
133134
let guar = error.emit();
134-
(query.value_from_cycle_error)(tcx, cycle_error, guar)
135+
(query.value_from_cycle_error)(tcx, key, cycle_error, guar)
135136
}
136137
CycleErrorHandling::DelayBug => {
137138
let guar = error.delay_as_bug();
138-
(query.value_from_cycle_error)(tcx, cycle_error, guar)
139+
(query.value_from_cycle_error)(tcx, key, cycle_error, guar)
139140
}
140141
}
141142
}
@@ -219,6 +220,7 @@ where
219220
fn cycle_error<'tcx, C: QueryCache>(
220221
query: &'tcx QueryVTable<'tcx, C>,
221222
tcx: TyCtxt<'tcx>,
223+
key: C::Key,
222224
try_execute: QueryJobId,
223225
span: Span,
224226
) -> (C::Value, Option<DepNodeIndex>) {
@@ -229,7 +231,7 @@ fn cycle_error<'tcx, C: QueryCache>(
229231
.expect("failed to collect active queries");
230232

231233
let error = find_cycle_in_stack(try_execute, job_map, &current_query_job(), span);
232-
(mk_cycle(query, tcx, error.lift()), None)
234+
(mk_cycle(query, tcx, key, error.lift()), None)
233235
}
234236

235237
#[inline(always)]
@@ -274,7 +276,7 @@ fn wait_for_query<'tcx, C: QueryCache>(
274276

275277
(v, Some(index))
276278
}
277-
Err(cycle) => (mk_cycle(query, tcx, cycle.lift()), None),
279+
Err(cycle) => (mk_cycle(query, tcx, key, cycle.lift()), None),
278280
}
279281
}
280282

@@ -337,7 +339,7 @@ fn try_execute_query<'tcx, C: QueryCache, const INCR: bool>(
337339

338340
// If we are single-threaded we know that we have cycle error,
339341
// so we just return the error.
340-
cycle_error(query, tcx, id, span)
342+
cycle_error(query, tcx, key, id, span)
341343
}
342344
}
343345
ActiveKeyStatus::Poisoned => FatalError.raise(),

‎compiler/rustc_query_impl/src/from_cycle_error.rs‎

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,34 @@ use rustc_middle::query::erase::erase_val;
1515
use rustc_middle::ty::layout::{LayoutError, TyAndLayout};
1616
use rustc_middle::ty::{self, Ty, TyCtxt};
1717
use rustc_middle::{bug, span_bug};
18-
use rustc_span::def_id::LocalDefId;
18+
use rustc_span::def_id::{DefId, LocalDefId};
1919
use rustc_span::{ErrorGuaranteed, Span};
2020

2121
use crate::job::report_cycle;
2222

2323
pub(crate) fn specialize_query_vtables<'tcx>(vtables: &mut QueryVTables<'tcx>) {
2424
vtables.type_of.value_from_cycle_error =
25-
|tcx, _, guar| erase_val(ty::EarlyBinder::bind(Ty::new_error(tcx, guar)));
25+
|tcx, _, _, guar| erase_val(ty::EarlyBinder::bind(Ty::new_error(tcx, guar)));
2626

2727
vtables.type_of_opaque_hir_typeck.value_from_cycle_error =
28-
|tcx, _, guar| erase_val(ty::EarlyBinder::bind(Ty::new_error(tcx, guar)));
28+
|tcx, _, _, guar| erase_val(ty::EarlyBinder::bind(Ty::new_error(tcx, guar)));
2929

3030
vtables.erase_and_anonymize_regions_ty.value_from_cycle_error =
31-
|tcx, _, guar| erase_val(Ty::new_error(tcx, guar));
31+
|tcx, _, _, guar| erase_val(Ty::new_error(tcx, guar));
3232

33-
vtables.fn_sig.value_from_cycle_error = |tcx, cycle, guar| erase_val(fn_sig(tcx, cycle, guar));
33+
vtables.fn_sig.value_from_cycle_error = |tcx, key, _, guar| erase_val(fn_sig(tcx, key, guar));
3434

3535
vtables.check_representability.value_from_cycle_error =
36-
|tcx, cycle, guar| check_representability(tcx, cycle, guar);
36+
|tcx, _, cycle, guar| check_representability(tcx, cycle, guar);
3737

3838
vtables.check_representability_adt_ty.value_from_cycle_error =
39-
|tcx, cycle, guar| check_representability(tcx, cycle, guar);
39+
|tcx, _, cycle, guar| check_representability(tcx, cycle, guar);
4040

4141
vtables.variances_of.value_from_cycle_error =
42-
|tcx, cycle, guar| erase_val(variances_of(tcx, cycle, guar));
42+
|tcx, _, cycle, guar| erase_val(variances_of(tcx, cycle, guar));
4343

4444
vtables.layout_of.value_from_cycle_error =
45-
|tcx, cycle, guar| erase_val(layout_of(tcx, cycle, guar));
45+
|tcx, _, cycle, guar| erase_val(layout_of(tcx, cycle, guar));
4646
}
4747

4848
pub(crate) fn default<'tcx>(tcx: TyCtxt<'tcx>, cycle_error: CycleError, query_name: &str) -> ! {
@@ -57,15 +57,12 @@ pub(crate) fn default<'tcx>(tcx: TyCtxt<'tcx>, cycle_error: CycleError, query_na
5757

5858
fn fn_sig<'tcx>(
5959
tcx: TyCtxt<'tcx>,
60-
cycle_error: CycleError,
60+
def_id: DefId,
6161
guar: ErrorGuaranteed,
6262
) -> ty::EarlyBinder<'tcx, ty::PolyFnSig<'tcx>> {
6363
let err = Ty::new_error(tcx, guar);
6464

65-
let arity = if let Some(info) = cycle_error.cycle.get(0)
66-
&& info.frame.dep_kind == DepKind::fn_sig
67-
&& let Some(def_id) = info.frame.def_id
68-
&& let Some(node) = tcx.hir_get_if_local(def_id)
65+
let arity = if let Some(node) = tcx.hir_get_if_local(def_id)
6966
&& let Some(sig) = node.fn_sig()
7067
{
7168
sig.decl.inputs.len()

‎compiler/rustc_query_impl/src/plumbing.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ macro_rules! define_queries {
487487
#[cfg(not($cache_on_disk))]
488488
is_loadable_from_disk_fn: |_tcx, _key, _index| false,
489489

490-
value_from_cycle_error: |tcx, cycle, _| {
490+
value_from_cycle_error: |tcx, _, cycle, _| {
491491
$crate::from_cycle_error::default(tcx, cycle, stringify!($name))
492492
},
493493

‎compiler/rustc_span/src/symbol.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2006,6 +2006,7 @@ symbols! {
20062006
test_2018_feature,
20072007
test_accepted_feature,
20082008
test_case,
2009+
test_incomplete_feature,
20092010
test_removed_feature,
20102011
test_runner,
20112012
test_unstable_lint,

0 commit comments

Comments
 (0)