@@ -265,12 +265,15 @@ fn is_named_constructor(
265
265
} ;
266
266
let path = expr. path ( ) ?;
267
267
268
- // If it exists, use qualifying segment as the constructor name.
269
- // If not, use the last segment.
270
- let qual_seg = match path. qualifier ( ) {
271
- Some ( qual) => qual. segment ( ) ,
272
- None => path. segment ( ) ,
268
+ let callable = sema. type_of_expr ( & ast:: Expr :: PathExpr ( expr) ) ?. original . as_callable ( sema. db ) ;
269
+ let callable_kind = callable. map ( |it| it. kind ( ) ) ;
270
+ let qual_seg = match callable_kind {
271
+ Some ( hir:: CallableKind :: Function ( _) | hir:: CallableKind :: TupleEnumVariant ( _) ) => {
272
+ path. qualifier ( ) ?. segment ( )
273
+ }
274
+ _ => path. segment ( ) ,
273
275
} ?;
276
+
274
277
let ctor_name = match qual_seg. kind ( ) ? {
275
278
ast:: PathSegmentKind :: Name ( name_ref) => {
276
279
match qual_seg. generic_arg_list ( ) . map ( |it| it. generic_args ( ) ) {
@@ -1348,6 +1351,13 @@ fn main() {
1348
1351
//- minicore: try, option
1349
1352
use core::ops::ControlFlow;
1350
1353
1354
+ mod x {
1355
+ pub mod y { pub struct Foo; }
1356
+ pub struct Foo;
1357
+ pub enum AnotherEnum {
1358
+ Variant()
1359
+ };
1360
+ }
1351
1361
struct Struct;
1352
1362
struct TupleStruct();
1353
1363
@@ -1378,6 +1388,8 @@ fn times2(value: i32) -> i32 {
1378
1388
fn main() {
1379
1389
let enumb = Enum::Variant(0);
1380
1390
1391
+ let strukt = x::Foo;
1392
+ let strukt = x::y::Foo;
1381
1393
let strukt = Struct;
1382
1394
let strukt = Struct::new();
1383
1395
0 commit comments