| /third_party/rust/rust/src/tools/rust-analyzer/crates/ide-db/src/ |
| D | active_parameter.rs | 4 use hir::{Semantics, Type}; 21 pub fn at_token(sema: &Semantics<'_, RootDatabase>, token: SyntaxToken) -> Option<Self> { in at_token() 34 pub fn ident(&self) -> Option<ast::Name> { in ident() 42 /// Returns a [`hir::Callable`] this token is a part of and its argument index of said callable. 46 ) -> Option<(hir::Callable, Option<usize>)> { in callable_for_token() 61 ) -> Option<(hir::Callable, Option<usize>)> { in callable_for_node() 89 ) -> Option<(hir::GenericDef, usize, bool)> { in generic_def_for_node() 91 let def = match_ast! { in generic_def_for_node() localVariable 95 let generic_def: hir::GenericDef = match res { in generic_def_for_node() 96 hir::PathResolution::Def(hir::ModuleDef::Adt(it)) => it.into(), in generic_def_for_node() [all …]
|
| D | traits.rs | 4 use hir::{db::HirDatabase, AsAssocItem, Semantics}; 12 ) -> Option<hir::Trait> { in resolve_target_trait() 17 Some(hir::PathResolution::Def(hir::ModuleDef::Trait(def))) => Some(def), in resolve_target_trait() 27 ) -> Vec<hir::AssocItem> { in get_missing_assoc_items() 40 hir::AssocItem::Function(it) => { in get_missing_assoc_items() 43 hir::AssocItem::Const(it) => { in get_missing_assoc_items() 48 hir::AssocItem::TypeAlias(it) => { in get_missing_assoc_items() 59 hir::AssocItem::Function(f) => { in get_missing_assoc_items() 62 hir::AssocItem::TypeAlias(t) => { in get_missing_assoc_items() 65 hir::AssocItem::Const(c) => c in get_missing_assoc_items() [all …]
|
| D | search.rs | 1 //! Implementation of find-usages functionality. 4 //! get a super-set of matches. Then, we we confirm each match using precise 10 use hir::{ 32 pub fn is_empty(&self) -> bool { in is_empty() 36 pub fn len(&self) -> usize { in len() 40 pub fn iter(&self) -> impl Iterator<Item = (&FileId, &[FileReference])> + '_ { in iter() 44 pub fn file_ranges(&self) -> impl Iterator<Item = FileRange> + '_ { in file_ranges() 55 fn into_iter(self) -> Self::IntoIter { in into_iter() 64 /// The node of the reference in the (macro-)file 91 fn new(entries: IntMap<FileId, Option<TextRange>>) -> SearchScope { in new() [all …]
|
| /third_party/rust/rust/src/tools/clippy/clippy_lints/src/ |
| D | redundant_type_annotations.rs | 4 use rustc_hir as hir; 5 use rustc_hir::def::DefKind; 21 /// - Generics 22 /// - Refs returned from anything else than a `MethodCall` 23 /// - Complex types (tuples, arrays, etc...) 24 /// - `Path` to anything else than a primitive type. 41 …_type<'tcx>(cx: &LateContext<'tcx>, ty_resolved_path: hir::def::Res, func_return_type: Ty<'tcx>) -… in is_same_type() 43 if let hir::def::Res::PrimTy(primty) = ty_resolved_path in is_same_type() 51 …if let hir::def::Res::Def(DefKind::Struct | DefKind::Union | DefKind::Enum, defid) = ty_resolved_p… in is_same_type() 60 fn func_hir_id_to_func_ty<'tcx>(cx: &LateContext<'tcx>, hir_id: hir::hir_id::HirId) -> Option<Ty<'t… in func_hir_id_to_func_ty() [all …]
|
| D | default_constructed_unit_structs.rs | 2 use hir::{def::Res, ExprKind}; 4 use rustc_hir as hir; 46 fn is_alias(ty: hir::Ty<'_>) -> bool { in is_alias() 47 if let hir::TyKind::Path(ref qpath) = ty.kind { in is_alias() 55 fn check_expr<'tcx>(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) { in check_expr() 58 if let hir::ExprKind::Call(fn_expr, &[]) = expr.kind; in check_expr() 59 if let ExprKind::Path(ref qpath @ hir::QPath::TypeRelative(base, _)) = fn_expr.kind; in check_expr() 63 if let Res::Def(_, def_id) = cx.qpath_res(qpath, fn_expr.hir_id); in check_expr() 66 if let ty::Adt(def, ..) = cx.typeck_results().expr_ty(expr).kind(); in check_expr() 67 if def.is_struct(); in check_expr() [all …]
|
| /third_party/rust/rust/src/tools/clippy/clippy_lints/src/methods/ |
| D | expect_fun_call.rs | 6 use rustc_hir as hir; 19 expr: &hir::Expr<'_>, in check() 22 receiver: &'tcx hir::Expr<'tcx>, in check() 23 args: &'tcx [hir::Expr<'tcx>], in check() 27 fn get_arg_root<'a>(cx: &LateContext<'_>, arg: &'a hir::Expr<'a>) -> &'a hir::Expr<'a> { in check() 31 hir::ExprKind::AddrOf(hir::BorrowKind::Ref, _, expr) => expr, in check() 32 hir::ExprKind::MethodCall(method_name, receiver, [], ..) => { in check() 36 … base_type.is_str() || is_type_lang_item(cx, base_type, hir::LangItem::String) in check() 51 fn requires_to_string(cx: &LateContext<'_>, arg: &hir::Expr<'_>) -> bool { in check() 53 if is_type_lang_item(cx, arg_ty, hir::LangItem::String) { in check() [all …]
|
| /third_party/rust/rust/src/tools/rust-analyzer/crates/ide-completion/src/completions/ |
| D | pattern.rs | 3 use hir::{db::DefDatabase, AssocItem, ScopeDef}; 47 let single_variant_enum = |enum_: hir::Enum| ctx.db.enum_data(enum_.into()).variants.len() == 1; in complete_pattern() 49 if let Some(hir::Adt::Enum(e)) = in complete_pattern() 66 // suggest variants + auto-imports in complete_pattern() 69 hir::ScopeDef::ModuleDef(def) => match def { in complete_pattern() 70 hir::ModuleDef::Adt(hir::Adt::Struct(strukt)) => { in complete_pattern() 74 hir::ModuleDef::Variant(variant) in complete_pattern() 80 hir::ModuleDef::Adt(hir::Adt::Enum(e)) => refutable || single_variant_enum(e), in complete_pattern() 81 hir::ModuleDef::Const(..) => refutable, in complete_pattern() 82 hir::ModuleDef::Module(..) => true, in complete_pattern() [all …]
|
| D | type.rs | 3 use hir::{HirDisplay, ScopeDef}; 20 let scope_def_applicable = |def| { 21 use hir::{GenericParam::*, ModuleDef::*}; 22 match def { 46 hir::AssocItem::Const(ct) if matches!(location, TypeLocation::GenericArgList(_)) => { 49 hir::AssocItem::Function(_) | hir::AssocItem::Const(_) => (), 50 hir::AssocItem::TypeAlias(ty) => acc.add_type_alias(ctx, ty), 57 .flat_map(|&it| hir::Trait::from(it).items(ctx.sema.db)) 69 if let hir::AssocItem::TypeAlias(ty) = item { 84 hir::PathResolution::Def(hir::ModuleDef::Module(module)) => { [all …]
|
| D | use_.rs | 3 use hir::ScopeDef; 23 // only show `self` in a new use-tree when the qualifier doesn't end in self 46 hir::PathResolution::Def(hir::ModuleDef::Module(module)) => { 48 let unknown_is_current = |name: &hir::Name| { 54 for (name, def) in module_scope { 55 if !ctx.check_stability(def.attrs(ctx.db).as_deref()) { 62 let add_resolution = match def { 73 let mut builder = Builder::from_resolution(ctx, path_ctx, name, def); 82 hir::PathResolution::Def(hir::ModuleDef::Adt(hir::Adt::Enum(e))) => { 94 // only show modules and non-std enum in a fresh UseTree [all …]
|
| /third_party/rust/rust/compiler/rustc_lint/src/ |
| D | types.rs | 17 use rustc_hir as hir; 102 /// second-largest variant. 111 /// [`Box`]: https://doc.rust-lang.org/std/boxed/index.html 142 negated_expr_id: Option<hir::HirId>, 148 pub fn new() -> TypeLimits { in new() 153 /// Attempts to special-case the overflowing literal lint when it occurs as a range endpoint (`expr… 157 lit: &hir::Lit, in lint_overflowing_range_endpoint() 160 expr: &'tcx hir::Expr<'tcx>, in lint_overflowing_range_endpoint() 162 ) -> bool { in lint_overflowing_range_endpoint() 164 …let (expr, lit_span) = if let Node::Expr(par_expr) = cx.tcx.hir().get(cx.tcx.hir().parent_id(expr.… in lint_overflowing_range_endpoint() [all …]
|
| /third_party/rust/rust/compiler/rustc_mir_build/src/thir/cx/ |
| D | mod.rs | 10 use rustc_hir as hir; 11 use rustc_hir::def::DefKind; 24 ) -> Result<(&Steal<Thir<'_>>, ExprId), ErrorGuaranteed> { in thir_body() 25 let hir = tcx.hir(); in thir_body() localVariable 26 let body = hir.body(hir.body_owned_by(owner_def)); in thir_body() 33 let owner_id = hir.local_def_id_to_hir_id(owner_def); in thir_body() 34 if let Some(ref fn_decl) = hir.fn_decl_by_hir_id(owner_id) { in thir_body() 81 fn new(tcx: TyCtxt<'tcx>, def: LocalDefId) -> Cx<'tcx> { in new() 82 let typeck_results = tcx.typeck(def); in new() 83 let hir = tcx.hir(); in new() localVariable [all …]
|
| D | expr.rs | 6 use rustc_hir as hir; 7 use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res}; 9 use rustc_middle::hir::place::Place as HirPlace; 10 use rustc_middle::hir::place::PlaceBase as HirPlaceBase; 11 use rustc_middle::hir::place::ProjectionKind as HirProjectionKind; 26 pub(crate) fn mirror_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) -> ExprId { in mirror_expr() 31 pub(crate) fn mirror_exprs(&mut self, exprs: &'tcx [hir::Expr<'tcx>]) -> Box<[ExprId]> { in mirror_exprs() 36 pub(super) fn mirror_expr_inner(&mut self, hir_expr: &'tcx hir::Expr<'tcx>) -> ExprId { in mirror_expr_inner() 101 hir_expr: &'tcx hir::Expr<'tcx>, in apply_adjustment() 105 ) -> Expr<'tcx> { in apply_adjustment() [all …]
|
| /third_party/rust/rust/compiler/rustc_hir_analysis/src/check/ |
| D | check.rs | 9 use rustc_hir as hir; 10 use rustc_hir::def::{CtorKind, DefKind, Res}; 19 use rustc_middle::hir::nested_filter; 40 pub fn check_abi(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: Abi) { in check_abi() 69 "the `\"C-cmse-nonsecure-call\"` ABI is only allowed on function pointers" in check_abi() 76 let def = tcx.adt_def(def_id); in check_struct() localVariable 78 def.destructor(tcx); // force the destructor to be evaluated in check_struct() 80 if def.repr().simd() { in check_struct() 84 check_transparent(tcx, def); in check_struct() 85 check_packed(tcx, span, def); in check_struct() [all …]
|
| /third_party/rust/rust/compiler/rustc_passes/src/ |
| D | dead.rs | 1 // This implements the dead-code warning pass. It follows middle::reachable 5 use hir::def_id::{LocalDefIdMap, LocalDefIdSet}; 8 use rustc_hir as hir; 9 use rustc_hir::def::{CtorOf, DefKind, Res}; 31 fn should_explore(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool { in should_explore() 33 tcx.hir().find_by_def_id(def_id), in should_explore() 63 /// Gets the type-checking results for the current body. 67 fn typeck_results(&self) -> &'tcx ty::TypeckResults<'tcx> { in typeck_results() 90 Res::Def(DefKind::Const | DefKind::AssocConst | DefKind::TyAlias, def_id) => { in handle_res() 95 Res::Def(DefKind::Ctor(CtorOf::Variant, ..), ctor_def_id) => { in handle_res() [all …]
|
| /third_party/rust/rust/src/tools/rust-analyzer/crates/ide-ssr/src/ |
| D | resolving.rs | 3 use hir::AsAssocItem; 11 scope: hir::SemanticsScope<'db>, 31 pub(crate) resolution: hir::PathResolution, 38 pub(crate) function: hir::Function, 39 pub(crate) qualifier_type: Option<hir::Type>, 47 ) -> Result<ResolvedRule, SsrError> { in new() 61 pub(crate) fn get_placeholder(&self, token: &SyntaxToken) -> Option<&Placeholder> { in get_placeholder() 75 fn resolve_pattern_tree(&self, pattern: SyntaxNode) -> Result<ResolvedPattern, SsrError> { in resolve_pattern_tree() 85 if let hir::PathResolution::Def(hir::ModuleDef::Function(function)) = in resolve_pattern_tree() 121 ) -> Result<(), SsrError> { in resolve() [all …]
|
| /third_party/rust/rust/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/ |
| D | highlight.rs | 3 use hir::{AsAssocItem, HasVisibility, Semantics}; 19 pub(super) fn token(sema: &Semantics<'_, RootDatabase>, token: SyntaxToken) -> Option<Highlight> { in token() 50 krate: hir::Crate, in name_like() 51 bindings_shadow_count: &mut FxHashMap<hir::Name, u32>, in name_like() 54 ) -> Option<(Highlight, Option<u64>)> { in name_like() 69 Some(IdentClass::NameClass(NameClass::Definition(def))) => { in name_like() 70 highlight_def(sema, krate, def) | HlMod::Definition in name_like() 72 Some(IdentClass::NameRefClass(NameRefClass::Definition(def))) => { in name_like() 73 highlight_def(sema, krate, def) in name_like() 86 ) -> Highlight { in punctuation() [all …]
|
| /third_party/rust/rust/compiler/rustc_ty_utils/src/ |
| D | ty.rs | 2 use rustc_hir as hir; 3 use rustc_hir::def::DefKind; 17 ) -> Vec<Ty<'tcx>> { in sized_constraint_for_ty() 31 // these are never sized - return the target type in sized_constraint_for_ty() 52 // FIXME: consider special-casing always-Sized projections in sized_constraint_for_ty() 76 fn defaultness(tcx: TyCtxt<'_>, def_id: LocalDefId) -> hir::Defaultness { in defaultness() 77 match tcx.hir().get_by_def_id(def_id) { in defaultness() 78 hir::Node::Item(hir::Item { kind: hir::ItemKind::Impl(impl_), .. }) => impl_.defaultness, in defaultness() 79 hir::Node::ImplItem(hir::ImplItem { defaultness, .. }) in defaultness() 80 | hir::Node::TraitItem(hir::TraitItem { defaultness, .. }) => *defaultness, in defaultness() [all …]
|
| /third_party/rust/rust/compiler/rustc_hir_analysis/src/collect/ |
| D | resolve_bound_vars.rs | 3 //! Name resolution for lifetimes is performed on the AST and embedded into HIR. From this 5 //! Lifetimes can be early-bound or late-bound. Construction of typechecking terms needs to visit 6 //! the types in HIR to identify late-bound lifetimes and assign their Debruijn indices. This file 12 use rustc_hir as hir; 13 use rustc_hir::def::{DefKind, Res}; 18 use rustc_middle::hir::nested_filter; 31 fn early(param: &GenericParam<'_>) -> (LocalDefId, ResolvedArg); in early() 33 fn late(index: u32, param: &GenericParam<'_>) -> (LocalDefId, ResolvedArg); in late() 35 fn id(&self) -> Option<DefId>; in id() 37 fn shifted(self, amount: u32) -> ResolvedArg; in shifted() [all …]
|
| /third_party/rust/rust/compiler/rustc_hir_typeck/src/fn_ctxt/ |
| D | adjust_fulfillment_errors.rs | 2 use rustc_hir as hir; 3 use rustc_hir::def::Res; 16 ) -> bool { in adjust_fulfillment_error_for_expr_obligation() 19 let hir = self.tcx.hir(); in adjust_fulfillment_error_for_expr_obligation() localVariable 20 let hir::Node::Expr(expr) = hir.get(hir_id) else { return false; }; in adjust_fulfillment_error_for_expr_obligation() localVariable 37 let find_param_matching = |matches: &dyn Fn(ty::ParamTerm) -> bool| { in adjust_fulfillment_error_for_expr_obligation() 76 // Finally, for ambiguity-related errors, we actually want to look in adjust_fulfillment_error_for_expr_obligation() 91 hir::ExprKind::Path(qpath) => { in adjust_fulfillment_error_for_expr_obligation() 92 if let hir::Node::Expr(hir::Expr { in adjust_fulfillment_error_for_expr_obligation() 93 kind: hir::ExprKind::Call(callee, args), in adjust_fulfillment_error_for_expr_obligation() [all …]
|
| /third_party/rust/rust/compiler/rustc_hir_typeck/src/ |
| D | expr_use_visitor.rs | 7 use hir::def::DefKind; 8 use hir::Expr; 10 pub use rustc_middle::hir::place::{Place, PlaceBase, PlaceWithHirId, Projection}; 13 use rustc_hir as hir; 14 use rustc_hir::def::Res; 18 use rustc_middle::hir::place::ProjectionKind; 38 /// The parameter `diag_expr_id` indicates the HIR id that ought to be used for 42 fn consume(&mut self, place_with_id: &PlaceWithHirId<'tcx>, diag_expr_id: hir::HirId); in consume() 49 diag_expr_id: hir::HirId, in borrow() 55 fn copy(&mut self, place_with_id: &PlaceWithHirId<'tcx>, diag_expr_id: hir::HirId) { in copy() [all …]
|
| /third_party/rust/rust/compiler/rustc_mir_build/src/build/ |
| D | mod.rs | 9 use rustc_hir as hir; 10 use rustc_hir::def::DefKind; 15 use rustc_middle::hir::place::PlaceBase as HirPlaceBase; 34 def: LocalDefId, in mir_built() 35 ) -> &rustc_data_structures::steal::Steal<Body<'_>> { in mir_built() 36 tcx.alloc_steal_mir(mir_build(tcx, def)) in mir_built() 42 ) -> IndexVec<FieldIdx, Symbol> { in closure_saved_names_of_captured_variables() 56 fn mir_build(tcx: TyCtxt<'_>, def: LocalDefId) -> Body<'_> { in mir_build() 58 tcx.ensure_with_value().thir_check_unsafety(def); in mir_build() 59 tcx.ensure_with_value().thir_abstract_const(def); in mir_build() [all …]
|
| /third_party/rust/rust/src/librustdoc/clean/ |
| D | utils.rs | 14 use rustc_hir as hir; 15 use rustc_hir::def::{DefKind, Res}; 30 pub(crate) fn krate(cx: &mut DocContext<'_>) -> Crate { in krate() 80 ) -> Vec<GenericArg> { in substs_to_args() 121 ) -> GenericArgs { in external_generic_args() 154 ) -> Path { in external_path() 158 res: Res::Def(def_kind, did), in external_path() 167 pub(crate) fn strip_path_generics(mut path: Path) -> Path { in strip_path_generics() 175 pub(crate) fn qpath_to_string(p: &hir::QPath<'_>) -> String { in qpath_to_string() 177 hir::QPath::Resolved(_, path) => &path.segments, in qpath_to_string() [all …]
|
| /third_party/rust/rust/compiler/rustc_privacy/src/ |
| D | lib.rs | 1 #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] 21 use rustc_hir as hir; 22 use rustc_hir::def::{DefKind, Res}; 27 use rustc_middle::hir::nested_filter; 61 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { in fmt() 69 /// <https://github.com/rust-lang/rfcs/blob/master/text/2145-type-privacy.md#how-to-determine-visib… 79 fn tcx(&self) -> TyCtxt<'tcx>; in tcx() 85 ) -> ControlFlow<Self::BreakTy>; in visit_def_id() 88 fn skeleton(&mut self) -> DefIdVisitorSkeleton<'_, 'tcx, Self> { in skeleton() 98 ) -> ControlFlow<Self::BreakTy> { in visit() [all …]
|
| /third_party/rust/rust/compiler/rustc_mir_transform/src/ |
| D | check_unsafety.rs | 2 use rustc_hir as hir; 3 use rustc_hir::def::DefKind; 37 ) -> Self { in new() 74 if let hir::Unsafety::Unsafe = sig.unsafety() { in visit_terminator() 152 let def_id = uv.def; in visit_operand() 179 // Check the base local: it might be an unsafe-to-access static. We only check derefs of the in visit_place() 181 // <https://github.com/rust-lang/rust/pull/78068#issuecomment-731753506>. in visit_place() 216 // Check for union fields. For this we traverse right-to-left, as the last `Deref` changes in visit_place() 328 if let ty::Adt(def, _) = ty.kind() { in check_mut_borrowing_layout_constrained_field() 329 if self.tcx.layout_scalar_valid_range(def.did()) in check_mut_borrowing_layout_constrained_field() [all …]
|
| /third_party/rust/rust/compiler/rustc_middle/src/ty/ |
| D | closure.rs | 1 use crate::hir::place::{ 11 use rustc_hir::{self as hir, LangItem}; 26 pub hir_id: hir::HirId, 40 pub fn new(var_hir_id: hir::HirId, closure_def_id: LocalDefId) -> UpvarId { in new() 59 pub type UpvarListMap = FxHashMap<DefId, FxIndexMap<hir::HirId, UpvarId>>; 72 pub type RootVariableMinCaptureList<'tcx> = FxIndexMap<hir::HirId, MinCaptureList<'tcx>>; 100 pub fn extends(self, other: ty::ClosureKind) -> bool { in extends() 107 pub fn to_def_id(&self, tcx: TyCtxt<'_>) -> DefId { in to_def_id() 120 pub fn to_ty(self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> { in to_ty() 143 pub mutability: hir::Mutability, [all …]
|