mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-30 04:56:25 +03:00
5bc1fd171c
Suggest function-local constructors without enclosing function path Closes rust-lang/rust#144319 This fixes a mismatched-type wrapper suggestion for constructors defined inside function-like scopes. The previous diagnostic used `def_path_str` directly, so a function-local tuple struct could be suggested as `main::Foo(false)`, even though `main` is not a module path that can name the constructor. The suggestion now prints the constructor path under rustc's existing suggestion printer mode. That mode omits path segments that cannot be written in source, while preserving real path segments such as local modules and enum names. The regression test covers: - a function-local tuple struct constructor - a function-local enum variant - a tuple struct inside a function-local module - a tuple struct inside a closure body - a tuple struct inside an inline const block