Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
8203411
Fix LegacyKeyValueFormat report from docker build: mips
homersimpsons Mar 7, 2026
a22e9e0
docs: autogenerate compiler flag stubs by parsing options! macro
mehdiakiki Mar 19, 2026
83a21a5
fix: move tests to separate file and avoid tidy markers in strings
mehdiakiki Mar 19, 2026
b4f2c8a
docs: parse unstable options with syn
mehdiakiki Mar 21, 2026
deeb45a
style: fix rustfmt
mehdiakiki Mar 21, 2026
36c22f7
Add test for dead code warnings in const _
JumpiiX Mar 23, 2026
75bd926
address PR review feedback for unstable-book-gen
mehdiakiki Mar 25, 2026
16b9fdd
Improve doc comment unicode guidance
chenyukang Mar 26, 2026
8fc0581
bootstrap: `-Zjson-target-spec` for synthetic targets
davidtwco Mar 26, 2026
741a3a7
avoid ICE in explicit reference cast suggestion for unrelated leaf pr…
TaKO8Ki Mar 26, 2026
5e4e8da
bootstrap.example.toml: Hint how to allow `build.warnings`
Enselic Mar 26, 2026
7e95a22
rustdoc rejects html emits with json output
chenyukang Mar 26, 2026
a53356e
fix: [rustfmt] prevent panic when rewritng associated item delegations
ytmimi Mar 27, 2026
08bb61b
Use `tcx.is_typeck_child()` more often
zetanumbers Mar 27, 2026
1b68d92
Add typeck_root_def_id_local
zetanumbers Mar 27, 2026
2bb9d70
Use stable_crate_id more often
zetanumbers Mar 27, 2026
62ec331
Use tcx.local_parent() more often
zetanumbers Mar 27, 2026
6fd8466
Rollup merge of #154070 - mehdiakiki:unstable-book-options-parser, r=…
fmease Mar 27, 2026
9ba9194
Rollup merge of #154371 - zetanumbers:typeck_root_def_id_local, r=pet…
fmease Mar 27, 2026
da5a1d7
Rollup merge of #154405 - chenyukang:yukang-fix-153096-doc-comment-bi…
fmease Mar 27, 2026
4f6837e
Rollup merge of #154431 - TaKO8Ki:fix-explicit-reference-cast-unrelat…
fmease Mar 27, 2026
9ee5459
Rollup merge of #153528 - homersimpsons:chore/fix-LegacyKeyValueForma…
fmease Mar 27, 2026
84ecc09
Rollup merge of #154246 - JumpiiX:fix-101532-dead-code-warnings, r=fm…
fmease Mar 27, 2026
20f9361
Rollup merge of #154421 - chenyukang:yukang-fix-154395-rustdoc-json-e…
fmease Mar 27, 2026
e8994ea
Rollup merge of #154428 - davidtwco:json-target-spec-synthetic-target…
fmease Mar 27, 2026
0ddeea3
Rollup merge of #154437 - Enselic:build.warnings, r=jieyouxu
fmease Mar 27, 2026
59d8609
Rollup merge of #154454 - ytmimi:rustfmt_issue_6513, r=jieyouxu
fmease Mar 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6088,6 +6088,8 @@ name = "unstable-book-gen"
version = "0.1.0"
dependencies = [
"num-traits",
"proc-macro2",
"syn 2.0.110",
"tidy",
]

Expand Down
3 changes: 2 additions & 1 deletion bootstrap.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,8 @@
# in the sysroot. It is required for running nvptx tests.
#rust.llvm-bitcode-linker = false

# Whether to deny warnings in crates
# Whether to deny warnings in crates. Set to `false` to avoid
# error: warnings are denied by `build.warnings` configuration
#rust.deny-warnings = true

# Print backtrace on internal compiler errors during bootstrap
Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1569,10 +1569,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
let tcx = self.infcx.tcx;
let generics = tcx.generics_of(self.mir_def_id());

let Some(hir_generics) = tcx
.typeck_root_def_id(self.mir_def_id().to_def_id())
.as_local()
.and_then(|def_id| tcx.hir_get_generics(def_id))
let Some(hir_generics) =
tcx.hir_get_generics(tcx.typeck_root_def_id_local(self.mir_def_id()))
else {
return;
};
Expand Down
9 changes: 3 additions & 6 deletions compiler/rustc_borrowck/src/diagnostics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1274,12 +1274,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
if let ty::Param(param_ty) = *self_ty.kind()
&& let generics = self.infcx.tcx.generics_of(self.mir_def_id())
&& let param = generics.type_param(param_ty, self.infcx.tcx)
&& let Some(hir_generics) = self
.infcx
.tcx
.typeck_root_def_id(self.mir_def_id().to_def_id())
.as_local()
.and_then(|def_id| self.infcx.tcx.hir_get_generics(def_id))
&& let Some(hir_generics) = self.infcx.tcx.hir_get_generics(
self.infcx.tcx.typeck_root_def_id_local(self.mir_def_id()),
)
&& let spans = hir_generics
.predicates
.iter()
Expand Down
18 changes: 7 additions & 11 deletions compiler/rustc_borrowck/src/universal_regions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,12 +476,10 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
let mut indices = self.compute_indices(fr_static, defining_ty);
debug!("build: indices={:?}", indices);

let typeck_root_def_id = self.infcx.tcx.typeck_root_def_id(self.mir_def.to_def_id());

// If this is a 'root' body (not a closure/coroutine/inline const), then
// there are no extern regions, so the local regions start at the same
// position as the (empty) sub-list of extern regions
let first_local_index = if self.mir_def.to_def_id() == typeck_root_def_id {
let first_local_index = if !self.infcx.tcx.is_typeck_child(self.mir_def.to_def_id()) {
first_extern_index
} else {
// If this is a closure, coroutine, or inline-const, then the late-bound regions from the enclosing
Expand Down Expand Up @@ -583,7 +581,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
/// see `DefiningTy` for details.
fn defining_ty(&self) -> DefiningTy<'tcx> {
let tcx = self.infcx.tcx;
let typeck_root_def_id = tcx.typeck_root_def_id(self.mir_def.to_def_id());
let typeck_root_def_id = tcx.typeck_root_def_id_local(self.mir_def);

match tcx.hir_body_owner_kind(self.mir_def) {
BodyOwnerKind::Closure | BodyOwnerKind::Fn => {
Expand Down Expand Up @@ -614,7 +612,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {

BodyOwnerKind::Const { .. } | BodyOwnerKind::Static(..) => {
let identity_args = GenericArgs::identity_for_item(tcx, typeck_root_def_id);
if self.mir_def.to_def_id() == typeck_root_def_id {
if self.mir_def == typeck_root_def_id {
let args = self.infcx.replace_free_regions_with_nll_infer_vars(
NllRegionVariableOrigin::FreeRegion,
identity_args,
Expand Down Expand Up @@ -660,7 +658,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
defining_ty: DefiningTy<'tcx>,
) -> UniversalRegionIndices<'tcx> {
let tcx = self.infcx.tcx;
let typeck_root_def_id = tcx.typeck_root_def_id(self.mir_def.to_def_id());
let typeck_root_def_id = tcx.typeck_root_def_id_local(self.mir_def);
let identity_args = GenericArgs::identity_for_item(tcx, typeck_root_def_id);
let renumbered_args = defining_ty.args();

Expand Down Expand Up @@ -948,16 +946,14 @@ fn for_each_late_bound_region_in_recursive_scope<'tcx>(
mut mir_def_id: LocalDefId,
mut f: impl FnMut(ty::Region<'tcx>),
) {
let typeck_root_def_id = tcx.typeck_root_def_id(mir_def_id.to_def_id());

// Walk up the tree, collecting late-bound regions until we hit the typeck root
loop {
for_each_late_bound_region_in_item(tcx, mir_def_id, &mut f);

if mir_def_id.to_def_id() == typeck_root_def_id {
break;
} else {
if tcx.is_typeck_child(mir_def_id.to_def_id()) {
mir_def_id = tcx.local_parent(mir_def_id);
} else {
break;
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_hir_analysis/src/check/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::mem;
use rustc_data_structures::fx::FxHashMap;
use rustc_hir as hir;
use rustc_hir::def::{CtorKind, DefKind, Res};
use rustc_hir::def_id::DefId;
use rustc_hir::def_id::LocalDefId;
use rustc_hir::intravisit::{self, Visitor};
use rustc_hir::{Arm, Block, Expr, LetStmt, Pat, PatKind, Stmt};
use rustc_index::Idx;
Expand Down Expand Up @@ -849,13 +849,13 @@ impl<'tcx> Visitor<'tcx> for ScopeResolutionVisitor<'tcx> {
/// re-use in incremental scenarios. We may sometimes need to rerun the
/// type checker even when the HIR hasn't changed, and in those cases
/// we can avoid reconstructing the region scope tree.
pub(crate) fn region_scope_tree(tcx: TyCtxt<'_>, def_id: DefId) -> &ScopeTree {
let typeck_root_def_id = tcx.typeck_root_def_id(def_id);
pub(crate) fn region_scope_tree(tcx: TyCtxt<'_>, def_id: LocalDefId) -> &ScopeTree {
let typeck_root_def_id = tcx.typeck_root_def_id_local(def_id);
if typeck_root_def_id != def_id {
return tcx.region_scope_tree(typeck_root_def_id);
}

let scope_tree = if let Some(body) = tcx.hir_maybe_body_owned_by(def_id.expect_local()) {
let scope_tree = if let Some(body) = tcx.hir_maybe_body_owned_by(def_id) {
let mut visitor = ScopeResolutionVisitor {
tcx,
scope_tree: ScopeTree::default(),
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_hir_analysis/src/collect/generics_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
| Node::Ctor(..)
| Node::Field(_) => {
let parent_id = tcx.hir_get_parent_item(hir_id);
Some(parent_id.to_def_id())
Some(parent_id.def_id)
}
// FIXME(#43408) always enable this once `lazy_normalization` is
// stable enough and does not need a feature gate anymore.
Node::AnonConst(_) => {
let parent_did = tcx.parent(def_id.to_def_id());
let parent_did = tcx.local_parent(def_id);
debug!(?parent_did);

let mut in_param_ty = false;
Expand Down Expand Up @@ -175,7 +175,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
}
Node::ConstBlock(_)
| Node::Expr(&hir::Expr { kind: hir::ExprKind::Closure { .. }, .. }) => {
Some(tcx.typeck_root_def_id(def_id.to_def_id()))
Some(tcx.typeck_root_def_id_local(def_id))
}
Node::OpaqueTy(&hir::OpaqueTy {
origin:
Expand All @@ -188,7 +188,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
} else {
assert_matches!(tcx.def_kind(fn_def_id), DefKind::AssocFn | DefKind::Fn);
}
Some(fn_def_id.to_def_id())
Some(fn_def_id)
}
Node::OpaqueTy(&hir::OpaqueTy {
origin: hir::OpaqueTyOrigin::TyAlias { parent, in_assoc_ty },
Expand All @@ -202,7 +202,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
debug!("generics_of: parent of opaque ty {:?} is {:?}", def_id, parent);
// Opaque types are always nested within another item, and
// inherit the generics of the item.
Some(parent.to_def_id())
Some(parent)
}

// All of these nodes have no parent from which to inherit generics.
Expand Down Expand Up @@ -380,7 +380,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
own_params.iter().map(|param| (param.def_id, param.index)).collect();

ty::Generics {
parent: parent_def_id,
parent: parent_def_id.map(LocalDefId::to_def_id),
parent_count,
own_params,
param_def_id_to_index,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/collect/predicates_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
);

return ty::GenericPredicates {
parent: Some(tcx.parent(def_id.to_def_id())),
parent: Some(tcx.local_parent(def_id).to_def_id()),
predicates: tcx.arena.alloc_from_iter(predicates),
};
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
debug!(?bound_sig, ?liberated_sig);

let parent_args =
GenericArgs::identity_for_item(tcx, tcx.typeck_root_def_id(expr_def_id.to_def_id()));
GenericArgs::identity_for_item(tcx, tcx.typeck_root_def_id_local(expr_def_id));

let tupled_upvars_ty = self.next_ty_var(expr_span);

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ fn typeck_with_inspect<'tcx>(
) -> &'tcx ty::TypeckResults<'tcx> {
// Closures' typeck results come from their outermost function,
// as they are part of the same "inference environment".
let typeck_root_def_id = tcx.typeck_root_def_id(def_id.to_def_id()).expect_local();
let typeck_root_def_id = tcx.typeck_root_def_id_local(def_id);
if typeck_root_def_id != def_id {
return tcx.typeck(typeck_root_def_id);
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_metadata/src/rmeta/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
is_stub: false,
},
extra_filename: tcx.sess.opts.cg.extra_filename.clone(),
stable_crate_id: tcx.def_path_hash(LOCAL_CRATE.as_def_id()).stable_crate_id(),
stable_crate_id: tcx.stable_crate_id(LOCAL_CRATE),
required_panic_strategy: tcx.required_panic_strategy(LOCAL_CRATE),
panic_in_drop_strategy: tcx.sess.opts.unstable_opts.panic_in_drop,
edition: tcx.sess.edition(),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1413,7 +1413,7 @@ rustc_queries! {

/// Per-body `region::ScopeTree`. The `DefId` should be the owner `DefId` for the body;
/// in the case of closures, this will be redirected to the enclosing function.
query region_scope_tree(def_id: DefId) -> &'tcx crate::middle::region::ScopeTree {
query region_scope_tree(def_id: LocalDefId) -> &'tcx crate::middle::region::ScopeTree {
desc { "computing drop scopes for `{}`", tcx.def_path_str(def_id) }
}

Expand Down
8 changes: 2 additions & 6 deletions compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -899,12 +899,8 @@ impl<'tcx> TyCtxt<'tcx> {
pub fn has_typeck_results(self, def_id: LocalDefId) -> bool {
// Closures' typeck results come from their outermost function,
// as they are part of the same "inference environment".
let typeck_root_def_id = self.typeck_root_def_id(def_id.to_def_id());
if typeck_root_def_id != def_id.to_def_id() {
return self.has_typeck_results(typeck_root_def_id.expect_local());
}

self.hir_node_by_def_id(def_id).body_id().is_some()
let root = self.typeck_root_def_id_local(def_id);
self.hir_node_by_def_id(root).body_id().is_some()
}

/// Expects a body and returns its codegen attributes.
Expand Down
14 changes: 14 additions & 0 deletions compiler/rustc_middle/src/ty/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,20 @@ impl<'tcx> TyCtxt<'tcx> {
def_id
}

/// Given the `LocalDefId`, returns the `LocalDefId` of the innermost item that
/// has its own type-checking context or "inference environment".
///
/// For example, a closure has its own `LocalDefId`, but it is type-checked
/// with the containing item. Therefore, when we fetch the `typeck` of the closure,
/// for example, we really wind up fetching the `typeck` of the enclosing fn item.
pub fn typeck_root_def_id_local(self, def_id: LocalDefId) -> LocalDefId {
let mut def_id = def_id;
while self.is_typeck_child(def_id.to_def_id()) {
def_id = self.local_parent(def_id);
}
def_id
}

/// Given the `DefId` and args a closure, creates the type of
/// `self` argument that the closure expects. For example, for a
/// `Fn` closure, this would return a reference type `&T` where
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_mir_build/src/thir/cx/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -816,16 +816,16 @@ impl<'tcx> ThirBuildCx<'tcx> {
}
hir::InlineAsmOperand::Const { ref anon_const } => {
let ty = self.typeck_results.node_type(anon_const.hir_id);
let did = anon_const.def_id.to_def_id();
let typeck_root_def_id = tcx.typeck_root_def_id(did);
let did = anon_const.def_id;
let typeck_root_def_id = tcx.typeck_root_def_id_local(did);
let parent_args = tcx.erase_and_anonymize_regions(
GenericArgs::identity_for_item(tcx, typeck_root_def_id),
);
let args =
InlineConstArgs::new(tcx, InlineConstArgsParts { parent_args, ty })
.args;

let uneval = mir::UnevaluatedConst::new(did, args);
let uneval = mir::UnevaluatedConst::new(did.to_def_id(), args);
let value = mir::Const::Unevaluated(uneval, ty);
InlineAsmOperand::Const { value, span: tcx.def_span(did) }
}
Expand Down Expand Up @@ -895,15 +895,15 @@ impl<'tcx> ThirBuildCx<'tcx> {

hir::ExprKind::ConstBlock(ref anon_const) => {
let ty = self.typeck_results.node_type(anon_const.hir_id);
let did = anon_const.def_id.to_def_id();
let typeck_root_def_id = tcx.typeck_root_def_id(did);
let did = anon_const.def_id;
let typeck_root_def_id = tcx.typeck_root_def_id_local(did);
let parent_args = tcx.erase_and_anonymize_regions(GenericArgs::identity_for_item(
tcx,
typeck_root_def_id,
));
let args = InlineConstArgs::new(tcx, InlineConstArgsParts { parent_args, ty }).args;

ExprKind::ConstBlock { did, args }
ExprKind::ConstBlock { did: did.to_def_id(), args }
}
// Now comes the rote stuff:
hir::ExprKind::Repeat(v, _) => {
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_mir_transform/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ fn mir_drops_elaborated_and_const_checked(tcx: TyCtxt<'_>, def: LocalDefId) -> &

// We only need to borrowck non-synthetic MIR.
let tainted_by_errors = if !tcx.is_synthetic_mir(def) {
tcx.mir_borrowck(tcx.typeck_root_def_id(def.to_def_id()).expect_local()).err()
tcx.mir_borrowck(tcx.typeck_root_def_id_local(def)).err()
} else {
None
};
Expand Down Expand Up @@ -554,14 +554,14 @@ fn mir_drops_elaborated_and_const_checked(tcx: TyCtxt<'_>, def: LocalDefId) -> &
//
// We do this check here and not during `mir_promoted` because that may result
// in borrowck cycles if WF requires looking into an opaque hidden type.
let root = tcx.typeck_root_def_id(def.to_def_id());
let root = tcx.typeck_root_def_id_local(def);
match tcx.def_kind(root) {
DefKind::Fn
| DefKind::AssocFn
| DefKind::Static { .. }
| DefKind::Const { .. }
| DefKind::AssocConst { .. } => {
if let Err(guar) = tcx.ensure_result().check_well_formed(root.expect_local()) {
if let Err(guar) = tcx.ensure_result().check_well_formed(root) {
body.tainted_by_errors = Some(guar);
}
}
Expand Down Expand Up @@ -840,7 +840,7 @@ fn promoted_mir(tcx: TyCtxt<'_>, def: LocalDefId) -> &IndexVec<Promoted, Body<'_
}

if !tcx.is_synthetic_mir(def) {
tcx.ensure_done().mir_borrowck(tcx.typeck_root_def_id(def.to_def_id()).expect_local());
tcx.ensure_done().mir_borrowck(tcx.typeck_root_def_id_local(def));
}
let mut promoted = tcx.mir_promoted(def).1.steal();

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub(crate) fn check_liveness<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Den
}

// Don't run unused pass for #[derive]
let parent = tcx.parent(tcx.typeck_root_def_id(def_id.to_def_id()));
let parent = tcx.local_parent(tcx.typeck_root_def_id_local(def_id));
if let DefKind::Impl { of_trait: true } = tcx.def_kind(parent)
&& find_attr!(tcx, parent, AutomaticallyDerived(..))
{
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_monomorphize/src/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1615,7 +1615,7 @@ impl<'v> RootCollector<'_, 'v> {
if (self.strategy == MonoItemCollectionStrategy::Eager || is_pub_fn_coroutine)
&& !self
.tcx
.generics_of(self.tcx.typeck_root_def_id(def_id.to_def_id()))
.generics_of(self.tcx.typeck_root_def_id_local(def_id))
.requires_monomorphization(self.tcx)
{
let instance = match *self.tcx.type_of(def_id).instantiate_identity().kind() {
Expand Down
10 changes: 7 additions & 3 deletions compiler/rustc_parse/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4344,7 +4344,7 @@ impl Subdiagnostic for HiddenUnicodeCodepointsDiagLabels {

pub(crate) enum HiddenUnicodeCodepointsDiagSub {
Escape { spans: Vec<(char, Span)> },
NoEscape { spans: Vec<(char, Span)> },
NoEscape { spans: Vec<(char, Span)>, is_doc_comment: bool },
}

// Used because of multiple multipart_suggestion and note
Expand All @@ -4370,7 +4370,7 @@ impl Subdiagnostic for HiddenUnicodeCodepointsDiagSub {
Applicability::MachineApplicable,
);
}
HiddenUnicodeCodepointsDiagSub::NoEscape { spans } => {
HiddenUnicodeCodepointsDiagSub::NoEscape { spans, is_doc_comment } => {
// FIXME: in other suggestions we've reversed the inner spans of doc comments. We
// should do the same here to provide the same good suggestions as we do for
// literals above.
Expand All @@ -4383,7 +4383,11 @@ impl Subdiagnostic for HiddenUnicodeCodepointsDiagSub {
.join(", "),
);
diag.note(msg!("if their presence wasn't intentional, you can remove them"));
diag.note(msg!("if you want to keep them but make them visible in your source code, you can escape them: {$escaped}"));
if is_doc_comment {
diag.note(msg!(r#"if you need to keep them and make them explicit in source, rewrite this doc comment as a `#[doc = "..."]` attribute and use Unicode escapes such as {$escaped}"#));
} else {
diag.note(msg!("if you want to keep them but make them visible in your source code, you can escape them: {$escaped}"));
}
}
}
}
Expand Down
Loading
Loading