Skip to content

Commit e27f16a

Browse files
committed
Auto merge of #143958 - samueltardieu:rollup-lh1s143, r=samueltardieu
Rollup of 13 pull requests Successful merges: - #142301 (tests: Fix duplicated-path-in-error fail with musl) - #143630 (Drop `./x suggest`) - #143736 (Give all bytes of TypeId provenance) - #143752 (Don't panic if WASI_SDK_PATH not set when detecting compiler) - #143837 (Adjust `run_make_support::symbols` helpers) - #143878 (Port `#[pointee]` to the new attribute parsing infrastructure) - #143905 (Recover and suggest to use `;` to construct array type) - #143907 (core: make `str::split_at_unchecked()` inline) - #143910 (Add experimental `backtrace-trace-only` std feature) - #143927 (Preserve constness in trait objects up to hir ty lowering) - #143935 (rustc_type_ir/walk: move docstring to `TypeWalker` itself) - #143938 (Update books) - #143941 (update `cfg_select!` documentation) Failed merges: - #143926 (Remove deprecated fields in bootstrap) r? `@ghost` `@rustbot` modify labels: rollup
2 parents a9fb610 + 010e3ef commit e27f16a

File tree

87 files changed

+752
-1282
lines changed

Some content is hidden

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

87 files changed

+752
-1282
lines changed

Cargo.lock

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5069,14 +5069,6 @@ dependencies = [
50695069
"syn 1.0.109",
50705070
]
50715071

5072-
[[package]]
5073-
name = "suggest-tests"
5074-
version = "0.1.0"
5075-
dependencies = [
5076-
"build_helper",
5077-
"glob",
5078-
]
5079-
50805072
[[package]]
50815073
name = "syn"
50825074
version = "1.0.109"

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ members = [
3939
"src/tools/rustdoc-gui-test",
4040
"src/tools/rustdoc-themes",
4141
"src/tools/rustfmt",
42-
"src/tools/suggest-tests",
4342
"src/tools/test-float-parse",
4443
"src/tools/tidy",
4544
"src/tools/tier-check",

compiler/rustc_attr_data_structures/src/attributes.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,9 @@ pub enum AttributeKind {
374374
/// Represents `#[path]`
375375
Path(Symbol, Span),
376376

377+
/// Represents `#[pointee]`
378+
Pointee(Span),
379+
377380
/// Represents `#[rustc_pub_transparent]` (used by the `repr_transparent_external_private_fields` lint).
378381
PubTransparent(Span),
379382

compiler/rustc_attr_data_structures/src/encode_cross_crate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ impl AttributeKind {
5757
ParenSugar(..) => No,
5858
PassByValue(..) => Yes,
5959
Path(..) => No,
60+
Pointee(..) => No,
6061
PubTransparent(..) => Yes,
6162
Repr { .. } => No,
6263
RustcLayoutScalarValidRangeEnd(..) => Yes,

compiler/rustc_attr_parsing/src/attributes/traits.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,10 @@ impl<S: Stage> NoArgsAttributeParser<S> for FundamentalParser {
145145
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
146146
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::Fundamental;
147147
}
148+
149+
pub(crate) struct PointeeParser;
150+
impl<S: Stage> NoArgsAttributeParser<S> for PointeeParser {
151+
const PATH: &[Symbol] = &[sym::pointee];
152+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
153+
const CREATE: fn(Span) -> AttributeKind = AttributeKind::Pointee;
154+
}

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ use crate::attributes::test_attrs::IgnoreParser;
4747
use crate::attributes::traits::{
4848
AllowIncoherentImplParser, CoherenceIsCoreParser, CoinductiveParser, ConstTraitParser,
4949
DenyExplicitImplParser, DoNotImplementViaObjectParser, FundamentalParser, MarkerParser,
50-
ParenSugarParser, SkipDuringMethodDispatchParser, SpecializationTraitParser, TypeConstParser,
51-
UnsafeSpecializationMarkerParser,
50+
ParenSugarParser, PointeeParser, SkipDuringMethodDispatchParser, SpecializationTraitParser,
51+
TypeConstParser, UnsafeSpecializationMarkerParser,
5252
};
5353
use crate::attributes::transparency::TransparencyParser;
5454
use crate::attributes::{AttributeParser as _, Combine, Single, WithoutArgs};
@@ -177,6 +177,7 @@ attribute_parsers!(
177177
Single<WithoutArgs<OmitGdbPrettyPrinterSectionParser>>,
178178
Single<WithoutArgs<ParenSugarParser>>,
179179
Single<WithoutArgs<PassByValueParser>>,
180+
Single<WithoutArgs<PointeeParser>>,
180181
Single<WithoutArgs<PubTransparentParser>>,
181182
Single<WithoutArgs<SpecializationTraitParser>>,
182183
Single<WithoutArgs<StdInternalSymbolParser>>,

compiler/rustc_builtin_macros/messages.ftl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ builtin_macros_cfg_accessible_literal_path = `cfg_accessible` path cannot be a l
8181
builtin_macros_cfg_accessible_multiple_paths = multiple `cfg_accessible` paths are specified
8282
builtin_macros_cfg_accessible_unspecified_path = `cfg_accessible` path is not specified
8383
84-
builtin_macros_cfg_select_no_matches = none of the rules in this `cfg_select` evaluated to true
84+
builtin_macros_cfg_select_no_matches = none of the predicates in this `cfg_select` evaluated to true
8585
86-
builtin_macros_cfg_select_unreachable = unreachable rule
86+
builtin_macros_cfg_select_unreachable = unreachable predicate
8787
.label = always matches
88-
.label2 = this rules is never reached
88+
.label2 = this predicate is never reached
8989
9090
builtin_macros_coerce_pointee_requires_maybe_sized = `derive(CoercePointee)` requires `{$name}` to be marked `?Sized`
9191

compiler/rustc_builtin_macros/src/cfg_select.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
use rustc_ast::tokenstream::TokenStream;
22
use rustc_attr_parsing as attr;
33
use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacroExpanderResult};
4-
use rustc_parse::parser::cfg_select::{CfgSelectBranches, CfgSelectRule, parse_cfg_select};
4+
use rustc_parse::parser::cfg_select::{CfgSelectBranches, CfgSelectPredicate, parse_cfg_select};
55
use rustc_span::{Ident, Span, sym};
66

77
use crate::errors::{CfgSelectNoMatches, CfgSelectUnreachable};
88

9-
/// Selects the first arm whose rule evaluates to true.
9+
/// Selects the first arm whose predicate evaluates to true.
1010
fn select_arm(ecx: &ExtCtxt<'_>, branches: CfgSelectBranches) -> Option<(TokenStream, Span)> {
1111
for (cfg, tt, arm_span) in branches.reachable {
1212
if attr::cfg_matches(
@@ -30,11 +30,11 @@ pub(super) fn expand_cfg_select<'cx>(
3030
ExpandResult::Ready(match parse_cfg_select(&mut ecx.new_parser_from_tts(tts)) {
3131
Ok(branches) => {
3232
if let Some((underscore, _, _)) = branches.wildcard {
33-
// Warn for every unreachable rule. We store the fully parsed branch for rustfmt.
34-
for (rule, _, _) in &branches.unreachable {
35-
let span = match rule {
36-
CfgSelectRule::Wildcard(underscore) => underscore.span,
37-
CfgSelectRule::Cfg(cfg) => cfg.span(),
33+
// Warn for every unreachable predicate. We store the fully parsed branch for rustfmt.
34+
for (predicate, _, _) in &branches.unreachable {
35+
let span = match predicate {
36+
CfgSelectPredicate::Wildcard(underscore) => underscore.span,
37+
CfgSelectPredicate::Cfg(cfg) => cfg.span(),
3838
};
3939
let err = CfgSelectUnreachable { span, wildcard_span: underscore.span };
4040
ecx.dcx().emit_warn(err);
@@ -50,7 +50,7 @@ pub(super) fn expand_cfg_select<'cx>(
5050
Ident::with_dummy_span(sym::cfg_select),
5151
);
5252
} else {
53-
// Emit a compiler error when none of the rules matched.
53+
// Emit a compiler error when none of the predicates matched.
5454
let guar = ecx.dcx().emit_err(CfgSelectNoMatches { span: sp });
5555
DummyResult::any(sp, guar)
5656
}

compiler/rustc_const_eval/src/interpret/intrinsics.rs

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,21 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
4444
)?;
4545
self.copy_op_allow_transmute(&op, dest)?;
4646

47-
// Give the first pointer-size bytes provenance that knows about the type id.
47+
// Give the each pointer-sized chunk provenance that knows about the type id.
4848
// Here we rely on `TypeId` being a newtype around an array of pointers, so we
49-
// first project to its only field and then the first array element.
49+
// first project to its only field and then the array elements.
5050
let alloc_id = tcx.reserve_and_set_type_id_alloc(ty);
5151
let first = self.project_field(dest, FieldIdx::ZERO)?;
52-
let first = self.project_index(&first, 0)?;
53-
let offset = self.read_scalar(&first)?.to_target_usize(&tcx)?;
54-
let ptr = Pointer::new(alloc_id.into(), Size::from_bytes(offset));
55-
let ptr = self.global_root_pointer(ptr)?;
56-
let val = Scalar::from_pointer(ptr, &tcx);
57-
self.write_scalar(val, &first)
52+
let mut elem_iter = self.project_array_fields(&first)?;
53+
while let Some((_, elem)) = elem_iter.next(self)? {
54+
// Decorate this part of the hash with provenance; leave the integer part unchanged.
55+
let hash_fragment = self.read_scalar(&elem)?.to_target_usize(&tcx)?;
56+
let ptr = Pointer::new(alloc_id.into(), Size::from_bytes(hash_fragment));
57+
let ptr = self.global_root_pointer(ptr)?;
58+
let val = Scalar::from_pointer(ptr, &tcx);
59+
self.write_scalar(val, &elem)?;
60+
}
61+
interp_ok(())
5862
}
5963

6064
/// Returns `true` if emulation happened.
@@ -101,34 +105,36 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
101105
let mut a_fields = self.project_array_fields(&a_fields)?;
102106
let mut b_fields = self.project_array_fields(&b_fields)?;
103107

104-
let (_idx, a) = a_fields
105-
.next(self)?
106-
.expect("we know the layout of TypeId has at least 2 array elements");
107-
let a = self.deref_pointer(&a)?;
108-
let (a, offset_a) = self.get_ptr_type_id(a.ptr())?;
109-
110-
let (_idx, b) = b_fields
111-
.next(self)?
112-
.expect("we know the layout of TypeId has at least 2 array elements");
113-
let b = self.deref_pointer(&b)?;
114-
let (b, offset_b) = self.get_ptr_type_id(b.ptr())?;
108+
let mut provenance_a = None;
109+
let mut provenance_b = None;
110+
let mut provenance_matches = true;
115111

116-
let provenance_matches = a == b;
112+
while let Some((i, a)) = a_fields.next(self)? {
113+
let (_, b) = b_fields.next(self)?.unwrap();
117114

118-
let mut eq_id = offset_a == offset_b;
115+
let a = self.deref_pointer(&a)?;
116+
let (a, offset_a) = self.get_ptr_type_id(a.ptr())?;
119117

120-
while let Some((_, a)) = a_fields.next(self)? {
121-
let (_, b) = b_fields.next(self)?.unwrap();
118+
let b = self.deref_pointer(&b)?;
119+
let (b, offset_b) = self.get_ptr_type_id(b.ptr())?;
122120

123-
let a = self.read_target_usize(&a)?;
124-
let b = self.read_target_usize(&b)?;
125-
eq_id &= a == b;
126-
}
121+
if *provenance_a.get_or_insert(a) != a {
122+
throw_ub_format!(
123+
"type_id_eq: the first TypeId argument is invalid, the provenance of chunk {i} does not match the first chunk's"
124+
)
125+
}
126+
if *provenance_b.get_or_insert(b) != b {
127+
throw_ub_format!(
128+
"type_id_eq: the second TypeId argument is invalid, the provenance of chunk {i} does not match the first chunk's"
129+
)
130+
}
131+
provenance_matches &= a == b;
127132

128-
if !eq_id && provenance_matches {
129-
throw_ub_format!(
130-
"type_id_eq: one of the TypeId arguments is invalid, the hash does not match the type it represents"
131-
)
133+
if offset_a != offset_b && provenance_matches {
134+
throw_ub_format!(
135+
"type_id_eq: one of the TypeId arguments is invalid, chunk {i} of the hash does not match the type it represents"
136+
)
137+
}
132138
}
133139

134140
self.write_scalar(Scalar::from_bool(provenance_matches), dest)?;

compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
4949
} = self.lower_poly_trait_ref(
5050
&trait_bound.trait_ref,
5151
trait_bound.span,
52-
hir::BoundConstness::Never,
52+
trait_bound.modifiers.constness,
5353
hir::BoundPolarity::Positive,
5454
dummy_self,
5555
&mut user_written_bounds,

0 commit comments

Comments
 (0)