Skip to content

Rollup of 12 pull requests #143287

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 32 commits into from
Jul 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
07e8b28
Implement `Random` for tuple
sorairolake Feb 10, 2025
3a56a03
Address documentation issues identified with Future
Diggsey Jun 1, 2025
977752f
docs(fs): Touch up grammar on lock api
epage Jun 20, 2025
4b6c3d9
moved & deleted some tests
Kivooeo Jun 29, 2025
4feb5de
moved tests
Kivooeo Jun 29, 2025
bf5910d
cleaned up some tests
Kivooeo Jun 29, 2025
90e0835
mir: Mark `Statement` and `BasicBlockData` as `#[non_exhaustive]`
dianqk Jun 30, 2025
c3fb7d1
Make some compiletest errors/warnings/help more visually obvious
jieyouxu Jun 30, 2025
c2daa28
Do not enable LLD by default in the dist profile
Kobzol Jun 30, 2025
09e0dca
bootstrap: make comment more clear
tshepang Jul 1, 2025
da5c639
cleaned up some tests
Kivooeo Jun 29, 2025
022c914
Remove `ItemKind::descr` method
GuillaumeGomez Jul 1, 2025
0fcf295
New test for malformed attributes
JonathanBrouwer Jun 28, 2025
86b54d5
Fix double error for `export_name`
JonathanBrouwer Jun 29, 2025
149bdde
Fix `#[must_use = 1]` not giving an error
JonathanBrouwer Jun 29, 2025
0b67d14
Fix `#[rustc_macro_transparency]` giving two errors
JonathanBrouwer Jun 29, 2025
d22ce4c
Fix duplicate help on export_name and others
JonathanBrouwer Jun 29, 2025
1e474c2
Port `#[rustc_object_lifetime_default]` to the new attribute parsing …
JonathanBrouwer Jul 1, 2025
57a5e3b
Fix duplicate errors for `link_section`, `rustc_layout_scalar_valid_r…
JonathanBrouwer Jul 1, 2025
711c616
Update clippy source code to make use of `TyCtxt::def_descr` instead …
GuillaumeGomez Jul 1, 2025
ad65039
Rollup merge of #136801 - sorairolake:add-random-for-tuple, r=joshtri…
GuillaumeGomez Jul 1, 2025
9887108
Rollup merge of #141867 - Diggsey:db-improve-future-docs, r=tgross35
GuillaumeGomez Jul 1, 2025
827cd29
Rollup merge of #142760 - epage:lock, r=tgross35
GuillaumeGomez Jul 1, 2025
1f88117
Rollup merge of #143181 - JonathanBrouwer:malformed-attrs, r=oli-obk
GuillaumeGomez Jul 1, 2025
ff0a5f5
Rollup merge of #143210 - Kivooeo:tf19, r=tgross35
GuillaumeGomez Jul 1, 2025
65942af
Rollup merge of #143212 - Kivooeo:tf20, r=tgross35
GuillaumeGomez Jul 1, 2025
cb451cf
Rollup merge of #143230 - jieyouxu:compiletest-maintenance-2, r=Kobzol
GuillaumeGomez Jul 1, 2025
61bb076
Rollup merge of #143240 - JonathanBrouwer:object_lifetime_default_par…
GuillaumeGomez Jul 1, 2025
8b0e7d7
Rollup merge of #143255 - Kobzol:disable-lld-by-default, r=jieyouxu
GuillaumeGomez Jul 1, 2025
b47008a
Rollup merge of #143262 - dianqk:non_exhaustive, r=oli-obk
GuillaumeGomez Jul 1, 2025
d2463c9
Rollup merge of #143269 - tshepang:patch-1, r=Kobzol
GuillaumeGomez Jul 1, 2025
189bfc1
Rollup merge of #143279 - GuillaumeGomez:rm-itemkind-descr, r=oli-obk
GuillaumeGomez Jul 1, 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
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 @@ -296,6 +296,9 @@ pub enum AttributeKind {
/// Represents `#[rustc_layout_scalar_valid_range_start]`.
RustcLayoutScalarValidRangeStart(Box<u128>, Span),

/// Represents `#[rustc_object_lifetime_default]`.
RustcObjectLifetimeDefault,

/// Represents `#[rustc_skip_during_method_dispatch]`.
SkipDuringMethodDispatch { array: bool, boxed_slice: bool, span: Span },

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ impl AttributeKind {
PubTransparent(..) => Yes,
RustcLayoutScalarValidRangeEnd(..) => Yes,
RustcLayoutScalarValidRangeStart(..) => Yes,
RustcObjectLifetimeDefault => No,
SkipDuringMethodDispatch { .. } => No,
TrackCaller(..) => Yes,
Used { .. } => No,
Expand Down
11 changes: 10 additions & 1 deletion compiler/rustc_attr_parsing/src/attributes/must_use.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,16 @@ impl<S: Stage> SingleAttributeParser<S> for MustUseParser {
span: cx.attr_span,
reason: match args {
ArgParser::NoArgs => None,
ArgParser::NameValue(name_value) => name_value.value_as_str(),
ArgParser::NameValue(name_value) => {
let Some(value_str) = name_value.value_as_str() else {
cx.expected_string_literal(
name_value.value_span,
Some(&name_value.value_as_lit()),
);
return None;
};
Some(value_str)
}
ArgParser::List(_) => {
let suggestions =
<Self as SingleAttributeParser<S>>::TEMPLATE.suggestions(false, "must_use");
Expand Down
18 changes: 18 additions & 0 deletions compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,21 @@ fn parse_rustc_layout_scalar_valid_range<S: Stage>(
};
Some(Box::new(num.0))
}

pub(crate) struct RustcObjectLifetimeDefaultParser;

impl<S: Stage> SingleAttributeParser<S> for RustcObjectLifetimeDefaultParser {
const PATH: &[rustc_span::Symbol] = &[sym::rustc_object_lifetime_default];
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepFirst;
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const TEMPLATE: AttributeTemplate = template!(Word);

fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
if let Err(span) = args.no_args() {
cx.expected_no_args(span);
return None;
}

Some(AttributeKind::RustcObjectLifetimeDefault)
}
}
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 @@ -29,6 +29,7 @@ use crate::attributes::must_use::MustUseParser;
use crate::attributes::repr::{AlignParser, ReprParser};
use crate::attributes::rustc_internal::{
RustcLayoutScalarValidRangeEnd, RustcLayoutScalarValidRangeStart,
RustcObjectLifetimeDefaultParser,
};
use crate::attributes::semantics::MayDangleParser;
use crate::attributes::stability::{
Expand Down Expand Up @@ -136,6 +137,7 @@ attribute_parsers!(
Single<RustcForceInlineParser>,
Single<RustcLayoutScalarValidRangeEnd>,
Single<RustcLayoutScalarValidRangeStart>,
Single<RustcObjectLifetimeDefaultParser>,
Single<SkipDuringMethodDispatchParser>,
Single<TrackCallerParser>,
Single<TransparencyParser>,
Expand Down
5 changes: 1 addition & 4 deletions compiler/rustc_attr_parsing/src/session_diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,10 +577,7 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for AttributeParseError {
diag.code(E0565);
}
AttributeParseErrorReason::ExpectedNameValue(None) => {
diag.span_label(
self.span,
format!("expected this to be of the form `{name} = \"...\"`"),
);
// The suggestion we add below this match already contains enough information
}
AttributeParseErrorReason::ExpectedNameValue(Some(name)) => {
diag.span_label(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
_,
mir::Rvalue::Use(mir::Operand::Copy(place)),
)),
..
}) = self.body[location.block].statements.get(location.statement_index)
{
self.body.local_decls[place.local].source_info.span
Expand Down
21 changes: 0 additions & 21 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4400,27 +4400,6 @@ impl ItemKind<'_> {
_ => return None,
})
}

pub fn descr(&self) -> &'static str {
match self {
ItemKind::ExternCrate(..) => "extern crate",
ItemKind::Use(..) => "`use` import",
ItemKind::Static(..) => "static item",
ItemKind::Const(..) => "constant item",
ItemKind::Fn { .. } => "function",
ItemKind::Macro(..) => "macro",
ItemKind::Mod(..) => "module",
ItemKind::ForeignMod { .. } => "extern block",
ItemKind::GlobalAsm { .. } => "global asm item",
ItemKind::TyAlias(..) => "type alias",
ItemKind::Enum(..) => "enum",
ItemKind::Struct(..) => "struct",
ItemKind::Union(..) => "union",
ItemKind::Trait(..) => "trait",
ItemKind::TraitAlias(..) => "trait alias",
ItemKind::Impl(..) => "implementation",
}
}
}

/// A reference from an trait to one of its associated items. This
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_middle/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1336,6 +1336,7 @@ impl BasicBlock {
///
/// See [`BasicBlock`] for documentation on what basic blocks are at a high level.
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
#[non_exhaustive]
pub struct BasicBlockData<'tcx> {
/// List of statements in this block.
pub statements: Vec<Statement<'tcx>>,
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_middle/src/mir/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::ty::CoroutineArgsExt;

/// A statement in a basic block, including information about its source code.
#[derive(Clone, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
#[non_exhaustive]
pub struct Statement<'tcx> {
pub source_info: SourceInfo,
pub kind: StatementKind<'tcx>,
Expand Down
49 changes: 24 additions & 25 deletions compiler/rustc_mir_transform/src/check_enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,11 @@ fn split_block(
let block_data = &mut basic_blocks[location.block];

// Drain every statement after this one and move the current terminator to a new basic block.
let new_block = BasicBlockData {
statements: block_data.statements.split_off(location.statement_index),
terminator: block_data.terminator.take(),
is_cleanup: block_data.is_cleanup,
};
let new_block = BasicBlockData::new_stmts(
block_data.statements.split_off(location.statement_index),
block_data.terminator.take(),
block_data.is_cleanup,
);

basic_blocks.push(new_block)
}
Expand Down Expand Up @@ -270,10 +270,9 @@ fn insert_discr_cast_to_u128<'tcx>(
let mu_array =
local_decls.push(LocalDecl::with_source_info(mu_array_ty, source_info)).into();
let rvalue = Rvalue::Cast(CastKind::Transmute, source_op, mu_array_ty);
block_data.statements.push(Statement {
source_info,
kind: StatementKind::Assign(Box::new((mu_array, rvalue))),
});
block_data
.statements
.push(Statement::new(source_info, StatementKind::Assign(Box::new((mu_array, rvalue)))));

// Index into the array of MaybeUninit to get something that is actually
// as wide as the discriminant.
Expand All @@ -294,10 +293,10 @@ fn insert_discr_cast_to_u128<'tcx>(
let op_as_int =
local_decls.push(LocalDecl::with_source_info(operand_int_ty, source_info)).into();
let rvalue = Rvalue::Cast(CastKind::Transmute, source_op, operand_int_ty);
block_data.statements.push(Statement {
block_data.statements.push(Statement::new(
source_info,
kind: StatementKind::Assign(Box::new((op_as_int, rvalue))),
});
StatementKind::Assign(Box::new((op_as_int, rvalue))),
));

(CastKind::IntToInt, Operand::Copy(op_as_int))
};
Expand All @@ -306,18 +305,18 @@ fn insert_discr_cast_to_u128<'tcx>(
let rvalue = Rvalue::Cast(cast_kind, discr_ty_bits, discr.ty);
let discr_in_discr_ty =
local_decls.push(LocalDecl::with_source_info(discr.ty, source_info)).into();
block_data.statements.push(Statement {
block_data.statements.push(Statement::new(
source_info,
kind: StatementKind::Assign(Box::new((discr_in_discr_ty, rvalue))),
});
StatementKind::Assign(Box::new((discr_in_discr_ty, rvalue))),
));

// Cast the discriminant to a u128 (base for comparisions of enum discriminants).
let const_u128 = Ty::new_uint(tcx, ty::UintTy::U128);
let rvalue = Rvalue::Cast(CastKind::IntToInt, Operand::Copy(discr_in_discr_ty), const_u128);
let discr = local_decls.push(LocalDecl::with_source_info(const_u128, source_info)).into();
block_data
.statements
.push(Statement { source_info, kind: StatementKind::Assign(Box::new((discr, rvalue))) });
.push(Statement::new(source_info, StatementKind::Assign(Box::new((discr, rvalue)))));

discr
}
Expand Down Expand Up @@ -390,17 +389,17 @@ fn insert_uninhabited_enum_check<'tcx>(
) {
let is_ok: Place<'_> =
local_decls.push(LocalDecl::with_source_info(tcx.types.bool, source_info)).into();
block_data.statements.push(Statement {
block_data.statements.push(Statement::new(
source_info,
kind: StatementKind::Assign(Box::new((
StatementKind::Assign(Box::new((
is_ok,
Rvalue::Use(Operand::Constant(Box::new(ConstOperand {
span: source_info.span,
user_ty: None,
const_: Const::Val(ConstValue::from_bool(false), tcx.types.bool),
}))),
))),
});
));

block_data.terminator = Some(Terminator {
source_info,
Expand Down Expand Up @@ -463,27 +462,27 @@ fn insert_niche_check<'tcx>(

let discr_diff: Place<'_> =
local_decls.push(LocalDecl::with_source_info(tcx.types.u128, source_info)).into();
block_data.statements.push(Statement {
block_data.statements.push(Statement::new(
source_info,
kind: StatementKind::Assign(Box::new((
StatementKind::Assign(Box::new((
discr_diff,
Rvalue::BinaryOp(BinOp::Sub, Box::new((Operand::Copy(discr), start_const))),
))),
});
));

let is_ok: Place<'_> =
local_decls.push(LocalDecl::with_source_info(tcx.types.bool, source_info)).into();
block_data.statements.push(Statement {
block_data.statements.push(Statement::new(
source_info,
kind: StatementKind::Assign(Box::new((
StatementKind::Assign(Box::new((
is_ok,
Rvalue::BinaryOp(
// This is a `WrappingRange`, so make sure to get the wrapping right.
BinOp::Le,
Box::new((Operand::Copy(discr_diff), end_start_diff_const)),
),
))),
});
));

block_data.terminator = Some(Terminator {
source_info,
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_parse/src/validate_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ fn emit_malformed_attribute(
| sym::must_use
| sym::track_caller
| sym::link_name
| sym::export_name
| sym::rustc_macro_transparency
| sym::link_section
| sym::rustc_layout_scalar_valid_range_start
| sym::rustc_layout_scalar_valid_range_end
) {
return;
}
Expand Down
7 changes: 4 additions & 3 deletions compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
}
Attribute::Parsed(AttributeKind::Repr(_)) => { /* handled below this loop and elsewhere */
}

Attribute::Parsed(AttributeKind::RustcObjectLifetimeDefault) => {
self.check_object_lifetime_default(hir_id);
}
&Attribute::Parsed(AttributeKind::PubTransparent(attr_span)) => {
self.check_rustc_pub_transparent(attr_span, span, attrs)
}
Expand Down Expand Up @@ -303,7 +305,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
[sym::no_implicit_prelude, ..] => {
self.check_generic_attr(hir_id, attr, target, Target::Mod)
}
[sym::rustc_object_lifetime_default, ..] => self.check_object_lifetime_default(hir_id),
[sym::proc_macro, ..] => {
self.check_proc_macro(hir_id, target, ProcMacroKind::FunctionLike)
}
Expand Down Expand Up @@ -2831,7 +2832,7 @@ fn check_invalid_crate_level_attr(tcx: TyCtxt<'_>, attrs: &[Attribute]) {
.find(|item| !item.span.is_dummy()) // Skip prelude `use`s
.map(|item| errors::ItemFollowingInnerAttr {
span: if let Some(ident) = item.kind.ident() { ident.span } else { item.span },
kind: item.kind.descr(),
kind: tcx.def_descr(item.owner_id.to_def_id()),
});
let err = tcx.dcx().create_err(errors::InvalidAttrAtCrateLevel {
span,
Expand Down
23 changes: 16 additions & 7 deletions library/core/src/future/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ use crate::ops;
use crate::pin::Pin;
use crate::task::{Context, Poll};

/// A future represents an asynchronous computation obtained by use of [`async`].
/// A future represents an asynchronous computation, commonly obtained by use of
/// [`async`].
///
/// A future is a value that might not have finished computing yet. This kind of
/// "asynchronous value" makes it possible for a thread to continue doing useful
Expand Down Expand Up @@ -68,13 +69,21 @@ pub trait Future {
///
/// # Runtime characteristics
///
/// Futures alone are *inert*; they must be *actively* `poll`ed to make
/// progress, meaning that each time the current task is woken up, it should
/// actively re-`poll` pending futures that it still has an interest in.
/// Futures alone are *inert*; they must be *actively* `poll`ed for the
/// underlying computation to make progress, meaning that each time the
/// current task is woken up, it should actively re-`poll` pending futures
/// that it still has an interest in.
///
/// The `poll` function is not called repeatedly in a tight loop -- instead,
/// it should only be called when the future indicates that it is ready to
/// make progress (by calling `wake()`). If you're familiar with the
/// Having said that, some Futures may represent a value that is being
/// computed in a different task. In this case, the future's underlying
/// computation is simply acting as a conduit for a value being computed
/// by that other task, which will proceed independently of the Future.
/// Futures of this kind are typically obtained when spawning a new task into an
/// async runtime.
///
/// The `poll` function should not be called repeatedly in a tight loop --
/// instead, it should only be called when the future indicates that it is
/// ready to make progress (by calling `wake()`). If you're familiar with the
/// `poll(2)` or `select(2)` syscalls on Unix it's worth noting that futures
/// typically do *not* suffer the same problems of "all wakeups must poll
/// all events"; they are more like `epoll(4)`.
Expand Down
2 changes: 2 additions & 0 deletions library/core/src/primitive_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1083,11 +1083,13 @@ mod prim_str {}
/// * [`Debug`]
/// * [`Default`]
/// * [`Hash`]
/// * [`Random`]
/// * [`From<[T; N]>`][from]
///
/// [from]: convert::From
/// [`Debug`]: fmt::Debug
/// [`Hash`]: hash::Hash
/// [`Random`]: random::Random
///
/// The following traits are implemented for tuples of any length. These traits have
/// implementations that are automatically generated by the compiler, so are not limited by
Expand Down
11 changes: 11 additions & 0 deletions library/core/src/tuple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use crate::cmp::Ordering::{self, *};
use crate::marker::{ConstParamTy_, PointeeSized, StructuralPartialEq, UnsizedConstParamTy};
use crate::ops::ControlFlow::{self, Break, Continue};
use crate::random::{Random, RandomSource};

// Recursive macro for implementing n-ary tuple functions and operations
//
Expand Down Expand Up @@ -139,6 +140,16 @@ macro_rules! tuple_impls {
}
}

maybe_tuple_doc! {
$($T)+ @
#[unstable(feature = "random", issue = "130703")]
impl<$($T: Random),+> Random for ($($T,)+) {
fn random(source: &mut (impl RandomSource + ?Sized)) -> Self {
($({ let x: $T = Random::random(source); x},)+)
}
}
}

maybe_tuple_doc! {
$($T)+ @
#[stable(feature = "array_tuple_conv", since = "1.71.0")]
Expand Down
Loading
Loading