Collect inherent impls in unnamed consts

This commit is contained in:
Jonas Schievink 2021-04-19 01:06:26 +02:00
parent b777d46ae6
commit 20c27dbdbe
2 changed files with 62 additions and 17 deletions

View file

@ -1294,7 +1294,7 @@ mod b {
}
#[test]
fn impl_in_unnamed_const() {
fn trait_impl_in_unnamed_const() {
check_types(
r#"
struct S;
@ -1314,3 +1314,38 @@ fn f() {
"#,
);
}
#[test]
fn inherent_impl_in_unnamed_const() {
check_types(
r#"
struct S;
const _: () = {
impl S {
fn method(&self) -> u16 { 0 }
pub(super) fn super_method(&self) -> u16 { 0 }
pub(crate) fn crate_method(&self) -> u16 { 0 }
pub fn pub_method(&self) -> u16 { 0 }
}
};
fn f() {
S.method();
//^^^^^^^^^^ u16
S.super_method();
//^^^^^^^^^^^^^^^^ u16
S.crate_method();
//^^^^^^^^^^^^^^^^ u16
S.pub_method();
//^^^^^^^^^^^^^^ u16
}
"#,
);
}