From 28a76a90009d605349babcd2755962ab93913327 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Tue, 26 Jun 2018 13:28:02 +0200 Subject: [PATCH] Don't inspect the generated existential type items --- src/librustc_typeck/collect.rs | 21 +------ src/test/ui/error-codes/E0657.rs | 4 +- src/test/ui/error-codes/E0657.stderr | 23 +------- src/test/ui/impl-trait/auto-trait-leak.rs | 2 - src/test/ui/impl-trait/auto-trait-leak.stderr | 56 +++---------------- src/test/ui/impl_trait_projections.rs | 5 +- src/test/ui/impl_trait_projections.stderr | 33 +---------- 7 files changed, 20 insertions(+), 124 deletions(-) diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index c24e20c569909..a537b7d41c44b 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -419,7 +419,7 @@ fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId) { convert_variant_ctor(tcx, struct_def.id()); } }, - hir::ItemExistential(..) | + hir::ItemExistential(..) => {} hir::ItemTy(..) | hir::ItemStatic(..) | hir::ItemConst(..) | hir::ItemFn(..) => { tcx.generics_of(def_id); tcx.type_of(def_id); @@ -1066,24 +1066,7 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ItemExistential(hir::ExistTy { impl_trait_fn: None, .. }) => unimplemented!(), // existential types desugared from impl Trait ItemExistential(hir::ExistTy { impl_trait_fn: Some(owner), .. }) => { - tcx.typeck_tables_of(owner).concrete_existential_types - .get(&def_id) - .cloned() - .unwrap_or_else(|| { - // This can occur if some error in the - // owner fn prevented us from populating - // the `concrete_existential_types` table. - tcx.sess.delay_span_bug( - DUMMY_SP, - &format!( - "owner {:?} has no existential type for {:?} in its tables", - owner, - def_id, - ), - ); - - tcx.types.err - }) + tcx.typeck_tables_of(owner).concrete_existential_types[&def_id] }, ItemTrait(..) | ItemTraitAlias(..) | ItemMod(..) | diff --git a/src/test/ui/error-codes/E0657.rs b/src/test/ui/error-codes/E0657.rs index 05a4b8b3544f5..af91c9e264911 100644 --- a/src/test/ui/error-codes/E0657.rs +++ b/src/test/ui/error-codes/E0657.rs @@ -19,7 +19,7 @@ fn free_fn_capture_hrtb_in_impl_trait() -> Box Id>> //~^ ERROR `impl Trait` can only capture lifetimes bound at the fn or impl level [E0657] { - () //~ ERROR mismatched types + Box::new(()) } struct Foo; @@ -28,7 +28,7 @@ impl Foo { -> Box Id>> //~^ ERROR `impl Trait` can only capture lifetimes bound at the fn or impl level { - () //~ ERROR mismatched types + Box::new(()) } } diff --git a/src/test/ui/error-codes/E0657.stderr b/src/test/ui/error-codes/E0657.stderr index fb7f88d5ca977..737ae3a163ac2 100644 --- a/src/test/ui/error-codes/E0657.stderr +++ b/src/test/ui/error-codes/E0657.stderr @@ -10,25 +10,6 @@ error[E0657]: `impl Trait` can only capture lifetimes bound at the fn or impl le LL | -> Box Id>> | ^^ -error[E0308]: mismatched types - --> $DIR/E0657.rs:22:5 - | -LL | () //~ ERROR mismatched types - | ^^ expected struct `std::boxed::Box`, found () - | - = note: expected type `std::boxed::Box<(dyn Id<_> + 'static)>` - found type `()` - -error[E0308]: mismatched types - --> $DIR/E0657.rs:31:9 - | -LL | () //~ ERROR mismatched types - | ^^ expected struct `std::boxed::Box`, found () - | - = note: expected type `std::boxed::Box<(dyn Id<_> + 'static)>` - found type `()` - -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors -Some errors occurred: E0308, E0657. -For more information about an error, try `rustc --explain E0308`. +For more information about this error, try `rustc --explain E0657`. diff --git a/src/test/ui/impl-trait/auto-trait-leak.rs b/src/test/ui/impl-trait/auto-trait-leak.rs index f6b64b394fc12..a594ee8aab42a 100644 --- a/src/test/ui/impl-trait/auto-trait-leak.rs +++ b/src/test/ui/impl-trait/auto-trait-leak.rs @@ -23,9 +23,7 @@ fn main() { // return type, which can't depend on the obligation. fn cycle1() -> impl Clone { //~^ ERROR cycle detected - //~| ERROR cycle detected send(cycle2().clone()); - //~^ ERROR `std::rc::Rc` cannot be sent between threads safely Rc::new(Cell::new(5)) } diff --git a/src/test/ui/impl-trait/auto-trait-leak.stderr b/src/test/ui/impl-trait/auto-trait-leak.stderr index b34facd2d39ce..490817c46f811 100644 --- a/src/test/ui/impl-trait/auto-trait-leak.stderr +++ b/src/test/ui/impl-trait/auto-trait-leak.stderr @@ -1,67 +1,29 @@ -error[E0391]: cycle detected when processing `cycle1::{{exist-impl-Trait}}` - --> $DIR/auto-trait-leak.rs:24:16 - | -LL | fn cycle1() -> impl Clone { - | ^^^^^^^^^^ - | -note: ...which requires processing `cycle1`... +error[E0391]: cycle detected when processing `cycle1` --> $DIR/auto-trait-leak.rs:24:1 | LL | fn cycle1() -> impl Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | note: ...which requires evaluating trait selection obligation `impl std::clone::Clone: std::marker::Send`... note: ...which requires processing `cycle2::{{exist-impl-Trait}}`... - --> $DIR/auto-trait-leak.rs:33:16 + --> $DIR/auto-trait-leak.rs:31:16 | LL | fn cycle2() -> impl Clone { | ^^^^^^^^^^ note: ...which requires processing `cycle2`... - --> $DIR/auto-trait-leak.rs:33:1 + --> $DIR/auto-trait-leak.rs:31:1 | LL | fn cycle2() -> impl Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^ note: ...which requires evaluating trait selection obligation `impl std::clone::Clone: std::marker::Send`... - = note: ...which again requires processing `cycle1::{{exist-impl-Trait}}`, completing the cycle - -error[E0391]: cycle detected when processing `cycle1::{{exist-impl-Trait}}` +note: ...which requires processing `cycle1::{{exist-impl-Trait}}`... --> $DIR/auto-trait-leak.rs:24:16 | LL | fn cycle1() -> impl Clone { | ^^^^^^^^^^ - | -note: ...which requires processing `cycle1`... - --> $DIR/auto-trait-leak.rs:24:1 - | -LL | fn cycle1() -> impl Clone { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires evaluating trait selection obligation `impl std::clone::Clone: std::marker::Send`... -note: ...which requires processing `cycle2::{{exist-impl-Trait}}`... - --> $DIR/auto-trait-leak.rs:33:16 - | -LL | fn cycle2() -> impl Clone { - | ^^^^^^^^^^ -note: ...which requires processing `cycle2`... - --> $DIR/auto-trait-leak.rs:33:1 - | -LL | fn cycle2() -> impl Clone { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: ...which again requires processing `cycle1::{{exist-impl-Trait}}`, completing the cycle - -error[E0277]: `std::rc::Rc` cannot be sent between threads safely - --> $DIR/auto-trait-leak.rs:27:5 - | -LL | send(cycle2().clone()); - | ^^^^ `std::rc::Rc` cannot be sent between threads safely - | - = help: within `impl std::clone::Clone`, the trait `std::marker::Send` is not implemented for `std::rc::Rc` - = note: required because it appears within the type `impl std::clone::Clone` -note: required by `send` - --> $DIR/auto-trait-leak.rs:16:1 - | -LL | fn send(_: T) {} - | ^^^^^^^^^^^^^^^^^^^^^^ + = note: ...which again requires processing `cycle1`, completing the cycle +note: cycle used when type-checking all item bodies -error: aborting due to 3 previous errors +error: aborting due to previous error -Some errors occurred: E0277, E0391. -For more information about an error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0391`. diff --git a/src/test/ui/impl_trait_projections.rs b/src/test/ui/impl_trait_projections.rs index b64caccd98abe..57a0040600a25 100644 --- a/src/test/ui/impl_trait_projections.rs +++ b/src/test/ui/impl_trait_projections.rs @@ -34,9 +34,8 @@ fn projection_with_named_trait_is_disallowed(x: impl Iterator) fn projection_with_named_trait_inside_path_is_disallowed() -> <::std::ops::Range as Iterator>::Item //~^ ERROR `impl Trait` is not allowed in path parameters -//~| ERROR trait bound `impl std::fmt::Debug: std::iter::Step` is not satisfied -{ //~ ERROR trait bound `impl std::fmt::Debug: std::iter::Step` is not satisfied - (1i32..100).next().unwrap() //~ ERROR mismatched types +{ + (1i32..100).next().unwrap() } fn projection_from_impl_trait_inside_dyn_trait_is_disallowed() diff --git a/src/test/ui/impl_trait_projections.stderr b/src/test/ui/impl_trait_projections.stderr index b495d4b4b010b..f6d58984ecef7 100644 --- a/src/test/ui/impl_trait_projections.stderr +++ b/src/test/ui/impl_trait_projections.stderr @@ -17,7 +17,7 @@ LL | -> <::std::ops::Range as Iterator>::Item | ^^^^^^^^^^ error[E0667]: `impl Trait` is not allowed in path parameters - --> $DIR/impl_trait_projections.rs:43:29 + --> $DIR/impl_trait_projections.rs:42:29 | LL | -> as Iterator>::Item | ^^^^^^^^^^ @@ -30,34 +30,7 @@ LL | fn projection_is_disallowed(x: impl Iterator) -> ::Item { | = note: specify the type using the syntax `::Item` -error[E0277]: the trait bound `impl std::fmt::Debug: std::iter::Step` is not satisfied - --> $DIR/impl_trait_projections.rs:38:1 - | -LL | / { //~ ERROR trait bound `impl std::fmt::Debug: std::iter::Step` is not satisfied -LL | | (1i32..100).next().unwrap() //~ ERROR mismatched types -LL | | } - | |_^ the trait `std::iter::Step` is not implemented for `impl std::fmt::Debug` - | - = note: required because of the requirements on the impl of `std::iter::Iterator` for `std::ops::Range` - -error[E0308]: mismatched types - --> $DIR/impl_trait_projections.rs:39:5 - | -LL | (1i32..100).next().unwrap() //~ ERROR mismatched types - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected anonymized type, found i32 - | - = note: expected type `impl std::fmt::Debug` - found type `i32` - -error[E0277]: the trait bound `impl std::fmt::Debug: std::iter::Step` is not satisfied - --> $DIR/impl_trait_projections.rs:35:8 - | -LL | -> <::std::ops::Range as Iterator>::Item - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::iter::Step` is not implemented for `impl std::fmt::Debug` - | - = note: required because of the requirements on the impl of `std::iter::Iterator` for `std::ops::Range` - -error: aborting due to 8 previous errors +error: aborting due to 5 previous errors -Some errors occurred: E0223, E0277, E0308, E0667. +Some errors occurred: E0223, E0667. For more information about an error, try `rustc --explain E0223`.