Skip to content

Commit dc7dbad

Browse files
authored
Merge pull request #148 from leodasvacas/shadowing-tests
Small things
2 parents 4a30113 + cc8b22b commit dc7dbad

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

src/ir/lowering.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ struct Env<'k> {
2121
type_ids: &'k TypeIds,
2222
type_kinds: &'k TypeKinds,
2323
associated_ty_infos: &'k AssociatedTyInfos,
24+
/// Parameter identifiers are used as keys, therefore
25+
/// all indentifiers in an environment must be unique (no shadowing).
2426
parameter_map: ParameterMap,
2527
}
2628

@@ -84,7 +86,7 @@ impl<'k> Env<'k> {
8486
.chain(binders)
8587
.collect();
8688
if parameter_map.len() != self.parameter_map.len() + len {
87-
bail!("duplicate parameters");
89+
bail!("duplicate or shadowed parameters");
8890
}
8991
Ok(Env {
9092
parameter_map,

src/ir/lowering/test.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ fn duplicate_parameters() {
362362
}
363363

364364
error_msg {
365-
"duplicate parameters"
365+
"duplicate or shadowed parameters"
366366
}
367367
}
368368

@@ -374,7 +374,18 @@ fn duplicate_parameters() {
374374
}
375375

376376
error_msg {
377-
"duplicate parameters"
377+
"duplicate or shadowed parameters"
378+
}
379+
}
380+
381+
lowering_error! {
382+
program {
383+
struct fn<'a> { }
384+
struct Foo<'a> {
385+
a: for<'a> fn<'a>
386+
}
387+
} error_msg {
388+
"duplicate or shadowed parameters"
378389
}
379390
}
380391
}

src/solve/infer.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ impl InferenceTable {
8989
crate fn new_universe(&mut self) -> UniverseIndex {
9090
let u = self.max_universe.next();
9191
self.max_universe = u;
92+
debug!("new_universe: {:?}", u);
9293
u
9394
}
9495

src/solve/test.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2371,6 +2371,7 @@ fn quantified_types() {
23712371
program {
23722372
trait Foo { }
23732373
struct fn<'a> { }
2374+
struct fn2<'a, 'b> { }
23742375
impl Foo for for<'a> fn<'a> { }
23752376
}
23762377

@@ -2380,6 +2381,12 @@ fn quantified_types() {
23802381
"Unique"
23812382
}
23822383

2384+
goal {
2385+
for<'a, 'b> fn2<'a, 'b> = for<'b, 'a> fn2<'a, 'b>
2386+
} yields {
2387+
"Unique"
2388+
}
2389+
23832390
goal {
23842391
forall<'a> { fn<'a>: Foo }
23852392
} yields {

0 commit comments

Comments
 (0)