Skip to content

Commit

Permalink
Unrolled build for rust-lang#138094
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#138094 - lcnr:cleanup-borrowck, r=fee1-dead

a small borrowck cleanup
  • Loading branch information
rust-timer authored Mar 7, 2025
2 parents 98a4878 + 1fac14d commit 826e1ca
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rustc_hir::def_id::DefId;
use rustc_hir::def_id::LocalDefId;
use rustc_infer::infer::canonical::QueryRegionConstraints;
use rustc_infer::infer::outlives::env::RegionBoundPairs;
use rustc_infer::infer::outlives::obligations::{TypeOutlives, TypeOutlivesDelegate};
Expand Down Expand Up @@ -88,7 +88,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
pub(crate) fn apply_closure_requirements(
&mut self,
closure_requirements: &ClosureRegionRequirements<'tcx>,
closure_def_id: DefId,
closure_def_id: LocalDefId,
closure_args: ty::GenericArgsRef<'tcx>,
) {
// Extract the values of the free regions in `closure_args`
Expand All @@ -98,7 +98,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
self.tcx,
closure_args,
closure_requirements.num_external_vids,
closure_def_id.expect_local(),
closure_def_id,
);
debug!(?closure_mapping);

Expand Down
37 changes: 24 additions & 13 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,8 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
}
}

#[instrument(level = "debug", skip(self))]
fn visit_const_operand(&mut self, constant: &ConstOperand<'tcx>, location: Location) {
debug!(?constant, ?location, "visit_const_operand");

self.super_const_operand(constant, location);
let ty = constant.const_.ty();

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

// HACK(compiler-errors): Constants that are gathered into Body.required_consts
// have their locations erased...
let locations = if location != Location::START {
location.to_locations()
} else {
Locations::All(constant.span)
};

let locations = location.to_locations();
if let Some(annotation_index) = constant.user_ty {
if let Err(terr) = self.typeck.relate_type_and_user_type(
constant.const_.ty(),
Expand Down Expand Up @@ -491,9 +483,28 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
}
}

#[instrument(level = "debug", skip(self))]
fn visit_body(&mut self, body: &Body<'tcx>) {
// The types of local_decls are checked above which is called in super_body.
self.super_body(body);
// We intentionally do not recurse into `body.required_consts` or
// `body.mentioned_items` here as the MIR at this phase should still
// refer to all items and we don't want to check them multiple times.

for (local, local_decl) in body.local_decls.iter_enumerated() {
self.visit_local_decl(local, local_decl);
}

for (block, block_data) in body.basic_blocks.iter_enumerated() {
let mut location = Location { block, statement_index: 0 };
for stmt in &block_data.statements {
if !stmt.source_info.span.is_dummy() {
self.last_span = stmt.source_info.span;
}
self.visit_statement(stmt, location);
location.statement_index += 1;
}

self.visit_terminator(block_data.terminator(), location);
}
}
}

Expand Down Expand Up @@ -2582,7 +2593,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
ConstraintCategory::Boring, // same as above.
self.constraints,
)
.apply_closure_requirements(closure_requirements, def_id.to_def_id(), args);
.apply_closure_requirements(closure_requirements, def_id, args);
}

// Now equate closure args to regions inherited from `typeck_root_def_id`. Fixes #98589.
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/error-codes/E0582.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ error[E0308]: mismatched types
--> $DIR/E0582.rs:22:5
|
LL | bar(mk_unexpected_char_err)
| ^^^ one type is more general than the other
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
= note: expected enum `Option<&_>`
found enum `Option<&'a _>`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error: implementation of `Foo` is not general enough
--> $DIR/hrtb-just-for-static.rs:24:5
|
LL | want_hrtb::<StaticInt>()
| ^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
| ^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
|
= note: `StaticInt` must implement `Foo<&'0 isize>`, for any lifetime `'0`...
= note: ...but it actually implements `Foo<&'static isize>`
Expand Down
1 change: 0 additions & 1 deletion tests/ui/nll/issue-97997.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ fn main() {

<fn(&u8) as Foo>::ASSOC;
//~^ ERROR implementation of `Foo` is not general enough
//~| ERROR implementation of `Foo` is not general enough
}
12 changes: 1 addition & 11 deletions tests/ui/nll/issue-97997.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,5 @@ LL | <fn(&u8) as Foo>::ASSOC;
= note: `Foo` would have to be implemented for the type `for<'a> fn(&'a u8)`
= note: ...but `Foo` is actually implemented for the type `fn(&'0 u8)`, for some specific lifetime `'0`

error: implementation of `Foo` is not general enough
--> $DIR/issue-97997.rs:13:5
|
LL | <fn(&u8) as Foo>::ASSOC;
| ^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
|
= note: `Foo` would have to be implemented for the type `for<'a> fn(&'a u8)`
= note: ...but `Foo` is actually implemented for the type `fn(&'0 u8)`, for some specific lifetime `'0`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: aborting due to 2 previous errors
error: aborting due to 1 previous error

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ error[E0310]: the parameter type `A` may not live long enough
--> $DIR/implied_lifetime_wf_check3.rs:52:5
|
LL | test_type_param::assert_static::<A>()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| the parameter type `A` must be valid for the static lifetime...
| ...so that the type `A` will meet its required lifetime bounds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ error[E0310]: the parameter type `A` may not live long enough
--> $DIR/implied_lifetime_wf_check4_static.rs:17:5
|
LL | assert_static::<A>()
| ^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^
| |
| the parameter type `A` must be valid for the static lifetime...
| ...so that the type `A` will meet its required lifetime bounds
Expand Down

0 comments on commit 826e1ca

Please sign in to comment.