Skip to content

Commit 91ecdb4

Browse files
committed
After-rebase fixes
1 parent 55e5d46 commit 91ecdb4

6 files changed

Lines changed: 37 additions & 31 deletions

File tree

compiler/rustc_hir/src/definitions.rs

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub struct Definitions {
5353
// We do only store the local hash, as all the definitions are from the current crate.
5454
def_path_hashes: IndexVec<LocalDefId, Hash64>,
5555
def_path_hash_to_index: DefPathHashMap,
56-
allow_overwrite: IndexSet<DefIndex>,
56+
allow_overwrite: IndexSet<LocalDefId>,
5757
}
5858

5959
/// A unique identifier that we can use to lookup a definition
@@ -304,27 +304,36 @@ impl Definitions {
304304
};
305305

306306
// Create the root definition.
307-
let root = defs.allocate(key, def_path_hash);
307+
let root = defs.allocate(key, def_path_hash, false);
308308
assert_eq!(root.local_def_index, CRATE_DEF_INDEX);
309309

310310
defs
311311
}
312312

313-
fn allocate(&mut self, key: DefKey, def_path_hash: DefPathHash) -> LocalDefId {
313+
fn allocate(
314+
&mut self,
315+
key: DefKey,
316+
def_path_hash: DefPathHash,
317+
in_sandbox: bool,
318+
) -> LocalDefId {
314319
// Assert that all DefPathHashes correctly contain the local crate's StableCrateId.
315320
debug_assert_eq!(self.stable_crate_id, def_path_hash.stable_crate_id());
316321
let local_hash = def_path_hash.local_hash();
317-
let index = self.index_to_key.next_index();
322+
let def_id = self.def_id_to_key.next_index();
318323

319324
// Check for hash collisions of DefPathHashes. These should be
320325
// exceedingly rare.
321-
if let Some(existing) = self.def_path_hash_to_index.insert(&local_hash, &index) {
326+
if let Some(existing) =
327+
self.def_path_hash_to_index.insert(&local_hash, &def_id.local_def_index)
328+
{
329+
let existing = LocalDefId { local_def_index: existing };
330+
322331
if !in_sandbox && self.allow_overwrite.swap_remove(&existing) {
323-
self.def_path_hash_to_index.insert(&local_hash, &existing);
332+
self.def_path_hash_to_index.insert(&local_hash, &existing.local_def_index);
324333
return existing;
325334
} else {
326-
let def_path1 = DefPath::make(LOCAL_CRATE, existing, |idx| self.def_key(idx));
327-
let def_path2 = DefPath::make(LOCAL_CRATE, index, |idx| self.def_key(idx));
335+
let def_path1 = self.def_path(existing);
336+
let def_path2 = self.def_path(def_id);
328337

329338
// Continuing with colliding DefPathHashes can lead to correctness
330339
// issues. We must abort compilation.
@@ -340,14 +349,14 @@ impl Definitions {
340349
);
341350
}
342351
} else {
343-
self.index_to_key.push(key);
344-
debug!("DefPathTable::insert() - {key:?} <-> {index:?}");
352+
self.def_id_to_key.push(key);
353+
debug!("def_id_to_key.push() - {key:?} <-> {:?}", def_id.local_def_index);
345354

346355
self.def_path_hashes.push(local_hash);
347-
debug_assert!(self.def_path_hashes.len() == self.index_to_key.len());
356+
debug_assert!(self.def_path_hashes.len() == self.def_id_to_key.len());
348357
}
349358

350-
index
359+
def_id
351360
}
352361

353362
pub fn enumerated_keys_and_path_hashes(
@@ -404,14 +413,12 @@ impl Definitions {
404413

405414
debug!("create_def: after disambiguation, key = {:?}", key);
406415

407-
let local_def_index = self.table.allocate(key, def_path_hash, in_sandbox);
408-
416+
let def_id = self.allocate(key, def_path_hash, in_sandbox);
409417
if in_sandbox {
410-
assert_eq!(self.table.allow_overwrite.insert(local_def_index), true);
418+
assert_eq!(self.allow_overwrite.insert(def_id), true);
411419
}
412420

413-
// Create the definition.
414-
LocalDefId { local_def_index }
421+
def_id
415422
}
416423

417424
#[inline(always)]

compiler/rustc_middle/src/dep_graph/graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ impl DepGraph {
222222
}
223223

224224
pub fn assert_eval_always(&self) {
225-
if self.data.is_some() {
225+
if self.data().is_some() {
226226
read_deps(|deps| {
227227
assert_matches!(deps, TaskDepsRef::EvalAlways, "expected eval always context")
228228
});

compiler/rustc_middle/src/hir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ impl<'tcx> ProjectedMaybeOwner<'tcx> {
520520
}),
521521
MaybeOwner::NonOwner(hir_id) => ProjectedMaybeOwner::NonOwner(hir_id),
522522
// Can't debug fmt `def_id` since it doesn't exist.
523-
MaybeOwner::Phantom => bug!("No HirId for {:?}", def_id.local_def_index),
523+
MaybeOwner::Phantom => bug!("No HirId for {:?}", def_id),
524524
}
525525
}
526526

compiler/rustc_query_impl/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fn enter_sandbox<'tcx, C: QueryCache>(query: &'tcx QueryVTable<'tcx, C>) {
6767

6868
fn leave_sandbox<'tcx, C: QueryCache>(query: &'tcx QueryVTable<'tcx, C>) {
6969
if query.name == "lower_delayed_owner"
70-
|| query.name == "delayed_owner"
70+
|| query.name == "hir_delayed_owner"
7171
|| query.name == "def_kind"
7272
{
7373
return;

tests/ui/delegation/query-cycle-oom.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ mod test_3 {
4848

4949
impl () { //~ ERROR: cannot define inherent `impl` for primitive types
5050
reuse Trait::*;
51-
//~^ ERROR: no method named `foo` found for reference `&()` in the current scope
51+
//~^ ERROR: the trait bound `(): test_3::Trait` is not satisfied
5252
}
5353
}
5454

tests/ui/delegation/query-cycle-oom.stderr

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,19 @@ LL - reuse Trait::* { &self.0 }
9090
LL + reuse Trait::&self.0 }
9191
|
9292

93-
error[E0599]: no method named `foo` found for reference `&()` in the current scope
93+
error[E0277]: the trait bound `(): test_3::Trait` is not satisfied
9494
--> $DIR/query-cycle-oom.rs:50:22
9595
|
9696
LL | reuse Trait::*;
97-
| ^ method not found in `&()`
98-
|
99-
= help: items from traits can only be used if the trait is implemented and in scope
100-
= note: the following traits define an item `foo`, perhaps you need to implement one of them:
101-
candidate #1: `test_1::Trait`
102-
candidate #2: `test_2::Trait`
103-
candidate #3: `test_3::Trait`
104-
candidate #4: `test_4::Trait`
97+
| ^ the trait `test_3::Trait` is not implemented for `()`
98+
|
99+
help: this trait has no implementations, consider adding one
100+
--> $DIR/query-cycle-oom.rs:43:5
101+
|
102+
LL | trait Trait {
103+
| ^^^^^^^^^^^
105104

106105
error: aborting due to 10 previous errors
107106

108-
Some errors have detailed explanations: E0046, E0061, E0107, E0121, E0220, E0390, E0433, E0599.
107+
Some errors have detailed explanations: E0046, E0061, E0107, E0121, E0220, E0277, E0390, E0433.
109108
For more information about an error, try `rustc --explain E0046`.

0 commit comments

Comments
 (0)