]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_codegen_llvm/callee.rs
Apply `resolve_vars_if_possible` to returned types for more accurate suggestions
[rust.git] / src / librustc_codegen_llvm / callee.rs
index c0be87b117d65d063d0941f7868f517299685e11..78dd6fc8ffe750d80f504b366a6a6b0922576606 100644 (file)
@@ -6,14 +6,14 @@
 
 use crate::abi::{FnAbi, FnAbiLlvmExt};
 use crate::attributes;
-use crate::llvm;
 use crate::context::CodegenCx;
+use crate::llvm;
 use crate::value::Value;
-use rustc_codegen_ssa::traits::*;
 use log::debug;
+use rustc_codegen_ssa::traits::*;
 
-use rustc::ty::{TypeFoldable, Instance};
 use rustc::ty::layout::{FnAbiExt, HasTyCtxt};
+use rustc::ty::{Instance, TypeFoldable};
 
 /// Codegens a reference to a fn/method item, monomorphizing and
 /// inlining as it goes.
 ///
 /// - `cx`: the crate context
 /// - `instance`: the instance to be instantiated
-pub fn get_fn(
-    cx: &CodegenCx<'ll, 'tcx>,
-    instance: Instance<'tcx>,
-) -> &'ll Value {
+pub fn get_fn(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'tcx>) -> &'ll Value {
     let tcx = cx.tcx();
 
     debug!("get_fn(instance={:?})", instance);
@@ -39,7 +36,7 @@ pub fn get_fn(
     }
 
     let sym = tcx.symbol_name(instance).name.as_str();
-    debug!("get_fn({:?}: {:?}) => {}", instance, instance.ty(cx.tcx()), sym);
+    debug!("get_fn({:?}: {:?}) => {}", instance, instance.monomorphic_ty(cx.tcx()), sym);
 
     let fn_abi = FnAbi::of_instance(cx, instance, &[]);
 
@@ -125,16 +122,20 @@ pub fn get_fn(
                         // the current crate does not re-export generics, the
                         // definition of the instance will have been declared
                         // as `hidden`.
-                        if cx.tcx.is_unreachable_local_definition(instance_def_id) ||
-                           !cx.tcx.local_crate_exports_generics() {
+                        if cx.tcx.is_unreachable_local_definition(instance_def_id)
+                            || !cx.tcx.local_crate_exports_generics()
+                        {
                             llvm::LLVMRustSetVisibility(llfn, llvm::Visibility::Hidden);
                         }
                     } else {
                         // This is a monomorphization of a generic function
                         // defined in an upstream crate.
-                        if cx.tcx.upstream_monomorphizations_for(instance_def_id)
-                                 .map(|set| set.contains_key(instance.substs))
-                                 .unwrap_or(false) {
+                        if cx
+                            .tcx
+                            .upstream_monomorphizations_for(instance_def_id)
+                            .map(|set| set.contains_key(instance.substs))
+                            .unwrap_or(false)
+                        {
                             // This is instantiated in another crate. It cannot
                             // be `hidden`.
                         } else {
@@ -172,9 +173,7 @@ pub fn get_fn(
             }
         }
 
-        if cx.use_dll_storage_attrs &&
-            tcx.is_dllimport_foreign_item(instance_def_id)
-        {
+        if cx.use_dll_storage_attrs && tcx.is_dllimport_foreign_item(instance_def_id) {
             unsafe {
                 llvm::LLVMSetDLLStorageClass(llfn, llvm::DLLStorageClass::DllImport);
             }