File tree 2 files changed +7
-5
lines changed
src/tools/rust-analyzer/crates
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(
680
680
memory_map : & MemoryMap ,
681
681
ty : & Ty ,
682
682
) -> 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 ( ) ) ;
687
684
let ty = normalize ( f. db , trait_env. clone ( ) , ty. clone ( ) ) ;
688
685
match ty. kind ( Interner ) {
689
686
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> {
10950
10950
10951
10951
#[ test]
10952
10952
fn 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.
10953
10956
check (
10954
10957
r#"
10958
+ //- /foo.rs crate:foo
10955
10959
pub trait PublicFlags {
10956
10960
type Internal;
10957
10961
}
@@ -10967,12 +10971,13 @@ pub struct InternalBitFlags;
10967
10971
impl PublicFlags for NoteDialects {
10968
10972
type Internal = InternalBitFlags;
10969
10973
}
10974
+ //- /bar.rs crate:bar
10970
10975
"# ,
10971
10976
expect ! [ [ r#"
10972
10977
*CLAP*
10973
10978
10974
10979
```rust
10975
- ra_test_fixture ::NoteDialects
10980
+ foo ::NoteDialects
10976
10981
```
10977
10982
10978
10983
```rust
You can’t perform that action at this time.
0 commit comments