Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
varkor committed Aug 2, 2019
1 parent a45cde5 commit b049221
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 116 deletions.
2 changes: 1 addition & 1 deletion src/librustc/hir/mod.rs
Expand Up @@ -1929,7 +1929,7 @@ pub struct OpaqueTy {
pub origin: OpaqueTyOrigin,
}

/// Where the opaque type came from
/// From whence the opaque type came.
#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Debug, HashStable)]
pub enum OpaqueTyOrigin {
/// `type Foo = impl Trait;`
Expand Down
19 changes: 9 additions & 10 deletions src/librustc/hir/print.rs
Expand Up @@ -565,17 +565,12 @@ impl<'a> State<'a> {
self.s.word(";");
self.end(); // end the outer ibox
}
hir::ItemKind::OpaqueTy(ref exist) => {
hir::ItemKind::OpaqueTy(ref opaque_ty) => {
self.head(visibility_qualified(&item.vis, "type"));
self.print_ident(item.ident);
self.word_space("= impl");
self.print_generic_params(&exist.generics.params);
self.end(); // end the inner ibox

self.print_where_clause(&exist.generics.where_clause);
self.s.space();
let mut real_bounds = Vec::with_capacity(exist.bounds.len());
for b in exist.bounds.iter() {
self.print_generic_params(&opaque_ty.generics.params);
let mut real_bounds = Vec::with_capacity(opaque_ty.bounds.len());
for b in opaque_ty.bounds.iter() {
if let GenericBound::Trait(ref ptr, hir::TraitBoundModifier::Maybe) = *b {
self.s.space();
self.word_space("for ?");
Expand All @@ -584,7 +579,11 @@ impl<'a> State<'a> {
real_bounds.push(b);
}
}
self.print_bounds(":", real_bounds);
self.print_bounds(" = impl", real_bounds);

self.end(); // end the inner ibox

self.print_where_clause(&opaque_ty.generics.where_clause);
self.s.word(";");
self.end(); // end the outer ibox
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/context.rs
Expand Up @@ -393,7 +393,7 @@ pub struct TypeckTables<'tcx> {
pub free_region_map: FreeRegionMap<'tcx>,

/// All the opaque types that are restricted to concrete types
/// by this function
/// by this function.
pub concrete_opaque_types: FxHashMap<DefId, ResolvedOpaqueTy<'tcx>>,

/// Given the closure ID this map provides the list of UpvarIDs used by it.
Expand Down
20 changes: 9 additions & 11 deletions src/librustc_save_analysis/sig.rs
Expand Up @@ -438,28 +438,26 @@ impl Sig for ast::Item {
refs: vec![],
})
}
ast::ItemKind::OpaqueTy(ref bounds, ref generics) => {
ast::ItemKind::Ty(ref ty, ref generics) => {
let text = "type ".to_owned();
let mut sig = name_and_generics(text, offset, generics, self.id, self.ident, scx)?;

if !bounds.is_empty() {
sig.text.push_str(" = impl ");
sig.text.push_str(&pprust::bounds_to_string(bounds));
}
sig.text.push_str(" = ");
let ty = ty.make(offset + sig.text.len(), id, scx)?;
sig.text.push_str(&ty.text);
sig.text.push(';');

Ok(sig)
Ok(merge_sigs(sig.text.clone(), vec![sig, ty]))
}
ast::ItemKind::Ty(ref ty, ref generics) => {
ast::ItemKind::OpaqueTy(ref bounds, ref generics) => {
let text = "type ".to_owned();
let mut sig = name_and_generics(text, offset, generics, self.id, self.ident, scx)?;

sig.text.push_str(" = ");
let ty = ty.make(offset + sig.text.len(), id, scx)?;
sig.text.push_str(&ty.text);
sig.text.push_str(" = impl ");
sig.text.push_str(&pprust::bounds_to_string(bounds));
sig.text.push(';');

Ok(merge_sigs(sig.text.clone(), vec![sig, ty]))
Ok(sig)
}
ast::ItemKind::Enum(_, ref generics) => {
let text = "enum ".to_owned();
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/wfcheck.rs
Expand Up @@ -219,7 +219,7 @@ fn check_associated_item(
}
}
ty::AssocKind::OpaqueTy => {
// do nothing, opaque types check themselves
// Do nothing: opaque types check themselves.
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/outlives/implicit_infer.rs
Expand Up @@ -296,7 +296,7 @@ pub fn check_explicit_predicates<'tcx>(
// struct MyStruct<'x, X> { field: Box<dyn Trait<'x, X>> }
// ```
//
// The `where Self: 'a` predicate refers to the *opaque, hidden type*
// The `where Self: 'a` predicate refers to the *existential, hidden type*
// that is represented by the `dyn Trait`, not to the `X` type parameter
// (or any other generic parameter) declared on `MyStruct`.
//
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-60662.stdout
Expand Up @@ -10,5 +10,5 @@ extern crate std;
trait Animal { }

fn main() {
pub type ServeFut= impl : Animal;
pub type ServeFut = impl Animal;
}
2 changes: 1 addition & 1 deletion src/test/ui/traits/trait-bounds-in-arc.rs
@@ -1,6 +1,6 @@
// run-pass
#![allow(unused_must_use)]
// Tests that a heterogeneous list of opaque types can be put inside an Arc
// Tests that a heterogeneous list of existential `dyn` types can be put inside an Arc
// and shared between threads as long as all types fulfill Send.

// ignore-emscripten no threads support
Expand Down
89 changes: 0 additions & 89 deletions src/test/ui/type-alias-impl-trait/type-alias-impl-trait-pass.rs

This file was deleted.

File renamed without changes.

0 comments on commit b049221

Please sign in to comment.