You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
HKalbasi opened this issue
Jan 3, 2023
· 3 comments
Labels
T-langRelevant to the language team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.
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:
structFwherefor<'a>&'ai32:'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.
The text was updated successfully, but these errors were encountered:
inquisitivecrystal
added
T-lang
Relevant to the language team, which will review and decide on the PR/issue.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
labels
Jan 4, 2023
This comment perhaps sheds some light on this inconsistency being (somewhat) intentional: #100090 (comment)
compiler-errors
added
T-types
Relevant to the types team, which will review and decide on the PR/issue.
and removed
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
labels
Jan 4, 2023
With trivial_bounds, the Iterator case would behave similar to the higher-ranked case (able to compile the definition but not to call it due to unsatisfiable bounds). And I believe the idea is both would warn about the unsatisfiable definition, yes.
T-langRelevant to the language team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.
In this code I will get a compiler error:
But in this code there is no compiler error:
But if I use
F
, I will get a compiler error:Which is inconsistent behavior. I think either both of them should compile, or both of them should not.
The text was updated successfully, but these errors were encountered: