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

Implementation of RFC 2289 (associated_type_bounds) #57428

Merged
merged 24 commits into from
Jun 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
35585c4
Aggregation of drive-by cosmetic changes.
alexreg Feb 28, 2019
dce27cb
Enabled `Self` in type aliases.
alexreg Mar 17, 2019
3816958
Implemented for function bounds, type bounds, and named existential t…
alexreg Feb 28, 2019
aaa53ec
Implemented for traits (associated type definitions).
alexreg Mar 16, 2019
01f49f0
Use both existential-type desugaring and where-clause (predicate) des…
alexreg Mar 21, 2019
cad1b18
Added feature gate.
alexreg Mar 21, 2019
4310ba2
Added test suite.
alexreg Mar 16, 2019
a71d557
Addressed points raised in review.
alexreg May 4, 2019
0f4a5ca
Added some comments to lowering code.
nikomatsakis May 8, 2019
538ebd1
Added some comments, made `add_bounds` private.
nikomatsakis May 8, 2019
5bf5994
Fixed up some comments.
alexreg May 10, 2019
f472cd9
Addressed points raised in review.
nikomatsakis May 8, 2019
c105c28
Fixed rebase fallout.
alexreg May 19, 2019
10b6daa
Reblessed tests.
alexreg May 20, 2019
2cdd7f8
Removed unnecessary nested-lifetime-bounds test.
alexreg Jun 2, 2019
963e22c
added a few comments
nikomatsakis May 8, 2019
049f4d8
document the `Bounds` struct a bit
alexreg Jun 5, 2019
f6ee542
make `instantiate_poly_trait_ref_inner` private to this module
nikomatsakis May 31, 2019
83078f0
comment `instantiate_poly_trait_ref` and its binder behavior
nikomatsakis May 31, 2019
18d5085
more comments
nikomatsakis May 31, 2019
e48dd12
another comment
nikomatsakis Jun 5, 2019
a900427
verified that skip-binder is ok
nikomatsakis Jun 5, 2019
e37a7a1
add an example to `create_substs_for_ast_path`
alexreg Jun 5, 2019
ee89033
Reblessed tests with NLL compare mode on.
alexreg Jun 6, 2019
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
2 changes: 1 addition & 1 deletion src/libcore/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,7 @@ impl<'b> BorrowRefMut<'b> {
}
}

// Clone a `BorrowRefMut`.
// Clones a `BorrowRefMut`.
//
// This is only valid if each `BorrowRefMut` is used to track a mutable
// reference to a distinct, nonoverlapping range of the original object.
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/ops/unsize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl<T: ?Sized+Unsize<U>, U: ?Sized> CoerceUnsized<*const U> for *const T {}

/// This is used for object safety, to check that a method's receiver type can be dispatched on.
///
/// example impl:
/// An example implementation of the trait:
///
/// ```
/// # #![feature(dispatch_from_dyn, unsize)]
Expand Down
10 changes: 8 additions & 2 deletions src/librustc/hir/intravisit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,14 @@ pub fn walk_assoc_type_binding<'v, V: Visitor<'v>>(visitor: &mut V,
type_binding: &'v TypeBinding) {
visitor.visit_id(type_binding.hir_id);
visitor.visit_ident(type_binding.ident);
visitor.visit_ty(&type_binding.ty);
match type_binding.kind {
TypeBindingKind::Equality { ref ty } => {
visitor.visit_ty(ty);
}
TypeBindingKind::Constraint { ref bounds } => {
walk_list!(visitor, visit_param_bound, bounds);
}
}
}

pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) {
Expand Down Expand Up @@ -934,7 +941,6 @@ pub fn walk_impl_item_ref<'v, V: Visitor<'v>>(visitor: &mut V, impl_item_ref: &'
visitor.visit_defaultness(defaultness);
}


pub fn walk_struct_def<'v, V: Visitor<'v>>(visitor: &mut V, struct_definition: &'v VariantData) {
if let Some(ctor_hir_id) = struct_definition.ctor_hir_id() {
visitor.visit_id(ctor_hir_id);
Expand Down
385 changes: 266 additions & 119 deletions src/librustc/hir/lowering.rs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/librustc/hir/map/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use std::iter::repeat;
use crate::ich::StableHashingContext;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableHasherResult};

/// A Visitor that walks over the HIR and collects Nodes into a HIR map
/// A visitor that walks over the HIR and collects `Node`s into a HIR map.
pub(super) struct NodeCollector<'a, 'hir> {
/// The crate
krate: &'hir Crate,
Expand All @@ -45,7 +45,7 @@ pub(super) struct NodeCollector<'a, 'hir> {

hcx: StableHashingContext<'a>,

// We are collecting DepNode::HirBody hashes here so we can compute the
// We are collecting `DepNode::HirBody` hashes here so we can compute the
// crate hash from then later on.
hir_body_nodes: Vec<(DefPathHash, Fingerprint)>,
}
Expand Down Expand Up @@ -109,7 +109,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {

let mut hir_body_nodes = Vec::new();

// Allocate DepNodes for the root module
// Allocate `DepNode`s for the root module.
let (root_mod_sig_dep_index, root_mod_full_dep_index) = {
let Crate {
ref module,
Expand Down
21 changes: 13 additions & 8 deletions src/librustc/hir/map/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ impl DefPath {
"{}[{}]",
component.data.as_interned_str(),
component.disambiguator)
.unwrap();
.unwrap();
}
}

Expand All @@ -263,7 +263,7 @@ impl DefPath {
"{}[{}]",
component.data.as_interned_str(),
component.disambiguator)
.unwrap();
.unwrap();
}
}
s
Expand All @@ -276,7 +276,7 @@ pub enum DefPathData {
// they are treated specially by the `def_path` function.
/// The crate root (marker)
CrateRoot,
// Catch-all for random DefId things like DUMMY_NODE_ID
// Catch-all for random DefId things like `DUMMY_NODE_ID`
Misc,
// Different kinds of items and item-like things:
/// An impl
Expand All @@ -298,9 +298,9 @@ pub enum DefPathData {
AnonConst,
/// An `impl Trait` type node
ImplTrait,
/// GlobalMetaData identifies a piece of crate metadata that is global to
/// a whole crate (as opposed to just one item). GlobalMetaData components
/// are only supposed to show up right below the crate root.
/// Identifies a piece of crate metadata that is global to a whole crate
/// (as opposed to just one item). `GlobalMetaData` components are only
/// supposed to show up right below the crate root.
GlobalMetaData(InternedString),
}

Expand Down Expand Up @@ -397,6 +397,11 @@ impl Definitions {
self.node_to_hir_id[node_id]
}

#[inline]
pub fn def_index_to_node_id(&self, def_index: DefIndex) -> ast::NodeId {
self.as_local_node_id(DefId::local(def_index)).unwrap()
alexreg marked this conversation as resolved.
Show resolved Hide resolved
}

/// Retrieves the span of the given `DefId` if `DefId` is in the local crate, the span exists
/// and it's not `DUMMY_SP`.
#[inline]
Expand Down Expand Up @@ -442,7 +447,7 @@ impl Definitions {
root_index
}

/// Add a definition with a parent definition.
/// Adds a definition with a parent definition.
pub fn create_def_with_parent(&mut self,
parent: DefIndex,
node_id: ast::NodeId,
Expand Down Expand Up @@ -559,7 +564,7 @@ impl DefPathData {
GlobalMetaData(name) => {
return name
}
// note that this does not show up in user printouts
// Note that this does not show up in user print-outs.
CrateRoot => sym::double_braced_crate,
Impl => sym::double_braced_impl,
Misc => sym::double_braced_misc,
Expand Down
Loading