Skip to content

Commit 26a16c4

Browse files
committed
Auto merge of rust-lang#16612 - Veykril:detached-files, r=Veykril
internal: Fetch toolchain and datalayout for DetachedFiles My changes broke the rustc test runs since we use detached files for that, this should fix that. Also addresses some new nightly warnings wrt to unnecessary imports
2 parents 2223b4f + d93096e commit 26a16c4

File tree

29 files changed

+164
-80
lines changed

29 files changed

+164
-80
lines changed

crates/hir-def/src/body/pretty.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use itertools::Itertools;
66

77
use crate::{
88
hir::{
9-
Array, BindingAnnotation, BindingId, CaptureBy, ClosureKind, Literal, LiteralOrConst,
10-
Movability, Statement,
9+
Array, BindingAnnotation, CaptureBy, ClosureKind, Literal, LiteralOrConst, Movability,
10+
Statement,
1111
},
1212
pretty::{print_generic_args, print_path, print_type_ref},
1313
type_ref::TypeRef,

crates/hir-def/src/import_map.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use std::{fmt, hash::BuildHasherDefault};
44

55
use base_db::CrateId;
6-
use fst::{self, raw::IndexedValue, Automaton, Streamer};
6+
use fst::{raw::IndexedValue, Automaton, Streamer};
77
use hir_expand::name::Name;
88
use indexmap::IndexMap;
99
use itertools::Itertools;
@@ -477,7 +477,7 @@ mod tests {
477477
use expect_test::{expect, Expect};
478478
use test_fixture::WithFixture;
479479

480-
use crate::{db::DefDatabase, test_db::TestDB, ItemContainerId, Lookup};
480+
use crate::{test_db::TestDB, ItemContainerId, Lookup};
481481

482482
use super::*;
483483

crates/hir-def/src/item_tree.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ use std::{
4444
ops::{Index, Range},
4545
};
4646

47-
use ast::{AstNode, HasName, StructKind};
47+
use ast::{AstNode, StructKind};
4848
use base_db::CrateId;
4949
use either::Either;
5050
use hir_expand::{
5151
ast_id_map::{AstIdNode, FileAstId},
5252
attrs::RawAttrs,
53-
name::{name, AsName, Name},
53+
name::Name,
5454
ExpandTo, HirFileId, InFile,
5555
};
5656
use intern::Interned;
@@ -67,7 +67,7 @@ use crate::{
6767
attr::Attrs,
6868
db::DefDatabase,
6969
generics::{GenericParams, LifetimeParamData, TypeOrConstParamData},
70-
path::{path, AssociatedTypeBinding, GenericArgs, ImportAlias, ModPath, Path, PathKind},
70+
path::{GenericArgs, ImportAlias, ModPath, Path, PathKind},
7171
type_ref::{Mutability, TraitRef, TypeBound, TypeRef},
7272
visibility::{RawVisibility, VisibilityExplicitness},
7373
BlockId, Lookup,

crates/hir-def/src/item_tree/lower.rs

+21-5
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,33 @@
22
33
use std::collections::hash_map::Entry;
44

5-
use hir_expand::{ast_id_map::AstIdMap, span_map::SpanMapRef, HirFileId};
6-
use syntax::ast::{self, HasModuleItem, HasTypeBounds, IsString};
5+
use hir_expand::{
6+
ast_id_map::AstIdMap, mod_path::path, name, name::AsName, span_map::SpanMapRef, HirFileId,
7+
};
8+
use la_arena::Arena;
9+
use syntax::{
10+
ast::{self, HasModuleItem, HasName, HasTypeBounds, IsString},
11+
AstNode,
12+
};
13+
use triomphe::Arc;
714

815
use crate::{
16+
db::DefDatabase,
917
generics::{GenericParams, GenericParamsCollector, TypeParamData, TypeParamProvenance},
10-
type_ref::{LifetimeRef, TraitBoundModifier, TraitRef},
18+
item_tree::{
19+
AssocItem, AttrOwner, Const, Either, Enum, ExternBlock, ExternCrate, Field, FieldAstId,
20+
Fields, FileItemTreeId, FnFlags, Function, GenericArgs, Idx, IdxRange, Impl, ImportAlias,
21+
Interned, ItemTree, ItemTreeData, ItemTreeNode, Macro2, MacroCall, MacroRules, Mod,
22+
ModItem, ModKind, ModPath, Mutability, Name, Param, ParamAstId, Path, Range, RawAttrs,
23+
RawIdx, RawVisibilityId, Static, Struct, StructKind, Trait, TraitAlias, TypeAlias, Union,
24+
Use, UseTree, UseTreeKind, Variant,
25+
},
26+
path::AssociatedTypeBinding,
27+
type_ref::{LifetimeRef, TraitBoundModifier, TraitRef, TypeBound, TypeRef},
28+
visibility::RawVisibility,
1129
LocalLifetimeParamId, LocalTypeOrConstParamId,
1230
};
1331

14-
use super::*;
15-
1632
fn id<N: ItemTreeNode>(index: Idx<N>) -> FileItemTreeId<N> {
1733
FileItemTreeId(index)
1834
}

crates/hir-def/src/item_tree/pretty.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@ use span::ErasedFileAstId;
66

77
use crate::{
88
generics::{TypeOrConstParamData, WherePredicate, WherePredicateTypeTarget},
9+
item_tree::{
10+
AttrOwner, Const, DefDatabase, Enum, ExternBlock, ExternCrate, Field, FieldAstId, Fields,
11+
FileItemTreeId, FnFlags, Function, GenericParams, Impl, Interned, ItemTree, Macro2,
12+
MacroCall, MacroRules, Mod, ModItem, ModKind, Param, ParamAstId, Path, RawAttrs,
13+
RawVisibilityId, Static, Struct, Trait, TraitAlias, TypeAlias, TypeBound, TypeRef, Union,
14+
Use, UseTree, UseTreeKind, Variant,
15+
},
916
pretty::{print_path, print_type_bounds, print_type_ref},
1017
visibility::RawVisibility,
1118
};
1219

13-
use super::*;
14-
1520
pub(super) fn print_item_tree(db: &dyn DefDatabase, tree: &ItemTree) -> String {
1621
let mut p = Printer { db, tree, buf: String::new(), indent_level: 0, needs_indent: true };
1722

crates/hir-def/src/nameres.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub mod proc_macro;
5757
#[cfg(test)]
5858
mod tests;
5959

60-
use std::{cmp::Ord, ops::Deref};
60+
use std::ops::Deref;
6161

6262
use base_db::{CrateId, Edition, FileId};
6363
use hir_expand::{

crates/hir-def/src/nameres/collector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2446,7 +2446,7 @@ mod tests {
24462446
use base_db::SourceDatabase;
24472447
use test_fixture::WithFixture;
24482448

2449-
use crate::{db::DefDatabase, test_db::TestDB};
2449+
use crate::test_db::TestDB;
24502450

24512451
use super::*;
24522452

crates/hir-def/src/nameres/tests/macros.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
use expect_test::expect;
2-
use test_fixture::WithFixture;
32

43
use itertools::Itertools;
54

6-
use crate::nameres::tests::check;
7-
85
use super::*;
96

107
#[test]

crates/hir-ty/src/diagnostics/match_check/pat_util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//!
33
//! Originates from `rustc_hir::pat_util`
44
5-
use std::iter::{Enumerate, ExactSizeIterator};
5+
use std::iter::Enumerate;
66

77
pub(crate) struct EnumerateAndAdjust<I> {
88
enumerate: Enumerate<I>,

crates/hir-ty/src/mir/eval/shim.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ use hir_def::{
88
builtin_type::{BuiltinInt, BuiltinUint},
99
resolver::HasResolver,
1010
};
11-
use hir_expand::mod_path::ModPath;
1211

13-
use super::*;
12+
use crate::mir::eval::{
13+
name, pad16, static_lifetime, Address, AdtId, Arc, BuiltinType, Evaluator, FunctionId,
14+
HasModule, HirDisplay, Interned, InternedClosure, Interner, Interval, IntervalAndTy,
15+
IntervalOrOwned, ItemContainerId, LangItem, Layout, Locals, Lookup, MirEvalError, MirSpan,
16+
ModPath, Mutability, Result, Substitution, Ty, TyBuilder, TyExt,
17+
};
1418

1519
mod simd;
1620

crates/hir-ty/src/mir/eval/shim/simd.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
use std::cmp::Ordering;
44

5+
use crate::consteval::try_const_usize;
56
use crate::TyKind;
67

78
use super::*;

crates/hir-ty/src/mir/lower.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,20 @@ use crate::{
3131
inhabitedness::is_ty_uninhabited_from,
3232
layout::LayoutError,
3333
mapping::ToChalk,
34+
mir::{
35+
intern_const_scalar, return_slot, AggregateKind, Arena, BasicBlock, BasicBlockId, BinOp,
36+
BorrowKind, CastKind, ClosureId, ConstScalar, Either, Expr, FieldId, Idx, InferenceResult,
37+
Interner, Local, LocalId, MemoryMap, MirBody, MirSpan, Mutability, Operand, Place,
38+
PlaceElem, PointerCast, ProjectionElem, ProjectionStore, RawIdx, Rvalue, Statement,
39+
StatementKind, Substitution, SwitchTargets, Terminator, TerminatorKind, TupleFieldId, Ty,
40+
UnOp, VariantId,
41+
},
3442
static_lifetime,
3543
traits::FnTrait,
3644
utils::{generics, ClosureSubst},
3745
Adjust, Adjustment, AutoBorrow, CallableDefId, TyBuilder, TyExt,
3846
};
3947

40-
use super::*;
41-
4248
mod as_place;
4349
mod pattern_matching;
4450

crates/hir-ty/src/mir/lower/pattern_matching.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,16 @@
22
33
use hir_def::{hir::LiteralOrConst, resolver::HasResolver, AssocItemId};
44

5-
use crate::BindingMode;
6-
7-
use super::*;
5+
use crate::{
6+
mir::lower::{
7+
BasicBlockId, BinOp, BindingId, BorrowKind, Either, Expr, FieldId, Idx, Interner,
8+
MemoryMap, MirLowerCtx, MirLowerError, MirSpan, Mutability, Operand, Pat, PatId, Place,
9+
PlaceElem, ProjectionElem, RecordFieldPat, ResolveValueResult, Result, Rvalue,
10+
Substitution, SwitchTargets, TerminatorKind, TupleFieldId, TupleId, TyBuilder, TyKind,
11+
ValueNs, VariantData, VariantId,
12+
},
13+
BindingMode,
14+
};
815

916
macro_rules! not_supported {
1017
($x: expr) => {

crates/ide-assists/src/handlers/generate_delegate_methods.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use hir::{self, HasCrate, HasVisibility};
1+
use hir::{HasCrate, HasVisibility};
22
use ide_db::{path_transform::PathTransform, FxHashSet};
33
use syntax::{
44
ast::{

crates/ide-completion/src/completions/item_list/trait_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
//! }
3232
//! ```
3333
34-
use hir::{self, HasAttrs};
34+
use hir::HasAttrs;
3535
use ide_db::{
3636
documentation::HasDocs, path_transform::PathTransform,
3737
syntax_helpers::insert_whitespace_into_node, traits::get_missing_assoc_items, SymbolKind,

crates/ide-db/src/imports/insert_use/tests.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use hir::PrefixKind;
21
use stdx::trim_indent;
32
use test_fixture::WithFixture;
43
use test_utils::{assert_eq_text, CURSOR_MARKER};

crates/ide-db/src/symbol_index.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use base_db::{
3131
salsa::{self, ParallelDatabase},
3232
SourceDatabaseExt, SourceRootId, Upcast,
3333
};
34-
use fst::{self, raw::IndexedValue, Automaton, Streamer};
34+
use fst::{raw::IndexedValue, Automaton, Streamer};
3535
use hir::{
3636
db::HirDatabase,
3737
import_map::{AssocSearchMode, SearchMode},
@@ -394,7 +394,6 @@ impl Query {
394394
mod tests {
395395

396396
use expect_test::expect_file;
397-
use hir::symbols::SymbolCollector;
398397
use test_fixture::WithFixture;
399398

400399
use super::*;

crates/ide/src/join_lines.rs

-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@ fn compute_ws(left: SyntaxKind, right: SyntaxKind) -> &'static str {
303303

304304
#[cfg(test)]
305305
mod tests {
306-
use syntax::SourceFile;
307306
use test_utils::{add_cursor, assert_eq_text, extract_offset, extract_range};
308307

309308
use super::*;

crates/load-cargo/src/lib.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,10 @@ fn load_crate_graph(
309309
vfs: &mut vfs::Vfs,
310310
receiver: &Receiver<vfs::loader::Message>,
311311
) -> AnalysisHost {
312+
let (ProjectWorkspace::Cargo { toolchain, target_layout, .. }
313+
| ProjectWorkspace::Json { toolchain, target_layout, .. }
314+
| ProjectWorkspace::DetachedFiles { toolchain, target_layout, .. }) = ws;
315+
312316
let lru_cap = std::env::var("RA_LRU_CAP").ok().and_then(|it| it.parse::<usize>().ok());
313317
let mut host = AnalysisHost::new(lru_cap);
314318
let mut analysis_change = Change::new();
@@ -344,14 +348,9 @@ fn load_crate_graph(
344348
let num_crates = crate_graph.len();
345349
analysis_change.set_crate_graph(crate_graph);
346350
analysis_change.set_proc_macros(proc_macros);
347-
if let ProjectWorkspace::Cargo { toolchain, target_layout, .. }
348-
| ProjectWorkspace::Json { toolchain, target_layout, .. } = ws
349-
{
350-
analysis_change.set_target_data_layouts(
351-
iter::repeat(target_layout.clone()).take(num_crates).collect(),
352-
);
353-
analysis_change.set_toolchains(iter::repeat(toolchain.clone()).take(num_crates).collect());
354-
}
351+
analysis_change
352+
.set_target_data_layouts(iter::repeat(target_layout.clone()).take(num_crates).collect());
353+
analysis_change.set_toolchains(iter::repeat(toolchain.clone()).take(num_crates).collect());
355354

356355
host.apply_change(analysis_change);
357356
host

0 commit comments

Comments
 (0)