Skip to content

Rollup of 15 pull requests #145020

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 34 commits into from
Aug 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
74e85a2
removed gate
Kivooeo Aug 3, 2025
f6ce4ac
Anonymize binders in tail call sig
compiler-errors Aug 2, 2025
c7ea022
Enforce tail call type is related to body return type in borrowck
compiler-errors Aug 4, 2025
904e2af
Port `#[coroutine]` to the new attribute system
scrabsha Aug 1, 2025
a573fd9
Don't actually pass BB to check_call_dest
compiler-errors Aug 4, 2025
d09cf61
Added checks for attribute in type case
Kivooeo Jul 19, 2025
092c6f3
Gate const trait syntax
fmease Aug 5, 2025
ea2c080
we only merge candidates for trait and normalizes-to goals
lcnr Aug 5, 2025
34b358d
rustdoc: fix caching of intra-doc links on reexports
lolbinarycat Aug 5, 2025
d8e8a5e
add code example showing that file_prefix treats dotfiles as the name…
the8472 Aug 5, 2025
1bb14a8
`File::set_times`: Remove `write(true)` from the example so it works …
joshtriplett Aug 5, 2025
a99860b
`File::set_times`: Add documentation about setting directory timestamps
joshtriplett Aug 5, 2025
02ea38c
Fortify generic param default checks
fmease Aug 5, 2025
2909de5
simplifycfg: Mark as changed when start is modified in collapse goto …
dianqk Aug 6, 2025
d55cc9a
mir: Do not modify NonUse in `super_projection_elem`
dianqk Aug 6, 2025
057df26
Remove unneeded `stage` parameter when setting up stdlib Cargo
Kobzol Aug 6, 2025
768f977
Fix rustdoc scrape-examples feature crash
GuillaumeGomez Aug 6, 2025
a2b1714
Add regression test for rustdoc scrape-examples feature crash (#144752)
GuillaumeGomez Aug 6, 2025
e597071
Reword documentation for `set_times` to clarify directory handling
joshtriplett Aug 6, 2025
d180873
Rollup merge of #144195 - Kivooeo:bad-attr, r=fmease,compiler-errors
GuillaumeGomez Aug 6, 2025
96a41c5
Rollup merge of #144794 - scrabsha:push-noqrrttovmwy, r=jdonszelmann
GuillaumeGomez Aug 6, 2025
940a003
Rollup merge of #144835 - compiler-errors:tail-call-sig-binder, r=Waf…
GuillaumeGomez Aug 6, 2025
5209bc6
Rollup merge of #144861 - Kivooeo:payload-as-str-stabilization, r=Chr…
GuillaumeGomez Aug 6, 2025
65479f7
Rollup merge of #144917 - compiler-errors:tail-call-linked-lifetimes,…
GuillaumeGomez Aug 6, 2025
f752035
Rollup merge of #144948 - lcnr:change-candidate-handling, r=compiler-…
GuillaumeGomez Aug 6, 2025
48d5756
Rollup merge of #144956 - fmease:gate-const-trait-syntax, r=BoxyUwU
GuillaumeGomez Aug 6, 2025
de6c639
Rollup merge of #144970 - lolbinarycat:rustdoc-macro-wrong-link-14496…
GuillaumeGomez Aug 6, 2025
09de71b
Rollup merge of #144972 - the8472:file-prefix-docs, r=joshtriplett
GuillaumeGomez Aug 6, 2025
094b893
Rollup merge of #144975 - joshtriplett:file-times-dir, r=jhpratt
GuillaumeGomez Aug 6, 2025
12d1b17
Rollup merge of #144977 - fmease:fortify-param-default-checks, r=comp…
GuillaumeGomez Aug 6, 2025
e56c241
Rollup merge of #144996 - dianqk:simplifycfg-collapse_goto_chain-chan…
GuillaumeGomez Aug 6, 2025
c152aa8
Rollup merge of #144998 - dianqk:visit-no-use-proj, r=cjgillot
GuillaumeGomez Aug 6, 2025
c17f50b
Rollup merge of #145000 - Kobzol:std-cargo-stage, r=jieyouxu
GuillaumeGomez Aug 6, 2025
d369a1f
Rollup merge of #145008 - GuillaumeGomez:fix-rustdoc-scrape-examples-…
GuillaumeGomez Aug 6, 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
18 changes: 6 additions & 12 deletions compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
}

let expr_hir_id = self.lower_node_id(e.id);
self.lower_attrs(expr_hir_id, &e.attrs, e.span);
let attrs = self.lower_attrs(expr_hir_id, &e.attrs, e.span);

let kind = match &e.kind {
ExprKind::Array(exprs) => hir::ExprKind::Array(self.lower_exprs(exprs)),
Expand Down Expand Up @@ -232,10 +232,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
*fn_arg_span,
),
None => self.lower_expr_closure(
attrs,
binder,
*capture_clause,
e.id,
expr_hir_id,
*constness,
*movability,
fn_decl,
Expand Down Expand Up @@ -1052,10 +1052,10 @@ impl<'hir> LoweringContext<'_, 'hir> {

fn lower_expr_closure(
&mut self,
attrs: &[rustc_hir::Attribute],
binder: &ClosureBinder,
capture_clause: CaptureBy,
closure_id: NodeId,
closure_hir_id: hir::HirId,
constness: Const,
movability: Movability,
decl: &FnDecl,
Expand All @@ -1067,15 +1067,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
let (binder_clause, generic_params) = self.lower_closure_binder(binder);

let (body_id, closure_kind) = self.with_new_scopes(fn_decl_span, move |this| {
let mut coroutine_kind = if this
.attrs
.get(&closure_hir_id.local_id)
.is_some_and(|attrs| attrs.iter().any(|attr| attr.has_name(sym::coroutine)))
{
Some(hir::CoroutineKind::Coroutine(Movability::Movable))
} else {
None
};

let mut coroutine_kind = find_attr!(attrs, AttributeKind::Coroutine(_) => hir::CoroutineKind::Coroutine(Movability::Movable));

// FIXME(contracts): Support contracts on closures?
let body_id = this.lower_fn_body(decl, None, |this| {
this.coroutine_kind = coroutine_kind;
Expand Down
15 changes: 15 additions & 0 deletions compiler/rustc_attr_parsing/src/attributes/body.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//! Attributes that can be found in function body.

use rustc_hir::attrs::AttributeKind;
use rustc_span::{Symbol, sym};

use super::{NoArgsAttributeParser, OnDuplicate};
use crate::context::Stage;

pub(crate) struct CoroutineParser;

impl<S: Stage> NoArgsAttributeParser<S> for CoroutineParser {
const PATH: &[Symbol] = &[sym::coroutine];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const CREATE: fn(rustc_span::Span) -> AttributeKind = |span| AttributeKind::Coroutine(span);
}
1 change: 1 addition & 0 deletions compiler/rustc_attr_parsing/src/attributes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use crate::parser::ArgParser;
use crate::session_diagnostics::UnusedMultiple;

pub(crate) mod allow_unstable;
pub(crate) mod body;
pub(crate) mod cfg;
pub(crate) mod cfg_old;
pub(crate) mod codegen_attrs;
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_attr_parsing/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span, Symbol, sym};
use crate::attributes::allow_unstable::{
AllowConstFnUnstableParser, AllowInternalUnstableParser, UnstableFeatureBoundParser,
};
use crate::attributes::body::CoroutineParser;
use crate::attributes::codegen_attrs::{
ColdParser, CoverageParser, ExportNameParser, NakedParser, NoMangleParser, OptimizeParser,
TargetFeatureParser, TrackCallerParser, UsedParser,
Expand Down Expand Up @@ -184,6 +185,7 @@ attribute_parsers!(
Single<WithoutArgs<ConstContinueParser>>,
Single<WithoutArgs<ConstStabilityIndirectParser>>,
Single<WithoutArgs<ConstTraitParser>>,
Single<WithoutArgs<CoroutineParser>>,
Single<WithoutArgs<DenyExplicitImplParser>>,
Single<WithoutArgs<DoNotImplementViaObjectParser>>,
Single<WithoutArgs<ExportStableParser>>,
Expand Down
110 changes: 54 additions & 56 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -769,9 +769,13 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
}
TerminatorKind::Call { func, args, .. }
| TerminatorKind::TailCall { func, args, .. } => {
let call_source = match term.kind {
TerminatorKind::Call { call_source, .. } => call_source,
TerminatorKind::TailCall { .. } => CallSource::Normal,
let (call_source, destination, is_diverging) = match term.kind {
TerminatorKind::Call { call_source, destination, target, .. } => {
(call_source, destination, target.is_none())
}
TerminatorKind::TailCall { .. } => {
(CallSource::Normal, RETURN_PLACE.into(), false)
}
_ => unreachable!(),
};

Expand Down Expand Up @@ -845,9 +849,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
);
}

if let TerminatorKind::Call { destination, target, .. } = term.kind {
self.check_call_dest(term, &sig, destination, target, term_location);
}
self.check_call_dest(term, &sig, destination, is_diverging, term_location);

// The ordinary liveness rules will ensure that all
// regions in the type of the callee are live here. We
Expand Down Expand Up @@ -1874,65 +1876,61 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
term: &Terminator<'tcx>,
sig: &ty::FnSig<'tcx>,
destination: Place<'tcx>,
target: Option<BasicBlock>,
is_diverging: bool,
term_location: Location,
) {
let tcx = self.tcx();
match target {
Some(_) => {
let dest_ty = destination.ty(self.body, tcx).ty;
let dest_ty = self.normalize(dest_ty, term_location);
let category = match destination.as_local() {
Some(RETURN_PLACE) => {
if let DefiningTy::Const(def_id, _) | DefiningTy::InlineConst(def_id, _) =
self.universal_regions.defining_ty
{
if tcx.is_static(def_id) {
ConstraintCategory::UseAsStatic
} else {
ConstraintCategory::UseAsConst
}
if is_diverging {
// The signature in this call can reference region variables,
// so erase them before calling a query.
let output_ty = self.tcx().erase_regions(sig.output());
if !output_ty
.is_privately_uninhabited(self.tcx(), self.infcx.typing_env(self.infcx.param_env))
{
span_mirbug!(self, term, "call to converging function {:?} w/o dest", sig);
}
} else {
let dest_ty = destination.ty(self.body, tcx).ty;
let dest_ty = self.normalize(dest_ty, term_location);
let category = match destination.as_local() {
Some(RETURN_PLACE) => {
if let DefiningTy::Const(def_id, _) | DefiningTy::InlineConst(def_id, _) =
self.universal_regions.defining_ty
{
if tcx.is_static(def_id) {
ConstraintCategory::UseAsStatic
} else {
ConstraintCategory::Return(ReturnConstraint::Normal)
ConstraintCategory::UseAsConst
}
} else {
ConstraintCategory::Return(ReturnConstraint::Normal)
}
Some(l) if !self.body.local_decls[l].is_user_variable() => {
ConstraintCategory::Boring
}
// The return type of a call is interesting for diagnostics.
_ => ConstraintCategory::Assignment,
};

let locations = term_location.to_locations();

if let Err(terr) = self.sub_types(sig.output(), dest_ty, locations, category) {
span_mirbug!(
self,
term,
"call dest mismatch ({:?} <- {:?}): {:?}",
dest_ty,
sig.output(),
terr
);
}

// When `unsized_fn_params` is not enabled,
// this check is done at `check_local`.
if self.unsized_feature_enabled() {
let span = term.source_info.span;
self.ensure_place_sized(dest_ty, span);
Some(l) if !self.body.local_decls[l].is_user_variable() => {
ConstraintCategory::Boring
}
// The return type of a call is interesting for diagnostics.
_ => ConstraintCategory::Assignment,
};

let locations = term_location.to_locations();

if let Err(terr) = self.sub_types(sig.output(), dest_ty, locations, category) {
span_mirbug!(
self,
term,
"call dest mismatch ({:?} <- {:?}): {:?}",
dest_ty,
sig.output(),
terr
);
}
None => {
// The signature in this call can reference region variables,
// so erase them before calling a query.
let output_ty = self.tcx().erase_regions(sig.output());
if !output_ty.is_privately_uninhabited(
self.tcx(),
self.infcx.typing_env(self.infcx.param_env),
) {
span_mirbug!(self, term, "call to converging function {:?} w/o dest", sig);
}

// When `unsized_fn_params` is not enabled,
// this check is done at `check_local`.
if self.unsized_feature_enabled() {
let span = term.source_info.span;
self.ensure_place_sized(dest_ty, span);
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_hir/src/attrs/data_structures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,9 @@ pub enum AttributeKind {
/// Represents `#[const_trait]`.
ConstTrait(Span),

/// Represents `#[coroutine]`.
Coroutine(Span),

/// Represents `#[coverage(..)]`.
Coverage(Span, CoverageAttrKind),

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir/src/attrs/encode_cross_crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ impl AttributeKind {
ConstStability { .. } => Yes,
ConstStabilityIndirect => No,
ConstTrait(..) => No,
Coroutine(..) => No,
Coverage(..) => No,
DenyExplicitImpl(..) => No,
Deprecation { .. } => Yes,
Expand Down
Loading
Loading