Skip to content

Commit 826e1ca

Browse files
authored
Unrolled build for rust-lang#138094
Rollup merge of rust-lang#138094 - lcnr:cleanup-borrowck, r=fee1-dead a small borrowck cleanup
2 parents 98a4878 + 1fac14d commit 826e1ca

File tree

8 files changed

+32
-32
lines changed

8 files changed

+32
-32
lines changed

compiler/rustc_borrowck/src/type_check/constraint_conversion.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_hir::def_id::DefId;
1+
use rustc_hir::def_id::LocalDefId;
22
use rustc_infer::infer::canonical::QueryRegionConstraints;
33
use rustc_infer::infer::outlives::env::RegionBoundPairs;
44
use rustc_infer::infer::outlives::obligations::{TypeOutlives, TypeOutlivesDelegate};
@@ -88,7 +88,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
8888
pub(crate) fn apply_closure_requirements(
8989
&mut self,
9090
closure_requirements: &ClosureRegionRequirements<'tcx>,
91-
closure_def_id: DefId,
91+
closure_def_id: LocalDefId,
9292
closure_args: ty::GenericArgsRef<'tcx>,
9393
) {
9494
// Extract the values of the free regions in `closure_args`
@@ -98,7 +98,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
9898
self.tcx,
9999
closure_args,
100100
closure_requirements.num_external_vids,
101-
closure_def_id.expect_local(),
101+
closure_def_id,
102102
);
103103
debug!(?closure_mapping);
104104

compiler/rustc_borrowck/src/type_check/mod.rs

+24-13
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,8 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
328328
}
329329
}
330330

331+
#[instrument(level = "debug", skip(self))]
331332
fn visit_const_operand(&mut self, constant: &ConstOperand<'tcx>, location: Location) {
332-
debug!(?constant, ?location, "visit_const_operand");
333-
334333
self.super_const_operand(constant, location);
335334
let ty = constant.const_.ty();
336335

@@ -339,14 +338,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
339338
self.typeck.constraints.liveness_constraints.add_location(live_region_vid, location);
340339
});
341340

342-
// HACK(compiler-errors): Constants that are gathered into Body.required_consts
343-
// have their locations erased...
344-
let locations = if location != Location::START {
345-
location.to_locations()
346-
} else {
347-
Locations::All(constant.span)
348-
};
349-
341+
let locations = location.to_locations();
350342
if let Some(annotation_index) = constant.user_ty {
351343
if let Err(terr) = self.typeck.relate_type_and_user_type(
352344
constant.const_.ty(),
@@ -491,9 +483,28 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
491483
}
492484
}
493485

486+
#[instrument(level = "debug", skip(self))]
494487
fn visit_body(&mut self, body: &Body<'tcx>) {
495-
// The types of local_decls are checked above which is called in super_body.
496-
self.super_body(body);
488+
// We intentionally do not recurse into `body.required_consts` or
489+
// `body.mentioned_items` here as the MIR at this phase should still
490+
// refer to all items and we don't want to check them multiple times.
491+
492+
for (local, local_decl) in body.local_decls.iter_enumerated() {
493+
self.visit_local_decl(local, local_decl);
494+
}
495+
496+
for (block, block_data) in body.basic_blocks.iter_enumerated() {
497+
let mut location = Location { block, statement_index: 0 };
498+
for stmt in &block_data.statements {
499+
if !stmt.source_info.span.is_dummy() {
500+
self.last_span = stmt.source_info.span;
501+
}
502+
self.visit_statement(stmt, location);
503+
location.statement_index += 1;
504+
}
505+
506+
self.visit_terminator(block_data.terminator(), location);
507+
}
497508
}
498509
}
499510

@@ -2582,7 +2593,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
25822593
ConstraintCategory::Boring, // same as above.
25832594
self.constraints,
25842595
)
2585-
.apply_closure_requirements(closure_requirements, def_id.to_def_id(), args);
2596+
.apply_closure_requirements(closure_requirements, def_id, args);
25862597
}
25872598

25882599
// Now equate closure args to regions inherited from `typeck_root_def_id`. Fixes #98589.

tests/ui/error-codes/E0582.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ error[E0308]: mismatched types
1414
--> $DIR/E0582.rs:22:5
1515
|
1616
LL | bar(mk_unexpected_char_err)
17-
| ^^^ one type is more general than the other
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
1818
|
1919
= note: expected enum `Option<&_>`
2020
found enum `Option<&'a _>`

tests/ui/higher-ranked/trait-bounds/hrtb-just-for-static.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: implementation of `Foo` is not general enough
22
--> $DIR/hrtb-just-for-static.rs:24:5
33
|
44
LL | want_hrtb::<StaticInt>()
5-
| ^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
66
|
77
= note: `StaticInt` must implement `Foo<&'0 isize>`, for any lifetime `'0`...
88
= note: ...but it actually implements `Foo<&'static isize>`

tests/ui/nll/issue-97997.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@ fn main() {
1212

1313
<fn(&u8) as Foo>::ASSOC;
1414
//~^ ERROR implementation of `Foo` is not general enough
15-
//~| ERROR implementation of `Foo` is not general enough
1615
}

tests/ui/nll/issue-97997.stderr

+1-11
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,5 @@ LL | <fn(&u8) as Foo>::ASSOC;
77
= note: `Foo` would have to be implemented for the type `for<'a> fn(&'a u8)`
88
= note: ...but `Foo` is actually implemented for the type `fn(&'0 u8)`, for some specific lifetime `'0`
99

10-
error: implementation of `Foo` is not general enough
11-
--> $DIR/issue-97997.rs:13:5
12-
|
13-
LL | <fn(&u8) as Foo>::ASSOC;
14-
| ^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
15-
|
16-
= note: `Foo` would have to be implemented for the type `for<'a> fn(&'a u8)`
17-
= note: ...but `Foo` is actually implemented for the type `fn(&'0 u8)`, for some specific lifetime `'0`
18-
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
19-
20-
error: aborting due to 2 previous errors
10+
error: aborting due to 1 previous error
2111

tests/ui/type-alias-impl-trait/implied_lifetime_wf_check3.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ error[E0310]: the parameter type `A` may not live long enough
2828
--> $DIR/implied_lifetime_wf_check3.rs:52:5
2929
|
3030
LL | test_type_param::assert_static::<A>()
31-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
31+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3232
| |
3333
| the parameter type `A` must be valid for the static lifetime...
3434
| ...so that the type `A` will meet its required lifetime bounds

tests/ui/type-alias-impl-trait/implied_lifetime_wf_check4_static.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ error[E0310]: the parameter type `A` may not live long enough
2121
--> $DIR/implied_lifetime_wf_check4_static.rs:17:5
2222
|
2323
LL | assert_static::<A>()
24-
| ^^^^^^^^^^^^^^^^^^
24+
| ^^^^^^^^^^^^^^^^^^^^
2525
| |
2626
| the parameter type `A` must be valid for the static lifetime...
2727
| ...so that the type `A` will meet its required lifetime bounds

0 commit comments

Comments
 (0)