Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
f3335c6
simplify `AnonTypeDecl` in the impl trait code
nikomatsakis Dec 6, 2017
f6741d0
region_infer/values.rs: rustfmt
nikomatsakis Dec 6, 2017
e447b54
Add tracking of causes for nll
Nashenas88 Nov 21, 2017
39b0e49
rustfmt: borrow_check/mod.rs
nikomatsakis Dec 14, 2017
594c386
dump out causal information for "free region" errors
nikomatsakis Dec 7, 2017
741ef41
use Rc to store nonlexical_regioncx in Borrows
nikomatsakis Dec 7, 2017
0e64a75
integrate -Znll-dump-cause into borrowck
nikomatsakis Dec 7, 2017
fe89f4b
get the `DefiningTy` from the `body_owner_kind` not type
nikomatsakis Dec 8, 2017
4a967c9
propagate `region_bound_pairs` into MIR type-check
nikomatsakis Dec 8, 2017
e96f4be
extract `instantiate_anon_types` to the `InferCtxt`
nikomatsakis Dec 9, 2017
8e64ba8
extract `constrain_anon_types` to the `InferCtxt`
nikomatsakis Dec 9, 2017
7f50e7c
extract the writeback code for anon types into InferCtxt
nikomatsakis Dec 9, 2017
a66c651
pass `UniversalRegions` to MIR type-checker instead of fields
nikomatsakis Dec 10, 2017
da63aaa
extract `input_output` code into its own module
nikomatsakis Dec 10, 2017
93afb1a
connect NLL type checker to the impl trait code
nikomatsakis Dec 10, 2017
58b0506
Move MirVisitable to visit.rs
spastorino Dec 12, 2017
6d2987c
Move categorize logic out of visit_local function
nikomatsakis Dec 20, 2017
3a185a5
Add three point error handling to borrowck
spastorino Dec 12, 2017
e28d03f
only dump causes if we have nothing better
nikomatsakis Dec 14, 2017
4089d14
move nice-region-error reporting into its own module
nikomatsakis Dec 12, 2017
93498e0
make `util` fns private to nice_region_error
nikomatsakis Dec 12, 2017
3720242
extract `find_anon_type` into its own module
nikomatsakis Dec 12, 2017
a28ab84
nice_region_error: rustfmt
nikomatsakis Dec 12, 2017
cba4732
introduce a `NiceRegionError` type and define methods on that
nikomatsakis Dec 12, 2017
de56308
use `Option<ErrorReported>` instead of `bool`
nikomatsakis Dec 12, 2017
94e7072
give precedence to `try_report_named_anon_conflict` method
nikomatsakis Dec 12, 2017
6b39781
connect NLL machinery to the `NiceRegionError` code
nikomatsakis Dec 12, 2017
3788f42
refactor `report_generic_bound_failure` to be usable by NLL code
nikomatsakis Dec 19, 2017
508a831
use `report_generic_bound_failure` when we can in the compiler
nikomatsakis Dec 19, 2017
95b6148
Add nll_dump_cause helper to Session
spastorino Dec 19, 2017
0b2db1e
Add nll feature and make nll imply nll_dump_cause
spastorino Dec 19, 2017
2019d69
feature nll implies two-phase-borrows
spastorino Dec 19, 2017
e980fb8
feature nll implies borrowck=mir
spastorino Dec 19, 2017
cfa4ffa
document and tweak the nll, use_mir, etc helpers
nikomatsakis Dec 20, 2017
80c510e
when using feature(nll), don't warn about AST-based region errors
nikomatsakis Dec 20, 2017
cba8256
add some run-pass tests for NLL showing that things work as expected
nikomatsakis Dec 7, 2017
3f490ca
convert region-liveness-drop{-,-no-}may-dangle.rs into ui tests
nikomatsakis Dec 20, 2017
4f549fe
improve comment about instantiating anon types
nikomatsakis Dec 20, 2017
d925f4d
fix truncated comment
nikomatsakis Dec 20, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
pass UniversalRegions to MIR type-checker instead of fields
No functional change.
  • Loading branch information
nikomatsakis committed Dec 20, 2017
commit a66c6512aa473bcb8721e0423a1739bf8e976b91
6 changes: 1 addition & 5 deletions src/librustc_mir/borrow_check/nll/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,12 @@ pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>(
// Run the MIR type-checker.
let mir_node_id = infcx.tcx.hir.as_local_node_id(def_id).unwrap();
let liveness = &LivenessResults::compute(mir);
let fr_fn_body = infcx.tcx.mk_region(ty::ReVar(universal_regions.fr_fn_body));
let constraint_sets = &type_check::type_check(
infcx,
mir_node_id,
param_env,
mir,
&universal_regions.region_bound_pairs,
fr_fn_body,
universal_regions.input_tys,
universal_regions.output_ty,
&universal_regions,
&liveness,
flow_inits,
move_data,
Expand Down
19 changes: 12 additions & 7 deletions src/librustc_mir/borrow_check/nll/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use borrow_check::nll::region_infer::Cause;
use borrow_check::nll::region_infer::ClosureRegionRequirementsExt;
use borrow_check::nll::universal_regions::UniversalRegions;
use dataflow::FlowAtLocation;
use dataflow::MaybeInitializedLvals;
use dataflow::move_paths::MoveData;
Expand Down Expand Up @@ -71,28 +72,32 @@ pub(crate) fn type_check<'gcx, 'tcx>(
body_id: ast::NodeId,
param_env: ty::ParamEnv<'gcx>,
mir: &Mir<'tcx>,
region_bound_pairs: &[(ty::Region<'tcx>, GenericKind<'tcx>)],
implicit_region_bound: ty::Region<'tcx>,
input_tys: &[Ty<'tcx>],
output_ty: Ty<'tcx>,
universal_regions: &UniversalRegions<'tcx>,
liveness: &LivenessResults,
flow_inits: &mut FlowAtLocation<MaybeInitializedLvals<'_, 'gcx, 'tcx>>,
move_data: &MoveData<'tcx>,
) -> MirTypeckRegionConstraints<'tcx> {
let implicit_region_bound = infcx.tcx.mk_region(ty::ReVar(universal_regions.fr_fn_body));
type_check_internal(
infcx,
body_id,
param_env,
mir,
region_bound_pairs,
&universal_regions.region_bound_pairs,
Some(implicit_region_bound),
&mut |cx| {
liveness::generate(cx, mir, liveness, flow_inits, move_data);

// Equate the input and output tys given by the user with
// the ones found in the MIR.
cx.equate_input_or_output(output_ty, mir.local_decls[RETURN_PLACE].ty);
for (&input_ty, local) in input_tys.iter().zip((1..).map(Local::new)) {
let &UniversalRegions {
unnormalized_output_ty,
unnormalized_input_tys,
..
} = universal_regions;
cx.equate_input_or_output(unnormalized_output_ty, mir.local_decls[RETURN_PLACE].ty);
let arg_locals = (1..).map(Local::new);
for (&input_ty, local) in unnormalized_input_tys.iter().zip(arg_locals) {
cx.equate_input_or_output(input_ty, mir.local_decls[local].ty);
}
},
Expand Down
23 changes: 13 additions & 10 deletions src/librustc_mir/borrow_check/nll/universal_regions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,18 @@ pub struct UniversalRegions<'tcx> {
pub defining_ty: DefiningTy<'tcx>,

/// The return type of this function, with all regions replaced by
/// their universal `RegionVid` equivalents. This type is **NOT
/// NORMALIZED** (i.e., it contains unnormalized associated type
/// projections).
pub output_ty: Ty<'tcx>,
/// their universal `RegionVid` equivalents.
///
/// NB. Associated types in this type have not been normalized,
/// as the name suggests. =)
pub unnormalized_output_ty: Ty<'tcx>,

/// The fully liberated input types of this function, with all
/// regions replaced by their universal `RegionVid` equivalents.
/// This type is **NOT NORMALIZED** (i.e., it contains
/// unnormalized associated type projections).
pub input_tys: &'tcx [Ty<'tcx>],
///
/// NB. Associated types in these types have not been normalized,
/// as the name suggests. =)
pub unnormalized_input_tys: &'tcx [Ty<'tcx>],

/// Each RBP `('a, GK)` indicates that `GK: 'a` can be assumed to
/// be true. These encode relationships like `T: 'a` that are
Expand Down Expand Up @@ -479,7 +481,8 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> {
self.relations.relate_universal_regions(fr, fr_fn_body);
}

let (output_ty, input_tys) = inputs_and_output.split_last().unwrap();
let (unnormalized_output_ty, unnormalized_input_tys) =
inputs_and_output.split_last().unwrap();

// we should not have created any more variables
assert_eq!(self.infcx.num_region_vars(), num_universals);
Expand Down Expand Up @@ -508,8 +511,8 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> {
first_local_index,
num_universals,
defining_ty,
output_ty,
input_tys,
unnormalized_output_ty,
unnormalized_input_tys,
region_bound_pairs: self.region_bound_pairs,
relations: self.relations,
}
Expand Down