Skip to content

Commit bcf3d36

Browse files
committed
Auto merge of #154092 - JonathanBrouwer:rollup-GKNFJe0, r=JonathanBrouwer
Rollup of 19 pull requests Successful merges: - #152870 (Do not enable split debuginfo for windows-gnu) - #153333 (Fix bootstrap rust build failure for vxworks) - #153681 (ci: add runners for vanilla LLVM 22) - #153727 (When single impl can satisfy inference error, suggest type) - #153824 (Add `Wake` diagnostic item for `alloc::task::Wake`) - #154077 (Optimize 128-bit integer formatting) - #154078 (`define_callbacks` tweaks) - #151905 (Split the `dec2flt::RawFloat` trait for easier reuse) - #153170 (Add is_disconnected functions to mpsc and mpmc channels) - #153308 (Add hygiene annotations for tokens in `macro_rules!` bodies) - #153557 (fix inference variables leaking into HIR const literal lowering logic) - #153804 (Derive Macro Eq: link to more detailed documentation) - #153913 (Fix some suggestions of the `for-loops-over-fallibles` lint) - #153974 (Point at return type when it is the source of the type expectation) - #153987 (mGCA: Lower const generic args to infer when needed) - #154018 (simplify and remove `tests/ui/kindck` and related tests) - #154036 (borrowck/type_check: remove helper left-over from unsized locals) - #154038 (merge `regions-outlives-nominal-type-*` tests into one file) - #154041 (bootstrap: Allow `--bless`ing changes to editor settings files)
2 parents 1f7f8ea + 71e463b commit bcf3d36

File tree

109 files changed

+1834
-1150
lines changed

Some content is hidden

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

109 files changed

+1834
-1150
lines changed

‎bootstrap.example.toml‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,9 +1013,10 @@
10131013
# its historical default, but when compiling the compiler itself, we skip it by
10141014
# default since we know it's safe to do so in that case.
10151015
#
1016-
# On Windows platforms, packed debuginfo is the only supported option,
1017-
# producing a `.pdb` file.
1018-
#split-debuginfo = if linux { off } else if windows { packed } else if apple { unpacked }
1016+
# On Windows MSVC platforms, packed debuginfo is the only supported option,
1017+
# producing a `.pdb` file. On Windows GNU rustc doesn't support splitting debuginfo,
1018+
# and enabling it causes issues.
1019+
#split-debuginfo = if linux || windows-gnu { off } else if windows-msvc { packed } else if apple { unpacked }
10191020

10201021
# Path to the `llvm-config` binary of the installation of a custom LLVM to link
10211022
# against. Note that if this is specified we don't compile LLVM at all for this

‎compiler/rustc_ast_lowering/src/lib.rs‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,9 +1310,13 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
13101310
}
13111311
GenericArg::Type(self.lower_ty_alloc(ty, itctx).try_as_ambig_ty().unwrap())
13121312
}
1313-
ast::GenericArg::Const(ct) => GenericArg::Const(
1314-
self.lower_anon_const_to_const_arg_and_alloc(ct).try_as_ambig_ct().unwrap(),
1315-
),
1313+
ast::GenericArg::Const(ct) => {
1314+
let ct = self.lower_anon_const_to_const_arg_and_alloc(ct);
1315+
match ct.try_as_ambig_ct() {
1316+
Some(ct) => GenericArg::Const(ct),
1317+
None => GenericArg::Infer(hir::InferArg { hir_id: ct.hir_id, span: ct.span }),
1318+
}
1319+
}
13161320
}
13171321
}
13181322

‎compiler/rustc_ast_pretty/src/pprust/state.rs‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,23 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
737737
TokenTree::Token(token, spacing) => {
738738
let token_str = self.token_to_string_ext(token, convert_dollar_crate);
739739
self.word(token_str);
740+
// Emit hygiene annotations for identity-bearing tokens,
741+
// matching how print_ident() and print_lifetime() call ann_post().
742+
match token.kind {
743+
token::Ident(name, _) => {
744+
self.ann_post(Ident::new(name, token.span));
745+
}
746+
token::NtIdent(ident, _) => {
747+
self.ann_post(ident);
748+
}
749+
token::Lifetime(name, _) => {
750+
self.ann_post(Ident::new(name, token.span));
751+
}
752+
token::NtLifetime(ident, _) => {
753+
self.ann_post(ident);
754+
}
755+
_ => {}
756+
}
740757
if let token::DocComment(..) = token.kind {
741758
self.hardbreak()
742759
}

‎compiler/rustc_borrowck/src/type_check/mod.rs‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -374,10 +374,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
374374
self.body
375375
}
376376

377-
fn unsized_feature_enabled(&self) -> bool {
378-
self.tcx().features().unsized_fn_params()
379-
}
380-
381377
/// Equate the inferred type and the annotated type for user type annotations
382378
#[instrument(skip(self), level = "debug")]
383379
fn check_user_type_annotations(&mut self) {
@@ -660,7 +656,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
660656
);
661657
}
662658

663-
if !self.unsized_feature_enabled() {
659+
if !self.tcx().features().unsized_fn_params() {
664660
let trait_ref = ty::TraitRef::new(
665661
tcx,
666662
tcx.require_lang_item(LangItem::Sized, self.last_span),
@@ -936,9 +932,10 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
936932
}
937933
}
938934

939-
// When `unsized_fn_params` is enabled, only function calls
940-
// and nullary ops are checked in `check_call_dest`.
941-
if !self.unsized_feature_enabled() {
935+
// When `unsized_fn_params` is enabled, this is checked in `check_call_dest`,
936+
// and `hir_typeck` still forces all non-argument locals to be sized (i.e., we don't
937+
// fully re-check what was already checked on HIR).
938+
if !self.tcx().features().unsized_fn_params() {
942939
match self.body.local_kind(local) {
943940
LocalKind::ReturnPointer | LocalKind::Arg => {
944941
// return values of normal functions are required to be
@@ -1953,8 +1950,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
19531950
}
19541951

19551952
// When `unsized_fn_params` is not enabled,
1956-
// this check is done at `check_local`.
1957-
if self.unsized_feature_enabled() {
1953+
// this check is done at `visit_local_decl`.
1954+
if self.tcx().features().unsized_fn_params() {
19581955
let span = term.source_info.span;
19591956
self.ensure_place_sized(dest_ty, span);
19601957
}

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2874,6 +2874,9 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
28742874
span: Span,
28752875
) -> Const<'tcx> {
28762876
let tcx = self.tcx();
2877+
2878+
let ty = if !ty.has_infer() { Some(ty) } else { None };
2879+
28772880
if let LitKind::Err(guar) = *kind {
28782881
return ty::Const::new_error(tcx, guar);
28792882
}
@@ -2905,16 +2908,20 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
29052908
};
29062909

29072910
let lit_input = match expr.kind {
2908-
hir::ExprKind::Lit(lit) => Some(LitToConstInput { lit: lit.node, ty, neg: false }),
2911+
hir::ExprKind::Lit(lit) => {
2912+
Some(LitToConstInput { lit: lit.node, ty: Some(ty), neg: false })
2913+
}
29092914
hir::ExprKind::Unary(hir::UnOp::Neg, expr) => match expr.kind {
2910-
hir::ExprKind::Lit(lit) => Some(LitToConstInput { lit: lit.node, ty, neg: true }),
2915+
hir::ExprKind::Lit(lit) => {
2916+
Some(LitToConstInput { lit: lit.node, ty: Some(ty), neg: true })
2917+
}
29112918
_ => None,
29122919
},
29132920
_ => None,
29142921
};
29152922

29162923
lit_input.and_then(|l| {
2917-
if const_lit_matches_ty(tcx, &l.lit, l.ty, l.neg) {
2924+
if const_lit_matches_ty(tcx, &l.lit, ty, l.neg) {
29182925
tcx.at(expr.span)
29192926
.lit_to_const(l)
29202927
.map(|value| ty::Const::new_value(tcx, value.valtree, value.ty))

‎compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs‎

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_hir::attrs::DivergingBlockBehavior;
1111
use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res};
1212
use rustc_hir::def_id::DefId;
1313
use rustc_hir::intravisit::Visitor;
14-
use rustc_hir::{Expr, ExprKind, HirId, LangItem, Node, QPath, is_range_literal};
14+
use rustc_hir::{Expr, ExprKind, FnRetTy, HirId, LangItem, Node, QPath, is_range_literal};
1515
use rustc_hir_analysis::check::potentially_plural_count;
1616
use rustc_hir_analysis::hir_ty_lowering::{HirTyLowerer, PermitVariants};
1717
use rustc_index::IndexVec;
@@ -1582,6 +1582,45 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
15821582
}
15831583
}
15841584
err.span_note(spans, format!("{} defined here", self.tcx.def_descr(def_id)));
1585+
if let DefKind::Fn | DefKind::AssocFn = self.tcx.def_kind(def_id)
1586+
&& let ty::Param(_) =
1587+
self.tcx.fn_sig(def_id).instantiate_identity().skip_binder().output().kind()
1588+
&& let parent = self.tcx.hir_get_parent_item(call_expr.hir_id).def_id
1589+
&& let Some((output, body_id)) = match self.tcx.hir_node_by_def_id(parent) {
1590+
hir::Node::Item(hir::Item {
1591+
kind: hir::ItemKind::Fn { sig, body, .. },
1592+
..
1593+
})
1594+
| hir::Node::TraitItem(hir::TraitItem {
1595+
kind: hir::TraitItemKind::Fn(sig, hir::TraitFn::Provided(body)),
1596+
..
1597+
})
1598+
| hir::Node::ImplItem(hir::ImplItem {
1599+
kind: hir::ImplItemKind::Fn(sig, body),
1600+
..
1601+
}) => Some((sig.decl.output, body)),
1602+
_ => None,
1603+
}
1604+
&& let expr = self.tcx.hir_body(*body_id).value
1605+
&& (expr.peel_blocks().span == call_expr.span
1606+
|| matches!(
1607+
self.tcx.parent_hir_node(call_expr.hir_id),
1608+
hir::Node::Expr(hir::Expr { kind: hir::ExprKind::Ret(_), .. })
1609+
))
1610+
{
1611+
err.span_label(
1612+
output.span(),
1613+
match output {
1614+
FnRetTy::DefaultReturn(_) => format!(
1615+
"this implicit `()` return type influences the call expression's return type"
1616+
),
1617+
FnRetTy::Return(_) => {
1618+
"this return type influences the call expression's return type"
1619+
.to_string()
1620+
}
1621+
},
1622+
);
1623+
}
15851624
} else if let Some(hir::Node::Expr(e)) = self.tcx.hir_get_if_local(def_id)
15861625
&& let hir::ExprKind::Closure(hir::Closure { body, .. }) = &e.kind
15871626
{

‎compiler/rustc_lint/src/for_loops_over_fallibles.rs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ impl<'tcx> LateLintPass<'tcx> for ForLoopsOverFallibles {
4949
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
5050
let Some((pat, arg)) = extract_for_loop(expr) else { return };
5151

52+
// Do not put suggestions for external macros.
53+
if pat.span.from_expansion() {
54+
return;
55+
}
56+
5257
let arg_span = arg.span.source_callsite();
5358

5459
let ty = cx.typeck_results().expr_ty(arg);
@@ -77,6 +82,8 @@ impl<'tcx> LateLintPass<'tcx> for ForLoopsOverFallibles {
7782
};
7883

7984
let sub = if let Some(recv) = extract_iterator_next_call(cx, arg)
85+
&& recv.span.can_be_used_for_suggestions()
86+
&& recv.span.between(arg_span.shrink_to_hi()).can_be_used_for_suggestions()
8087
&& let Ok(recv_snip) = cx.sess().source_map().span_to_snippet(recv.span)
8188
{
8289
ForLoopsOverFalliblesLoopSub::RemoveNext {

‎compiler/rustc_middle/src/queries.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ use crate::mir::mono::{
101101
CodegenUnit, CollectionMode, MonoItem, MonoItemPartitions, NormalizationErrorInMono,
102102
};
103103
use crate::query::describe_as_module;
104-
use crate::query::plumbing::{define_callbacks, query_helper_param_ty};
104+
use crate::query::plumbing::{define_callbacks, maybe_into_query_key};
105105
use crate::traits::query::{
106106
CanonicalAliasGoal, CanonicalDropckOutlivesGoal, CanonicalImpliedOutlivesBoundsGoal,
107107
CanonicalMethodAutoderefStepsGoal, CanonicalPredicateGoal, CanonicalTypeOpAscribeUserTypeGoal,

0 commit comments

Comments
 (0)