File: cycle-modulo-ambig-aliases.rs

package info (click to toggle)
rustc 1.85.0%2Bdfsg2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 893,176 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,051; lisp: 29; perl: 29; ruby: 19; sql: 11
file content (89 lines) | stat: -rw-r--r-- 2,254 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//@ compile-flags: -Znext-solver

// A regression test for #125269. We previously ended up
// recursively proving `&<_ as SpeciesPackedElem>::Assoc: Typed`
// for all aliases which ended up causing exponential blowup.
//
// This has been fixed by eagerly normalizing the associated
// type before computing the nested goals, resulting in an
// immediate inductive cycle.

pub trait Typed {}

pub struct SpeciesCases<E>(E);

pub trait SpeciesPackedElim {
    type Ogre;
    type Cyclops;
    type Wendigo;
    type Cavetroll;
    type Mountaintroll;
    type Swamptroll;
    type Dullahan;
    type Werewolf;
    type Occultsaurok;
    type Mightysaurok;
    type Slysaurok;
    type Mindflayer;
    type Minotaur;
    type Tidalwarrior;
    type Yeti;
    type Harvester;
    type Blueoni;
    type Redoni;
    type Cultistwarlord;
    type Cultistwarlock;
    type Huskbrute;
    type Tursus;
    type Gigasfrost;
    type AdletElder;
    type SeaBishop;
    type HaniwaGeneral;
    type TerracottaBesieger;
    type TerracottaDemolisher;
    type TerracottaPunisher;
    type TerracottaPursuer;
    type Cursekeeper;
}

impl<'b, E: SpeciesPackedElim> Typed for &'b SpeciesCases<E>
where
    &'b E::Ogre: Typed,
    &'b E::Cyclops: Typed,
    &'b E::Wendigo: Typed,
    &'b E::Cavetroll: Typed,
    &'b E::Mountaintroll: Typed,
    &'b E::Swamptroll: Typed,
    &'b E::Dullahan: Typed,
    &'b E::Werewolf: Typed,
    &'b E::Occultsaurok: Typed,
    &'b E::Mightysaurok: Typed,
    &'b E::Slysaurok: Typed,
    &'b E::Mindflayer: Typed,
    &'b E::Minotaur: Typed,
    &'b E::Tidalwarrior: Typed,
    &'b E::Yeti: Typed,
    &'b E::Harvester: Typed,
    &'b E::Blueoni: Typed,
    &'b E::Redoni: Typed,
    &'b E::Cultistwarlord: Typed,
    &'b E::Cultistwarlock: Typed,
    &'b E::Huskbrute: Typed,
    &'b E::Tursus: Typed,
    &'b E::Gigasfrost: Typed,
    &'b E::AdletElder: Typed,
    &'b E::SeaBishop: Typed,
    &'b E::HaniwaGeneral: Typed,
    &'b E::TerracottaBesieger: Typed,
    &'b E::TerracottaDemolisher: Typed,
    &'b E::TerracottaPunisher: Typed,
    &'b E::TerracottaPursuer: Typed,
    &'b E::Cursekeeper: Typed,
{}

fn foo<T: Typed>() {}

fn main() {
    foo::<&_>();
    //~^ ERROR overflow evaluating the requirement `&_: Typed`
}