rust/src/libstd
bors e629dba0ee Auto merge of #28256 - petrochenkov:conv, r=alexcrichton
This patch transforms functions of the form
```
fn f<Generic: AsRef<Concrete>>(arg: Generic) {
	let arg: &Concrete = arg.as_ref();
	// Code using arg
}
```
to the next form:
```
#[inline]
fn f<Generic: AsRef<Concrete>>(arg: Generic) {
	fn f_inner(arg: &Concrete) {
		// Code using arg
	}
	
	f_inner(arg.as_ref());
}
```

Therefore, most of the code is concrete and not duplicated during monomorphisation (unless inlined)
and only the tiny bit of conversion code is duplicated. This method was mentioned by @aturon in the
Conversion Traits RFC (https://github.com/rust-lang/rfcs/blame/master/text/0529-conversion-traits.md#L249) and similar techniques are not uncommon in C++ template libraries.

This patch goes to the extremes and applies the transformation even to smaller functions<sup>1</sup>
for purity of the experiment. *Some of them can be rolled back* if considered too ridiculous.

<sup>1</sup> However who knows how small are these functions are after inlining and everything.

The functions in question are mostly `fs`/`os` functions and not used especially often with variety
of argument types, so the code size reduction is rather small (but consistent). Here are the sizes
of stage2 artifacts before and after the patch:
https://gist.github.com/petrochenkov/e76a6b280f382da13c5d
https://gist.github.com/petrochenkov/6cc28727d5256dbdfed0

Note:
All the `inner` functions are concrete and unavailable for cross-crate inlining, some of them may
need `#[inline]` annotations in the future.

r? @aturon
2015-09-14 22:21:41 +00:00
..
collections std: Internalize almost all of std::rt 2015-09-11 11:19:20 -07:00
ffi Auto merge of #28256 - petrochenkov:conv, r=alexcrichton 2015-09-14 22:21:41 +00:00
io Auto merge of #28256 - petrochenkov:conv, r=alexcrichton 2015-09-14 22:21:41 +00:00
net Drop upper bounds on net timeout tests 2015-09-14 10:11:40 -07:00
num std: Stabilize/deprecate features for 1.4 2015-09-11 09:48:48 -07:00
os Fix compile on DragonFly: Replace unknown uint32_t/in64_t by u32/i64. 2015-09-02 10:57:57 +02:00
prelude Fix typo in prelude docs 2015-09-04 21:27:55 -07:00
rand Use null()/null_mut() instead of 0 as *const T/0 as *mut T 2015-09-03 09:49:50 +03:00
sync some more clippy-based improvements 2015-09-08 00:36:29 +02:00
sys Auto merge of #28358 - dotdash:nounwind, r=alexcrichton 2015-09-14 11:05:34 +00:00
thread Auto merge of #28339 - alexcrichton:stabilize-1.4, r=aturon 2015-09-13 19:45:15 +00:00
time std: Add issues to all unstable features 2015-08-15 18:09:17 -07:00
ascii.rs std: Add issues to all unstable features 2015-08-15 18:09:17 -07:00
dynamic_lib.rs some more clippy-based improvements 2015-09-08 00:36:29 +02:00
env.rs Reduce code bloat from conversion traits in function parameters 2015-09-09 22:37:59 +03:00
error.rs std: Add issues to all unstable features 2015-08-15 18:09:17 -07:00
fs.rs Reduce code bloat from conversion traits in function parameters 2015-09-09 22:37:59 +03:00
lib.rs Auto merge of #28358 - dotdash:nounwind, r=alexcrichton 2015-09-14 11:05:34 +00:00
macros.rs Clarify that include_bytes! returns a reference to an array, not just a slice 2015-09-07 20:01:14 -04:00
panicking.rs std: Internalize almost all of std::rt 2015-09-11 11:19:20 -07:00
path.rs Reduce code bloat from conversion traits in function parameters 2015-09-09 22:37:59 +03:00
primitive_docs.rs std: Stabilize/deprecate features for 1.4 2015-09-11 09:48:48 -07:00
process.rs std: Internalize almost all of std::rt 2015-09-11 11:19:20 -07:00
rt.rs std: Internalize almost all of std::rt 2015-09-11 11:19:20 -07:00
rtdeps.rs Auto merge of #26741 - alexcrichton:noinline-destructors, r=brson 2015-07-06 19:49:16 +00:00