1▶//! Traits, helpers, and type definitions for core I/O functionality.
2//!
3//! The `std::io` module contains a number of common things you'll need
· · ·
20//! use std::fs::File;
21//!
22▶//! fn main() -> io::Result<()> {
23//! let mut f = File::open("foo.txt")?;
24//! let mut buffer = [0; 10];
· · ·
49//! use std::fs::File;
50//!
51▶//! fn main() -> io::Result<()> {
52//! let mut f = File::open("foo.txt")?;
53//! let mut buffer = [0; 10];
· · ·
84//! use std::fs::File;
85//!
86▶//! fn main() -> io::Result<()> {
87//! let f = File::open("foo.txt")?;
88//! let mut reader = BufReader::new(f);
· · ·
106//! use std::fs::File;
107//!
108▶//! fn main() -> io::Result<()> {
109//! let f = File::create("foo.txt")?;
110//! {
+ 121 more matches in this file
32use rustc_span::source_map::SourceMap;
33use rustc_span::{FileName, InnerSpan, Span, SpanData};
34▶use rustc_target::spec::{MergeFunctions, SanitizerSet};
35use tracing::debug;
36
· · ·
106 pub vectorize_loop: bool,
107 pub vectorize_slp: bool,
108▶ pub merge_functions: bool,
109 pub emit_lifetime_markers: bool,
110 pub llvm_plugins: Vec<String>,
· · ·
224
225 // Some targets (namely, NVPTX) interact badly with the
226▶ // MergeFunctions pass. This is because MergeFunctions can generate
227 // new function calls which may interfere with the target calling
228 // convention; e.g. for the NVPTX target, PTX kernels should not
· · ·
227▶ // new function calls which may interfere with the target calling
228 // convention; e.g. for the NVPTX target, PTX kernels should not
229 // call other PTX kernels. MergeFunctions can also be configured to
· · ·
229▶ // call other PTX kernels. MergeFunctions can also be configured to
230 // generate aliases instead, but aliases are not supported by some
231 // backends (again, NVPTX). Therefore, allow targets to opt out of
+ 94 more matches in this file
34// Assist: inline_into_callers
35//
36▶// Inline a function or method body into all of its callers where possible, creating a `let` statement per parameter
37// unless the parameter can be inlined. The parameter will be inlined either if it the supplied argument is a simple local
38// or if the parameter is only accessed inside the function body once.
· · ·
38▶// or if the parameter is only accessed inside the function body once.
39// If all calls can be inlined the function will be removed.
40//
· · ·
39▶// If all calls can be inlined the function will be removed.
40//
41// ```
· · ·
74 let vfs_def_file = ctx.vfs_file_id();
75 let name = ctx.find_node_at_offset::<ast::Name>()?;
76▶ let ast_func = name.syntax().parent().and_then(ast::Fn::cast)?;
77 let func_body = ast_func.body()?;
78 let param_list = ast_func.param_list()?;
· · ·
77▶ let func_body = ast_func.body()?;
78 let param_list = ast_func.param_list()?;
79
+ 90 more matches in this file
192 // traits are equal, then the associated type bounds (`dyn Trait<Assoc=T>`)
193 // are also equal, which is ensured by the fact that normalization is
194▶ // a function and we do not allow overlapping impls.
195 return old_info;
196 }
· · ·
396) {
397 // this is an info! to allow collecting monomorphization statistics
398▶ // and to allow finding the last function before LLVM aborts from
399 // release builds.
400 info!("codegen_instance({})", instance);
· · ·
448 expr.span,
449 ),
450▶ _ => span_bug!(*op_sp, "asm sym is not a function"),
451 };
452
· · ·
472}
473
474▶/// Creates the `main` function which will initialize the rust runtime and call
475/// users main function.
476pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
· · ·
475▶/// users main function.
476pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
477 cx: &'a Bx::CodegenCx,
+ 43 more matches in this file
4//! This module is responsible for discovering all items that will contribute
5//! to code generation of the crate. The important part here is that it not only
6▶//! needs to find syntax-level items (functions, structs, etc) but also all
7//! their monomorphized instantiations. Every non-generic, non-const function
8//! maps to one LLVM artifact. Every generic function can produce
· · ·
7▶//! their monomorphized instantiations. Every non-generic, non-const function
8//! maps to one LLVM artifact. Every generic function can produce
9//! from zero to N artifacts, depending on the sets of type arguments it
· · ·
8▶//! maps to one LLVM artifact. Every generic function can produce
9//! from zero to N artifacts, depending on the sets of type arguments it
10//! is instantiated with.
· · ·
15//! The following kinds of "mono items" are handled here:
16//!
17▶//! - Functions
18//! - Methods
19//! - Closures
· · ·
29//! - Object Shims
30//!
31▶//! The main entry point is `collect_crate_mono_items`, at the bottom of this file.
32//!
33//! General Algorithm
+ 50 more matches in this file
375#[doc(hidden)]
376pub(super) trait SplitIter: DoubleEndedIterator {
377▶ /// Marks the underlying iterator as complete, extracting the remaining
378 /// portion of the slice.
379 fn finish(&mut self) -> Option<Self::Item>;
· · ·
381
382/// An iterator over subslices separated by elements that match a predicate
383▶/// function.
384///
385/// This struct is created by the [`split`] method on [slices].
· · ·
536
537/// An iterator over subslices separated by elements that match a predicate
538▶/// function. Unlike `Split`, it contains the matched part as a terminator
539/// of the subslice.
540///
· · ·
646 // by the last iteration, so we start searching a new match
647 // one index to the left.
648▶ let remainder = if self.v.is_empty() { &[] } else { &self.v[..(self.v.len() - 1)] };
649 let idx = remainder.iter().rposition(|x| (self.pred)(x)).map(|idx| idx + 1).unwrap_or(0);
650 if idx == 0 {
· · ·
649▶ let idx = remainder.iter().rposition(|x| (self.pred)(x)).map(|idx| idx + 1).unwrap_or(0);
650 if idx == 0 {
651 self.finished = true;
+ 44 more matches in this file
44 AddressOfTemporaryTaken, BaseExpressionDoubleDot, BaseExpressionDoubleDotAddExpr,
45 BaseExpressionDoubleDotRemove, CantDereference, FieldMultiplySpecifiedInInitializer,
46▶ FunctionalRecordUpdateOnNonStruct, HelpUseLatestEdition, NakedAsmOutsideNakedFn,
47 NoFieldOnVariant, ReturnLikeStatementKind, ReturnStmtOutsideOfFnBody, StructExprNonExhaustive,
48 TypeMismatchFruTypo, YieldExprOutsideOfCoroutine,
· · ·
231 let mut lines = lint_str.lines();
232 if let Some(line0) = lines.next() {
233▶ let remaining_lines = lines.count();
234 debug!("expr text: {line0}");
235 debug!("expr text: ...(and {remaining_lines} more lines)");
· · ·
235▶ debug!("expr text: ...(and {remaining_lines} more lines)");
236 }
237 }
· · ·
260
261 if self.is_whole_body.replace(false) {
262▶ // If this expression is the whole body and the function diverges because of its
263 // arguments, we check this here to ensure the body is considered to diverge.
264 self.diverges.set(self.function_diverges_because_of_empty_arguments.get())
· · ·
264▶ self.diverges.set(self.function_diverges_because_of_empty_arguments.get())
265 };
266
+ 49 more matches in this file
80/// Calculates the direction and split point of a one-sided range.
81///
82▶/// This is a helper function for `split_off` and `split_off_mut` that returns
83/// the direction of the split (front or back) as well as the index at
84/// which to split. Returns `None` if the split index would overflow.
· · ·
366 }
367
368▶ /// Returns an array reference to the first `N` items in the slice and the remaining slice.
369 ///
370 /// If the slice is not at least `N` in length, this will return `None`.
· · ·
393 }
394
395▶ /// Returns a mutable array reference to the first `N` items in the slice and the remaining
396 /// slice.
397 ///
· · ·
426 }
427
428▶ /// Returns an array reference to the last `N` items in the slice and the remaining slice.
429 ///
430 /// If the slice is not at least `N` in length, this will return `None`.
· · ·
454 }
455
456▶ /// Returns a mutable array reference to the last `N` items in the slice and the remaining
457 /// slice.
458 ///
+ 126 more matches in this file
141 it.declaration_source_range(db).map(|src| src.file_id)
142 }
143▶ Definition::Function(it) => it.source(db).map(|src| src.file_id),
144 _ => None,
145 };
· · ·
155 let runnable = match def {
156 Definition::Module(it) => runnable_mod(&sema, it),
157▶ Definition::Function(it) => runnable_fn(&sema, it),
158 Definition::SelfType(impl_) => runnable_impl(&sema, &impl_),
159 _ => None,
· · ·
163 impl_.items(db).into_iter().for_each(|assoc| {
164 let runnable = match assoc {
165▶ hir::AssocItem::Function(it) => {
166 runnable_fn(&sema, it).or_else(|| module_def_doctest(&sema, it.into()))
167 }
· · ·
295fn as_test_runnable(sema: &Semantics<'_, RootDatabase>, fn_def: &ast::Fn) -> Option<Runnable> {
296 if test_related_attribute_syn(fn_def).is_some() {
297▶ let function = sema.to_def(fn_def)?;
298 runnable_fn(sema, function)
299 } else {
· · ·
298▶ runnable_fn(sema, function)
299 } else {
300 None
+ 78 more matches in this file
1▶//! Renaming functionality.
2//!
3//! This is mostly front-end for [`ide_db::rename`], but it also includes the
· · ·
4//! tests. This module also implements a couple of magic tricks, like renaming
5▶//! `self` and to `self` (to switch between associated function and method).
6
7use hir::{AsAssocItem, FindPathConfig, HasContainer, HirDisplay, InFile, Name, Semantics, sym};
· · ·
71}
72
73▶/// Prepares a rename. The sole job of this function is to return the TextRange of the thing that is
74/// being targeted for a rename.
75pub(crate) fn prepare_rename(
· · ·
390 sema: &Semantics<'_, RootDatabase>,
391 source_change: &mut SourceChange,
392▶ f: hir::Function,
393) {
394 let calls = Definition::Function(f).usages(sema).all();
· · ·
394▶ let calls = Definition::Function(f).usages(sema).all();
395 for (_file_id, calls) in calls {
396 for call in calls {
+ 69 more matches in this file
3
4pub(crate) mod const_;
5▶pub(crate) mod function;
6pub(crate) mod literal;
7pub(crate) mod macro_;
· · ·
29 item::{Builder, CompletionRelevanceTypeMatch},
30 render::{
31▶ function::render_fn,
32 literal::render_variant_lit,
33 macro_::{render_macro, render_macro_pat},
· · ·
100 ///
101 /// In order to be able to check for the latter, we'd ideally want to `try_as_dyn<_, dyn AsAssocItem>(def)`
102▶ /// (see [`try_as_dyn`][]), but that function is currently unstable. Therefore, we employ a hack instead:
103 /// if `def` can be an assoc item, it should be passed to this method as follows:
104 /// ```ignore
· · ·
160 let mut builder = TextEdit::builder();
161 // Using TextEdit, insert '(' before the struct name and ')' before the
162▶ // dot access, then comes the field name and optionally insert function
163 // call parens.
164
· · ·
372) -> Option<hir::Name> {
373 Some(match resolution {
374▶ ScopeDef::ModuleDef(hir::ModuleDef::Function(f)) => f.name(ctx.completion.db),
375 ScopeDef::ModuleDef(hir::ModuleDef::Const(c)) => c.name(ctx.completion.db)?,
376 ScopeDef::ModuleDef(hir::ModuleDef::TypeAlias(t)) => t.name(ctx.completion.db),
+ 150 more matches in this file
18use rustc_resolve::rustdoc::pulldown_cmark::{BrokenLink, CodeBlockKind, CowStr, Options, TagEnd};
19use rustc_resolve::rustdoc::{
20▶ DocFragment, add_doc_fragment, attrs_to_doc_fragments, main_body_opts, pulldown_cmark,
21 source_span_for_markdown_range, span_of_fragments,
22};
· · ·
35mod markdown;
36mod missing_headers;
37▶mod needless_doctest_main;
38mod suspicious_doc_comments;
39mod test_attr_in_doctest;
· · ·
266 /// /// [`SmallVec<[T; INLINE_CAPACITY]>`][SmallVec].
267 /// /// [SmallVec]: SmallVec
268▶ /// fn main() {}
269 /// ```
270 #[clippy::version = "pre 1.29.0"]
· · ·
401 /// Detects documentation that is empty.
402 /// ### Why is this bad?
403▶ /// Empty docs clutter code without adding value, reducing readability and maintainability.
404 /// ### Example
405 /// ```no_run
· · ·
423declare_clippy_lint! {
424 /// ### What it does
425▶ /// Checks the doc comments of publicly visible functions that
426 /// return a `Result` type and warns if there is no `# Errors` section.
427 ///
+ 31 more matches in this file
1//! Logic for transforming the raw code given by the user into something actually
2▶//! runnable, e.g. by adding a `main` function if it doesn't already exist.
3
4use std::fmt::{self, Write as _};
· · ·
27#[derive(Default)]
28struct ParseSourceInfo {
29▶ has_main_fn: bool,
30 already_has_extern_crate: bool,
31 supports_color: bool,
· · ·
127
128 let Ok(Ok(ParseSourceInfo {
129▶ has_main_fn,
130 already_has_extern_crate,
131 supports_color,
· · ·
176 DocTestBuilder {
177 supports_color,
178▶ has_main_fn,
179 global_crate_attrs,
180 crate_attrs,
· · ·
195 pub(crate) supports_color: bool,
196 pub(crate) already_has_extern_crate: bool,
197▶ pub(crate) has_main_fn: bool,
198 pub(crate) global_crate_attrs: Vec<String>,
199 pub(crate) crate_attrs: String,
+ 29 more matches in this file
127/// with the `rustc_private` feature. This is intended for use when
128/// compiling library and `rustc_*` crates themselves so we can leverage crates.io
129▶/// while maintaining the invariant that all sysroot crates are unstable
130/// by default and are unable to be used.
131const FORCE_UNSTABLE: Stability = Stability {
· · ·
237 {
238 const_stab = Some(ConstStability {
239▶ // We subject these implicitly-const functions to recursive const stability.
240 const_stable_indirect: true,
241 promotable: false,
· · ·
382 }
383
384▶ // If the current node is a function with const stability attributes (directly given or
385 // implied), check if the function/method is const or the parent impl block is const.
386 let fn_sig = self.tcx.hir_node_by_def_id(def_id).fn_sig();
· · ·
385▶ // implied), check if the function/method is const or the parent impl block is const.
386 let fn_sig = self.tcx.hir_node_by_def_id(def_id).fn_sig();
387 if let Some(fn_sig) = fn_sig
· · ·
933 self.fully_stable = false;
934 }
935▶ if let TyKind::FnPtr(function) = t.kind {
936 if extern_abi_stability(function.abi).is_err() {
937 self.fully_stable = false;
+ 32 more matches in this file
5//! check_* methods in rustc_hir_analysis/check/mod.rs are a good entry point) and
6//! IntelliJ-Rust (org.rust.lang.core.types.infer). Our entry point for
7▶//! inference here is the `infer` function, which infers the types of all
8//! expressions in a given function.
9//!
· · ·
8▶//! expressions in a given function.
9//!
10//! During inference, types (i.e. the `Ty` struct) can contain type 'variables'
· · ·
36use hir_def::{
37 AdtId, AssocItemId, ConstId, ConstParamId, DefWithBodyId, ExpressionStoreOwnerId, FieldId,
38▶ FunctionId, GenericDefId, GenericParamId, ItemContainerId, LocalFieldId, Lookup, TraitId,
39 TupleFieldId, TupleId, TypeAliasId, TypeOrConstParamId, VariantId,
40 expr_store::{Body, ExpressionStore, HygieneId, RootExprOrigin, path::Path},
· · ·
43 layout::Integer,
44 resolver::{HasResolver, ResolveValueResult, Resolver, TypeNs, ValueNs},
45▶ signatures::{ConstSignature, EnumSignature, FunctionSignature, StaticSignature},
46 type_ref::{ConstRef, LifetimeRefId, TypeRef, TypeRefId},
47};
· · ·
120
121 match def {
122▶ DefWithBodyId::FunctionId(f) => ctx.collect_fn(f, body.self_param, &body.params),
123 DefWithBodyId::ConstId(c) => ctx.collect_const(c, ConstSignature::of(db, c)),
124 DefWithBodyId::StaticId(s) => ctx.collect_static(StaticSignature::of(db, s)),
+ 32 more matches in this file
3//! This module contains basic methods to manipulate the contents of the local
4//! filesystem. All methods in this module represent cross-platform filesystem
5▶//! operations. Extra platform-specific functionality can be found in the
6//! extension traits of `std::os::$platform`.
7//!
· · ·
72/// use std::io::prelude::*;
73///
74▶/// fn main() -> std::io::Result<()> {
75/// let mut file = File::create("foo.txt")?;
76/// file.write_all(b"Hello, world!")?;
· · ·
85/// use std::io::prelude::*;
86///
87▶/// fn main() -> std::io::Result<()> {
88/// let mut file = File::open("foo.txt")?;
89/// let mut contents = String::new();
· · ·
101/// use std::io::prelude::*;
102///
103▶/// fn main() -> std::io::Result<()> {
104/// let file = File::open("foo.txt")?;
105/// let mut buf_reader = BufReader::new(file);
· · ·
160/// # Platform-specific behavior
161///
162▶/// On supported systems (including Windows and some UNIX-based OSes), this function acquires a
163/// handle/file descriptor for the directory. This allows functions like [`Dir::open_file`] to
164/// avoid [TOCTOU] errors when the directory itself is being moved.
+ 214 more matches in this file
115 postfix_snippet("dbg", "dbg!(expr)", &format!("dbg!({receiver_text})")).add_to(acc, ctx.db); // fixme
116 postfix_snippet("dbgr", "dbg!(&expr)", &format!("dbg!(&{receiver_text})")).add_to(acc, ctx.db);
117▶ postfix_snippet("call", "function(expr)", &format!("${{1}}({receiver_text})"))
118 .add_to(acc, ctx.db);
119
· · ·
547 check(
548 r#"
549▶fn main() {
550 let bar = true;
551 bar.$0
· · ·
554 expect![[r#"
555 sn box Box::new(expr)
556▶ sn call function(expr)
557 sn const const {}
558 sn dbg dbg!(expr)
· · ·
574
575 #[test]
576▶ fn postfix_completion_works_for_function_calln() {
577 check(
578 r#"
· · ·
581}
582
583▶fn main() {
584 let bar = true;
585 foo(bar.$0)
+ 121 more matches in this file
1//! Lookup hir elements using positions in the source code. This is a lossy
2//! transformation: in general, a single source might correspond to several
3▶//! modules, functions, etc, due to macros, cfgs and `#[path=]` attributes on
4//! modules.
5//!
· · ·
11use hir_def::{
12 AdtId, AssocItemId, CallableDefId, ConstId, DefWithBodyId, ExpressionStoreOwnerId, FieldId,
13▶ FunctionId, GenericDefId, LocalFieldId, ModuleDefId, StructId, TraitId, VariantId,
14 expr_store::{
15 Body, BodySourceMap, ExpressionStore, ExpressionStoreSourceMap, HygieneId,
· · ·
58
59use crate::{
60▶ Adt, AnyFunctionId, AssocItem, BindingMode, BuiltinAttr, BuiltinType, Callable, Const,
61 DeriveHelper, EnumVariant, Field, Function, GenericSubstitution, Local, Macro, ModuleDef,
62 Static, Struct, ToolModule, Trait, TupleField, Type, TypeAlias,
· · ·
61▶ DeriveHelper, EnumVariant, Field, Function, GenericSubstitution, Local, Macro, ModuleDef,
62 Static, Struct, ToolModule, Trait, TupleField, Type, TypeAlias,
63 db::HirDatabase,
· · ·
482 ) -> Option<Callable<'db>> {
483 let expr_id = self.expr_id(call.clone().into())?.as_expr()?;
484▶ let (func, args) = self.infer()?.method_resolution(expr_id)?;
485 let interner = DbInterner::new_no_crate(db);
486 let ty = db.value_ty(func.into())?.instantiate(interner, args);
+ 45 more matches in this file
274/// All path separators recognized on the current platform, represented as [`char`]s; for example,
275/// this is `&['/'][..]` on Unix and `&['\\', '/'][..]` on Windows. The [primary
276▶/// separator](MAIN_SEPARATOR) is always element 0 of the slice.
277#[unstable(feature = "const_path_separators", issue = "153106")]
278pub const SEPARATORS: &[char] = crate::sys::path::SEPARATORS;
· · ·
280/// All path separators recognized on the current platform, represented as [`&str`]s; for example,
281/// this is `&["/"][..]` on Unix and `&["\\", "/"][..]` on Windows. The [primary
282▶/// separator](MAIN_SEPARATOR_STR) is always element 0 of the slice.
283#[unstable(feature = "const_path_separators", issue = "153106")]
284pub const SEPARATORS_STR: &[&str] = crate::sys::path::SEPARATORS_STR;
· · ·
287/// for example, this is `'/'` on Unix and `'\\'` on Windows.
288#[stable(feature = "rust1", since = "1.0.0")]
289▶#[cfg_attr(not(test), rustc_diagnostic_item = "path_main_separator")]
290pub const MAIN_SEPARATOR: char = SEPARATORS[0];
291
· · ·
290▶pub const MAIN_SEPARATOR: char = SEPARATORS[0];
291
292/// The primary separator of path components for the current platform, represented as a [`&str`];
· · ·
293/// for example, this is `"/"` on Unix and `"\\"` on Windows.
294▶#[stable(feature = "main_separator_str", since = "1.68.0")]
295pub const MAIN_SEPARATOR_STR: &str = SEPARATORS_STR[0];
296
+ 41 more matches in this file
424
425 // We should handle `return` separately, because when it is used in a `try` block,
426▶ // it will exit the outside function instead of the block itself.
427 WalkExpandedExprCtx::new(sema)
428 .with_check_ctx(&WalkExpandedExprCtx::is_async_const_block_or_closure)
· · ·
871 r#"
872fn foo() {
873▶ unsafe fn this_is_unsafe_function() {}
874
875 unsa$0fe {
· · ·
883 //^^^^^^^^
884
885▶ this_is_unsafe_function();
886 //^^^^^^^^^^^^^^^^^^^^^^^^^
887 }
· · ·
937 check(
938 r#"
939▶//- /main.rs crate:main deps:lib
940use lib$0;
941 //^^^ import
· · ·
1640struct Struct { field: u32 }
1641 //^^^^^
1642▶fn function(field: u32) {
1643 //^^^^^
1644 Struct { field$0 }
+ 32 more matches in this file
303 or some other example.
304
305▶ * Struct/enum/const/static/impl definitions nested in a function do not mention the function name.
306 See #18771.
307
· · ·
398 SymbolInformationKind::EnumMember => ScipKind::EnumMember,
399 SymbolInformationKind::Field => ScipKind::Field,
400▶ SymbolInformationKind::Function => ScipKind::Function,
401 SymbolInformationKind::Macro => ScipKind::Macro,
402 SymbolInformationKind::Method => ScipKind::Method,
· · ·
592 check_symbol(
593 r#"
594▶//- /workspace/lib.rs crate:main deps:foo
595use foo::example_mod::func;
596fn main() {
· · ·
595▶use foo::example_mod::func;
596fn main() {
597 func$0();
· · ·
596▶fn main() {
597 func$0();
598}
+ 62 more matches in this file
140 /// ```
141 ///
142▶ /// Output from this function is controlled by passing `-Z dump-mir=<filter>`,
143 /// where `<filter>` takes the following forms:
144 ///
· · ·
381 }
382
383▶ /// Write out a human-readable textual representation for the given function.
384 pub fn write_mir_fn(&self, body: &Body<'tcx>, w: &mut dyn io::Write) -> io::Result<()> {
385 write_mir_intro(self.tcx, body, w, self.options)?;
· · ·
565 write_coverage_info_hi(coverage_info_hi, w)?;
566 }
567▶ if let Some(function_coverage_info) = &body.function_coverage_info {
568 write_function_coverage_info(function_coverage_info, w)?;
569 }
· · ·
568▶ write_function_coverage_info(function_coverage_info, w)?;
569 }
570
· · ·
596}
597
598▶fn write_function_coverage_info(
599 function_coverage_info: &coverage::FunctionCoverageInfo,
600 w: &mut dyn io::Write,
+ 21 more matches in this file
159 sema: &Semantics<'_, RootDatabase>,
160 node: &SyntaxNode,
161▶) -> Option<hir::Function> {
162 let node = ast::TryExpr::cast(node.clone())?;
163 let try_expr_ty = sema.type_of_expr(&node.expr()?)?.adjusted();
· · ·
185
186 let from_trait = fd.core_convert_From()?;
187▶ let from_fn = from_trait.function(sema.db, sym::from)?;
188 sema.resolve_trait_impl_method(
189 returned_err_ty.clone(),
· · ·
201 let method_call = ast::MethodCallExpr::cast(original_token.parent()?.parent()?)?;
202 let callable = sema.resolve_method_call_as_callable(&method_call)?;
203▶ let CallableKind::Function(f) = callable.kind() else { return None };
204 let assoc = f.as_assoc_item(sema.db)?;
205
· · ·
213 {
214 let t = fd.core_convert_FromStr()?;
215▶ let t_f = t.function(sema.db, &sym::from_str)?;
216 return sema
217 .resolve_trait_impl_method(
· · ·
229 let f = if fn_name == sym::into && fd.core_convert_Into() == Some(t) {
230 let dual = fd.core_convert_From()?;
231▶ let dual_f = dual.function(sema.db, &sym::from)?;
232 sema.resolve_trait_impl_method(
233 return_type.clone(),
+ 77 more matches in this file
1▶//! This module provides primitives for showing type and function parameter information when editing
2//! a call or use-site.
3
· · ·
173 let mut fn_params = None;
174 match callable.kind() {
175▶ hir::CallableKind::Function(func) => {
176 res.doc = func.docs(db).map(Documentation::into_owned);
177 if func.is_async(db) {
· · ·
176▶ res.doc = func.docs(db).map(Documentation::into_owned);
177 if func.is_async(db) {
178 format_to!(res.signature, "async ");
· · ·
177▶ if func.is_async(db) {
178 format_to!(res.signature, "async ");
179 }
· · ·
180▶ format_to!(res.signature, "fn {}", func.name(db).display(db, edition));
181
182 let generic_params = GenericDef::Function(func)
+ 70 more matches in this file
19extern crate rustc_span;
20
21▶/// See docs in https://github.com/rust-lang/rust/blob/HEAD/compiler/rustc/src/main.rs
22/// and https://github.com/rust-lang/rust/pull/146627 for why we need this.
23///
· · ·
52use rustc_hir::def_id::LOCAL_CRATE;
53use rustc_hir::{self as hir, Node};
54▶use rustc_hir_analysis::check::check_function_signature;
55use rustc_interface::interface::Config;
56use rustc_interface::util::DummyCodegenBackend;
· · ·
102 ));
103
104▶ let correct_func_sig = check_function_signature(
105 tcx,
106 ObligationCause::new(start_span, start_def_id, ObligationCauseCode::Misc),
· · ·
110 .is_ok();
111
112▶ if correct_func_sig {
113 (*id, MiriEntryFnType::MiriStart)
114 } else {
· · ·
120 } else {
121 tcx.dcx().fatal(
122▶ "Miri can only run programs that have a main function.\n\
123 Alternatively, you can export a `miri_start` function:\n\
124 \n\
+ 8 more matches in this file