Skip to content
This repository was archived by the owner on May 23, 2024. It is now read-only.

ices/93955.rs: fixed with errors #1186

Merged
merged 1 commit into from
Mar 26, 2022
Merged

ices/93955.rs: fixed with errors #1186

merged 1 commit into from
Mar 26, 2022

Conversation

github-actions[bot]
Copy link
Contributor

Issue: rust-lang/rust#93955

use std::ops::Add;
struct Point<T> {
    x: T,
    y: T,
}

impl<'a, T> Add for &'a Point<T>
where
    for<'x> &'x T: Add<Output = T>,
{
    type Output = Point<T>;
    fn add(self, rhs: Self) -> Self::Output {
        Point {
            x: &self.x + &rhs.x,
            y: &self.y + &rhs.y,
        }
    }
}

fn add<T, U>(x: T, y: T) -> T
where
    T: From<U>,
    for<'x> &'x T: Add<Output = U>,
{
    T::from(&x + &y)
}

fn main() {
    let x = 2;
    let y = 3;
    //let a = add(x, y); // E0275
    let b = add::<i32>(x, y); // ICE
    //let c = add::<i32, i32>(x, y); // works
}
=== stdout ===
=== stderr ===
error[E0107]: this function takes 2 generic arguments but 1 generic argument was supplied
  --> /home/runner/work/glacier/glacier/ices/93955.rs:32:13
   |
32 |     let b = add::<i32>(x, y); // ICE
   |             ^^^   --- supplied 1 generic argument
   |             |
   |             expected 2 generic arguments
   |
note: function defined here, with 2 generic parameters: `T`, `U`
  --> /home/runner/work/glacier/glacier/ices/93955.rs:20:4
   |
20 | fn add<T, U>(x: T, y: T) -> T
   |    ^^^ -  -
help: add missing generic argument
   |
32 |     let b = add::<i32, U>(x, y); // ICE
   |                      +++

error: aborting due to previous error

For more information about this error, try `rustc --explain E0107`.
==============

=== stdout ===
=== stderr ===
error[E0107]: this function takes 2 generic arguments but 1 generic argument was supplied
  --> /home/runner/work/glacier/glacier/ices/93955.rs:32:13
   |
32 |     let b = add::<i32>(x, y); // ICE
   |             ^^^   --- supplied 1 generic argument
   |             |
   |             expected 2 generic arguments
   |
note: function defined here, with 2 generic parameters: `T`, `U`
  --> /home/runner/work/glacier/glacier/ices/93955.rs:20:4
   |
20 | fn add<T, U>(x: T, y: T) -> T
   |    ^^^ -  -
help: add missing generic argument
   |
32 |     let b = add::<i32, U>(x, y); // ICE
   |                      +++

error: aborting due to previous error

For more information about this error, try `rustc --explain E0107`.
==============
@Alexendoo Alexendoo merged commit c17432a into master Mar 26, 2022
@Alexendoo Alexendoo deleted the autofix/ices/93955.rs branch March 26, 2022 12:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants