Skip to content

Commit b6aadcf

Browse files
committed
feat(hygiene): Print erased regions as underscore lifetimes
1 parent 64794a6 commit b6aadcf

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

mutest-emit/src/analysis/ty.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,9 @@ pub mod print {
435435
Ok(Some(ast::mk::lifetime(sp, ident)))
436436
}
437437

438-
ty::RegionKind::ReVar(_) | ty::RegionKind::ReErased => Ok(None),
438+
ty::RegionKind::ReVar(_) => Ok(None),
439+
440+
ty::RegionKind::ReErased => Ok(Some(ast::mk::lifetime(sp, Ident::new(kw::UnderscoreLifetime, sp)))),
439441

440442
ty::RegionKind::ReError(_) => Err("encountered region error".to_owned()),
441443
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//@ build
2+
//@ stderr: empty
3+
4+
#![feature(decl_macro)]
5+
6+
#![allow(unused)]
7+
8+
macro m() {
9+
trait NestedTrait {
10+
fn nested_assoc_fn() -> Self;
11+
}
12+
13+
trait Trait {
14+
type GenericAssocTy<'a>: NestedTrait;
15+
}
16+
17+
// TEST: In the path referencing the assoc ty `Trait::GenericAssocTy`,
18+
// the region parameter is an erased region.
19+
// To create a valid path, this erased region must be represented
20+
// as the `'_` lifetime.
21+
fn test_call_to_nested_assoc_fn_through_generic_assoc_ty<T>()
22+
where
23+
T: Trait
24+
{
25+
let _ = T::GenericAssocTy::nested_assoc_fn();
26+
}
27+
}
28+
29+
m!();

0 commit comments

Comments
 (0)