Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
0ef4e11
style: Clarify nullary call and `()` no-break rule applies past max w…
ajasad25 May 22, 2026
239e4dd
Remove will_cache_on_disk_for_key_fn and AsLocalQueryKey
zetanumbers Mar 30, 2026
76c099c
Rename helper QueryVTable method back
zetanumbers May 26, 2026
0a36812
Fix and update changes
zetanumbers May 26, 2026
9d82fce
Formatter
zetanumbers May 26, 2026
33f5959
Remove unused functions in `value_analysis.rs`
nnethercote Apr 29, 2026
bdf8d76
Reduce more visibilities
nnethercote May 1, 2026
d2bb772
Note irrefutable while let in loop type errors
anoshyn May 27, 2026
cfbe6af
Fix tupled closure signature in AsyncFn arg mismatch diagnostic
cijiugechu May 28, 2026
e731b4e
Allow two object files for a single CGU in CompiledModule
bjorn3 May 27, 2026
686c8c9
Expanded tests for &x -> &mut x suggestions
nullie May 29, 2026
9bef677
Fixed &x -> &mut x suggestions for pattern matching
nullie May 29, 2026
4f1630d
Move `compute_object_lifetime_bound` into submodule `dyn_trait`
fmease May 29, 2026
a866e42
Rename `AmbiguousAssocItem` to `AmbiguityBetweenVariantAndAssocItem` …
fmease May 29, 2026
fd36a80
Move distractingly lengthy error reporting code into new `report_ambi…
fmease May 29, 2026
4fe62be
Address irrefutable while let diagnostic review
anoshyn May 29, 2026
5878c57
Make a dedicated coroutine mir-opt test directory.
cjgillot May 10, 2026
d332a12
Change how coroutine layout is dumped in MIR.
cjgillot May 14, 2026
3b77583
Simplify can_unwind.
cjgillot May 17, 2026
9e5c064
Put entry block at the end instead of shifting everything.
cjgillot May 17, 2026
f6a5b0b
Review nits.
cjgillot May 29, 2026
ad7cda0
Use `trait_object_dummy_self` more & heavily fix+update related docs
fmease Mar 6, 2026
57393b7
Label irrefutable while let pattern diagnostic
anoshyn May 29, 2026
f7cf361
compiler: `ops::RangeInclusive` → `range::RangeInclusive`
scottmcm May 30, 2026
e83d369
Use default field values to avoid some churn
oli-obk May 29, 2026
fec4545
Track `lifetime_elision_allowed` per owner, and discard fn ptr and `F…
oli-obk May 27, 2026
5b37028
Track `label_res_map` per-owner
oli-obk May 28, 2026
b7ea5d8
Track `lifetimes_res_map` per owner
oli-obk May 28, 2026
e8659d7
Rollup merge of #154591 - zetanumbers:refactor_query_fns_and_traits, …
JonathanBrouwer May 30, 2026
3a53860
Rollup merge of #156672 - cjgillot:coroutine-qol, r=oli-obk
JonathanBrouwer May 30, 2026
18e61f0
Rollup merge of #157027 - fmease:hirtylo-mv-things, r=nnethercote
JonathanBrouwer May 30, 2026
b8c03ee
Rollup merge of #157051 - bjorn3:lto_refactors20, r=saethlin
JonathanBrouwer May 30, 2026
b7856de
Rollup merge of #157100 - oli-obk:some_more_per_owner_things, r=petro…
JonathanBrouwer May 30, 2026
e842f5e
Rollup merge of #153497 - fmease:trait-obj-dummy-self-improvs, r=John…
JonathanBrouwer May 30, 2026
0bd5f41
Rollup merge of #155638 - cijiugechu:fix-asyncfn-e0631-diagnostic, r=…
JonathanBrouwer May 30, 2026
7d7fa76
Rollup merge of #156826 - ajasad25:style-never-break-empty-parens-152…
JonathanBrouwer May 30, 2026
1111bad
Rollup merge of #157004 - nnethercote:value_analysis-visibility, r=cj…
JonathanBrouwer May 30, 2026
6717454
Rollup merge of #157032 - nullie:borrowck-deref-pattern-mut-suggestio…
JonathanBrouwer May 30, 2026
1451099
Rollup merge of #157033 - anoshyn:issue-116572-irrefutable-while-let-…
JonathanBrouwer May 30, 2026
cf39dc6
Rollup merge of #157139 - scottmcm:abi-range-inclusive, r=oli-obk
JonathanBrouwer May 30, 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
9 changes: 6 additions & 3 deletions compiler/rustc_abi/src/layout.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::collections::BTreeSet;
use std::fmt::{self, Write};
use std::ops::Deref;
use std::range::RangeInclusive;
use std::{cmp, iter};

use rustc_hashes::Hash64;
Expand Down Expand Up @@ -631,11 +632,13 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
let all_indices = variants.indices();
let needs_disc =
|index: VariantIdx| index != largest_variant_index && !absent(&variants[index]);
let niche_variants = all_indices.clone().find(|v| needs_disc(*v)).unwrap()
..=all_indices.rev().find(|v| needs_disc(*v)).unwrap();
let niche_variants = RangeInclusive {
start: all_indices.clone().find(|v| needs_disc(*v)).unwrap(),
last: all_indices.rev().find(|v| needs_disc(*v)).unwrap(),
};

let count =
(niche_variants.end().index() as u128 - niche_variants.start().index() as u128) + 1;
(niche_variants.last.index() as u128 - niche_variants.start.index() as u128) + 1;

// Use the largest niche in the largest variant.
let niche = variant_layouts[largest_variant_index].largest_niche?;
Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ use std::fmt;
#[cfg(feature = "nightly")]
use std::iter::Step;
use std::num::{NonZeroUsize, ParseIntError};
use std::ops::{Add, AddAssign, Deref, Mul, RangeFull, RangeInclusive, Sub};
use std::ops::{Add, AddAssign, Deref, Mul, RangeFull, Sub};
use std::range::RangeInclusive;
use std::str::FromStr;

use bitflags::bitflags;
Expand Down Expand Up @@ -1958,7 +1959,7 @@ pub enum Variants<FieldIdx: Idx, VariantIdx: Idx> {
}

// NOTE: This struct is generic over the VariantIdx for rust-analyzer usage.
#[derive(PartialEq, Eq, Hash, Clone, Debug)]
#[derive(PartialEq, Eq, Hash, Copy, Clone, Debug)]
#[cfg_attr(feature = "nightly", derive(StableHash))]
pub enum TagEncoding<VariantIdx: Idx> {
/// The tag directly stores the discriminant, but possibly with a smaller layout
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1549,7 +1549,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
fn lower_loop_destination(&mut self, destination: Option<(NodeId, Label)>) -> hir::Destination {
let target_id = match destination {
Some((id, _)) => {
if let Some(loop_id) = self.resolver.get_label_res(id) {
if let Some(loop_id) = self.owner.get_label_res(id) {
let local_id = self.ident_and_label_to_local_id[&loop_id];
let loop_hir_id = HirId { owner: self.current_hir_id_owner, local_id };
Ok(loop_hir_id)
Expand Down
35 changes: 11 additions & 24 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,16 +293,6 @@ impl<'tcx> ResolverAstLowering<'tcx> {
self.import_res_map.get(&id).copied().unwrap_or_default()
}

/// Obtains resolution for a label with the given `NodeId`.
fn get_label_res(&self, id: NodeId) -> Option<NodeId> {
self.label_res_map.get(&id).copied()
}

/// Obtains resolution for a lifetime with the given `NodeId`.
fn get_lifetime_res(&self, id: NodeId) -> Option<LifetimeRes> {
self.lifetimes_res_map.get(&id).copied()
}

/// Obtain the list of lifetimes parameters to add to an item.
///
/// Extra lifetime parameters should only be added in places that can appear
Expand All @@ -321,10 +311,6 @@ impl<'tcx> ResolverAstLowering<'tcx> {
fn owner_def_id(&self, id: NodeId) -> LocalDefId {
self.owners[&id].def_id
}

fn lifetime_elision_allowed(&self, id: NodeId) -> bool {
self.lifetime_elision_allowed.contains(&id)
}
}

/// How relaxed bounds `?Trait` should be treated.
Expand Down Expand Up @@ -1612,7 +1598,7 @@ impl<'hir> LoweringContext<'_, 'hir> {

None => {
let id = if let Some(LifetimeRes::ElidedAnchor { start, end }) =
self.resolver.get_lifetime_res(t.id)
self.owner.get_lifetime_res(t.id)
{
assert_eq!(start.plus(1), end);
start
Expand Down Expand Up @@ -1853,7 +1839,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
_ => hir::ImplicitSelfKind::None,
}
}))
.set_lifetime_elision_allowed(self.resolver.lifetime_elision_allowed(fn_node_id))
.set_lifetime_elision_allowed(
self.owner.id == fn_node_id && self.owner.lifetime_elision_allowed,
)
.set_c_variadic(c_variadic);

self.arena.alloc(hir::FnDecl { inputs, output, fn_decl_kind })
Expand Down Expand Up @@ -2019,7 +2007,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
source: LifetimeSource,
syntax: LifetimeSyntax,
) -> &'hir hir::Lifetime {
let res = if let Some(res) = self.resolver.get_lifetime_res(id) {
let res = if let Some(res) = self.owner.get_lifetime_res(id) {
match res {
LifetimeRes::Param { param, .. } => hir::LifetimeKind::Param(param),
LifetimeRes::Fresh { param, .. } => {
Expand Down Expand Up @@ -2105,13 +2093,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
// AST resolution emitted an error on those parameters, so we lower them using
// `ParamName::Error`.
let ident = self.lower_ident(param.ident);
let param_name = if let Some(LifetimeRes::Error(..)) =
self.resolver.get_lifetime_res(param.id)
{
ParamName::Error(ident)
} else {
ParamName::Plain(ident)
};
let param_name =
if let Some(LifetimeRes::Error(..)) = self.owner.get_lifetime_res(param.id) {
ParamName::Error(ident)
} else {
ParamName::Plain(ident)
};
let kind =
hir::GenericParamKind::Lifetime { kind: hir::LifetimeParamKind::Explicit };

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ast_lowering/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use super::errors::{
};
use super::{
AllowReturnTypeNotation, GenericArgsCtor, GenericArgsMode, ImplTraitContext, ImplTraitPosition,
LifetimeRes, LoweringContext, ParamMode, ResolverAstLoweringExt,
LifetimeRes, LoweringContext, ParamMode,
};

impl<'hir> LoweringContext<'_, 'hir> {
Expand Down Expand Up @@ -422,7 +422,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
segment_ident_span: Span,
generic_args: &mut GenericArgsCtor<'hir>,
) {
let (start, end) = match self.resolver.get_lifetime_res(segment_id) {
let (start, end) = match self.owner.get_lifetime_res(segment_id) {
Some(LifetimeRes::ElidedAnchor { start, end }) => (start, end),
None => return,
Some(res) => {
Expand Down
75 changes: 36 additions & 39 deletions compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4023,63 +4023,60 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
&& decl.can_be_made_mutable()
{
let mut is_for_loop = false;
let mut is_ref_pattern = false;
let mut is_immut_ref_pattern = false;
if let LocalInfo::User(BindingForm::Var(VarBindingForm {
opt_match_place: Some((_, match_span)),
..
})) = *decl.local_info()
{
if matches!(match_span.desugaring_kind(), Some(DesugaringKind::ForLoop)) {
is_for_loop = true;
}

if let Some(body) = self.infcx.tcx.hir_maybe_body_owned_by(self.mir_def_id()) {
struct RefPatternFinder<'tcx> {
tcx: TyCtxt<'tcx>,
binding_span: Span,
is_ref_pattern: bool,
}
if let Some(body) = self.infcx.tcx.hir_maybe_body_owned_by(self.mir_def_id()) {
struct RefPatternFinder<'tcx> {
tcx: TyCtxt<'tcx>,
binding_span: Span,
is_immut_ref_pattern: bool,
}

impl<'tcx> Visitor<'tcx> for RefPatternFinder<'tcx> {
type NestedFilter = OnlyBodies;
impl<'tcx> Visitor<'tcx> for RefPatternFinder<'tcx> {
type NestedFilter = OnlyBodies;

fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.tcx
}
fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.tcx
}

fn visit_pat(&mut self, pat: &'tcx hir::Pat<'tcx>) {
if !self.is_ref_pattern
&& let hir::PatKind::Binding(_, _, ident, _) = pat.kind
&& ident.span == self.binding_span
{
self.is_ref_pattern =
self.tcx.hir_parent_iter(pat.hir_id).any(|(_, node)| {
matches!(
node,
hir::Node::Pat(hir::Pat {
kind: hir::PatKind::Ref(..),
..
})
)
});
}
hir::intravisit::walk_pat(self, pat);
fn visit_pat(&mut self, pat: &'tcx hir::Pat<'tcx>) {
if !self.is_immut_ref_pattern
&& let hir::PatKind::Binding(_, _, ident, _) = pat.kind
&& ident.span == self.binding_span
&& matches!(
self.tcx.parent_hir_node(pat.hir_id),
hir::Node::Pat(hir::Pat {
kind: hir::PatKind::Ref(_, _, hir::Mutability::Not),
..
})
)
{
self.is_immut_ref_pattern = true;
}
hir::intravisit::walk_pat(self, pat);
}
}

let mut finder = RefPatternFinder {
tcx: self.infcx.tcx,
binding_span: decl.source_info.span,
is_ref_pattern: false,
};
let mut finder = RefPatternFinder {
tcx: self.infcx.tcx,
binding_span: decl.source_info.span,
is_immut_ref_pattern: false,
};

finder.visit_body(body);
is_ref_pattern = finder.is_ref_pattern;
}
finder.visit_body(body);
is_immut_ref_pattern = finder.is_immut_ref_pattern;
}
}

let (span, message) = if is_for_loop
&& is_ref_pattern
let (span, message) = if is_immut_ref_pattern
&& let Ok(binding_name) =
self.infcx.tcx.sess.source_map().span_to_snippet(decl.source_info.span)
{
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_codegen_cranelift/src/discriminant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub(crate) fn codegen_set_discriminant<'tcx>(
if variant_index != untagged_variant {
let niche = place.place_field(fx, tag_field);
let niche_type = fx.clif_type(niche.layout().ty).unwrap();
let niche_value = variant_index.as_u32() - niche_variants.start().as_u32();
let niche_value = variant_index.as_u32() - niche_variants.start.as_u32();
let niche_value = (niche_value as u128).wrapping_add(niche_start);
let niche_value = match niche_type {
types::I128 => {
Expand Down Expand Up @@ -133,7 +133,7 @@ pub(crate) fn codegen_get_discriminant<'tcx>(
dest.write_cvalue(fx, res);
}
TagEncoding::Niche { untagged_variant, ref niche_variants, niche_start } => {
let relative_max = niche_variants.end().as_u32() - niche_variants.start().as_u32();
let relative_max = niche_variants.last.as_u32() - niche_variants.start.as_u32();

// We have a subrange `niche_start..=niche_end` inside `range`.
// If the value of the tag is inside this subrange, it's a
Expand Down Expand Up @@ -162,7 +162,7 @@ pub(crate) fn codegen_get_discriminant<'tcx>(
// }
let is_niche = codegen_icmp_imm(fx, IntCC::Equal, tag, niche_start as i128);
let tagged_discr =
fx.bcx.ins().iconst(cast_to, niche_variants.start().as_u32() as i64);
fx.bcx.ins().iconst(cast_to, niche_variants.start.as_u32() as i64);
(is_niche, tagged_discr, 0)
} else {
// The special cases don't apply, so we'll have to go with
Expand All @@ -184,7 +184,7 @@ pub(crate) fn codegen_get_discriminant<'tcx>(
relative_discr,
i128::from(relative_max),
);
(is_niche, cast_tag, niche_variants.start().as_u32() as u128)
(is_niche, cast_tag, niche_variants.start.as_u32() as u128)
};

let tagged_discr = if delta == 0 {
Expand Down
Loading
Loading