File tree Expand file tree Collapse file tree 3 files changed +43
-3
lines changed
src/tools/rust-analyzer/crates Expand file tree Collapse file tree 3 files changed +43
-3
lines changed Original file line number Diff line number Diff line change @@ -1252,7 +1252,11 @@ fn scope_for(
12521252 node : InFile < & SyntaxNode > ,
12531253) -> Option < ScopeId > {
12541254 node. ancestors_with_macros ( db. upcast ( ) )
1255- . take_while ( |it| !ast:: Item :: can_cast ( it. kind ( ) ) || ast:: MacroCall :: can_cast ( it. kind ( ) ) )
1255+ . take_while ( |it| {
1256+ !ast:: Item :: can_cast ( it. kind ( ) )
1257+ || ast:: MacroCall :: can_cast ( it. kind ( ) )
1258+ || ast:: Use :: can_cast ( it. kind ( ) )
1259+ } )
12561260 . filter_map ( |it| it. map ( ast:: Expr :: cast) . transpose ( ) )
12571261 . filter_map ( |it| source_map. node_expr ( it. as_ref ( ) ) ?. as_expr ( ) )
12581262 . find_map ( |it| scopes. scope_for ( it) )
Original file line number Diff line number Diff line change @@ -3272,4 +3272,22 @@ fn f() {
32723272 "# ,
32733273 ) ;
32743274 }
3275+
3276+ #[ test]
3277+ fn use_inside_body ( ) {
3278+ check (
3279+ r#"
3280+ fn main() {
3281+ mod nice_module {
3282+ pub(super) struct NiceStruct;
3283+ // ^^^^^^^^^^
3284+ }
3285+
3286+ use nice_module::NiceStruct$0;
3287+
3288+ let _ = NiceStruct;
3289+ }
3290+ "# ,
3291+ ) ;
3292+ }
32753293}
Original file line number Diff line number Diff line change @@ -2001,19 +2001,37 @@ impl Foo {
20012001 "foo" ,
20022002 r#"
20032003fn f($0self) -> i32 {
2004- use self as _;
20052004 self.i
20062005}
20072006"# ,
20082007 r#"
20092008fn f(foo: _) -> i32 {
2010- use self as _;
20112009 foo.i
20122010}
20132011"# ,
20142012 ) ;
20152013 }
20162014
2015+ #[ test]
2016+ fn no_type_value_ns_confuse ( ) {
2017+ // Test that we don't rename items from different namespaces.
2018+ check (
2019+ "bar" ,
2020+ r#"
2021+ struct foo {}
2022+ fn f(foo$0: i32) -> i32 {
2023+ use foo as _;
2024+ }
2025+ "# ,
2026+ r#"
2027+ struct foo {}
2028+ fn f(bar: i32) -> i32 {
2029+ use foo as _;
2030+ }
2031+ "# ,
2032+ ) ;
2033+ }
2034+
20172035 #[ test]
20182036 fn test_self_in_path_to_parameter ( ) {
20192037 check (
You can’t perform that action at this time.
0 commit comments