Skip to content

Commit 4781cdf

Browse files
authored
Merge branch 'rust-lang:main' into main
2 parents 5888bc1 + 7c2c3c0 commit 4781cdf

File tree

169 files changed

+8215
-1170
lines changed

Some content is hidden

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

169 files changed

+8215
-1170
lines changed

.mailmap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ Rui <[email protected]>
597597
Russell Johnston <[email protected]>
598598
Rustin-Liu <[email protected]>
599599
Rusty Blitzerr <[email protected]>
600-
RustyYato <krishna.sd.2012@gmail.com>
600+
RustyYato <rustyyato@gmail.com>
601601
Ruud van Asseldonk <[email protected]> Ruud van Asseldonk <[email protected]>
602602
Ryan Leung <[email protected]>
603603

bootstrap.example.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,11 @@
831831
# If an explicit setting is given, it will be used for all parts of the codebase.
832832
#rust.new-symbol-mangling = true|false (see comment)
833833

834+
# Size limit in bytes for move/copy annotations (-Zannotate-moves). Only types
835+
# at or above this size will be annotated. If not specified, uses the default
836+
# limit (65 bytes).
837+
#rust.annotate-moves-size-limit = 65
838+
834839
# Select LTO mode that will be used for compiling rustc. By default, thin local LTO
835840
# (LTO within a single crate) is used (like for any Rust crate). You can also select
836841
# "thin" or "fat" to apply Thin/Fat LTO to the `rustc_driver` dylib, or "off" to disable

compiler/rustc_attr_parsing/src/attributes/cfg.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use rustc_ast::token::Delimiter;
22
use rustc_ast::tokenstream::DelimSpan;
33
use rustc_ast::{AttrItem, Attribute, CRATE_NODE_ID, LitKind, NodeId, ast, token};
44
use rustc_errors::{Applicability, PResult};
5-
use rustc_feature::{AttributeTemplate, Features, template};
5+
use rustc_feature::{AttrSuggestionStyle, AttributeTemplate, Features, template};
66
use rustc_hir::attrs::CfgEntry;
77
use rustc_hir::{AttrPath, RustcVersion};
88
use rustc_parse::parser::{ForceCollect, Parser};
@@ -323,8 +323,8 @@ pub fn parse_cfg_attr(
323323
}) {
324324
Ok(r) => return Some(r),
325325
Err(e) => {
326-
let suggestions =
327-
CFG_ATTR_TEMPLATE.suggestions(Some(cfg_attr.style), sym::cfg_attr);
326+
let suggestions = CFG_ATTR_TEMPLATE
327+
.suggestions(AttrSuggestionStyle::Attribute(cfg_attr.style), sym::cfg_attr);
328328
e.with_span_suggestions(
329329
cfg_attr.span,
330330
"must be of the form",
@@ -355,7 +355,8 @@ pub fn parse_cfg_attr(
355355
path: AttrPath::from_ast(&cfg_attr.get_normal_item().path),
356356
description: ParsedDescription::Attribute,
357357
reason,
358-
suggestions: CFG_ATTR_TEMPLATE.suggestions(Some(cfg_attr.style), sym::cfg_attr),
358+
suggestions: CFG_ATTR_TEMPLATE
359+
.suggestions(AttrSuggestionStyle::Attribute(cfg_attr.style), sym::cfg_attr),
359360
});
360361
}
361362
}

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::sync::LazyLock;
66
use private::Sealed;
77
use rustc_ast::{AttrStyle, CRATE_NODE_ID, MetaItemLit, NodeId};
88
use rustc_errors::{Diag, Diagnostic, Level};
9-
use rustc_feature::AttributeTemplate;
9+
use rustc_feature::{AttrSuggestionStyle, AttributeTemplate};
1010
use rustc_hir::attrs::AttributeKind;
1111
use rustc_hir::lints::{AttributeLint, AttributeLintKind};
1212
use rustc_hir::{AttrPath, CRATE_HIR_ID, HirId};
@@ -637,9 +637,15 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
637637
}
638638

639639
pub(crate) fn suggestions(&self) -> Vec<String> {
640-
// If the outer and inner spans are equal, we are parsing an attribute from `cfg_attr`,
641-
// So don't display an attribute style in the suggestions
642-
let style = (self.attr_span != self.inner_span).then_some(self.attr_style);
640+
let style = match self.parsed_description {
641+
// If the outer and inner spans are equal, we are parsing an embedded attribute
642+
ParsedDescription::Attribute if self.attr_span == self.inner_span => {
643+
AttrSuggestionStyle::EmbeddedAttribute
644+
}
645+
ParsedDescription::Attribute => AttrSuggestionStyle::Attribute(self.attr_style),
646+
ParsedDescription::Macro => AttrSuggestionStyle::Macro,
647+
};
648+
643649
self.template.suggestions(style, &self.attr_path)
644650
}
645651
}

compiler/rustc_borrowck/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1559,7 +1559,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
15591559
self.consume_operand(location, (operand2, span), state);
15601560
}
15611561

1562-
Rvalue::NullaryOp(_op, _ty) => {
1562+
Rvalue::NullaryOp(_op) => {
15631563
// nullary ops take no dynamic input; no borrowck effect.
15641564
}
15651565

compiler/rustc_borrowck/src/polonius/legacy/loan_invalidations.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ impl<'a, 'tcx> LoanInvalidationsGenerator<'a, 'tcx> {
314314
self.consume_operand(location, operand2);
315315
}
316316

317-
Rvalue::NullaryOp(_op, _ty) => {}
317+
Rvalue::NullaryOp(_op) => {}
318318

319319
Rvalue::Aggregate(_, operands) => {
320320
for operand in operands {

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
10461046
}
10471047
}
10481048

1049-
&Rvalue::NullaryOp(NullOp::RuntimeChecks(_), _) => {}
1049+
&Rvalue::NullaryOp(NullOp::RuntimeChecks(_)) => {}
10501050

10511051
Rvalue::ShallowInitBox(_operand, ty) => {
10521052
let trait_ref =
@@ -1633,8 +1633,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
16331633
| Rvalue::BinaryOp(..)
16341634
| Rvalue::RawPtr(..)
16351635
| Rvalue::ThreadLocalRef(..)
1636-
| Rvalue::Discriminant(..)
1637-
| Rvalue::NullaryOp(NullOp::OffsetOf(..), _) => {}
1636+
| Rvalue::Discriminant(..) => {}
16381637
}
16391638
}
16401639

compiler/rustc_codegen_cranelift/src/base.rs

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -853,31 +853,14 @@ fn codegen_stmt<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, cur_block: Block, stmt:
853853
fx.bcx.ins().nop();
854854
}
855855
}
856-
Rvalue::NullaryOp(ref null_op, ty) => {
856+
Rvalue::NullaryOp(ref null_op) => {
857857
assert!(lval.layout().ty.is_sized(fx.tcx, fx.typing_env()));
858-
let layout = fx.layout_of(fx.monomorphize(ty));
859858
let val = match null_op {
860-
NullOp::OffsetOf(fields) => fx
861-
.tcx
862-
.offset_of_subfield(
863-
ty::TypingEnv::fully_monomorphized(),
864-
layout,
865-
fields.iter(),
866-
)
867-
.bytes(),
868-
NullOp::RuntimeChecks(kind) => {
869-
let val = kind.value(fx.tcx.sess);
870-
let val = CValue::by_val(
871-
fx.bcx.ins().iconst(types::I8, i64::from(val)),
872-
fx.layout_of(fx.tcx.types.bool),
873-
);
874-
lval.write_cvalue(fx, val);
875-
return;
876-
}
859+
NullOp::RuntimeChecks(kind) => kind.value(fx.tcx.sess),
877860
};
878861
let val = CValue::by_val(
879-
fx.bcx.ins().iconst(fx.pointer_type, i64::try_from(val).unwrap()),
880-
fx.layout_of(fx.tcx.types.usize),
862+
fx.bcx.ins().iconst(types::I8, i64::from(val)),
863+
fx.layout_of(fx.tcx.types.bool),
881864
);
882865
lval.write_cvalue(fx, val);
883866
}

compiler/rustc_codegen_ssa/src/mir/rvalue.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -613,17 +613,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
613613
}
614614
}
615615

616-
mir::Rvalue::NullaryOp(ref null_op, ty) => {
617-
let ty = self.monomorphize(ty);
618-
let layout = bx.cx().layout_of(ty);
616+
mir::Rvalue::NullaryOp(ref null_op) => {
619617
let val = match null_op {
620-
mir::NullOp::OffsetOf(fields) => {
621-
let val = bx
622-
.tcx()
623-
.offset_of_subfield(bx.typing_env(), layout, fields.iter())
624-
.bytes();
625-
bx.cx().const_usize(val)
626-
}
627618
mir::NullOp::RuntimeChecks(kind) => {
628619
let val = kind.value(bx.tcx().sess);
629620
bx.cx().const_bool(val)

compiler/rustc_const_eval/src/check_consts/check.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
645645

646646
Rvalue::Cast(_, _, _) => {}
647647

648-
Rvalue::NullaryOp(NullOp::OffsetOf(_) | NullOp::RuntimeChecks(_), _) => {}
648+
Rvalue::NullaryOp(NullOp::RuntimeChecks(_)) => {}
649649
Rvalue::ShallowInitBox(_, _) => {}
650650

651651
Rvalue::UnaryOp(op, operand) => {
@@ -886,6 +886,15 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
886886
feature,
887887
..
888888
}) => {
889+
// We only honor `span.allows_unstable` aka `#[allow_internal_unstable]`
890+
// if the callee is safe to expose, to avoid bypassing recursive stability.
891+
// This is not ideal since it means the user sees an error, not the macro
892+
// author, but that's also the case if one forgets to set
893+
// `#[allow_internal_unstable]` in the first place.
894+
if self.span.allows_unstable(feature) && is_const_stable {
895+
return;
896+
}
897+
889898
self.check_op(ops::IntrinsicUnstable {
890899
name: intrinsic.name,
891900
feature,

0 commit comments

Comments
 (0)