Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
4da823b
Do not enable split debuginfo for windows-gnu
mati865 Feb 19, 2026
7adb9ba
Add is_disconnected functions to mpsc and mpmc channels
LevitatingBusinessMan Feb 27, 2026
feef7b4
warn of possible race condition in channel is_disconnected doc
LevitatingBusinessMan Feb 28, 2026
f5a2bb6
Add hygiene annotations for tokens in macro_rules! bodies
aytey Mar 2, 2026
bf6db4f
Add regression tests for token hygiene annotations in macro bodies
aytey Mar 3, 2026
ce2de64
assign mpsc_is_disconnected issue 153668
LevitatingBusinessMan Mar 10, 2026
b36ee95
ci: add runners for vanilla LLVM 22
cuviper Mar 11, 2026
b3b6627
Derive Macro Eq: link to more detailed documentation
DanielEScherzer Mar 13, 2026
6e7d6d7
Add `Wake` diagnostic item for `alloc::task::Wake`
samueltardieu Mar 12, 2026
02ac190
dec2flt: Rename `Integer` to `Int`
tgross35 Jan 31, 2026
b07c043
dec2flt: Split up the `RawFloat` trait
tgross35 Jan 31, 2026
bec94a3
dec2flt: Move internal traits to better locations
tgross35 Jan 31, 2026
24d86b5
Fix rust build failure for vxworks
gautam899 Mar 3, 2026
7ec77fd
Fix invalid suggestion on `for-loops-over-fallibles`
JohnTitor Mar 15, 2026
924374c
mGCA: Lower const generic args to infer when needed
reddevilmidzy Mar 17, 2026
11810b8
fix inference variables leaking into HIR const lowering logic
Human9000-bit Mar 8, 2026
5113488
Improve `ty::Infer` handling during const literal lowering
Human9000-bit Mar 17, 2026
69fd61e
merge `kindck/send-*` tests
cyrgani Mar 17, 2026
b4c1677
Do not lint `for-loops-over-fallibles` on external macros
JohnTitor Mar 15, 2026
cfe18cf
Correct dir name
JohnTitor Mar 15, 2026
caeda18
reformat and update remaining `ui/kindck` tests
cyrgani Mar 17, 2026
62b9fa1
move tests from `ui/kindck` to `ui/traits`
cyrgani Mar 17, 2026
eda328c
delete incorrect test
cyrgani Mar 17, 2026
38aa322
borrowck/type_check: remove helper left-over from unsized locals
RalfJung Mar 18, 2026
6b0fecf
merge `regions-outlives-nominal-type-*` tests into one file
cyrgani Mar 18, 2026
c8a2c46
bootstrap: Optionally print a backtrace if a command fails
jyn514 Mar 16, 2026
a4d2384
Move hashes into a separate json file
jyn514 Mar 18, 2026
a085b68
Add bootstrap step for stdarch-verify
xonx4l Mar 18, 2026
49bb371
When single impl can satisfy inference error, suggest type
estebank Mar 11, 2026
ca2139d
Point at return type when it is the source of the type expectation
estebank Mar 16, 2026
1098a9d
Support `--bless`-ing editor hashes
jyn514 Mar 18, 2026
ebb1f47
Optimize 128-bit integer formatting
jhpratt Mar 19, 2026
ce55a8c
Rollup merge of #153957 - xonx4l:stdarch-verify, r=Kobzol
Zalathar Mar 19, 2026
00da2e5
Rollup merge of #152870 - mati865:mingw-disable-packed-debuginfo-in-b…
Zalathar Mar 19, 2026
b6c4338
Rollup merge of #153333 - gautam899:main, r=Mark-Simulacrum
Zalathar Mar 19, 2026
091838f
Rollup merge of #153681 - cuviper:ci-llvm-22, r=Mark-Simulacrum
Zalathar Mar 19, 2026
e32084b
Rollup merge of #153727 - estebank:issue-100802, r=JohnTitor
Zalathar Mar 19, 2026
b4fff12
Rollup merge of #153824 - samueltardieu:wake-diagnostic-item, r=Mark-…
Zalathar Mar 19, 2026
c988eff
Rollup merge of #154077 - jhpratt:optimize-128-bit-formatting, r=dtolnay
Zalathar Mar 19, 2026
be53009
Rollup merge of #151905 - tgross35:dec2flt-traits, r=Mark-Simulacrum
Zalathar Mar 19, 2026
d812fb4
Rollup merge of #153170 - LevitatingBusinessMan:is_disconnected, r=Ma…
Zalathar Mar 19, 2026
657e347
Rollup merge of #153308 - aytey:macro_meta_hygiene, r=jdonszelmann
Zalathar Mar 19, 2026
a69519e
Rollup merge of #153557 - Human9000-bit:issue-153525, r=BoxyUwU
Zalathar Mar 19, 2026
526c4c4
Rollup merge of #153804 - DanielEScherzer:derive-eq-docs, r=Mark-Simu…
Zalathar Mar 19, 2026
052b068
Rollup merge of #153913 - JohnTitor:issue-148814, r=Kivooeo
Zalathar Mar 19, 2026
0eb86bf
Rollup merge of #153974 - estebank:issue-43608, r=nnethercote
Zalathar Mar 19, 2026
f56662a
Rollup merge of #153987 - reddevilmidzy:mgca-ast, r=BoxyUwU
Zalathar Mar 19, 2026
f951c0e
Rollup merge of #153992 - ferrocene:jyn/bootstrap-backtrace, r=jieyou…
Zalathar Mar 19, 2026
78c0bd7
Rollup merge of #154018 - cyrgani:kindck-tests, r=jieyouxu
Zalathar Mar 19, 2026
eecd65a
Rollup merge of #154036 - RalfJung:unsized-locals-helper-rm, r=nnethe…
Zalathar Mar 19, 2026
c63be99
Rollup merge of #154038 - cyrgani:regiontests, r=Kivooeo
Zalathar Mar 19, 2026
773e481
Rollup merge of #154041 - ferrocene:jyn/bless-hashes, r=jieyouxu
Zalathar Mar 19, 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
7 changes: 4 additions & 3 deletions bootstrap.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1013,9 +1013,10 @@
# its historical default, but when compiling the compiler itself, we skip it by
# default since we know it's safe to do so in that case.
#
# On Windows platforms, packed debuginfo is the only supported option,
# producing a `.pdb` file.
#split-debuginfo = if linux { off } else if windows { packed } else if apple { unpacked }
# On Windows MSVC platforms, packed debuginfo is the only supported option,
# producing a `.pdb` file. On Windows GNU rustc doesn't support splitting debuginfo,
# and enabling it causes issues.
#split-debuginfo = if linux || windows-gnu { off } else if windows-msvc { packed } else if apple { unpacked }

# Path to the `llvm-config` binary of the installation of a custom LLVM to link
# against. Note that if this is specified we don't compile LLVM at all for this
Expand Down
10 changes: 7 additions & 3 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1310,9 +1310,13 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
}
GenericArg::Type(self.lower_ty_alloc(ty, itctx).try_as_ambig_ty().unwrap())
}
ast::GenericArg::Const(ct) => GenericArg::Const(
self.lower_anon_const_to_const_arg_and_alloc(ct).try_as_ambig_ct().unwrap(),
),
ast::GenericArg::Const(ct) => {
let ct = self.lower_anon_const_to_const_arg_and_alloc(ct);
match ct.try_as_ambig_ct() {
Some(ct) => GenericArg::Const(ct),
None => GenericArg::Infer(hir::InferArg { hir_id: ct.hir_id, span: ct.span }),
}
}
}
}

Expand Down
17 changes: 17 additions & 0 deletions compiler/rustc_ast_pretty/src/pprust/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,23 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
TokenTree::Token(token, spacing) => {
let token_str = self.token_to_string_ext(token, convert_dollar_crate);
self.word(token_str);
// Emit hygiene annotations for identity-bearing tokens,
// matching how print_ident() and print_lifetime() call ann_post().
match token.kind {
token::Ident(name, _) => {
self.ann_post(Ident::new(name, token.span));
}
token::NtIdent(ident, _) => {
self.ann_post(ident);
}
token::Lifetime(name, _) => {
self.ann_post(Ident::new(name, token.span));
}
token::NtLifetime(ident, _) => {
self.ann_post(ident);
}
_ => {}
}
if let token::DocComment(..) = token.kind {
self.hardbreak()
}
Expand Down
17 changes: 7 additions & 10 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
self.body
}

fn unsized_feature_enabled(&self) -> bool {
self.tcx().features().unsized_fn_params()
}

/// Equate the inferred type and the annotated type for user type annotations
#[instrument(skip(self), level = "debug")]
fn check_user_type_annotations(&mut self) {
Expand Down Expand Up @@ -660,7 +656,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
);
}

if !self.unsized_feature_enabled() {
if !self.tcx().features().unsized_fn_params() {
let trait_ref = ty::TraitRef::new(
tcx,
tcx.require_lang_item(LangItem::Sized, self.last_span),
Expand Down Expand Up @@ -936,9 +932,10 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
}
}

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

// When `unsized_fn_params` is not enabled,
// this check is done at `check_local`.
if self.unsized_feature_enabled() {
// this check is done at `visit_local_decl`.
if self.tcx().features().unsized_fn_params() {
let span = term.source_info.span;
self.ensure_place_sized(dest_ty, span);
}
Expand Down
13 changes: 10 additions & 3 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2874,6 +2874,9 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
span: Span,
) -> Const<'tcx> {
let tcx = self.tcx();

let ty = if !ty.has_infer() { Some(ty) } else { None };

if let LitKind::Err(guar) = *kind {
return ty::Const::new_error(tcx, guar);
}
Expand Down Expand Up @@ -2905,16 +2908,20 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
};

let lit_input = match expr.kind {
hir::ExprKind::Lit(lit) => Some(LitToConstInput { lit: lit.node, ty, neg: false }),
hir::ExprKind::Lit(lit) => {
Some(LitToConstInput { lit: lit.node, ty: Some(ty), neg: false })
}
hir::ExprKind::Unary(hir::UnOp::Neg, expr) => match expr.kind {
hir::ExprKind::Lit(lit) => Some(LitToConstInput { lit: lit.node, ty, neg: true }),
hir::ExprKind::Lit(lit) => {
Some(LitToConstInput { lit: lit.node, ty: Some(ty), neg: true })
}
_ => None,
},
_ => None,
};

lit_input.and_then(|l| {
if const_lit_matches_ty(tcx, &l.lit, l.ty, l.neg) {
if const_lit_matches_ty(tcx, &l.lit, ty, l.neg) {
tcx.at(expr.span)
.lit_to_const(l)
.map(|value| ty::Const::new_value(tcx, value.valtree, value.ty))
Expand Down
41 changes: 40 additions & 1 deletion compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use rustc_hir::attrs::DivergingBlockBehavior;
use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res};
use rustc_hir::def_id::DefId;
use rustc_hir::intravisit::Visitor;
use rustc_hir::{Expr, ExprKind, HirId, LangItem, Node, QPath, is_range_literal};
use rustc_hir::{Expr, ExprKind, FnRetTy, HirId, LangItem, Node, QPath, is_range_literal};
use rustc_hir_analysis::check::potentially_plural_count;
use rustc_hir_analysis::hir_ty_lowering::{HirTyLowerer, PermitVariants};
use rustc_index::IndexVec;
Expand Down Expand Up @@ -1587,6 +1587,45 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
err.span_note(spans, format!("{} defined here", self.tcx.def_descr(def_id)));
if let DefKind::Fn | DefKind::AssocFn = self.tcx.def_kind(def_id)
&& let ty::Param(_) =
self.tcx.fn_sig(def_id).instantiate_identity().skip_binder().output().kind()
&& let parent = self.tcx.hir_get_parent_item(call_expr.hir_id).def_id
&& let Some((output, body_id)) = match self.tcx.hir_node_by_def_id(parent) {
hir::Node::Item(hir::Item {
kind: hir::ItemKind::Fn { sig, body, .. },
..
})
| hir::Node::TraitItem(hir::TraitItem {
kind: hir::TraitItemKind::Fn(sig, hir::TraitFn::Provided(body)),
..
})
| hir::Node::ImplItem(hir::ImplItem {
kind: hir::ImplItemKind::Fn(sig, body),
..
}) => Some((sig.decl.output, body)),
_ => None,
}
&& let expr = self.tcx.hir_body(*body_id).value
&& (expr.peel_blocks().span == call_expr.span
|| matches!(
self.tcx.parent_hir_node(call_expr.hir_id),
hir::Node::Expr(hir::Expr { kind: hir::ExprKind::Ret(_), .. })
))
{
err.span_label(
output.span(),
match output {
FnRetTy::DefaultReturn(_) => format!(
"this implicit `()` return type influences the call expression's return type"
),
FnRetTy::Return(_) => {
"this return type influences the call expression's return type"
.to_string()
}
},
);
}
} else if let Some(hir::Node::Expr(e)) = self.tcx.hir_get_if_local(def_id)
&& let hir::ExprKind::Closure(hir::Closure { body, .. }) = &e.kind
{
Expand Down
7 changes: 7 additions & 0 deletions compiler/rustc_lint/src/for_loops_over_fallibles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ impl<'tcx> LateLintPass<'tcx> for ForLoopsOverFallibles {
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
let Some((pat, arg)) = extract_for_loop(expr) else { return };

// Do not put suggestions for external macros.
if pat.span.from_expansion() {
return;
}

let arg_span = arg.span.source_callsite();

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

let sub = if let Some(recv) = extract_iterator_next_call(cx, arg)
&& recv.span.can_be_used_for_suggestions()
&& recv.span.between(arg_span.shrink_to_hi()).can_be_used_for_suggestions()
&& let Ok(recv_snip) = cx.sess().source_map().span_to_snippet(recv.span)
{
ForLoopsOverFalliblesLoopSub::RemoveNext {
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_middle/src/ty/consts/lit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ pub struct LitToConstInput<'tcx> {
/// The absolute value of the resultant constant.
pub lit: LitKind,
/// The type of the constant.
pub ty: Ty<'tcx>,
///
/// `None` is used by const generics when the type of the constant is unknown, e.g.
/// if there are inference variables
pub ty: Option<Ty<'tcx>>,
/// If the constant is negative.
pub neg: bool,
}
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_mir_build/src/builder/expr/as_constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ pub(crate) fn as_constant_inner<'tcx>(

match *kind {
ExprKind::Literal { lit, neg } => {
let const_ = lit_to_mir_constant(tcx, LitToConstInput { lit: lit.node, ty, neg });
let const_ =
lit_to_mir_constant(tcx, LitToConstInput { lit: lit.node, ty: Some(ty), neg });

ConstOperand { span, user_ty: None, const_ }
}
Expand Down Expand Up @@ -109,6 +110,8 @@ pub(crate) fn as_constant_inner<'tcx>(
fn lit_to_mir_constant<'tcx>(tcx: TyCtxt<'tcx>, lit_input: LitToConstInput<'tcx>) -> Const<'tcx> {
let LitToConstInput { lit, ty, neg } = lit_input;

let ty = ty.expect("type of literal must be known at this point");

if let Err(guar) = ty.error_reported() {
return Const::Ty(Ty::new_error(tcx, guar), ty::Const::new_error(tcx, guar));
}
Expand Down
22 changes: 12 additions & 10 deletions compiler/rustc_mir_build/src/thir/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,27 @@ pub(crate) fn lit_to_const<'tcx>(
.unwrap_or_else(|| bug!("expected to create ScalarInt from uint {:?}", result))
};

let (valtree, valtree_ty) = match (lit, expected_ty.kind()) {
let (valtree, valtree_ty) = match (lit, expected_ty.map(|ty| ty.kind())) {
(ast::LitKind::Str(s, _), _) => {
let str_bytes = s.as_str().as_bytes();
let valtree_ty = Ty::new_imm_ref(tcx, tcx.lifetimes.re_static, tcx.types.str_);
(ty::ValTree::from_raw_bytes(tcx, str_bytes), valtree_ty)
}
(ast::LitKind::ByteStr(byte_sym, _), ty::Ref(_, inner_ty, _))
(ast::LitKind::ByteStr(byte_sym, _), Some(ty::Ref(_, inner_ty, _)))
if let ty::Slice(ty) | ty::Array(ty, _) = inner_ty.kind()
&& let ty::Uint(UintTy::U8) = ty.kind() =>
{
(ty::ValTree::from_raw_bytes(tcx, byte_sym.as_byte_str()), expected_ty)
(ty::ValTree::from_raw_bytes(tcx, byte_sym.as_byte_str()), expected_ty.unwrap())
}
(ast::LitKind::ByteStr(byte_sym, _), ty::Slice(inner_ty) | ty::Array(inner_ty, _))
if tcx.features().deref_patterns()
&& let ty::Uint(UintTy::U8) = inner_ty.kind() =>
(
ast::LitKind::ByteStr(byte_sym, _),
Some(ty::Slice(inner_ty) | ty::Array(inner_ty, _)),
) if tcx.features().deref_patterns()
&& let ty::Uint(UintTy::U8) = inner_ty.kind() =>
{
// Byte string literal patterns may have type `[u8]` or `[u8; N]` if `deref_patterns` is
// enabled, in order to allow, e.g., `deref!(b"..."): Vec<u8>`.
(ty::ValTree::from_raw_bytes(tcx, byte_sym.as_byte_str()), expected_ty)
(ty::ValTree::from_raw_bytes(tcx, byte_sym.as_byte_str()), expected_ty.unwrap())
}
(ast::LitKind::ByteStr(byte_sym, _), _) => {
let valtree = ty::ValTree::from_raw_bytes(tcx, byte_sym.as_byte_str());
Expand Down Expand Up @@ -79,11 +81,11 @@ pub(crate) fn lit_to_const<'tcx>(
trunc(if neg { u128::wrapping_neg(n.get()) } else { n.get() }, i.to_unsigned());
(ty::ValTree::from_scalar_int(tcx, scalar_int), Ty::new_int(tcx, i))
}
(ast::LitKind::Int(n, ast::LitIntType::Unsuffixed), ty::Uint(ui)) if !neg => {
(ast::LitKind::Int(n, ast::LitIntType::Unsuffixed), Some(ty::Uint(ui))) if !neg => {
let scalar_int = trunc(n.get(), *ui);
(ty::ValTree::from_scalar_int(tcx, scalar_int), Ty::new_uint(tcx, *ui))
}
(ast::LitKind::Int(n, ast::LitIntType::Unsuffixed), ty::Int(i)) => {
(ast::LitKind::Int(n, ast::LitIntType::Unsuffixed), Some(ty::Int(i))) => {
// Unsigned "negation" has the same bitwise effect as signed negation,
// which gets the result we want without additional casts.
let scalar_int =
Expand All @@ -101,7 +103,7 @@ pub(crate) fn lit_to_const<'tcx>(
let bits = parse_float_into_scalar(n, fty, neg)?;
(ty::ValTree::from_scalar_int(tcx, bits), Ty::new_float(tcx, fty))
}
(ast::LitKind::Float(n, ast::LitFloatType::Unsuffixed), ty::Float(fty)) => {
(ast::LitKind::Float(n, ast::LitFloatType::Unsuffixed), Some(ty::Float(fty))) => {
let bits = parse_float_into_scalar(n, *fty, neg)?;
(ty::ValTree::from_scalar_int(tcx, bits), Ty::new_float(tcx, *fty))
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/thir/pattern/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ impl<'tcx> PatCtxt<'tcx> {
// patterns to `str`, and byte-string literal patterns to `[u8; N]` or `[u8]`.

let pat_ty = self.typeck_results.node_type(pat.hir_id);
let lit_input = LitToConstInput { lit: lit.node, ty: pat_ty, neg: *negated };
let lit_input = LitToConstInput { lit: lit.node, ty: Some(pat_ty), neg: *negated };
let constant = const_lit_matches_ty(self.tcx, &lit.node, pat_ty, *negated)
.then(|| self.tcx.at(expr.span).lit_to_const(lit_input))
.flatten()
Expand Down
Loading
Loading