Skip to content

Commit ce8b317

Browse files
committed
rustc_trans: Tidy up some style and line lengths
Match the surrounding style in the rest of the `rustc_trans::trans` module.
1 parent 181dbd7 commit ce8b317

File tree

2 files changed

+53
-48
lines changed

2 files changed

+53
-48
lines changed

src/librustc_trans/trans/base.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,8 @@ pub fn trans_external_path<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
670670
ccx.sess().bug("unexpected intrinsic in trans_external_path")
671671
}
672672
_ => {
673-
let llfn = foreign::register_foreign_item_fn(ccx, fn_ty.abi, t, &name[..]);
673+
let llfn = foreign::register_foreign_item_fn(ccx, fn_ty.abi,
674+
t, &name);
674675
let attrs = csearch::get_item_attrs(&ccx.sess().cstore, did);
675676
attributes::from_fn_attrs(ccx, &attrs, llfn);
676677
llfn

src/librustc_trans/trans/declare.rs

Lines changed: 51 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
// except according to those terms.
1010
//! Declare various LLVM values.
1111
//!
12-
//! Prefer using functions and methods from this module rather than calling LLVM functions
13-
//! directly. These functions do some additional work to ensure we do the right thing given
14-
//! the preconceptions of trans.
12+
//! Prefer using functions and methods from this module rather than calling LLVM
13+
//! functions directly. These functions do some additional work to ensure we do
14+
//! the right thing given the preconceptions of trans.
1515
//!
1616
//! Some useful guidelines:
1717
//!
18-
//! * Use declare_* family of methods if you are declaring, but are not interested in defining the
19-
//! ValueRef they return.
18+
//! * Use declare_* family of methods if you are declaring, but are not
19+
//! interested in defining the ValueRef they return.
2020
//! * Use define_* family of methods when you might be defining the ValueRef.
2121
//! * When in doubt, define.
2222
use llvm::{self, ValueRef};
@@ -37,8 +37,8 @@ use libc::c_uint;
3737

3838
/// Declare a global value.
3939
///
40-
/// If there’s a value with the same name already declared, the function will return its ValueRef
41-
/// instead.
40+
/// If there’s a value with the same name already declared, the function will
41+
/// return its ValueRef instead.
4242
pub fn declare_global(ccx: &CrateContext, name: &str, ty: Type) -> llvm::ValueRef {
4343
debug!("declare_global(name={:?})", name);
4444
let namebuf = CString::new(name).unwrap_or_else(|_|{
@@ -54,10 +54,10 @@ pub fn declare_global(ccx: &CrateContext, name: &str, ty: Type) -> llvm::ValueRe
5454
///
5555
/// For rust functions use `declare_rust_fn` instead.
5656
///
57-
/// If there’s a value with the same name already declared, the function will update the
58-
/// declaration and return existing ValueRef instead.
59-
pub fn declare_fn(ccx: &CrateContext, name: &str, callconv: llvm::CallConv, ty: Type,
60-
output: ty::FnOutput) -> ValueRef {
57+
/// If there’s a value with the same name already declared, the function will
58+
/// update the declaration and return existing ValueRef instead.
59+
pub fn declare_fn(ccx: &CrateContext, name: &str, callconv: llvm::CallConv,
60+
ty: Type, output: ty::FnOutput) -> ValueRef {
6161
debug!("declare_fn(name={:?})", name);
6262
let namebuf = CString::new(name).unwrap_or_else(|_|{
6363
ccx.sess().bug(&format!("name {:?} contains an interior null byte", name))
@@ -67,7 +67,8 @@ pub fn declare_fn(ccx: &CrateContext, name: &str, callconv: llvm::CallConv, ty:
6767
};
6868

6969
llvm::SetFunctionCallConv(llfn, callconv);
70-
// Function addresses in Rust are never significant, allowing functions to be merged.
70+
// Function addresses in Rust are never significant, allowing functions to
71+
// be merged.
7172
llvm::SetUnnamedAddr(llfn, true);
7273

7374
if output == ty::FnDiverging {
@@ -88,23 +89,25 @@ pub fn declare_fn(ccx: &CrateContext, name: &str, callconv: llvm::CallConv, ty:
8889

8990
/// Declare a C ABI function.
9091
///
91-
/// Only use this for foreign function ABIs and glue. For Rust functions use `declare_rust_fn`
92-
/// instead.
92+
/// Only use this for foreign function ABIs and glue. For Rust functions use
93+
/// `declare_rust_fn` instead.
9394
///
94-
/// If there’s a value with the same name already declared, the function will update the
95-
/// declaration and return existing ValueRef instead.
96-
pub fn declare_cfn(ccx: &CrateContext, name: &str, fn_type: Type, output: ty::Ty) -> ValueRef {
95+
/// If there’s a value with the same name already declared, the function will
96+
/// update the declaration and return existing ValueRef instead.
97+
pub fn declare_cfn(ccx: &CrateContext, name: &str, fn_type: Type,
98+
output: ty::Ty) -> ValueRef {
9799
declare_fn(ccx, name, llvm::CCallConv, fn_type, ty::FnConverging(output))
98100
}
99101

100102

101103
/// Declare a Rust function.
102104
///
103-
/// If there’s a value with the same name already declared, the function will update the
104-
/// declaration and return existing ValueRef instead.
105+
/// If there’s a value with the same name already declared, the function will
106+
/// update the declaration and return existing ValueRef instead.
105107
pub fn declare_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, name: &str,
106108
fn_type: ty::Ty<'tcx>) -> ValueRef {
107-
debug!("declare_rust_fn(name={:?}, fn_type={})", name, fn_type.repr(ccx.tcx()));
109+
debug!("declare_rust_fn(name={:?}, fn_type={})", name,
110+
fn_type.repr(ccx.tcx()));
108111
let fn_type = monomorphize::normalize_associated_type(ccx.tcx(), &fn_type);
109112
debug!("declare_rust_fn (after normalised associated types) fn_type={}",
110113
fn_type.repr(ccx.tcx()));
@@ -131,7 +134,8 @@ pub fn declare_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, name: &str,
131134
let llfty = type_of::type_of_rust_fn(ccx, env, &sig, abi);
132135
debug!("declare_rust_fn llfty={}", ccx.tn().type_to_string(llfty));
133136

134-
// it is ok to directly access sig.0.output because we erased all late-bound-regions above
137+
// it is ok to directly access sig.0.output because we erased all
138+
// late-bound-regions above
135139
let llfn = declare_fn(ccx, name, llvm::CCallConv, llfty, sig.0.output);
136140
attributes::from_fn_type(ccx, fn_type).apply_llfn(llfn);
137141
llfn
@@ -140,8 +144,8 @@ pub fn declare_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, name: &str,
140144

141145
/// Declare a Rust function with internal linkage.
142146
///
143-
/// If there’s a value with the same name already declared, the function will update the
144-
/// declaration and return existing ValueRef instead.
147+
/// If there’s a value with the same name already declared, the function will
148+
/// update the declaration and return existing ValueRef instead.
145149
pub fn declare_internal_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, name: &str,
146150
fn_type: ty::Ty<'tcx>) -> ValueRef {
147151
let llfn = declare_rust_fn(ccx, name, fn_type);
@@ -152,10 +156,10 @@ pub fn declare_internal_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, name: &s
152156

153157
/// Declare a global with an intention to define it.
154158
///
155-
/// Use this function when you intend to define a global. This function will return None if the
156-
/// name already has a definition associated with it. In that case an error should be reported to
157-
/// the user, because it usually happens due to user’s fault (e.g. misuse of #[no_mangle] or
158-
/// #[export_name] attributes).
159+
/// Use this function when you intend to define a global. This function will
160+
/// return None if the name already has a definition associated with it. In that
161+
/// case an error should be reported to the user, because it usually happens due
162+
/// to user’s fault (e.g. misuse of #[no_mangle] or #[export_name] attributes).
159163
pub fn define_global(ccx: &CrateContext, name: &str, ty: Type) -> Option<ValueRef> {
160164
if get_defined_value(ccx, name).is_some() {
161165
None
@@ -169,10 +173,10 @@ pub fn define_global(ccx: &CrateContext, name: &str, ty: Type) -> Option<ValueRe
169173
///
170174
/// For rust functions use `define_rust_fn` instead.
171175
///
172-
/// Use this function when you intend to define a function. This function will return None if the
173-
/// name already has a definition associated with it. In that case an error should be reported to
174-
/// the user, because it usually happens due to user’s fault (e.g. misuse of #[no_mangle] or
175-
/// #[export_name] attributes).
176+
/// Use this function when you intend to define a function. This function will
177+
/// return None if the name already has a definition associated with it. In that
178+
/// case an error should be reported to the user, because it usually happens due
179+
/// to user’s fault (e.g. misuse of #[no_mangle] or #[export_name] attributes).
176180
pub fn define_fn(ccx: &CrateContext, name: &str, callconv: llvm::CallConv, fn_type: Type,
177181
output: ty::FnOutput) -> Option<ValueRef> {
178182
if get_defined_value(ccx, name).is_some() {
@@ -185,13 +189,13 @@ pub fn define_fn(ccx: &CrateContext, name: &str, callconv: llvm::CallConv, fn_ty
185189

186190
/// Declare a C ABI function with an intention to define it.
187191
///
188-
/// Use this function when you intend to define a function. This function will return None if the
189-
/// name already has a definition associated with it. In that case an error should be reported to
190-
/// the user, because it usually happens due to user’s fault (e.g. misuse of #[no_mangle] or
191-
/// #[export_name] attributes).
192+
/// Use this function when you intend to define a function. This function will
193+
/// return None if the name already has a definition associated with it. In that
194+
/// case an error should be reported to the user, because it usually happens due
195+
/// to user’s fault (e.g. misuse of #[no_mangle] or #[export_name] attributes).
192196
///
193-
/// Only use this for foreign function ABIs and glue. For Rust functions use `declare_rust_fn`
194-
/// instead.
197+
/// Only use this for foreign function ABIs and glue. For Rust functions use
198+
/// `declare_rust_fn` instead.
195199
pub fn define_cfn(ccx: &CrateContext, name: &str, fn_type: Type,
196200
output: ty::Ty) -> Option<ValueRef> {
197201
if get_defined_value(ccx, name).is_some() {
@@ -204,10 +208,10 @@ pub fn define_cfn(ccx: &CrateContext, name: &str, fn_type: Type,
204208

205209
/// Declare a Rust function with an intention to define it.
206210
///
207-
/// Use this function when you intend to define a function. This function will return None if the
208-
/// name already has a definition associated with it. In that case an error should be reported to
209-
/// the user, because it usually happens due to user’s fault (e.g. misuse of #[no_mangle] or
210-
/// #[export_name] attributes).
211+
/// Use this function when you intend to define a function. This function will
212+
/// return None if the name already has a definition associated with it. In that
213+
/// case an error should be reported to the user, because it usually happens due
214+
/// to user’s fault (e.g. misuse of #[no_mangle] or #[export_name] attributes).
211215
pub fn define_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, name: &str,
212216
fn_type: ty::Ty<'tcx>) -> Option<ValueRef> {
213217
if get_defined_value(ccx, name).is_some() {
@@ -220,10 +224,10 @@ pub fn define_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, name: &str,
220224

221225
/// Declare a Rust function with an intention to define it.
222226
///
223-
/// Use this function when you intend to define a function. This function will return None if the
224-
/// name already has a definition associated with it. In that case an error should be reported to
225-
/// the user, because it usually happens due to user’s fault (e.g. misuse of #[no_mangle] or
226-
/// #[export_name] attributes).
227+
/// Use this function when you intend to define a function. This function will
228+
/// return None if the name already has a definition associated with it. In that
229+
/// case an error should be reported to the user, because it usually happens due
230+
/// to user’s fault (e.g. misuse of #[no_mangle] or #[export_name] attributes).
227231
pub fn define_internal_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, name: &str,
228232
fn_type: ty::Ty<'tcx>) -> Option<ValueRef> {
229233
if get_defined_value(ccx, name).is_some() {
@@ -250,8 +254,8 @@ fn get_defined_value(ccx: &CrateContext, name: &str) -> Option<ValueRef> {
250254
(llvm::LLVMIsDeclaration(val) != 0,
251255
linkage == llvm::AvailableExternallyLinkage as c_uint)
252256
};
253-
debug!("get_defined_value: found {:?} value (declaration: {}, aext_link: {})", name,
254-
declaration, aext_link);
257+
debug!("get_defined_value: found {:?} value (declaration: {}, \
258+
aext_link: {})", name, declaration, aext_link);
255259
if !declaration || aext_link {
256260
Some(val)
257261
} else {

0 commit comments

Comments
 (0)