Skip to content

Commit 3d207da

Browse files
committed
Auto merge of #144791 - GuillaumeGomez:rollup-ujf9ae4, r=GuillaumeGomez
Rollup of 11 pull requests Successful merges: - #132748 (get rid of some false negatives in rustdoc::broken_intra_doc_links) - #135771 ([rustdoc] Add support for associated items in "jump to def" feature) - #143360 (loop match: error on `#[const_continue]` outside `#[loop_match]`) - #143662 ([rustdoc] Display unsafe attrs with edition 2024 `unsafe()` wrappers.) - #143900 ([rustdoc] Correctly handle `should_panic` doctest attribute and fix `--no-run` test flag on the 2024 edition) - #144478 (Improve formatting of doc code blocks) - #144703 ([test][AIX] ignore extern_weak linkage test) - #144747 (compiletest: Improve diagnostics for line annotation mismatches 2) - #144756 (detect infinite recursion with tail calls in ctfe) - #144766 (Add human readable name "Cygwin") - #144782 (Properly pass path to staged `rustc` to `compiletest` self-tests) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 4b55fe1 + 772e645 commit 3d207da

File tree

77 files changed

+970
-283
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+970
-283
lines changed

compiler/rustc_borrowck/src/region_infer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
417417
/// minimum values.
418418
///
419419
/// For example:
420-
/// ```
420+
/// ```ignore (illustrative)
421421
/// fn foo<'a, 'b>( /* ... */ ) where 'a: 'b { /* ... */ }
422422
/// ```
423423
/// would initialize two variables like so:

compiler/rustc_hir/src/def.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ impl DefKind {
360360
/// For example, everything prefixed with `/* Res */` in this example has
361361
/// an associated `Res`:
362362
///
363-
/// ```
363+
/// ```ignore (illustrative)
364364
/// fn str_to_string(s: & /* Res */ str) -> /* Res */ String {
365365
/// /* Res */ String::from(/* Res */ s)
366366
/// }
@@ -421,7 +421,7 @@ pub enum Res<Id = hir::HirId> {
421421
/// }
422422
///
423423
/// impl Foo for Bar {
424-
/// fn foo() -> Box<Self> { // SelfTyAlias
424+
/// fn foo() -> Box<Self /* SelfTyAlias */> {
425425
/// let _: Self; // SelfTyAlias
426426
///
427427
/// todo!()

compiler/rustc_hir/src/hir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3016,7 +3016,7 @@ impl fmt::Display for LoopIdError {
30163016
}
30173017
}
30183018

3019-
#[derive(Copy, Clone, Debug, HashStable_Generic)]
3019+
#[derive(Copy, Clone, Debug, PartialEq, HashStable_Generic)]
30203020
pub struct Destination {
30213021
/// This is `Some(_)` iff there is an explicit user-specified 'label
30223022
pub label: Option<Label>,

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for RemapLateParam<'tcx> {
425425
///
426426
/// trait Foo {
427427
/// fn bar() -> impl Deref<Target = impl Sized>;
428-
/// // ^- RPITIT #1 ^- RPITIT #2
428+
/// // ^- RPITIT #1 ^- RPITIT #2
429429
/// }
430430
///
431431
/// impl Foo for () {

compiler/rustc_hir_typeck/src/loops.rs

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use std::collections::BTreeMap;
22
use std::fmt;
33

44
use Context::*;
5-
use rustc_ast::Label;
65
use rustc_hir as hir;
76
use rustc_hir::attrs::AttributeKind;
87
use rustc_hir::def::DefKind;
@@ -42,8 +41,8 @@ enum Context {
4241
ConstBlock,
4342
/// E.g. `#[loop_match] loop { state = 'label: { /* ... */ } }`.
4443
LoopMatch {
45-
/// The label of the labeled block (not of the loop itself).
46-
labeled_block: Label,
44+
/// The destination pointing to the labeled block (not to the loop itself).
45+
labeled_block: Destination,
4746
},
4847
}
4948

@@ -186,18 +185,18 @@ impl<'hir> Visitor<'hir> for CheckLoopVisitor<'hir> {
186185
{
187186
self.with_context(UnlabeledBlock(b.span.shrink_to_lo()), |v| v.visit_block(b));
188187
}
189-
hir::ExprKind::Break(break_label, ref opt_expr) => {
188+
hir::ExprKind::Break(break_destination, ref opt_expr) => {
190189
if let Some(e) = opt_expr {
191190
self.visit_expr(e);
192191
}
193192

194-
if self.require_label_in_labeled_block(e.span, &break_label, "break") {
193+
if self.require_label_in_labeled_block(e.span, &break_destination, "break") {
195194
// If we emitted an error about an unlabeled break in a labeled
196195
// block, we don't need any further checking for this break any more
197196
return;
198197
}
199198

200-
let loop_id = match break_label.target_id {
199+
let loop_id = match break_destination.target_id {
201200
Ok(loop_id) => Some(loop_id),
202201
Err(hir::LoopIdError::OutsideLoopScope) => None,
203202
Err(hir::LoopIdError::UnlabeledCfInWhileCondition) => {
@@ -212,18 +211,25 @@ impl<'hir> Visitor<'hir> for CheckLoopVisitor<'hir> {
212211

213212
// A `#[const_continue]` must break to a block in a `#[loop_match]`.
214213
if find_attr!(self.tcx.hir_attrs(e.hir_id), AttributeKind::ConstContinue(_)) {
215-
if let Some(break_label) = break_label.label {
216-
let is_target_label = |cx: &Context| match cx {
217-
Context::LoopMatch { labeled_block } => {
218-
break_label.ident.name == labeled_block.ident.name
219-
}
220-
_ => false,
221-
};
214+
let Some(label) = break_destination.label else {
215+
let span = e.span;
216+
self.tcx.dcx().emit_fatal(ConstContinueBadLabel { span });
217+
};
222218

223-
if !self.cx_stack.iter().rev().any(is_target_label) {
224-
let span = break_label.ident.span;
225-
self.tcx.dcx().emit_fatal(ConstContinueBadLabel { span });
219+
let is_target_label = |cx: &Context| match cx {
220+
Context::LoopMatch { labeled_block } => {
221+
// NOTE: with macro expansion, the label's span might be different here
222+
// even though it does still refer to the same HIR node. A block
223+
// can't have two labels, so the hir_id is a unique identifier.
224+
assert!(labeled_block.target_id.is_ok()); // see `is_loop_match`.
225+
break_destination.target_id == labeled_block.target_id
226226
}
227+
_ => false,
228+
};
229+
230+
if !self.cx_stack.iter().rev().any(is_target_label) {
231+
let span = label.ident.span;
232+
self.tcx.dcx().emit_fatal(ConstContinueBadLabel { span });
227233
}
228234
}
229235

@@ -249,7 +255,7 @@ impl<'hir> Visitor<'hir> for CheckLoopVisitor<'hir> {
249255
Some(kind) => {
250256
let suggestion = format!(
251257
"break{}",
252-
break_label
258+
break_destination
253259
.label
254260
.map_or_else(String::new, |l| format!(" {}", l.ident))
255261
);
@@ -259,7 +265,7 @@ impl<'hir> Visitor<'hir> for CheckLoopVisitor<'hir> {
259265
kind: kind.name(),
260266
suggestion,
261267
loop_label,
262-
break_label: break_label.label,
268+
break_label: break_destination.label,
263269
break_expr_kind: &break_expr.kind,
264270
break_expr_span: break_expr.span,
265271
});
@@ -268,7 +274,7 @@ impl<'hir> Visitor<'hir> for CheckLoopVisitor<'hir> {
268274
}
269275

270276
let sp_lo = e.span.with_lo(e.span.lo() + BytePos("break".len() as u32));
271-
let label_sp = match break_label.label {
277+
let label_sp = match break_destination.label {
272278
Some(label) => sp_lo.with_hi(label.ident.span.hi()),
273279
None => sp_lo.shrink_to_lo(),
274280
};
@@ -416,7 +422,7 @@ impl<'hir> CheckLoopVisitor<'hir> {
416422
&self,
417423
e: &'hir hir::Expr<'hir>,
418424
body: &'hir hir::Block<'hir>,
419-
) -> Option<Label> {
425+
) -> Option<Destination> {
420426
if !find_attr!(self.tcx.hir_attrs(e.hir_id), AttributeKind::LoopMatch(_)) {
421427
return None;
422428
}
@@ -438,8 +444,8 @@ impl<'hir> CheckLoopVisitor<'hir> {
438444

439445
let hir::ExprKind::Assign(_, rhs_expr, _) = loop_body_expr.kind else { return None };
440446

441-
let hir::ExprKind::Block(_, label) = rhs_expr.kind else { return None };
447+
let hir::ExprKind::Block(block, label) = rhs_expr.kind else { return None };
442448

443-
label
449+
Some(Destination { label, target_id: Ok(block.hir_id) })
444450
}
445451
}

compiler/rustc_hir_typeck/src/upvar.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2391,13 +2391,11 @@ fn migration_suggestion_for_2229(
23912391
/// let mut p = Point { x: 10, y: 10 };
23922392
///
23932393
/// let c = || {
2394-
/// p.x += 10;
2395-
/// // ^ E1 ^
2394+
/// p.x += 10; // E1
23962395
/// // ...
23972396
/// // More code
23982397
/// // ...
23992398
/// p.x += 10; // E2
2400-
/// // ^ E2 ^
24012399
/// };
24022400
/// ```
24032401
/// `CaptureKind` associated with both `E1` and `E2` will be ByRef(MutBorrow),

compiler/rustc_infer/src/infer/outlives/obligations.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
//! fn bar<T>(a: T, b: impl for<'a> Fn(&'a T)) {}
3737
//! fn foo<T>(x: T) {
3838
//! bar(x, |y| { /* ... */})
39-
//! // ^ closure arg
39+
//! // ^ closure arg
4040
//! }
4141
//! ```
4242
//!

compiler/rustc_middle/src/hir/map.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,10 @@ impl<'tcx> TyCtxt<'tcx> {
533533
/// ```
534534
/// fn foo(x: usize) -> bool {
535535
/// if x == 1 {
536-
/// true // If `get_fn_id_for_return_block` gets passed the `id` corresponding
537-
/// } else { // to this, it will return `foo`'s `HirId`.
536+
/// // If `get_fn_id_for_return_block` gets passed the `id` corresponding to this, it
537+
/// // will return `foo`'s `HirId`.
538+
/// true
539+
/// } else {
538540
/// false
539541
/// }
540542
/// }
@@ -543,8 +545,10 @@ impl<'tcx> TyCtxt<'tcx> {
543545
/// ```compile_fail,E0308
544546
/// fn foo(x: usize) -> bool {
545547
/// loop {
546-
/// true // If `get_fn_id_for_return_block` gets passed the `id` corresponding
547-
/// } // to this, it will return `None`.
548+
/// // If `get_fn_id_for_return_block` gets passed the `id` corresponding to this, it
549+
/// // will return `None`.
550+
/// true
551+
/// }
548552
/// false
549553
/// }
550554
/// ```

compiler/rustc_middle/src/mir/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,8 @@ pub struct LocalDecl<'tcx> {
10171017
/// ```
10181018
/// fn foo(x: &str) {
10191019
/// #[allow(unused_mut)]
1020-
/// let mut x: u32 = { // <- one unused mut
1020+
/// let mut x: u32 = {
1021+
/// //^ one unused mut
10211022
/// let mut y: u32 = x.parse().unwrap();
10221023
/// y + 2
10231024
/// };

compiler/rustc_mir_build/messages.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ mir_build_confused = missing patterns are not covered because `{$variable}` is i
8787
mir_build_const_continue_bad_const = could not determine the target branch for this `#[const_continue]`
8888
.label = this value is too generic
8989
90-
mir_build_const_continue_missing_value = a `#[const_continue]` must break to a label with a value
90+
mir_build_const_continue_missing_label_or_value = a `#[const_continue]` must break to a label with a value
9191
9292
mir_build_const_continue_not_const = could not determine the target branch for this `#[const_continue]`
9393
.help = try extracting the expression into a `const` item

0 commit comments

Comments
 (0)