Fix tests that depended on loose visibility restriction

This commit is contained in:
Ryo Yoshida 2022-11-11 19:59:52 +09:00
parent e75afebeb2
commit 19306c070d
No known key found for this signature in database
GPG key ID: E25698A930586171
12 changed files with 90 additions and 89 deletions

View file

@ -58,9 +58,9 @@ extern {
"#, "#,
expect![[r#" expect![[r#"
crate crate
E: t E: _
S: t v S: t v
V: t v V: _
foo: t foo: t
crate::foo crate::foo
@ -307,7 +307,7 @@ pub struct FromLib;
Bar: t v Bar: t v
crate::foo crate::foo
Bar: t v Bar: _
FromLib: t v FromLib: t v
"#]], "#]],
); );

View file

@ -119,7 +119,7 @@ use foo::*;
use foo::bar::*; use foo::bar::*;
//- /foo/mod.rs //- /foo/mod.rs
mod bar; pub mod bar;
fn Foo() {}; fn Foo() {};
pub struct Foo {}; pub struct Foo {};
@ -132,6 +132,7 @@ pub(crate) struct PubCrateStruct;
crate crate
Foo: t Foo: t
PubCrateStruct: t v PubCrateStruct: t v
bar: t
foo: t foo: t
crate::foo crate::foo

View file

@ -580,7 +580,7 @@ fn module_resolution_decl_inside_inline_module_in_crate_root() {
//- /main.rs //- /main.rs
mod foo { mod foo {
#[path = "baz.rs"] #[path = "baz.rs"]
mod bar; pub mod bar;
} }
use self::foo::bar::Baz; use self::foo::bar::Baz;

View file

@ -164,16 +164,16 @@ fn infer_associated_method_with_modules() {
check_infer( check_infer(
r#" r#"
mod a { mod a {
struct A; pub struct A;
impl A { pub fn thing() -> A { A {} }} impl A { pub fn thing() -> A { A {} }}
} }
mod b { mod b {
struct B; pub struct B;
impl B { pub fn thing() -> u32 { 99 }} impl B { pub fn thing() -> u32 { 99 }}
mod c { pub mod c {
struct C; pub struct C;
impl C { pub fn thing() -> C { C {} }} impl C { pub fn thing() -> C { C {} }}
} }
} }
@ -186,22 +186,22 @@ fn infer_associated_method_with_modules() {
} }
"#, "#,
expect![[r#" expect![[r#"
55..63 '{ A {} }': A 59..67 '{ A {} }': A
57..61 'A {}': A 61..65 'A {}': A
125..131 '{ 99 }': u32 133..139 '{ 99 }': u32
127..129 '99': u32 135..137 '99': u32
201..209 '{ C {} }': C 217..225 '{ C {} }': C
203..207 'C {}': C 219..223 'C {}': C
240..324 '{ ...g(); }': () 256..340 '{ ...g(); }': ()
250..251 'x': A 266..267 'x': A
254..265 'a::A::thing': fn thing() -> A 270..281 'a::A::thing': fn thing() -> A
254..267 'a::A::thing()': A 270..283 'a::A::thing()': A
277..278 'y': u32 293..294 'y': u32
281..292 'b::B::thing': fn thing() -> u32 297..308 'b::B::thing': fn thing() -> u32
281..294 'b::B::thing()': u32 297..310 'b::B::thing()': u32
304..305 'z': C 320..321 'z': C
308..319 'c::C::thing': fn thing() -> C 324..335 'c::C::thing': fn thing() -> C
308..321 'c::C::thing()': C 324..337 'c::C::thing()': C
"#]], "#]],
); );
} }

View file

@ -214,7 +214,7 @@ fn infer_paths() {
fn a() -> u32 { 1 } fn a() -> u32 { 1 }
mod b { mod b {
fn c() -> u32 { 1 } pub fn c() -> u32 { 1 }
} }
fn test() { fn test() {
@ -225,13 +225,13 @@ fn test() {
expect![[r#" expect![[r#"
14..19 '{ 1 }': u32 14..19 '{ 1 }': u32
16..17 '1': u32 16..17 '1': u32
47..52 '{ 1 }': u32 51..56 '{ 1 }': u32
49..50 '1': u32 53..54 '1': u32
66..90 '{ ...c(); }': () 70..94 '{ ...c(); }': ()
72..73 'a': fn a() -> u32 76..77 'a': fn a() -> u32
72..75 'a()': u32 76..79 'a()': u32
81..85 'b::c': fn c() -> u32 85..89 'b::c': fn c() -> u32
81..87 'b::c()': u32 85..91 'b::c()': u32
"#]], "#]],
); );
} }
@ -1856,7 +1856,7 @@ fn not_shadowing_module_by_primitive() {
check_types( check_types(
r#" r#"
//- /str.rs //- /str.rs
fn foo() -> u32 {0} pub fn foo() -> u32 {0}
//- /main.rs //- /main.rs
mod str; mod str;

View file

@ -1706,7 +1706,7 @@ fn where_clause_trait_in_scope_for_method_resolution() {
check_types( check_types(
r#" r#"
mod foo { mod foo {
trait Trait { pub trait Trait {
fn foo(&self) -> u32 { 0 } fn foo(&self) -> u32 { 0 }
} }
} }
@ -1723,7 +1723,7 @@ fn super_trait_method_resolution() {
check_infer( check_infer(
r#" r#"
mod foo { mod foo {
trait SuperTrait { pub trait SuperTrait {
fn foo(&self) -> u32 {} fn foo(&self) -> u32 {}
} }
} }
@ -1735,15 +1735,15 @@ fn test<T: Trait1, U: Trait2>(x: T, y: U) {
y.foo(); y.foo();
}"#, }"#,
expect![[r#" expect![[r#"
49..53 'self': &Self 53..57 'self': &Self
62..64 '{}': u32 66..68 '{}': u32
181..182 'x': T 185..186 'x': T
187..188 'y': U 191..192 'y': U
193..222 '{ ...o(); }': () 197..226 '{ ...o(); }': ()
199..200 'x': T 203..204 'x': T
199..206 'x.foo()': u32 203..210 'x.foo()': u32
212..213 'y': U 216..217 'y': U
212..219 'y.foo()': u32 216..223 'y.foo()': u32
"#]], "#]],
); );
} }
@ -1754,7 +1754,7 @@ fn super_trait_impl_trait_method_resolution() {
r#" r#"
//- minicore: sized //- minicore: sized
mod foo { mod foo {
trait SuperTrait { pub trait SuperTrait {
fn foo(&self) -> u32 {} fn foo(&self) -> u32 {}
} }
} }
@ -1764,12 +1764,12 @@ fn test(x: &impl Trait1) {
x.foo(); x.foo();
}"#, }"#,
expect![[r#" expect![[r#"
49..53 'self': &Self 53..57 'self': &Self
62..64 '{}': u32 66..68 '{}': u32
115..116 'x': &impl Trait1 119..120 'x': &impl Trait1
132..148 '{ ...o(); }': () 136..152 '{ ...o(); }': ()
138..139 'x': &impl Trait1 142..143 'x': &impl Trait1
138..145 'x.foo()': u32 142..149 'x.foo()': u32
"#]], "#]],
); );
} }

View file

@ -379,14 +379,14 @@ impl Foo for S {
r#" r#"
mod foo { mod foo {
pub struct Bar; pub struct Bar;
trait Foo { fn foo(&self, bar: Bar); } pub trait Foo { fn foo(&self, bar: Bar); }
} }
struct S; struct S;
impl foo::Foo for S { $0 }"#, impl foo::Foo for S { $0 }"#,
r#" r#"
mod foo { mod foo {
pub struct Bar; pub struct Bar;
trait Foo { fn foo(&self, bar: Bar); } pub trait Foo { fn foo(&self, bar: Bar); }
} }
struct S; struct S;
impl foo::Foo for S { impl foo::Foo for S {
@ -439,14 +439,14 @@ impl bar::Foo for S {
r#" r#"
mod foo { mod foo {
pub struct Bar<T>; pub struct Bar<T>;
trait Foo { fn foo(&self, bar: Bar<u32>); } pub trait Foo { fn foo(&self, bar: Bar<u32>); }
} }
struct S; struct S;
impl foo::Foo for S { $0 }"#, impl foo::Foo for S { $0 }"#,
r#" r#"
mod foo { mod foo {
pub struct Bar<T>; pub struct Bar<T>;
trait Foo { fn foo(&self, bar: Bar<u32>); } pub trait Foo { fn foo(&self, bar: Bar<u32>); }
} }
struct S; struct S;
impl foo::Foo for S { impl foo::Foo for S {
@ -464,14 +464,14 @@ impl foo::Foo for S {
r#" r#"
mod foo { mod foo {
pub struct Bar<T>; pub struct Bar<T>;
trait Foo<T> { fn foo(&self, bar: Bar<T>); } pub trait Foo<T> { fn foo(&self, bar: Bar<T>); }
} }
struct S; struct S;
impl foo::Foo<u32> for S { $0 }"#, impl foo::Foo<u32> for S { $0 }"#,
r#" r#"
mod foo { mod foo {
pub struct Bar<T>; pub struct Bar<T>;
trait Foo<T> { fn foo(&self, bar: Bar<T>); } pub trait Foo<T> { fn foo(&self, bar: Bar<T>); }
} }
struct S; struct S;
impl foo::Foo<u32> for S { impl foo::Foo<u32> for S {
@ -489,7 +489,7 @@ impl foo::Foo<u32> for S {
add_missing_impl_members, add_missing_impl_members,
r#" r#"
mod foo { mod foo {
trait Foo<T> { fn foo(&self, bar: T); } pub trait Foo<T> { fn foo(&self, bar: T); }
pub struct Param; pub struct Param;
} }
struct Param; struct Param;
@ -497,7 +497,7 @@ struct S;
impl foo::Foo<Param> for S { $0 }"#, impl foo::Foo<Param> for S { $0 }"#,
r#" r#"
mod foo { mod foo {
trait Foo<T> { fn foo(&self, bar: T); } pub trait Foo<T> { fn foo(&self, bar: T); }
pub struct Param; pub struct Param;
} }
struct Param; struct Param;
@ -518,7 +518,7 @@ impl foo::Foo<Param> for S {
mod foo { mod foo {
pub struct Bar<T>; pub struct Bar<T>;
impl Bar<T> { type Assoc = u32; } impl Bar<T> { type Assoc = u32; }
trait Foo { fn foo(&self, bar: Bar<u32>::Assoc); } pub trait Foo { fn foo(&self, bar: Bar<u32>::Assoc); }
} }
struct S; struct S;
impl foo::Foo for S { $0 }"#, impl foo::Foo for S { $0 }"#,
@ -526,7 +526,7 @@ impl foo::Foo for S { $0 }"#,
mod foo { mod foo {
pub struct Bar<T>; pub struct Bar<T>;
impl Bar<T> { type Assoc = u32; } impl Bar<T> { type Assoc = u32; }
trait Foo { fn foo(&self, bar: Bar<u32>::Assoc); } pub trait Foo { fn foo(&self, bar: Bar<u32>::Assoc); }
} }
struct S; struct S;
impl foo::Foo for S { impl foo::Foo for S {
@ -545,7 +545,7 @@ impl foo::Foo for S {
mod foo { mod foo {
pub struct Bar<T>; pub struct Bar<T>;
pub struct Baz; pub struct Baz;
trait Foo { fn foo(&self, bar: Bar<Baz>); } pub trait Foo { fn foo(&self, bar: Bar<Baz>); }
} }
struct S; struct S;
impl foo::Foo for S { $0 }"#, impl foo::Foo for S { $0 }"#,
@ -553,7 +553,7 @@ impl foo::Foo for S { $0 }"#,
mod foo { mod foo {
pub struct Bar<T>; pub struct Bar<T>;
pub struct Baz; pub struct Baz;
trait Foo { fn foo(&self, bar: Bar<Baz>); } pub trait Foo { fn foo(&self, bar: Bar<Baz>); }
} }
struct S; struct S;
impl foo::Foo for S { impl foo::Foo for S {
@ -571,14 +571,14 @@ impl foo::Foo for S {
r#" r#"
mod foo { mod foo {
pub trait Fn<Args> { type Output; } pub trait Fn<Args> { type Output; }
trait Foo { fn foo(&self, bar: dyn Fn(u32) -> i32); } pub trait Foo { fn foo(&self, bar: dyn Fn(u32) -> i32); }
} }
struct S; struct S;
impl foo::Foo for S { $0 }"#, impl foo::Foo for S { $0 }"#,
r#" r#"
mod foo { mod foo {
pub trait Fn<Args> { type Output; } pub trait Fn<Args> { type Output; }
trait Foo { fn foo(&self, bar: dyn Fn(u32) -> i32); } pub trait Foo { fn foo(&self, bar: dyn Fn(u32) -> i32); }
} }
struct S; struct S;
impl foo::Foo for S { impl foo::Foo for S {

View file

@ -261,12 +261,12 @@ fn main() {
} }
//- /foo.rs //- /foo.rs
enum Foo { pub enum Foo {
Bar, Bar,
} }
", ",
r" r"
enum Foo { pub enum Foo {
Bar, Bar,
Baz, Baz,
} }
@ -310,7 +310,7 @@ fn main() {
generate_enum_variant, generate_enum_variant,
r" r"
mod m { mod m {
enum Foo { pub enum Foo {
Bar, Bar,
} }
} }
@ -320,7 +320,7 @@ fn main() {
", ",
r" r"
mod m { mod m {
enum Foo { pub enum Foo {
Bar, Bar,
Baz, Baz,
} }
@ -516,10 +516,10 @@ mod foo;
use foo::Foo::Bar$0; use foo::Foo::Bar$0;
//- /foo.rs //- /foo.rs
enum Foo {} pub enum Foo {}
", ",
r" r"
enum Foo { pub enum Foo {
Bar, Bar,
} }
", ",

View file

@ -1324,7 +1324,7 @@ fn foo() {
generate_function, generate_function,
r" r"
mod bar { mod bar {
mod baz {} pub mod baz {}
} }
fn foo() { fn foo() {
@ -1333,7 +1333,7 @@ fn foo() {
", ",
r" r"
mod bar { mod bar {
mod baz { pub mod baz {
pub(crate) fn my_fn() { pub(crate) fn my_fn() {
${0:todo!()} ${0:todo!()}
} }

View file

@ -268,12 +268,12 @@ fn main() {
foo::Foo { bar: 3, $0baz: false}; foo::Foo { bar: 3, $0baz: false};
} }
//- /foo.rs //- /foo.rs
struct Foo { pub struct Foo {
bar: i32 bar: i32
} }
"#, "#,
r#" r#"
struct Foo { pub struct Foo {
bar: i32, bar: i32,
pub(crate) baz: bool pub(crate) baz: bool
} }

View file

@ -71,9 +71,9 @@ use a;
use a::{c, d::e}; use a::{c, d::e};
mod a { mod a {
mod c {} pub mod c {}
mod d { pub mod d {
mod e {} pub mod e {}
} }
} }
"#, "#,
@ -87,9 +87,9 @@ use a::{
}; };
mod a { mod a {
mod c {} pub mod c {}
mod d { pub mod d {
mod e {} pub mod e {}
} }
} }
"#, "#,
@ -116,11 +116,11 @@ use b;
); );
check_fix( check_fix(
r#" r#"
mod a { mod c {} } mod a { pub mod c {} }
use a::{c$0}; use a::{c$0};
"#, "#,
r#" r#"
mod a { mod c {} } mod a { pub mod c {} }
use a::c; use a::c;
"#, "#,
); );
@ -136,11 +136,11 @@ use a;
); );
check_fix( check_fix(
r#" r#"
mod a { mod c {} mod d { mod e {} } } mod a { pub mod c {} pub mod d { pub mod e {} } }
use a::{c, d::{e$0}}; use a::{c, d::{e$0}};
"#, "#,
r#" r#"
mod a { mod c {} mod d { mod e {} } } mod a { pub mod c {} pub mod d { pub mod e {} } }
use a::{c, d::e}; use a::{c, d::e};
"#, "#,
); );

View file

@ -289,10 +289,10 @@ mod b;
enum E { X(Foo$0) } enum E { X(Foo$0) }
//- /a.rs //- /a.rs
struct Foo; pub struct Foo;
//^^^ //^^^
//- /b.rs //- /b.rs
struct Foo; pub struct Foo;
"#, "#,
); );
} }