Skip to content

Commit 344f790

Browse files
committed
Auto merge of rust-lang#161906 - JonathanBrouwer:rollup-obMe707, r=JonathanBrouwer
Rollup of 21 pull requests Successful merges: - rust-lang#150075 (Implement clamp_to) - rust-lang#159103 (fix(reborrow): recursive implementation) - rust-lang#160562 (add target feature ABI checks for SPARC) - rust-lang#160848 (std: avoid aliasing violations when wrapping opaque C types) - rust-lang#161421 (Include startup crt objects on WASI for more outputs) - rust-lang#161805 (Prefer ambiguous candidates when deduplicating traits in scope, so `ambiguous_glob_imported_traits` doesn't depend on import order) - rust-lang#161862 (Put data segment in specified section with link_section on wasm) - rust-lang#161866 (delegation: add tests fixating behavior of delegating to default trait implementations) - rust-lang#157218 (Track items behind `cfg_select` in the same way we do for `cfg`) - rust-lang#161456 (reduce perf impact of scalar size checks) - rust-lang#161528 (Add regression test to ensure optimal compilation) - rust-lang#161666 (Print vendor instructions in `x vendor`) - rust-lang#161730 (Improve type mismatch annotation for lets with block-wrapped initializers) - rust-lang#161828 (Never type after-stabilization cleanup) - rust-lang#161859 (Do not optimize MIR for comptime ConstFns) - rust-lang#161860 (atomicptr.rs test: remove unused import) - rust-lang#161870 (bind to [::1] instead of 127.0.0.1 in documentation examples for v6 UDP methods) - rust-lang#161876 (rustdoc: Correctly handle when a macro generates multiple items in `--generate-macro-expansion`) - rust-lang#161889 (Add link to ownership section in ptr::read docs) - rust-lang#161890 (rustdoc: some clarifying comments) - rust-lang#161891 (Mark `extern_item_impls` feature as incomplete) Failed merges: - rust-lang#161702 (Use `drop_guard` in some places in {core,alloc,std})
2 parents c42ac5f + 17366b1 commit 344f790

204 files changed

Lines changed: 2494 additions & 710 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/cfg_select.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,25 +47,28 @@ pub struct CfgSelectBranches {
4747
impl CfgSelectBranches {
4848
/// Removes the top-most branch for which `predicate` returns `true`,
4949
/// or the wildcard if none of the reachable branches satisfied the predicate.
50-
pub fn pop_first_match<F>(&mut self, predicate: F) -> Option<(TokenStream, Span)>
50+
pub fn pop_first_match<F>(&mut self, predicate: F) -> Option<(CfgEntry, TokenStream, Span)>
5151
where
5252
F: Fn(&CfgEntry) -> bool,
5353
{
5454
for (index, (cfg, _, _)) in self.reachable.iter().enumerate() {
5555
if predicate(cfg) {
56-
let matched = self.reachable.remove(index);
57-
return Some((matched.1, matched.2));
56+
return Some(self.reachable.remove(index));
5857
}
5958
}
6059

61-
self.wildcard.take().map(|(_, tts, span)| (tts, span))
60+
self.wildcard.take().map(|(_, tts, span)| (CfgEntry::Bool(true, span), tts, span))
6261
}
6362

6463
/// Consume this value and iterate over all the `TokenStream`s that it stores.
65-
pub fn into_iter_tts(self) -> impl Iterator<Item = (TokenStream, Span)> {
66-
let it1 = self.reachable.into_iter().map(|(_, tts, span)| (tts, span));
67-
let it2 = self.wildcard.into_iter().map(|(_, tts, span)| (tts, span));
68-
let it3 = self.unreachable.into_iter().map(|(_, tts, span)| (tts, span));
64+
pub fn into_iter_tts(self) -> impl Iterator<Item = (CfgEntry, TokenStream, Span)> {
65+
let it1 = self.reachable.into_iter();
66+
let it2 =
67+
self.wildcard.into_iter().map(|(_, tts, span)| (CfgEntry::Bool(true, span), tts, span));
68+
let it3 = self
69+
.unreachable
70+
.into_iter()
71+
.map(|(_, tts, span)| (CfgEntry::Bool(false, span), tts, span));
6972

7073
it1.chain(it2).chain(it3)
7174
}

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>,

0 commit comments

Comments
 (0)