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

impl Trait binary operations #50626

Closed
DutchGhost opened this Issue May 10, 2018 · 1 comment

Comments

Projects
None yet
3 participants
@DutchGhost
Copy link

DutchGhost commented May 10, 2018

having a function signature like the following, results in a stack overflow during compilation on rustc 1.26.0 (a775680 2018-05-07), rustc 1.26.0-beta.18 (2018-05-03 1f200ac), and rustc 1.27.0-nightly (e5f80f2 2018-05-09)

fn test_impl_Add() -> impl std::ops::Add {1 + 1}
fn test_impl_Sub() -> impl std::ops::Sub {1 - 1}
fn test_impl_Mul() -> impl std::ops::Mul {1 * 1}
fn test_impl_Div() -> impl std::ops::Div {2 / 1}

fn test_impl_AddAssign() -> impl std::ops::AddAssign { 1 }
fn test_impl_SubAssign() -> impl std::ops::SubAssign { 1 }
fn test_impl_MulAssign() -> impl std::ops::MulAssign { 1 }
fn test_impl_DivAssign() -> impl std::ops::DivAssign { 1 }

Adding the Output parameter, like the example below, still results in a stack overflow:

fn test_impl_Add() -> impl std::ops::Add<Output = i32> {1 + 1}
fn test_impl_Sub() -> impl std::ops::Sub<Output = i32> {1 - 1}
fn test_impl_Mul() -> impl std::ops::Mul<Output = i32> {1 * 1}
fn test_impl_Div() -> impl std::ops::Div<Output = i32> {2 / 1}

A signature looking like fn test_iml_add() -> impl std::ops::Add<u32> {1 + 1} however does compile.

A playground link to make things more clear: https://play.rust-lang.org/?gist=9990fff6d401794400ba4d424ec89f54&version=beta&mode=debug

@FreeFull

This comment has been minimized.

Copy link
Contributor

FreeFull commented May 10, 2018

This might be the same issue as #49376

leodasvacas added a commit to leodasvacas/rust that referenced this issue May 12, 2018

Fix self referential impl Trait substitutions
A high impact bug because a lot of common traits use a `Self`
substitution by default. Should be backported to beta.

There was a check for this which wasn't catching all cases, it was made
more robust.

Fixes rust-lang#49376
Fixes rust-lang#50626

r? @petrochenkov

bors added a commit that referenced this issue May 14, 2018

Auto merge of #50694 - leodasvacas:fix-impl-trait-self-substitution, …
…r=petrochenkov

Fix self referential impl Trait substitutions

A high impact bug because a lot of common traits use a `Self` substitution by default. Should be backported to beta.

There was a check for this which wasn't catching all cases, it was made more robust.

Fixes #49376
Fixes #50626

r? @petrochenkov

@bors bors closed this in #50694 May 14, 2018

leodasvacas added a commit to leodasvacas/rust that referenced this issue May 14, 2018

Fix self referential impl Trait substitutions
A high impact bug because a lot of common traits use a `Self`
substitution by default. Should be backported to beta.

There was a check for this which wasn't catching all cases, it was made
more robust.

Fixes rust-lang#49376
Fixes rust-lang#50626

r? @petrochenkov

pietroalbini added a commit to pietroalbini/rust that referenced this issue May 15, 2018

Fix self referential impl Trait substitutions
A high impact bug because a lot of common traits use a `Self`
substitution by default. Should be backported to beta.

There was a check for this which wasn't catching all cases, it was made
more robust.

Fixes rust-lang#49376
Fixes rust-lang#50626

r? @petrochenkov

Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue May 24, 2018

Fix self referential impl Trait substitutions
A high impact bug because a lot of common traits use a `Self`
substitution by default. Should be backported to beta.

There was a check for this which wasn't catching all cases, it was made
more robust.

Fixes rust-lang#49376
Fixes rust-lang#50626

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