Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
81c0b8e
Introduce `OptimizationObjective` and fix the entry shim's size attri…
cezarbbb Oct 26, 2026
8ab43eb
Drop array elements in order after a partial move
yashaggarwal85d Oct 27, 2026
6b30d83
Lower #[no_mangle] to #[symbol_name]/#[link_name]
bjorn3 Jul 15, 2026
f141419
Fix clashing_extern_declarations lint
bjorn3 Jul 16, 2026
4d5eb58
Bless several tests
bjorn3 Jul 16, 2026
23a3f18
Disable symbol name mangling for #[link_ordinal]
bjorn3 Jul 16, 2026
3bc2932
Add explanation why #[no_mangle] + #[link_name] matters
bjorn3 Aug 20, 2026
2c2e988
Clarify comment
bjorn3 Oct 9, 2026
d79c109
Apply comment wording suggestions by Ralf
bjorn3 Oct 9, 2026
d3d5579
add tests for the use<..> suggestion with argument position impl trait
Albab-Hasan Oct 30, 2026
20430dc
move the apit rewrite above the lifetime naming in suggest_precise_ca…
Albab-Hasan Oct 30, 2026
81bbd86
name the elided lifetimes in the use<..> suggestion with argument pos…
Albab-Hasan Oct 30, 2026
500e0c6
feat(Reborrow): Allow multiple lifetimes
aapoalas Sep 24, 2026
11a8eaf
Accept variadic SysV64, Win64, and Aapcs FnAbis in rustc_public
lapla-cogito Nov 3, 2026
460bb55
Review comments
bjorn3 Nov 3, 2026
cd22011
fix Miri ICE on exit with () return type
RalfJung Nov 5, 2026
b4b982c
Use symbol name in build_dll_import
bjorn3 Nov 5, 2026
4400802
fallible type ops
nia-e Jun 15, 2026
a51b14a
Use the `2.38` binutils version in CI
GuillaumeGomez Oct 28, 2026
70ed043
update Enzyem submodule
ZuseZ4 Nov 5, 2026
1dd187d
Update Vec::retain_unstable docs to say that this method is generally…
asder8215 Nov 4, 2026
d40c05a
DFV: Reject `#[non_exhaustive]` on enum variants with default field v…
fmease Nov 5, 2026
8696003
remove unused WhereEqPredicate and ScopeId types
TaKO8Ki Nov 5, 2026
7f4b36e
When missing const param in `impl`, provide complete suggestion
estebank Oct 23, 2026
8718bb4
Point at const param declaration when constant is not expected type
estebank Oct 23, 2026
37d1642
Point at type alias type on failed obligations
estebank Oct 23, 2026
1be208e
Tweak span of WF errors in type aliases
estebank Oct 23, 2026
3fceff3
Reword label
estebank Nov 4, 2026
dc7eb41
style-guide: Remove ABI explicitness prescription for extern items
GrimlockOnline Nov 5, 2026
64fe271
Update books
rustbot Nov 5, 2026
39cd593
Disable MAKEINFO when building binutils
GuillaumeGomez Oct 28, 2026
266b16c
Bump SCCACHE_C_CUSTOM_CACHE_BUSTER to force sccache refresh
GuillaumeGomez Nov 5, 2026
b4f8df1
Fix suggestion span
estebank Nov 5, 2026
ca9e035
Fix rebase
estebank Nov 5, 2026
af6c6bc
Update CI GCC stamp
GuillaumeGomez Nov 5, 2026
2aa9a63
Improve comment
GuillaumeGomez Nov 5, 2026
db777f2
Fix warnings for the L4Re targets
farao Nov 5, 2026
c08c7c6
Anonymize all binders and bound vars
mu001999 Oct 31, 2026
a8e658b
rename MIR_borrow_checking timing scope to less confusing name
panstromek Nov 6, 2026
92c5768
Rollup merge of #164784 - cezarbbb:overhaul-size-flags, r=oli-obk
JonathanBrouwer Nov 6, 2026
3e785ba
Rollup merge of #165037 - yashaggarwal85d:fix-array-partial-move-drop…
JonathanBrouwer Nov 6, 2026
88404cd
Rollup merge of #165078 - GuillaumeGomez:binutils-2.38, r=Kobzol
JonathanBrouwer Nov 6, 2026
f326e50
Rollup merge of #159374 - bjorn3:desugar_no_mangle, r=mejrs
JonathanBrouwer Nov 6, 2026
ead715f
Rollup merge of #163284 - aapoalas:reborrow/allow-multiple-lifetimes,…
JonathanBrouwer Nov 6, 2026
29bc3bb
Rollup merge of #164775 - estebank:missing-const-param, r=wesleywiser
JonathanBrouwer Nov 6, 2026
7172008
Rollup merge of #165194 - Albab-Hasan:name-anon-lifetimes-with-apit, …
JonathanBrouwer Nov 6, 2026
7cff0d6
Rollup merge of #165222 - mu001999-contrib:fix-165091, r=fmease
JonathanBrouwer Nov 6, 2026
69951f6
Rollup merge of #165335 - jdonszelmann:fallible-type-ops, r=adwinwhite
JonathanBrouwer Nov 6, 2026
0ffe29c
Rollup merge of #165388 - lapla-cogito:issue_163233, r=makai410
JonathanBrouwer Nov 6, 2026
f67f73b
Rollup merge of #165448 - asder8215:vec_retain_unstable_docs, r=maxdexh
JonathanBrouwer Nov 6, 2026
832e41c
Rollup merge of #165494 - RalfJung:miri-exit-ice, r=oli-obk
JonathanBrouwer Nov 6, 2026
bc5b023
Rollup merge of #165503 - ZuseZ4:update-enzyme-05-11, r=ZuseZ4
JonathanBrouwer Nov 6, 2026
d3d91a2
Rollup merge of #165505 - fmease:dfv-rej-nonex-struct-like-variant, r…
JonathanBrouwer Nov 6, 2026
4e201be
Rollup merge of #165512 - farao:l4re-fix-build2, r=maxdexh
JonathanBrouwer Nov 6, 2026
8c3d7a1
Rollup merge of #165514 - TaKO8Ki:remove-unused-predicate-and-scope-t…
JonathanBrouwer Nov 6, 2026
15f81c0
Rollup merge of #165518 - Kolgrim33:style-guide-remove-abi-prescripti…
JonathanBrouwer Nov 6, 2026
f766ab1
Rollup merge of #165519 - rustbot:docs-update, r=traviscross
JonathanBrouwer Nov 6, 2026
4ff9bb5
Rollup merge of #165534 - panstromek:mir-checking, r=jackh726
JonathanBrouwer Nov 6, 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: 0 additions & 9 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,15 +550,6 @@ pub struct WhereRegionPredicate {
pub bounds: GenericBounds,
}

/// An equality predicate (unsupported).
///
/// E.g., `T = int`.
#[derive(Clone, Encodable, Decodable, Debug, Walkable)]
pub struct WhereEqPredicate {
pub lhs_ty: Box<Ty>,
pub rhs_ty: Box<Ty>,
}

#[derive(Clone, Encodable, Decodable, Debug, Walkable)]
pub struct Crate {
/// Must be equal to `CRATE_NODE_ID` after the crate root is expanded, but may hold
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_ast/src/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,6 @@ macro_rules! common_visitor_and_walkers {
VisibilityKind,
WhereBoundPredicate,
WhereClause,
WhereEqPredicate,
WhereRegionPredicate,
YieldKind,
// tidy-alphabetical-end
Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_attr_parsing/src/attributes/non_exhaustive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ impl NoArgsAttributeParser for NonExhaustiveParser {
const CREATE: fn(Span) -> AttributeKind = AttributeKind::NonExhaustive;

fn finalize_check(cx: &mut FinalizeCheckContext<'_, '_>, attr_span: Span) {
let AstTarget::Struct(_, _, data) = cx.ast_target else {
return;
};
if let VariantData::Struct { fields, .. } = data
if let AstTarget::Struct(_, _, data) | AstTarget::Variant(rustc_ast::Variant { data, .. }) =
cx.ast_target
&& let VariantData::Struct { fields, .. } = data
&& fields.iter().any(|f| f.default_value().is_some())
{
cx.emit_err(NonExhaustiveWithDefaultFieldValues {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr_parsing/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1281,7 +1281,7 @@ pub(crate) struct DeprecatedAnnotationHasNoEffect {
}

#[derive(Diagnostic)]
#[diag("`#[non_exhaustive]` can't be used to annotate items with default field values")]
#[diag("`#[non_exhaustive]` can't be used to annotate structs with default field values")]
pub(crate) struct NonExhaustiveWithDefaultFieldValues {
#[primary_span]
pub attr_span: Span,
Expand Down
36 changes: 36 additions & 0 deletions compiler/rustc_borrowck/src/type_check/canonical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ use std::fmt;
use rustc_errors::ErrorGuaranteed;
use rustc_infer::infer::canonical::Canonical;
use rustc_infer::infer::outlives::env::RegionBoundPairs;
use rustc_infer::traits::Obligation;
use rustc_middle::mir::{Body, ConstraintCategory};
use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, Unnormalized, Upcast};
use rustc_span::def_id::DefId;
use rustc_span::{Span, bug};
use rustc_trait_selection::traits::ObligationCause;
use rustc_trait_selection::traits::query::type_op::custom::FallibleCustomTypeOp;
use rustc_trait_selection::traits::query::type_op::{self, TypeOpOutput};
use tracing::{debug, instrument};

Expand Down Expand Up @@ -165,6 +167,12 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
}
}

/// Proves and asserts that a predicate holds.
/// Errors may be emitted that are only dependent on region constraints.
/// However, errors that are not dependent on region constraints are emitted as a delayed bug,
/// since those should have already been emitted earlier in the compiler.
/// If this is undesirable and errors should be emitted properly,
/// use [`prove_fallible_predicate`](Self::prove_fallible_predicate).
#[instrument(skip(self), level = "debug")]
pub(super) fn prove_clause(
&mut self,
Expand All @@ -182,6 +190,34 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
);
}

/// Certain proofs (e.g. `Move`) may error during MIR typeck for reasons that
/// are unrelated to regions. Unlike [`prove_clause`](Self::prove_clause),
/// this API reports those errors properly.
#[allow(unused)]
pub(super) fn prove_fallible_predicate(
&mut self,
predicate: impl Upcast<TyCtxt<'tcx>, ty::Predicate<'tcx>> + std::fmt::Debug,
locations: Locations,
category: ConstraintCategory<'tcx>,
) {
let span = self.last_span;
let predicate = predicate.upcast(self.tcx());
let op = FallibleCustomTypeOp::new(
|ocx| {
ocx.register_obligation(Obligation::new(
ocx.infcx.tcx,
ObligationCause::dummy_with_span(span),
self.infcx.param_env,
predicate,
));
Ok(())
},
"fallible type op",
);

let _: Result<_, ErrorGuaranteed> = self.fully_perform_op(locations, category, op);
}

pub(super) fn normalize<T>(
&mut self,
value: Unnormalized<'tcx, T>,
Expand Down
16 changes: 11 additions & 5 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use rustc_infer::infer::region_constraints::RegionConstraintData;
use rustc_infer::infer::{
BoundRegionConversionTime, InferCtxt, NllRegionVariableOrigin, RegionVariableOrigin,
};
use rustc_infer::traits::{Obligation, ObligationCause, PredicateObligations};
use rustc_infer::traits::{Obligation, ObligationCause, PredicateObligations, ScrubbedTraitError};
use rustc_middle::mir::visit::{NonMutatingUseContext, PlaceContext, Visitor};
use rustc_middle::mir::*;
use rustc_middle::traits::query::NoSolution;
Expand Down Expand Up @@ -2800,10 +2800,16 @@ impl<'tcx> TypeOp<'tcx> for InstantiateOpaqueType<'tcx> {
span: Span,
) -> Result<TypeOpOutput<'tcx, Self>, ErrorGuaranteed> {
let (mut output, region_constraints) =
scrape_region_constraints(infcx, root_def_id, "InstantiateOpaqueType", span, |ocx| {
ocx.register_obligations(self.obligations.clone());
Ok(())
})?;
scrape_region_constraints::<_, _, ScrubbedTraitError<'tcx>>(
infcx,
root_def_id,
"InstantiateOpaqueType",
span,
|ocx| {
ocx.register_obligations(self.obligations.clone());
Ok(())
},
)?;
self.region_constraints = Some(region_constraints);
output.error_info = Some(self);
Ok(output)
Expand Down
136 changes: 123 additions & 13 deletions compiler/rustc_builtin_macros/src/deriving/reborrow.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use rustc_ast::{self as ast, AttrArgs, Generics, ItemKind, token};
use rustc_ast::{
self as ast, AngleBracketedArg, AttrArgs, DUMMY_NODE_ID, GenericArg, Generics, ItemKind, token,
};
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::E0802;
use rustc_expand::base::ExtCtxt;
use rustc_macros::Diagnostic;
Expand All @@ -18,7 +21,10 @@ pub(crate) fn expand_deriving_reborrow(
return;
};

push_marker_impl(cx, span, ident, generics, sym::Reborrow, Vec::new(), push);
let self_args: Vec<_> =
generics.params.iter().map(|p| generic_param_to_arg(cx, p, p.span())).collect();

push_marker_impl(cx, span, ident, generics, sym::Reborrow, vec![], self_args, push);
}

pub(crate) fn expand_deriving_coerce_shared(
Expand All @@ -31,17 +37,20 @@ pub(crate) fn expand_deriving_coerce_shared(
let Some((ident, generics)) = struct_def(cx, span, item, sym::CoerceShared) else {
return;
};
let Some(target) = coerce_shared_target(cx, span, item) else {
let self_args: Vec<_> =
generics.params.iter().map(|p| generic_param_to_arg(cx, p, p.span())).collect();
let Some((target, generics)) = coerce_shared_target(cx, span, item, generics) else {
return;
};

push_marker_impl(
cx,
span,
ident,
generics,
&generics,
sym::CoerceShared,
vec![ast::GenericArg::Type(target)],
vec![GenericArg::Type(target)],
self_args,
push,
);
}
Expand Down Expand Up @@ -69,8 +78,14 @@ fn struct_def<'a>(
}
}

fn coerce_shared_target(cx: &ExtCtxt<'_>, span: Span, item: &ast::Item) -> Option<Box<ast::Ty>> {
let mut attrs = item.attrs.iter().filter(|attr| attr.has_name(sym::coerce_shared));
fn coerce_shared_target(
cx: &ExtCtxt<'_>,
span: Span,
coerce_shared_item: &ast::Item,
source_generics: &Generics,
) -> Option<(Box<ast::Ty>, Generics)> {
let mut attrs =
coerce_shared_item.attrs.iter().filter(|attr| attr.has_name(sym::coerce_shared));
let Some(attr) = attrs.next() else {
cx.dcx().emit_err(MissingTarget { span });
return None;
Expand All @@ -90,7 +105,7 @@ fn coerce_shared_target(cx: &ExtCtxt<'_>, span: Span, item: &ast::Item) -> Optio
}

let mut parser = cx.new_parser_from_tts(args.tokens.clone());
let target = match parser.parse_ty() {
let mut target = match parser.parse_ty() {
Ok(target) => target,
Err(err) => {
err.cancel();
Expand All @@ -103,7 +118,87 @@ fn coerce_shared_target(cx: &ExtCtxt<'_>, span: Span, item: &ast::Item) -> Optio
return None;
}

Some(target)
let rustc_ast::TyKind::Path(_, path) = &mut target.kind else {
cx.dcx().emit_err(MalformedTargetType { span: target.span });
return None;
};

let Some(last) = path.segments.last_mut() else {
// It shouldn't be possible for segments to be empty.
cx.dcx().emit_err(MalformedTargetType { span: path.span });
return None;
};

let Some(rustc_ast::GenericArgs::AngleBracketed(target_args)) = last.args.as_deref_mut() else {
// FIXME(reborrow): same as above.
cx.dcx().emit_err(NoGenericsOnTargetType { span: last.span() });
return None;
};

// Map to check generated lifetime arg names against.
let mut lt_names: FxHashSet<Symbol> = target_args
.args
.iter()
.filter_map(|arg| {
if let AngleBracketedArg::Arg(GenericArg::Lifetime(arg)) = arg {
Some(arg.ident.name)
} else {
None
}
})
.collect();

// struct Source<'a, 'b, T, const U> {} + coerce_shared(Target<'a>) =>
// impl<'a, 'a_, T, const U> CoerceShared<Target<'a_>> for Source<'a, T, const U>
// where 'a: 'a_ {}
let coerce_shared_trait_param_count = source_generics.params.len() + lt_names.len();
let mut trait_params = ThinVec::with_capacity(coerce_shared_trait_param_count);
let mut trait_where_clause = source_generics.where_clause.clone();

// First add in the existing lifetimes.
trait_params.extend(
source_generics
.params
.iter()
.take_while(|p| matches!(p.kind, rustc_ast::GenericParamKind::Lifetime))
.cloned(),
);

// Remember how many lifetime parameters there were.
let source_generics_lt_count = trait_params.len();

// Replace all lifetime parameters 'a with a new 'a_ where 'a: 'a_ in the Target definition, and
// push the new lifetimes into trait params.
for arg in target_args.args.iter_mut() {
let AngleBracketedArg::Arg(GenericArg::Lifetime(arg)) = arg else {
continue;
};

// Eagerly intern the generated lifetime name - it is unlikely we have a naming conflict.
let mut name_string = format!("{}_", arg.ident.as_str());
let mut name = Symbol::intern(&name_string);
while lt_names.contains(&name) {
// Just keep piling on the underscores.
name_string.push('_');
name = Symbol::intern(&name_string);
}
// Now that we generated a unique lifetime name, add it into the set.
lt_names.insert(name);

// Create our lifetime, add it into the trait parameters and create a where-clause predicate
// for it.
let lt = rustc_ast::Lifetime { id: DUMMY_NODE_ID, ident: Ident::with_dummy_span(name) };
trait_params.push(cx.lifetime_param(lt.ident, Default::default()));
trait_where_clause.predicates.push(cx.where_outlives(*arg, lt));
// Note: this mutates `target` from `Target<'a>` to `Target<'a_>`.
*arg = lt;
}

// Finally add in any non-lifetime generics to the trait parameters: they must follow lifetimes
// hence this ordering. This is also why we made note of lifetime parameter count.
trait_params.extend_from_slice(&source_generics.params[source_generics_lt_count..]);

Some((target, Generics { params: trait_params, where_clause: trait_where_clause, span }))
}

fn push_marker_impl(
Expand All @@ -112,15 +207,14 @@ fn push_marker_impl(
ident: Ident,
generics: &Generics,
trait_name: Symbol,
trait_args: Vec<ast::GenericArg>,
trait_args: Vec<GenericArg>,
self_args: Vec<GenericArg>,
push: &mut dyn FnMut(Box<ast::Item>),
) {
let trait_path = cx.std_path_all(span, &[sym::marker, trait_name], trait_args);
let trait_ref = cx.trait_ref(trait_path);

let self_params: Vec<_> =
generics.params.iter().map(|p| generic_param_to_arg(cx, p, p.span())).collect();
let self_ty = cx.ty_path(cx.path_all(span, &[ident], self_params));
let self_ty = cx.ty_path(cx.path_all(span, &[ident], self_args));

push(cx.item_trait_impl(
span,
Expand Down Expand Up @@ -166,3 +260,19 @@ struct MalformedTarget {
#[primary_span]
span: Span,
}

#[derive(Diagnostic)]
#[diag("malformed `#[coerce_shared(Target)]` attribute for `derive(CoerceShared)`", code = E0802)]
#[note("expected target type to be a user-defined type")]
struct MalformedTargetType {
#[primary_span]
span: Span,
}

#[derive(Diagnostic)]
#[diag("malformed `#[coerce_shared(Target)]` attribute for `derive(CoerceShared)`", code = E0802)]
#[note("expected target type to have generics")]
struct NoGenericsOnTargetType {
#[primary_span]
span: Span,
}
2 changes: 2 additions & 0 deletions compiler/rustc_codegen_llvm/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,8 @@ pub(crate) fn default_optimisation_attrs<'ll>(
sess: &Session,
) -> SmallVec<[&'ll Attribute; 2]> {
let mut attrs = SmallVec::new();
// Either attribute satisfies LLVM's combined size predicate, but the software pipeliner reads
// `optsize` alone, so a `z` build needs both.
match sess.opts.optimize {
OptLevel::Size => {
attrs.push(llvm::AttributeKind::OptimizeForSize.create_attr(cx.llcx));
Expand Down
19 changes: 9 additions & 10 deletions compiler/rustc_codegen_llvm/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@ pub(crate) fn create_target_machine(tcx: TyCtxt<'_>, mod_name: &str) -> OwnedTar
target_machine_factory(tcx.sess, tcx.backend_optimization_level(()))(tcx.dcx(), config)
}

fn to_llvm_opt_settings(cfg: config::OptLevel) -> (llvm::CodeGenOptLevel, llvm::CodeGenOptSize) {
// `s` and `z` are the same codegen level; what tells LLVM that they are size builds is the
// per-function attribute, not this setting.
fn to_llvm_opt_level(cfg: config::OptLevel) -> llvm::CodeGenOptLevel {
use self::config::OptLevel::*;
match cfg {
No => (llvm::CodeGenOptLevel::None, llvm::CodeGenOptSizeNone),
Less => (llvm::CodeGenOptLevel::Less, llvm::CodeGenOptSizeNone),
More => (llvm::CodeGenOptLevel::Default, llvm::CodeGenOptSizeNone),
Aggressive => (llvm::CodeGenOptLevel::Aggressive, llvm::CodeGenOptSizeNone),
Size => (llvm::CodeGenOptLevel::Default, llvm::CodeGenOptSizeDefault),
SizeMin => (llvm::CodeGenOptLevel::Default, llvm::CodeGenOptSizeAggressive),
No => llvm::CodeGenOptLevel::None,
Less => llvm::CodeGenOptLevel::Less,
More | Size | SizeMin => llvm::CodeGenOptLevel::Default,
Aggressive => llvm::CodeGenOptLevel::Aggressive,
}
}

Expand Down Expand Up @@ -184,7 +184,7 @@ pub(crate) fn target_machine_factory(

let reloc_model = to_llvm_relocation_model(sess.relocation_model());

let (opt_level, _) = to_llvm_opt_settings(optlvl);
let opt_level = to_llvm_opt_level(optlvl);
let float_abi = to_llvm_float_abi(sess.target.llvm_floatabi);

let ffunction_sections =
Expand Down Expand Up @@ -594,8 +594,7 @@ pub(crate) unsafe fn llvm_optimize<'ll>(
vectorize_slp = false;
vectorize_loop = false;
} else {
unroll_loops =
opt_level != config::OptLevel::Size && opt_level != config::OptLevel::SizeMin;
unroll_loops = opt_level.objective() != config::OptimizationObjective::Size;
merge_functions = config.merge_functions;
vectorize_slp = config.vectorize_slp;
vectorize_loop = config.vectorize_loop;
Expand Down
Loading
Loading