Skip to content

Rollup of 14 pull requests #143233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 35 commits into from
Jun 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
66ea349
Use let chains in the new solver
compiler-errors Jun 27, 2025
ccbe983
Use one more let chain
compiler-errors Jun 27, 2025
953cf27
Workaround for mem safety in third party dlls
ChrisDenton Jun 27, 2025
3d81af8
moved tests
Kivooeo Jun 28, 2025
ed16ae8
Do not freshen ReError
compiler-errors Jun 28, 2025
1347b48
Remove additional call to lookup_op_method
compiler-errors Jun 28, 2025
74657a4
Move some UI tests to more apropriate directories
tgross35 Jun 28, 2025
897c4ee
Update README.md
kilavvy Jun 29, 2025
d0bd279
cleaned up some tests
Kivooeo Jun 12, 2025
71a8418
Add my work email to mailmap
yotamofek Jun 29, 2025
9f9cd5e
mir: Add a `new` method to `statement`
dianqk Jun 8, 2025
24e553e
mir: Use the `new` method for `BasicBlockData`
dianqk Jun 16, 2025
a38c78c
moved tests
Kivooeo Jun 29, 2025
54cec0c
Port #[link_section] to the new attribute parsing infrastructure
Periodic1911 Jun 29, 2025
20d69c6
Re-disable `tests/run-make/short-ice` on Windows MSVC again
jieyouxu Jun 29, 2025
60a4828
make some powf and powi cases involving SNaN non-deterministic
LorrensP-2158466 Jun 14, 2025
67ab61e
add float_nan test for powf
RalfJung Jun 29, 2025
d98aaf7
Show auto trait and blanket impls for `!`
zachs18 Jun 29, 2025
580bc12
cleaned up some tests
Kivooeo Jun 27, 2025
1e3a2b2
cleaned up some tests
Kivooeo Jun 29, 2025
c240566
cleaned up some tests
Kivooeo Jun 28, 2025
384d699
Rollup merge of #142429 - Kivooeo:tf13, r=jieyouxu
dianqk Jun 30, 2025
d2dc99c
Rollup merge of #142514 - LorrensP-2158466:miri-float-nondet-pow, r=R…
dianqk Jun 30, 2025
8c4bcb8
Rollup merge of #143066 - compiler-errors:let-chain-solver, r=lcnr
dianqk Jun 30, 2025
a94f0a4
Rollup merge of #143090 - ChrisDenton:workaround1, r=tgross35
dianqk Jun 30, 2025
0952f86
Rollup merge of #143118 - Kivooeo:tf15, r=tgross35
dianqk Jun 30, 2025
3a35f36
Rollup merge of #143159 - compiler-errors:freshen-re-error, r=oli-obk
dianqk Jun 30, 2025
8ccffc9
Rollup merge of #143168 - Kivooeo:tf16, r=tgross35
dianqk Jun 30, 2025
462c7c3
Rollup merge of #143176 - kilavvy:master, r=jieyouxu
dianqk Jun 30, 2025
043fc5b
Rollup merge of #143187 - yotamofek:mailmap, r=jieyouxu
dianqk Jun 30, 2025
ab633af
Rollup merge of #143190 - dianqk:new-method, r=oli-obk
dianqk Jun 30, 2025
327fe35
Rollup merge of #143195 - Kivooeo:tf17, r=tgross35
dianqk Jun 30, 2025
7760cd6
Rollup merge of #143196 - Periodic1911:link_section, r=oli-obk
dianqk Jun 30, 2025
e18342a
Rollup merge of #143199 - jieyouxu:short-ice, r=RalfJung
dianqk Jun 30, 2025
c2904f7
Rollup merge of #143219 - zachs18:patch-5, r=tgross35
dianqk Jun 30, 2025
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
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,7 @@ Xinye Tao <[email protected]>
Xuefeng Wu <[email protected]> Xuefeng Wu <[email protected]>
Xuefeng Wu <[email protected]> XuefengWu <[email protected]>
York Xiang <[email protected]>
Yotam Ofek <[email protected]> <[email protected]>
Youngsoo Son <[email protected]> <[email protected]>
Youngsuk Kim <[email protected]>
Yuki Okushi <[email protected]>
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_attr_data_structures/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ pub enum AttributeKind {
/// Represents `#[link_name]`.
LinkName { name: Symbol, span: Span },

/// Represents [`#[link_section]`](https://doc.rust-lang.org/reference/abi.html#the-link_section-attribute)
LinkSection { name: Symbol, span: Span },

/// Represents `#[loop_match]`.
LoopMatch(Span),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ impl AttributeKind {
DocComment { .. } => Yes,
ExportName { .. } => Yes,
Inline(..) => No,
LinkSection { .. } => No,
MacroTransparency(..) => Yes,
Repr(..) => No,
Stability { .. } => Yes,
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_attr_parsing/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ attr_parsing_non_ident_feature =

attr_parsing_null_on_export = `export_name` may not contain null characters

attr_parsing_null_on_link_section = `link_section` may not contain null characters

attr_parsing_repr_ident =
meta item in `repr` must be an identifier

Expand Down
31 changes: 30 additions & 1 deletion compiler/rustc_attr_parsing/src/attributes/link_attrs.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use rustc_attr_data_structures::AttributeKind;
use rustc_attr_data_structures::AttributeKind::LinkName;
use rustc_attr_data_structures::AttributeKind::{LinkName, LinkSection};
use rustc_feature::{AttributeTemplate, template};
use rustc_span::{Symbol, sym};

use crate::attributes::{AttributeOrder, OnDuplicate, SingleAttributeParser};
use crate::context::{AcceptContext, Stage};
use crate::parser::ArgParser;
use crate::session_diagnostics::NullOnLinkSection;

pub(crate) struct LinkNameParser;

Expand All @@ -28,3 +29,31 @@ impl<S: Stage> SingleAttributeParser<S> for LinkNameParser {
Some(LinkName { name, span: cx.attr_span })
}
}

pub(crate) struct LinkSectionParser;

impl<S: Stage> SingleAttributeParser<S> for LinkSectionParser {
const PATH: &[Symbol] = &[sym::link_section];
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepFirst;
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::WarnButFutureError;
const TEMPLATE: AttributeTemplate = template!(NameValueStr: "name");

fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
let Some(nv) = args.name_value() else {
cx.expected_name_value(cx.attr_span, None);
return None;
};
let Some(name) = nv.value_as_str() else {
cx.expected_string_literal(nv.value_span, Some(nv.value_as_lit()));
return None;
};
if name.as_str().contains('\0') {
// `#[link_section = ...]` will be converted to a null-terminated string,
// so it may not contain any null characters.
cx.emit_err(NullOnLinkSection { span: cx.attr_span });
return None;
}

Some(LinkSection { name, span: cx.attr_span })
}
}
3 changes: 2 additions & 1 deletion compiler/rustc_attr_parsing/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::attributes::codegen_attrs::{
use crate::attributes::confusables::ConfusablesParser;
use crate::attributes::deprecation::DeprecationParser;
use crate::attributes::inline::{InlineParser, RustcForceInlineParser};
use crate::attributes::link_attrs::LinkNameParser;
use crate::attributes::link_attrs::{LinkNameParser, LinkSectionParser};
use crate::attributes::lint_helpers::{AsPtrParser, PubTransparentParser};
use crate::attributes::loop_match::{ConstContinueParser, LoopMatchParser};
use crate::attributes::must_use::MustUseParser;
Expand Down Expand Up @@ -123,6 +123,7 @@ attribute_parsers!(
Single<ExportNameParser>,
Single<InlineParser>,
Single<LinkNameParser>,
Single<LinkSectionParser>,
Single<LoopMatchParser>,
Single<MayDangleParser>,
Single<MustUseParser>,
Expand Down
7 changes: 7 additions & 0 deletions compiler/rustc_attr_parsing/src/session_diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,13 @@ pub(crate) struct NullOnExport {
pub span: Span,
}

#[derive(Diagnostic)]
#[diag(attr_parsing_null_on_link_section, code = E0648)]
pub(crate) struct NullOnLinkSection {
#[primary_span]
pub span: Span,
}

#[derive(Diagnostic)]
#[diag(attr_parsing_stability_outside_std, code = E0734)]
pub(crate) struct StabilityOutsideStd {
Expand Down
13 changes: 3 additions & 10 deletions compiler/rustc_codegen_ssa/src/codegen_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
AttributeKind::Naked(_) => codegen_fn_attrs.flags |= CodegenFnAttrFlags::NAKED,
AttributeKind::Align { align, .. } => codegen_fn_attrs.alignment = Some(*align),
AttributeKind::LinkName { name, .. } => codegen_fn_attrs.link_name = Some(*name),
AttributeKind::LinkSection { name, .. } => {
codegen_fn_attrs.link_section = Some(*name)
}
AttributeKind::NoMangle(attr_span) => {
if tcx.opt_item_name(did.to_def_id()).is_some() {
codegen_fn_attrs.flags |= CodegenFnAttrFlags::NO_MANGLE;
Expand Down Expand Up @@ -253,16 +256,6 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
}
}
}
sym::link_section => {
if let Some(val) = attr.value_str() {
if val.as_str().bytes().any(|b| b == 0) {
let msg = format!("illegal null byte in link_section value: `{val}`");
tcx.dcx().span_err(attr.span(), msg);
} else {
codegen_fn_attrs.link_section = Some(val);
}
}
}
sym::link_ordinal => {
link_ordinal_span = Some(attr.span());
if let ordinal @ Some(_) = check_link_ordinal(tcx, attr) {
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_codegen_ssa/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,15 +354,15 @@ fn optimize_use_clone<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(

let destination_block = target.unwrap();

bb.statements.push(mir::Statement {
source_info: bb.terminator().source_info,
kind: mir::StatementKind::Assign(Box::new((
bb.statements.push(mir::Statement::new(
bb.terminator().source_info,
mir::StatementKind::Assign(Box::new((
*destination,
mir::Rvalue::Use(mir::Operand::Copy(
arg_place.project_deeper(&[mir::ProjectionElem::Deref], tcx),
)),
))),
});
));

bb.terminator_mut().kind = mir::TerminatorKind::Goto { target: destination_block };
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3055,7 +3055,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pub(crate) fn note_unmet_impls_on_type(
&self,
err: &mut Diag<'_>,
errors: Vec<FulfillmentError<'tcx>>,
errors: &[FulfillmentError<'tcx>],
suggest_derive: bool,
) {
let preds: Vec<_> = errors
Expand Down
22 changes: 3 additions & 19 deletions compiler/rustc_hir_typeck/src/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
lhs_expr.span,
format!("cannot use `{}` on type `{}`", s, lhs_ty_str),
);
self.note_unmet_impls_on_type(&mut err, errors, false);
self.note_unmet_impls_on_type(&mut err, &errors, false);
(err, None)
}
Op::BinOp(bin_op) => {
Expand Down Expand Up @@ -382,7 +382,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
err.span_label(rhs_expr.span, rhs_ty_str);
}
let suggest_derive = self.can_eq(self.param_env, lhs_ty, rhs_ty);
self.note_unmet_impls_on_type(&mut err, errors, suggest_derive);
self.note_unmet_impls_on_type(&mut err, &errors, suggest_derive);
(err, output_def_id)
}
};
Expand Down Expand Up @@ -582,22 +582,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// concatenation (e.g., "Hello " + "World!"). This means
// we don't want the note in the else clause to be emitted
} else if lhs_ty.has_non_region_param() {
// Look for a TraitPredicate in the Fulfillment errors,
// and use it to generate a suggestion.
//
// Note that lookup_op_method must be called again but
// with a specific rhs_ty instead of a placeholder so
// the resulting predicate generates a more specific
// suggestion for the user.
let errors = self
.lookup_op_method(
(lhs_expr, lhs_ty),
Some((rhs_expr, rhs_ty)),
lang_item_for_binop(self.tcx, op),
op.span(),
expected,
)
.unwrap_err();
if !errors.is_empty() {
for error in errors {
if let Some(trait_pred) =
Expand Down Expand Up @@ -946,7 +930,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
ty::Str | ty::Never | ty::Char | ty::Tuple(_) | ty::Array(_, _) => {}
ty::Ref(_, lty, _) if *lty.kind() == ty::Str => {}
_ => {
self.note_unmet_impls_on_type(&mut err, errors, true);
self.note_unmet_impls_on_type(&mut err, &errors, true);
}
}
}
Expand Down
9 changes: 4 additions & 5 deletions compiler/rustc_infer/src/infer/freshen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,16 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for TypeFreshener<'a, 'tcx> {

fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
match r.kind() {
ty::ReBound(..) => {
// leave bound regions alone
r
}
// Leave bound regions alone, since they affect selection via the leak check.
ty::ReBound(..) => r,
// Leave error regions alone, since they affect selection b/c of incompleteness.
ty::ReError(_) => r,

ty::ReEarlyParam(..)
| ty::ReLateParam(_)
| ty::ReVar(_)
| ty::RePlaceholder(..)
| ty::ReStatic
| ty::ReError(_)
| ty::ReErased => self.cx().lifetimes.re_erased,
}
}
Expand Down
10 changes: 9 additions & 1 deletion compiler/rustc_middle/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1359,7 +1359,15 @@ pub struct BasicBlockData<'tcx> {

impl<'tcx> BasicBlockData<'tcx> {
pub fn new(terminator: Option<Terminator<'tcx>>, is_cleanup: bool) -> BasicBlockData<'tcx> {
BasicBlockData { statements: vec![], terminator, is_cleanup }
BasicBlockData::new_stmts(Vec::new(), terminator, is_cleanup)
}

pub fn new_stmts(
statements: Vec<Statement<'tcx>>,
terminator: Option<Terminator<'tcx>>,
is_cleanup: bool,
) -> BasicBlockData<'tcx> {
BasicBlockData { statements, terminator, is_cleanup }
}

/// Accessor for terminator.
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_middle/src/mir/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@ pub struct Statement<'tcx> {
pub kind: StatementKind<'tcx>,
}

impl Statement<'_> {
impl<'tcx> Statement<'tcx> {
/// Changes a statement to a nop. This is both faster than deleting instructions and avoids
/// invalidating statement indices in `Location`s.
pub fn make_nop(&mut self) {
self.kind = StatementKind::Nop
}

pub fn new(source_info: SourceInfo, kind: StatementKind<'tcx>) -> Self {
Statement { source_info, kind }
}
}

impl<'tcx> StatementKind<'tcx> {
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_mir_build/src/builder/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl<'tcx> CFG<'tcx> {
) {
self.push(
block,
Statement { source_info, kind: StatementKind::Assign(Box::new((place, rvalue))) },
Statement::new(source_info, StatementKind::Assign(Box::new((place, rvalue)))),
);
}

Expand Down Expand Up @@ -88,7 +88,7 @@ impl<'tcx> CFG<'tcx> {
place: Place<'tcx>,
) {
let kind = StatementKind::FakeRead(Box::new((cause, place)));
let stmt = Statement { source_info, kind };
let stmt = Statement::new(source_info, kind);
self.push(block, stmt);
}

Expand All @@ -99,7 +99,7 @@ impl<'tcx> CFG<'tcx> {
place: Place<'tcx>,
) {
let kind = StatementKind::PlaceMention(Box::new(place));
let stmt = Statement { source_info, kind };
let stmt = Statement::new(source_info, kind);
self.push(block, stmt);
}

Expand All @@ -110,7 +110,7 @@ impl<'tcx> CFG<'tcx> {
/// syntax (e.g. `continue` or `if !`) that would otherwise not appear in MIR.
pub(crate) fn push_coverage_span_marker(&mut self, block: BasicBlock, source_info: SourceInfo) {
let kind = StatementKind::Coverage(coverage::CoverageKind::SpanMarker);
let stmt = Statement { source_info, kind };
let stmt = Statement::new(source_info, kind);
self.push(block, stmt);
}

Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_mir_build/src/builder/coverageinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ impl BlockMarkerGen {
block: BasicBlock,
) -> BlockMarkerId {
let id = self.next_block_marker_id();
let marker_statement = mir::Statement {
let marker_statement = mir::Statement::new(
source_info,
kind: mir::StatementKind::Coverage(CoverageKind::BlockMarker { id }),
};
mir::StatementKind::Coverage(CoverageKind::BlockMarker { id }),
);
cfg.push(block, marker_statement);

id
Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_mir_build/src/builder/custom/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,8 @@ impl<'a, 'tcx> ParseCtxt<'a, 'tcx> {
let stmt = self.statement_as_expr(*stmt_id)?;
let span = self.thir[stmt].span;
let statement = self.parse_statement(stmt)?;
data.statements.push(Statement {
source_info: SourceInfo { span, scope: self.source_scope },
kind: statement,
});
data.statements
.push(Statement::new(SourceInfo { span, scope: self.source_scope }, statement));
}

let Some(trailing) = block.expr else { return Err(self.expr_error(expr_id, "terminator")) };
Expand Down
16 changes: 8 additions & 8 deletions compiler/rustc_mir_build/src/builder/expr/as_place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,16 +489,16 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let place = place_builder.to_place(this);
this.cfg.push(
block,
Statement {
source_info: ty_source_info,
kind: StatementKind::AscribeUserType(
Statement::new(
ty_source_info,
StatementKind::AscribeUserType(
Box::new((
place,
UserTypeProjection { base: annotation_index, projs: vec![] },
)),
Variance::Invariant,
),
},
),
);
}
block.and(place_builder)
Expand All @@ -518,16 +518,16 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
});
this.cfg.push(
block,
Statement {
source_info: ty_source_info,
kind: StatementKind::AscribeUserType(
Statement::new(
ty_source_info,
StatementKind::AscribeUserType(
Box::new((
Place::from(temp),
UserTypeProjection { base: annotation_index, projs: vec![] },
)),
Variance::Invariant,
),
},
),
);
}
block.and(PlaceBuilder::from(temp))
Expand Down
Loading
Loading