diff --git a/Cargo.toml b/Cargo.toml index afbec5d..a41cad9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "core_io" -version = "0.1.20170615" +version = "0.1.20180307" authors = ["The Rust Project Developers", "Jethro Beekman"] license = "MIT/Apache-2.0" description = """ diff --git a/build.rs b/build.rs index a345b72..ded38f7 100644 --- a/build.rs +++ b/build.rs @@ -48,7 +48,15 @@ fn main() { mappings.iter().find(|&&Mapping(elem,_)|elem==compiler).expect("Unknown compiler version, upgrade core_io?").1.to_owned() } }; - + + if ver.commit_date.as_ref().map_or(false,|d| &**d>="2018-01-01") { + println!("cargo:rustc-cfg=core_memchr"); + } + + if ver.commit_date.as_ref().map_or(false,|d| &**d>="2017-06-15") { + println!("cargo:rustc-cfg=no_collections"); + } + if ver.commit_date.as_ref().map_or(false,|d| &**d<"2016-12-15") { println!("cargo:rustc-cfg=rustc_unicode"); } else if ver.commit_date.as_ref().map_or(false,|d| &**d<"2017-03-03") { diff --git a/functions.sh b/functions.sh index e099e01..c5f6ec7 100644 --- a/functions.sh +++ b/functions.sh @@ -41,7 +41,9 @@ get_patch_commits() { prepare_version() { mkdir src/$IO_COMMIT git_extract src/libstd/io/ - if git_file_exists src/libstd/sys_common/memchr.rs; then + if git_file_exists src/libcore/slice/memchr.rs; then + true + elif git_file_exists src/libstd/sys_common/memchr.rs; then git_extract src/libstd/sys_common/memchr.rs elif git_file_exists src/libstd/sys/common/memchr.rs; then git_extract src/libstd/sys/common/memchr.rs diff --git a/mapping.rs b/mapping.rs index a5f2862..b9bfb4b 100644 --- a/mapping.rs +++ b/mapping.rs @@ -333,3 +333,259 @@ -Mapping("258ae6dd9b1a8ac97986852fc9f00f7687004ccb","3cb78259862d37da082f628af3ccb54edf264fd0") -Mapping("ad36c2f5528d617db66c244d8bcbfc4b36da0ca0","b4be4758361bf1b03410a523e8672b1c1fa7d385") -Mapping("14481f72102ba2abb5f314d5537fee90352981c5","b4be4758361bf1b03410a523e8672b1c1fa7d385") +-Mapping("29f5c699b11a6a148f097f82eaa05202f8799bbc","f0a968eada509f71971e3ece02f8ec91b6f79e8a") +-Mapping("a0dcecff90c45ad5d4eb60859e22bb3f1b03842a","6966f335ac7037900831007022f8d655bc186904") +-Mapping("8d22af87d812d9a132f0a030753a5cdf53c87ee8","cc20ab1f2509de4ef0a9953e514d62fa23b6c572") +-Mapping("bacb5c58dfdde7c35e99b2b0d8171238cc33cf6c","6966f335ac7037900831007022f8d655bc186904") +-Mapping("720c596ec62e8fec855c2953f21b0118ae408bdd","d280b40b18532dfeb80b1a98109fa6218630b939") +-Mapping("23032d0afa2b0e0c60a9b2ae62709f846d90007c","4c8cddb11b34021434d8d757e174096b10475840") +-Mapping("15aa15b03f41278aa5b9e56975889929ee734c63","cc20ab1f2509de4ef0a9953e514d62fa23b6c572") +-Mapping("f85579d4a2c342654f9b158fafd565eb159fdb59","cc20ab1f2509de4ef0a9953e514d62fa23b6c572") +-Mapping("7eb64b86ce44cc1828dd176a8b981e37ea08fc38","3024c1434a667425d30e4b0785857381323712aa") +-Mapping("ae920dcc98c9b18b38aac03367f7f1cd6dce7d2d","6966f335ac7037900831007022f8d655bc186904") +-Mapping("5965b790142eff7a8546e947914e7a8e00c61575","6966f335ac7037900831007022f8d655bc186904") +-Mapping("ee2286149a5f0b148334841d4f067dc819dcca3b","58557fafae060c500394d5df13cd0cf68170903e") +-Mapping("b7960878ba77124505aabe7dc99d0a898354c326","d52acbe37f69a2ebc9d161c479ed628da1cbea4e") +-Mapping("417c73891ffd3a769e27c83b1d34916c3924ec94","075e16b2615ed16db9225bb28048cb334324e071") +-Mapping("37c7d0ebb3ec5b62bd37df9ee8826194e3c6300a","72e8009185b537083015f43a8e0fd34509ab1938") +-Mapping("b2c0707872082c890f332178f59fd02eea5b98f3","cc20ab1f2509de4ef0a9953e514d62fa23b6c572") +-Mapping("8b22e70b2de5152db3b0c53cfa16eb96b0b9e40e","d52acbe37f69a2ebc9d161c479ed628da1cbea4e") +-Mapping("4e3901d35f6a8652f67111e7272263c9e62ab3e1","6966f335ac7037900831007022f8d655bc186904") +-Mapping("6a360194404c07e09b548626efa4b7c7777510e9","3024c1434a667425d30e4b0785857381323712aa") +-Mapping("02a24dbdd8c3a5daa6578af72116020de75b5f93","d52acbe37f69a2ebc9d161c479ed628da1cbea4e") +-Mapping("1d2a6df38442a297b4ae25899700e29d1f150bb0","72e8009185b537083015f43a8e0fd34509ab1938") +-Mapping("4502e2aa9c28d8caa610fc1815fd9c5b5a16e91c","075e16b2615ed16db9225bb28048cb334324e071") +-Mapping("ddd123ed9a35ec76103d42cecf322ee8d2896bf9","1d6d09fa6d3392343a89e1a4d116bf4170334300") +-Mapping("6fa53b00e7450060a3af9b1ef63169db37e589c2","02c1862fb55c6ae4198038b1b317bcdd06e395d1") +-Mapping("445077963c55297ef1e196a3525723090fe80b22","f5f74a22c94a7053d33c88d135f9fdc44fa2ea5b") +-Mapping("3c96d40d326b64f6a50f4a902051fe71c4acdc92","075e16b2615ed16db9225bb28048cb334324e071") +-Mapping("981ce7d8dd2c24063df648895196d9d557666fb1","1d6d09fa6d3392343a89e1a4d116bf4170334300") +-Mapping("ca94c75c527006be0824c764773380bbeea6030b","1d6d09fa6d3392343a89e1a4d116bf4170334300") +-Mapping("d762b1d6c67db12e117186d94d70e46cddb22965","e2554b36fc805c5dcb8bef65fee12e0753d5ad03") +-Mapping("73bca2b9fa9399751e432734f7f12bd6a37fc167","4c8cddb11b34021434d8d757e174096b10475840") +-Mapping("edbd7d232ee1272285be332b8a38eb47b4c8f5c6","3024c1434a667425d30e4b0785857381323712aa") +-Mapping("77efd6800c57ba83923dddbbabf03c7afa6a34a4","3024c1434a667425d30e4b0785857381323712aa") +-Mapping("250b492052e94d76bd318a4b932159395da55981","8835289434ba88351610f1ca7a19f7fefe5a53fa") +-Mapping("dd53dd5f9e21dce1fbc06b7f9f451d1009bdcfd8","72e8009185b537083015f43a8e0fd34509ab1938") +-Mapping("6f87d20a7cce70b8cc59a1adf3037d14bc83f237","075e16b2615ed16db9225bb28048cb334324e071") +-Mapping("05b5797664d6aeaa0c7d0606610f336fe0b57e97","ecbb896b9eb2acadefde57be493e4298c1aa04a3") +-Mapping("21882aad7299e8e859785845ac12374990f24dae","6966f335ac7037900831007022f8d655bc186904") +-Mapping("4279e2b4c14dc90191595c97ad3a019d618e7158","d52acbe37f69a2ebc9d161c479ed628da1cbea4e") +-Mapping("c9bb93576d4484edd1b3c40eb2aea0dfa0788851","ecbb896b9eb2acadefde57be493e4298c1aa04a3") +-Mapping("3610a70ce488953c5b0379fece70f2baad30a825","d280b40b18532dfeb80b1a98109fa6218630b939") +-Mapping("fc9ccfdbe02f4cf3e3ea60ee4412f00d29ef7f53","ecbb896b9eb2acadefde57be493e4298c1aa04a3") +-Mapping("622e7e6487b6fb7fdbb901720cd4214f9179ed67","ecbb896b9eb2acadefde57be493e4298c1aa04a3") +-Mapping("b633341c49498488b6e3fce501e23e9f9f8fadec","d52acbe37f69a2ebc9d161c479ed628da1cbea4e") +-Mapping("33374fa9d09e2a790979b31e61100dfed4b44139","838a38365daa047fca7e57f63f9c54614c45595f") +-Mapping("dd08c30703d052205a68ae34331eea464178cd99","1d6d09fa6d3392343a89e1a4d116bf4170334300") +-Mapping("f62f774035735a06c880c48c0b9017fcc0577e33","27ede55414e01f13c6869a8763da207e544cc6ad") +-Mapping("2d4df9584bebbdc72db77f550a6786819a3a791f","3024c1434a667425d30e4b0785857381323712aa") +-Mapping("9fe7aa353fac5084d0a44d6a15970310e9be67f4","3024c1434a667425d30e4b0785857381323712aa") +-Mapping("4fdb4bedfd2395e1e1ebb923b10165b850e6064c","c9f99924192e5c3a8d120eb36bcf96419b3fc7e0") +-Mapping("56733bc9f8302409a2b6110f422512923c878154","e9d70417cae7fcb08323351d9388b65b39560156") +-Mapping("150b625a07f135d0a5e1693adf2b14315709779e","d52acbe37f69a2ebc9d161c479ed628da1cbea4e") +-Mapping("5041b3bb3d953a14f32b15d1e41341c629acae12","838a38365daa047fca7e57f63f9c54614c45595f") +-Mapping("932c736479f43dc8893a924946e4335d8e308c2e","e9d70417cae7fcb08323351d9388b65b39560156") +-Mapping("90eb44a5897c39e3dff9c7e48e3973671dcd9496","6966f335ac7037900831007022f8d655bc186904") +-Mapping("3681220877771954fa923e50f227e632aabe8bbc","1d6d09fa6d3392343a89e1a4d116bf4170334300") +-Mapping("15a1e2844dfea7850be5c6c901b67ceff370b0eb","6966f335ac7037900831007022f8d655bc186904") +-Mapping("52a3309695e82ed399c1a22b4e4fdde5d3aa0f3b","72e8009185b537083015f43a8e0fd34509ab1938") +-Mapping("827cb0d61e22eb6d5c9c5e8e8d05b07108a9968b","4c8cddb11b34021434d8d757e174096b10475840") +-Mapping("0ff9872b2280009f094af0df3dcdc542cc46a5fd","f0a968eada509f71971e3ece02f8ec91b6f79e8a") +-Mapping("d6b06c63a0c735fc15c9c704422375c17b7c7e12","1ccb50eaa670f86b69e7a64484a8c97e13169183") +-Mapping("aac223f4f5d5ca979c694b614d4db37a7200528d","72e8009185b537083015f43a8e0fd34509ab1938") +-Mapping("5dfc84cfa72b405c194228b53c4de3f6474204ec","1d6d09fa6d3392343a89e1a4d116bf4170334300") +-Mapping("e6072a7b3835f1875e81c9fd27799f9b20a0770c","27ede55414e01f13c6869a8763da207e544cc6ad") +-Mapping("4d2d3fc5dadf894a8ad709a5860a549f2c0b1032","e9d70417cae7fcb08323351d9388b65b39560156") +-Mapping("8c303ed8799edb0ea76d681a6ee97f7ef9f8f2a1","c9f99924192e5c3a8d120eb36bcf96419b3fc7e0") +-Mapping("e340996ff5faa77b72d9b859aff34211033c1b68","e2554b36fc805c5dcb8bef65fee12e0753d5ad03") +-Mapping("f9b0897c5d42a4dfa425db799073c6feb21b0178","4c8cddb11b34021434d8d757e174096b10475840") +-Mapping("79cfce3d35cc8c2716c65650389d79551c2ea6ea","1ccb50eaa670f86b69e7a64484a8c97e13169183") +-Mapping("bd0e45a323f85a1940d997ac237023c00670da67","58557fafae060c500394d5df13cd0cf68170903e") +-Mapping("cbbe17aa7f13f9568a652c2180de03fa6881b86a","72e8009185b537083015f43a8e0fd34509ab1938") +-Mapping("d9f124965551e8fb9403def6a715e13dfd5e9c95","d52acbe37f69a2ebc9d161c479ed628da1cbea4e") +-Mapping("277476c4fb9e967ca28a7b529dbcf6b348cb787d","1d6d09fa6d3392343a89e1a4d116bf4170334300") +-Mapping("734c83642cff23f0d9b4b8f006b05437697bcd91","d280b40b18532dfeb80b1a98109fa6218630b939") +-Mapping("3b82e4c74d43fc1273244532c3a90bf9912061cf","e2554b36fc805c5dcb8bef65fee12e0753d5ad03") +-Mapping("d0f8e2913a93573c78cddfd297944cff4eb4c41a","838a38365daa047fca7e57f63f9c54614c45595f") +-Mapping("c8ddf28527119a06a9f5da9bd34c97ae97afe531","02c1862fb55c6ae4198038b1b317bcdd06e395d1") +-Mapping("599be0d18f4c6ddf36366d2a5a2ca6dc65886896","72e8009185b537083015f43a8e0fd34509ab1938") +-Mapping("0701b37d97d08da7074ece7a7dcb4449498f4bfa","1d6d09fa6d3392343a89e1a4d116bf4170334300") +-Mapping("59d484575a714291481563d13ad058b9a3d31fa8","e2554b36fc805c5dcb8bef65fee12e0753d5ad03") +-Mapping("73ac5d6a80f26c692f1e084b72d69637d7de2c8c","27ede55414e01f13c6869a8763da207e544cc6ad") +-Mapping("0c6091fbd0eee290c651f73be899f221eeab3c05","e9d70417cae7fcb08323351d9388b65b39560156") +-Mapping("322d7f7b97f1672bade31e1c43d5753e0e45a1a8","f0a968eada509f71971e3ece02f8ec91b6f79e8a") +-Mapping("cfcac37204c8dbdde192c1c9387cdbe663fe5ed5","1d6d09fa6d3392343a89e1a4d116bf4170334300") +-Mapping("a47c9f870f13603a06ffe63ab4834fc716912843","d52acbe37f69a2ebc9d161c479ed628da1cbea4e") +-Mapping("b98fd524eca6dca5c4788f0d20becb10e099b876","f3ef077b910c9dada20eb106e8469ec071c27dad") +-Mapping("b5392f54503fdaf04df4b9578510b2baa944f4af","d301da55f8cd7b8b10771d3171ae60ba334bf067") +-Mapping("b8398d947d160ad4f26cc22da66e5fbc7030817b","e9d70417cae7fcb08323351d9388b65b39560156") +-Mapping("5165ee9e209e0e70d89946ccbb7e90b9c0c3a7ac","b60e6f82855d387c0ad98179c33e6c019e8a7d26") +-Mapping("3f92e8d89861f0f5408ad9381a7467ec6e7d76bc","80e2e67f4c6fbbef5e4789df7fc96804e6a84196") +-Mapping("469a6f9bd9aef394c5cff6b3bc41b8c520f9515b","871bd237ee233bce3c3ba964c0b3948d685d7902") +-Mapping("16362c737fe740f630ada06349fa9004e2a51bb7","e9d70417cae7fcb08323351d9388b65b39560156") +-Mapping("229d0d3266002d343cdd2f4a3bf7f2fe9da15f38","ecbb896b9eb2acadefde57be493e4298c1aa04a3") +-Mapping("d692a91fa69a057d82cf6cb71aa3d50260f9de4a","72e8009185b537083015f43a8e0fd34509ab1938") +-Mapping("8e7a609e635b728eba65d471c985ab462dc4cfc7","f3ef077b910c9dada20eb106e8469ec071c27dad") +-Mapping("da569fa9ddf8369a9809184d43c600dc06bd4b4d","6966f335ac7037900831007022f8d655bc186904") +-Mapping("a7e0d3a81f224649c8fcfc8ac3cb93f1e1107bea","972d67cec1fc0aeafebcc60ffcdf4dea0eadff8c") +-Mapping("c284f8807eb3a1d728242bb6a767b0306d6f6bd5","b60e6f82855d387c0ad98179c33e6c019e8a7d26") +-Mapping("0077d128d33543290140763ce7d84d05eb57c40a","3024c1434a667425d30e4b0785857381323712aa") +-Mapping("63739ab7b210c1a8c890c2ea5238a3284877daa3","9b090a026108fab89cfe5f39bfd3492597e76ad4") +-Mapping("9cb18a92ad87852c4c5d6726b8fbe8c38deda4ba","cb56b2d1522e83c5bb0613abcf78b686e994df9e") +-Mapping("c9334404f06a188854af33835a0efe1e834e4ac4","cb56b2d1522e83c5bb0613abcf78b686e994df9e") +-Mapping("f25c2283b3f8a7518b2f83a252b50d29d9bfbfda","972d67cec1fc0aeafebcc60ffcdf4dea0eadff8c") +-Mapping("eba374fb21b63751ac10a09dbf269fd5067d4eb8","1d6d09fa6d3392343a89e1a4d116bf4170334300") +-Mapping("6828cf90146c7fefc4ba4f16dffe75f763f2d910","d301da55f8cd7b8b10771d3171ae60ba334bf067") +-Mapping("2c0558f635861533e2fcb4298ea93250cdfc2c58","871bd237ee233bce3c3ba964c0b3948d685d7902") +-Mapping("126321e2e505ea07887134ffe63afc759a8b7e9f","72e8009185b537083015f43a8e0fd34509ab1938") +-Mapping("16992930835ce3376a4aaed42307726e1fc78e45","b60e6f82855d387c0ad98179c33e6c019e8a7d26") +-Mapping("5f44c653cff61d0f55f53e07a188f755c7acddd1","9b090a026108fab89cfe5f39bfd3492597e76ad4") +-Mapping("7ac979d8cbe97241fd39f4037e1d4069caaff4d2","1b6c9605e41b7c7dc23e0e6f633f05912d0463dd") +-Mapping("2bb8fca18215298487a8684a132da828fdb5a751","871bd237ee233bce3c3ba964c0b3948d685d7902") +-Mapping("2fbba5bdbadeef403a64e9e1568cdad225cbcec1","d280b40b18532dfeb80b1a98109fa6218630b939") +-Mapping("215e0b10eac17e43f0132971f4e2dd018fc33d43","72e8009185b537083015f43a8e0fd34509ab1938") +-Mapping("45594d5dec4237f49e794a2a854a69f50b63d31e","9b090a026108fab89cfe5f39bfd3492597e76ad4") +-Mapping("b1f8e6fb06d7362eeb2065347a7db94e76b1cb2f","f0a968eada509f71971e3ece02f8ec91b6f79e8a") +-Mapping("0f9c784751434c70ddd6719ccda6817c819126f9","6966f335ac7037900831007022f8d655bc186904") +-Mapping("90ef3372e8ad74517eafa61e9494688c258b15ce","d52acbe37f69a2ebc9d161c479ed628da1cbea4e") +-Mapping("dc39c31699a83313edf2ac096d0bf3cef871b705","3024c1434a667425d30e4b0785857381323712aa") +-Mapping("3eeb5a665e313c5b281820099e04d4c6c8188b46","f0a968eada509f71971e3ece02f8ec91b6f79e8a") +-Mapping("560a5da9f1cc7f67d2fc372925aef18c96c82629","4c8cddb11b34021434d8d757e174096b10475840") +-Mapping("088216fb997c9cb12ce049bbe7975d1f657551ca","1d6d09fa6d3392343a89e1a4d116bf4170334300") +-Mapping("ee220daca345302c3277befee2732b6b2a5a711c","d301da55f8cd7b8b10771d3171ae60ba334bf067") +-Mapping("1ed7d41d8849d930f0622eaf54049f66fff0ca2a","075e16b2615ed16db9225bb28048cb334324e071") +-Mapping("003a929f99f7d4b36f62c4bdd5e5b0c7406e1189","49ee9f3f08ba4583bc722a663e43551067ace271") +-Mapping("10d7cb44c98f25c04dcefb6b6555237de8b8bd7e","f5f74a22c94a7053d33c88d135f9fdc44fa2ea5b") +-Mapping("9b85e1cfa5aa2aaa4b5df4359a023ad793983ffc","d280b40b18532dfeb80b1a98109fa6218630b939") +-Mapping("d93036a043dbd19f394ad320313bdbe81644f121","1d6d09fa6d3392343a89e1a4d116bf4170334300") +-Mapping("79a521bb9a8ace1a6663578a4c409906adde620d","6966f335ac7037900831007022f8d655bc186904") +-Mapping("fd4bef54abafe6d93ec3c87498de696da6ef5819","1d6d09fa6d3392343a89e1a4d116bf4170334300") +-Mapping("8493813cd8143940264f17d7bcb026c968d43b03","d52acbe37f69a2ebc9d161c479ed628da1cbea4e") +-Mapping("3f916bd3029262e2270dfbafb9ab045927499abd","b60e6f82855d387c0ad98179c33e6c019e8a7d26") +-Mapping("ab40a7cb0e01159a04d4cfffc432c6d77f1f23c8","972d67cec1fc0aeafebcc60ffcdf4dea0eadff8c") +-Mapping("97b01abf3d222523d0db4f79c13ed45e7fef27e3","bba7fd9dd54937719a6e88c954db7ab2ea5a3541") +-Mapping("f590a44ce61888c78b9044817d8b798db5cd2ffd","ecbb896b9eb2acadefde57be493e4298c1aa04a3") +-Mapping("fe7227f6c8704f0186091085a14fd1027920e4bb","f5f74a22c94a7053d33c88d135f9fdc44fa2ea5b") +-Mapping("f1b5225e8b67adab52dda2b5ed5c8b805b716a6d","075e16b2615ed16db9225bb28048cb334324e071") +-Mapping("45fba43b3d5b4d1944268cf973099bfacb11bf4c","e9d70417cae7fcb08323351d9388b65b39560156") +-Mapping("f861b6ee46465097eec266c160ac53e230df7cf0","1d6d09fa6d3392343a89e1a4d116bf4170334300") +-Mapping("bedbad61195d2eae69b43eca49c6d3e2aee8f208","f0a968eada509f71971e3ece02f8ec91b6f79e8a") +-Mapping("ff0f5de3b3220e1276bfc9a70ce1787ca7a45388","838a38365daa047fca7e57f63f9c54614c45595f") +-Mapping("269cf5026cdac6ff47f886a948e99101316d7091","d52acbe37f69a2ebc9d161c479ed628da1cbea4e") +-Mapping("ab5bec25530aac43dfd64384b405c909b6e405e3","ecbb896b9eb2acadefde57be493e4298c1aa04a3") +-Mapping("5af17242ccb151e136122b2231df2fe4031d340e","c9f99924192e5c3a8d120eb36bcf96419b3fc7e0") +-Mapping("7778906bee9e8e93792353824548044a758b72f4","d52acbe37f69a2ebc9d161c479ed628da1cbea4e") +-Mapping("7eeac1b81446c6327f1827ef334eca2db7fe28f7","49ee9f3f08ba4583bc722a663e43551067ace271") +-Mapping("3bcda48a30b21e46b81a7989deb30a3ba85fb918","e9d70417cae7fcb08323351d9388b65b39560156") +-Mapping("063deba92e44809125a433ca6e6c1ad0993313bf","f0a968eada509f71971e3ece02f8ec91b6f79e8a") +-Mapping("2aeb5930f32514b9f2a4b90cd8ce6362af5f3c9f","871bd237ee233bce3c3ba964c0b3948d685d7902") +-Mapping("9389e23a8a754097e233c7bf3ea1bb404ccf1075","b60e6f82855d387c0ad98179c33e6c019e8a7d26") +-Mapping("0a2e9ade83ff253bb489c63a95b1f499c5e0916f","4c8cddb11b34021434d8d757e174096b10475840") +-Mapping("6d9d82d3dff580d2ec31e4db5cdef73c9625a864","cc20ab1f2509de4ef0a9953e514d62fa23b6c572") +-Mapping("e026b59cf4f4cb9dd86510438085efafbc630e5a","cb56b2d1522e83c5bb0613abcf78b686e994df9e") +-Mapping("3bfc18a9619a5151ff4f11618db9cd882996ba6f","ecbb896b9eb2acadefde57be493e4298c1aa04a3") +-Mapping("bb42071f63830a984c4983f6fbdf982916857f72","4c8cddb11b34021434d8d757e174096b10475840") +-Mapping("2dad872a2dae12b882cd73536a66c9289a2b65ae","b60e6f82855d387c0ad98179c33e6c019e8a7d26") +-Mapping("29ed49fb0aeab444adcfe16ef3d04e5e910fb08d","d52acbe37f69a2ebc9d161c479ed628da1cbea4e") +-Mapping("4c053db233d69519b548e5b8ed7192d0783e582a","d52acbe37f69a2ebc9d161c479ed628da1cbea4e") +-Mapping("04145943a25c3b8c7e7d7fe8c2efb04f259c25fb","f5f74a22c94a7053d33c88d135f9fdc44fa2ea5b") +-Mapping("539f2083de809b5c8304fe7426655cfeb0e66d5e","1d6d09fa6d3392343a89e1a4d116bf4170334300") +-Mapping("930d3b17dd91b6564cf535ac717c688db757be5d","075e16b2615ed16db9225bb28048cb334324e071") +-Mapping("c6884b12d9298f1e0af919cb9458a0d80acb3b0a","075e16b2615ed16db9225bb28048cb334324e071") +-Mapping("afe145d227c5739ec5305f6b5352230a58ebb029","cc20ab1f2509de4ef0a9953e514d62fa23b6c572") +-Mapping("0a3761e63e5961ddd6ae5b9923e7a3c0725541f8","f3ef077b910c9dada20eb106e8469ec071c27dad") +-Mapping("2652ce6771b114189cdc1f9bd026a10af0a714e0","cc20ab1f2509de4ef0a9953e514d62fa23b6c572") +-Mapping("45caff88d1dabd71aec9431c07c0b4a77b20f203","1ccb50eaa670f86b69e7a64484a8c97e13169183") +-Mapping("616b66dca25a67321b1654e5a65acc6337d63cf4","e9d70417cae7fcb08323351d9388b65b39560156") +-Mapping("dead08cb331343b84564628b139b657f93548320","1d6d09fa6d3392343a89e1a4d116bf4170334300") +-Mapping("51b0b3734cbd0ca58c8be3512d53fce2d95f40dd","27ede55414e01f13c6869a8763da207e544cc6ad") +-Mapping("687d3d15ba726dbb1ac6b85223ebe0e98c6820cc","b60e6f82855d387c0ad98179c33e6c019e8a7d26") +-Mapping("97520ccb101609af63f29919bb0a39115269c89e","6966f335ac7037900831007022f8d655bc186904") +-Mapping("744dd6c1d5db522d5d3b7f2bb82abde5dc41cbeb","1d6d09fa6d3392343a89e1a4d116bf4170334300") +-Mapping("ed16b0a1de57bac50477ad83e35d648688cc0ded","72e8009185b537083015f43a8e0fd34509ab1938") +-Mapping("9fd7da904b46ff7aa78c2e2cc1986c4975aeccc6","6966f335ac7037900831007022f8d655bc186904") +-Mapping("cfe1668ca3ddb3dc57b1af319e258a16664486fa","72e8009185b537083015f43a8e0fd34509ab1938") +-Mapping("29c8276cee4a0eab7e0634ff25c6b47bd9f87c6c","e9d70417cae7fcb08323351d9388b65b39560156") +-Mapping("086eaa78ea70075abe4e6b7fb9dc76259867b4be","cc20ab1f2509de4ef0a9953e514d62fa23b6c572") +-Mapping("27a046e9338fb0455c33b13e8fe28da78212dedc","af140ecdbc64251d7f536411c84e0d398a3d6631") +-Mapping("4750c1ec047f18bc0e33823182e09711a3826fb5","d52acbe37f69a2ebc9d161c479ed628da1cbea4e") +-Mapping("f6d7514545cbe83e771a400d04049b96dfb210cd","d52acbe37f69a2ebc9d161c479ed628da1cbea4e") +-Mapping("230a379a452e5a2bcdfd0a956b259e0a1d83b512","c9f99924192e5c3a8d120eb36bcf96419b3fc7e0") +-Mapping("598eddf4f785df12e79fba5a996f153dc6fdb7e0","72e8009185b537083015f43a8e0fd34509ab1938") +-Mapping("a35a3abcda67a729edbb7d649dbc663c6feabd4c","1ccb50eaa670f86b69e7a64484a8c97e13169183") +-Mapping("cddc4a62d8e72c2bd303994752a7f8545ffb9c79","b60e6f82855d387c0ad98179c33e6c019e8a7d26") +-Mapping("4a7c072fa61b42f96d8b75c37fc1edfd71172695","b60e6f82855d387c0ad98179c33e6c019e8a7d26") +-Mapping("8ccab7eed5f4fc93500fbf242e575073ca70d7cb","e9d70417cae7fcb08323351d9388b65b39560156") +-Mapping("325ba23d5525ecdd555f19c7f527bce913dfd756","1d6d09fa6d3392343a89e1a4d116bf4170334300") +-Mapping("6c476ce462333fccd89ce3ed8c290998db874653","075e16b2615ed16db9225bb28048cb334324e071") +-Mapping("df511d5548ebb7f971abcd3a5283cb1d37b64596","972d67cec1fc0aeafebcc60ffcdf4dea0eadff8c") +-Mapping("dcbbfb6e807fdff9c9ba80073bb755f9d9d95e31","d52acbe37f69a2ebc9d161c479ed628da1cbea4e") +-Mapping("78d8416caf65cfb50de61bb9423e9efa026bd45a","f5f74a22c94a7053d33c88d135f9fdc44fa2ea5b") +-Mapping("8f1339af2e5d1b33ec9ee3c8a3c531bcd61770fc","cc20ab1f2509de4ef0a9953e514d62fa23b6c572") +-Mapping("05cbece0948f4fc0da3e21a7309e5ed34afdafe2","075e16b2615ed16db9225bb28048cb334324e071") +-Mapping("b39c4bc12358078f77ddd01288b24252f757f37d","3024c1434a667425d30e4b0785857381323712aa") +-Mapping("d7e73e4b1abe120520d1894b89c0e25469f41e69","075e16b2615ed16db9225bb28048cb334324e071") +-Mapping("e97ba83287a6f0f85cc9cc7a51ab309487e17038","9b090a026108fab89cfe5f39bfd3492597e76ad4") +-Mapping("3bee2b44cfd5610ad0346f0179602d91a8dedfd0","3024c1434a667425d30e4b0785857381323712aa") +-Mapping("0679711398bef656699e1ff6b004ecccbdb67284","d280b40b18532dfeb80b1a98109fa6218630b939") +-Mapping("e21df8020d0d1a37d2856117b1be2f1a91d8bc42","1ccb50eaa670f86b69e7a64484a8c97e13169183") +-Mapping("59ccba995de202fb9d9a8d795d2770fb2d199db0","c9f99924192e5c3a8d120eb36bcf96419b3fc7e0") +-Mapping("692b94ae25e0ae7d74cf15a5800e10a16239dab1","d52acbe37f69a2ebc9d161c479ed628da1cbea4e") +-Mapping("def3269a71be2e737cad27418a3dad9f5bd6cd32","6966f335ac7037900831007022f8d655bc186904") +-Mapping("bf0a9e0b4d3a4dd09717960840798e2933ec7568","d280b40b18532dfeb80b1a98109fa6218630b939") +-Mapping("bd98fe0c05601d8a318a709adc4263f3348ea8d4","e9d70417cae7fcb08323351d9388b65b39560156") +-Mapping("28a1e4ffefa2620ad9f4179ea339833448874fd3","f0a968eada509f71971e3ece02f8ec91b6f79e8a") +-Mapping("3bd4af88bea2e6ecdd3455ed89b3ef1fc3500aa4","6966f335ac7037900831007022f8d655bc186904") +-Mapping("aabfed5e0c84211005c1cb2ecec2206a574a5146","838a38365daa047fca7e57f63f9c54614c45595f") +-Mapping("2789b067da2ac921b86199bde21dd231ace1da39","cb56b2d1522e83c5bb0613abcf78b686e994df9e") +-Mapping("185cc5f26d2c8a794189b028b43f6a3b8fc586db","075e16b2615ed16db9225bb28048cb334324e071") +-Mapping("77e189cd79ce98cf8d39082157445db54696f316","b60e6f82855d387c0ad98179c33e6c019e8a7d26") +-Mapping("3ec5a99aaa0084d97a9e845b34fdf03d1462c475","e9d70417cae7fcb08323351d9388b65b39560156") +-Mapping("246a6d19c9844744737876fc55701395ae535579","9b090a026108fab89cfe5f39bfd3492597e76ad4") +-Mapping("13d94d5fa8129a34f5c77a1bcd76983f5aed2434","9c854db82b767ddd228dbff1e51bb3eed87464b4") +-Mapping("5a2465e2b44ecdd3b5d835c0abe29e9a4c9dcfe4","02c1862fb55c6ae4198038b1b317bcdd06e395d1") +-Mapping("61452e506f0c88861cccaeea4ced3419bdb3cbe0","93969734f6a8f38e95c7038c926ab2504e87dad6") +-Mapping("02004ef78383cb174a41df7735a552823fa10b90","58557fafae060c500394d5df13cd0cf68170903e") +-Mapping("b65f0bedd2f22d9661ecb7092f07746dc2ccfb0d","b60e6f82855d387c0ad98179c33e6c019e8a7d26") +-Mapping("69c65d29615c391c958ebf75dd65258ec23e175c","ecbb896b9eb2acadefde57be493e4298c1aa04a3") +-Mapping("e2668882406b68739c6ed33d420358d5d710e67b","49ee9f3f08ba4583bc722a663e43551067ace271") +-Mapping("14039a42ac6365afc842214989613f9a688c9a66","ff457f012aef26f82c42c73783d7d3810d04d624") +-Mapping("7d6e5b9da0865fbc9fa54edb324fefe80f358da7","6966f335ac7037900831007022f8d655bc186904") +-Mapping("f142499539d038ef60f4e22cafe11ecdd8a29a1d","72e8009185b537083015f43a8e0fd34509ab1938") +-Mapping("83c659ef655b1f740777f83eb415fd7ebe5a3fe5","cc20ab1f2509de4ef0a9953e514d62fa23b6c572") +-Mapping("58a8e0c27152e9306f8e0cd4fa3a162f5ae8e8c4","45d5a420ada9c11f61347fd4c63c7f0234adaea7") +-Mapping("2be4cc040211a85b17f21e813ff62351ae4de642","e2554b36fc805c5dcb8bef65fee12e0753d5ad03") +-Mapping("1956d5535ad77ddf46e4b29ba089a8b4a73cfaea","4c8cddb11b34021434d8d757e174096b10475840") +-Mapping("f8af59d95225d122e38bb5dceb1027844d4ce170","3024c1434a667425d30e4b0785857381323712aa") +-Mapping("f774bced502cf190426f778001a342715acb1d47","972d67cec1fc0aeafebcc60ffcdf4dea0eadff8c") +-Mapping("2f1ef9ef1181298d46e79d5dde6bafeb6483926f","1d6d09fa6d3392343a89e1a4d116bf4170334300") +-Mapping("26015da01497b4014fc4f2ecedee5a7090c354e6","075e16b2615ed16db9225bb28048cb334324e071") +-Mapping("01c65cb15ac57bfdc91613a4f6032ecc76c402a3","ff457f012aef26f82c42c73783d7d3810d04d624") +-Mapping("6160040d8547222e761ad876cbe3a48c9c90a5bf","838a38365daa047fca7e57f63f9c54614c45595f") +-Mapping("05f8ddc46a3fc09762a19f6c168550ce1ae66593","075e16b2615ed16db9225bb28048cb334324e071") +-Mapping("cfba0d446e8ab90f0c81aa0942819d05621c8b8e","02c1862fb55c6ae4198038b1b317bcdd06e395d1") +-Mapping("17f56c549c35bb2cb316e5abff116e65277c7bb1","ff457f012aef26f82c42c73783d7d3810d04d624") +-Mapping("37849a002ed91ac2b80aeb2172364b4e19250e05","ecbb896b9eb2acadefde57be493e4298c1aa04a3") +-Mapping("696412de7e4e119f8536686c643621115b90c775","d280b40b18532dfeb80b1a98109fa6218630b939") +-Mapping("1abeb436d5b9618d96fe5ac093146aa3d782ef26","b60e6f82855d387c0ad98179c33e6c019e8a7d26") +-Mapping("ba1d065ffa3606b61201ef69fec3ad0bfc5b2f7b","72e8009185b537083015f43a8e0fd34509ab1938") +-Mapping("5313e8728f028cb7914f3c9f02804158a5732b52","62d6ba4638c0a4623f9aa703aa790da1380806d7") +-Mapping("c11f689d2475dd9ab956e881238d5d7b6b485efb","49ee9f3f08ba4583bc722a663e43551067ace271") +-Mapping("ae98ebfcb9ad5a5384fd229a6ee91315b02ca969","cc20ab1f2509de4ef0a9953e514d62fa23b6c572") +-Mapping("3d292b793ade0c1c9098fb32586033d79f6e9969","e9d70417cae7fcb08323351d9388b65b39560156") +-Mapping("ad3543db3408b8d4ca53133a2999833befde8494","02c1862fb55c6ae4198038b1b317bcdd06e395d1") +-Mapping("9475ae477a4d42c564eab9621ffb6aa7c160a3dc","d280b40b18532dfeb80b1a98109fa6218630b939") +-Mapping("859c3236e5ab974f24a82bbebffc72f58cf43800","ecbb896b9eb2acadefde57be493e4298c1aa04a3") +-Mapping("c417ee9ae8c30ac307c58591da46cf62e91caac1","72e8009185b537083015f43a8e0fd34509ab1938") +-Mapping("259e4a67843d5fbe6761a5e442836d7109d72cbe","cb56b2d1522e83c5bb0613abcf78b686e994df9e") +-Mapping("4e9527cf6f2d3749554d07a96fe14967f5470ef6","d52acbe37f69a2ebc9d161c479ed628da1cbea4e") +-Mapping("0e6f4cf51cd3b799fb057956f8e733d16605d09b","075e16b2615ed16db9225bb28048cb334324e071") +-Mapping("f0fe716dbcbf2363ab8f929325d32a17e51039d0","d52acbe37f69a2ebc9d161c479ed628da1cbea4e") +-Mapping("d84693b93dae3958e3504f817face0184c5c3fdd","d280b40b18532dfeb80b1a98109fa6218630b939") +-Mapping("582af6e1ad75c12320e7237ff4361a1ed3514124","cc20ab1f2509de4ef0a9953e514d62fa23b6c572") +-Mapping("fa26421f56e385b1055e65b29a55b36bb2eae23e","838a38365daa047fca7e57f63f9c54614c45595f") +-Mapping("6c04c41034c46730fba97bfe9cfa2dd0687c2a5f","e9d70417cae7fcb08323351d9388b65b39560156") +-Mapping("b75d1f0ce252f4b53f8a97aee0fcf4a785186fef","72e8009185b537083015f43a8e0fd34509ab1938") +-Mapping("d6d711dd8f7ad5885294b8e1f0009a23dc1f8b1f","d52acbe37f69a2ebc9d161c479ed628da1cbea4e") +-Mapping("8503b3ff822c1ed01c89773d30e4e10b886d77a5","02c1862fb55c6ae4198038b1b317bcdd06e395d1") diff --git a/patches/02c1862fb55c6ae4198038b1b317bcdd06e395d1.patch b/patches/02c1862fb55c6ae4198038b1b317bcdd06e395d1.patch new file mode 100644 index 0000000..5d1bcd0 --- /dev/null +++ b/patches/02c1862fb55c6ae4198038b1b317bcdd06e395d1.patch @@ -0,0 +1,1642 @@ +diff --git a/buffered.rs b/buffered.rs +index 6d3fbc9..548f596 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Returns `true` if there are no bytes in the internal buffer. +@@ -167,7 +162,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "bufreader_is_empty", issue = "45323", reason = "recently added")] + pub fn is_empty(&self) -> bool { + self.pos == self.cap + } +@@ -190,11 +184,9 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -217,7 +209,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -237,7 +228,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -247,7 +237,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -345,7 +334,6 @@ impl Seek for BufReader { + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html + /// [`flush`]: #method.flush +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -380,7 +368,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -394,7 +381,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -412,7 +398,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -461,7 +446,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -479,7 +463,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -497,7 +480,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -506,7 +488,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -526,7 +507,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -536,7 +516,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -546,7 +525,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -585,7 +563,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -618,23 +595,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -689,7 +656,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -710,7 +676,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -731,7 +696,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -755,7 +719,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -778,7 +741,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -800,7 +762,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -811,7 +772,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -856,7 +816,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index b5ea553..b31cfa3 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,17 +215,16 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } + + fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> { + let n = buf.len(); +- Read::read_exact(&mut self.fill_buf()?, buf)?; ++ Read::read_exact(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(()) + } +@@ -243,16 +235,19 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -264,7 +259,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos: usize = self.position().try_into().map_err(|_| { +@@ -294,8 +289,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos = cmp::min(self.pos, self.inner.len() as u64); +diff --git a/error.rs b/error.rs +index bb9383d..01ddea6 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -48,7 +53,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and +@@ -63,7 +67,6 @@ pub type Result = result::Result; + /// [`Seek`]: ../io/trait.Seek.html + /// [`ErrorKind`]: enum.ErrorKind.html + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } +@@ -71,13 +74,16 @@ pub struct Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -89,47 +95,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -141,10 +134,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -155,15 +146,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -172,15 +160,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -213,7 +196,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -242,14 +224,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind, +@@ -258,24 +239,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -301,7 +264,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -332,7 +294,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -366,12 +327,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -437,12 +397,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -471,8 +430,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -498,10 +456,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -512,21 +469,18 @@ impl fmt::Debug for Repr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Repr::Os(ref code) => +- fmt.debug_struct("Os").field("code", code) +- .field("message", &sys::os::error_string(*code)).finish(), ++ fmt.debug_struct("Os").field("code", code).finish(), + Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -534,24 +488,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index fe1179a..452b8b7 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -207,6 +211,7 @@ impl<'a> Read for &'a [u8] { + Ok(()) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + buf.extend_from_slice(*self); +@@ -216,7 +221,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -230,7 +235,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -256,7 +260,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/memchr.rs b/memchr.rs +index 50f998e..a8bff09 100644 +--- a/memchr.rs ++++ b/memchr.rs +@@ -11,10 +11,12 @@ + // Original implementation taken from rust-memchr + // Copyright 2015 Andrew Gallant, bluss and Nicolas Koch + ++pub use self::fallback::{memchr,memrchr}; ++ + #[allow(dead_code)] + pub mod fallback { +- use cmp; +- use mem; ++ use core::cmp; ++ use core::mem; + + const LO_U64: u64 = 0x0101010101010101; + const HI_U64: u64 = 0x8080808080808080; +diff --git a/mod.rs b/mod.rs +index b7a3695..ad2460d 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -268,50 +268,35 @@ + //! [`Result`]: ../result/enum.Result.html + //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++mod memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -336,6 +321,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -363,6 +349,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -465,7 +452,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// [`BufRead`]: trait.BufRead.html + /// [`BufReader`]: struct.BufReader.html + /// [`&[u8]`]: primitive.slice.html +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning +@@ -522,7 +508,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -547,7 +532,6 @@ pub trait Read { + /// + /// [`Initializer::nop()`]: ../../std/io/struct.Initializer.html#method.nop + /// [`Initializer`]: ../../std/io/struct.Initializer.html +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -595,7 +579,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -633,7 +617,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -696,7 +680,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -748,7 +731,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an [`Iterator`] over its bytes. +@@ -785,7 +767,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -826,10 +807,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -864,7 +841,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -900,20 +876,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -927,21 +900,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -984,7 +954,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. +@@ -1029,7 +998,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1055,7 +1023,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1085,7 +1052,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1137,7 +1103,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1193,7 +1158,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1223,7 +1187,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1239,7 +1202,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1249,29 +1211,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1351,7 +1310,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1396,7 +1355,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1418,7 +1376,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1476,7 +1433,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1533,7 +1489,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1574,7 +1529,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1613,7 +1567,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1625,7 +1578,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1651,7 +1603,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1674,7 +1625,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1701,13 +1651,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1717,7 +1665,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1739,7 +1686,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1766,7 +1713,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1801,7 +1747,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Sets the number of bytes that can be read before this instance will +@@ -1828,7 +1773,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "take_set_limit", issue = "42781")] + pub fn set_limit(&mut self, limit: u64) { + self.limit = limit; + } +@@ -1853,7 +1797,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1878,7 +1821,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1907,13 +1849,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1932,7 +1872,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1971,13 +1911,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -1992,8 +1930,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -2002,8 +1938,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -2013,8 +1947,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -2046,25 +1978,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2083,14 +1996,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2115,13 +2028,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 45d281e..0efc3b1 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -45,7 +46,6 @@ use mem; + /// # } + /// # foo().unwrap(); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -74,7 +74,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of [`empty()`][`empty`] for more details. + /// + /// [`empty`]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -94,10 +93,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -107,7 +104,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -115,7 +113,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -128,7 +125,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -145,10 +141,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -164,7 +158,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -177,7 +170,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -194,10 +186,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -205,7 +195,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/075e16b2615ed16db9225bb28048cb334324e071.patch b/patches/075e16b2615ed16db9225bb28048cb334324e071.patch new file mode 100644 index 0000000..dce8163 --- /dev/null +++ b/patches/075e16b2615ed16db9225bb28048cb334324e071.patch @@ -0,0 +1,1618 @@ +diff --git a/buffered.rs b/buffered.rs +index 4ebd355..242aab4 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Unwraps this `BufReader`, returning the underlying reader. +@@ -165,11 +160,9 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -192,7 +185,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -212,7 +204,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -222,7 +213,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -320,7 +310,6 @@ impl Seek for BufReader { + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html + /// [`flush`]: #method.flush +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -355,7 +344,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -369,7 +357,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -387,7 +374,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -436,7 +422,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -454,7 +439,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -472,7 +456,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -481,7 +464,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -501,7 +483,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -511,7 +492,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -521,7 +501,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -560,7 +539,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -593,23 +571,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -664,7 +632,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -685,7 +652,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -706,7 +672,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -730,7 +695,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -753,7 +717,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -775,7 +738,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -786,7 +748,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -831,7 +792,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index 32a9214..21ed409 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,10 +215,9 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } +@@ -236,16 +228,19 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -257,7 +252,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos: usize = self.position().try_into().map_err(|_| { +@@ -287,8 +282,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos = cmp::min(self.pos, self.inner.len() as u64); +diff --git a/error.rs b/error.rs +index bb9383d..01ddea6 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -48,7 +53,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and +@@ -63,7 +67,6 @@ pub type Result = result::Result; + /// [`Seek`]: ../io/trait.Seek.html + /// [`ErrorKind`]: enum.ErrorKind.html + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } +@@ -71,13 +74,16 @@ pub struct Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -89,47 +95,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -141,10 +134,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -155,15 +146,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -172,15 +160,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -213,7 +196,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -242,14 +224,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind, +@@ -258,24 +239,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -301,7 +264,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -332,7 +294,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -366,12 +327,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -437,12 +397,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -471,8 +430,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -498,10 +456,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -512,21 +469,18 @@ impl fmt::Debug for Repr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Repr::Os(ref code) => +- fmt.debug_struct("Os").field("code", code) +- .field("message", &sys::os::error_string(*code)).finish(), ++ fmt.debug_struct("Os").field("code", code).finish(), + Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -534,24 +488,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index d6b41ce..1ddabf1 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -208,7 +212,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -222,7 +226,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -248,7 +251,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/memchr.rs b/memchr.rs +index 50f998e..a8bff09 100644 +--- a/memchr.rs ++++ b/memchr.rs +@@ -11,10 +11,12 @@ + // Original implementation taken from rust-memchr + // Copyright 2015 Andrew Gallant, bluss and Nicolas Koch + ++pub use self::fallback::{memchr,memrchr}; ++ + #[allow(dead_code)] + pub mod fallback { +- use cmp; +- use mem; ++ use core::cmp; ++ use core::mem; + + const LO_U64: u64 = 0x0101010101010101; + const HI_U64: u64 = 0x8080808080808080; +diff --git a/mod.rs b/mod.rs +index 074ab3e..8dfbe83 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -268,50 +268,35 @@ + //! [`Result`]: ../result/enum.Result.html + //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++mod memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -336,6 +321,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -363,6 +349,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -449,7 +436,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning + /// how many bytes were read. +@@ -505,7 +491,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -530,7 +515,6 @@ pub trait Read { + /// + /// [`Initializer::nop()`]: ../../std/io/struct.Initializer.html#method.nop + /// [`Initializer`]: ../../std/io/struct.Initializer.html +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -578,7 +562,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -616,7 +600,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -679,7 +663,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -731,7 +714,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an [`Iterator`] over its bytes. +@@ -767,7 +749,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -808,10 +789,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -846,7 +823,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -882,20 +858,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -909,21 +882,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -966,7 +936,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. + /// +@@ -1010,7 +979,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1036,7 +1004,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1066,7 +1033,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1118,7 +1084,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1174,7 +1139,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1204,7 +1168,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1220,7 +1183,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1230,29 +1192,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1332,7 +1291,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1377,7 +1336,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1399,7 +1357,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1455,7 +1412,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1510,7 +1466,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1551,7 +1506,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1590,7 +1544,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1602,7 +1555,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1628,7 +1580,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1651,7 +1602,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1678,13 +1628,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1694,7 +1642,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1716,7 +1663,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1743,7 +1690,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1778,7 +1724,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Sets the number of bytes that can be read before this instance will +@@ -1805,7 +1750,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "take_set_limit", issue = "42781")] + pub fn set_limit(&mut self, limit: u64) { + self.limit = limit; + } +@@ -1830,7 +1774,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1855,7 +1798,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1884,13 +1826,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1909,7 +1849,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1948,13 +1888,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -1969,8 +1907,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -1979,8 +1915,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -1990,8 +1924,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -2023,25 +1955,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2060,14 +1973,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2092,13 +2005,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 45d281e..0efc3b1 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -45,7 +46,6 @@ use mem; + /// # } + /// # foo().unwrap(); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -74,7 +74,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of [`empty()`][`empty`] for more details. + /// + /// [`empty`]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -94,10 +93,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -107,7 +104,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -115,7 +113,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -128,7 +125,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -145,10 +141,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -164,7 +158,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -177,7 +170,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -194,10 +186,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -205,7 +195,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/1b6c9605e41b7c7dc23e0e6f633f05912d0463dd.patch b/patches/1b6c9605e41b7c7dc23e0e6f633f05912d0463dd.patch new file mode 100644 index 0000000..3a75501 --- /dev/null +++ b/patches/1b6c9605e41b7c7dc23e0e6f633f05912d0463dd.patch @@ -0,0 +1,1618 @@ +diff --git a/buffered.rs b/buffered.rs +index 4ebd355..242aab4 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Unwraps this `BufReader`, returning the underlying reader. +@@ -165,11 +160,9 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -192,7 +185,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -212,7 +204,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -222,7 +213,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -320,7 +310,6 @@ impl Seek for BufReader { + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html + /// [`flush`]: #method.flush +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -355,7 +344,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -369,7 +357,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -387,7 +374,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -436,7 +422,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -454,7 +439,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -472,7 +456,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -481,7 +464,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -501,7 +483,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -511,7 +492,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -521,7 +501,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -560,7 +539,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -593,23 +571,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -664,7 +632,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -685,7 +652,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -706,7 +672,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -730,7 +695,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -753,7 +717,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -775,7 +738,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -786,7 +748,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -831,7 +792,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index d986021..4cd22cf 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,10 +215,9 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } +@@ -236,16 +228,19 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -257,7 +252,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos: usize = self.position().try_into().map_err(|_| { +@@ -287,8 +282,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos = cmp::min(self.pos, self.inner.len() as u64); +diff --git a/error.rs b/error.rs +index bb9383d..01ddea6 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -48,7 +53,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and +@@ -63,7 +67,6 @@ pub type Result = result::Result; + /// [`Seek`]: ../io/trait.Seek.html + /// [`ErrorKind`]: enum.ErrorKind.html + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } +@@ -71,13 +74,16 @@ pub struct Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -89,47 +95,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -141,10 +134,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -155,15 +146,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -172,15 +160,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -213,7 +196,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -242,14 +224,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind, +@@ -258,24 +239,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -301,7 +264,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -332,7 +294,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -366,12 +327,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -437,12 +397,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -471,8 +430,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -498,10 +456,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -512,21 +469,18 @@ impl fmt::Debug for Repr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Repr::Os(ref code) => +- fmt.debug_struct("Os").field("code", code) +- .field("message", &sys::os::error_string(*code)).finish(), ++ fmt.debug_struct("Os").field("code", code).finish(), + Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -534,24 +488,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index d6b41ce..1ddabf1 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -208,7 +212,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -222,7 +226,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -248,7 +251,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/memchr.rs b/memchr.rs +index 3824a5f..312cf47 100644 +--- a/memchr.rs ++++ b/memchr.rs +@@ -11,10 +11,12 @@ + // Original implementation taken from rust-memchr + // Copyright 2015 Andrew Gallant, bluss and Nicolas Koch + ++pub use self::fallback::{memchr,memrchr}; ++ + #[allow(dead_code)] + pub mod fallback { +- use cmp; +- use mem; ++ use core::cmp; ++ use core::mem; + + const LO_U64: u64 = 0x0101010101010101; + const HI_U64: u64 = 0x8080808080808080; +diff --git a/mod.rs b/mod.rs +index f486493..6b63b12 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -268,50 +268,35 @@ + //! [`Result`]: ../result/enum.Result.html + //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++mod memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -336,6 +321,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -363,6 +349,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -448,7 +435,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning + /// how many bytes were read. +@@ -501,7 +487,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -523,7 +508,6 @@ pub trait Read { + /// This method is unsafe because a `Read`er could otherwise return a + /// non-zeroing `Initializer` from another `Read` type without an `unsafe` + /// block. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -568,7 +552,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -606,7 +590,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -667,7 +651,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -719,7 +702,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an `Iterator` over its bytes. +@@ -749,7 +731,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -786,10 +767,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -824,7 +801,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -858,20 +834,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -885,21 +858,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -942,7 +912,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. + /// +@@ -986,7 +955,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1012,7 +980,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1042,7 +1009,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1094,7 +1060,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1150,7 +1115,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1180,7 +1144,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1196,7 +1159,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1206,29 +1168,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1308,7 +1267,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1353,7 +1312,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1375,7 +1333,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1431,7 +1388,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1486,7 +1442,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1527,7 +1482,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1566,7 +1520,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1578,7 +1531,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1604,7 +1556,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1627,7 +1578,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1654,13 +1604,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1670,7 +1618,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1692,7 +1639,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1719,7 +1666,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1754,7 +1700,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Sets the number of bytes that can be read before this instance will +@@ -1781,7 +1726,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "take_set_limit", issue = "42781")] + pub fn set_limit(&mut self, limit: u64) { + self.limit = limit; + } +@@ -1806,7 +1750,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1831,7 +1774,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1860,13 +1802,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1885,7 +1825,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1924,13 +1864,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -1945,8 +1883,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -1955,8 +1891,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -1966,8 +1900,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -1999,25 +1931,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2036,14 +1949,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2068,13 +1981,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 88f4214..df974c3 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -44,7 +45,6 @@ use mem; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -73,7 +73,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of `empty()` for more details. + /// + /// [empty]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -91,10 +90,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -104,7 +101,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -112,7 +110,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -125,7 +122,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -142,10 +138,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -161,7 +155,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -174,7 +167,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -191,10 +183,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -202,7 +192,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/1ccb50eaa670f86b69e7a64484a8c97e13169183.patch b/patches/1ccb50eaa670f86b69e7a64484a8c97e13169183.patch new file mode 100644 index 0000000..be0007c --- /dev/null +++ b/patches/1ccb50eaa670f86b69e7a64484a8c97e13169183.patch @@ -0,0 +1,1634 @@ +diff --git a/buffered.rs b/buffered.rs +index 6d3fbc9..548f596 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Returns `true` if there are no bytes in the internal buffer. +@@ -167,7 +162,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "bufreader_is_empty", issue = "45323", reason = "recently added")] + pub fn is_empty(&self) -> bool { + self.pos == self.cap + } +@@ -190,11 +184,9 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -217,7 +209,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -237,7 +228,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -247,7 +237,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -345,7 +334,6 @@ impl Seek for BufReader { + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html + /// [`flush`]: #method.flush +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -380,7 +368,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -394,7 +381,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -412,7 +398,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -461,7 +446,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -479,7 +463,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -497,7 +480,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -506,7 +488,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -526,7 +507,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -536,7 +516,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -546,7 +525,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -585,7 +563,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -618,23 +595,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -689,7 +656,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -710,7 +676,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -731,7 +696,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -755,7 +719,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -778,7 +741,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -800,7 +762,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -811,7 +772,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -856,7 +816,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index 32a9214..21ed409 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,10 +215,9 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } +@@ -236,16 +228,19 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -257,7 +252,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos: usize = self.position().try_into().map_err(|_| { +@@ -287,8 +282,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos = cmp::min(self.pos, self.inner.len() as u64); +diff --git a/error.rs b/error.rs +index bb9383d..01ddea6 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -48,7 +53,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and +@@ -63,7 +67,6 @@ pub type Result = result::Result; + /// [`Seek`]: ../io/trait.Seek.html + /// [`ErrorKind`]: enum.ErrorKind.html + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } +@@ -71,13 +74,16 @@ pub struct Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -89,47 +95,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -141,10 +134,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -155,15 +146,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -172,15 +160,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -213,7 +196,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -242,14 +224,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind, +@@ -258,24 +239,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -301,7 +264,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -332,7 +294,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -366,12 +327,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -437,12 +397,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -471,8 +430,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -498,10 +456,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -512,21 +469,18 @@ impl fmt::Debug for Repr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Repr::Os(ref code) => +- fmt.debug_struct("Os").field("code", code) +- .field("message", &sys::os::error_string(*code)).finish(), ++ fmt.debug_struct("Os").field("code", code).finish(), + Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -534,24 +488,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index fe1179a..452b8b7 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -207,6 +211,7 @@ impl<'a> Read for &'a [u8] { + Ok(()) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + buf.extend_from_slice(*self); +@@ -216,7 +221,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -230,7 +235,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -256,7 +260,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/memchr.rs b/memchr.rs +index 50f998e..a8bff09 100644 +--- a/memchr.rs ++++ b/memchr.rs +@@ -11,10 +11,12 @@ + // Original implementation taken from rust-memchr + // Copyright 2015 Andrew Gallant, bluss and Nicolas Koch + ++pub use self::fallback::{memchr,memrchr}; ++ + #[allow(dead_code)] + pub mod fallback { +- use cmp; +- use mem; ++ use core::cmp; ++ use core::mem; + + const LO_U64: u64 = 0x0101010101010101; + const HI_U64: u64 = 0x8080808080808080; +diff --git a/mod.rs b/mod.rs +index dec2812..4dfa83a 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -268,50 +268,35 @@ + //! [`Result`]: ../result/enum.Result.html + //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++mod memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -336,6 +321,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -363,6 +349,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -449,7 +436,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning + /// how many bytes were read. +@@ -505,7 +491,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -530,7 +515,6 @@ pub trait Read { + /// + /// [`Initializer::nop()`]: ../../std/io/struct.Initializer.html#method.nop + /// [`Initializer`]: ../../std/io/struct.Initializer.html +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -578,7 +562,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -616,7 +600,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -679,7 +663,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -731,7 +714,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an [`Iterator`] over its bytes. +@@ -768,7 +750,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -809,10 +790,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -847,7 +824,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -883,20 +859,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -910,21 +883,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -967,7 +937,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. + /// +@@ -1011,7 +980,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1037,7 +1005,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1067,7 +1034,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1119,7 +1085,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1175,7 +1140,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1205,7 +1169,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1221,7 +1184,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1231,29 +1193,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1333,7 +1292,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1378,7 +1337,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1400,7 +1358,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1458,7 +1415,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1515,7 +1471,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1556,7 +1511,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1595,7 +1549,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1607,7 +1560,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1633,7 +1585,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1656,7 +1607,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1683,13 +1633,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1699,7 +1647,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1721,7 +1668,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1748,7 +1695,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1783,7 +1729,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Sets the number of bytes that can be read before this instance will +@@ -1810,7 +1755,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "take_set_limit", issue = "42781")] + pub fn set_limit(&mut self, limit: u64) { + self.limit = limit; + } +@@ -1835,7 +1779,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1860,7 +1803,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1889,13 +1831,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1914,7 +1854,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1953,13 +1893,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -1974,8 +1912,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -1984,8 +1920,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -1995,8 +1929,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -2028,25 +1960,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2065,14 +1978,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2097,13 +2010,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 45d281e..0efc3b1 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -45,7 +46,6 @@ use mem; + /// # } + /// # foo().unwrap(); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -74,7 +74,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of [`empty()`][`empty`] for more details. + /// + /// [`empty`]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -94,10 +93,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -107,7 +104,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -115,7 +113,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -128,7 +125,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -145,10 +141,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -164,7 +158,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -177,7 +170,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -194,10 +186,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -205,7 +195,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/1d6d09fa6d3392343a89e1a4d116bf4170334300.patch b/patches/1d6d09fa6d3392343a89e1a4d116bf4170334300.patch new file mode 100644 index 0000000..0f0f43a --- /dev/null +++ b/patches/1d6d09fa6d3392343a89e1a4d116bf4170334300.patch @@ -0,0 +1,1618 @@ +diff --git a/buffered.rs b/buffered.rs +index 4ebd355..242aab4 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Unwraps this `BufReader`, returning the underlying reader. +@@ -165,11 +160,9 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -192,7 +185,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -212,7 +204,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -222,7 +213,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -320,7 +310,6 @@ impl Seek for BufReader { + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html + /// [`flush`]: #method.flush +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -355,7 +344,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -369,7 +357,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -387,7 +374,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -436,7 +422,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -454,7 +439,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -472,7 +456,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -481,7 +464,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -501,7 +483,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -511,7 +492,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -521,7 +501,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -560,7 +539,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -593,23 +571,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -664,7 +632,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -685,7 +652,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -706,7 +672,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -730,7 +695,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -753,7 +717,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -775,7 +738,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -786,7 +748,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -831,7 +792,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index 32a9214..21ed409 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,10 +215,9 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } +@@ -236,16 +228,19 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -257,7 +252,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos: usize = self.position().try_into().map_err(|_| { +@@ -287,8 +282,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos = cmp::min(self.pos, self.inner.len() as u64); +diff --git a/error.rs b/error.rs +index bb9383d..01ddea6 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -48,7 +53,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and +@@ -63,7 +67,6 @@ pub type Result = result::Result; + /// [`Seek`]: ../io/trait.Seek.html + /// [`ErrorKind`]: enum.ErrorKind.html + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } +@@ -71,13 +74,16 @@ pub struct Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -89,47 +95,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -141,10 +134,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -155,15 +146,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -172,15 +160,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -213,7 +196,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -242,14 +224,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind, +@@ -258,24 +239,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -301,7 +264,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -332,7 +294,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -366,12 +327,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -437,12 +397,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -471,8 +430,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -498,10 +456,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -512,21 +469,18 @@ impl fmt::Debug for Repr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Repr::Os(ref code) => +- fmt.debug_struct("Os").field("code", code) +- .field("message", &sys::os::error_string(*code)).finish(), ++ fmt.debug_struct("Os").field("code", code).finish(), + Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -534,24 +488,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index d6b41ce..1ddabf1 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -208,7 +212,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -222,7 +226,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -248,7 +251,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/memchr.rs b/memchr.rs +index 3824a5f..312cf47 100644 +--- a/memchr.rs ++++ b/memchr.rs +@@ -11,10 +11,12 @@ + // Original implementation taken from rust-memchr + // Copyright 2015 Andrew Gallant, bluss and Nicolas Koch + ++pub use self::fallback::{memchr,memrchr}; ++ + #[allow(dead_code)] + pub mod fallback { +- use cmp; +- use mem; ++ use core::cmp; ++ use core::mem; + + const LO_U64: u64 = 0x0101010101010101; + const HI_U64: u64 = 0x8080808080808080; +diff --git a/mod.rs b/mod.rs +index 074ab3e..8dfbe83 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -268,50 +268,35 @@ + //! [`Result`]: ../result/enum.Result.html + //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++mod memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -336,6 +321,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -363,6 +349,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -449,7 +436,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning + /// how many bytes were read. +@@ -505,7 +491,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -530,7 +515,6 @@ pub trait Read { + /// + /// [`Initializer::nop()`]: ../../std/io/struct.Initializer.html#method.nop + /// [`Initializer`]: ../../std/io/struct.Initializer.html +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -578,7 +562,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -616,7 +600,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -679,7 +663,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -731,7 +714,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an [`Iterator`] over its bytes. +@@ -767,7 +749,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -808,10 +789,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -846,7 +823,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -882,20 +858,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -909,21 +882,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -966,7 +936,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. + /// +@@ -1010,7 +979,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1036,7 +1004,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1066,7 +1033,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1118,7 +1084,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1174,7 +1139,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1204,7 +1168,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1220,7 +1183,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1230,29 +1192,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1332,7 +1291,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1377,7 +1336,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1399,7 +1357,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1455,7 +1412,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1510,7 +1466,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1551,7 +1506,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1590,7 +1544,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1602,7 +1555,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1628,7 +1580,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1651,7 +1602,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1678,13 +1628,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1694,7 +1642,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1716,7 +1663,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1743,7 +1690,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1778,7 +1724,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Sets the number of bytes that can be read before this instance will +@@ -1805,7 +1750,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "take_set_limit", issue = "42781")] + pub fn set_limit(&mut self, limit: u64) { + self.limit = limit; + } +@@ -1830,7 +1774,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1855,7 +1798,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1884,13 +1826,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1909,7 +1849,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1948,13 +1888,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -1969,8 +1907,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -1979,8 +1915,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -1990,8 +1924,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -2023,25 +1955,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2060,14 +1973,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2092,13 +2005,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 88f4214..df974c3 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -44,7 +45,6 @@ use mem; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -73,7 +73,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of `empty()` for more details. + /// + /// [empty]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -91,10 +90,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -104,7 +101,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -112,7 +110,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -125,7 +122,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -142,10 +138,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -161,7 +155,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -174,7 +167,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -191,10 +183,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -202,7 +192,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/27ede55414e01f13c6869a8763da207e544cc6ad.patch b/patches/27ede55414e01f13c6869a8763da207e544cc6ad.patch new file mode 100644 index 0000000..f2d08d0 --- /dev/null +++ b/patches/27ede55414e01f13c6869a8763da207e544cc6ad.patch @@ -0,0 +1,1647 @@ +diff --git a/buffered.rs b/buffered.rs +index 7001d8e..8e5daa4 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Returns `true` if there are no bytes in the internal buffer. +@@ -167,7 +162,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "bufreader_is_empty", issue = "45323", reason = "recently added")] + pub fn is_empty(&self) -> bool { + self.pos == self.cap + } +@@ -190,11 +184,9 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -217,7 +209,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -237,7 +228,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -247,7 +237,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -345,7 +334,6 @@ impl Seek for BufReader { + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html + /// [`flush`]: #method.flush +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -380,7 +368,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -394,7 +381,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -412,7 +398,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -461,7 +446,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -479,7 +463,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -501,7 +484,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -510,7 +492,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -530,7 +511,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -540,7 +520,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -550,7 +529,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -589,7 +567,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -622,23 +599,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -696,7 +663,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -717,7 +683,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -738,7 +703,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -762,7 +726,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -785,7 +748,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -811,7 +773,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -822,7 +783,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -867,7 +827,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index c844770..dcc64c6 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,17 +215,16 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } + + fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> { + let n = buf.len(); +- Read::read_exact(&mut self.fill_buf()?, buf)?; ++ Read::read_exact(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(()) + } +@@ -243,12 +235,16 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +@@ -261,6 +257,7 @@ fn slice_write(pos_mut: &mut u64, slice: &mut [u8], buf: &[u8]) -> io::Result, buf: &[u8]) -> io::Result { + let pos: usize = (*pos_mut).try_into().map_err(|_| { + Error::new(ErrorKind::InvalidInput, +@@ -287,7 +284,6 @@ fn vec_write(pos_mut: &mut u64, vec: &mut Vec, buf: &[u8]) -> io::Result Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +@@ -296,7 +292,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[unstable(feature = "cursor_mut_vec", issue = "30132")] ++#[cfg(feature="collections")] + impl<'a> Write for Cursor<&'a mut Vec> { + fn write(&mut self, buf: &[u8]) -> io::Result { + vec_write(&mut self.pos, self.inner, buf) +@@ -304,7 +300,7 @@ impl<'a> Write for Cursor<&'a mut Vec> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + vec_write(&mut self.pos, &mut self.inner, buf) +@@ -312,8 +308,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + slice_write(&mut self.pos, &mut self.inner, buf) +diff --git a/error.rs b/error.rs +index bb9383d..01ddea6 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -48,7 +53,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and +@@ -63,7 +67,6 @@ pub type Result = result::Result; + /// [`Seek`]: ../io/trait.Seek.html + /// [`ErrorKind`]: enum.ErrorKind.html + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } +@@ -71,13 +74,16 @@ pub struct Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -89,47 +95,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -141,10 +134,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -155,15 +146,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -172,15 +160,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -213,7 +196,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -242,14 +224,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind, +@@ -258,24 +239,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -301,7 +264,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -332,7 +294,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -366,12 +327,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -437,12 +397,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -471,8 +430,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -498,10 +456,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -512,21 +469,18 @@ impl fmt::Debug for Repr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Repr::Os(ref code) => +- fmt.debug_struct("Os").field("code", code) +- .field("message", &sys::os::error_string(*code)).finish(), ++ fmt.debug_struct("Os").field("code", code).finish(), + Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -534,24 +488,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index fe1179a..452b8b7 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -207,6 +211,7 @@ impl<'a> Read for &'a [u8] { + Ok(()) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + buf.extend_from_slice(*self); +@@ -216,7 +221,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -230,7 +235,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -256,7 +260,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/mod.rs b/mod.rs +index 33d11eb..569daa2 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -268,50 +268,38 @@ + //! [`Result`]: ../result/enum.Result.html + //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++#[cfg(not(core_memchr))] ++mod memchr; ++#[cfg(all(feature="collections",core_memchr))] ++use core::slice::memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -336,6 +324,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -363,6 +352,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -466,7 +456,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// [`BufReader`]: struct.BufReader.html + /// [`&str`]: ../../std/primitive.str.html + /// [slice]: ../../std/primitive.slice.html +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning +@@ -523,7 +512,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -548,7 +536,6 @@ pub trait Read { + /// + /// [`Initializer::nop()`]: ../../std/io/struct.Initializer.html#method.nop + /// [`Initializer`]: ../../std/io/struct.Initializer.html +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -596,7 +583,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -634,7 +621,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -697,7 +684,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -749,7 +735,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an [`Iterator`] over its bytes. +@@ -786,7 +771,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -827,10 +811,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -865,7 +845,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -901,20 +880,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -928,21 +904,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -985,7 +958,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. +@@ -1034,7 +1006,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1060,7 +1031,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1093,7 +1063,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1145,7 +1114,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1201,7 +1169,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1231,7 +1198,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1247,7 +1213,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1257,29 +1222,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1359,7 +1321,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1404,7 +1366,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1426,7 +1387,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1484,7 +1444,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1541,7 +1500,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1582,7 +1540,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1621,7 +1578,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1633,7 +1589,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1659,7 +1614,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1682,7 +1636,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1709,13 +1662,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1725,7 +1676,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1747,7 +1697,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1774,7 +1724,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1809,7 +1758,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Sets the number of bytes that can be read before this instance will +@@ -1836,7 +1784,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "take_set_limit", issue = "42781")] + pub fn set_limit(&mut self, limit: u64) { + self.limit = limit; + } +@@ -1861,7 +1808,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1886,7 +1832,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1915,13 +1860,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1940,7 +1883,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1979,13 +1922,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -2000,8 +1941,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -2010,8 +1949,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -2021,8 +1958,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -2053,25 +1988,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2090,14 +2006,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2122,13 +2038,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 45d281e..0efc3b1 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -45,7 +46,6 @@ use mem; + /// # } + /// # foo().unwrap(); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -74,7 +74,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of [`empty()`][`empty`] for more details. + /// + /// [`empty`]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -94,10 +93,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -107,7 +104,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -115,7 +113,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -128,7 +125,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -145,10 +141,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -164,7 +158,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -177,7 +170,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -194,10 +186,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -205,7 +195,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/3024c1434a667425d30e4b0785857381323712aa.patch b/patches/3024c1434a667425d30e4b0785857381323712aa.patch new file mode 100644 index 0000000..3dc7c96 --- /dev/null +++ b/patches/3024c1434a667425d30e4b0785857381323712aa.patch @@ -0,0 +1,1642 @@ +diff --git a/buffered.rs b/buffered.rs +index 6d3fbc9..548f596 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Returns `true` if there are no bytes in the internal buffer. +@@ -167,7 +162,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "bufreader_is_empty", issue = "45323", reason = "recently added")] + pub fn is_empty(&self) -> bool { + self.pos == self.cap + } +@@ -190,11 +184,9 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -217,7 +209,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -237,7 +228,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -247,7 +237,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -345,7 +334,6 @@ impl Seek for BufReader { + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html + /// [`flush`]: #method.flush +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -380,7 +368,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -394,7 +381,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -412,7 +398,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -461,7 +446,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -479,7 +463,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -497,7 +480,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -506,7 +488,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -526,7 +507,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -536,7 +516,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -546,7 +525,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -585,7 +563,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -618,23 +595,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -689,7 +656,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -710,7 +676,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -731,7 +696,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -755,7 +719,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -778,7 +741,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -800,7 +762,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -811,7 +772,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -856,7 +816,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index b5ea553..b31cfa3 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,17 +215,16 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } + + fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> { + let n = buf.len(); +- Read::read_exact(&mut self.fill_buf()?, buf)?; ++ Read::read_exact(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(()) + } +@@ -243,16 +235,19 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -264,7 +259,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos: usize = self.position().try_into().map_err(|_| { +@@ -294,8 +289,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos = cmp::min(self.pos, self.inner.len() as u64); +diff --git a/error.rs b/error.rs +index bb9383d..01ddea6 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -48,7 +53,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and +@@ -63,7 +67,6 @@ pub type Result = result::Result; + /// [`Seek`]: ../io/trait.Seek.html + /// [`ErrorKind`]: enum.ErrorKind.html + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } +@@ -71,13 +74,16 @@ pub struct Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -89,47 +95,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -141,10 +134,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -155,15 +146,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -172,15 +160,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -213,7 +196,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -242,14 +224,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind, +@@ -258,24 +239,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -301,7 +264,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -332,7 +294,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -366,12 +327,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -437,12 +397,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -471,8 +430,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -498,10 +456,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -512,21 +469,18 @@ impl fmt::Debug for Repr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Repr::Os(ref code) => +- fmt.debug_struct("Os").field("code", code) +- .field("message", &sys::os::error_string(*code)).finish(), ++ fmt.debug_struct("Os").field("code", code).finish(), + Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -534,24 +488,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index fe1179a..452b8b7 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -207,6 +211,7 @@ impl<'a> Read for &'a [u8] { + Ok(()) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + buf.extend_from_slice(*self); +@@ -216,7 +221,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -230,7 +235,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -256,7 +260,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/memchr.rs b/memchr.rs +index 50f998e..a8bff09 100644 +--- a/memchr.rs ++++ b/memchr.rs +@@ -11,10 +11,12 @@ + // Original implementation taken from rust-memchr + // Copyright 2015 Andrew Gallant, bluss and Nicolas Koch + ++pub use self::fallback::{memchr,memrchr}; ++ + #[allow(dead_code)] + pub mod fallback { +- use cmp; +- use mem; ++ use core::cmp; ++ use core::mem; + + const LO_U64: u64 = 0x0101010101010101; + const HI_U64: u64 = 0x8080808080808080; +diff --git a/mod.rs b/mod.rs +index 9c401d7..99da778 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -268,50 +268,35 @@ + //! [`Result`]: ../result/enum.Result.html + //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++mod memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -336,6 +321,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -363,6 +349,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -465,7 +452,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// [`BufRead`]: trait.BufRead.html + /// [`BufReader`]: struct.BufReader.html + /// [`&[u8]`]: primitive.slice.html +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning +@@ -522,7 +508,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -547,7 +532,6 @@ pub trait Read { + /// + /// [`Initializer::nop()`]: ../../std/io/struct.Initializer.html#method.nop + /// [`Initializer`]: ../../std/io/struct.Initializer.html +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -595,7 +579,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -633,7 +617,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -696,7 +680,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -748,7 +731,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an [`Iterator`] over its bytes. +@@ -785,7 +767,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -826,10 +807,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -864,7 +841,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -900,20 +876,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -927,21 +900,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -984,7 +954,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. +@@ -1029,7 +998,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1055,7 +1023,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1085,7 +1052,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1137,7 +1103,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1193,7 +1158,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1223,7 +1187,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1239,7 +1202,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1249,29 +1211,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1351,7 +1310,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1396,7 +1355,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1418,7 +1376,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1476,7 +1433,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1533,7 +1489,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1574,7 +1529,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1613,7 +1567,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1625,7 +1578,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1651,7 +1603,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1674,7 +1625,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1701,13 +1651,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1717,7 +1665,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1739,7 +1686,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1766,7 +1713,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1801,7 +1747,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Sets the number of bytes that can be read before this instance will +@@ -1828,7 +1773,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "take_set_limit", issue = "42781")] + pub fn set_limit(&mut self, limit: u64) { + self.limit = limit; + } +@@ -1853,7 +1797,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1878,7 +1821,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1907,13 +1849,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1932,7 +1872,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1971,13 +1911,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -1992,8 +1930,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -2002,8 +1938,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -2013,8 +1947,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -2045,25 +1977,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2082,14 +1995,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2114,13 +2027,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 45d281e..0efc3b1 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -45,7 +46,6 @@ use mem; + /// # } + /// # foo().unwrap(); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -74,7 +74,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of [`empty()`][`empty`] for more details. + /// + /// [`empty`]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -94,10 +93,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -107,7 +104,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -115,7 +113,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -128,7 +125,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -145,10 +141,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -164,7 +158,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -177,7 +170,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -194,10 +186,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -205,7 +195,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/45d5a420ada9c11f61347fd4c63c7f0234adaea7.patch b/patches/45d5a420ada9c11f61347fd4c63c7f0234adaea7.patch new file mode 100644 index 0000000..6568bde --- /dev/null +++ b/patches/45d5a420ada9c11f61347fd4c63c7f0234adaea7.patch @@ -0,0 +1,1665 @@ +diff --git a/buffered.rs b/buffered.rs +index 4e7db5f..d956165 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Returns `true` if there are no bytes in the internal buffer. +@@ -167,7 +162,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "bufreader_is_empty", issue = "45323", reason = "recently added")] + pub fn is_empty(&self) -> bool { + self.pos == self.cap + } +@@ -190,7 +184,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +@@ -199,7 +192,6 @@ impl BufReader { + /// the buffer will not be flushed, allowing for more efficient seeks. + /// This method does not return the location of the underlying reader, so the caller + /// must track this information themselves if it is required. +- #[unstable(feature = "bufreader_seek_relative", issue = "31100")] + pub fn seek_relative(&mut self, offset: i64) -> io::Result<()> { + let pos = self.pos as u64; + if offset < 0 { +@@ -219,7 +211,6 @@ impl BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -242,7 +233,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -262,7 +252,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -272,7 +261,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -374,7 +362,6 @@ impl Seek for BufReader { + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html + /// [`flush`]: #method.flush +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -409,7 +396,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -423,7 +409,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -441,7 +426,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -490,7 +474,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -508,7 +491,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -530,7 +512,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -539,7 +520,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -559,7 +539,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -569,7 +548,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -579,7 +557,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -618,7 +595,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -651,23 +627,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -725,7 +691,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -746,7 +711,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -767,7 +731,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -791,7 +754,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -814,7 +776,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -840,7 +801,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -851,7 +811,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -896,7 +855,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index 76bcb5f..dcc64c6 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,17 +215,16 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } + + fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> { + let n = buf.len(); +- Read::read_exact(&mut self.fill_buf()?, buf)?; ++ Read::read_exact(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(()) + } +@@ -243,12 +235,16 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +@@ -261,6 +257,7 @@ fn slice_write(pos_mut: &mut u64, slice: &mut [u8], buf: &[u8]) -> io::Result, buf: &[u8]) -> io::Result { + let pos: usize = (*pos_mut).try_into().map_err(|_| { + Error::new(ErrorKind::InvalidInput, +@@ -287,7 +284,6 @@ fn vec_write(pos_mut: &mut u64, vec: &mut Vec, buf: &[u8]) -> io::Result Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +@@ -296,7 +292,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_mut_vec", since = "1.25.0")] ++#[cfg(feature="collections")] + impl<'a> Write for Cursor<&'a mut Vec> { + fn write(&mut self, buf: &[u8]) -> io::Result { + vec_write(&mut self.pos, self.inner, buf) +@@ -304,7 +300,7 @@ impl<'a> Write for Cursor<&'a mut Vec> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + vec_write(&mut self.pos, &mut self.inner, buf) +@@ -312,8 +308,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + slice_write(&mut self.pos, &mut self.inner, buf) +diff --git a/error.rs b/error.rs +index bdd675e..3acdadf 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -48,7 +53,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and +@@ -62,12 +66,10 @@ pub type Result = result::Result; + /// [`Write`]: ../io/trait.Write.html + /// [`Seek`]: ../io/trait.Seek.html + /// [`ErrorKind`]: enum.ErrorKind.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Debug::fmt(&self.repr, f) +@@ -77,13 +79,16 @@ impl fmt::Debug for Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -95,47 +100,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -147,10 +139,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -161,15 +151,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -178,15 +165,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -219,7 +201,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -248,14 +229,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind, +@@ -264,24 +244,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -307,7 +269,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::InvalidInput); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -338,7 +299,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -372,12 +332,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -443,12 +402,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -477,8 +435,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -504,10 +461,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -519,22 +475,18 @@ impl fmt::Debug for Repr { + match *self { + Repr::Os(code) => + fmt.debug_struct("Os") +- .field("code", &code) +- .field("kind", &sys::decode_error_kind(code)) +- .field("message", &sys::os::error_string(code)).finish(), ++ .field("code", &code).finish(), + Repr::Custom(ref c) => fmt::Debug::fmt(&c, fmt), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -542,24 +494,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index fe1179a..452b8b7 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -207,6 +211,7 @@ impl<'a> Read for &'a [u8] { + Ok(()) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + buf.extend_from_slice(*self); +@@ -216,7 +221,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -230,7 +235,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -256,7 +260,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/mod.rs b/mod.rs +index 33d11eb..569daa2 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -268,50 +268,38 @@ + //! [`Result`]: ../result/enum.Result.html + //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++#[cfg(not(core_memchr))] ++mod memchr; ++#[cfg(all(feature="collections",core_memchr))] ++use core::slice::memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -336,6 +324,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -363,6 +352,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -466,7 +456,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// [`BufReader`]: struct.BufReader.html + /// [`&str`]: ../../std/primitive.str.html + /// [slice]: ../../std/primitive.slice.html +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning +@@ -523,7 +512,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -548,7 +536,6 @@ pub trait Read { + /// + /// [`Initializer::nop()`]: ../../std/io/struct.Initializer.html#method.nop + /// [`Initializer`]: ../../std/io/struct.Initializer.html +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -596,7 +583,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -634,7 +621,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -697,7 +684,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -749,7 +735,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an [`Iterator`] over its bytes. +@@ -786,7 +771,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -827,10 +811,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -865,7 +845,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -901,20 +880,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -928,21 +904,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -985,7 +958,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. +@@ -1034,7 +1006,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1060,7 +1031,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1093,7 +1063,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1145,7 +1114,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1201,7 +1169,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1231,7 +1198,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1247,7 +1213,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1257,29 +1222,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1359,7 +1321,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1404,7 +1366,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1426,7 +1387,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1484,7 +1444,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1541,7 +1500,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1582,7 +1540,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1621,7 +1578,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1633,7 +1589,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1659,7 +1614,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1682,7 +1636,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1709,13 +1662,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1725,7 +1676,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1747,7 +1697,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1774,7 +1724,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1809,7 +1758,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Sets the number of bytes that can be read before this instance will +@@ -1836,7 +1784,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "take_set_limit", issue = "42781")] + pub fn set_limit(&mut self, limit: u64) { + self.limit = limit; + } +@@ -1861,7 +1808,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1886,7 +1832,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1915,13 +1860,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1940,7 +1883,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1979,13 +1922,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -2000,8 +1941,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -2010,8 +1949,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -2021,8 +1958,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -2053,25 +1988,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2090,14 +2006,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2122,13 +2038,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 45d281e..0efc3b1 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -45,7 +46,6 @@ use mem; + /// # } + /// # foo().unwrap(); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -74,7 +74,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of [`empty()`][`empty`] for more details. + /// + /// [`empty`]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -94,10 +93,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -107,7 +104,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -115,7 +113,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -128,7 +125,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -145,10 +141,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -164,7 +158,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -177,7 +170,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -194,10 +186,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -205,7 +195,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/49ee9f3f08ba4583bc722a663e43551067ace271.patch b/patches/49ee9f3f08ba4583bc722a663e43551067ace271.patch new file mode 100644 index 0000000..0f0f43a --- /dev/null +++ b/patches/49ee9f3f08ba4583bc722a663e43551067ace271.patch @@ -0,0 +1,1618 @@ +diff --git a/buffered.rs b/buffered.rs +index 4ebd355..242aab4 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Unwraps this `BufReader`, returning the underlying reader. +@@ -165,11 +160,9 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -192,7 +185,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -212,7 +204,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -222,7 +213,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -320,7 +310,6 @@ impl Seek for BufReader { + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html + /// [`flush`]: #method.flush +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -355,7 +344,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -369,7 +357,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -387,7 +374,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -436,7 +422,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -454,7 +439,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -472,7 +456,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -481,7 +464,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -501,7 +483,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -511,7 +492,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -521,7 +501,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -560,7 +539,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -593,23 +571,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -664,7 +632,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -685,7 +652,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -706,7 +672,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -730,7 +695,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -753,7 +717,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -775,7 +738,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -786,7 +748,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -831,7 +792,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index 32a9214..21ed409 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,10 +215,9 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } +@@ -236,16 +228,19 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -257,7 +252,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos: usize = self.position().try_into().map_err(|_| { +@@ -287,8 +282,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos = cmp::min(self.pos, self.inner.len() as u64); +diff --git a/error.rs b/error.rs +index bb9383d..01ddea6 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -48,7 +53,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and +@@ -63,7 +67,6 @@ pub type Result = result::Result; + /// [`Seek`]: ../io/trait.Seek.html + /// [`ErrorKind`]: enum.ErrorKind.html + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } +@@ -71,13 +74,16 @@ pub struct Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -89,47 +95,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -141,10 +134,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -155,15 +146,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -172,15 +160,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -213,7 +196,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -242,14 +224,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind, +@@ -258,24 +239,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -301,7 +264,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -332,7 +294,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -366,12 +327,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -437,12 +397,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -471,8 +430,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -498,10 +456,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -512,21 +469,18 @@ impl fmt::Debug for Repr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Repr::Os(ref code) => +- fmt.debug_struct("Os").field("code", code) +- .field("message", &sys::os::error_string(*code)).finish(), ++ fmt.debug_struct("Os").field("code", code).finish(), + Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -534,24 +488,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index d6b41ce..1ddabf1 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -208,7 +212,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -222,7 +226,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -248,7 +251,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/memchr.rs b/memchr.rs +index 3824a5f..312cf47 100644 +--- a/memchr.rs ++++ b/memchr.rs +@@ -11,10 +11,12 @@ + // Original implementation taken from rust-memchr + // Copyright 2015 Andrew Gallant, bluss and Nicolas Koch + ++pub use self::fallback::{memchr,memrchr}; ++ + #[allow(dead_code)] + pub mod fallback { +- use cmp; +- use mem; ++ use core::cmp; ++ use core::mem; + + const LO_U64: u64 = 0x0101010101010101; + const HI_U64: u64 = 0x8080808080808080; +diff --git a/mod.rs b/mod.rs +index 074ab3e..8dfbe83 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -268,50 +268,35 @@ + //! [`Result`]: ../result/enum.Result.html + //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++mod memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -336,6 +321,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -363,6 +349,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -449,7 +436,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning + /// how many bytes were read. +@@ -505,7 +491,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -530,7 +515,6 @@ pub trait Read { + /// + /// [`Initializer::nop()`]: ../../std/io/struct.Initializer.html#method.nop + /// [`Initializer`]: ../../std/io/struct.Initializer.html +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -578,7 +562,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -616,7 +600,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -679,7 +663,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -731,7 +714,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an [`Iterator`] over its bytes. +@@ -767,7 +749,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -808,10 +789,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -846,7 +823,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -882,20 +858,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -909,21 +882,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -966,7 +936,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. + /// +@@ -1010,7 +979,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1036,7 +1004,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1066,7 +1033,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1118,7 +1084,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1174,7 +1139,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1204,7 +1168,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1220,7 +1183,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1230,29 +1192,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1332,7 +1291,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1377,7 +1336,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1399,7 +1357,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1455,7 +1412,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1510,7 +1466,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1551,7 +1506,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1590,7 +1544,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1602,7 +1555,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1628,7 +1580,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1651,7 +1602,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1678,13 +1628,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1694,7 +1642,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1716,7 +1663,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1743,7 +1690,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1778,7 +1724,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Sets the number of bytes that can be read before this instance will +@@ -1805,7 +1750,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "take_set_limit", issue = "42781")] + pub fn set_limit(&mut self, limit: u64) { + self.limit = limit; + } +@@ -1830,7 +1774,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1855,7 +1798,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1884,13 +1826,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1909,7 +1849,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1948,13 +1888,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -1969,8 +1907,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -1979,8 +1915,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -1990,8 +1924,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -2023,25 +1955,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2060,14 +1973,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2092,13 +2005,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 88f4214..df974c3 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -44,7 +45,6 @@ use mem; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -73,7 +73,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of `empty()` for more details. + /// + /// [empty]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -91,10 +90,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -104,7 +101,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -112,7 +110,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -125,7 +122,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -142,10 +138,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -161,7 +155,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -174,7 +167,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -191,10 +183,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -202,7 +192,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/4c8cddb11b34021434d8d757e174096b10475840.patch b/patches/4c8cddb11b34021434d8d757e174096b10475840.patch new file mode 100644 index 0000000..a8c8faa --- /dev/null +++ b/patches/4c8cddb11b34021434d8d757e174096b10475840.patch @@ -0,0 +1,1634 @@ +diff --git a/buffered.rs b/buffered.rs +index 6d3fbc9..548f596 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Returns `true` if there are no bytes in the internal buffer. +@@ -167,7 +162,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "bufreader_is_empty", issue = "45323", reason = "recently added")] + pub fn is_empty(&self) -> bool { + self.pos == self.cap + } +@@ -190,11 +184,9 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -217,7 +209,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -237,7 +228,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -247,7 +237,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -345,7 +334,6 @@ impl Seek for BufReader { + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html + /// [`flush`]: #method.flush +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -380,7 +368,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -394,7 +381,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -412,7 +398,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -461,7 +446,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -479,7 +463,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -497,7 +480,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -506,7 +488,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -526,7 +507,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -536,7 +516,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -546,7 +525,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -585,7 +563,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -618,23 +595,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -689,7 +656,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -710,7 +676,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -731,7 +696,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -755,7 +719,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -778,7 +741,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -800,7 +762,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -811,7 +772,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -856,7 +816,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index 32a9214..21ed409 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,10 +215,9 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } +@@ -236,16 +228,19 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -257,7 +252,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos: usize = self.position().try_into().map_err(|_| { +@@ -287,8 +282,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos = cmp::min(self.pos, self.inner.len() as u64); +diff --git a/error.rs b/error.rs +index bb9383d..01ddea6 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -48,7 +53,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and +@@ -63,7 +67,6 @@ pub type Result = result::Result; + /// [`Seek`]: ../io/trait.Seek.html + /// [`ErrorKind`]: enum.ErrorKind.html + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } +@@ -71,13 +74,16 @@ pub struct Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -89,47 +95,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -141,10 +134,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -155,15 +146,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -172,15 +160,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -213,7 +196,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -242,14 +224,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind, +@@ -258,24 +239,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -301,7 +264,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -332,7 +294,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -366,12 +327,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -437,12 +397,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -471,8 +430,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -498,10 +456,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -512,21 +469,18 @@ impl fmt::Debug for Repr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Repr::Os(ref code) => +- fmt.debug_struct("Os").field("code", code) +- .field("message", &sys::os::error_string(*code)).finish(), ++ fmt.debug_struct("Os").field("code", code).finish(), + Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -534,24 +488,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index fe1179a..452b8b7 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -207,6 +211,7 @@ impl<'a> Read for &'a [u8] { + Ok(()) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + buf.extend_from_slice(*self); +@@ -216,7 +221,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -230,7 +235,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -256,7 +260,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/memchr.rs b/memchr.rs +index 50f998e..a8bff09 100644 +--- a/memchr.rs ++++ b/memchr.rs +@@ -11,10 +11,12 @@ + // Original implementation taken from rust-memchr + // Copyright 2015 Andrew Gallant, bluss and Nicolas Koch + ++pub use self::fallback::{memchr,memrchr}; ++ + #[allow(dead_code)] + pub mod fallback { +- use cmp; +- use mem; ++ use core::cmp; ++ use core::mem; + + const LO_U64: u64 = 0x0101010101010101; + const HI_U64: u64 = 0x8080808080808080; +diff --git a/mod.rs b/mod.rs +index b7a3695..ad2460d 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -268,50 +268,35 @@ + //! [`Result`]: ../result/enum.Result.html + //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++mod memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -336,6 +321,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -363,6 +349,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -465,7 +452,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// [`BufRead`]: trait.BufRead.html + /// [`BufReader`]: struct.BufReader.html + /// [`&[u8]`]: primitive.slice.html +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning +@@ -522,7 +508,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -547,7 +532,6 @@ pub trait Read { + /// + /// [`Initializer::nop()`]: ../../std/io/struct.Initializer.html#method.nop + /// [`Initializer`]: ../../std/io/struct.Initializer.html +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -595,7 +579,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -633,7 +617,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -696,7 +680,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -748,7 +731,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an [`Iterator`] over its bytes. +@@ -785,7 +767,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -826,10 +807,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -864,7 +841,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -900,20 +876,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -927,21 +900,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -984,7 +954,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. +@@ -1029,7 +998,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1055,7 +1023,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1085,7 +1052,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1137,7 +1103,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1193,7 +1158,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1223,7 +1187,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1239,7 +1202,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1249,29 +1211,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1351,7 +1310,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1396,7 +1355,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1418,7 +1376,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1476,7 +1433,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1533,7 +1489,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1574,7 +1529,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1613,7 +1567,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1625,7 +1578,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1651,7 +1603,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1674,7 +1625,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1701,13 +1651,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1717,7 +1665,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1739,7 +1686,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1766,7 +1713,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1801,7 +1747,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Sets the number of bytes that can be read before this instance will +@@ -1828,7 +1773,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "take_set_limit", issue = "42781")] + pub fn set_limit(&mut self, limit: u64) { + self.limit = limit; + } +@@ -1853,7 +1797,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1878,7 +1821,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1907,13 +1849,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1932,7 +1872,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1971,13 +1911,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -1992,8 +1930,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -2002,8 +1938,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -2013,8 +1947,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -2046,25 +1978,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2083,14 +1996,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2115,13 +2028,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 45d281e..0efc3b1 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -45,7 +46,6 @@ use mem; + /// # } + /// # foo().unwrap(); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -74,7 +74,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of [`empty()`][`empty`] for more details. + /// + /// [`empty`]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -94,10 +93,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -107,7 +104,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -115,7 +113,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -128,7 +125,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -145,10 +141,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -164,7 +158,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -177,7 +170,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -194,10 +186,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -205,7 +195,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/58557fafae060c500394d5df13cd0cf68170903e.patch b/patches/58557fafae060c500394d5df13cd0cf68170903e.patch new file mode 100644 index 0000000..be0007c --- /dev/null +++ b/patches/58557fafae060c500394d5df13cd0cf68170903e.patch @@ -0,0 +1,1634 @@ +diff --git a/buffered.rs b/buffered.rs +index 6d3fbc9..548f596 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Returns `true` if there are no bytes in the internal buffer. +@@ -167,7 +162,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "bufreader_is_empty", issue = "45323", reason = "recently added")] + pub fn is_empty(&self) -> bool { + self.pos == self.cap + } +@@ -190,11 +184,9 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -217,7 +209,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -237,7 +228,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -247,7 +237,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -345,7 +334,6 @@ impl Seek for BufReader { + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html + /// [`flush`]: #method.flush +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -380,7 +368,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -394,7 +381,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -412,7 +398,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -461,7 +446,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -479,7 +463,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -497,7 +480,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -506,7 +488,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -526,7 +507,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -536,7 +516,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -546,7 +525,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -585,7 +563,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -618,23 +595,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -689,7 +656,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -710,7 +676,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -731,7 +696,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -755,7 +719,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -778,7 +741,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -800,7 +762,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -811,7 +772,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -856,7 +816,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index 32a9214..21ed409 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,10 +215,9 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } +@@ -236,16 +228,19 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -257,7 +252,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos: usize = self.position().try_into().map_err(|_| { +@@ -287,8 +282,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos = cmp::min(self.pos, self.inner.len() as u64); +diff --git a/error.rs b/error.rs +index bb9383d..01ddea6 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -48,7 +53,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and +@@ -63,7 +67,6 @@ pub type Result = result::Result; + /// [`Seek`]: ../io/trait.Seek.html + /// [`ErrorKind`]: enum.ErrorKind.html + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } +@@ -71,13 +74,16 @@ pub struct Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -89,47 +95,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -141,10 +134,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -155,15 +146,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -172,15 +160,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -213,7 +196,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -242,14 +224,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind, +@@ -258,24 +239,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -301,7 +264,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -332,7 +294,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -366,12 +327,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -437,12 +397,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -471,8 +430,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -498,10 +456,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -512,21 +469,18 @@ impl fmt::Debug for Repr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Repr::Os(ref code) => +- fmt.debug_struct("Os").field("code", code) +- .field("message", &sys::os::error_string(*code)).finish(), ++ fmt.debug_struct("Os").field("code", code).finish(), + Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -534,24 +488,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index fe1179a..452b8b7 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -207,6 +211,7 @@ impl<'a> Read for &'a [u8] { + Ok(()) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + buf.extend_from_slice(*self); +@@ -216,7 +221,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -230,7 +235,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -256,7 +260,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/memchr.rs b/memchr.rs +index 50f998e..a8bff09 100644 +--- a/memchr.rs ++++ b/memchr.rs +@@ -11,10 +11,12 @@ + // Original implementation taken from rust-memchr + // Copyright 2015 Andrew Gallant, bluss and Nicolas Koch + ++pub use self::fallback::{memchr,memrchr}; ++ + #[allow(dead_code)] + pub mod fallback { +- use cmp; +- use mem; ++ use core::cmp; ++ use core::mem; + + const LO_U64: u64 = 0x0101010101010101; + const HI_U64: u64 = 0x8080808080808080; +diff --git a/mod.rs b/mod.rs +index dec2812..4dfa83a 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -268,50 +268,35 @@ + //! [`Result`]: ../result/enum.Result.html + //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++mod memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -336,6 +321,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -363,6 +349,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -449,7 +436,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning + /// how many bytes were read. +@@ -505,7 +491,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -530,7 +515,6 @@ pub trait Read { + /// + /// [`Initializer::nop()`]: ../../std/io/struct.Initializer.html#method.nop + /// [`Initializer`]: ../../std/io/struct.Initializer.html +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -578,7 +562,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -616,7 +600,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -679,7 +663,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -731,7 +714,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an [`Iterator`] over its bytes. +@@ -768,7 +750,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -809,10 +790,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -847,7 +824,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -883,20 +859,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -910,21 +883,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -967,7 +937,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. + /// +@@ -1011,7 +980,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1037,7 +1005,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1067,7 +1034,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1119,7 +1085,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1175,7 +1140,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1205,7 +1169,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1221,7 +1184,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1231,29 +1193,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1333,7 +1292,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1378,7 +1337,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1400,7 +1358,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1458,7 +1415,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1515,7 +1471,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1556,7 +1511,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1595,7 +1549,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1607,7 +1560,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1633,7 +1585,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1656,7 +1607,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1683,13 +1633,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1699,7 +1647,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1721,7 +1668,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1748,7 +1695,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1783,7 +1729,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Sets the number of bytes that can be read before this instance will +@@ -1810,7 +1755,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "take_set_limit", issue = "42781")] + pub fn set_limit(&mut self, limit: u64) { + self.limit = limit; + } +@@ -1835,7 +1779,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1860,7 +1803,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1889,13 +1831,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1914,7 +1854,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1953,13 +1893,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -1974,8 +1912,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -1984,8 +1920,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -1995,8 +1929,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -2028,25 +1960,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2065,14 +1978,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2097,13 +2010,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 45d281e..0efc3b1 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -45,7 +46,6 @@ use mem; + /// # } + /// # foo().unwrap(); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -74,7 +74,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of [`empty()`][`empty`] for more details. + /// + /// [`empty`]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -94,10 +93,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -107,7 +104,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -115,7 +113,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -128,7 +125,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -145,10 +141,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -164,7 +158,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -177,7 +170,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -194,10 +186,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -205,7 +195,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/62d6ba4638c0a4623f9aa703aa790da1380806d7.patch b/patches/62d6ba4638c0a4623f9aa703aa790da1380806d7.patch new file mode 100644 index 0000000..40d5273 --- /dev/null +++ b/patches/62d6ba4638c0a4623f9aa703aa790da1380806d7.patch @@ -0,0 +1,1665 @@ +diff --git a/buffered.rs b/buffered.rs +index 4e7db5f..d956165 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Returns `true` if there are no bytes in the internal buffer. +@@ -167,7 +162,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "bufreader_is_empty", issue = "45323", reason = "recently added")] + pub fn is_empty(&self) -> bool { + self.pos == self.cap + } +@@ -190,7 +184,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +@@ -199,7 +192,6 @@ impl BufReader { + /// the buffer will not be flushed, allowing for more efficient seeks. + /// This method does not return the location of the underlying reader, so the caller + /// must track this information themselves if it is required. +- #[unstable(feature = "bufreader_seek_relative", issue = "31100")] + pub fn seek_relative(&mut self, offset: i64) -> io::Result<()> { + let pos = self.pos as u64; + if offset < 0 { +@@ -219,7 +211,6 @@ impl BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -242,7 +233,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -262,7 +252,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -272,7 +261,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -374,7 +362,6 @@ impl Seek for BufReader { + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html + /// [`flush`]: #method.flush +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -409,7 +396,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -423,7 +409,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -441,7 +426,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -490,7 +474,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -508,7 +491,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -530,7 +512,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -539,7 +520,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -559,7 +539,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -569,7 +548,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -579,7 +557,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -618,7 +595,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -651,23 +627,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -725,7 +691,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -746,7 +711,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -767,7 +731,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -791,7 +754,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -814,7 +776,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -840,7 +801,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -851,7 +811,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -896,7 +855,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index 76bcb5f..dcc64c6 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,17 +215,16 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } + + fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> { + let n = buf.len(); +- Read::read_exact(&mut self.fill_buf()?, buf)?; ++ Read::read_exact(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(()) + } +@@ -243,12 +235,16 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +@@ -261,6 +257,7 @@ fn slice_write(pos_mut: &mut u64, slice: &mut [u8], buf: &[u8]) -> io::Result, buf: &[u8]) -> io::Result { + let pos: usize = (*pos_mut).try_into().map_err(|_| { + Error::new(ErrorKind::InvalidInput, +@@ -287,7 +284,6 @@ fn vec_write(pos_mut: &mut u64, vec: &mut Vec, buf: &[u8]) -> io::Result Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +@@ -296,7 +292,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_mut_vec", since = "1.25.0")] ++#[cfg(feature="collections")] + impl<'a> Write for Cursor<&'a mut Vec> { + fn write(&mut self, buf: &[u8]) -> io::Result { + vec_write(&mut self.pos, self.inner, buf) +@@ -304,7 +300,7 @@ impl<'a> Write for Cursor<&'a mut Vec> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + vec_write(&mut self.pos, &mut self.inner, buf) +@@ -312,8 +308,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + slice_write(&mut self.pos, &mut self.inner, buf) +diff --git a/error.rs b/error.rs +index bdd675e..3acdadf 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -48,7 +53,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and +@@ -62,12 +66,10 @@ pub type Result = result::Result; + /// [`Write`]: ../io/trait.Write.html + /// [`Seek`]: ../io/trait.Seek.html + /// [`ErrorKind`]: enum.ErrorKind.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Debug::fmt(&self.repr, f) +@@ -77,13 +79,16 @@ impl fmt::Debug for Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -95,47 +100,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -147,10 +139,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -161,15 +151,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -178,15 +165,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -219,7 +201,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -248,14 +229,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind, +@@ -264,24 +244,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -307,7 +269,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::InvalidInput); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -338,7 +299,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -372,12 +332,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -443,12 +402,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -477,8 +435,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -504,10 +461,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -519,22 +475,18 @@ impl fmt::Debug for Repr { + match *self { + Repr::Os(code) => + fmt.debug_struct("Os") +- .field("code", &code) +- .field("kind", &sys::decode_error_kind(code)) +- .field("message", &sys::os::error_string(code)).finish(), ++ .field("code", &code).finish(), + Repr::Custom(ref c) => fmt::Debug::fmt(&c, fmt), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -542,24 +494,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index fe1179a..452b8b7 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -207,6 +211,7 @@ impl<'a> Read for &'a [u8] { + Ok(()) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + buf.extend_from_slice(*self); +@@ -216,7 +221,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -230,7 +235,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -256,7 +260,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/mod.rs b/mod.rs +index aa07f64..c6fee4b 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -268,50 +268,38 @@ + //! [`Result`]: ../result/enum.Result.html + //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++#[cfg(not(core_memchr))] ++mod memchr; ++#[cfg(all(feature="collections",core_memchr))] ++use core::slice::memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -336,6 +324,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -363,6 +352,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -466,7 +456,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// [`BufReader`]: struct.BufReader.html + /// [`&str`]: ../../std/primitive.str.html + /// [slice]: ../../std/primitive.slice.html +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning +@@ -523,7 +512,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -548,7 +536,6 @@ pub trait Read { + /// + /// [`Initializer::nop()`]: ../../std/io/struct.Initializer.html#method.nop + /// [`Initializer`]: ../../std/io/struct.Initializer.html +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -596,7 +583,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -634,7 +621,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -697,7 +684,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -749,7 +735,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an [`Iterator`] over its bytes. +@@ -786,7 +771,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -827,10 +811,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -865,7 +845,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -901,20 +880,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -928,21 +904,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -985,7 +958,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. +@@ -1034,7 +1006,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1060,7 +1031,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1093,7 +1063,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1145,7 +1114,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1201,7 +1169,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1231,7 +1198,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1247,7 +1213,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1257,29 +1222,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1359,7 +1321,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1404,7 +1366,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1426,7 +1387,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1482,7 +1442,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1539,7 +1498,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1580,7 +1538,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1619,7 +1576,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1631,7 +1587,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1657,7 +1612,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1680,7 +1634,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1707,13 +1660,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1723,7 +1674,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1745,7 +1695,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1772,7 +1722,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1807,7 +1756,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Sets the number of bytes that can be read before this instance will +@@ -1834,7 +1782,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "take_set_limit", issue = "42781")] + pub fn set_limit(&mut self, limit: u64) { + self.limit = limit; + } +@@ -1859,7 +1806,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1884,7 +1830,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1913,13 +1858,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1938,7 +1881,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1977,13 +1920,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -1998,8 +1939,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -2008,8 +1947,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -2019,8 +1956,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -2051,25 +1986,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2088,14 +2004,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2120,13 +2036,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 45d281e..0efc3b1 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -45,7 +46,6 @@ use mem; + /// # } + /// # foo().unwrap(); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -74,7 +74,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of [`empty()`][`empty`] for more details. + /// + /// [`empty`]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -94,10 +93,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -107,7 +104,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -115,7 +113,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -128,7 +125,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -145,10 +141,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -164,7 +158,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -177,7 +170,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -194,10 +186,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -205,7 +195,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/6966f335ac7037900831007022f8d655bc186904.patch b/patches/6966f335ac7037900831007022f8d655bc186904.patch new file mode 100644 index 0000000..67f2967 --- /dev/null +++ b/patches/6966f335ac7037900831007022f8d655bc186904.patch @@ -0,0 +1,1665 @@ +diff --git a/buffered.rs b/buffered.rs +index 4e7db5f..d956165 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Returns `true` if there are no bytes in the internal buffer. +@@ -167,7 +162,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "bufreader_is_empty", issue = "45323", reason = "recently added")] + pub fn is_empty(&self) -> bool { + self.pos == self.cap + } +@@ -190,7 +184,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +@@ -199,7 +192,6 @@ impl BufReader { + /// the buffer will not be flushed, allowing for more efficient seeks. + /// This method does not return the location of the underlying reader, so the caller + /// must track this information themselves if it is required. +- #[unstable(feature = "bufreader_seek_relative", issue = "31100")] + pub fn seek_relative(&mut self, offset: i64) -> io::Result<()> { + let pos = self.pos as u64; + if offset < 0 { +@@ -219,7 +211,6 @@ impl BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -242,7 +233,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -262,7 +252,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -272,7 +261,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -374,7 +362,6 @@ impl Seek for BufReader { + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html + /// [`flush`]: #method.flush +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -409,7 +396,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -423,7 +409,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -441,7 +426,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -490,7 +474,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -508,7 +491,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -530,7 +512,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -539,7 +520,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -559,7 +539,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -569,7 +548,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -579,7 +557,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -618,7 +595,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -651,23 +627,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -725,7 +691,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -746,7 +711,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -767,7 +731,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -791,7 +754,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -814,7 +776,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -840,7 +801,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -851,7 +811,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -896,7 +855,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index c844770..dcc64c6 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,17 +215,16 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } + + fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> { + let n = buf.len(); +- Read::read_exact(&mut self.fill_buf()?, buf)?; ++ Read::read_exact(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(()) + } +@@ -243,12 +235,16 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +@@ -261,6 +257,7 @@ fn slice_write(pos_mut: &mut u64, slice: &mut [u8], buf: &[u8]) -> io::Result, buf: &[u8]) -> io::Result { + let pos: usize = (*pos_mut).try_into().map_err(|_| { + Error::new(ErrorKind::InvalidInput, +@@ -287,7 +284,6 @@ fn vec_write(pos_mut: &mut u64, vec: &mut Vec, buf: &[u8]) -> io::Result Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +@@ -296,7 +292,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[unstable(feature = "cursor_mut_vec", issue = "30132")] ++#[cfg(feature="collections")] + impl<'a> Write for Cursor<&'a mut Vec> { + fn write(&mut self, buf: &[u8]) -> io::Result { + vec_write(&mut self.pos, self.inner, buf) +@@ -304,7 +300,7 @@ impl<'a> Write for Cursor<&'a mut Vec> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + vec_write(&mut self.pos, &mut self.inner, buf) +@@ -312,8 +308,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + slice_write(&mut self.pos, &mut self.inner, buf) +diff --git a/error.rs b/error.rs +index f0b41f3..5341820 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -48,7 +53,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and +@@ -62,12 +66,10 @@ pub type Result = result::Result; + /// [`Write`]: ../io/trait.Write.html + /// [`Seek`]: ../io/trait.Seek.html + /// [`ErrorKind`]: enum.ErrorKind.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Debug::fmt(&self.repr, f) +@@ -77,13 +79,16 @@ impl fmt::Debug for Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -95,47 +100,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -147,10 +139,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -161,15 +151,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -178,15 +165,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -219,7 +201,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -248,14 +229,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind, +@@ -264,24 +244,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -307,7 +269,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -338,7 +299,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -372,12 +332,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -443,12 +402,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -477,8 +435,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -504,10 +461,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -519,22 +475,18 @@ impl fmt::Debug for Repr { + match *self { + Repr::Os(code) => + fmt.debug_struct("Os") +- .field("code", &code) +- .field("kind", &sys::decode_error_kind(code)) +- .field("message", &sys::os::error_string(code)).finish(), ++ .field("code", &code).finish(), + Repr::Custom(ref c) => fmt::Debug::fmt(&c, fmt), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -542,24 +494,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index fe1179a..452b8b7 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -207,6 +211,7 @@ impl<'a> Read for &'a [u8] { + Ok(()) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + buf.extend_from_slice(*self); +@@ -216,7 +221,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -230,7 +235,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -256,7 +260,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/mod.rs b/mod.rs +index 33d11eb..569daa2 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -268,50 +268,38 @@ + //! [`Result`]: ../result/enum.Result.html + //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++#[cfg(not(core_memchr))] ++mod memchr; ++#[cfg(all(feature="collections",core_memchr))] ++use core::slice::memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -336,6 +324,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -363,6 +352,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -466,7 +456,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// [`BufReader`]: struct.BufReader.html + /// [`&str`]: ../../std/primitive.str.html + /// [slice]: ../../std/primitive.slice.html +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning +@@ -523,7 +512,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -548,7 +536,6 @@ pub trait Read { + /// + /// [`Initializer::nop()`]: ../../std/io/struct.Initializer.html#method.nop + /// [`Initializer`]: ../../std/io/struct.Initializer.html +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -596,7 +583,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -634,7 +621,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -697,7 +684,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -749,7 +735,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an [`Iterator`] over its bytes. +@@ -786,7 +771,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -827,10 +811,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -865,7 +845,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -901,20 +880,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -928,21 +904,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -985,7 +958,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. +@@ -1034,7 +1006,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1060,7 +1031,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1093,7 +1063,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1145,7 +1114,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1201,7 +1169,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1231,7 +1198,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1247,7 +1213,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1257,29 +1222,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1359,7 +1321,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1404,7 +1366,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1426,7 +1387,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1484,7 +1444,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1541,7 +1500,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1582,7 +1540,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1621,7 +1578,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1633,7 +1589,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1659,7 +1614,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1682,7 +1636,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1709,13 +1662,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1725,7 +1676,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1747,7 +1697,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1774,7 +1724,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1809,7 +1758,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Sets the number of bytes that can be read before this instance will +@@ -1836,7 +1784,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "take_set_limit", issue = "42781")] + pub fn set_limit(&mut self, limit: u64) { + self.limit = limit; + } +@@ -1861,7 +1808,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1886,7 +1832,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1915,13 +1860,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1940,7 +1883,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1979,13 +1922,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -2000,8 +1941,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -2010,8 +1949,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -2021,8 +1958,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -2053,25 +1988,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2090,14 +2006,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2122,13 +2038,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 45d281e..0efc3b1 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -45,7 +46,6 @@ use mem; + /// # } + /// # foo().unwrap(); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -74,7 +74,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of [`empty()`][`empty`] for more details. + /// + /// [`empty`]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -94,10 +93,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -107,7 +104,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -115,7 +113,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -128,7 +125,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -145,10 +141,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -164,7 +158,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -177,7 +170,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -194,10 +186,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -205,7 +195,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/72e8009185b537083015f43a8e0fd34509ab1938.patch b/patches/72e8009185b537083015f43a8e0fd34509ab1938.patch new file mode 100644 index 0000000..7648334 --- /dev/null +++ b/patches/72e8009185b537083015f43a8e0fd34509ab1938.patch @@ -0,0 +1,1618 @@ +diff --git a/buffered.rs b/buffered.rs +index d765dd2..1428736 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Unwraps this `BufReader`, returning the underlying reader. +@@ -165,11 +160,9 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -192,7 +185,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -212,7 +204,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -222,7 +213,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -320,7 +310,6 @@ impl Seek for BufReader { + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html + /// [`flush`]: #method.flush +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -355,7 +344,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -369,7 +357,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -387,7 +374,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -436,7 +422,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -454,7 +439,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -472,7 +456,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -481,7 +464,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -501,7 +483,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -511,7 +492,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -521,7 +501,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -560,7 +539,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -593,23 +571,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -664,7 +632,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -685,7 +652,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -706,7 +672,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -730,7 +695,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -753,7 +717,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -775,7 +738,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -786,7 +748,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -831,7 +792,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index 616b4f4..97d1076 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,10 +215,9 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } +@@ -236,16 +228,19 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -257,7 +252,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos: usize = self.position().try_into().map_err(|_| { +@@ -287,8 +282,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos = cmp::min(self.pos, self.inner.len() as u64); +diff --git a/error.rs b/error.rs +index 0a5804a..4564ca7 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -44,7 +49,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the `Read`, `Write`, `Seek`, and +@@ -56,7 +60,6 @@ pub type Result = result::Result; + /// + /// [`ErrorKind`]: enum.ErrorKind.html + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } +@@ -64,13 +67,16 @@ pub struct Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -82,47 +88,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -134,10 +127,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -148,15 +139,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -165,15 +153,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -206,7 +189,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -235,14 +217,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind: kind, +@@ -251,24 +232,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -294,7 +257,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -325,7 +287,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -359,12 +320,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -430,12 +390,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -464,8 +423,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -491,10 +449,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -505,21 +462,18 @@ impl fmt::Debug for Repr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Repr::Os(ref code) => +- fmt.debug_struct("Os").field("code", code) +- .field("message", &sys::os::error_string(*code)).finish(), ++ fmt.debug_struct("Os").field("code", code).finish(), + Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -527,24 +481,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index d6b41ce..1ddabf1 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -208,7 +212,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -222,7 +226,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -248,7 +251,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/memchr.rs b/memchr.rs +index 3824a5f..312cf47 100644 +--- a/memchr.rs ++++ b/memchr.rs +@@ -11,10 +11,12 @@ + // Original implementation taken from rust-memchr + // Copyright 2015 Andrew Gallant, bluss and Nicolas Koch + ++pub use self::fallback::{memchr,memrchr}; ++ + #[allow(dead_code)] + pub mod fallback { +- use cmp; +- use mem; ++ use core::cmp; ++ use core::mem; + + const LO_U64: u64 = 0x0101010101010101; + const HI_U64: u64 = 0x8080808080808080; +diff --git a/mod.rs b/mod.rs +index 9a3036f..bb88614 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -266,50 +266,35 @@ + //! [`?` operator]: ../../book/first-edition/syntax-index.html + //! [`Read::read`]: trait.Read.html#tymethod.read + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++mod memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -334,6 +319,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -361,6 +347,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -446,7 +433,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning + /// how many bytes were read. +@@ -499,7 +485,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -521,7 +506,6 @@ pub trait Read { + /// This method is unsafe because a `Read`er could otherwise return a + /// non-zeroing `Initializer` from another `Read` type without an `unsafe` + /// block. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -566,7 +550,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -604,7 +588,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -665,7 +649,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -717,7 +700,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an `Iterator` over its bytes. +@@ -747,7 +729,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -784,10 +765,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -822,7 +799,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -856,20 +832,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -883,21 +856,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -940,7 +910,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. + /// +@@ -984,7 +953,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1010,7 +978,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1040,7 +1007,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1092,7 +1058,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1148,7 +1113,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1178,7 +1142,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1194,7 +1157,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1204,29 +1166,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1306,7 +1265,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1351,7 +1310,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1373,7 +1331,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1429,7 +1386,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1484,7 +1440,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1525,7 +1480,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1564,7 +1518,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1576,7 +1529,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1602,7 +1554,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1625,7 +1576,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1652,13 +1602,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1668,7 +1616,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1690,7 +1637,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1717,7 +1664,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1752,7 +1698,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Sets the number of bytes that can be read before this instance will +@@ -1779,7 +1724,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "take_set_limit", issue = "42781")] + pub fn set_limit(&mut self, limit: u64) { + self.limit = limit; + } +@@ -1804,7 +1748,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1829,7 +1772,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1858,13 +1800,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1883,7 +1823,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1922,13 +1862,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -1943,8 +1881,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -1953,8 +1889,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -1964,8 +1898,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -1997,25 +1929,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2034,14 +1947,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2066,13 +1979,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 88f4214..df974c3 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -44,7 +45,6 @@ use mem; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -73,7 +73,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of `empty()` for more details. + /// + /// [empty]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -91,10 +90,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -104,7 +101,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -112,7 +110,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -125,7 +122,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -142,10 +138,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -161,7 +155,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -174,7 +167,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -191,10 +183,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -202,7 +192,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/80e2e67f4c6fbbef5e4789df7fc96804e6a84196.patch b/patches/80e2e67f4c6fbbef5e4789df7fc96804e6a84196.patch new file mode 100644 index 0000000..99f0ac0 --- /dev/null +++ b/patches/80e2e67f4c6fbbef5e4789df7fc96804e6a84196.patch @@ -0,0 +1,1659 @@ +diff --git a/buffered.rs b/buffered.rs +index 16fbf0c..17a2d08 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Returns `true` if there are no bytes in the internal buffer. +@@ -167,7 +162,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "bufreader_is_empty", issue = "45323", reason = "recently added")] + pub fn is_empty(&self) -> bool { + self.pos == self.cap + } +@@ -190,7 +184,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +@@ -199,7 +192,6 @@ impl BufReader { + /// the buffer will not be flushed, allowing for more efficient seeks. + /// This method does not return the location of the underlying reader, so the caller + /// must track this information themselves if it is required. +- #[unstable(feature = "bufreader_seek_relative", issue = "31100")] + pub fn seek_relative(&mut self, offset: i64) -> io::Result<()> { + let pos = self.pos as u64; + if offset < 0 { +@@ -219,7 +211,6 @@ impl BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -242,7 +233,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -262,7 +252,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -272,7 +261,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -374,7 +362,6 @@ impl Seek for BufReader { + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html + /// [`flush`]: #method.flush +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -409,7 +396,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -423,7 +409,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -441,7 +426,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -490,7 +474,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -508,7 +491,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -530,7 +512,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -539,7 +520,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -559,7 +539,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -569,7 +548,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -579,7 +557,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -618,7 +595,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -651,23 +627,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -725,7 +691,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -746,7 +711,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -767,7 +731,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -791,7 +754,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -814,7 +776,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -840,7 +801,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -851,7 +811,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -896,7 +855,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index c844770..dcc64c6 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,17 +215,16 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } + + fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> { + let n = buf.len(); +- Read::read_exact(&mut self.fill_buf()?, buf)?; ++ Read::read_exact(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(()) + } +@@ -243,12 +235,16 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +@@ -261,6 +257,7 @@ fn slice_write(pos_mut: &mut u64, slice: &mut [u8], buf: &[u8]) -> io::Result, buf: &[u8]) -> io::Result { + let pos: usize = (*pos_mut).try_into().map_err(|_| { + Error::new(ErrorKind::InvalidInput, +@@ -287,7 +284,6 @@ fn vec_write(pos_mut: &mut u64, vec: &mut Vec, buf: &[u8]) -> io::Result Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +@@ -296,7 +292,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[unstable(feature = "cursor_mut_vec", issue = "30132")] ++#[cfg(feature="collections")] + impl<'a> Write for Cursor<&'a mut Vec> { + fn write(&mut self, buf: &[u8]) -> io::Result { + vec_write(&mut self.pos, self.inner, buf) +@@ -304,7 +300,7 @@ impl<'a> Write for Cursor<&'a mut Vec> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + vec_write(&mut self.pos, &mut self.inner, buf) +@@ -312,8 +308,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + slice_write(&mut self.pos, &mut self.inner, buf) +diff --git a/error.rs b/error.rs +index bb9383d..01ddea6 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -48,7 +53,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and +@@ -63,7 +67,6 @@ pub type Result = result::Result; + /// [`Seek`]: ../io/trait.Seek.html + /// [`ErrorKind`]: enum.ErrorKind.html + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } +@@ -71,13 +74,16 @@ pub struct Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -89,47 +95,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -141,10 +134,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -155,15 +146,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -172,15 +160,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -213,7 +196,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -242,14 +224,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind, +@@ -258,24 +239,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -301,7 +264,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -332,7 +294,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -366,12 +327,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -437,12 +397,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -471,8 +430,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -498,10 +456,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -512,21 +469,18 @@ impl fmt::Debug for Repr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Repr::Os(ref code) => +- fmt.debug_struct("Os").field("code", code) +- .field("message", &sys::os::error_string(*code)).finish(), ++ fmt.debug_struct("Os").field("code", code).finish(), + Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -534,24 +488,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index fe1179a..452b8b7 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -207,6 +211,7 @@ impl<'a> Read for &'a [u8] { + Ok(()) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + buf.extend_from_slice(*self); +@@ -216,7 +221,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -230,7 +235,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -256,7 +260,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/mod.rs b/mod.rs +index 33d11eb..569daa2 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -268,50 +268,38 @@ + //! [`Result`]: ../result/enum.Result.html + //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++#[cfg(not(core_memchr))] ++mod memchr; ++#[cfg(all(feature="collections",core_memchr))] ++use core::slice::memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -336,6 +324,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -363,6 +352,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -466,7 +456,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// [`BufReader`]: struct.BufReader.html + /// [`&str`]: ../../std/primitive.str.html + /// [slice]: ../../std/primitive.slice.html +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning +@@ -523,7 +512,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -548,7 +536,6 @@ pub trait Read { + /// + /// [`Initializer::nop()`]: ../../std/io/struct.Initializer.html#method.nop + /// [`Initializer`]: ../../std/io/struct.Initializer.html +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -596,7 +583,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -634,7 +621,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -697,7 +684,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -749,7 +735,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an [`Iterator`] over its bytes. +@@ -786,7 +771,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -827,10 +811,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -865,7 +845,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -901,20 +880,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -928,21 +904,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -985,7 +958,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. +@@ -1034,7 +1006,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1060,7 +1031,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1093,7 +1063,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1145,7 +1114,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1201,7 +1169,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1231,7 +1198,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1247,7 +1213,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1257,29 +1222,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1359,7 +1321,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1404,7 +1366,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1426,7 +1387,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1484,7 +1444,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1541,7 +1500,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1582,7 +1540,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1621,7 +1578,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1633,7 +1589,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1659,7 +1614,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1682,7 +1636,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1709,13 +1662,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1725,7 +1676,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1747,7 +1697,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1774,7 +1724,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1809,7 +1758,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Sets the number of bytes that can be read before this instance will +@@ -1836,7 +1784,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "take_set_limit", issue = "42781")] + pub fn set_limit(&mut self, limit: u64) { + self.limit = limit; + } +@@ -1861,7 +1808,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1886,7 +1832,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1915,13 +1860,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1940,7 +1883,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1979,13 +1922,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -2000,8 +1941,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -2010,8 +1949,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -2021,8 +1958,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -2053,25 +1988,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2090,14 +2006,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2122,13 +2038,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 45d281e..0efc3b1 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -45,7 +46,6 @@ use mem; + /// # } + /// # foo().unwrap(); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -74,7 +74,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of [`empty()`][`empty`] for more details. + /// + /// [`empty`]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -94,10 +93,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -107,7 +104,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -115,7 +113,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -128,7 +125,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -145,10 +141,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -164,7 +158,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -177,7 +170,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -194,10 +186,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -205,7 +195,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/838a38365daa047fca7e57f63f9c54614c45595f.patch b/patches/838a38365daa047fca7e57f63f9c54614c45595f.patch new file mode 100644 index 0000000..0c93322 --- /dev/null +++ b/patches/838a38365daa047fca7e57f63f9c54614c45595f.patch @@ -0,0 +1,1634 @@ +diff --git a/buffered.rs b/buffered.rs +index 6d3fbc9..548f596 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Returns `true` if there are no bytes in the internal buffer. +@@ -167,7 +162,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "bufreader_is_empty", issue = "45323", reason = "recently added")] + pub fn is_empty(&self) -> bool { + self.pos == self.cap + } +@@ -190,11 +184,9 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -217,7 +209,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -237,7 +228,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -247,7 +237,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -345,7 +334,6 @@ impl Seek for BufReader { + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html + /// [`flush`]: #method.flush +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -380,7 +368,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -394,7 +381,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -412,7 +398,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -461,7 +446,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -479,7 +463,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -497,7 +480,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -506,7 +488,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -526,7 +507,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -536,7 +516,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -546,7 +525,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -585,7 +563,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -618,23 +595,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -689,7 +656,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -710,7 +676,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -731,7 +696,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -755,7 +719,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -778,7 +741,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -800,7 +762,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -811,7 +772,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -856,7 +816,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index 32a9214..21ed409 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,10 +215,9 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } +@@ -236,16 +228,19 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -257,7 +252,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos: usize = self.position().try_into().map_err(|_| { +@@ -287,8 +282,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos = cmp::min(self.pos, self.inner.len() as u64); +diff --git a/error.rs b/error.rs +index bb9383d..01ddea6 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -48,7 +53,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and +@@ -63,7 +67,6 @@ pub type Result = result::Result; + /// [`Seek`]: ../io/trait.Seek.html + /// [`ErrorKind`]: enum.ErrorKind.html + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } +@@ -71,13 +74,16 @@ pub struct Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -89,47 +95,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -141,10 +134,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -155,15 +146,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -172,15 +160,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -213,7 +196,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -242,14 +224,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind, +@@ -258,24 +239,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -301,7 +264,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -332,7 +294,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -366,12 +327,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -437,12 +397,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -471,8 +430,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -498,10 +456,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -512,21 +469,18 @@ impl fmt::Debug for Repr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Repr::Os(ref code) => +- fmt.debug_struct("Os").field("code", code) +- .field("message", &sys::os::error_string(*code)).finish(), ++ fmt.debug_struct("Os").field("code", code).finish(), + Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -534,24 +488,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index fe1179a..452b8b7 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -207,6 +211,7 @@ impl<'a> Read for &'a [u8] { + Ok(()) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + buf.extend_from_slice(*self); +@@ -216,7 +221,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -230,7 +235,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -256,7 +260,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/memchr.rs b/memchr.rs +index 50f998e..a8bff09 100644 +--- a/memchr.rs ++++ b/memchr.rs +@@ -11,10 +11,12 @@ + // Original implementation taken from rust-memchr + // Copyright 2015 Andrew Gallant, bluss and Nicolas Koch + ++pub use self::fallback::{memchr,memrchr}; ++ + #[allow(dead_code)] + pub mod fallback { +- use cmp; +- use mem; ++ use core::cmp; ++ use core::mem; + + const LO_U64: u64 = 0x0101010101010101; + const HI_U64: u64 = 0x8080808080808080; +diff --git a/mod.rs b/mod.rs +index 57f8c39..f9cb93d 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -268,50 +268,35 @@ + //! [`Result`]: ../result/enum.Result.html + //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++mod memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -336,6 +321,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -363,6 +349,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -449,7 +436,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning + /// how many bytes were read. +@@ -505,7 +491,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -530,7 +515,6 @@ pub trait Read { + /// + /// [`Initializer::nop()`]: ../../std/io/struct.Initializer.html#method.nop + /// [`Initializer`]: ../../std/io/struct.Initializer.html +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -578,7 +562,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -616,7 +600,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -679,7 +663,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -731,7 +714,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an [`Iterator`] over its bytes. +@@ -768,7 +750,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -809,10 +790,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -847,7 +824,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -883,20 +859,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -910,21 +883,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -967,7 +937,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. + /// +@@ -1011,7 +980,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1037,7 +1005,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1067,7 +1034,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1119,7 +1085,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1175,7 +1140,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1205,7 +1169,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1221,7 +1184,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1231,29 +1193,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1333,7 +1292,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1378,7 +1337,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1400,7 +1358,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1458,7 +1415,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1515,7 +1471,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1556,7 +1511,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1595,7 +1549,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1607,7 +1560,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1633,7 +1585,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1656,7 +1607,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1683,13 +1633,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1699,7 +1647,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1721,7 +1668,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1748,7 +1695,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1783,7 +1729,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Sets the number of bytes that can be read before this instance will +@@ -1810,7 +1755,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "take_set_limit", issue = "42781")] + pub fn set_limit(&mut self, limit: u64) { + self.limit = limit; + } +@@ -1835,7 +1779,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1860,7 +1803,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1889,13 +1831,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1914,7 +1854,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1953,13 +1893,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -1974,8 +1912,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -1984,8 +1920,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -1995,8 +1929,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -2028,25 +1960,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2065,14 +1978,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2097,13 +2010,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 45d281e..0efc3b1 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -45,7 +46,6 @@ use mem; + /// # } + /// # foo().unwrap(); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -74,7 +74,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of [`empty()`][`empty`] for more details. + /// + /// [`empty`]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -94,10 +93,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -107,7 +104,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -115,7 +113,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -128,7 +125,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -145,10 +141,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -164,7 +158,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -177,7 +170,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -194,10 +186,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -205,7 +195,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/871bd237ee233bce3c3ba964c0b3948d685d7902.patch b/patches/871bd237ee233bce3c3ba964c0b3948d685d7902.patch new file mode 100644 index 0000000..0c22dec --- /dev/null +++ b/patches/871bd237ee233bce3c3ba964c0b3948d685d7902.patch @@ -0,0 +1,1618 @@ +diff --git a/buffered.rs b/buffered.rs +index 4ebd355..242aab4 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Unwraps this `BufReader`, returning the underlying reader. +@@ -165,11 +160,9 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -192,7 +185,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -212,7 +204,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -222,7 +213,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -320,7 +310,6 @@ impl Seek for BufReader { + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html + /// [`flush`]: #method.flush +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -355,7 +344,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -369,7 +357,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -387,7 +374,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -436,7 +422,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -454,7 +439,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -472,7 +456,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -481,7 +464,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -501,7 +483,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -511,7 +492,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -521,7 +501,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -560,7 +539,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -593,23 +571,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -664,7 +632,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -685,7 +652,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -706,7 +672,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -730,7 +695,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -753,7 +717,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -775,7 +738,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -786,7 +748,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -831,7 +792,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index 32a9214..21ed409 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,10 +215,9 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } +@@ -236,16 +228,19 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -257,7 +252,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos: usize = self.position().try_into().map_err(|_| { +@@ -287,8 +282,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos = cmp::min(self.pos, self.inner.len() as u64); +diff --git a/error.rs b/error.rs +index bb9383d..01ddea6 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -48,7 +53,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and +@@ -63,7 +67,6 @@ pub type Result = result::Result; + /// [`Seek`]: ../io/trait.Seek.html + /// [`ErrorKind`]: enum.ErrorKind.html + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } +@@ -71,13 +74,16 @@ pub struct Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -89,47 +95,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -141,10 +134,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -155,15 +146,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -172,15 +160,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -213,7 +196,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -242,14 +224,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind, +@@ -258,24 +239,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -301,7 +264,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -332,7 +294,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -366,12 +327,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -437,12 +397,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -471,8 +430,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -498,10 +456,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -512,21 +469,18 @@ impl fmt::Debug for Repr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Repr::Os(ref code) => +- fmt.debug_struct("Os").field("code", code) +- .field("message", &sys::os::error_string(*code)).finish(), ++ fmt.debug_struct("Os").field("code", code).finish(), + Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -534,24 +488,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index d6b41ce..1ddabf1 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -208,7 +212,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -222,7 +226,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -248,7 +251,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/memchr.rs b/memchr.rs +index 3824a5f..312cf47 100644 +--- a/memchr.rs ++++ b/memchr.rs +@@ -11,10 +11,12 @@ + // Original implementation taken from rust-memchr + // Copyright 2015 Andrew Gallant, bluss and Nicolas Koch + ++pub use self::fallback::{memchr,memrchr}; ++ + #[allow(dead_code)] + pub mod fallback { +- use cmp; +- use mem; ++ use core::cmp; ++ use core::mem; + + const LO_U64: u64 = 0x0101010101010101; + const HI_U64: u64 = 0x8080808080808080; +diff --git a/mod.rs b/mod.rs +index 0fff833..5f0d95d 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -268,50 +268,35 @@ + //! [`Result`]: ../result/enum.Result.html + //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++mod memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -336,6 +321,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -363,6 +349,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -449,7 +436,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning + /// how many bytes were read. +@@ -505,7 +491,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -530,7 +515,6 @@ pub trait Read { + /// + /// [`Initializer::nop()`]: ../../std/io/struct.Initializer.html#method.nop + /// [`Initializer`]: ../../std/io/struct.Initializer.html +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -578,7 +562,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -616,7 +600,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -679,7 +663,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -731,7 +714,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an [`Iterator`] over its bytes. +@@ -767,7 +749,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -808,10 +789,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -846,7 +823,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -882,20 +858,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -909,21 +882,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -966,7 +936,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. + /// +@@ -1010,7 +979,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1036,7 +1004,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1066,7 +1033,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1118,7 +1084,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1174,7 +1139,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1204,7 +1168,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1220,7 +1183,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1230,29 +1192,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1332,7 +1291,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1377,7 +1336,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1399,7 +1357,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1455,7 +1412,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1510,7 +1466,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1551,7 +1506,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1590,7 +1544,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1602,7 +1555,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1628,7 +1580,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1651,7 +1602,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1678,13 +1628,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1694,7 +1642,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1716,7 +1663,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1743,7 +1690,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1778,7 +1724,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Sets the number of bytes that can be read before this instance will +@@ -1805,7 +1750,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "take_set_limit", issue = "42781")] + pub fn set_limit(&mut self, limit: u64) { + self.limit = limit; + } +@@ -1830,7 +1774,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1855,7 +1798,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1884,13 +1826,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1909,7 +1849,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1948,13 +1888,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -1969,8 +1907,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -1979,8 +1915,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -1990,8 +1924,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -2023,25 +1955,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2060,14 +1973,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2092,13 +2005,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 88f4214..df974c3 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -44,7 +45,6 @@ use mem; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -73,7 +73,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of `empty()` for more details. + /// + /// [empty]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -91,10 +90,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -104,7 +101,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -112,7 +110,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -125,7 +122,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -142,10 +138,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -161,7 +155,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -174,7 +167,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -191,10 +183,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -202,7 +192,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/8835289434ba88351610f1ca7a19f7fefe5a53fa.patch b/patches/8835289434ba88351610f1ca7a19f7fefe5a53fa.patch new file mode 100644 index 0000000..226452d --- /dev/null +++ b/patches/8835289434ba88351610f1ca7a19f7fefe5a53fa.patch @@ -0,0 +1,1642 @@ +diff --git a/buffered.rs b/buffered.rs +index 6d3fbc9..548f596 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Returns `true` if there are no bytes in the internal buffer. +@@ -167,7 +162,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "bufreader_is_empty", issue = "45323", reason = "recently added")] + pub fn is_empty(&self) -> bool { + self.pos == self.cap + } +@@ -190,11 +184,9 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -217,7 +209,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -237,7 +228,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -247,7 +237,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -345,7 +334,6 @@ impl Seek for BufReader { + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html + /// [`flush`]: #method.flush +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -380,7 +368,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -394,7 +381,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -412,7 +398,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -461,7 +446,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -479,7 +463,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -497,7 +480,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -506,7 +488,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -526,7 +507,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -536,7 +516,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -546,7 +525,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -585,7 +563,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -618,23 +595,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -689,7 +656,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -710,7 +676,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -731,7 +696,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -755,7 +719,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -778,7 +741,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -800,7 +762,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -811,7 +772,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -856,7 +816,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index b5ea553..b31cfa3 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,17 +215,16 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } + + fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> { + let n = buf.len(); +- Read::read_exact(&mut self.fill_buf()?, buf)?; ++ Read::read_exact(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(()) + } +@@ -243,16 +235,19 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -264,7 +259,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos: usize = self.position().try_into().map_err(|_| { +@@ -294,8 +289,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos = cmp::min(self.pos, self.inner.len() as u64); +diff --git a/error.rs b/error.rs +index bb9383d..01ddea6 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -48,7 +53,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and +@@ -63,7 +67,6 @@ pub type Result = result::Result; + /// [`Seek`]: ../io/trait.Seek.html + /// [`ErrorKind`]: enum.ErrorKind.html + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } +@@ -71,13 +74,16 @@ pub struct Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -89,47 +95,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -141,10 +134,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -155,15 +146,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -172,15 +160,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -213,7 +196,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -242,14 +224,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind, +@@ -258,24 +239,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -301,7 +264,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -332,7 +294,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -366,12 +327,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -437,12 +397,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -471,8 +430,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -498,10 +456,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -512,21 +469,18 @@ impl fmt::Debug for Repr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Repr::Os(ref code) => +- fmt.debug_struct("Os").field("code", code) +- .field("message", &sys::os::error_string(*code)).finish(), ++ fmt.debug_struct("Os").field("code", code).finish(), + Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -534,24 +488,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index fe1179a..452b8b7 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -207,6 +211,7 @@ impl<'a> Read for &'a [u8] { + Ok(()) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + buf.extend_from_slice(*self); +@@ -216,7 +221,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -230,7 +235,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -256,7 +260,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/memchr.rs b/memchr.rs +index 50f998e..a8bff09 100644 +--- a/memchr.rs ++++ b/memchr.rs +@@ -11,10 +11,12 @@ + // Original implementation taken from rust-memchr + // Copyright 2015 Andrew Gallant, bluss and Nicolas Koch + ++pub use self::fallback::{memchr,memrchr}; ++ + #[allow(dead_code)] + pub mod fallback { +- use cmp; +- use mem; ++ use core::cmp; ++ use core::mem; + + const LO_U64: u64 = 0x0101010101010101; + const HI_U64: u64 = 0x8080808080808080; +diff --git a/mod.rs b/mod.rs +index e9b707c..4a4592d 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -268,50 +268,35 @@ + //! [`Result`]: ../result/enum.Result.html + //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++mod memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -336,6 +321,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -363,6 +349,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -466,7 +453,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// [`BufReader`]: struct.BufReader.html + /// [`&str`]: ../../std/primitive.str.html + /// [slice]: ../../std/primitive.slice.html +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning +@@ -523,7 +509,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -548,7 +533,6 @@ pub trait Read { + /// + /// [`Initializer::nop()`]: ../../std/io/struct.Initializer.html#method.nop + /// [`Initializer`]: ../../std/io/struct.Initializer.html +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -596,7 +580,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -634,7 +618,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -697,7 +681,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -749,7 +732,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an [`Iterator`] over its bytes. +@@ -786,7 +768,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -827,10 +808,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -865,7 +842,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -901,20 +877,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -928,21 +901,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -985,7 +955,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. +@@ -1030,7 +999,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1056,7 +1024,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1086,7 +1053,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1138,7 +1104,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1194,7 +1159,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1224,7 +1188,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1240,7 +1203,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1250,29 +1212,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1352,7 +1311,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1397,7 +1356,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1419,7 +1377,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1477,7 +1434,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1534,7 +1490,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1575,7 +1530,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1614,7 +1568,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1626,7 +1579,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1652,7 +1604,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1675,7 +1626,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1702,13 +1652,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1718,7 +1666,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1740,7 +1687,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1767,7 +1714,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1802,7 +1748,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Sets the number of bytes that can be read before this instance will +@@ -1829,7 +1774,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "take_set_limit", issue = "42781")] + pub fn set_limit(&mut self, limit: u64) { + self.limit = limit; + } +@@ -1854,7 +1798,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1879,7 +1822,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1908,13 +1850,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1933,7 +1873,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1972,13 +1912,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -1993,8 +1931,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -2003,8 +1939,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -2014,8 +1948,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -2046,25 +1978,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2083,14 +1996,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2115,13 +2028,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 45d281e..0efc3b1 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -45,7 +46,6 @@ use mem; + /// # } + /// # foo().unwrap(); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -74,7 +74,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of [`empty()`][`empty`] for more details. + /// + /// [`empty`]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -94,10 +93,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -107,7 +104,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -115,7 +113,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -128,7 +125,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -145,10 +141,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -164,7 +158,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -177,7 +170,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -194,10 +186,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -205,7 +195,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/93969734f6a8f38e95c7038c926ab2504e87dad6.patch b/patches/93969734f6a8f38e95c7038c926ab2504e87dad6.patch new file mode 100644 index 0000000..a9b4170 --- /dev/null +++ b/patches/93969734f6a8f38e95c7038c926ab2504e87dad6.patch @@ -0,0 +1,1626 @@ +diff --git a/buffered.rs b/buffered.rs +index 7001d8e..8e5daa4 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Returns `true` if there are no bytes in the internal buffer. +@@ -167,7 +162,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "bufreader_is_empty", issue = "45323", reason = "recently added")] + pub fn is_empty(&self) -> bool { + self.pos == self.cap + } +@@ -190,11 +184,9 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -217,7 +209,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -237,7 +228,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -247,7 +237,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -345,7 +334,6 @@ impl Seek for BufReader { + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html + /// [`flush`]: #method.flush +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -380,7 +368,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -394,7 +381,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -412,7 +398,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -461,7 +446,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -479,7 +463,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -501,7 +484,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -510,7 +492,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -530,7 +511,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -540,7 +520,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -550,7 +529,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -589,7 +567,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -622,23 +599,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -696,7 +663,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -717,7 +683,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -738,7 +703,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -762,7 +726,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -785,7 +748,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -811,7 +773,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -822,7 +783,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -867,7 +827,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index b5ea553..b31cfa3 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,17 +215,16 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } + + fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> { + let n = buf.len(); +- Read::read_exact(&mut self.fill_buf()?, buf)?; ++ Read::read_exact(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(()) + } +@@ -243,16 +235,19 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -264,7 +259,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos: usize = self.position().try_into().map_err(|_| { +@@ -294,8 +289,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos = cmp::min(self.pos, self.inner.len() as u64); +diff --git a/error.rs b/error.rs +index bb9383d..01ddea6 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -48,7 +53,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and +@@ -63,7 +67,6 @@ pub type Result = result::Result; + /// [`Seek`]: ../io/trait.Seek.html + /// [`ErrorKind`]: enum.ErrorKind.html + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } +@@ -71,13 +74,16 @@ pub struct Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -89,47 +95,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -141,10 +134,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -155,15 +146,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -172,15 +160,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -213,7 +196,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -242,14 +224,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind, +@@ -258,24 +239,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -301,7 +264,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -332,7 +294,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -366,12 +327,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -437,12 +397,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -471,8 +430,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -498,10 +456,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -512,21 +469,18 @@ impl fmt::Debug for Repr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Repr::Os(ref code) => +- fmt.debug_struct("Os").field("code", code) +- .field("message", &sys::os::error_string(*code)).finish(), ++ fmt.debug_struct("Os").field("code", code).finish(), + Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -534,24 +488,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index fe1179a..452b8b7 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -207,6 +211,7 @@ impl<'a> Read for &'a [u8] { + Ok(()) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + buf.extend_from_slice(*self); +@@ -216,7 +221,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -230,7 +235,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -256,7 +260,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/mod.rs b/mod.rs +index 33d11eb..569daa2 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -268,50 +268,38 @@ + //! [`Result`]: ../result/enum.Result.html + //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++#[cfg(not(core_memchr))] ++mod memchr; ++#[cfg(all(feature="collections",core_memchr))] ++use core::slice::memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -336,6 +324,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -363,6 +352,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -466,7 +456,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// [`BufReader`]: struct.BufReader.html + /// [`&str`]: ../../std/primitive.str.html + /// [slice]: ../../std/primitive.slice.html +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning +@@ -523,7 +512,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -548,7 +536,6 @@ pub trait Read { + /// + /// [`Initializer::nop()`]: ../../std/io/struct.Initializer.html#method.nop + /// [`Initializer`]: ../../std/io/struct.Initializer.html +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -596,7 +583,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -634,7 +621,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -697,7 +684,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -749,7 +735,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an [`Iterator`] over its bytes. +@@ -786,7 +771,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -827,10 +811,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -865,7 +845,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -901,20 +880,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -928,21 +904,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -985,7 +958,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. +@@ -1034,7 +1006,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1060,7 +1031,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1093,7 +1063,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1145,7 +1114,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1201,7 +1169,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1231,7 +1198,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1247,7 +1213,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1257,29 +1222,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1359,7 +1321,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1404,7 +1366,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1426,7 +1387,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1484,7 +1444,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1541,7 +1500,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1582,7 +1540,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1621,7 +1578,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1633,7 +1589,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1659,7 +1614,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1682,7 +1636,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1709,13 +1662,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1725,7 +1676,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1747,7 +1697,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1774,7 +1724,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1809,7 +1758,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Sets the number of bytes that can be read before this instance will +@@ -1836,7 +1784,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "take_set_limit", issue = "42781")] + pub fn set_limit(&mut self, limit: u64) { + self.limit = limit; + } +@@ -1861,7 +1808,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1886,7 +1832,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1915,13 +1860,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1940,7 +1883,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1979,13 +1922,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -2000,8 +1941,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -2010,8 +1949,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -2021,8 +1958,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -2053,25 +1988,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2090,14 +2006,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2122,13 +2038,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 45d281e..0efc3b1 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -45,7 +46,6 @@ use mem; + /// # } + /// # foo().unwrap(); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -74,7 +74,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of [`empty()`][`empty`] for more details. + /// + /// [`empty`]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -94,10 +93,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -107,7 +104,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -115,7 +113,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -128,7 +125,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -145,10 +141,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -164,7 +158,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -177,7 +170,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -194,10 +186,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -205,7 +195,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/972d67cec1fc0aeafebcc60ffcdf4dea0eadff8c.patch b/patches/972d67cec1fc0aeafebcc60ffcdf4dea0eadff8c.patch new file mode 100644 index 0000000..5ca7ab0 --- /dev/null +++ b/patches/972d67cec1fc0aeafebcc60ffcdf4dea0eadff8c.patch @@ -0,0 +1,1618 @@ +diff --git a/buffered.rs b/buffered.rs +index d765dd2..1428736 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Unwraps this `BufReader`, returning the underlying reader. +@@ -165,11 +160,9 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -192,7 +185,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -212,7 +204,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -222,7 +213,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -320,7 +310,6 @@ impl Seek for BufReader { + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html + /// [`flush`]: #method.flush +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -355,7 +344,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -369,7 +357,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -387,7 +374,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -436,7 +422,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -454,7 +439,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -472,7 +456,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -481,7 +464,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -501,7 +483,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -511,7 +492,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -521,7 +501,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -560,7 +539,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -593,23 +571,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -664,7 +632,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -685,7 +652,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -706,7 +672,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -730,7 +695,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -753,7 +717,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -775,7 +738,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -786,7 +748,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -831,7 +792,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index d986021..4cd22cf 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,10 +215,9 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } +@@ -236,16 +228,19 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -257,7 +252,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos: usize = self.position().try_into().map_err(|_| { +@@ -287,8 +282,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos = cmp::min(self.pos, self.inner.len() as u64); +diff --git a/error.rs b/error.rs +index 68f5522..0960bf5 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -48,7 +53,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and +@@ -63,7 +67,6 @@ pub type Result = result::Result; + /// [`Seek`]: ../io/trait.Seek.html + /// [`ErrorKind`]: enum.ErrorKind.html + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } +@@ -71,13 +74,16 @@ pub struct Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -89,47 +95,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -141,10 +134,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -155,15 +146,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -172,15 +160,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -213,7 +196,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -242,14 +224,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind: kind, +@@ -258,24 +239,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -301,7 +264,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -332,7 +294,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -366,12 +327,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -437,12 +397,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -471,8 +430,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -498,10 +456,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -512,21 +469,18 @@ impl fmt::Debug for Repr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Repr::Os(ref code) => +- fmt.debug_struct("Os").field("code", code) +- .field("message", &sys::os::error_string(*code)).finish(), ++ fmt.debug_struct("Os").field("code", code).finish(), + Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -534,24 +488,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index d6b41ce..1ddabf1 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -208,7 +212,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -222,7 +226,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -248,7 +251,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/memchr.rs b/memchr.rs +index 3824a5f..312cf47 100644 +--- a/memchr.rs ++++ b/memchr.rs +@@ -11,10 +11,12 @@ + // Original implementation taken from rust-memchr + // Copyright 2015 Andrew Gallant, bluss and Nicolas Koch + ++pub use self::fallback::{memchr,memrchr}; ++ + #[allow(dead_code)] + pub mod fallback { +- use cmp; +- use mem; ++ use core::cmp; ++ use core::mem; + + const LO_U64: u64 = 0x0101010101010101; + const HI_U64: u64 = 0x8080808080808080; +diff --git a/mod.rs b/mod.rs +index f486493..6b63b12 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -268,50 +268,35 @@ + //! [`Result`]: ../result/enum.Result.html + //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++mod memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -336,6 +321,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -363,6 +349,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -448,7 +435,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning + /// how many bytes were read. +@@ -501,7 +487,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -523,7 +508,6 @@ pub trait Read { + /// This method is unsafe because a `Read`er could otherwise return a + /// non-zeroing `Initializer` from another `Read` type without an `unsafe` + /// block. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -568,7 +552,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -606,7 +590,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -667,7 +651,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -719,7 +702,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an `Iterator` over its bytes. +@@ -749,7 +731,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -786,10 +767,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -824,7 +801,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -858,20 +834,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -885,21 +858,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -942,7 +912,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. + /// +@@ -986,7 +955,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1012,7 +980,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1042,7 +1009,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1094,7 +1060,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1150,7 +1115,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1180,7 +1144,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1196,7 +1159,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1206,29 +1168,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1308,7 +1267,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1353,7 +1312,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1375,7 +1333,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1431,7 +1388,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1486,7 +1442,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1527,7 +1482,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1566,7 +1520,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1578,7 +1531,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1604,7 +1556,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1627,7 +1578,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1654,13 +1604,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1670,7 +1618,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1692,7 +1639,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1719,7 +1666,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1754,7 +1700,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Sets the number of bytes that can be read before this instance will +@@ -1781,7 +1726,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "take_set_limit", issue = "42781")] + pub fn set_limit(&mut self, limit: u64) { + self.limit = limit; + } +@@ -1806,7 +1750,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1831,7 +1774,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1860,13 +1802,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1885,7 +1825,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1924,13 +1864,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -1945,8 +1883,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -1955,8 +1891,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -1966,8 +1900,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -1999,25 +1931,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2036,14 +1949,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2068,13 +1981,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 88f4214..df974c3 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -44,7 +45,6 @@ use mem; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -73,7 +73,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of `empty()` for more details. + /// + /// [empty]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -91,10 +90,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -104,7 +101,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -112,7 +110,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -125,7 +122,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -142,10 +138,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -161,7 +155,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -174,7 +167,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -191,10 +183,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -202,7 +192,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/9b090a026108fab89cfe5f39bfd3492597e76ad4.patch b/patches/9b090a026108fab89cfe5f39bfd3492597e76ad4.patch new file mode 100644 index 0000000..cd7beed --- /dev/null +++ b/patches/9b090a026108fab89cfe5f39bfd3492597e76ad4.patch @@ -0,0 +1,1634 @@ +diff --git a/buffered.rs b/buffered.rs +index 6d3fbc9..548f596 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Returns `true` if there are no bytes in the internal buffer. +@@ -167,7 +162,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "bufreader_is_empty", issue = "45323", reason = "recently added")] + pub fn is_empty(&self) -> bool { + self.pos == self.cap + } +@@ -190,11 +184,9 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -217,7 +209,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -237,7 +228,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -247,7 +237,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -345,7 +334,6 @@ impl Seek for BufReader { + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html + /// [`flush`]: #method.flush +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -380,7 +368,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -394,7 +381,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -412,7 +398,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -461,7 +446,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -479,7 +463,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -497,7 +480,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -506,7 +488,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -526,7 +507,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -536,7 +516,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -546,7 +525,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -585,7 +563,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -618,23 +595,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -689,7 +656,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -710,7 +676,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -731,7 +696,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -755,7 +719,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -778,7 +741,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -800,7 +762,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -811,7 +772,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -856,7 +816,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index 32a9214..21ed409 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,10 +215,9 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } +@@ -236,16 +228,19 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -257,7 +252,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos: usize = self.position().try_into().map_err(|_| { +@@ -287,8 +282,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos = cmp::min(self.pos, self.inner.len() as u64); +diff --git a/error.rs b/error.rs +index bb9383d..01ddea6 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -48,7 +53,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and +@@ -63,7 +67,6 @@ pub type Result = result::Result; + /// [`Seek`]: ../io/trait.Seek.html + /// [`ErrorKind`]: enum.ErrorKind.html + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } +@@ -71,13 +74,16 @@ pub struct Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -89,47 +95,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -141,10 +134,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -155,15 +146,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -172,15 +160,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -213,7 +196,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -242,14 +224,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind, +@@ -258,24 +239,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -301,7 +264,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -332,7 +294,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -366,12 +327,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -437,12 +397,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -471,8 +430,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -498,10 +456,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -512,21 +469,18 @@ impl fmt::Debug for Repr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Repr::Os(ref code) => +- fmt.debug_struct("Os").field("code", code) +- .field("message", &sys::os::error_string(*code)).finish(), ++ fmt.debug_struct("Os").field("code", code).finish(), + Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -534,24 +488,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index fe1179a..452b8b7 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -207,6 +211,7 @@ impl<'a> Read for &'a [u8] { + Ok(()) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + buf.extend_from_slice(*self); +@@ -216,7 +221,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -230,7 +235,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -256,7 +260,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/memchr.rs b/memchr.rs +index 50f998e..a8bff09 100644 +--- a/memchr.rs ++++ b/memchr.rs +@@ -11,10 +11,12 @@ + // Original implementation taken from rust-memchr + // Copyright 2015 Andrew Gallant, bluss and Nicolas Koch + ++pub use self::fallback::{memchr,memrchr}; ++ + #[allow(dead_code)] + pub mod fallback { +- use cmp; +- use mem; ++ use core::cmp; ++ use core::mem; + + const LO_U64: u64 = 0x0101010101010101; + const HI_U64: u64 = 0x8080808080808080; +diff --git a/mod.rs b/mod.rs +index 54ee888..1449426 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -268,50 +268,35 @@ + //! [`Result`]: ../result/enum.Result.html + //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++mod memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -336,6 +321,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -363,6 +349,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -466,7 +453,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// [`BufReader`]: struct.BufReader.html + /// [`&[u8]`]: primitive.slice.html + /// +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning +@@ -523,7 +509,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -548,7 +533,6 @@ pub trait Read { + /// + /// [`Initializer::nop()`]: ../../std/io/struct.Initializer.html#method.nop + /// [`Initializer`]: ../../std/io/struct.Initializer.html +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -596,7 +580,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -634,7 +618,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -697,7 +681,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -749,7 +732,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an [`Iterator`] over its bytes. +@@ -786,7 +768,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -827,10 +808,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -865,7 +842,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -901,20 +877,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -928,21 +901,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -985,7 +955,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. +@@ -1030,7 +999,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1056,7 +1024,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1086,7 +1053,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1138,7 +1104,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1194,7 +1159,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1224,7 +1188,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1240,7 +1203,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1250,29 +1212,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1352,7 +1311,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1397,7 +1356,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1419,7 +1377,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1477,7 +1434,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1534,7 +1490,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1575,7 +1530,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1614,7 +1568,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1626,7 +1579,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1652,7 +1604,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1675,7 +1626,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1702,13 +1652,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1718,7 +1666,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1740,7 +1687,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1767,7 +1714,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1802,7 +1748,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Sets the number of bytes that can be read before this instance will +@@ -1829,7 +1774,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "take_set_limit", issue = "42781")] + pub fn set_limit(&mut self, limit: u64) { + self.limit = limit; + } +@@ -1854,7 +1798,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1879,7 +1822,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1908,13 +1850,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1933,7 +1873,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1972,13 +1912,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -1993,8 +1931,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -2003,8 +1939,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -2014,8 +1948,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -2047,25 +1979,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2084,14 +1997,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2116,13 +2029,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 45d281e..0efc3b1 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -45,7 +46,6 @@ use mem; + /// # } + /// # foo().unwrap(); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -74,7 +74,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of [`empty()`][`empty`] for more details. + /// + /// [`empty`]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -94,10 +93,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -107,7 +104,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -115,7 +113,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -128,7 +125,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -145,10 +141,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -164,7 +158,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -177,7 +170,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -194,10 +186,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -205,7 +195,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/9c854db82b767ddd228dbff1e51bb3eed87464b4.patch b/patches/9c854db82b767ddd228dbff1e51bb3eed87464b4.patch new file mode 100644 index 0000000..877d46a --- /dev/null +++ b/patches/9c854db82b767ddd228dbff1e51bb3eed87464b4.patch @@ -0,0 +1,1618 @@ +diff --git a/buffered.rs b/buffered.rs +index d765dd2..1428736 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Unwraps this `BufReader`, returning the underlying reader. +@@ -165,11 +160,9 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -192,7 +185,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -212,7 +204,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -222,7 +213,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -320,7 +310,6 @@ impl Seek for BufReader { + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html + /// [`flush`]: #method.flush +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -355,7 +344,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -369,7 +357,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -387,7 +374,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -436,7 +422,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -454,7 +439,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -472,7 +456,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -481,7 +464,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -501,7 +483,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -511,7 +492,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -521,7 +501,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -560,7 +539,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -593,23 +571,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -664,7 +632,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -685,7 +652,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -706,7 +672,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -730,7 +695,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -753,7 +717,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -775,7 +738,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -786,7 +748,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -831,7 +792,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index d986021..4cd22cf 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,10 +215,9 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } +@@ -236,16 +228,19 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -257,7 +252,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos: usize = self.position().try_into().map_err(|_| { +@@ -287,8 +282,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos = cmp::min(self.pos, self.inner.len() as u64); +diff --git a/error.rs b/error.rs +index 0a5804a..4564ca7 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -44,7 +49,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the `Read`, `Write`, `Seek`, and +@@ -56,7 +60,6 @@ pub type Result = result::Result; + /// + /// [`ErrorKind`]: enum.ErrorKind.html + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } +@@ -64,13 +67,16 @@ pub struct Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -82,47 +88,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -134,10 +127,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -148,15 +139,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -165,15 +153,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -206,7 +189,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -235,14 +217,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind: kind, +@@ -251,24 +232,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -294,7 +257,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -325,7 +287,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -359,12 +320,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -430,12 +390,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -464,8 +423,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -491,10 +449,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -505,21 +462,18 @@ impl fmt::Debug for Repr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Repr::Os(ref code) => +- fmt.debug_struct("Os").field("code", code) +- .field("message", &sys::os::error_string(*code)).finish(), ++ fmt.debug_struct("Os").field("code", code).finish(), + Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -527,24 +481,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index d6b41ce..1ddabf1 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -208,7 +212,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -222,7 +226,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -248,7 +251,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/memchr.rs b/memchr.rs +index 3824a5f..312cf47 100644 +--- a/memchr.rs ++++ b/memchr.rs +@@ -11,10 +11,12 @@ + // Original implementation taken from rust-memchr + // Copyright 2015 Andrew Gallant, bluss and Nicolas Koch + ++pub use self::fallback::{memchr,memrchr}; ++ + #[allow(dead_code)] + pub mod fallback { +- use cmp; +- use mem; ++ use core::cmp; ++ use core::mem; + + const LO_U64: u64 = 0x0101010101010101; + const HI_U64: u64 = 0x8080808080808080; +diff --git a/mod.rs b/mod.rs +index 9a3036f..bb88614 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -266,50 +266,35 @@ + //! [`?` operator]: ../../book/first-edition/syntax-index.html + //! [`Read::read`]: trait.Read.html#tymethod.read + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++mod memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -334,6 +319,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -361,6 +347,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -446,7 +433,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning + /// how many bytes were read. +@@ -499,7 +485,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -521,7 +506,6 @@ pub trait Read { + /// This method is unsafe because a `Read`er could otherwise return a + /// non-zeroing `Initializer` from another `Read` type without an `unsafe` + /// block. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -566,7 +550,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -604,7 +588,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -665,7 +649,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -717,7 +700,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an `Iterator` over its bytes. +@@ -747,7 +729,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -784,10 +765,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -822,7 +799,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -856,20 +832,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -883,21 +856,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -940,7 +910,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. + /// +@@ -984,7 +953,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1010,7 +978,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1040,7 +1007,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1092,7 +1058,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1148,7 +1113,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1178,7 +1142,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1194,7 +1157,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1204,29 +1166,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1306,7 +1265,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1351,7 +1310,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1373,7 +1331,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1429,7 +1386,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1484,7 +1440,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1525,7 +1480,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1564,7 +1518,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1576,7 +1529,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1602,7 +1554,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1625,7 +1576,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1652,13 +1602,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1668,7 +1616,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1690,7 +1637,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1717,7 +1664,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1752,7 +1698,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Sets the number of bytes that can be read before this instance will +@@ -1779,7 +1724,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "take_set_limit", issue = "42781")] + pub fn set_limit(&mut self, limit: u64) { + self.limit = limit; + } +@@ -1804,7 +1748,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1829,7 +1772,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1858,13 +1800,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1883,7 +1823,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1922,13 +1862,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -1943,8 +1881,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -1953,8 +1889,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -1964,8 +1898,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -1997,25 +1929,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2034,14 +1947,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2066,13 +1979,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 88f4214..df974c3 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -44,7 +45,6 @@ use mem; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -73,7 +73,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of `empty()` for more details. + /// + /// [empty]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -91,10 +90,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -104,7 +101,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -112,7 +110,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -125,7 +122,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -142,10 +138,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -161,7 +155,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -174,7 +167,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -191,10 +183,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -202,7 +192,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/af140ecdbc64251d7f536411c84e0d398a3d6631.patch b/patches/af140ecdbc64251d7f536411c84e0d398a3d6631.patch new file mode 100644 index 0000000..5a948fd --- /dev/null +++ b/patches/af140ecdbc64251d7f536411c84e0d398a3d6631.patch @@ -0,0 +1,1665 @@ +diff --git a/buffered.rs b/buffered.rs +index 9250c1c..bf6383f 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Returns `true` if there are no bytes in the internal buffer. +@@ -167,7 +162,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "bufreader_is_empty", issue = "45323", reason = "recently added")] + pub fn is_empty(&self) -> bool { + self.pos == self.cap + } +@@ -190,7 +184,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +@@ -199,7 +192,6 @@ impl BufReader { + /// the buffer will not be flushed, allowing for more efficient seeks. + /// This method does not return the location of the underlying reader, so the caller + /// must track this information themselves if it is required. +- #[unstable(feature = "bufreader_seek_relative", issue = "31100")] + pub fn seek_relative(&mut self, offset: i64) -> io::Result<()> { + let pos = self.pos as u64; + if offset < 0 { +@@ -219,7 +211,6 @@ impl BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -242,7 +233,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -262,7 +252,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -272,7 +261,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -374,7 +362,6 @@ impl Seek for BufReader { + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html + /// [`flush`]: #method.flush +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -409,7 +396,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -423,7 +409,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -441,7 +426,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -490,7 +474,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -508,7 +491,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -530,7 +512,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -539,7 +520,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -559,7 +539,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -569,7 +548,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -579,7 +557,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -618,7 +595,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -651,23 +627,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -725,7 +691,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -746,7 +711,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -767,7 +731,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -791,7 +754,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -814,7 +776,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -840,7 +801,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -851,7 +811,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -896,7 +855,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index 76bcb5f..dcc64c6 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,17 +215,16 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } + + fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> { + let n = buf.len(); +- Read::read_exact(&mut self.fill_buf()?, buf)?; ++ Read::read_exact(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(()) + } +@@ -243,12 +235,16 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +@@ -261,6 +257,7 @@ fn slice_write(pos_mut: &mut u64, slice: &mut [u8], buf: &[u8]) -> io::Result, buf: &[u8]) -> io::Result { + let pos: usize = (*pos_mut).try_into().map_err(|_| { + Error::new(ErrorKind::InvalidInput, +@@ -287,7 +284,6 @@ fn vec_write(pos_mut: &mut u64, vec: &mut Vec, buf: &[u8]) -> io::Result Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +@@ -296,7 +292,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_mut_vec", since = "1.25.0")] ++#[cfg(feature="collections")] + impl<'a> Write for Cursor<&'a mut Vec> { + fn write(&mut self, buf: &[u8]) -> io::Result { + vec_write(&mut self.pos, self.inner, buf) +@@ -304,7 +300,7 @@ impl<'a> Write for Cursor<&'a mut Vec> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + vec_write(&mut self.pos, &mut self.inner, buf) +@@ -312,8 +308,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + slice_write(&mut self.pos, &mut self.inner, buf) +diff --git a/error.rs b/error.rs +index bdd675e..3acdadf 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -48,7 +53,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and +@@ -62,12 +66,10 @@ pub type Result = result::Result; + /// [`Write`]: ../io/trait.Write.html + /// [`Seek`]: ../io/trait.Seek.html + /// [`ErrorKind`]: enum.ErrorKind.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Debug::fmt(&self.repr, f) +@@ -77,13 +79,16 @@ impl fmt::Debug for Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -95,47 +100,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -147,10 +139,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -161,15 +151,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -178,15 +165,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -219,7 +201,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -248,14 +229,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind, +@@ -264,24 +244,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -307,7 +269,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::InvalidInput); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -338,7 +299,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -372,12 +332,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -443,12 +402,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -477,8 +435,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -504,10 +461,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -519,22 +475,18 @@ impl fmt::Debug for Repr { + match *self { + Repr::Os(code) => + fmt.debug_struct("Os") +- .field("code", &code) +- .field("kind", &sys::decode_error_kind(code)) +- .field("message", &sys::os::error_string(code)).finish(), ++ .field("code", &code).finish(), + Repr::Custom(ref c) => fmt::Debug::fmt(&c, fmt), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -542,24 +494,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index fe1179a..452b8b7 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -207,6 +211,7 @@ impl<'a> Read for &'a [u8] { + Ok(()) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + buf.extend_from_slice(*self); +@@ -216,7 +221,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -230,7 +235,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -256,7 +260,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/mod.rs b/mod.rs +index aa07f64..c6fee4b 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -268,50 +268,38 @@ + //! [`Result`]: ../result/enum.Result.html + //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++#[cfg(not(core_memchr))] ++mod memchr; ++#[cfg(all(feature="collections",core_memchr))] ++use core::slice::memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -336,6 +324,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -363,6 +352,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -466,7 +456,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// [`BufReader`]: struct.BufReader.html + /// [`&str`]: ../../std/primitive.str.html + /// [slice]: ../../std/primitive.slice.html +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning +@@ -523,7 +512,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -548,7 +536,6 @@ pub trait Read { + /// + /// [`Initializer::nop()`]: ../../std/io/struct.Initializer.html#method.nop + /// [`Initializer`]: ../../std/io/struct.Initializer.html +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -596,7 +583,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -634,7 +621,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -697,7 +684,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -749,7 +735,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an [`Iterator`] over its bytes. +@@ -786,7 +771,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -827,10 +811,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -865,7 +845,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -901,20 +880,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -928,21 +904,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -985,7 +958,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. +@@ -1034,7 +1006,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1060,7 +1031,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1093,7 +1063,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1145,7 +1114,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1201,7 +1169,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1231,7 +1198,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1247,7 +1213,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1257,29 +1222,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1359,7 +1321,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1404,7 +1366,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1426,7 +1387,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1482,7 +1442,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1539,7 +1498,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1580,7 +1538,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1619,7 +1576,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1631,7 +1587,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1657,7 +1612,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1680,7 +1634,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1707,13 +1660,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1723,7 +1674,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1745,7 +1695,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1772,7 +1722,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1807,7 +1756,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Sets the number of bytes that can be read before this instance will +@@ -1834,7 +1782,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "take_set_limit", issue = "42781")] + pub fn set_limit(&mut self, limit: u64) { + self.limit = limit; + } +@@ -1859,7 +1806,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1884,7 +1830,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1913,13 +1858,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1938,7 +1881,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1977,13 +1920,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -1998,8 +1939,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -2008,8 +1947,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -2019,8 +1956,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -2051,25 +1986,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2088,14 +2004,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2120,13 +2036,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 45d281e..0efc3b1 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -45,7 +46,6 @@ use mem; + /// # } + /// # foo().unwrap(); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -74,7 +74,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of [`empty()`][`empty`] for more details. + /// + /// [`empty`]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -94,10 +93,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -107,7 +104,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -115,7 +113,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -128,7 +125,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -145,10 +141,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -164,7 +158,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -177,7 +170,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -194,10 +186,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -205,7 +195,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/b60e6f82855d387c0ad98179c33e6c019e8a7d26.patch b/patches/b60e6f82855d387c0ad98179c33e6c019e8a7d26.patch new file mode 100644 index 0000000..abb3b10 --- /dev/null +++ b/patches/b60e6f82855d387c0ad98179c33e6c019e8a7d26.patch @@ -0,0 +1,1642 @@ +diff --git a/buffered.rs b/buffered.rs +index 8308ab4..f6ef1bd 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Returns `true` if there are no bytes in the internal buffer. +@@ -167,7 +162,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "bufreader_is_empty", issue = "45323", reason = "recently added")] + pub fn is_empty(&self) -> bool { + self.pos == self.cap + } +@@ -190,11 +184,9 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -217,7 +209,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -237,7 +228,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -247,7 +237,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -345,7 +334,6 @@ impl Seek for BufReader { + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html + /// [`flush`]: #method.flush +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -380,7 +368,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -394,7 +381,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -412,7 +398,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -461,7 +446,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -479,7 +463,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -497,7 +480,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -506,7 +488,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -526,7 +507,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -536,7 +516,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -546,7 +525,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -585,7 +563,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -618,23 +595,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -689,7 +656,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -710,7 +676,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -731,7 +696,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -755,7 +719,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -778,7 +741,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -800,7 +762,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -811,7 +772,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -856,7 +816,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index b5ea553..b31cfa3 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,17 +215,16 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } + + fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> { + let n = buf.len(); +- Read::read_exact(&mut self.fill_buf()?, buf)?; ++ Read::read_exact(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(()) + } +@@ -243,16 +235,19 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -264,7 +259,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos: usize = self.position().try_into().map_err(|_| { +@@ -294,8 +289,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos = cmp::min(self.pos, self.inner.len() as u64); +diff --git a/error.rs b/error.rs +index bb9383d..01ddea6 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -48,7 +53,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and +@@ -63,7 +67,6 @@ pub type Result = result::Result; + /// [`Seek`]: ../io/trait.Seek.html + /// [`ErrorKind`]: enum.ErrorKind.html + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } +@@ -71,13 +74,16 @@ pub struct Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -89,47 +95,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -141,10 +134,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -155,15 +146,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -172,15 +160,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -213,7 +196,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -242,14 +224,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind, +@@ -258,24 +239,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -301,7 +264,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -332,7 +294,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -366,12 +327,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -437,12 +397,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -471,8 +430,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -498,10 +456,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -512,21 +469,18 @@ impl fmt::Debug for Repr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Repr::Os(ref code) => +- fmt.debug_struct("Os").field("code", code) +- .field("message", &sys::os::error_string(*code)).finish(), ++ fmt.debug_struct("Os").field("code", code).finish(), + Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -534,24 +488,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index fe1179a..452b8b7 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -207,6 +211,7 @@ impl<'a> Read for &'a [u8] { + Ok(()) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + buf.extend_from_slice(*self); +@@ -216,7 +221,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -230,7 +235,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -256,7 +260,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/memchr.rs b/memchr.rs +index 50f998e..a8bff09 100644 +--- a/memchr.rs ++++ b/memchr.rs +@@ -11,10 +11,12 @@ + // Original implementation taken from rust-memchr + // Copyright 2015 Andrew Gallant, bluss and Nicolas Koch + ++pub use self::fallback::{memchr,memrchr}; ++ + #[allow(dead_code)] + pub mod fallback { +- use cmp; +- use mem; ++ use core::cmp; ++ use core::mem; + + const LO_U64: u64 = 0x0101010101010101; + const HI_U64: u64 = 0x8080808080808080; +diff --git a/mod.rs b/mod.rs +index e9b707c..4a4592d 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -268,50 +268,35 @@ + //! [`Result`]: ../result/enum.Result.html + //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++mod memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -336,6 +321,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -363,6 +349,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -466,7 +453,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// [`BufReader`]: struct.BufReader.html + /// [`&str`]: ../../std/primitive.str.html + /// [slice]: ../../std/primitive.slice.html +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning +@@ -523,7 +509,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -548,7 +533,6 @@ pub trait Read { + /// + /// [`Initializer::nop()`]: ../../std/io/struct.Initializer.html#method.nop + /// [`Initializer`]: ../../std/io/struct.Initializer.html +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -596,7 +580,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -634,7 +618,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -697,7 +681,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -749,7 +732,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an [`Iterator`] over its bytes. +@@ -786,7 +768,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -827,10 +808,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -865,7 +842,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -901,20 +877,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -928,21 +901,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -985,7 +955,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. +@@ -1030,7 +999,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1056,7 +1024,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1086,7 +1053,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1138,7 +1104,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1194,7 +1159,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1224,7 +1188,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1240,7 +1203,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1250,29 +1212,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1352,7 +1311,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1397,7 +1356,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1419,7 +1377,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1477,7 +1434,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1534,7 +1490,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1575,7 +1530,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1614,7 +1568,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1626,7 +1579,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1652,7 +1604,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1675,7 +1626,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1702,13 +1652,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1718,7 +1666,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1740,7 +1687,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1767,7 +1714,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1802,7 +1748,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Sets the number of bytes that can be read before this instance will +@@ -1829,7 +1774,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "take_set_limit", issue = "42781")] + pub fn set_limit(&mut self, limit: u64) { + self.limit = limit; + } +@@ -1854,7 +1798,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1879,7 +1822,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1908,13 +1850,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1933,7 +1873,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1972,13 +1912,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -1993,8 +1931,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -2003,8 +1939,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -2014,8 +1948,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -2046,25 +1978,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2083,14 +1996,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2115,13 +2028,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 45d281e..0efc3b1 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -45,7 +46,6 @@ use mem; + /// # } + /// # foo().unwrap(); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -74,7 +74,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of [`empty()`][`empty`] for more details. + /// + /// [`empty`]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -94,10 +93,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -107,7 +104,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -115,7 +113,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -128,7 +125,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -145,10 +141,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -164,7 +158,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -177,7 +170,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -194,10 +186,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -205,7 +195,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/bba7fd9dd54937719a6e88c954db7ab2ea5a3541.patch b/patches/bba7fd9dd54937719a6e88c954db7ab2ea5a3541.patch new file mode 100644 index 0000000..0a597ab --- /dev/null +++ b/patches/bba7fd9dd54937719a6e88c954db7ab2ea5a3541.patch @@ -0,0 +1,1618 @@ +diff --git a/buffered.rs b/buffered.rs +index 4ebd355..242aab4 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Unwraps this `BufReader`, returning the underlying reader. +@@ -165,11 +160,9 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -192,7 +185,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -212,7 +204,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -222,7 +213,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -320,7 +310,6 @@ impl Seek for BufReader { + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html + /// [`flush`]: #method.flush +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -355,7 +344,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -369,7 +357,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -387,7 +374,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -436,7 +422,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -454,7 +439,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -472,7 +456,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -481,7 +464,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -501,7 +483,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -511,7 +492,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -521,7 +501,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -560,7 +539,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -593,23 +571,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -664,7 +632,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -685,7 +652,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -706,7 +672,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -730,7 +695,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -753,7 +717,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -775,7 +738,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -786,7 +748,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -831,7 +792,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index 32a9214..21ed409 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,10 +215,9 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } +@@ -236,16 +228,19 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -257,7 +252,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos: usize = self.position().try_into().map_err(|_| { +@@ -287,8 +282,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos = cmp::min(self.pos, self.inner.len() as u64); +diff --git a/error.rs b/error.rs +index bb9383d..01ddea6 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -48,7 +53,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and +@@ -63,7 +67,6 @@ pub type Result = result::Result; + /// [`Seek`]: ../io/trait.Seek.html + /// [`ErrorKind`]: enum.ErrorKind.html + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } +@@ -71,13 +74,16 @@ pub struct Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -89,47 +95,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -141,10 +134,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -155,15 +146,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -172,15 +160,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -213,7 +196,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -242,14 +224,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind, +@@ -258,24 +239,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -301,7 +264,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -332,7 +294,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -366,12 +327,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -437,12 +397,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -471,8 +430,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -498,10 +456,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -512,21 +469,18 @@ impl fmt::Debug for Repr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Repr::Os(ref code) => +- fmt.debug_struct("Os").field("code", code) +- .field("message", &sys::os::error_string(*code)).finish(), ++ fmt.debug_struct("Os").field("code", code).finish(), + Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -534,24 +488,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index d6b41ce..1ddabf1 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -208,7 +212,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -222,7 +226,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -248,7 +251,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/memchr.rs b/memchr.rs +index 3824a5f..312cf47 100644 +--- a/memchr.rs ++++ b/memchr.rs +@@ -11,10 +11,12 @@ + // Original implementation taken from rust-memchr + // Copyright 2015 Andrew Gallant, bluss and Nicolas Koch + ++pub use self::fallback::{memchr,memrchr}; ++ + #[allow(dead_code)] + pub mod fallback { +- use cmp; +- use mem; ++ use core::cmp; ++ use core::mem; + + const LO_U64: u64 = 0x0101010101010101; + const HI_U64: u64 = 0x8080808080808080; +diff --git a/mod.rs b/mod.rs +index 181b872..64efb23 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -268,50 +268,35 @@ + //! [`Result`]: ../result/enum.Result.html + //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++mod memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -336,6 +321,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -363,6 +349,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -449,7 +436,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning + /// how many bytes were read. +@@ -505,7 +491,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -530,7 +515,6 @@ pub trait Read { + /// + /// [`Initializer::nop()`]: ../../std/io/struct.Initializer.html#method.nop + /// [`Initializer`]: ../../std/io/struct.Initializer.html +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -578,7 +562,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -616,7 +600,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -679,7 +663,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -731,7 +714,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an [`Iterator`] over its bytes. +@@ -767,7 +749,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -808,10 +789,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -846,7 +823,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -882,20 +858,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -909,21 +882,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -966,7 +936,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. + /// +@@ -1010,7 +979,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1036,7 +1004,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1066,7 +1033,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1118,7 +1084,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1174,7 +1139,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1204,7 +1168,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1220,7 +1183,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1230,29 +1192,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1332,7 +1291,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1377,7 +1336,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1399,7 +1357,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1455,7 +1412,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1510,7 +1466,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1551,7 +1506,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1590,7 +1544,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1602,7 +1555,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1628,7 +1580,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1651,7 +1602,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1678,13 +1628,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1694,7 +1642,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1716,7 +1663,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1743,7 +1690,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1778,7 +1724,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Sets the number of bytes that can be read before this instance will +@@ -1805,7 +1750,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "take_set_limit", issue = "42781")] + pub fn set_limit(&mut self, limit: u64) { + self.limit = limit; + } +@@ -1830,7 +1774,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1855,7 +1798,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1884,13 +1826,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1909,7 +1849,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1948,13 +1888,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -1969,8 +1907,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -1979,8 +1915,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -1990,8 +1924,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -2023,25 +1955,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2060,14 +1973,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2092,13 +2005,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 88f4214..df974c3 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -44,7 +45,6 @@ use mem; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -73,7 +73,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of `empty()` for more details. + /// + /// [empty]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -91,10 +90,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -104,7 +101,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -112,7 +110,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -125,7 +122,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -142,10 +138,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -161,7 +155,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -174,7 +167,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -191,10 +183,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -202,7 +192,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/c9f99924192e5c3a8d120eb36bcf96419b3fc7e0.patch b/patches/c9f99924192e5c3a8d120eb36bcf96419b3fc7e0.patch new file mode 100644 index 0000000..f332f58 --- /dev/null +++ b/patches/c9f99924192e5c3a8d120eb36bcf96419b3fc7e0.patch @@ -0,0 +1,1618 @@ +diff --git a/buffered.rs b/buffered.rs +index 4ebd355..242aab4 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Unwraps this `BufReader`, returning the underlying reader. +@@ -165,11 +160,9 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -192,7 +185,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -212,7 +204,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -222,7 +213,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -320,7 +310,6 @@ impl Seek for BufReader { + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html + /// [`flush`]: #method.flush +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -355,7 +344,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -369,7 +357,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -387,7 +374,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -436,7 +422,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -454,7 +439,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -472,7 +456,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -481,7 +464,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -501,7 +483,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -511,7 +492,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -521,7 +501,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -560,7 +539,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -593,23 +571,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -664,7 +632,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -685,7 +652,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -706,7 +672,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -730,7 +695,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -753,7 +717,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -775,7 +738,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -786,7 +748,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -831,7 +792,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index 32a9214..21ed409 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,10 +215,9 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } +@@ -236,16 +228,19 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -257,7 +252,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos: usize = self.position().try_into().map_err(|_| { +@@ -287,8 +282,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos = cmp::min(self.pos, self.inner.len() as u64); +diff --git a/error.rs b/error.rs +index bb9383d..01ddea6 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -48,7 +53,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and +@@ -63,7 +67,6 @@ pub type Result = result::Result; + /// [`Seek`]: ../io/trait.Seek.html + /// [`ErrorKind`]: enum.ErrorKind.html + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } +@@ -71,13 +74,16 @@ pub struct Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -89,47 +95,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -141,10 +134,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -155,15 +146,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -172,15 +160,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -213,7 +196,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -242,14 +224,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind, +@@ -258,24 +239,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -301,7 +264,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -332,7 +294,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -366,12 +327,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -437,12 +397,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -471,8 +430,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -498,10 +456,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -512,21 +469,18 @@ impl fmt::Debug for Repr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Repr::Os(ref code) => +- fmt.debug_struct("Os").field("code", code) +- .field("message", &sys::os::error_string(*code)).finish(), ++ fmt.debug_struct("Os").field("code", code).finish(), + Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -534,24 +488,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index d6b41ce..1ddabf1 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -208,7 +212,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -222,7 +226,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -248,7 +251,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/memchr.rs b/memchr.rs +index 3824a5f..312cf47 100644 +--- a/memchr.rs ++++ b/memchr.rs +@@ -11,10 +11,12 @@ + // Original implementation taken from rust-memchr + // Copyright 2015 Andrew Gallant, bluss and Nicolas Koch + ++pub use self::fallback::{memchr,memrchr}; ++ + #[allow(dead_code)] + pub mod fallback { +- use cmp; +- use mem; ++ use core::cmp; ++ use core::mem; + + const LO_U64: u64 = 0x0101010101010101; + const HI_U64: u64 = 0x8080808080808080; +diff --git a/mod.rs b/mod.rs +index f486493..6b63b12 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -268,50 +268,35 @@ + //! [`Result`]: ../result/enum.Result.html + //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++mod memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -336,6 +321,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -363,6 +349,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -448,7 +435,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning + /// how many bytes were read. +@@ -501,7 +487,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -523,7 +508,6 @@ pub trait Read { + /// This method is unsafe because a `Read`er could otherwise return a + /// non-zeroing `Initializer` from another `Read` type without an `unsafe` + /// block. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -568,7 +552,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -606,7 +590,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -667,7 +651,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -719,7 +702,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an `Iterator` over its bytes. +@@ -749,7 +731,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -786,10 +767,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -824,7 +801,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -858,20 +834,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -885,21 +858,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -942,7 +912,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. + /// +@@ -986,7 +955,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1012,7 +980,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1042,7 +1009,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1094,7 +1060,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1150,7 +1115,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1180,7 +1144,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1196,7 +1159,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1206,29 +1168,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1308,7 +1267,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1353,7 +1312,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1375,7 +1333,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1431,7 +1388,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1486,7 +1442,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1527,7 +1482,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1566,7 +1520,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1578,7 +1531,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1604,7 +1556,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1627,7 +1578,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1654,13 +1604,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1670,7 +1618,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1692,7 +1639,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1719,7 +1666,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1754,7 +1700,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Sets the number of bytes that can be read before this instance will +@@ -1781,7 +1726,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "take_set_limit", issue = "42781")] + pub fn set_limit(&mut self, limit: u64) { + self.limit = limit; + } +@@ -1806,7 +1750,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1831,7 +1774,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1860,13 +1802,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1885,7 +1825,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1924,13 +1864,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -1945,8 +1883,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -1955,8 +1891,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -1966,8 +1900,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -1999,25 +1931,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2036,14 +1949,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2068,13 +1981,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 88f4214..df974c3 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -44,7 +45,6 @@ use mem; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -73,7 +73,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of `empty()` for more details. + /// + /// [empty]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -91,10 +90,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -104,7 +101,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -112,7 +110,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -125,7 +122,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -142,10 +138,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -161,7 +155,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -174,7 +167,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -191,10 +183,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -202,7 +192,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/cb56b2d1522e83c5bb0613abcf78b686e994df9e.patch b/patches/cb56b2d1522e83c5bb0613abcf78b686e994df9e.patch new file mode 100644 index 0000000..193c6fb --- /dev/null +++ b/patches/cb56b2d1522e83c5bb0613abcf78b686e994df9e.patch @@ -0,0 +1,1665 @@ +diff --git a/buffered.rs b/buffered.rs +index 9250c1c..bf6383f 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Returns `true` if there are no bytes in the internal buffer. +@@ -167,7 +162,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "bufreader_is_empty", issue = "45323", reason = "recently added")] + pub fn is_empty(&self) -> bool { + self.pos == self.cap + } +@@ -190,7 +184,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +@@ -199,7 +192,6 @@ impl BufReader { + /// the buffer will not be flushed, allowing for more efficient seeks. + /// This method does not return the location of the underlying reader, so the caller + /// must track this information themselves if it is required. +- #[unstable(feature = "bufreader_seek_relative", issue = "31100")] + pub fn seek_relative(&mut self, offset: i64) -> io::Result<()> { + let pos = self.pos as u64; + if offset < 0 { +@@ -219,7 +211,6 @@ impl BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -242,7 +233,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -262,7 +252,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -272,7 +261,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -374,7 +362,6 @@ impl Seek for BufReader { + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html + /// [`flush`]: #method.flush +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -409,7 +396,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -423,7 +409,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -441,7 +426,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -490,7 +474,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -508,7 +491,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -530,7 +512,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -539,7 +520,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -559,7 +539,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -569,7 +548,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -579,7 +557,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -618,7 +595,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -651,23 +627,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -725,7 +691,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -746,7 +711,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -767,7 +731,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -791,7 +754,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -814,7 +776,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -840,7 +801,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -851,7 +811,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -896,7 +855,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index 76bcb5f..dcc64c6 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,17 +215,16 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } + + fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> { + let n = buf.len(); +- Read::read_exact(&mut self.fill_buf()?, buf)?; ++ Read::read_exact(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(()) + } +@@ -243,12 +235,16 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +@@ -261,6 +257,7 @@ fn slice_write(pos_mut: &mut u64, slice: &mut [u8], buf: &[u8]) -> io::Result, buf: &[u8]) -> io::Result { + let pos: usize = (*pos_mut).try_into().map_err(|_| { + Error::new(ErrorKind::InvalidInput, +@@ -287,7 +284,6 @@ fn vec_write(pos_mut: &mut u64, vec: &mut Vec, buf: &[u8]) -> io::Result Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +@@ -296,7 +292,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_mut_vec", since = "1.25.0")] ++#[cfg(feature="collections")] + impl<'a> Write for Cursor<&'a mut Vec> { + fn write(&mut self, buf: &[u8]) -> io::Result { + vec_write(&mut self.pos, self.inner, buf) +@@ -304,7 +300,7 @@ impl<'a> Write for Cursor<&'a mut Vec> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + vec_write(&mut self.pos, &mut self.inner, buf) +@@ -312,8 +308,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + slice_write(&mut self.pos, &mut self.inner, buf) +diff --git a/error.rs b/error.rs +index bdd675e..3acdadf 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -48,7 +53,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and +@@ -62,12 +66,10 @@ pub type Result = result::Result; + /// [`Write`]: ../io/trait.Write.html + /// [`Seek`]: ../io/trait.Seek.html + /// [`ErrorKind`]: enum.ErrorKind.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Debug::fmt(&self.repr, f) +@@ -77,13 +79,16 @@ impl fmt::Debug for Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -95,47 +100,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -147,10 +139,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -161,15 +151,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -178,15 +165,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -219,7 +201,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -248,14 +229,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind, +@@ -264,24 +244,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -307,7 +269,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::InvalidInput); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -338,7 +299,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -372,12 +332,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -443,12 +402,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -477,8 +435,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -504,10 +461,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -519,22 +475,18 @@ impl fmt::Debug for Repr { + match *self { + Repr::Os(code) => + fmt.debug_struct("Os") +- .field("code", &code) +- .field("kind", &sys::decode_error_kind(code)) +- .field("message", &sys::os::error_string(code)).finish(), ++ .field("code", &code).finish(), + Repr::Custom(ref c) => fmt::Debug::fmt(&c, fmt), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -542,24 +494,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index fe1179a..452b8b7 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -207,6 +211,7 @@ impl<'a> Read for &'a [u8] { + Ok(()) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + buf.extend_from_slice(*self); +@@ -216,7 +221,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -230,7 +235,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -256,7 +260,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/mod.rs b/mod.rs +index d403bf6..c6c236e 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -268,50 +268,38 @@ + //! [`Result`]: ../result/enum.Result.html + //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++#[cfg(not(core_memchr))] ++mod memchr; ++#[cfg(all(feature="collections",core_memchr))] ++use core::slice::memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -336,6 +324,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -363,6 +352,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -466,7 +456,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// [`BufReader`]: struct.BufReader.html + /// [`&str`]: ../../std/primitive.str.html + /// [slice]: ../../std/primitive.slice.html +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning +@@ -523,7 +512,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -548,7 +536,6 @@ pub trait Read { + /// + /// [`Initializer::nop()`]: ../../std/io/struct.Initializer.html#method.nop + /// [`Initializer`]: ../../std/io/struct.Initializer.html +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -596,7 +583,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -634,7 +621,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -697,7 +684,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -749,7 +735,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an [`Iterator`] over its bytes. +@@ -786,7 +771,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -827,10 +811,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -865,7 +845,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -901,20 +880,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -928,21 +904,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -985,7 +958,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. +@@ -1034,7 +1006,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1060,7 +1031,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1093,7 +1063,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1145,7 +1114,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1201,7 +1169,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1231,7 +1198,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1247,7 +1213,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1257,29 +1222,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1359,7 +1321,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1404,7 +1366,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1426,7 +1387,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1482,7 +1442,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1541,7 +1500,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1582,7 +1540,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1621,7 +1578,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1633,7 +1589,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1659,7 +1614,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1682,7 +1636,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1709,13 +1662,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1725,7 +1676,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1747,7 +1697,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1774,7 +1724,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1809,7 +1758,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Sets the number of bytes that can be read before this instance will +@@ -1836,7 +1784,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "take_set_limit", issue = "42781")] + pub fn set_limit(&mut self, limit: u64) { + self.limit = limit; + } +@@ -1861,7 +1808,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1886,7 +1832,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1915,13 +1860,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1940,7 +1883,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1979,13 +1922,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -2000,8 +1941,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -2010,8 +1949,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -2021,8 +1958,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -2053,25 +1988,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2090,14 +2006,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2122,13 +2038,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 45d281e..0efc3b1 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -45,7 +46,6 @@ use mem; + /// # } + /// # foo().unwrap(); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -74,7 +74,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of [`empty()`][`empty`] for more details. + /// + /// [`empty`]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -94,10 +93,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -107,7 +104,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -115,7 +113,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -128,7 +125,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -145,10 +141,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -164,7 +158,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -177,7 +170,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -194,10 +186,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -205,7 +195,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/cc20ab1f2509de4ef0a9953e514d62fa23b6c572.patch b/patches/cc20ab1f2509de4ef0a9953e514d62fa23b6c572.patch new file mode 100644 index 0000000..93aab87 --- /dev/null +++ b/patches/cc20ab1f2509de4ef0a9953e514d62fa23b6c572.patch @@ -0,0 +1,1618 @@ +diff --git a/buffered.rs b/buffered.rs +index 1b83245..28a2456 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Unwraps this `BufReader`, returning the underlying reader. +@@ -165,11 +160,9 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -192,7 +185,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -212,7 +204,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -222,7 +213,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -320,7 +310,6 @@ impl Seek for BufReader { + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html + /// [`flush`]: #method.flush +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -355,7 +344,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -369,7 +357,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -387,7 +374,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -436,7 +422,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -454,7 +439,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -472,7 +456,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -481,7 +464,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -501,7 +483,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -511,7 +492,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -521,7 +501,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -560,7 +539,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -593,23 +571,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -664,7 +632,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -685,7 +652,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -706,7 +672,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -730,7 +695,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -753,7 +717,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -775,7 +738,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -786,7 +748,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -831,7 +792,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index 616b4f4..97d1076 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,10 +215,9 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } +@@ -236,16 +228,19 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -257,7 +252,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos: usize = self.position().try_into().map_err(|_| { +@@ -287,8 +282,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos = cmp::min(self.pos, self.inner.len() as u64); +diff --git a/error.rs b/error.rs +index 0a5804a..4564ca7 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -44,7 +49,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the `Read`, `Write`, `Seek`, and +@@ -56,7 +60,6 @@ pub type Result = result::Result; + /// + /// [`ErrorKind`]: enum.ErrorKind.html + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } +@@ -64,13 +67,16 @@ pub struct Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -82,47 +88,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -134,10 +127,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -148,15 +139,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -165,15 +153,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -206,7 +189,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -235,14 +217,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind: kind, +@@ -251,24 +232,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -294,7 +257,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -325,7 +287,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -359,12 +320,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -430,12 +390,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -464,8 +423,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -491,10 +449,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -505,21 +462,18 @@ impl fmt::Debug for Repr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Repr::Os(ref code) => +- fmt.debug_struct("Os").field("code", code) +- .field("message", &sys::os::error_string(*code)).finish(), ++ fmt.debug_struct("Os").field("code", code).finish(), + Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -527,24 +481,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index d6b41ce..1ddabf1 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -208,7 +212,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -222,7 +226,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -248,7 +251,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/memchr.rs b/memchr.rs +index 3824a5f..312cf47 100644 +--- a/memchr.rs ++++ b/memchr.rs +@@ -11,10 +11,12 @@ + // Original implementation taken from rust-memchr + // Copyright 2015 Andrew Gallant, bluss and Nicolas Koch + ++pub use self::fallback::{memchr,memrchr}; ++ + #[allow(dead_code)] + pub mod fallback { +- use cmp; +- use mem; ++ use core::cmp; ++ use core::mem; + + const LO_U64: u64 = 0x0101010101010101; + const HI_U64: u64 = 0x8080808080808080; +diff --git a/mod.rs b/mod.rs +index 9a3036f..bb88614 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -266,50 +266,35 @@ + //! [`?` operator]: ../../book/first-edition/syntax-index.html + //! [`Read::read`]: trait.Read.html#tymethod.read + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++mod memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -334,6 +319,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -361,6 +347,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -446,7 +433,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning + /// how many bytes were read. +@@ -499,7 +485,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -521,7 +506,6 @@ pub trait Read { + /// This method is unsafe because a `Read`er could otherwise return a + /// non-zeroing `Initializer` from another `Read` type without an `unsafe` + /// block. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -566,7 +550,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -604,7 +588,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -665,7 +649,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -717,7 +700,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an `Iterator` over its bytes. +@@ -747,7 +729,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -784,10 +765,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -822,7 +799,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -856,20 +832,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -883,21 +856,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -940,7 +910,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. + /// +@@ -984,7 +953,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1010,7 +978,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1040,7 +1007,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1092,7 +1058,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1148,7 +1113,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1178,7 +1142,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1194,7 +1157,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1204,29 +1166,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1306,7 +1265,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1351,7 +1310,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1373,7 +1331,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1429,7 +1386,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1484,7 +1440,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1525,7 +1480,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1564,7 +1518,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1576,7 +1529,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1602,7 +1554,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1625,7 +1576,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1652,13 +1602,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1668,7 +1616,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1690,7 +1637,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1717,7 +1664,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1752,7 +1698,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Sets the number of bytes that can be read before this instance will +@@ -1779,7 +1724,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "take_set_limit", issue = "42781")] + pub fn set_limit(&mut self, limit: u64) { + self.limit = limit; + } +@@ -1804,7 +1748,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1829,7 +1772,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1858,13 +1800,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1883,7 +1823,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1922,13 +1862,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -1943,8 +1881,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -1953,8 +1889,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -1964,8 +1898,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -1997,25 +1929,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2034,14 +1947,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2066,13 +1979,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 88f4214..df974c3 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -44,7 +45,6 @@ use mem; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -73,7 +73,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of `empty()` for more details. + /// + /// [empty]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -91,10 +90,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -104,7 +101,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -112,7 +110,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -125,7 +122,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -142,10 +138,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -161,7 +155,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -174,7 +167,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -191,10 +183,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -202,7 +192,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/d280b40b18532dfeb80b1a98109fa6218630b939.patch b/patches/d280b40b18532dfeb80b1a98109fa6218630b939.patch new file mode 100644 index 0000000..6ef5d62 --- /dev/null +++ b/patches/d280b40b18532dfeb80b1a98109fa6218630b939.patch @@ -0,0 +1,1610 @@ +diff --git a/buffered.rs b/buffered.rs +index 296ee78..4262dc5 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Unwraps this `BufReader`, returning the underlying reader. +@@ -165,11 +160,9 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -192,7 +185,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -212,7 +204,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -222,7 +213,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -316,7 +306,6 @@ impl Seek for BufReader { + /// [`Write`]: ../../std/io/trait.Write.html + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -351,7 +340,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -365,7 +353,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -383,7 +370,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -432,7 +418,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -450,7 +435,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -468,7 +452,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -477,7 +460,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -497,7 +479,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -507,7 +488,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -517,7 +497,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -556,7 +535,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -589,23 +567,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -660,7 +628,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -681,7 +648,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -702,7 +668,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -726,7 +691,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -749,7 +713,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -771,7 +734,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -782,7 +744,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -827,7 +788,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index 616b4f4..97d1076 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,10 +215,9 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } +@@ -236,16 +228,19 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -257,7 +252,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos: usize = self.position().try_into().map_err(|_| { +@@ -287,8 +282,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos = cmp::min(self.pos, self.inner.len() as u64); +diff --git a/error.rs b/error.rs +index 0a5804a..4564ca7 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -44,7 +49,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the `Read`, `Write`, `Seek`, and +@@ -56,7 +60,6 @@ pub type Result = result::Result; + /// + /// [`ErrorKind`]: enum.ErrorKind.html + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } +@@ -64,13 +67,16 @@ pub struct Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -82,47 +88,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -134,10 +127,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -148,15 +139,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -165,15 +153,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -206,7 +189,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -235,14 +217,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind: kind, +@@ -251,24 +232,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -294,7 +257,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -325,7 +287,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -359,12 +320,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -430,12 +390,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -464,8 +423,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -491,10 +449,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -505,21 +462,18 @@ impl fmt::Debug for Repr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Repr::Os(ref code) => +- fmt.debug_struct("Os").field("code", code) +- .field("message", &sys::os::error_string(*code)).finish(), ++ fmt.debug_struct("Os").field("code", code).finish(), + Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -527,24 +481,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index d6b41ce..1ddabf1 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -208,7 +212,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -222,7 +226,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -248,7 +251,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/memchr.rs b/memchr.rs +index 3824a5f..312cf47 100644 +--- a/memchr.rs ++++ b/memchr.rs +@@ -11,10 +11,12 @@ + // Original implementation taken from rust-memchr + // Copyright 2015 Andrew Gallant, bluss and Nicolas Koch + ++pub use self::fallback::{memchr,memrchr}; ++ + #[allow(dead_code)] + pub mod fallback { +- use cmp; +- use mem; ++ use core::cmp; ++ use core::mem; + + const LO_U64: u64 = 0x0101010101010101; + const HI_U64: u64 = 0x8080808080808080; +diff --git a/mod.rs b/mod.rs +index 71c7600..ab9da6e 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -266,50 +266,35 @@ + //! [`?` operator]: ../../book/first-edition/syntax-index.html + //! [`Read::read`]: trait.Read.html#tymethod.read + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++mod memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -334,6 +319,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -361,6 +347,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -446,7 +433,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning + /// how many bytes were read. +@@ -499,7 +485,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -521,7 +506,6 @@ pub trait Read { + /// This method is unsafe because a `Read`er could otherwise return a + /// non-zeroing `Initializer` from another `Read` type without an `unsafe` + /// block. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -566,7 +550,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -604,7 +588,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -665,7 +649,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -717,7 +700,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an `Iterator` over its bytes. +@@ -747,7 +729,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -784,10 +765,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -822,7 +799,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -856,20 +832,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -883,21 +856,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -940,7 +910,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. + /// +@@ -984,7 +953,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1010,7 +978,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1040,7 +1007,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1092,7 +1058,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1148,7 +1113,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1178,7 +1142,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1194,7 +1157,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1204,29 +1166,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1306,7 +1265,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1351,7 +1310,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1373,7 +1331,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1429,7 +1386,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1484,7 +1440,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1525,7 +1480,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1564,7 +1518,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1576,7 +1529,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1602,7 +1554,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1625,7 +1576,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1652,13 +1602,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1668,7 +1616,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1690,7 +1637,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1717,7 +1664,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1752,7 +1698,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Consumes the `Take`, returning the wrapped reader. +@@ -1775,7 +1720,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1800,7 +1744,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1829,13 +1772,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1854,7 +1795,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1893,13 +1834,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -1914,8 +1853,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -1924,8 +1861,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -1935,8 +1870,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -1968,25 +1901,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2005,14 +1919,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2037,13 +1951,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 88f4214..df974c3 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -44,7 +45,6 @@ use mem; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -73,7 +73,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of `empty()` for more details. + /// + /// [empty]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -91,10 +90,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -104,7 +101,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -112,7 +110,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -125,7 +122,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -142,10 +138,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -161,7 +155,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -174,7 +167,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -191,10 +183,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -202,7 +192,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/d301da55f8cd7b8b10771d3171ae60ba334bf067.patch b/patches/d301da55f8cd7b8b10771d3171ae60ba334bf067.patch new file mode 100644 index 0000000..5602084 --- /dev/null +++ b/patches/d301da55f8cd7b8b10771d3171ae60ba334bf067.patch @@ -0,0 +1,1626 @@ +diff --git a/buffered.rs b/buffered.rs +index 7001d8e..8e5daa4 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Returns `true` if there are no bytes in the internal buffer. +@@ -167,7 +162,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "bufreader_is_empty", issue = "45323", reason = "recently added")] + pub fn is_empty(&self) -> bool { + self.pos == self.cap + } +@@ -190,11 +184,9 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -217,7 +209,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -237,7 +228,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -247,7 +237,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -345,7 +334,6 @@ impl Seek for BufReader { + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html + /// [`flush`]: #method.flush +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -380,7 +368,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -394,7 +381,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -412,7 +398,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -461,7 +446,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -479,7 +463,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -501,7 +484,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -510,7 +492,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -530,7 +511,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -540,7 +520,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -550,7 +529,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -589,7 +567,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -622,23 +599,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -696,7 +663,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -717,7 +683,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -738,7 +703,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -762,7 +726,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -785,7 +748,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -811,7 +773,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -822,7 +783,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -867,7 +827,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index b5ea553..b31cfa3 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,17 +215,16 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } + + fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> { + let n = buf.len(); +- Read::read_exact(&mut self.fill_buf()?, buf)?; ++ Read::read_exact(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(()) + } +@@ -243,16 +235,19 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -264,7 +259,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos: usize = self.position().try_into().map_err(|_| { +@@ -294,8 +289,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos = cmp::min(self.pos, self.inner.len() as u64); +diff --git a/error.rs b/error.rs +index bb9383d..01ddea6 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -48,7 +53,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and +@@ -63,7 +67,6 @@ pub type Result = result::Result; + /// [`Seek`]: ../io/trait.Seek.html + /// [`ErrorKind`]: enum.ErrorKind.html + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } +@@ -71,13 +74,16 @@ pub struct Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -89,47 +95,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -141,10 +134,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -155,15 +146,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -172,15 +160,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -213,7 +196,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -242,14 +224,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind, +@@ -258,24 +239,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -301,7 +264,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -332,7 +294,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -366,12 +327,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -437,12 +397,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -471,8 +430,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -498,10 +456,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -512,21 +469,18 @@ impl fmt::Debug for Repr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Repr::Os(ref code) => +- fmt.debug_struct("Os").field("code", code) +- .field("message", &sys::os::error_string(*code)).finish(), ++ fmt.debug_struct("Os").field("code", code).finish(), + Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -534,24 +488,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index fe1179a..452b8b7 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -207,6 +211,7 @@ impl<'a> Read for &'a [u8] { + Ok(()) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + buf.extend_from_slice(*self); +@@ -216,7 +221,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -230,7 +235,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -256,7 +260,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/mod.rs b/mod.rs +index ad9cf1e..4273686 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -268,50 +268,38 @@ + //! [`Result`]: ../result/enum.Result.html + //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++#[cfg(not(core_memchr))] ++mod memchr; ++#[cfg(all(feature="collections",core_memchr))] ++use core::slice::memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -336,6 +324,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -363,6 +352,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -466,7 +456,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// [`BufReader`]: struct.BufReader.html + /// [`&str`]: ../../std/primitive.str.html + /// [slice]: ../../std/primitive.slice.html +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning +@@ -523,7 +512,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -548,7 +536,6 @@ pub trait Read { + /// + /// [`Initializer::nop()`]: ../../std/io/struct.Initializer.html#method.nop + /// [`Initializer`]: ../../std/io/struct.Initializer.html +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -596,7 +583,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -634,7 +621,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -697,7 +684,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -749,7 +735,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an [`Iterator`] over its bytes. +@@ -786,7 +771,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -827,10 +811,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -865,7 +845,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -901,20 +880,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -928,21 +904,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -985,7 +958,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. +@@ -1030,7 +1002,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1056,7 +1027,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1086,7 +1056,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1138,7 +1107,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1194,7 +1162,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1224,7 +1191,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1240,7 +1206,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1250,29 +1215,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1352,7 +1314,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1397,7 +1359,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1419,7 +1380,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1477,7 +1437,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1534,7 +1493,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1575,7 +1533,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1614,7 +1571,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1626,7 +1582,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1652,7 +1607,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1675,7 +1629,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1702,13 +1655,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1718,7 +1669,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1740,7 +1690,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1767,7 +1717,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1802,7 +1751,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Sets the number of bytes that can be read before this instance will +@@ -1829,7 +1777,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "take_set_limit", issue = "42781")] + pub fn set_limit(&mut self, limit: u64) { + self.limit = limit; + } +@@ -1854,7 +1801,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1879,7 +1825,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1908,13 +1853,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1933,7 +1876,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1972,13 +1915,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -1993,8 +1934,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -2003,8 +1942,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -2014,8 +1951,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -2046,25 +1981,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2083,14 +1999,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2115,13 +2031,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 45d281e..0efc3b1 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -45,7 +46,6 @@ use mem; + /// # } + /// # foo().unwrap(); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -74,7 +74,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of [`empty()`][`empty`] for more details. + /// + /// [`empty`]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -94,10 +93,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -107,7 +104,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -115,7 +113,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -128,7 +125,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -145,10 +141,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -164,7 +158,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -177,7 +170,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -194,10 +186,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -205,7 +195,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/d52acbe37f69a2ebc9d161c479ed628da1cbea4e.patch b/patches/d52acbe37f69a2ebc9d161c479ed628da1cbea4e.patch new file mode 100644 index 0000000..a70111b --- /dev/null +++ b/patches/d52acbe37f69a2ebc9d161c479ed628da1cbea4e.patch @@ -0,0 +1,1626 @@ +diff --git a/buffered.rs b/buffered.rs +index 4ebd355..242aab4 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Unwraps this `BufReader`, returning the underlying reader. +@@ -165,11 +160,9 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -192,7 +185,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -212,7 +204,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -222,7 +213,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -320,7 +310,6 @@ impl Seek for BufReader { + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html + /// [`flush`]: #method.flush +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -355,7 +344,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -369,7 +357,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -387,7 +374,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -436,7 +422,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -454,7 +439,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -472,7 +456,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -481,7 +464,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -501,7 +483,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -511,7 +492,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -521,7 +501,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -560,7 +539,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -593,23 +571,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -664,7 +632,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -685,7 +652,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -706,7 +672,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -730,7 +695,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -753,7 +717,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -775,7 +738,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -786,7 +748,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -831,7 +792,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index 32a9214..21ed409 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,10 +215,9 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } +@@ -236,16 +228,19 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -257,7 +252,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos: usize = self.position().try_into().map_err(|_| { +@@ -287,8 +282,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos = cmp::min(self.pos, self.inner.len() as u64); +diff --git a/error.rs b/error.rs +index bb9383d..01ddea6 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -48,7 +53,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and +@@ -63,7 +67,6 @@ pub type Result = result::Result; + /// [`Seek`]: ../io/trait.Seek.html + /// [`ErrorKind`]: enum.ErrorKind.html + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } +@@ -71,13 +74,16 @@ pub struct Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -89,47 +95,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -141,10 +134,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -155,15 +146,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -172,15 +160,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -213,7 +196,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -242,14 +224,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind, +@@ -258,24 +239,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -301,7 +264,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -332,7 +294,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -366,12 +327,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -437,12 +397,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -471,8 +430,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -498,10 +456,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -512,21 +469,18 @@ impl fmt::Debug for Repr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Repr::Os(ref code) => +- fmt.debug_struct("Os").field("code", code) +- .field("message", &sys::os::error_string(*code)).finish(), ++ fmt.debug_struct("Os").field("code", code).finish(), + Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -534,24 +488,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index fe1179a..452b8b7 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -207,6 +211,7 @@ impl<'a> Read for &'a [u8] { + Ok(()) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + buf.extend_from_slice(*self); +@@ -216,7 +221,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -230,7 +235,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -256,7 +260,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/memchr.rs b/memchr.rs +index 50f998e..a8bff09 100644 +--- a/memchr.rs ++++ b/memchr.rs +@@ -11,10 +11,12 @@ + // Original implementation taken from rust-memchr + // Copyright 2015 Andrew Gallant, bluss and Nicolas Koch + ++pub use self::fallback::{memchr,memrchr}; ++ + #[allow(dead_code)] + pub mod fallback { +- use cmp; +- use mem; ++ use core::cmp; ++ use core::mem; + + const LO_U64: u64 = 0x0101010101010101; + const HI_U64: u64 = 0x8080808080808080; +diff --git a/mod.rs b/mod.rs +index 074ab3e..8dfbe83 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -268,50 +268,35 @@ + //! [`Result`]: ../result/enum.Result.html + //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++mod memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -336,6 +321,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -363,6 +349,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -449,7 +436,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning + /// how many bytes were read. +@@ -505,7 +491,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -530,7 +515,6 @@ pub trait Read { + /// + /// [`Initializer::nop()`]: ../../std/io/struct.Initializer.html#method.nop + /// [`Initializer`]: ../../std/io/struct.Initializer.html +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -578,7 +562,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -616,7 +600,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -679,7 +663,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -731,7 +714,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an [`Iterator`] over its bytes. +@@ -767,7 +749,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -808,10 +789,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -846,7 +823,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -882,20 +858,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -909,21 +882,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -966,7 +936,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. + /// +@@ -1010,7 +979,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1036,7 +1004,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1066,7 +1033,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1118,7 +1084,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1174,7 +1139,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1204,7 +1168,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1220,7 +1183,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1230,29 +1192,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1332,7 +1291,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1377,7 +1336,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1399,7 +1357,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1455,7 +1412,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1510,7 +1466,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1551,7 +1506,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1590,7 +1544,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1602,7 +1555,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1628,7 +1580,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1651,7 +1602,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1678,13 +1628,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1694,7 +1642,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1716,7 +1663,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1743,7 +1690,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1778,7 +1724,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Sets the number of bytes that can be read before this instance will +@@ -1805,7 +1750,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "take_set_limit", issue = "42781")] + pub fn set_limit(&mut self, limit: u64) { + self.limit = limit; + } +@@ -1830,7 +1774,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1855,7 +1798,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1884,13 +1826,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1909,7 +1849,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1948,13 +1888,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -1969,8 +1907,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -1979,8 +1915,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -1990,8 +1924,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -2023,25 +1955,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2060,14 +1973,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2092,13 +2005,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 45d281e..0efc3b1 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -45,7 +46,6 @@ use mem; + /// # } + /// # foo().unwrap(); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -74,7 +74,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of [`empty()`][`empty`] for more details. + /// + /// [`empty`]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -94,10 +93,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -107,7 +104,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -115,7 +113,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -128,7 +125,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -145,10 +141,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -164,7 +158,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -177,7 +170,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -194,10 +186,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -205,7 +195,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/e2554b36fc805c5dcb8bef65fee12e0753d5ad03.patch b/patches/e2554b36fc805c5dcb8bef65fee12e0753d5ad03.patch new file mode 100644 index 0000000..eec7791 --- /dev/null +++ b/patches/e2554b36fc805c5dcb8bef65fee12e0753d5ad03.patch @@ -0,0 +1,1626 @@ +diff --git a/buffered.rs b/buffered.rs +index 4ebd355..242aab4 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Unwraps this `BufReader`, returning the underlying reader. +@@ -165,11 +160,9 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -192,7 +185,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -212,7 +204,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -222,7 +213,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -320,7 +310,6 @@ impl Seek for BufReader { + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html + /// [`flush`]: #method.flush +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -355,7 +344,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -369,7 +357,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -387,7 +374,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -436,7 +422,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -454,7 +439,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -472,7 +456,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -481,7 +464,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -501,7 +483,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -511,7 +492,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -521,7 +501,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -560,7 +539,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -593,23 +571,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -664,7 +632,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -685,7 +652,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -706,7 +672,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -730,7 +695,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -753,7 +717,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -775,7 +738,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -786,7 +748,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -831,7 +792,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index 32a9214..21ed409 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,10 +215,9 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } +@@ -236,16 +228,19 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -257,7 +252,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos: usize = self.position().try_into().map_err(|_| { +@@ -287,8 +282,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos = cmp::min(self.pos, self.inner.len() as u64); +diff --git a/error.rs b/error.rs +index bb9383d..01ddea6 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -48,7 +53,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and +@@ -63,7 +67,6 @@ pub type Result = result::Result; + /// [`Seek`]: ../io/trait.Seek.html + /// [`ErrorKind`]: enum.ErrorKind.html + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } +@@ -71,13 +74,16 @@ pub struct Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -89,47 +95,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -141,10 +134,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -155,15 +146,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -172,15 +160,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -213,7 +196,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -242,14 +224,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind, +@@ -258,24 +239,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -301,7 +264,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -332,7 +294,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -366,12 +327,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -437,12 +397,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -471,8 +430,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -498,10 +456,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -512,21 +469,18 @@ impl fmt::Debug for Repr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Repr::Os(ref code) => +- fmt.debug_struct("Os").field("code", code) +- .field("message", &sys::os::error_string(*code)).finish(), ++ fmt.debug_struct("Os").field("code", code).finish(), + Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -534,24 +488,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index fe1179a..452b8b7 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -207,6 +211,7 @@ impl<'a> Read for &'a [u8] { + Ok(()) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + buf.extend_from_slice(*self); +@@ -216,7 +221,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -230,7 +235,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -256,7 +260,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/memchr.rs b/memchr.rs +index 50f998e..a8bff09 100644 +--- a/memchr.rs ++++ b/memchr.rs +@@ -11,10 +11,12 @@ + // Original implementation taken from rust-memchr + // Copyright 2015 Andrew Gallant, bluss and Nicolas Koch + ++pub use self::fallback::{memchr,memrchr}; ++ + #[allow(dead_code)] + pub mod fallback { +- use cmp; +- use mem; ++ use core::cmp; ++ use core::mem; + + const LO_U64: u64 = 0x0101010101010101; + const HI_U64: u64 = 0x8080808080808080; +diff --git a/mod.rs b/mod.rs +index dec2812..4dfa83a 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -268,50 +268,35 @@ + //! [`Result`]: ../result/enum.Result.html + //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++mod memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -336,6 +321,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -363,6 +349,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -449,7 +436,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning + /// how many bytes were read. +@@ -505,7 +491,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -530,7 +515,6 @@ pub trait Read { + /// + /// [`Initializer::nop()`]: ../../std/io/struct.Initializer.html#method.nop + /// [`Initializer`]: ../../std/io/struct.Initializer.html +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -578,7 +562,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -616,7 +600,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -679,7 +663,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -731,7 +714,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an [`Iterator`] over its bytes. +@@ -768,7 +750,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -809,10 +790,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -847,7 +824,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -883,20 +859,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -910,21 +883,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -967,7 +937,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. + /// +@@ -1011,7 +980,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1037,7 +1005,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1067,7 +1034,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1119,7 +1085,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1175,7 +1140,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1205,7 +1169,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1221,7 +1184,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1231,29 +1193,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1333,7 +1292,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1378,7 +1337,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1400,7 +1358,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1458,7 +1415,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1515,7 +1471,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1556,7 +1511,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1595,7 +1549,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1607,7 +1560,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1633,7 +1585,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1656,7 +1607,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1683,13 +1633,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1699,7 +1647,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1721,7 +1668,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1748,7 +1695,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1783,7 +1729,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Sets the number of bytes that can be read before this instance will +@@ -1810,7 +1755,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "take_set_limit", issue = "42781")] + pub fn set_limit(&mut self, limit: u64) { + self.limit = limit; + } +@@ -1835,7 +1779,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1860,7 +1803,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1889,13 +1831,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1914,7 +1854,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1953,13 +1893,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -1974,8 +1912,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -1984,8 +1920,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -1995,8 +1929,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -2028,25 +1960,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2065,14 +1978,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2097,13 +2010,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 45d281e..0efc3b1 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -45,7 +46,6 @@ use mem; + /// # } + /// # foo().unwrap(); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -74,7 +74,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of [`empty()`][`empty`] for more details. + /// + /// [`empty`]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -94,10 +93,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -107,7 +104,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -115,7 +113,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -128,7 +125,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -145,10 +141,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -164,7 +158,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -177,7 +170,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -194,10 +186,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -205,7 +195,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/e9d70417cae7fcb08323351d9388b65b39560156.patch b/patches/e9d70417cae7fcb08323351d9388b65b39560156.patch new file mode 100644 index 0000000..965e706 --- /dev/null +++ b/patches/e9d70417cae7fcb08323351d9388b65b39560156.patch @@ -0,0 +1,1665 @@ +diff --git a/buffered.rs b/buffered.rs +index 4e7db5f..d956165 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Returns `true` if there are no bytes in the internal buffer. +@@ -167,7 +162,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "bufreader_is_empty", issue = "45323", reason = "recently added")] + pub fn is_empty(&self) -> bool { + self.pos == self.cap + } +@@ -190,7 +184,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +@@ -199,7 +192,6 @@ impl BufReader { + /// the buffer will not be flushed, allowing for more efficient seeks. + /// This method does not return the location of the underlying reader, so the caller + /// must track this information themselves if it is required. +- #[unstable(feature = "bufreader_seek_relative", issue = "31100")] + pub fn seek_relative(&mut self, offset: i64) -> io::Result<()> { + let pos = self.pos as u64; + if offset < 0 { +@@ -219,7 +211,6 @@ impl BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -242,7 +233,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -262,7 +252,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -272,7 +261,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -374,7 +362,6 @@ impl Seek for BufReader { + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html + /// [`flush`]: #method.flush +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -409,7 +396,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -423,7 +409,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -441,7 +426,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -490,7 +474,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -508,7 +491,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -530,7 +512,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -539,7 +520,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -559,7 +539,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -569,7 +548,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -579,7 +557,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -618,7 +595,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -651,23 +627,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -725,7 +691,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -746,7 +711,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -767,7 +731,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -791,7 +754,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -814,7 +776,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -840,7 +801,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -851,7 +811,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -896,7 +855,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index c844770..dcc64c6 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,17 +215,16 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } + + fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> { + let n = buf.len(); +- Read::read_exact(&mut self.fill_buf()?, buf)?; ++ Read::read_exact(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(()) + } +@@ -243,12 +235,16 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +@@ -261,6 +257,7 @@ fn slice_write(pos_mut: &mut u64, slice: &mut [u8], buf: &[u8]) -> io::Result, buf: &[u8]) -> io::Result { + let pos: usize = (*pos_mut).try_into().map_err(|_| { + Error::new(ErrorKind::InvalidInput, +@@ -287,7 +284,6 @@ fn vec_write(pos_mut: &mut u64, vec: &mut Vec, buf: &[u8]) -> io::Result Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +@@ -296,7 +292,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[unstable(feature = "cursor_mut_vec", issue = "30132")] ++#[cfg(feature="collections")] + impl<'a> Write for Cursor<&'a mut Vec> { + fn write(&mut self, buf: &[u8]) -> io::Result { + vec_write(&mut self.pos, self.inner, buf) +@@ -304,7 +300,7 @@ impl<'a> Write for Cursor<&'a mut Vec> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + vec_write(&mut self.pos, &mut self.inner, buf) +@@ -312,8 +308,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + slice_write(&mut self.pos, &mut self.inner, buf) +diff --git a/error.rs b/error.rs +index bdd675e..3acdadf 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -48,7 +53,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and +@@ -62,12 +66,10 @@ pub type Result = result::Result; + /// [`Write`]: ../io/trait.Write.html + /// [`Seek`]: ../io/trait.Seek.html + /// [`ErrorKind`]: enum.ErrorKind.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Debug::fmt(&self.repr, f) +@@ -77,13 +79,16 @@ impl fmt::Debug for Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -95,47 +100,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -147,10 +139,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -161,15 +151,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -178,15 +165,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -219,7 +201,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -248,14 +229,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind, +@@ -264,24 +244,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -307,7 +269,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::InvalidInput); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -338,7 +299,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -372,12 +332,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -443,12 +402,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -477,8 +435,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -504,10 +461,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -519,22 +475,18 @@ impl fmt::Debug for Repr { + match *self { + Repr::Os(code) => + fmt.debug_struct("Os") +- .field("code", &code) +- .field("kind", &sys::decode_error_kind(code)) +- .field("message", &sys::os::error_string(code)).finish(), ++ .field("code", &code).finish(), + Repr::Custom(ref c) => fmt::Debug::fmt(&c, fmt), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -542,24 +494,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index fe1179a..452b8b7 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -207,6 +211,7 @@ impl<'a> Read for &'a [u8] { + Ok(()) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + buf.extend_from_slice(*self); +@@ -216,7 +221,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -230,7 +235,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -256,7 +260,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/mod.rs b/mod.rs +index 33d11eb..569daa2 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -268,50 +268,38 @@ + //! [`Result`]: ../result/enum.Result.html + //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++#[cfg(not(core_memchr))] ++mod memchr; ++#[cfg(all(feature="collections",core_memchr))] ++use core::slice::memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -336,6 +324,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -363,6 +352,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -466,7 +456,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// [`BufReader`]: struct.BufReader.html + /// [`&str`]: ../../std/primitive.str.html + /// [slice]: ../../std/primitive.slice.html +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning +@@ -523,7 +512,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -548,7 +536,6 @@ pub trait Read { + /// + /// [`Initializer::nop()`]: ../../std/io/struct.Initializer.html#method.nop + /// [`Initializer`]: ../../std/io/struct.Initializer.html +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -596,7 +583,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -634,7 +621,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -697,7 +684,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -749,7 +735,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an [`Iterator`] over its bytes. +@@ -786,7 +771,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -827,10 +811,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -865,7 +845,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -901,20 +880,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -928,21 +904,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -985,7 +958,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. +@@ -1034,7 +1006,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1060,7 +1031,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1093,7 +1063,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1145,7 +1114,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1201,7 +1169,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1231,7 +1198,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1247,7 +1213,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1257,29 +1222,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1359,7 +1321,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1404,7 +1366,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1426,7 +1387,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1484,7 +1444,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1541,7 +1500,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1582,7 +1540,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1621,7 +1578,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1633,7 +1589,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1659,7 +1614,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1682,7 +1636,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1709,13 +1662,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1725,7 +1676,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1747,7 +1697,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1774,7 +1724,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1809,7 +1758,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Sets the number of bytes that can be read before this instance will +@@ -1836,7 +1784,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "take_set_limit", issue = "42781")] + pub fn set_limit(&mut self, limit: u64) { + self.limit = limit; + } +@@ -1861,7 +1808,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1886,7 +1832,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1915,13 +1860,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1940,7 +1883,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1979,13 +1922,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -2000,8 +1941,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -2010,8 +1949,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -2021,8 +1958,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -2053,25 +1988,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2090,14 +2006,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2122,13 +2038,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 45d281e..0efc3b1 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -45,7 +46,6 @@ use mem; + /// # } + /// # foo().unwrap(); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -74,7 +74,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of [`empty()`][`empty`] for more details. + /// + /// [`empty`]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -94,10 +93,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -107,7 +104,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -115,7 +113,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -128,7 +125,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -145,10 +141,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -164,7 +158,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -177,7 +170,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -194,10 +186,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -205,7 +195,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/ecbb896b9eb2acadefde57be493e4298c1aa04a3.patch b/patches/ecbb896b9eb2acadefde57be493e4298c1aa04a3.patch new file mode 100644 index 0000000..5ad2a3d --- /dev/null +++ b/patches/ecbb896b9eb2acadefde57be493e4298c1aa04a3.patch @@ -0,0 +1,1610 @@ +diff --git a/buffered.rs b/buffered.rs +index 296ee78..4262dc5 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Unwraps this `BufReader`, returning the underlying reader. +@@ -165,11 +160,9 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -192,7 +185,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -212,7 +204,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -222,7 +213,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -316,7 +306,6 @@ impl Seek for BufReader { + /// [`Write`]: ../../std/io/trait.Write.html + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -351,7 +340,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -365,7 +353,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -383,7 +370,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -432,7 +418,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -450,7 +435,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -468,7 +452,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -477,7 +460,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -497,7 +479,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -507,7 +488,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -517,7 +497,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -556,7 +535,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -589,23 +567,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -660,7 +628,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -681,7 +648,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -702,7 +668,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -726,7 +691,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -749,7 +713,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -771,7 +734,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -782,7 +744,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -827,7 +788,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index 616b4f4..97d1076 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,10 +215,9 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } +@@ -236,16 +228,19 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -257,7 +252,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos: usize = self.position().try_into().map_err(|_| { +@@ -287,8 +282,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos = cmp::min(self.pos, self.inner.len() as u64); +diff --git a/error.rs b/error.rs +index 0a5804a..4564ca7 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -44,7 +49,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the `Read`, `Write`, `Seek`, and +@@ -56,7 +60,6 @@ pub type Result = result::Result; + /// + /// [`ErrorKind`]: enum.ErrorKind.html + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } +@@ -64,13 +67,16 @@ pub struct Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -82,47 +88,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -134,10 +127,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -148,15 +139,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -165,15 +153,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -206,7 +189,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -235,14 +217,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind: kind, +@@ -251,24 +232,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -294,7 +257,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -325,7 +287,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -359,12 +320,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -430,12 +390,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -464,8 +423,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -491,10 +449,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -505,21 +462,18 @@ impl fmt::Debug for Repr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Repr::Os(ref code) => +- fmt.debug_struct("Os").field("code", code) +- .field("message", &sys::os::error_string(*code)).finish(), ++ fmt.debug_struct("Os").field("code", code).finish(), + Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -527,24 +481,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index d6b41ce..1ddabf1 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -208,7 +212,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -222,7 +226,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -248,7 +251,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/memchr.rs b/memchr.rs +index 3824a5f..312cf47 100644 +--- a/memchr.rs ++++ b/memchr.rs +@@ -11,10 +11,12 @@ + // Original implementation taken from rust-memchr + // Copyright 2015 Andrew Gallant, bluss and Nicolas Koch + ++pub use self::fallback::{memchr,memrchr}; ++ + #[allow(dead_code)] + pub mod fallback { +- use cmp; +- use mem; ++ use core::cmp; ++ use core::mem; + + const LO_U64: u64 = 0x0101010101010101; + const HI_U64: u64 = 0x8080808080808080; +diff --git a/mod.rs b/mod.rs +index 680a5f3..1531824 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -266,50 +266,35 @@ + //! [`?` operator]: ../../book/first-edition/syntax-index.html + //! [`Read::read`]: trait.Read.html#tymethod.read + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++mod memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -334,6 +319,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -361,6 +347,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -446,7 +433,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning + /// how many bytes were read. +@@ -499,7 +485,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -521,7 +506,6 @@ pub trait Read { + /// This method is unsafe because a `Read`er could otherwise return a + /// non-zeroing `Initializer` from another `Read` type without an `unsafe` + /// block. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -566,7 +550,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -604,7 +588,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -665,7 +649,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -717,7 +700,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an `Iterator` over its bytes. +@@ -747,7 +729,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -784,10 +765,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -822,7 +799,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -856,20 +832,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -883,21 +856,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -940,7 +910,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. + /// +@@ -984,7 +953,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1010,7 +978,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1040,7 +1007,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1092,7 +1058,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1148,7 +1113,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1178,7 +1142,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1194,7 +1157,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1204,29 +1166,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1306,7 +1265,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1351,7 +1310,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1373,7 +1331,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1429,7 +1386,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1484,7 +1440,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1525,7 +1480,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1564,7 +1518,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1576,7 +1529,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1604,7 +1556,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "more_io_inner_methods", issue="41519")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1629,7 +1580,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "more_io_inner_methods", issue="41519")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1658,13 +1608,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "more_io_inner_methods", issue="41519")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1674,7 +1622,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1696,7 +1643,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1723,7 +1670,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1758,7 +1704,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Consumes the `Take`, returning the wrapped reader. +@@ -1781,7 +1726,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1808,7 +1752,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "more_io_inner_methods", issue="41519")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1839,13 +1782,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "more_io_inner_methods", issue="41519")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1864,7 +1805,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1903,13 +1844,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -1924,8 +1863,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -1934,8 +1871,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -1945,8 +1880,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -1978,25 +1911,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2015,14 +1929,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2047,13 +1961,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 88f4214..df974c3 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -44,7 +45,6 @@ use mem; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -73,7 +73,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of `empty()` for more details. + /// + /// [empty]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -91,10 +90,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -104,7 +101,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -112,7 +110,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -125,7 +122,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -142,10 +138,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -161,7 +155,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -174,7 +167,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -191,10 +183,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -202,7 +192,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/f0a968eada509f71971e3ece02f8ec91b6f79e8a.patch b/patches/f0a968eada509f71971e3ece02f8ec91b6f79e8a.patch new file mode 100644 index 0000000..193c6fb --- /dev/null +++ b/patches/f0a968eada509f71971e3ece02f8ec91b6f79e8a.patch @@ -0,0 +1,1665 @@ +diff --git a/buffered.rs b/buffered.rs +index 9250c1c..bf6383f 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Returns `true` if there are no bytes in the internal buffer. +@@ -167,7 +162,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "bufreader_is_empty", issue = "45323", reason = "recently added")] + pub fn is_empty(&self) -> bool { + self.pos == self.cap + } +@@ -190,7 +184,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +@@ -199,7 +192,6 @@ impl BufReader { + /// the buffer will not be flushed, allowing for more efficient seeks. + /// This method does not return the location of the underlying reader, so the caller + /// must track this information themselves if it is required. +- #[unstable(feature = "bufreader_seek_relative", issue = "31100")] + pub fn seek_relative(&mut self, offset: i64) -> io::Result<()> { + let pos = self.pos as u64; + if offset < 0 { +@@ -219,7 +211,6 @@ impl BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -242,7 +233,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -262,7 +252,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -272,7 +261,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -374,7 +362,6 @@ impl Seek for BufReader { + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html + /// [`flush`]: #method.flush +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -409,7 +396,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -423,7 +409,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -441,7 +426,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -490,7 +474,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -508,7 +491,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -530,7 +512,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -539,7 +520,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -559,7 +539,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -569,7 +548,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -579,7 +557,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -618,7 +595,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -651,23 +627,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -725,7 +691,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -746,7 +711,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -767,7 +731,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -791,7 +754,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -814,7 +776,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -840,7 +801,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -851,7 +811,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -896,7 +855,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index 76bcb5f..dcc64c6 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,17 +215,16 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } + + fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> { + let n = buf.len(); +- Read::read_exact(&mut self.fill_buf()?, buf)?; ++ Read::read_exact(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(()) + } +@@ -243,12 +235,16 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +@@ -261,6 +257,7 @@ fn slice_write(pos_mut: &mut u64, slice: &mut [u8], buf: &[u8]) -> io::Result, buf: &[u8]) -> io::Result { + let pos: usize = (*pos_mut).try_into().map_err(|_| { + Error::new(ErrorKind::InvalidInput, +@@ -287,7 +284,6 @@ fn vec_write(pos_mut: &mut u64, vec: &mut Vec, buf: &[u8]) -> io::Result Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +@@ -296,7 +292,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_mut_vec", since = "1.25.0")] ++#[cfg(feature="collections")] + impl<'a> Write for Cursor<&'a mut Vec> { + fn write(&mut self, buf: &[u8]) -> io::Result { + vec_write(&mut self.pos, self.inner, buf) +@@ -304,7 +300,7 @@ impl<'a> Write for Cursor<&'a mut Vec> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + vec_write(&mut self.pos, &mut self.inner, buf) +@@ -312,8 +308,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + slice_write(&mut self.pos, &mut self.inner, buf) +diff --git a/error.rs b/error.rs +index bdd675e..3acdadf 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -48,7 +53,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and +@@ -62,12 +66,10 @@ pub type Result = result::Result; + /// [`Write`]: ../io/trait.Write.html + /// [`Seek`]: ../io/trait.Seek.html + /// [`ErrorKind`]: enum.ErrorKind.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Debug::fmt(&self.repr, f) +@@ -77,13 +79,16 @@ impl fmt::Debug for Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -95,47 +100,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -147,10 +139,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -161,15 +151,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -178,15 +165,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -219,7 +201,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -248,14 +229,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind, +@@ -264,24 +244,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -307,7 +269,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::InvalidInput); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -338,7 +299,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -372,12 +332,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -443,12 +402,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -477,8 +435,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -504,10 +461,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -519,22 +475,18 @@ impl fmt::Debug for Repr { + match *self { + Repr::Os(code) => + fmt.debug_struct("Os") +- .field("code", &code) +- .field("kind", &sys::decode_error_kind(code)) +- .field("message", &sys::os::error_string(code)).finish(), ++ .field("code", &code).finish(), + Repr::Custom(ref c) => fmt::Debug::fmt(&c, fmt), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -542,24 +494,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index fe1179a..452b8b7 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -207,6 +211,7 @@ impl<'a> Read for &'a [u8] { + Ok(()) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + buf.extend_from_slice(*self); +@@ -216,7 +221,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -230,7 +235,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -256,7 +260,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/mod.rs b/mod.rs +index d403bf6..c6c236e 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -268,50 +268,38 @@ + //! [`Result`]: ../result/enum.Result.html + //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++#[cfg(not(core_memchr))] ++mod memchr; ++#[cfg(all(feature="collections",core_memchr))] ++use core::slice::memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -336,6 +324,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -363,6 +352,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -466,7 +456,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// [`BufReader`]: struct.BufReader.html + /// [`&str`]: ../../std/primitive.str.html + /// [slice]: ../../std/primitive.slice.html +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning +@@ -523,7 +512,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -548,7 +536,6 @@ pub trait Read { + /// + /// [`Initializer::nop()`]: ../../std/io/struct.Initializer.html#method.nop + /// [`Initializer`]: ../../std/io/struct.Initializer.html +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -596,7 +583,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -634,7 +621,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -697,7 +684,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -749,7 +735,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an [`Iterator`] over its bytes. +@@ -786,7 +771,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -827,10 +811,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -865,7 +845,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -901,20 +880,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -928,21 +904,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -985,7 +958,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. +@@ -1034,7 +1006,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1060,7 +1031,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1093,7 +1063,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1145,7 +1114,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1201,7 +1169,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1231,7 +1198,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1247,7 +1213,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1257,29 +1222,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1359,7 +1321,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1404,7 +1366,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1426,7 +1387,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1482,7 +1442,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1541,7 +1500,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1582,7 +1540,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1621,7 +1578,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1633,7 +1589,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1659,7 +1614,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1682,7 +1636,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1709,13 +1662,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1725,7 +1676,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1747,7 +1697,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1774,7 +1724,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1809,7 +1758,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Sets the number of bytes that can be read before this instance will +@@ -1836,7 +1784,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "take_set_limit", issue = "42781")] + pub fn set_limit(&mut self, limit: u64) { + self.limit = limit; + } +@@ -1861,7 +1808,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1886,7 +1832,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1915,13 +1860,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1940,7 +1883,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1979,13 +1922,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -2000,8 +1941,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -2010,8 +1949,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -2021,8 +1958,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -2053,25 +1988,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2090,14 +2006,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2122,13 +2038,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 45d281e..0efc3b1 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -45,7 +46,6 @@ use mem; + /// # } + /// # foo().unwrap(); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -74,7 +74,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of [`empty()`][`empty`] for more details. + /// + /// [`empty`]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -94,10 +93,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -107,7 +104,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -115,7 +113,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -128,7 +125,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -145,10 +141,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -164,7 +158,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -177,7 +170,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -194,10 +186,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -205,7 +195,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/f3ef077b910c9dada20eb106e8469ec071c27dad.patch b/patches/f3ef077b910c9dada20eb106e8469ec071c27dad.patch new file mode 100644 index 0000000..6194cf3 --- /dev/null +++ b/patches/f3ef077b910c9dada20eb106e8469ec071c27dad.patch @@ -0,0 +1,1626 @@ +diff --git a/buffered.rs b/buffered.rs +index 7001d8e..8e5daa4 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Returns `true` if there are no bytes in the internal buffer. +@@ -167,7 +162,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "bufreader_is_empty", issue = "45323", reason = "recently added")] + pub fn is_empty(&self) -> bool { + self.pos == self.cap + } +@@ -190,11 +184,9 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -217,7 +209,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -237,7 +228,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -247,7 +237,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -345,7 +334,6 @@ impl Seek for BufReader { + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html + /// [`flush`]: #method.flush +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -380,7 +368,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -394,7 +381,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -412,7 +398,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -461,7 +446,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -479,7 +463,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -501,7 +484,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -510,7 +492,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -530,7 +511,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -540,7 +520,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -550,7 +529,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -589,7 +567,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -622,23 +599,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -696,7 +663,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -717,7 +683,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -738,7 +703,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -762,7 +726,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -785,7 +748,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -811,7 +773,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -822,7 +783,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -867,7 +827,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index b5ea553..b31cfa3 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,17 +215,16 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } + + fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> { + let n = buf.len(); +- Read::read_exact(&mut self.fill_buf()?, buf)?; ++ Read::read_exact(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(()) + } +@@ -243,16 +235,19 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -264,7 +259,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos: usize = self.position().try_into().map_err(|_| { +@@ -294,8 +289,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos = cmp::min(self.pos, self.inner.len() as u64); +diff --git a/error.rs b/error.rs +index bb9383d..01ddea6 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -48,7 +53,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and +@@ -63,7 +67,6 @@ pub type Result = result::Result; + /// [`Seek`]: ../io/trait.Seek.html + /// [`ErrorKind`]: enum.ErrorKind.html + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } +@@ -71,13 +74,16 @@ pub struct Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -89,47 +95,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -141,10 +134,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -155,15 +146,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -172,15 +160,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -213,7 +196,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -242,14 +224,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind, +@@ -258,24 +239,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -301,7 +264,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -332,7 +294,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -366,12 +327,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -437,12 +397,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -471,8 +430,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -498,10 +456,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -512,21 +469,18 @@ impl fmt::Debug for Repr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Repr::Os(ref code) => +- fmt.debug_struct("Os").field("code", code) +- .field("message", &sys::os::error_string(*code)).finish(), ++ fmt.debug_struct("Os").field("code", code).finish(), + Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -534,24 +488,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index fe1179a..452b8b7 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -207,6 +211,7 @@ impl<'a> Read for &'a [u8] { + Ok(()) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + buf.extend_from_slice(*self); +@@ -216,7 +221,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -230,7 +235,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -256,7 +260,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/mod.rs b/mod.rs +index e9b707c..f98ebae 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -268,50 +268,38 @@ + //! [`Result`]: ../result/enum.Result.html + //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++#[cfg(not(core_memchr))] ++mod memchr; ++#[cfg(all(feature="collections",core_memchr))] ++use core::slice::memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -336,6 +324,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -363,6 +352,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -466,7 +456,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// [`BufReader`]: struct.BufReader.html + /// [`&str`]: ../../std/primitive.str.html + /// [slice]: ../../std/primitive.slice.html +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning +@@ -523,7 +512,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -548,7 +536,6 @@ pub trait Read { + /// + /// [`Initializer::nop()`]: ../../std/io/struct.Initializer.html#method.nop + /// [`Initializer`]: ../../std/io/struct.Initializer.html +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -596,7 +583,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -634,7 +621,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -697,7 +684,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -749,7 +735,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an [`Iterator`] over its bytes. +@@ -786,7 +771,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -827,10 +811,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -865,7 +845,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -901,20 +880,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -928,21 +904,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -985,7 +958,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[doc(spotlight)] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. +@@ -1030,7 +1002,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1056,7 +1027,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1086,7 +1056,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1138,7 +1107,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1194,7 +1162,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1224,7 +1191,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1240,7 +1206,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1250,29 +1215,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1352,7 +1314,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1397,7 +1359,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1419,7 +1380,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1477,7 +1437,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1534,7 +1493,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1575,7 +1533,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1614,7 +1571,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1626,7 +1582,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1652,7 +1607,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1675,7 +1629,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1702,13 +1655,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1718,7 +1669,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1740,7 +1690,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1767,7 +1717,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1802,7 +1751,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Sets the number of bytes that can be read before this instance will +@@ -1829,7 +1777,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "take_set_limit", issue = "42781")] + pub fn set_limit(&mut self, limit: u64) { + self.limit = limit; + } +@@ -1854,7 +1801,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1879,7 +1825,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1908,13 +1853,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1933,7 +1876,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1972,13 +1915,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -1993,8 +1934,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -2003,8 +1942,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -2014,8 +1951,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -2046,25 +1981,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2083,14 +1999,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2115,13 +2031,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 45d281e..0efc3b1 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -45,7 +46,6 @@ use mem; + /// # } + /// # foo().unwrap(); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -74,7 +74,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of [`empty()`][`empty`] for more details. + /// + /// [`empty`]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -94,10 +93,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -107,7 +104,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -115,7 +113,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -128,7 +125,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -145,10 +141,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -164,7 +158,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -177,7 +170,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -194,10 +186,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -205,7 +195,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/f5f74a22c94a7053d33c88d135f9fdc44fa2ea5b.patch b/patches/f5f74a22c94a7053d33c88d135f9fdc44fa2ea5b.patch new file mode 100644 index 0000000..23e0656 --- /dev/null +++ b/patches/f5f74a22c94a7053d33c88d135f9fdc44fa2ea5b.patch @@ -0,0 +1,1551 @@ +diff --git a/buffered.rs b/buffered.rs +index 3b82412..0566d0f 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + BufReader { + inner: inner, +@@ -118,7 +115,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -139,7 +135,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Unwraps this `BufReader`, returning the underlying reader. +@@ -160,11 +155,9 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -182,7 +175,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -202,7 +194,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -212,7 +203,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -306,7 +296,6 @@ impl Seek for BufReader { + /// [`Write`]: ../../std/io/trait.Write.html + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -341,7 +330,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -355,7 +343,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -373,7 +360,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -422,7 +408,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -440,7 +425,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -458,7 +442,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -467,7 +450,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -487,7 +469,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -497,7 +478,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -507,7 +487,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -546,7 +525,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -579,23 +557,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -650,7 +618,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -671,7 +638,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -692,7 +658,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -716,7 +681,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -739,7 +703,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -761,7 +724,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -772,7 +734,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -817,7 +778,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index 53347eb..637f4e0 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,25 +215,27 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature = "collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -252,7 +247,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos: usize = self.position().try_into().map_err(|_| { +@@ -282,8 +277,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos = cmp::min(self.pos, self.inner.len() as u64); +diff --git a/error.rs b/error.rs +index 0a5804a..4564ca7 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -44,7 +49,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the `Read`, `Write`, `Seek`, and +@@ -56,7 +60,6 @@ pub type Result = result::Result; + /// + /// [`ErrorKind`]: enum.ErrorKind.html + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } +@@ -64,13 +67,16 @@ pub struct Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -82,47 +88,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -134,10 +127,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -148,15 +139,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -165,15 +153,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -206,7 +189,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -235,14 +217,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind: kind, +@@ -251,24 +232,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -294,7 +257,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -325,7 +287,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -359,12 +320,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -430,12 +390,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -464,8 +423,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -491,10 +449,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -505,21 +462,18 @@ impl fmt::Debug for Repr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Repr::Os(ref code) => +- fmt.debug_struct("Os").field("code", code) +- .field("message", &sys::os::error_string(*code)).finish(), ++ fmt.debug_struct("Os").field("code", code).finish(), + Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -527,24 +481,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index f691289..c4374d3 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,26 +8,31 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { + (**self).read(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -38,7 +43,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -56,12 +60,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -80,18 +83,20 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { + (**self).read(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -102,7 +107,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -120,12 +125,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -151,7 +156,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -193,7 +197,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -207,7 +211,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -233,7 +236,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/memchr.rs b/memchr.rs +index 3824a5f..312cf47 100644 +--- a/memchr.rs ++++ b/memchr.rs +@@ -11,10 +11,12 @@ + // Original implementation taken from rust-memchr + // Copyright 2015 Andrew Gallant, bluss and Nicolas Koch + ++pub use self::fallback::{memchr,memrchr}; ++ + #[allow(dead_code)] + pub mod fallback { +- use cmp; +- use mem; ++ use core::cmp; ++ use core::mem; + + const LO_U64: u64 = 0x0101010101010101; + const HI_U64: u64 = 0x8080808080808080; +diff --git a/mod.rs b/mod.rs +index 3f859c4..178783b 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -266,46 +266,34 @@ + //! [`?` operator]: ../../book/first-edition/syntax-index.html + //! [`Read::read`]: trait.Read.html#tymethod.read + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::iter::{Iterator}; ++use core::marker::Sized; ++#[cfg(feature="collections")] use core::ops::{Drop, FnOnce}; ++use core::option::Option::{self, Some, None}; ++use core::result::Result::{Ok, Err}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++mod memchr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "0")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + + // A few methods below (read_to_string, read_line) will append data into a + // `String` buffer, but we need to be pretty careful when doing this. The +@@ -325,6 +313,7 @@ const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -356,6 +345,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // of data to return. Simply tacking on an extra DEFAULT_BUF_SIZE space every + // time is 4,500 times (!) slower than this if the reader has a very small + // amount of data to return. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut len = start_len; +@@ -438,7 +428,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning + /// how many bytes were read. +@@ -491,7 +480,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Read all bytes until EOF in this source, placing them into `buf`. +@@ -533,7 +521,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -571,7 +559,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -632,7 +620,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -684,7 +671,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an `Iterator` over its bytes. +@@ -714,7 +700,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -751,10 +736,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -789,7 +770,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -823,7 +803,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } +@@ -863,7 +842,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. + /// +@@ -907,7 +885,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -933,7 +910,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -963,7 +939,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1015,7 +990,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1071,7 +1045,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1101,7 +1074,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1117,7 +1089,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1127,29 +1098,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1229,7 +1197,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1274,7 +1242,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1296,7 +1263,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1352,7 +1318,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1407,7 +1372,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1448,7 +1412,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1487,7 +1450,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1499,7 +1461,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1527,7 +1488,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "more_io_inner_methods", issue="41519")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1552,7 +1512,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "more_io_inner_methods", issue="41519")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1581,13 +1540,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "more_io_inner_methods", issue="41519")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1597,7 +1554,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1610,7 +1566,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1637,7 +1593,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1672,7 +1627,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Consumes the `Take`, returning the wrapped reader. +@@ -1695,7 +1649,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1722,7 +1675,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "more_io_inner_methods", issue="41519")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1753,13 +1705,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "more_io_inner_methods", issue="41519")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1774,7 +1724,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1813,13 +1763,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -1834,8 +1782,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -1844,8 +1790,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -1855,8 +1799,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -1888,25 +1830,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -1925,14 +1848,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -1957,13 +1880,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index 078f1ad..fd13c98 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,8 +10,9 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Write, ErrorKind, BufRead}; ++use core::fmt; ++use io::{self, Read, Write, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -43,7 +44,6 @@ use io::{self, Read, Write, ErrorKind, BufRead}; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -67,7 +67,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of `empty()` for more details. + /// + /// [empty]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -85,20 +84,18 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -111,7 +108,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -128,10 +124,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + for slot in &mut *buf { +@@ -141,7 +135,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -154,7 +147,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -171,16 +163,13 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/patches/ff457f012aef26f82c42c73783d7d3810d04d624.patch b/patches/ff457f012aef26f82c42c73783d7d3810d04d624.patch new file mode 100644 index 0000000..0e836f7 --- /dev/null +++ b/patches/ff457f012aef26f82c42c73783d7d3810d04d624.patch @@ -0,0 +1,1618 @@ +diff --git a/buffered.rs b/buffered.rs +index 4ebd355..242aab4 100644 +--- a/buffered.rs ++++ b/buffered.rs +@@ -10,13 +10,13 @@ + + //! Buffering wrappers for I/O traits + ++use core::prelude::v1::*; + use io::prelude::*; + +-use cmp; +-use error; +-use fmt; ++use core::cmp; ++use core::fmt; + use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; +-use memchr; ++use io::memchr; + + /// The `BufReader` struct adds buffering to any reader. + /// +@@ -46,7 +46,6 @@ use memchr; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufReader { + inner: R, + buf: Box<[u8]>, +@@ -69,7 +68,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: R) -> BufReader { + BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -90,7 +88,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: R) -> BufReader { + unsafe { + let mut buffer = Vec::with_capacity(cap); +@@ -123,7 +120,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &R { &self.inner } + + /// Gets a mutable reference to the underlying reader. +@@ -144,7 +140,6 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut R { &mut self.inner } + + /// Unwraps this `BufReader`, returning the underlying reader. +@@ -165,11 +160,9 @@ impl BufReader { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> R { self.inner } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for BufReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + // If we don't have any buffered data and we're doing a massive read +@@ -192,7 +185,6 @@ impl Read for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl BufRead for BufReader { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + // If we've reached the end of our internal buffer then we need to fetch +@@ -212,7 +204,6 @@ impl BufRead for BufReader { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufReader where R: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufReader") +@@ -222,7 +213,6 @@ impl fmt::Debug for BufReader where R: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufReader { + /// Seek to an offset, in bytes, in the underlying reader. + /// +@@ -320,7 +310,6 @@ impl Seek for BufReader { + /// [`Tcpstream::write`]: ../../std/net/struct.TcpStream.html#method.write + /// [`TcpStream`]: ../../std/net/struct.TcpStream.html + /// [`flush`]: #method.flush +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct BufWriter { + inner: Option, + buf: Vec, +@@ -355,7 +344,6 @@ pub struct BufWriter { + /// }; + /// ``` + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct IntoInnerError(W, Error); + + impl BufWriter { +@@ -369,7 +357,6 @@ impl BufWriter { + /// + /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> BufWriter { + BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) + } +@@ -387,7 +374,6 @@ impl BufWriter { + /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// let mut buffer = BufWriter::with_capacity(100, stream); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> BufWriter { + BufWriter { + inner: Some(inner), +@@ -436,7 +422,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.as_ref().unwrap() } + + /// Gets a mutable reference to the underlying writer. +@@ -454,7 +439,6 @@ impl BufWriter { + /// // we can use reference just like buffer + /// let reference = buffer.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.as_mut().unwrap() } + + /// Unwraps this `BufWriter`, returning the underlying writer. +@@ -472,7 +456,6 @@ impl BufWriter { + /// // unwrap the TcpStream and flush the buffer + /// let stream = buffer.into_inner().unwrap(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(mut self) -> Result>> { + match self.flush_buf() { + Err(e) => Err(IntoInnerError(self, e)), +@@ -481,7 +464,6 @@ impl BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for BufWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.buf.len() + buf.len() > self.buf.capacity() { +@@ -501,7 +483,6 @@ impl Write for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for BufWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BufWriter") +@@ -511,7 +492,6 @@ impl fmt::Debug for BufWriter where W: fmt::Debug { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Seek for BufWriter { + /// Seek to the offset, in bytes, in the underlying writer. + /// +@@ -521,7 +501,6 @@ impl Seek for BufWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Drop for BufWriter { + fn drop(&mut self) { + if self.inner.is_some() && !self.panicked { +@@ -560,7 +539,6 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { &self.1 } + + /// Returns the buffered writer instance which generated the error. +@@ -593,23 +571,13 @@ impl IntoInnerError { + /// } + /// }; + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { self.0 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl From> for Error { + fn from(iie: IntoInnerError) -> Error { iie.1 } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for IntoInnerError { +- fn description(&self) -> &str { +- error::Error::description(self.error()) +- } +-} +- +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.error().fmt(f) +@@ -664,7 +632,6 @@ impl fmt::Display for IntoInnerError { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct LineWriter { + inner: BufWriter, + need_flush: bool, +@@ -685,7 +652,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: W) -> LineWriter { + // Lines typically aren't that long, don't use a giant buffer + LineWriter::with_capacity(1024, inner) +@@ -706,7 +672,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn with_capacity(cap: usize, inner: W) -> LineWriter { + LineWriter { + inner: BufWriter::with_capacity(cap, inner), +@@ -730,7 +695,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &W { self.inner.get_ref() } + + /// Gets a mutable reference to the underlying writer. +@@ -753,7 +717,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut W { self.inner.get_mut() } + + /// Unwraps this `LineWriter`, returning the underlying writer. +@@ -775,7 +738,6 @@ impl LineWriter { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> Result>> { + self.inner.into_inner().map_err(|IntoInnerError(buf, e)| { + IntoInnerError(LineWriter { +@@ -786,7 +748,6 @@ impl LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for LineWriter { + fn write(&mut self, buf: &[u8]) -> io::Result { + if self.need_flush { +@@ -831,7 +792,6 @@ impl Write for LineWriter { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Debug for LineWriter where W: fmt::Debug { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("LineWriter") +diff --git a/cursor.rs b/cursor.rs +index 32a9214..21ed409 100644 +--- a/cursor.rs ++++ b/cursor.rs +@@ -8,10 +8,11 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + ++use core::prelude::v1::*; + use io::prelude::*; + +-use core::convert::TryInto; +-use cmp; ++#[cfg(feature = "collections")] use core::convert::TryInto; ++use core::cmp; + use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + + /// A `Cursor` wraps another type and provides it with a +@@ -79,7 +80,6 @@ use io::{self, Initializer, SeekFrom, Error, ErrorKind}; + /// assert_eq!(&buff.get_ref()[5..15], &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Clone, Debug)] + pub struct Cursor { + inner: T, +@@ -102,7 +102,6 @@ impl Cursor { + /// # fn force_inference(_: &Cursor>) {} + /// # force_inference(&buff); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(inner: T) -> Cursor { + Cursor { pos: 0, inner: inner } + } +@@ -120,7 +119,6 @@ impl Cursor { + /// + /// let vec = buff.into_inner(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> T { self.inner } + + /// Gets a reference to the underlying value in this cursor. +@@ -136,7 +134,6 @@ impl Cursor { + /// + /// let reference = buff.get_ref(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_ref(&self) -> &T { &self.inner } + + /// Gets a mutable reference to the underlying value in this cursor. +@@ -155,7 +152,6 @@ impl Cursor { + /// + /// let reference = buff.get_mut(); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn get_mut(&mut self) -> &mut T { &mut self.inner } + + /// Returns the current position of this cursor. +@@ -177,7 +173,6 @@ impl Cursor { + /// buff.seek(SeekFrom::Current(-1)).unwrap(); + /// assert_eq!(buff.position(), 1); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn position(&self) -> u64 { self.pos } + + /// Sets the position of this cursor. +@@ -197,11 +192,9 @@ impl Cursor { + /// buff.set_position(4); + /// assert_eq!(buff.position(), 4); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn set_position(&mut self, pos: u64) { self.pos = pos; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl io::Seek for Cursor where T: AsRef<[u8]> { + fn seek(&mut self, style: SeekFrom) -> io::Result { + let (base_pos, offset) = match style { +@@ -222,10 +215,9 @@ impl io::Seek for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Cursor where T: AsRef<[u8]> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { +- let n = Read::read(&mut self.fill_buf()?, buf)?; ++ let n = Read::read(&mut self.get_buf()?, buf)?; + self.pos += n as u64; + Ok(n) + } +@@ -236,16 +228,19 @@ impl Read for Cursor where T: AsRef<[u8]> { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl BufRead for Cursor where T: AsRef<[u8]> { +- fn fill_buf(&mut self) -> io::Result<&[u8]> { ++impl Cursor where T: AsRef<[u8]> { ++ fn get_buf(&mut self) -> io::Result<&[u8]> { + let amt = cmp::min(self.pos, self.inner.as_ref().len() as u64); + Ok(&self.inner.as_ref()[(amt as usize)..]) + } ++} ++ ++#[cfg(feature="collections")] ++impl BufRead for Cursor where T: AsRef<[u8]> { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { self.get_buf() } + fn consume(&mut self, amt: usize) { self.pos += amt as u64; } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for Cursor<&'a mut [u8]> { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -257,7 +252,7 @@ impl<'a> Write for Cursor<&'a mut [u8]> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature = "collections")] + impl Write for Cursor> { + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos: usize = self.position().try_into().map_err(|_| { +@@ -287,8 +282,8 @@ impl Write for Cursor> { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "cursor_box_slice", since = "1.5.0")] +-impl Write for Cursor> { ++#[cfg(feature = "alloc")] ++impl Write for Cursor<::alloc::boxed::Box<[u8]>> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { + let pos = cmp::min(self.pos, self.inner.len() as u64); +diff --git a/error.rs b/error.rs +index bb9383d..01ddea6 100644 +--- a/error.rs ++++ b/error.rs +@@ -8,11 +8,16 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use error; +-use fmt; +-use result; +-use sys; +-use convert::From; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++#[cfg(not(feature="alloc"))] use ::FakeBox as Box; ++use core::convert::Into; ++use core::fmt; ++use core::marker::{Send, Sync}; ++use core::option::Option::{self, Some, None}; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(not(feature="collections"))] use ::ErrorString as String; ++use core::convert::From; + + /// A specialized [`Result`](../result/enum.Result.html) type for I/O + /// operations. +@@ -48,7 +53,6 @@ use convert::From; + /// Ok(buffer) + /// } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub type Result = result::Result; + + /// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and +@@ -63,7 +67,6 @@ pub type Result = result::Result; + /// [`Seek`]: ../io/trait.Seek.html + /// [`ErrorKind`]: enum.ErrorKind.html + #[derive(Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Error { + repr: Repr, + } +@@ -71,13 +74,16 @@ pub struct Error { + enum Repr { + Os(i32), + Simple(ErrorKind), ++ #[cfg(feature="alloc")] + Custom(Box), ++ #[cfg(not(feature="alloc"))] ++ Custom(Custom), + } + + #[derive(Debug)] + struct Custom { + kind: ErrorKind, +- error: Box, ++ error: String, + } + + /// A list specifying general categories of I/O error. +@@ -89,47 +95,34 @@ struct Custom { + /// + /// [`io::Error`]: struct.Error.html + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +-#[stable(feature = "rust1", since = "1.0.0")] + #[allow(deprecated)] + pub enum ErrorKind { + /// An entity was not found, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + NotFound, + /// The operation lacked the necessary privileges to complete. +- #[stable(feature = "rust1", since = "1.0.0")] + PermissionDenied, + /// The connection was refused by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionRefused, + /// The connection was reset by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionReset, + /// The connection was aborted (terminated) by the remote server. +- #[stable(feature = "rust1", since = "1.0.0")] + ConnectionAborted, + /// The network operation failed because it was not connected yet. +- #[stable(feature = "rust1", since = "1.0.0")] + NotConnected, + /// A socket address could not be bound because the address is already in + /// use elsewhere. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrInUse, + /// A nonexistent interface was requested or the requested address was not + /// local. +- #[stable(feature = "rust1", since = "1.0.0")] + AddrNotAvailable, + /// The operation failed because a pipe was closed. +- #[stable(feature = "rust1", since = "1.0.0")] + BrokenPipe, + /// An entity already exists, often a file. +- #[stable(feature = "rust1", since = "1.0.0")] + AlreadyExists, + /// The operation needs to block to complete, but the blocking operation was + /// requested to not occur. +- #[stable(feature = "rust1", since = "1.0.0")] + WouldBlock, + /// A parameter was incorrect. +- #[stable(feature = "rust1", since = "1.0.0")] + InvalidInput, + /// Data not valid for the operation were encountered. + /// +@@ -141,10 +134,8 @@ pub enum ErrorKind { + /// `InvalidData` if the file's contents are not valid UTF-8. + /// + /// [`InvalidInput`]: #variant.InvalidInput +- #[stable(feature = "io_invalid_data", since = "1.2.0")] + InvalidData, + /// The I/O operation's timeout expired, causing it to be canceled. +- #[stable(feature = "rust1", since = "1.0.0")] + TimedOut, + /// An error returned when an operation could not be completed because a + /// call to [`write`] returned [`Ok(0)`]. +@@ -155,15 +146,12 @@ pub enum ErrorKind { + /// + /// [`write`]: ../../std/io/trait.Write.html#tymethod.write + /// [`Ok(0)`]: ../../std/io/type.Result.html +- #[stable(feature = "rust1", since = "1.0.0")] + WriteZero, + /// This operation was interrupted. + /// + /// Interrupted operations can typically be retried. +- #[stable(feature = "rust1", since = "1.0.0")] + Interrupted, + /// Any I/O error not part of this list. +- #[stable(feature = "rust1", since = "1.0.0")] + Other, + + /// An error returned when an operation could not be completed because an +@@ -172,15 +160,10 @@ pub enum ErrorKind { + /// This typically means that an operation could only succeed if it read a + /// particular number of bytes but only a smaller number of bytes could be + /// read. +- #[stable(feature = "read_exact", since = "1.6.0")] + UnexpectedEof, + + /// A marker variant that tells the compiler that users of this enum cannot + /// match it exhaustively. +- #[unstable(feature = "io_error_internals", +- reason = "better expressed through extensible enums that this \ +- enum cannot be exhaustively matched against", +- issue = "0")] + #[doc(hidden)] + __Nonexhaustive, + } +@@ -213,7 +196,6 @@ impl ErrorKind { + + /// Intended for use for errors not exposed to the user, where allocating onto + /// the heap (for normal construction via Error::new) is too costly. +-#[stable(feature = "io_error_from_errorkind", since = "1.14.0")] + impl From for Error { + #[inline] + fn from(kind: ErrorKind) -> Error { +@@ -242,14 +224,13 @@ impl Error { + /// // errors can also be created from other errors + /// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn new(kind: ErrorKind, error: E) -> Error +- where E: Into> ++ where E: Into + { + Self::_new(kind, error.into()) + } + +- fn _new(kind: ErrorKind, error: Box) -> Error { ++ fn _new(kind: ErrorKind, error: String) -> Error { + Error { + repr: Repr::Custom(Box::new(Custom { + kind, +@@ -258,24 +239,6 @@ impl Error { + } + } + +- /// Returns an error representing the last OS error which occurred. +- /// +- /// This function reads the value of `errno` for the target platform (e.g. +- /// `GetLastError` on Windows) and will return a corresponding instance of +- /// `Error` for the error code. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::io::Error; +- /// +- /// println!("last OS error: {:?}", Error::last_os_error()); +- /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn last_os_error() -> Error { +- Error::from_raw_os_error(sys::os::errno() as i32) +- } +- + /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples +@@ -301,7 +264,6 @@ impl Error { + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn from_raw_os_error(code: i32) -> Error { + Error { repr: Repr::Os(code) } + } +@@ -332,7 +294,6 @@ impl Error { + /// print_os_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn raw_os_error(&self) -> Option { + match self.repr { + Repr::Os(i) => Some(i), +@@ -366,12 +327,11 @@ impl Error { + /// print_error(&Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> { ++ pub fn get_ref(&self) -> Option<&String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref c) => Some(&*c.error), ++ Repr::Custom(ref c) => Some(&c.error), + } + } + +@@ -437,12 +397,11 @@ impl Error { + /// print_error(&change_error(Error::new(ErrorKind::Other, MyError::new()))); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> { ++ pub fn get_mut(&mut self) -> Option<&mut String> { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +- Repr::Custom(ref mut c) => Some(&mut *c.error), ++ Repr::Custom(ref mut c) => Some(&mut c.error), + } + } + +@@ -471,8 +430,7 @@ impl Error { + /// print_error(Error::new(ErrorKind::Other, "oh no!")); + /// } + /// ``` +- #[stable(feature = "io_error_inner", since = "1.3.0")] +- pub fn into_inner(self) -> Option> { ++ pub fn into_inner(self) -> Option { + match self.repr { + Repr::Os(..) => None, + Repr::Simple(..) => None, +@@ -498,10 +456,9 @@ impl Error { + /// print_error(Error::new(ErrorKind::AddrInUse, "oh no!")); + /// } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn kind(&self) -> ErrorKind { + match self.repr { +- Repr::Os(code) => sys::decode_error_kind(code), ++ Repr::Os(_code) => ErrorKind::Other, + Repr::Custom(ref c) => c.kind, + Repr::Simple(kind) => kind, + } +@@ -512,21 +469,18 @@ impl fmt::Debug for Repr { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match *self { + Repr::Os(ref code) => +- fmt.debug_struct("Os").field("code", code) +- .field("message", &sys::os::error_string(*code)).finish(), ++ fmt.debug_struct("Os").field("code", code).finish(), + Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), + Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(), + } + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl fmt::Display for Error { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + match self.repr { + Repr::Os(code) => { +- let detail = sys::os::error_string(code); +- write!(fmt, "{} (os error {})", detail, code) ++ write!(fmt, "os error {}", code) + } + Repr::Custom(ref c) => c.error.fmt(fmt), + Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()), +@@ -534,24 +488,6 @@ impl fmt::Display for Error { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-impl error::Error for Error { +- fn description(&self) -> &str { +- match self.repr { +- Repr::Os(..) | Repr::Simple(..) => self.kind().as_str(), +- Repr::Custom(ref c) => c.error.description(), +- } +- } +- +- fn cause(&self) -> Option<&error::Error> { +- match self.repr { +- Repr::Os(..) => None, +- Repr::Simple(..) => None, +- Repr::Custom(ref c) => c.error.cause(), +- } +- } +-} +- + fn _assert_error_is_sync_send() { + fn _is_sync_send() {} + _is_sync_send::(); +diff --git a/impls.rs b/impls.rs +index d6b41ce..1ddabf1 100644 +--- a/impls.rs ++++ b/impls.rs +@@ -8,15 +8,18 @@ + // option. This file may not be copied, modified, or distributed + // except according to those terms. + +-use cmp; +-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind}; +-use fmt; +-use mem; ++#[cfg(feature="alloc")] use alloc::boxed::Box; ++use core::cmp; ++use io::{self, SeekFrom, Read, Initializer, Write, Seek, Error, ErrorKind}; ++#[cfg(feature="collections")] use io::BufRead; ++use core::fmt; ++use core::mem; ++#[cfg(feature="collections")] use collections::string::String; ++#[cfg(feature="collections")] use collections::vec::Vec; + + // ============================================================================= + // Forwarding implementations + +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, R: Read + ?Sized> Read for &'a mut R { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -28,11 +31,13 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -43,7 +48,6 @@ impl<'a, R: Read + ?Sized> Read for &'a mut R { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, W: Write + ?Sized> Write for &'a mut W { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -61,12 +65,11 @@ impl<'a, W: Write + ?Sized> Write for &'a mut W { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a, S: Seek + ?Sized> Seek for &'a mut S { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -85,7 +88,7 @@ impl<'a, B: BufRead + ?Sized> BufRead for &'a mut B { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Read for Box { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -97,11 +100,13 @@ impl Read for Box { + (**self).initializer() + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { + (**self).read_to_end(buf) + } + ++ #[cfg(feature="collections")] + #[inline] + fn read_to_string(&mut self, buf: &mut String) -> io::Result { + (**self).read_to_string(buf) +@@ -112,7 +117,7 @@ impl Read for Box { + (**self).read_exact(buf) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Write for Box { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { (**self).write(buf) } +@@ -130,12 +135,12 @@ impl Write for Box { + (**self).write_fmt(fmt) + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="alloc")] + impl Seek for Box { + #[inline] + fn seek(&mut self, pos: SeekFrom) -> io::Result { (**self).seek(pos) } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Box { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { (**self).fill_buf() } +@@ -161,7 +166,6 @@ impl BufRead for Box { + /// + /// Note that reading updates the slice to point to the yet unread part. + /// The slice will be empty when EOF is reached. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Read for &'a [u8] { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -208,7 +212,7 @@ impl<'a> Read for &'a [u8] { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl<'a> BufRead for &'a [u8] { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(*self) } +@@ -222,7 +226,6 @@ impl<'a> BufRead for &'a [u8] { + /// + /// Note that writing updates the slice to point to the yet unwritten part. + /// The slice will be empty when it has been completely overwritten. +-#[stable(feature = "rust1", since = "1.0.0")] + impl<'a> Write for &'a mut [u8] { + #[inline] + fn write(&mut self, data: &[u8]) -> io::Result { +@@ -248,7 +251,7 @@ impl<'a> Write for &'a mut [u8] { + + /// Write is implemented for `Vec` by appending to the vector. + /// The vector will grow as needed. +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Write for Vec { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { +diff --git a/memchr.rs b/memchr.rs +index 50f998e..a8bff09 100644 +--- a/memchr.rs ++++ b/memchr.rs +@@ -11,10 +11,12 @@ + // Original implementation taken from rust-memchr + // Copyright 2015 Andrew Gallant, bluss and Nicolas Koch + ++pub use self::fallback::{memchr,memrchr}; ++ + #[allow(dead_code)] + pub mod fallback { +- use cmp; +- use mem; ++ use core::cmp; ++ use core::mem; + + const LO_U64: u64 = 0x0101010101010101; + const HI_U64: u64 = 0x8080808080808080; +diff --git a/mod.rs b/mod.rs +index 074ab3e..8dfbe83 100644 +--- a/mod.rs ++++ b/mod.rs +@@ -268,50 +268,35 @@ + //! [`Result`]: ../result/enum.Result.html + //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap + +-#![stable(feature = "rust1", since = "1.0.0")] +- +-use cmp; ++use core::cmp; + use core::str as core_str; +-use error as std_error; +-use fmt; +-use result; +-use str; +-use memchr; +-use ptr; +- +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::{BufReader, BufWriter, LineWriter}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::buffered::IntoInnerError; +-#[stable(feature = "rust1", since = "1.0.0")] ++use core::fmt; ++use core::result; ++#[cfg(feature="collections")] use collections::string::String; ++use core::str; ++#[cfg(feature="collections")] use collections::vec::Vec; ++mod memchr; ++use core::ptr; ++ ++#[cfg(feature="collections")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; ++#[cfg(feature="collections")] pub use self::buffered::IntoInnerError; + pub use self::cursor::Cursor; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::error::{Result, Error, ErrorKind}; +-#[stable(feature = "rust1", since = "1.0.0")] + pub use self::util::{copy, sink, Sink, empty, Empty, repeat, Repeat}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{stdin, stdout, stderr, Stdin, Stdout, Stderr}; +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use self::stdio::{StdoutLock, StderrLock, StdinLock}; +-#[unstable(feature = "print_internals", issue = "0")] +-pub use self::stdio::{_print, _eprint}; +-#[unstable(feature = "libstd_io_internals", issue = "42788")] +-#[doc(no_inline, hidden)] +-pub use self::stdio::{set_panic, set_print}; + + pub mod prelude; +-mod buffered; ++#[cfg(feature="collections")] mod buffered; + mod cursor; + mod error; + mod impls; +-mod lazy; + mod util; +-mod stdio; + +-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; ++const DEFAULT_BUF_SIZE: usize = 8 * 1024; + ++#[cfg(feature="collections")] + struct Guard<'a> { buf: &'a mut Vec, len: usize } + ++#[cfg(feature="collections")] + impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + unsafe { self.buf.set_len(self.len); } +@@ -336,6 +321,7 @@ impl<'a> Drop for Guard<'a> { + // 2. We're passing a raw buffer to the function `f`, and it is expected that + // the function only *appends* bytes to the buffer. We'll get undefined + // behavior if existing bytes are overwritten to have non-UTF-8 data. ++#[cfg(feature="collections")] + fn append_to_string(buf: &mut String, f: F) -> Result + where F: FnOnce(&mut Vec) -> Result + { +@@ -363,6 +349,7 @@ fn append_to_string(buf: &mut String, f: F) -> Result + // + // Because we're extending the buffer with uninitialized data for trusted + // readers, we need to make sure to truncate that if any of this panics. ++#[cfg(feature="collections")] + fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { + let start_len = buf.len(); + let mut g = Guard { len: buf.len(), buf: buf }; +@@ -449,7 +436,6 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Read { + /// Pull some bytes from this source into the specified buffer, returning + /// how many bytes were read. +@@ -505,7 +491,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read(&mut self, buf: &mut [u8]) -> Result; + + /// Determines if this `Read`er can work with buffers of uninitialized +@@ -530,7 +515,6 @@ pub trait Read { + /// + /// [`Initializer::nop()`]: ../../std/io/struct.Initializer.html#method.nop + /// [`Initializer`]: ../../std/io/struct.Initializer.html +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + unsafe fn initializer(&self) -> Initializer { + Initializer::zeroing() +@@ -578,7 +562,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_end(&mut self, buf: &mut Vec) -> Result { + read_to_end(self, buf) + } +@@ -616,7 +600,7 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] ++ #[cfg(feature="collections")] + fn read_to_string(&mut self, buf: &mut String) -> Result { + // Note that we do *not* call `.read_to_end()` here. We are passing + // `&mut Vec` (the raw contents of `buf`) into the `read_to_end` +@@ -679,7 +663,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "read_exact", since = "1.6.0")] + fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> { + while !buf.is_empty() { + match self.read(buf) { +@@ -731,7 +714,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + + /// Transforms this `Read` instance to an [`Iterator`] over its bytes. +@@ -767,7 +749,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn bytes(self) -> Bytes where Self: Sized { + Bytes { inner: self } + } +@@ -808,10 +789,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "io", reason = "the semantics of a partial read/write \ +- of where errors happen is currently \ +- unclear and may change", +- issue = "27802")] + fn chars(self) -> Chars where Self: Sized { + Chars { inner: self } + } +@@ -846,7 +823,6 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn chain(self, next: R) -> Chain where Self: Sized { + Chain { first: self, second: next, done_first: false } + } +@@ -882,20 +858,17 @@ pub trait Read { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn take(self, limit: u64) -> Take where Self: Sized { + Take { inner: self, limit: limit } + } + } + + /// A type used to conditionally initialize buffers passed to `Read` methods. +-#[unstable(feature = "read_initializer", issue = "42788")] + #[derive(Debug)] + pub struct Initializer(bool); + + impl Initializer { + /// Returns a new `Initializer` which will zero out buffers. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn zeroing() -> Initializer { + Initializer(true) +@@ -909,21 +882,18 @@ impl Initializer { + /// read from buffers passed to `Read` methods, and that the return value of + /// the method accurately reflects the number of bytes that have been + /// written to the head of the buffer. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub unsafe fn nop() -> Initializer { + Initializer(false) + } + + /// Indicates if a buffer should be initialized. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn should_initialize(&self) -> bool { + self.0 + } + + /// Initializes a buffer if necessary. +- #[unstable(feature = "read_initializer", issue = "42788")] + #[inline] + pub fn initialize(&self, buf: &mut [u8]) { + if self.should_initialize() { +@@ -966,7 +936,6 @@ impl Initializer { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Write { + /// Write a buffer into this object, returning how many bytes were written. + /// +@@ -1010,7 +979,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write(&mut self, buf: &[u8]) -> Result; + + /// Flush this output stream, ensuring that all intermediately buffered +@@ -1036,7 +1004,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn flush(&mut self) -> Result<()>; + + /// Attempts to write an entire buffer into this write. +@@ -1066,7 +1033,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_all(&mut self, mut buf: &[u8]) -> Result<()> { + while !buf.is_empty() { + match self.write(buf) { +@@ -1118,7 +1084,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()> { + // Create a shim which translates a Write to a fmt::Write and saves + // off I/O errors. instead of discarding them +@@ -1174,7 +1139,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } + } + +@@ -1204,7 +1168,6 @@ pub trait Write { + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub trait Seek { + /// Seek to an offset, in bytes, in a stream. + /// +@@ -1220,7 +1183,6 @@ pub trait Seek { + /// Seeking to a negative offset is considered an error. + /// + /// [`SeekFrom::Start`]: enum.SeekFrom.html#variant.Start +- #[stable(feature = "rust1", since = "1.0.0")] + fn seek(&mut self, pos: SeekFrom) -> Result; + } + +@@ -1230,29 +1192,26 @@ pub trait Seek { + /// + /// [`Seek`]: trait.Seek.html + #[derive(Copy, PartialEq, Eq, Clone, Debug)] +-#[stable(feature = "rust1", since = "1.0.0")] + pub enum SeekFrom { + /// Set the offset to the provided number of bytes. +- #[stable(feature = "rust1", since = "1.0.0")] +- Start(#[stable(feature = "rust1", since = "1.0.0")] u64), ++ Start(u64), + + /// Set the offset to the size of this object plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- End(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ End(i64), + + /// Set the offset to the current position plus the specified number of + /// bytes. + /// + /// It is possible to seek beyond the end of an object, but it's an error to + /// seek before byte 0. +- #[stable(feature = "rust1", since = "1.0.0")] +- Current(#[stable(feature = "rust1", since = "1.0.0")] i64), ++ Current(i64), + } + ++#[cfg(feature="collections")] + fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + -> Result { + let mut read = 0; +@@ -1332,7 +1291,7 @@ fn read_until(r: &mut R, delim: u8, buf: &mut Vec) + /// # } + /// ``` + /// +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + pub trait BufRead: Read { + /// Fills the internal buffer of this object, returning the buffer contents. + /// +@@ -1377,7 +1336,6 @@ pub trait BufRead: Read { + /// // ensure the bytes we worked with aren't returned again later + /// stdin.consume(length); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn fill_buf(&mut self) -> Result<&[u8]>; + + /// Tells this buffer that `amt` bytes have been consumed from the buffer, +@@ -1399,7 +1357,6 @@ pub trait BufRead: Read { + /// that method's example includes an example of `consume()`. + /// + /// [`fill_buf`]: #tymethod.fill_buf +- #[stable(feature = "rust1", since = "1.0.0")] + fn consume(&mut self, amt: usize); + + /// Read all bytes into `buf` until the delimiter `byte` or EOF is reached. +@@ -1455,7 +1412,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, b""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_until(&mut self, byte: u8, buf: &mut Vec) -> Result { + read_until(self, byte, buf) + } +@@ -1510,7 +1466,6 @@ pub trait BufRead: Read { + /// assert_eq!(num_bytes, 0); + /// assert_eq!(buf, ""); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn read_line(&mut self, buf: &mut String) -> Result { + // Note that we are not calling the `.read_until` method here, but + // rather our hardcoded implementation. For more details as to why, see +@@ -1551,7 +1506,6 @@ pub trait BufRead: Read { + /// assert_eq!(split_iter.next(), Some(b"dolor".to_vec())); + /// assert_eq!(split_iter.next(), None); + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + fn split(self, byte: u8) -> Split where Self: Sized { + Split { buf: self, delim: byte } + } +@@ -1590,7 +1544,6 @@ pub trait BufRead: Read { + /// Each line of the iterator has the same error semantics as [`BufRead::read_line`]. + /// + /// [`BufRead::read_line`]: trait.BufRead.html#method.read_line +- #[stable(feature = "rust1", since = "1.0.0")] + fn lines(self) -> Lines where Self: Sized { + Lines { buf: self } + } +@@ -1602,7 +1555,6 @@ pub trait BufRead: Read { + /// Please see the documentation of [`chain`] for more details. + /// + /// [`chain`]: trait.Read.html#method.chain +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Chain { + first: T, + second: U, +@@ -1628,7 +1580,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn into_inner(self) -> (T, U) { + (self.first, self.second) + } +@@ -1651,7 +1602,6 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> (&T, &U) { + (&self.first, &self.second) + } +@@ -1678,13 +1628,11 @@ impl Chain { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> (&mut T, &mut U) { + (&mut self.first, &mut self.second) + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Chain { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Chain") +@@ -1694,7 +1642,6 @@ impl fmt::Debug for Chain { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Chain { + fn read(&mut self, buf: &mut [u8]) -> Result { + if !self.done_first { +@@ -1716,7 +1663,7 @@ impl Read for Chain { + } + } + +-#[stable(feature = "chain_bufread", since = "1.9.0")] ++#[cfg(feature="collections")] + impl BufRead for Chain { + fn fill_buf(&mut self) -> Result<&[u8]> { + if !self.done_first { +@@ -1743,7 +1690,6 @@ impl BufRead for Chain { + /// Please see the documentation of [`take`] for more details. + /// + /// [`take`]: trait.Read.html#method.take +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Take { + inner: T, +@@ -1778,7 +1724,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "rust1", since = "1.0.0")] + pub fn limit(&self) -> u64 { self.limit } + + /// Sets the number of bytes that can be read before this instance will +@@ -1805,7 +1750,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[unstable(feature = "take_set_limit", issue = "42781")] + pub fn set_limit(&mut self, limit: u64) { + self.limit = limit; + } +@@ -1830,7 +1774,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "io_take_into_inner", since = "1.15.0")] + pub fn into_inner(self) -> T { + self.inner + } +@@ -1855,7 +1798,6 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_ref(&self) -> &T { + &self.inner + } +@@ -1884,13 +1826,11 @@ impl Take { + /// # Ok(()) + /// # } + /// ``` +- #[stable(feature = "more_io_inner_methods", since = "1.20.0")] + pub fn get_mut(&mut self) -> &mut T { + &mut self.inner + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Take { + fn read(&mut self, buf: &mut [u8]) -> Result { + // Don't call into inner reader at all at EOF because it may still block +@@ -1909,7 +1849,7 @@ impl Read for Take { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl BufRead for Take { + fn fill_buf(&mut self) -> Result<&[u8]> { + // Don't call into inner reader at all at EOF because it may still block +@@ -1948,13 +1888,11 @@ fn read_one_byte(reader: &mut Read) -> Option> { + /// Please see the documentation of [`bytes`] for more details. + /// + /// [`bytes`]: trait.Read.html#method.bytes +-#[stable(feature = "rust1", since = "1.0.0")] + #[derive(Debug)] + pub struct Bytes { + inner: R, + } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Iterator for Bytes { + type Item = Result; + +@@ -1969,8 +1907,6 @@ impl Iterator for Bytes { + /// Please see the documentation of `chars()` for more details. + /// + /// [chars]: trait.Read.html#method.chars +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + #[derive(Debug)] + pub struct Chars { + inner: R, +@@ -1979,8 +1915,6 @@ pub struct Chars { + /// An enumeration of possible errors that can be generated from the `Chars` + /// adapter. + #[derive(Debug)] +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + pub enum CharsError { + /// Variant representing that the underlying stream was read successfully + /// but it did not contain valid utf8 data. +@@ -1990,8 +1924,6 @@ pub enum CharsError { + Other(Error), + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl Iterator for Chars { + type Item = result::Result; + +@@ -2023,25 +1955,6 @@ impl Iterator for Chars { + } + } + +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] +-impl std_error::Error for CharsError { +- fn description(&self) -> &str { +- match *self { +- CharsError::NotUtf8 => "invalid utf8 encoding", +- CharsError::Other(ref e) => std_error::Error::description(e), +- } +- } +- fn cause(&self) -> Option<&std_error::Error> { +- match *self { +- CharsError::NotUtf8 => None, +- CharsError::Other(ref e) => e.cause(), +- } +- } +-} +- +-#[unstable(feature = "io", reason = "awaiting stability of Read::chars", +- issue = "27802")] + impl fmt::Display for CharsError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { +@@ -2060,14 +1973,14 @@ impl fmt::Display for CharsError { + /// `BufRead`. Please see the documentation of `split()` for more details. + /// + /// [split]: trait.BufRead.html#method.split +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Split { + buf: B, + delim: u8, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Split { + type Item = Result>; + +@@ -2092,13 +2005,13 @@ impl Iterator for Split { + /// `BufRead`. Please see the documentation of `lines()` for more details. + /// + /// [lines]: trait.BufRead.html#method.lines +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + #[derive(Debug)] + pub struct Lines { + buf: B, + } + +-#[stable(feature = "rust1", since = "1.0.0")] ++#[cfg(feature="collections")] + impl Iterator for Lines { + type Item = Result; + +diff --git a/prelude.rs b/prelude.rs +index 8772d0f..49d66c9 100644 +--- a/prelude.rs ++++ b/prelude.rs +@@ -18,7 +18,8 @@ + //! use std::io::prelude::*; + //! ``` + +-#![stable(feature = "rust1", since = "1.0.0")] ++pub use super::{Read, Write, Seek}; ++#[cfg(feature="collections")] pub use super::BufRead; + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use super::{Read, Write, BufRead, Seek}; ++#[cfg(feature="collections")] pub use alloc::boxed::Box; ++#[cfg(feature="collections")] pub use collections::vec::Vec; +diff --git a/util.rs b/util.rs +index e20f249..cf60151 100644 +--- a/util.rs ++++ b/util.rs +@@ -10,9 +10,10 @@ + + #![allow(missing_copy_implementations)] + +-use fmt; +-use io::{self, Read, Initializer, Write, ErrorKind, BufRead}; +-use mem; ++use core::fmt; ++use io::{self, Read, Initializer, Write, ErrorKind}; ++use core::mem; ++#[cfg(feature="collections")] use io::BufRead; + + /// Copies the entire contents of a reader into a writer. + /// +@@ -44,7 +45,6 @@ use mem; + /// # Ok(()) + /// # } + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn copy(reader: &mut R, writer: &mut W) -> io::Result + where R: Read, W: Write + { +@@ -73,7 +73,6 @@ pub fn copy(reader: &mut R, writer: &mut W) -> io::Result< + /// the documentation of [`empty()`][`empty`] for more details. + /// + /// [`empty`]: fn.empty.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Empty { _priv: () } + + /// Constructs a new handle to an empty reader. +@@ -93,10 +92,8 @@ pub struct Empty { _priv: () } + /// io::empty().read_to_string(&mut buffer).unwrap(); + /// assert!(buffer.is_empty()); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn empty() -> Empty { Empty { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Empty { + #[inline] + fn read(&mut self, _buf: &mut [u8]) -> io::Result { Ok(0) } +@@ -106,7 +103,8 @@ impl Read for Empty { + Initializer::nop() + } + } +-#[stable(feature = "rust1", since = "1.0.0")] ++ ++#[cfg(feature="collections")] + impl BufRead for Empty { + #[inline] + fn fill_buf(&mut self) -> io::Result<&[u8]> { Ok(&[]) } +@@ -114,7 +112,6 @@ impl BufRead for Empty { + fn consume(&mut self, _n: usize) {} + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Empty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Empty { .. }") +@@ -127,7 +124,6 @@ impl fmt::Debug for Empty { + /// see the documentation of `repeat()` for more details. + /// + /// [repeat]: fn.repeat.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Repeat { byte: u8 } + + /// Creates an instance of a reader that infinitely repeats one byte. +@@ -144,10 +140,8 @@ pub struct Repeat { byte: u8 } + /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); + /// assert_eq!(buffer, [0b101, 0b101, 0b101]); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Read for Repeat { + #[inline] + fn read(&mut self, buf: &mut [u8]) -> io::Result { +@@ -163,7 +157,6 @@ impl Read for Repeat { + } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Repeat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Repeat { .. }") +@@ -176,7 +169,6 @@ impl fmt::Debug for Repeat { + /// see the documentation of `sink()` for more details. + /// + /// [sink]: fn.sink.html +-#[stable(feature = "rust1", since = "1.0.0")] + pub struct Sink { _priv: () } + + /// Creates an instance of a writer which will successfully consume all data. +@@ -193,10 +185,8 @@ pub struct Sink { _priv: () } + /// let num_bytes = io::sink().write(&buffer).unwrap(); + /// assert_eq!(num_bytes, 5); + /// ``` +-#[stable(feature = "rust1", since = "1.0.0")] + pub fn sink() -> Sink { Sink { _priv: () } } + +-#[stable(feature = "rust1", since = "1.0.0")] + impl Write for Sink { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result { Ok(buf.len()) } +@@ -204,7 +194,6 @@ impl Write for Sink { + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + +-#[stable(feature = "std_debug", since = "1.16.0")] + impl fmt::Debug for Sink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Sink { .. }") diff --git a/src/lib.rs b/src/lib.rs index 4121798..990600b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,11 +3,15 @@ //! the [std documentation](https://doc.rust-lang.org/nightly/std/io/index.html) //! for a full description of the functionality. #![allow(stable_features,unused_features)] -#![feature(question_mark,const_fn,collections,alloc,unicode,copy_from_slice,str_char,try_from,str_internals)] +#![feature(question_mark,const_fn,collections,alloc,unicode,copy_from_slice, + str_char,try_from,str_internals,align_offset,doc_spotlight,slice_internals)] #![no_std] #[cfg_attr(feature="collections",macro_use)] -#[cfg(feature="collections")] extern crate collections; +#[cfg(all(feature="collections",not(no_collections)))] extern crate collections; +#[cfg_attr(feature="collections",allow(unused_imports))] +#[cfg_attr(feature="collections",macro_use)] +#[cfg(all(feature="collections",no_collections))] extern crate alloc as collections; #[cfg(feature="alloc")] extern crate alloc; #[cfg(rustc_unicode)] extern crate rustc_unicode;