Skip to content

Commit 71e4c00

Browse files
committed
Auto merge of #143287 - GuillaumeGomez:rollup-fdjcti9, r=GuillaumeGomez
Rollup of 12 pull requests Successful merges: - #136801 (Implement `Random` for tuple) - #141867 (Describe Future invariants more precisely) - #142760 (docs(fs): Touch up grammar on lock api) - #143181 (Improve testing and error messages for malformed attributes) - #143210 (`tests/ui`: A New Order [19/N] ) - #143212 (`tests/ui`: A New Order [20/N]) - #143230 ([COMPILETEST-UNTANGLE 2/N] Make some compiletest errors/warnings/help more visually obvious) - #143240 (Port `#[rustc_object_lifetime_default]` to the new attribute parsing …) - #143255 (Do not enable LLD by default in the dist profile) - #143262 (mir: Mark `Statement` and `BasicBlockData` as `#[non_exhaustive]`) - #143269 (bootstrap: make comment more clear) - #143279 (Remove `ItemKind::descr` method) Failed merges: - #143237 (Port `#[no_implicit_prelude]` to the new attribute parsing infrastructure) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 4e97337 + 189bfc1 commit 71e4c00

File tree

89 files changed

+1573
-574
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+1573
-574
lines changed

compiler/rustc_attr_data_structures/src/attributes.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,9 @@ pub enum AttributeKind {
296296
/// Represents `#[rustc_layout_scalar_valid_range_start]`.
297297
RustcLayoutScalarValidRangeStart(Box<u128>, Span),
298298

299+
/// Represents `#[rustc_object_lifetime_default]`.
300+
RustcObjectLifetimeDefault,
301+
299302
/// Represents `#[rustc_skip_during_method_dispatch]`.
300303
SkipDuringMethodDispatch { array: bool, boxed_slice: bool, span: Span },
301304

compiler/rustc_attr_data_structures/src/encode_cross_crate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ impl AttributeKind {
4040
PubTransparent(..) => Yes,
4141
RustcLayoutScalarValidRangeEnd(..) => Yes,
4242
RustcLayoutScalarValidRangeStart(..) => Yes,
43+
RustcObjectLifetimeDefault => No,
4344
SkipDuringMethodDispatch { .. } => No,
4445
TrackCaller(..) => Yes,
4546
Used { .. } => No,

compiler/rustc_attr_parsing/src/attributes/must_use.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,16 @@ impl<S: Stage> SingleAttributeParser<S> for MustUseParser {
2121
span: cx.attr_span,
2222
reason: match args {
2323
ArgParser::NoArgs => None,
24-
ArgParser::NameValue(name_value) => name_value.value_as_str(),
24+
ArgParser::NameValue(name_value) => {
25+
let Some(value_str) = name_value.value_as_str() else {
26+
cx.expected_string_literal(
27+
name_value.value_span,
28+
Some(&name_value.value_as_lit()),
29+
);
30+
return None;
31+
};
32+
Some(value_str)
33+
}
2534
ArgParser::List(_) => {
2635
let suggestions =
2736
<Self as SingleAttributeParser<S>>::TEMPLATE.suggestions(false, "must_use");

compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,21 @@ fn parse_rustc_layout_scalar_valid_range<S: Stage>(
5757
};
5858
Some(Box::new(num.0))
5959
}
60+
61+
pub(crate) struct RustcObjectLifetimeDefaultParser;
62+
63+
impl<S: Stage> SingleAttributeParser<S> for RustcObjectLifetimeDefaultParser {
64+
const PATH: &[rustc_span::Symbol] = &[sym::rustc_object_lifetime_default];
65+
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepFirst;
66+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
67+
const TEMPLATE: AttributeTemplate = template!(Word);
68+
69+
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
70+
if let Err(span) = args.no_args() {
71+
cx.expected_no_args(span);
72+
return None;
73+
}
74+
75+
Some(AttributeKind::RustcObjectLifetimeDefault)
76+
}
77+
}

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use crate::attributes::must_use::MustUseParser;
2929
use crate::attributes::repr::{AlignParser, ReprParser};
3030
use crate::attributes::rustc_internal::{
3131
RustcLayoutScalarValidRangeEnd, RustcLayoutScalarValidRangeStart,
32+
RustcObjectLifetimeDefaultParser,
3233
};
3334
use crate::attributes::semantics::MayDangleParser;
3435
use crate::attributes::stability::{
@@ -136,6 +137,7 @@ attribute_parsers!(
136137
Single<RustcForceInlineParser>,
137138
Single<RustcLayoutScalarValidRangeEnd>,
138139
Single<RustcLayoutScalarValidRangeStart>,
140+
Single<RustcObjectLifetimeDefaultParser>,
139141
Single<SkipDuringMethodDispatchParser>,
140142
Single<TrackCallerParser>,
141143
Single<TransparencyParser>,

compiler/rustc_attr_parsing/src/session_diagnostics.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -577,10 +577,7 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for AttributeParseError {
577577
diag.code(E0565);
578578
}
579579
AttributeParseErrorReason::ExpectedNameValue(None) => {
580-
diag.span_label(
581-
self.span,
582-
format!("expected this to be of the form `{name} = \"...\"`"),
583-
);
580+
// The suggestion we add below this match already contains enough information
584581
}
585582
AttributeParseErrorReason::ExpectedNameValue(Some(name)) => {
586583
diag.span_label(

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,6 +1168,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
11681168
_,
11691169
mir::Rvalue::Use(mir::Operand::Copy(place)),
11701170
)),
1171+
..
11711172
}) = self.body[location.block].statements.get(location.statement_index)
11721173
{
11731174
self.body.local_decls[place.local].source_info.span

compiler/rustc_hir/src/hir.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4400,27 +4400,6 @@ impl ItemKind<'_> {
44004400
_ => return None,
44014401
})
44024402
}
4403-
4404-
pub fn descr(&self) -> &'static str {
4405-
match self {
4406-
ItemKind::ExternCrate(..) => "extern crate",
4407-
ItemKind::Use(..) => "`use` import",
4408-
ItemKind::Static(..) => "static item",
4409-
ItemKind::Const(..) => "constant item",
4410-
ItemKind::Fn { .. } => "function",
4411-
ItemKind::Macro(..) => "macro",
4412-
ItemKind::Mod(..) => "module",
4413-
ItemKind::ForeignMod { .. } => "extern block",
4414-
ItemKind::GlobalAsm { .. } => "global asm item",
4415-
ItemKind::TyAlias(..) => "type alias",
4416-
ItemKind::Enum(..) => "enum",
4417-
ItemKind::Struct(..) => "struct",
4418-
ItemKind::Union(..) => "union",
4419-
ItemKind::Trait(..) => "trait",
4420-
ItemKind::TraitAlias(..) => "trait alias",
4421-
ItemKind::Impl(..) => "implementation",
4422-
}
4423-
}
44244403
}
44254404

44264405
/// A reference from an trait to one of its associated items. This

compiler/rustc_middle/src/mir/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,6 +1336,7 @@ impl BasicBlock {
13361336
///
13371337
/// See [`BasicBlock`] for documentation on what basic blocks are at a high level.
13381338
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
1339+
#[non_exhaustive]
13391340
pub struct BasicBlockData<'tcx> {
13401341
/// List of statements in this block.
13411342
pub statements: Vec<Statement<'tcx>>,

compiler/rustc_middle/src/mir/statement.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use crate::ty::CoroutineArgsExt;
1111

1212
/// A statement in a basic block, including information about its source code.
1313
#[derive(Clone, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
14+
#[non_exhaustive]
1415
pub struct Statement<'tcx> {
1516
pub source_info: SourceInfo,
1617
pub kind: StatementKind<'tcx>,

0 commit comments

Comments
 (0)