Skip to content

Commit ae7f582

Browse files
committed
Auto merge of #161875 - JonathanBrouwer:rollup-jDGOOBv, r=<try>
Rollup of 11 pull requests try-job: dist-various-1 try-job: test-various try-job: x86_64-gnu-aux try-job: x86_64-gnu-llvm-21-3 try-job: x86_64-msvc-1 try-job: aarch64-apple-1 try-job: aarch64-apple-2 try-job: x86_64-mingw-1 try-job: i686-msvc-1 try-job: i686-msvc-2
2 parents e457a7b + 37ba63a commit ae7f582

53 files changed

Lines changed: 1045 additions & 401 deletions

File tree

Some content is hidden

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

compiler/rustc_attr_ir/src/data_structures.rs

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -70,42 +70,6 @@ pub enum CguFields {
7070
ExpectedCguReuse { cfg: Symbol, module: Symbol, kind: CguKind },
7171
}
7272

73-
#[derive(Copy, Clone, PartialEq, Debug, PrintAttribute)]
74-
#[derive(StableHash, Encodable, Decodable)]
75-
pub enum DivergingFallbackBehavior {
76-
/// Always fallback to `()` (aka "always spontaneous decay")
77-
ToUnit,
78-
/// Always fallback to `!` (which should be equivalent to never falling back + not making
79-
/// never-to-any coercions unless necessary)
80-
ToNever,
81-
/// Don't fallback at all
82-
NoFallback,
83-
}
84-
85-
#[derive(Copy, Clone, PartialEq, Debug, PrintAttribute, Default)]
86-
#[derive(StableHash, Encodable, Decodable)]
87-
pub enum DivergingBlockBehavior {
88-
/// This is the current stable behavior:
89-
///
90-
/// ```rust
91-
/// {
92-
/// return;
93-
/// } // block has type = !, even though we are supposedly dropping it with `;`
94-
/// ```
95-
#[default]
96-
Never,
97-
98-
/// Alternative behavior:
99-
///
100-
/// ```ignore (very-unstable-new-attribute)
101-
/// #![rustc_never_type_options(diverging_block_default = "unit")]
102-
/// {
103-
/// return;
104-
/// } // block has type = (), since we are dropping `!` from `return` with `;`
105-
/// ```
106-
Unit,
107-
}
108-
10973
#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, StableHash, PrintAttribute)]
11074
pub enum InlineAttr {
11175
None,
@@ -1367,12 +1331,6 @@ pub enum AttributeKind {
13671331
/// Represents `#[rustc_never_returns_null_ptr]`
13681332
RustcNeverReturnsNullPtr,
13691333

1370-
/// Represents `#[rustc_never_type_options]`.
1371-
RustcNeverTypeOptions {
1372-
fallback: Option<DivergingFallbackBehavior>,
1373-
diverging_block_default: Option<DivergingBlockBehavior>,
1374-
},
1375-
13761334
/// Represents `#[rustc_no_implicit_autorefs]`
13771335
RustcNoImplicitAutorefs,
13781336

compiler/rustc_attr_ir/src/encode_cross_crate.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ impl AttributeKind {
165165
RustcMustImplementOneOf { .. } => No,
166166
RustcMustMatchExhaustively(..) => Yes,
167167
RustcNeverReturnsNullPtr => Yes,
168-
RustcNeverTypeOptions { .. } => No,
169168
RustcNoImplicitAutorefs => Yes,
170169
RustcNoImplicitBounds => No,
171170
RustcNoMirInline => Yes,

compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs

Lines changed: 2 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use rustc_ast::{LitIntType, LitKind, MetaItemLit};
44
use rustc_attr_ir::lang_items::LangItem;
55
use rustc_attr_ir::target::GenericParamKind;
66
use rustc_attr_ir::{
7-
BorrowckGraphvizFormatKind, CguFields, CguKind, DivergingBlockBehavior,
8-
DivergingFallbackBehavior, RustcCleanAttribute, RustcCleanQueries, RustcMirKind,
7+
BorrowckGraphvizFormatKind, CguFields, CguKind, RustcCleanAttribute, RustcCleanQueries,
8+
RustcMirKind,
99
};
1010
use rustc_data_structures::fx::FxHashMap;
1111
use rustc_feature::AttributeStability;
@@ -397,79 +397,6 @@ impl NoArgsAttributeParser for RustcCaptureAnalysisParser {
397397
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcCaptureAnalysis;
398398
}
399399

400-
pub(crate) struct RustcNeverTypeOptionsParser;
401-
402-
impl SingleAttributeParser for RustcNeverTypeOptionsParser {
403-
const PATH: &[Symbol] = &[sym::rustc_never_type_options];
404-
const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
405-
const TEMPLATE: AttributeTemplate = template!(List: &[
406-
r#"fallback = "unit", "never", "no""#,
407-
r#"diverging_block_default = "unit", "never""#,
408-
]);
409-
const STABILITY: AttributeStability = unstable!(
410-
rustc_attrs,
411-
"`rustc_never_type_options` is used to experiment with never type fallback and work on never type stabilization"
412-
);
413-
414-
fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option<AttributeKind> {
415-
let list = cx.expect_list(args, cx.attr_span)?;
416-
417-
let mut fallback = None::<Ident>;
418-
let mut diverging_block_default = None::<Ident>;
419-
420-
for arg in list.mixed() {
421-
let Some((ident, arg)) = cx.expect_name_value(arg, arg.span(), None) else {
422-
continue;
423-
};
424-
425-
let res = match ident.name {
426-
sym::fallback => &mut fallback,
427-
sym::diverging_block_default => &mut diverging_block_default,
428-
_ => {
429-
cx.adcx().expected_specific_argument(
430-
ident.span,
431-
&[sym::fallback, sym::diverging_block_default],
432-
);
433-
continue;
434-
}
435-
};
436-
437-
let field = cx.expect_string_literal(arg)?;
438-
439-
if res.is_some() {
440-
cx.adcx().duplicate_key(ident.span, ident.name);
441-
continue;
442-
}
443-
444-
*res = Some(Ident { name: field, span: arg.value_span });
445-
}
446-
447-
let fallback = match fallback {
448-
None => None,
449-
Some(Ident { name: sym::unit, .. }) => Some(DivergingFallbackBehavior::ToUnit),
450-
Some(Ident { name: sym::never, .. }) => Some(DivergingFallbackBehavior::ToNever),
451-
Some(Ident { name: sym::no, .. }) => Some(DivergingFallbackBehavior::NoFallback),
452-
Some(Ident { span, .. }) => {
453-
cx.adcx()
454-
.expected_specific_argument_strings(span, &[sym::unit, sym::never, sym::no]);
455-
return None;
456-
}
457-
};
458-
459-
let diverging_block_default = match diverging_block_default {
460-
None => None,
461-
Some(Ident { name: sym::unit, .. }) => Some(DivergingBlockBehavior::Unit),
462-
Some(Ident { name: sym::never, .. }) => Some(DivergingBlockBehavior::Never),
463-
Some(Ident { span, .. }) => {
464-
cx.adcx().expected_specific_argument_strings(span, &[sym::unit, sym::no]);
465-
return None;
466-
}
467-
};
468-
469-
Some(AttributeKind::RustcNeverTypeOptions { fallback, diverging_block_default })
470-
}
471-
}
472-
473400
pub(crate) struct RustcTrivialFieldReadsParser;
474401

475402
impl NoArgsAttributeParser for RustcTrivialFieldReadsParser {

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ attribute_parsers!(
246246
Single<RustcLintOptDenyFieldAccessParser>,
247247
Single<RustcMacroTransparencyParser>,
248248
Single<RustcMustImplementOneOfParser>,
249-
Single<RustcNeverTypeOptionsParser>,
250249
Single<RustcObjcClassParser>,
251250
Single<RustcObjcSelectorParser>,
252251
Single<RustcScalableVectorParser>,

compiler/rustc_codegen_llvm/src/consts.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -544,8 +544,9 @@ impl<'ll> CodegenCx<'ll, '_> {
544544
}
545545

546546
// Wasm statics with custom link sections get special treatment as they
547-
// go into custom sections of the wasm executable. The exception to this
548-
// is the `.init_array` section which are treated specially by the wasm linker.
547+
// also go into custom sections of the wasm executable. The exception to
548+
// this is the `.init_array` section for which we can't emit a custom
549+
// section as it contains relocations.
549550
if self.tcx.sess.target.is_like_wasm
550551
&& attrs
551552
.link_section
@@ -564,10 +565,9 @@ impl<'ll> CodegenCx<'ll, '_> {
564565
let data = [section, alloc];
565566
self.module_add_named_metadata_node(self.llmod(), c"wasm.custom_sections", &data);
566567
}
567-
} else {
568-
base::set_link_section(g, attrs);
569568
}
570569

570+
base::set_link_section(g, attrs);
571571
base::set_variable_sanitizer_attrs(g, attrs);
572572

573573
if attrs.flags.contains(CodegenFnAttrFlags::USED_COMPILER) {

compiler/rustc_hir_analysis/src/coherence/builtin.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ fn visit_implementation_of_unpin(checker: &Checker<'_>) -> Result<(), ErrorGuara
153153
}));
154154
}
155155
ty::Adt(_, _) => {}
156+
// `extern type`s have no fields, so they can't be structurally pinned.
157+
ty::Foreign(_) => {}
156158
_ => {
157159
return Err(tcx.dcx().span_delayed_bug(span, "impl of `Unpin` for a non-adt type"));
158160
}

compiler/rustc_hir_typeck/src/demand.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -711,9 +711,31 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
711711
expr: &hir::Expr<'_>,
712712
error: Option<TypeError<'tcx>>,
713713
) {
714-
match (self.tcx.parent_hir_node(expr.hir_id), error) {
714+
// Skip nested block to find the correct parent node to point at.
715+
let mut current_hir_id = expr.hir_id;
716+
let parent = self
717+
.tcx
718+
.hir_parent_iter(expr.hir_id)
719+
.find_map(|(parent_hir_id, parent)| match parent {
720+
hir::Node::Block(block)
721+
if block.expr.is_some_and(|expr| expr.hir_id == current_hir_id) =>
722+
{
723+
current_hir_id = parent_hir_id;
724+
None
725+
}
726+
hir::Node::Expr(hir::Expr { kind: hir::ExprKind::Block(block, _), .. })
727+
if block.hir_id == current_hir_id =>
728+
{
729+
current_hir_id = parent_hir_id;
730+
None
731+
}
732+
parent => Some(parent),
733+
})
734+
.expect("an expression must have a non-block ancestor");
735+
736+
match (parent, error) {
715737
(hir::Node::LetStmt(hir::LetStmt { ty: Some(ty), init: Some(init), .. }), _)
716-
if init.hir_id == expr.hir_id && !ty.span.source_equal(init.span) =>
738+
if init.hir_id == current_hir_id && !ty.span.source_equal(init.span) =>
717739
{
718740
// Point at `let` assignment type.
719741
err.span_label(ty.span, "expected due to this");

0 commit comments

Comments
 (0)