This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed
src/tools/rust-analyzer/crates Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -680,10 +680,7 @@ fn render_const_scalar(
680680 memory_map : & MemoryMap ,
681681 ty : & Ty ,
682682) -> Result < ( ) , HirDisplayError > {
683- // FIXME: We need to get krate from the final callers of the hir display
684- // infrastructure and have it here as a field on `f`.
685- let trait_env =
686- TraitEnvironment :: empty ( * f. db . crate_graph ( ) . crates_in_topological_order ( ) . last ( ) . unwrap ( ) ) ;
683+ let trait_env = TraitEnvironment :: empty ( f. krate ( ) ) ;
687684 let ty = normalize ( f. db , trait_env. clone ( ) , ty. clone ( ) ) ;
688685 match ty. kind ( Interner ) {
689686 TyKind :: Scalar ( s) => match s {
Original file line number Diff line number Diff line change @@ -10950,8 +10950,12 @@ pub struct ManuallyDrop$0<T: ?Sized> {
1095010950
1095110951#[ test]
1095210952fn projection_const ( ) {
10953+ // This uses two crates, which have *no* relation between them, to test another thing:
10954+ // `render_const_scalar()` used to just use the last crate for the trait env, which will
10955+ // fail in this scenario.
1095310956 check (
1095410957 r#"
10958+ //- /foo.rs crate:foo
1095510959pub trait PublicFlags {
1095610960 type Internal;
1095710961}
@@ -10967,12 +10971,13 @@ pub struct InternalBitFlags;
1096710971impl PublicFlags for NoteDialects {
1096810972 type Internal = InternalBitFlags;
1096910973}
10974+ //- /bar.rs crate:bar
1097010975 "# ,
1097110976 expect ! [ [ r#"
1097210977 *CLAP*
1097310978
1097410979 ```rust
10975- ra_test_fixture ::NoteDialects
10980+ foo ::NoteDialects
1097610981 ```
1097710982
1097810983 ```rust
You can’t perform that action at this time.
0 commit comments