-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-trait-systemArea: Trait systemArea: Trait systemC-bugCategory: This is a bug.Category: This is a bug.E-hardCall for participation: Hard difficulty. Experience needed to fix: A lot.Call for participation: Hard difficulty. Experience needed to fix: A lot.P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
When compiling this program, the compiler fails with an infinitely recursive error message. The message makes no sense, as it contains types that aren't even in the program.
use std::ops::{Add, Sub};
struct Point2d<T> {
pub x: T,
pub y: T,
}
impl<'a, T> Sub<&'a Point2d<T>> for &'a Point2d<T>
where &'a T: Sub<&'a T, Output=T>,
{
type Output = Point2d<T>;
fn sub(self, other: &'a Point2d<T>) -> Self::Output { unimplemented!(); }
}
fn f1<'a, I>(x: &'a I)
where &'a I: Sub<Output=I> { unimplemented!(); }
fn main() {
let a = 123;
f1(&a);
}
This code won't do anything, but it should compile (I think). Instead, the compiler emits an infinite series of error messages like:
error[E0275]: overflow evaluating the requirement `&hashbrown::set::HashSet<_, _>: std::ops::Sub`
--> src\main.rs:28:5
|
28 | f1(&a);
| ^^
|
= help: consider adding a `#![recursion_limit="128"]` attribute to your crate
= note: required because of the requirements on the impl of `std::ops::Sub` for `&Point2d<hashbrown::set::HashSet<_, _>>`
= note: required because of the requirements on the impl of `std::ops::Sub` for `&Point2d<Point2d<hashbrown::set::HashSet<_, _>>>`
= note: required because of the requirements on the impl of `std::ops::Sub` for `&Point2d<Point2d<Point2d<hashbrown::set::HashSet<_, _>>>>`
= note: required because of the requirements on the impl of `std::ops::Sub` for `&Point2d<Point2d<Point2d<Point2d<hashbrown::set::HashSet<_, _>>>>>`
This program doesn't even use HashSet.
rustc 1.36.0-nightly (d628c2e 2019-05-05)
binary: rustc
commit-hash: d628c2e
commit-date: 2019-05-05
host: x86_64-pc-windows-msvc
release: 1.36.0-nightly
LLVM version: 8.0
Torrencem and Ri0njonas-schievink, comex, TheDan64, runiq and Ri0n
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-trait-systemArea: Trait systemArea: Trait systemC-bugCategory: This is a bug.Category: This is a bug.E-hardCall for participation: Hard difficulty. Experience needed to fix: A lot.Call for participation: Hard difficulty. Experience needed to fix: A lot.P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.