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
llogiq opened this issue
Jun 21, 2015
· 2 comments
Labels
A-lintArea: New lintsE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.T-middleType: Probably requires verifiying types
It just occurred to me that this is a special case of a more general 'unbounded_recursion' lint, only for trait impls.
Manishearth
added
E-medium
Call for participation: Medium difficulty level problem and requires some initial experience.
T-middle
Type: Probably requires verifiying types
A-lint
Area: New lints
labels
Aug 11, 2015
This can be closed, Rust has a unconditional_recursion lint since v1.3 (2015-09-17) which warns exactly for that:
% cat a.rsuse std::default;pubstructA{x:i32}implDefaultforA{fndefault() -> A{A{ ..Default::default()}}}fnmain(){let test = A{ ..Default::default()};}
% rustc a.rs[…]
a.rs:8:5:10:6 warning:function cannot return without recurring,#[warn(unconditional_recursion)] on by default
a.rs:8fndefault() -> A{
a.rs:9A{ ..Default::default()}
a.rs:10}a.rs:9:15:9:33 note: recursive call site
a.rs:9A{ ..Default::default()}
^~~~~~~~~~~~~~~~~~
a.rs:8:5:10:6 help:a `loop` may express intention better if this is on purpose
[…]
^~~~
and there also is #428 for a more general recursion lint.
A-lintArea: New lintsE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.T-middleType: Probably requires verifiying types
On StackOverflow, someone suggested the compiler should keep them from implementing default in terms of itself.
Well, it's not exactly a common use case, but it's also pretty easy to spot.
The text was updated successfully, but these errors were encountered: