Skip to content

Commit b049221

Browse files
committed
Address review comments
1 parent a45cde5 commit b049221

File tree

10 files changed

+24
-116
lines changed

10 files changed

+24
-116
lines changed

Diff for: src/librustc/hir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1929,7 +1929,7 @@ pub struct OpaqueTy {
19291929
pub origin: OpaqueTyOrigin,
19301930
}
19311931

1932-
/// Where the opaque type came from
1932+
/// From whence the opaque type came.
19331933
#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Debug, HashStable)]
19341934
pub enum OpaqueTyOrigin {
19351935
/// `type Foo = impl Trait;`

Diff for: src/librustc/hir/print.rs

+9-10
Original file line numberDiff line numberDiff line change
@@ -565,17 +565,12 @@ impl<'a> State<'a> {
565565
self.s.word(";");
566566
self.end(); // end the outer ibox
567567
}
568-
hir::ItemKind::OpaqueTy(ref exist) => {
568+
hir::ItemKind::OpaqueTy(ref opaque_ty) => {
569569
self.head(visibility_qualified(&item.vis, "type"));
570570
self.print_ident(item.ident);
571-
self.word_space("= impl");
572-
self.print_generic_params(&exist.generics.params);
573-
self.end(); // end the inner ibox
574-
575-
self.print_where_clause(&exist.generics.where_clause);
576-
self.s.space();
577-
let mut real_bounds = Vec::with_capacity(exist.bounds.len());
578-
for b in exist.bounds.iter() {
571+
self.print_generic_params(&opaque_ty.generics.params);
572+
let mut real_bounds = Vec::with_capacity(opaque_ty.bounds.len());
573+
for b in opaque_ty.bounds.iter() {
579574
if let GenericBound::Trait(ref ptr, hir::TraitBoundModifier::Maybe) = *b {
580575
self.s.space();
581576
self.word_space("for ?");
@@ -584,7 +579,11 @@ impl<'a> State<'a> {
584579
real_bounds.push(b);
585580
}
586581
}
587-
self.print_bounds(":", real_bounds);
582+
self.print_bounds(" = impl", real_bounds);
583+
584+
self.end(); // end the inner ibox
585+
586+
self.print_where_clause(&opaque_ty.generics.where_clause);
588587
self.s.word(";");
589588
self.end(); // end the outer ibox
590589
}

Diff for: src/librustc/ty/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ pub struct TypeckTables<'tcx> {
393393
pub free_region_map: FreeRegionMap<'tcx>,
394394

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

399399
/// Given the closure ID this map provides the list of UpvarIDs used by it.

Diff for: src/librustc_save_analysis/sig.rs

+9-11
Original file line numberDiff line numberDiff line change
@@ -438,28 +438,26 @@ impl Sig for ast::Item {
438438
refs: vec![],
439439
})
440440
}
441-
ast::ItemKind::OpaqueTy(ref bounds, ref generics) => {
441+
ast::ItemKind::Ty(ref ty, ref generics) => {
442442
let text = "type ".to_owned();
443443
let mut sig = name_and_generics(text, offset, generics, self.id, self.ident, scx)?;
444444

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

451-
Ok(sig)
450+
Ok(merge_sigs(sig.text.clone(), vec![sig, ty]))
452451
}
453-
ast::ItemKind::Ty(ref ty, ref generics) => {
452+
ast::ItemKind::OpaqueTy(ref bounds, ref generics) => {
454453
let text = "type ".to_owned();
455454
let mut sig = name_and_generics(text, offset, generics, self.id, self.ident, scx)?;
456455

457-
sig.text.push_str(" = ");
458-
let ty = ty.make(offset + sig.text.len(), id, scx)?;
459-
sig.text.push_str(&ty.text);
456+
sig.text.push_str(" = impl ");
457+
sig.text.push_str(&pprust::bounds_to_string(bounds));
460458
sig.text.push(';');
461459

462-
Ok(merge_sigs(sig.text.clone(), vec![sig, ty]))
460+
Ok(sig)
463461
}
464462
ast::ItemKind::Enum(_, ref generics) => {
465463
let text = "enum ".to_owned();

Diff for: src/librustc_typeck/check/wfcheck.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ fn check_associated_item(
219219
}
220220
}
221221
ty::AssocKind::OpaqueTy => {
222-
// do nothing, opaque types check themselves
222+
// Do nothing: opaque types check themselves.
223223
}
224224
}
225225

Diff for: src/librustc_typeck/outlives/implicit_infer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ pub fn check_explicit_predicates<'tcx>(
296296
// struct MyStruct<'x, X> { field: Box<dyn Trait<'x, X>> }
297297
// ```
298298
//
299-
// The `where Self: 'a` predicate refers to the *opaque, hidden type*
299+
// The `where Self: 'a` predicate refers to the *existential, hidden type*
300300
// that is represented by the `dyn Trait`, not to the `X` type parameter
301301
// (or any other generic parameter) declared on `MyStruct`.
302302
//

Diff for: src/test/ui/issues/issue-60662.stdout

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ extern crate std;
1010
trait Animal { }
1111

1212
fn main() {
13-
pub type ServeFut= impl : Animal;
13+
pub type ServeFut = impl Animal;
1414
}

Diff for: src/test/ui/traits/trait-bounds-in-arc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// run-pass
22
#![allow(unused_must_use)]
3-
// Tests that a heterogeneous list of opaque types can be put inside an Arc
3+
// Tests that a heterogeneous list of existential `dyn` types can be put inside an Arc
44
// and shared between threads as long as all types fulfill Send.
55

66
// ignore-emscripten no threads support

Diff for: src/test/ui/type-alias-impl-trait/type-alias-impl-trait-pass.rs

-89
This file was deleted.

0 commit comments

Comments
 (0)