Skip to content

Commit 3d7e881

Browse files
committed
Auto merge of #123484 - jhpratt:rollup-usz4e64, r=jhpratt
Rollup of 9 pull requests Successful merges: - #123206 (Require Pointee::Metadata to be Freeze) - #123363 (change `NormalizesTo` to fully structurally normalize) - #123407 (Default to light theme if JS is enabled but not working) - #123417 (Add Description for cargo in rustdoc documentation) - #123437 (Manually run `clang-format` on `CoverageMappingWrapper.cpp`) - #123454 (hir: Use `ItemLocalId::ZERO` in a couple more places) - #123464 (Cleanup: Rename `HAS_PROJECTIONS` to `HAS_ALIASES` etc.) - #123477 (do not ICE in `fn forced_ambiguity` if we get an error) - #123478 (CFI: Add test for `call_once` addr taken) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 9cbaa01 + e8b0c30 commit 3d7e881

File tree

41 files changed

+286
-374
lines changed

Some content is hidden

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

41 files changed

+286
-374
lines changed

compiler/rustc_ast_lowering/src/index.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct NodeCollector<'a, 'hir> {
1919
parenting: LocalDefIdMap<ItemLocalId>,
2020

2121
/// The parent of this node
22-
parent_node: hir::ItemLocalId,
22+
parent_node: ItemLocalId,
2323

2424
owner: OwnerId,
2525
}
@@ -31,17 +31,16 @@ pub(super) fn index_hir<'hir>(
3131
bodies: &SortedMap<ItemLocalId, &'hir Body<'hir>>,
3232
num_nodes: usize,
3333
) -> (IndexVec<ItemLocalId, ParentedNode<'hir>>, LocalDefIdMap<ItemLocalId>) {
34-
let zero_id = ItemLocalId::ZERO;
35-
let err_node = ParentedNode { parent: zero_id, node: Node::Err(item.span()) };
34+
let err_node = ParentedNode { parent: ItemLocalId::ZERO, node: Node::Err(item.span()) };
3635
let mut nodes = IndexVec::from_elem_n(err_node, num_nodes);
3736
// This node's parent should never be accessed: the owner's parent is computed by the
3837
// hir_owner_parent query. Make it invalid (= ItemLocalId::MAX) to force an ICE whenever it is
3938
// used.
40-
nodes[zero_id] = ParentedNode { parent: ItemLocalId::INVALID, node: item.into() };
39+
nodes[ItemLocalId::ZERO] = ParentedNode { parent: ItemLocalId::INVALID, node: item.into() };
4140
let mut collector = NodeCollector {
4241
tcx,
4342
owner: item.def_id(),
44-
parent_node: zero_id,
43+
parent_node: ItemLocalId::ZERO,
4544
nodes,
4645
bodies,
4746
parenting: Default::default(),
@@ -112,7 +111,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
112111
}
113112

114113
fn insert_nested(&mut self, item: LocalDefId) {
115-
if self.parent_node.as_u32() != 0 {
114+
if self.parent_node != ItemLocalId::ZERO {
116115
self.parenting.insert(item, self.parent_node);
117116
}
118117
}

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
461461
where
462462
T: TypeVisitable<TyCtxt<'tcx>>,
463463
{
464-
t.has_free_regions() || t.has_projections() || t.has_infer_types()
464+
t.has_free_regions() || t.has_aliases() || t.has_infer_types()
465465
}
466466

467467
pub fn node_ty(&self, id: hir::HirId) -> Ty<'tcx> {

compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp

+20-28
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#include "LLVMWrapper.h"
2+
#include "llvm/ADT/ArrayRef.h"
23
#include "llvm/ProfileData/Coverage/CoverageMapping.h"
34
#include "llvm/ProfileData/Coverage/CoverageMappingWriter.h"
45
#include "llvm/ProfileData/InstrProf.h"
5-
#include "llvm/ADT/ArrayRef.h"
66

77
#include <iostream>
88

@@ -103,35 +103,30 @@ fromRust(LLVMRustCounterExprKind Kind) {
103103
}
104104

105105
extern "C" void LLVMRustCoverageWriteFilenamesSectionToBuffer(
106-
const char *const Filenames[],
107-
size_t FilenamesLen,
108-
const size_t *const Lengths,
109-
size_t LengthsLen,
106+
const char *const Filenames[], size_t FilenamesLen, // String start pointers
107+
const size_t *const Lengths, size_t LengthsLen, // Corresponding lengths
110108
RustStringRef BufferOut) {
111109
if (FilenamesLen != LengthsLen) {
112110
report_fatal_error(
113111
"Mismatched lengths in LLVMRustCoverageWriteFilenamesSectionToBuffer");
114112
}
115113

116-
SmallVector<std::string,32> FilenameRefs;
114+
SmallVector<std::string, 32> FilenameRefs;
117115
FilenameRefs.reserve(FilenamesLen);
118116
for (size_t i = 0; i < FilenamesLen; i++) {
119117
FilenameRefs.emplace_back(Filenames[i], Lengths[i]);
120118
}
121-
auto FilenamesWriter =
122-
coverage::CoverageFilenamesSectionWriter(ArrayRef<std::string>(FilenameRefs));
119+
auto FilenamesWriter = coverage::CoverageFilenamesSectionWriter(
120+
ArrayRef<std::string>(FilenameRefs));
123121
auto OS = RawRustStringOstream(BufferOut);
124122
FilenamesWriter.write(OS);
125123
}
126124

127125
extern "C" void LLVMRustCoverageWriteMappingToBuffer(
128-
const unsigned *VirtualFileMappingIDs,
129-
unsigned NumVirtualFileMappingIDs,
130-
const LLVMRustCounterExpression *RustExpressions,
131-
unsigned NumExpressions,
126+
const unsigned *VirtualFileMappingIDs, unsigned NumVirtualFileMappingIDs,
127+
const LLVMRustCounterExpression *RustExpressions, unsigned NumExpressions,
132128
const LLVMRustCounterMappingRegion *RustMappingRegions,
133-
unsigned NumMappingRegions,
134-
RustStringRef BufferOut) {
129+
unsigned NumMappingRegions, RustStringRef BufferOut) {
135130
// Convert from FFI representation to LLVM representation.
136131
SmallVector<coverage::CounterMappingRegion, 0> MappingRegions;
137132
MappingRegions.reserve(NumMappingRegions);
@@ -142,7 +137,7 @@ extern "C" void LLVMRustCoverageWriteMappingToBuffer(
142137
#if LLVM_VERSION_GE(18, 0) && LLVM_VERSION_LT(19, 0)
143138
coverage::CounterMappingRegion::MCDCParameters{},
144139
#endif
145-
Region.FileID, Region.ExpandedFileID,
140+
Region.FileID, Region.ExpandedFileID, // File IDs, then region info.
146141
Region.LineStart, Region.ColumnStart, Region.LineEnd, Region.ColumnEnd,
147142
fromRust(Region.Kind));
148143
}
@@ -158,29 +153,25 @@ extern "C" void LLVMRustCoverageWriteMappingToBuffer(
158153

159154
auto CoverageMappingWriter = coverage::CoverageMappingWriter(
160155
ArrayRef<unsigned>(VirtualFileMappingIDs, NumVirtualFileMappingIDs),
161-
Expressions,
162-
MappingRegions);
156+
Expressions, MappingRegions);
163157
auto OS = RawRustStringOstream(BufferOut);
164158
CoverageMappingWriter.write(OS);
165159
}
166160

167-
extern "C" LLVMValueRef LLVMRustCoverageCreatePGOFuncNameVar(
168-
LLVMValueRef F,
169-
const char *FuncName,
170-
size_t FuncNameLen) {
161+
extern "C" LLVMValueRef
162+
LLVMRustCoverageCreatePGOFuncNameVar(LLVMValueRef F, const char *FuncName,
163+
size_t FuncNameLen) {
171164
auto FuncNameRef = StringRef(FuncName, FuncNameLen);
172165
return wrap(createPGOFuncNameVar(*cast<Function>(unwrap(F)), FuncNameRef));
173166
}
174167

175-
extern "C" uint64_t LLVMRustCoverageHashByteArray(
176-
const char *Bytes,
177-
size_t NumBytes) {
168+
extern "C" uint64_t LLVMRustCoverageHashByteArray(const char *Bytes,
169+
size_t NumBytes) {
178170
auto StrRef = StringRef(Bytes, NumBytes);
179171
return IndexedInstrProf::ComputeHash(StrRef);
180172
}
181173

182-
static void WriteSectionNameToString(LLVMModuleRef M,
183-
InstrProfSectKind SK,
174+
static void WriteSectionNameToString(LLVMModuleRef M, InstrProfSectKind SK,
184175
RustStringRef Str) {
185176
auto TargetTriple = Triple(unwrap(M)->getTargetTriple());
186177
auto name = getInstrProfSectionName(SK, TargetTriple.getObjectFormat());
@@ -193,8 +184,9 @@ extern "C" void LLVMRustCoverageWriteMapSectionNameToString(LLVMModuleRef M,
193184
WriteSectionNameToString(M, IPSK_covmap, Str);
194185
}
195186

196-
extern "C" void LLVMRustCoverageWriteFuncSectionNameToString(LLVMModuleRef M,
197-
RustStringRef Str) {
187+
extern "C" void
188+
LLVMRustCoverageWriteFuncSectionNameToString(LLVMModuleRef M,
189+
RustStringRef Str) {
198190
WriteSectionNameToString(M, IPSK_covfun, Str);
199191
}
200192

compiler/rustc_middle/src/hir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ pub fn provide(providers: &mut Providers) {
179179
.parenting
180180
.get(&owner_id.def_id)
181181
.copied()
182-
.unwrap_or(ItemLocalId::from_u32(0)),
182+
.unwrap_or(ItemLocalId::ZERO),
183183
}
184184
})
185185
};

compiler/rustc_middle/src/traits/solve/inspect.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,6 @@ pub enum ProbeStep<'tcx> {
121121
/// used whenever there are multiple candidates to prove the
122122
/// current goalby .
123123
NestedProbe(Probe<'tcx>),
124-
CommitIfOkStart,
125-
CommitIfOkSuccess,
126124
}
127125

128126
/// What kind of probe we're in. In case the probe represents a candidate, or
@@ -132,6 +130,8 @@ pub enum ProbeStep<'tcx> {
132130
pub enum ProbeKind<'tcx> {
133131
/// The root inference context while proving a goal.
134132
Root { result: QueryResult<'tcx> },
133+
/// Trying to normalize an alias by at least one stpe in `NormalizesTo`.
134+
TryNormalizeNonRigid { result: QueryResult<'tcx> },
135135
/// Probe entered when normalizing the self ty during candidate assembly
136136
NormalizedSelfTyAssembly,
137137
/// Some candidate to prove the current goal.
@@ -143,9 +143,6 @@ pub enum ProbeKind<'tcx> {
143143
/// Used in the probe that wraps normalizing the non-self type for the unsize
144144
/// trait, which is also structurally matched on.
145145
UnsizeAssembly,
146-
/// A call to `EvalCtxt::commit_if_ok` which failed, causing the work
147-
/// to be discarded.
148-
CommitIfOk,
149146
/// During upcasting from some source object to target object type, used to
150147
/// do a probe to find out what projection type(s) may be used to prove that
151148
/// the source type upholds all of the target type's object bounds.

compiler/rustc_middle/src/traits/solve/inspect/format.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ impl<'a, 'b> ProofTreeFormatter<'a, 'b> {
100100
ProbeKind::Root { result } => {
101101
write!(self.f, "ROOT RESULT: {result:?}")
102102
}
103+
ProbeKind::TryNormalizeNonRigid { result } => {
104+
write!(self.f, "TRY NORMALIZE NON-RIGID: {result:?}")
105+
}
103106
ProbeKind::NormalizedSelfTyAssembly => {
104107
write!(self.f, "NORMALIZING SELF TY FOR ASSEMBLY:")
105108
}
@@ -109,9 +112,6 @@ impl<'a, 'b> ProofTreeFormatter<'a, 'b> {
109112
ProbeKind::UpcastProjectionCompatibility => {
110113
write!(self.f, "PROBING FOR PROJECTION COMPATIBILITY FOR UPCASTING:")
111114
}
112-
ProbeKind::CommitIfOk => {
113-
write!(self.f, "COMMIT_IF_OK:")
114-
}
115115
ProbeKind::MiscCandidate { name, result } => {
116116
write!(self.f, "CANDIDATE {name}: {result:?}")
117117
}
@@ -132,8 +132,6 @@ impl<'a, 'b> ProofTreeFormatter<'a, 'b> {
132132
}
133133
ProbeStep::EvaluateGoals(eval) => this.format_added_goals_evaluation(eval)?,
134134
ProbeStep::NestedProbe(probe) => this.format_probe(probe)?,
135-
ProbeStep::CommitIfOkStart => writeln!(this.f, "COMMIT_IF_OK START")?,
136-
ProbeStep::CommitIfOkSuccess => writeln!(this.f, "COMMIT_IF_OK SUCCESS")?,
137135
}
138136
}
139137
Ok(())

compiler/rustc_middle/src/ty/normalize_erasing_regions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl<'tcx> TyCtxt<'tcx> {
4949
let value = self.erase_regions(value);
5050
debug!(?value);
5151

52-
if !value.has_projections() {
52+
if !value.has_aliases() {
5353
value
5454
} else {
5555
value.fold_with(&mut NormalizeAfterErasingRegionsFolder { tcx: self, param_env })
@@ -81,7 +81,7 @@ impl<'tcx> TyCtxt<'tcx> {
8181
let value = self.erase_regions(value);
8282
debug!(?value);
8383

84-
if !value.has_projections() {
84+
if !value.has_aliases() {
8585
Ok(value)
8686
} else {
8787
let mut folder = TryNormalizeAfterErasingRegionsFolder::new(self, param_env);

compiler/rustc_mir_transform/src/inline.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ fn try_instance_mir<'tcx>(
10771077
let fields = def.all_fields();
10781078
for field in fields {
10791079
let field_ty = field.ty(tcx, args);
1080-
if field_ty.has_param() && field_ty.has_projections() {
1080+
if field_ty.has_param() && field_ty.has_aliases() {
10811081
return Err("cannot build drop shim for polymorphic type");
10821082
}
10831083
}

0 commit comments

Comments
 (0)