Skip to content

impl Trait binary operations #50626

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

impl Trait binary operations #50626

DutchGhost opened this issue May 10, 2018 · 1 comment
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

Comments

@DutchGhost
Copy link
Contributor

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

@shepmaster shepmaster added A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. labels May 10, 2018
@FreeFull
Copy link
Contributor

This might be the same issue as #49376

leoyvens added a commit to leoyvens/rust that referenced this issue May 12, 2018
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
…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
leoyvens added a commit to leoyvens/rust that referenced this issue May 14, 2018
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 pushed a commit to pietroalbini/rust that referenced this issue May 15, 2018
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 pushed a commit to Mark-Simulacrum/rust that referenced this issue May 24, 2018
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
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Projects
None yet
Development

No branches or pull requests

3 participants