Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 7 pull requests #84440

Merged
merged 22 commits into from
Apr 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
98a11e0
Remove closure_tree
camsteffen Apr 19, 2021
c9c14d0
Small refactor
camsteffen Apr 19, 2021
a10d01b
Uses flex to fix formatting of h1 at any width.
Apr 20, 2021
ba3d22e
Precompute inverse binder depth
jackh726 Apr 12, 2021
32942ab
A non-minimal set of TraitRefBoundarys to work on removing from_poly_…
jackh726 Apr 12, 2021
457c4c1
Add BinderScopeType to replace binder_depth and from_poly_trait_ref
jackh726 Apr 13, 2021
9891582
Remove TraitRefHackInner and use the concatenating functionality inst…
jackh726 Apr 20, 2021
75732dd
Check for intrinsics before coercing to a function pointer
tmiasko Apr 21, 2021
4568e7d
Move nested quantification check to ast_validation
jackh726 Apr 21, 2021
e34f7e6
Update LLVM submodule
Amanieu Apr 21, 2021
b78c0d8
Review comments
jackh726 Apr 21, 2021
eb9b0f6
Move `sys_common::rwlock::StaticRWLock` etc. to `sys::unix::rwlock`
CDirkx Apr 21, 2021
c78724f
More review changes
jackh726 Apr 21, 2021
bb91805
Replaced flex gap with margin, for compatibility with older browsers.
Apr 21, 2021
1a6de84
Remove `sys::args::Args::inner_debug` and use `Debug` instead
CDirkx Apr 21, 2021
2f438e3
Rollup merge of #84343 - camsteffen:closure-tree, r=varkor
Dylan-DPC Apr 22, 2021
7b6fd61
Rollup merge of #84376 - torhovland:issue-84534, r=GuillaumeGomez
Dylan-DPC Apr 22, 2021
9b432e0
Rollup merge of #84377 - jackh726:binder-refactor-fix, r=nikomatsakis
Dylan-DPC Apr 22, 2021
54af84b
Rollup merge of #84396 - Amanieu:fix_compiler_builtins_llvm, r=cuviper
Dylan-DPC Apr 22, 2021
aac5125
Rollup merge of #84402 - CDirkx:rwlock, r=dtolnay
Dylan-DPC Apr 22, 2021
f180c1e
Rollup merge of #84404 - tmiasko:intrinsics-in-coercion-lub, r=Mark-S…
Dylan-DPC Apr 22, 2021
d1f5fc6
Rollup merge of #84413 - CDirkx:args_inner_debug, r=m-ou-se
Dylan-DPC Apr 22, 2021
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
45 changes: 35 additions & 10 deletions compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1213,8 +1213,41 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
deny_equality_constraints(self, predicate, generics);
}
}

visit::walk_generics(self, generics)
walk_list!(self, visit_generic_param, &generics.params);
for predicate in &generics.where_clause.predicates {
match predicate {
WherePredicate::BoundPredicate(bound_pred) => {
// A type binding, eg `for<'c> Foo: Send+Clone+'c`
self.check_late_bound_lifetime_defs(&bound_pred.bound_generic_params);

// This is slightly complicated. Our representation for poly-trait-refs contains a single
// binder and thus we only allow a single level of quantification. However,
// the syntax of Rust permits quantification in two places in where clauses,
// e.g., `T: for <'a> Foo<'a>` and `for <'a, 'b> &'b T: Foo<'a>`. If both are
// defined, then error.
if !bound_pred.bound_generic_params.is_empty() {
for bound in &bound_pred.bounds {
match bound {
GenericBound::Trait(t, _) => {
if !t.bound_generic_params.is_empty() {
struct_span_err!(
self.err_handler(),
t.span,
E0316,
"nested quantification of lifetimes"
)
.emit();
}
}
GenericBound::Outlives(_) => {}
}
}
}
}
_ => {}
}
self.visit_where_predicate(predicate);
}
}

fn visit_generic_param(&mut self, param: &'a GenericParam) {
Expand Down Expand Up @@ -1263,14 +1296,6 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
visit::walk_pat(self, pat)
}

fn visit_where_predicate(&mut self, p: &'a WherePredicate) {
if let &WherePredicate::BoundPredicate(ref bound_predicate) = p {
// A type binding, eg `for<'c> Foo: Send+Clone+'c`
self.check_late_bound_lifetime_defs(&bound_predicate.bound_generic_params);
}
visit::walk_where_predicate(self, p);
}

fn visit_poly_trait_ref(&mut self, t: &'a PolyTraitRef, m: &'a TraitBoundModifier) {
self.check_late_bound_lifetime_defs(&t.bound_generic_params);
visit::walk_poly_trait_ref(self, t, m);
Expand Down
31 changes: 0 additions & 31 deletions compiler/rustc_middle/src/middle/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,18 +235,6 @@ pub struct ScopeTree {
/// escape into 'static and should have no local cleanup scope.
rvalue_scopes: FxHashMap<hir::ItemLocalId, Option<Scope>>,

/// Encodes the hierarchy of fn bodies. Every fn body (including
/// closures) forms its own distinct region hierarchy, rooted in
/// the block that is the fn body. This map points from the ID of
/// that root block to the ID of the root block for the enclosing
/// fn, if any. Thus the map structures the fn bodies into a
/// hierarchy based on their lexical mapping. This is used to
/// handle the relationships between regions in a fn and in a
/// closure defined by that fn. See the "Modeling closures"
/// section of the README in infer::region_constraints for
/// more details.
closure_tree: FxHashMap<hir::ItemLocalId, hir::ItemLocalId>,

/// If there are any `yield` nested within a scope, this map
/// stores the `Span` of the last one and its index in the
/// postorder of the Visitor traversal on the HIR.
Expand Down Expand Up @@ -356,23 +344,6 @@ impl ScopeTree {
self.destruction_scopes.get(&n).cloned()
}

/// Records that `sub_closure` is defined within `sup_closure`. These IDs
/// should be the ID of the block that is the fn body, which is
/// also the root of the region hierarchy for that fn.
pub fn record_closure_parent(
&mut self,
sub_closure: hir::ItemLocalId,
sup_closure: hir::ItemLocalId,
) {
debug!(
"record_closure_parent(sub_closure={:?}, sup_closure={:?})",
sub_closure, sup_closure
);
assert!(sub_closure != sup_closure);
let previous = self.closure_tree.insert(sub_closure, sup_closure);
assert!(previous.is_none());
}

pub fn record_var_scope(&mut self, var: hir::ItemLocalId, lifetime: Scope) {
debug!("record_var_scope(sub={:?}, sup={:?})", var, lifetime);
assert!(var != lifetime.item_local_id());
Expand Down Expand Up @@ -474,7 +445,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for ScopeTree {
ref var_map,
ref destruction_scopes,
ref rvalue_scopes,
ref closure_tree,
ref yield_in_scope,
} = *self;

Expand All @@ -488,7 +458,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for ScopeTree {
var_map.hash_stable(hcx, hasher);
destruction_scopes.hash_stable(hcx, hasher);
rvalue_scopes.hash_stable(hcx, hasher);
closure_tree.hash_stable(hcx, hasher);
yield_in_scope.hash_stable(hcx, hasher);
}
}
15 changes: 1 addition & 14 deletions compiler/rustc_passes/src/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@ use std::mem;

#[derive(Debug, Copy, Clone)]
pub struct Context {
/// The root of the current region tree. This is typically the id
/// of the innermost fn body. Each fn forms its own disjoint tree
/// in the region hierarchy. These fn bodies are themselves
/// arranged into a tree. See the "Modeling closures" section of
/// the README in `rustc_trait_selection::infer::region_constraints`
/// for more details.
root_id: Option<hir::ItemLocalId>,

/// The scope that contains any new variables declared, plus its depth in
/// the scope tree.
var_parent: Option<(Scope, ScopeDepth)>,
Expand Down Expand Up @@ -743,11 +735,6 @@ impl<'tcx> Visitor<'tcx> for RegionResolutionVisitor<'tcx> {
let outer_pessimistic_yield = mem::replace(&mut self.pessimistic_yield, false);
self.terminating_scopes.insert(body.value.hir_id.local_id);

if let Some(root_id) = self.cx.root_id {
self.scope_tree.record_closure_parent(body.value.hir_id.local_id, root_id);
}
self.cx.root_id = Some(body.value.hir_id.local_id);

self.enter_scope(Scope { id: body.value.hir_id.local_id, data: ScopeData::CallSite });
self.enter_scope(Scope { id: body.value.hir_id.local_id, data: ScopeData::Arguments });

Expand Down Expand Up @@ -824,7 +811,7 @@ fn region_scope_tree(tcx: TyCtxt<'_>, def_id: DefId) -> &ScopeTree {
tcx,
scope_tree: ScopeTree::default(),
expr_and_pat_count: 0,
cx: Context { root_id: None, parent: None, var_parent: None },
cx: Context { parent: None, var_parent: None },
terminating_scopes: Default::default(),
pessimistic_yield: false,
fixup_scopes: vec![],
Expand Down
Loading