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

Don't inspect the generated existential type items #51773

Merged
merged 1 commit into from
Jun 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 2 additions & 19 deletions src/librustc_typeck/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(..) => {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this always something we will want to skip...? or will we want to do something here when user-given predicates are permitted?

Actually I think in general that we've been wanting to get rid of this part of the code anyway, which maybe isn't strictly needed anymore? (Though it may be good for generating the errors in a predictable order)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will want this even before user defined existentials. It's just that right now these existential types can't really live on their own because their generics still refer to generics of their parent function. Once we get that fully separated, there won't be any more code running twice with different settings on this node

hir::ItemTy(..) | hir::ItemStatic(..) | hir::ItemConst(..) | hir::ItemFn(..) => {
tcx.generics_of(def_id);
tcx.type_of(def_id);
Expand Down Expand Up @@ -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(..) |
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/error-codes/E0657.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn free_fn_capture_hrtb_in_impl_trait()
-> Box<for<'a> Id<impl Lt<'a>>>
//~^ ERROR `impl Trait` can only capture lifetimes bound at the fn or impl level [E0657]
{
() //~ ERROR mismatched types
Box::new(())
}

struct Foo;
Expand All @@ -28,7 +28,7 @@ impl Foo {
-> Box<for<'a> Id<impl Lt<'a>>>
//~^ ERROR `impl Trait` can only capture lifetimes bound at the fn or impl level
{
() //~ ERROR mismatched types
Box::new(())
}
}

Expand Down
23 changes: 2 additions & 21 deletions src/test/ui/error-codes/E0657.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,6 @@ error[E0657]: `impl Trait` can only capture lifetimes bound at the fn or impl le
LL | -> Box<for<'a> Id<impl Lt<'a>>>
| ^^

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`.
2 changes: 0 additions & 2 deletions src/test/ui/impl-trait/auto-trait-leak.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string::String>` cannot be sent between threads safely

Rc::new(Cell::new(5))
}
Expand Down
56 changes: 9 additions & 47 deletions src/test/ui/impl-trait/auto-trait-leak.stderr
Original file line number Diff line number Diff line change
@@ -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<std::string::String>` cannot be sent between threads safely
--> $DIR/auto-trait-leak.rs:27:5
|
LL | send(cycle2().clone());
| ^^^^ `std::rc::Rc<std::string::String>` cannot be sent between threads safely
|
= help: within `impl std::clone::Clone`, the trait `std::marker::Send` is not implemented for `std::rc::Rc<std::string::String>`
= 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: 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`.
5 changes: 2 additions & 3 deletions src/test/ui/impl_trait_projections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<impl Debug> 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()
Expand Down
33 changes: 3 additions & 30 deletions src/test/ui/impl_trait_projections.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ LL | -> <::std::ops::Range<impl Debug> 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 | -> <dyn Iterator<Item = impl Debug> as Iterator>::Item
| ^^^^^^^^^^
Expand All @@ -30,34 +30,7 @@ LL | fn projection_is_disallowed(x: impl Iterator) -> <impl Iterator>::Item {
|
= note: specify the type using the syntax `<impl std::iter::Iterator as Trait>::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<impl std::fmt::Debug>`

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<impl Debug> 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<impl std::fmt::Debug>`

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`.