Skip to content

Higher kinded checks are deferred to the time of use #106426

Description

@hkalbasi

In this code I will get a compiler error:

struct F where i32: Iterator;
error[[E0277]](https://doc.rust-lang.org/stable/error-index.html#E0277): `i32` is not an iterator
 --> src/main.rs:2:20
  |
2 |     struct F where i32: Iterator;
  |                    ^^^^^^^^^^^^^ `i32` is not an iterator
  |
  = help: the trait `Iterator` is not implemented for `i32`
  = note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end`
  = help: see issue #48214

But in this code there is no compiler error:

struct F where for<'a> &'a i32: 'static;

But if I use F, I will get a compiler error:

struct F where for<'a> &'a i32: 'static;
let _x = F;
error: higher-ranked lifetime error
 --> src/main.rs:4:14
  |
4 |     let _x = F;
  |              ^
  |
  = note: could not prove `for<'a> &'a i32: 'static`

error: could not compile `playground` due to previous error

Which is inconsistent behavior. I think either both of them should compile, or both of them should not.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-langRelevant to the language teamT-typesRelevant to the types team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions