Gentoo Archives: gentoo-commits

From: Georgy Yakovlev <gyakovlev@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-lang/rust/files/, dev-lang/rust/
Date: Sat, 28 Mar 2020 19:08:26
Message-Id: 1585422472.db3aa7638741984c27df6bb96069ed1a40ad54c8.gyakovlev@gentoo
1 commit: db3aa7638741984c27df6bb96069ed1a40ad54c8
2 Author: Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
3 AuthorDate: Sat Mar 28 18:31:31 2020 +0000
4 Commit: Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
5 CommitDate: Sat Mar 28 19:07:52 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=db3aa763
7
8 dev-lang/rust: fix system-bootstrap with 1.42.0
9
10 Closes: https://bugs.gentoo.org/715142
11 Package-Manager: Portage-2.3.96, Repoman-2.3.22
12 Signed-off-by: Georgy Yakovlev <gyakovlev <AT> gentoo.org>
13
14 dev-lang/rust/files/1.42.0-fix-bootstrap.patch | 440 +++++++++++++++++++++++++
15 dev-lang/rust/rust-1.42.0.ebuild | 1 +
16 2 files changed, 441 insertions(+)
17
18 diff --git a/dev-lang/rust/files/1.42.0-fix-bootstrap.patch b/dev-lang/rust/files/1.42.0-fix-bootstrap.patch
19 new file mode 100644
20 index 00000000000..16e4e6dce1c
21 --- /dev/null
22 +++ b/dev-lang/rust/files/1.42.0-fix-bootstrap.patch
23 @@ -0,0 +1,440 @@
24 +From 5f979e9afab42dd7536ca93994de66169880361e Mon Sep 17 00:00:00 2001
25 +From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= <matthias.krueger@××××××.de>
26 +Date: Mon, 3 Feb 2020 20:13:30 +0100
27 +Subject: [PATCH] bootstrap: fix clippy warnings
28 +
29 +---
30 + src/bootstrap/bin/rustc.rs | 6 +++---
31 + src/bootstrap/bin/rustdoc.rs | 2 +-
32 + src/bootstrap/builder.rs | 24 ++++++++----------------
33 + src/bootstrap/builder/tests.rs | 1 -
34 + src/bootstrap/compile.rs | 20 ++++++++++----------
35 + src/bootstrap/config.rs | 7 +++----
36 + src/bootstrap/dist.rs | 4 ++--
37 + src/bootstrap/doc.rs | 2 +-
38 + src/bootstrap/flags.rs | 2 +-
39 + src/bootstrap/install.rs | 5 ++---
40 + src/bootstrap/lib.rs | 6 +++---
41 + src/bootstrap/metadata.rs | 1 -
42 + src/bootstrap/native.rs | 4 +---
43 + src/bootstrap/test.rs | 9 +++------
44 + src/bootstrap/tool.rs | 2 +-
45 + src/bootstrap/toolstate.rs | 2 +-
46 + src/bootstrap/util.rs | 2 +-
47 + 17 files changed, 41 insertions(+), 58 deletions(-)
48 +
49 +diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs
50 +index a34ec44566bc..a8c00c8c3ca8 100644
51 +--- a/src/bootstrap/bin/rustc.rs
52 ++++ b/src/bootstrap/bin/rustc.rs
53 +@@ -47,7 +47,7 @@ fn main() {
54 + };
55 + let stage = env::var("RUSTC_STAGE").expect("RUSTC_STAGE was not set");
56 + let sysroot = env::var_os("RUSTC_SYSROOT").expect("RUSTC_SYSROOT was not set");
57 +- let on_fail = env::var_os("RUSTC_ON_FAIL").map(|of| Command::new(of));
58 ++ let on_fail = env::var_os("RUSTC_ON_FAIL").map(Command::new);
59 +
60 + let rustc = env::var_os(rustc).unwrap_or_else(|| panic!("{:?} was not set", rustc));
61 + let libdir = env::var_os(libdir).unwrap_or_else(|| panic!("{:?} was not set", libdir));
62 +@@ -64,7 +64,7 @@ fn main() {
63 + if let Some(crate_name) = crate_name {
64 + if let Some(target) = env::var_os("RUSTC_TIME") {
65 + if target == "all"
66 +- || target.into_string().unwrap().split(",").any(|c| c.trim() == crate_name)
67 ++ || target.into_string().unwrap().split(',').any(|c| c.trim() == crate_name)
68 + {
69 + cmd.arg("-Ztime");
70 + }
71 +@@ -189,7 +189,7 @@ fn main() {
72 + crate_name,
73 + is_test,
74 + dur.as_secs(),
75 +- dur.subsec_nanos() / 1_000_000
76 ++ dur.subsec_millis()
77 + );
78 +
79 + match status.code() {
80 +diff --git a/src/bootstrap/bin/rustdoc.rs b/src/bootstrap/bin/rustdoc.rs
81 +index 8c8b33a4e4e0..04345867bf5c 100644
82 +--- a/src/bootstrap/bin/rustdoc.rs
83 ++++ b/src/bootstrap/bin/rustdoc.rs
84 +@@ -61,7 +61,7 @@ fn main() {
85 + }
86 +
87 + // Needed to be able to run all rustdoc tests.
88 +- if let Some(_) = env::var_os("RUSTDOC_GENERATE_REDIRECT_PAGES") {
89 ++ if env::var_os("RUSTDOC_GENERATE_REDIRECT_PAGES").is_some() {
90 + // This "unstable-options" can be removed when `--generate-redirect-pages` is stabilized
91 + if !has_unstable {
92 + cmd.arg("-Z").arg("unstable-options");
93 +diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
94 +index d9c894aa9c6b..18f6fda76084 100644
95 +--- a/src/bootstrap/builder.rs
96 ++++ b/src/bootstrap/builder.rs
97 +@@ -510,7 +510,7 @@ impl<'a> Builder<'a> {
98 + Subcommand::Format { .. } | Subcommand::Clean { .. } => panic!(),
99 + };
100 +
101 +- let builder = Builder {
102 ++ Builder {
103 + build,
104 + top_stage: build.config.stage.unwrap_or(2),
105 + kind,
106 +@@ -518,9 +518,7 @@ impl<'a> Builder<'a> {
107 + stack: RefCell::new(Vec::new()),
108 + time_spent_on_dependencies: Cell::new(Duration::new(0, 0)),
109 + paths: paths.to_owned(),
110 +- };
111 +-
112 +- builder
113 ++ }
114 + }
115 +
116 + pub fn execute_cli(&self) {
117 +@@ -753,13 +751,12 @@ impl<'a> Builder<'a> {
118 + cargo.env("RUST_CHECK", "1");
119 + }
120 +
121 +- let stage;
122 +- if compiler.stage == 0 && self.local_rebuild {
123 ++ let stage = if compiler.stage == 0 && self.local_rebuild {
124 + // Assume the local-rebuild rustc already has stage1 features.
125 +- stage = 1;
126 ++ 1
127 + } else {
128 +- stage = compiler.stage;
129 +- }
130 ++ compiler.stage
131 ++ };
132 +
133 + let mut rustflags = Rustflags::new(&target);
134 + if stage != 0 {
135 +@@ -1252,12 +1249,7 @@ impl<'a> Builder<'a> {
136 + };
137 +
138 + if self.config.print_step_timings && dur > Duration::from_millis(100) {
139 +- println!(
140 +- "[TIMING] {:?} -- {}.{:03}",
141 +- step,
142 +- dur.as_secs(),
143 +- dur.subsec_nanos() / 1_000_000
144 +- );
145 ++ println!("[TIMING] {:?} -- {}.{:03}", step, dur.as_secs(), dur.subsec_millis());
146 + }
147 +
148 + {
149 +@@ -1302,7 +1294,7 @@ impl Rustflags {
150 +
151 + fn arg(&mut self, arg: &str) -> &mut Self {
152 + assert_eq!(arg.split_whitespace().count(), 1);
153 +- if self.0.len() > 0 {
154 ++ if !self.0.is_empty() {
155 + self.0.push_str(" ");
156 + }
157 + self.0.push_str(arg);
158 +diff --git a/src/bootstrap/builder/tests.rs b/src/bootstrap/builder/tests.rs
159 +index 5fefb972866a..cca8ab80c93b 100644
160 +--- a/src/bootstrap/builder/tests.rs
161 ++++ b/src/bootstrap/builder/tests.rs
162 +@@ -19,7 +19,6 @@ fn configure(host: &[&str], target: &[&str]) -> Config {
163 + config.out = dir;
164 + config.build = INTERNER.intern_str("A");
165 + config.hosts = vec![config.build]
166 +- .clone()
167 + .into_iter()
168 + .chain(host.iter().map(|s| INTERNER.intern_str(s)))
169 + .collect::<Vec<_>>();
170 +diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
171 +index eced03506ab9..7dded96e18ef 100644
172 +--- a/src/bootstrap/compile.rs
173 ++++ b/src/bootstrap/compile.rs
174 +@@ -18,7 +18,6 @@ use std::str;
175 + use build_helper::{output, t, up_to_date};
176 + use filetime::FileTime;
177 + use serde::Deserialize;
178 +-use serde_json;
179 +
180 + use crate::builder::Cargo;
181 + use crate::dist;
182 +@@ -149,7 +148,8 @@ fn copy_third_party_objects(
183 + // which is provided by std for this target.
184 + if target == "x86_64-fortanix-unknown-sgx" {
185 + let src_path_env = "X86_FORTANIX_SGX_LIBS";
186 +- let src = env::var(src_path_env).expect(&format!("{} not found in env", src_path_env));
187 ++ let src =
188 ++ env::var(src_path_env).unwrap_or_else(|_| panic!("{} not found in env", src_path_env));
189 + copy_and_stamp(Path::new(&src), "libunwind.a");
190 + }
191 +
192 +@@ -361,7 +361,7 @@ impl Step for StartupObjects {
193 + );
194 + }
195 +
196 +- let target = sysroot_dir.join(file.to_string() + ".o");
197 ++ let target = sysroot_dir.join((*file).to_string() + ".o");
198 + builder.copy(dst_file, &target);
199 + target_deps.push(target);
200 + }
201 +@@ -515,7 +515,7 @@ pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: Interne
202 + .env("CFG_VERSION", builder.rust_version())
203 + .env("CFG_PREFIX", builder.config.prefix.clone().unwrap_or_default());
204 +
205 +- let libdir_relative = builder.config.libdir_relative().unwrap_or(Path::new("lib"));
206 ++ let libdir_relative = builder.config.libdir_relative().unwrap_or_else(|| Path::new("lib"));
207 + cargo.env("CFG_LIBDIR_RELATIVE", libdir_relative);
208 +
209 + if let Some(ref ver_date) = builder.rust_info.commit_date() {
210 +@@ -843,11 +843,11 @@ pub fn run_cargo(
211 + };
212 + for filename in filenames {
213 + // Skip files like executables
214 +- if !filename.ends_with(".rlib")
215 +- && !filename.ends_with(".lib")
216 +- && !filename.ends_with(".a")
217 +- && !is_dylib(&filename)
218 +- && !(is_check && filename.ends_with(".rmeta"))
219 ++ if !(filename.ends_with(".rlib")
220 ++ || filename.ends_with(".lib")
221 ++ || filename.ends_with(".a")
222 ++ || is_dylib(&filename)
223 ++ || (is_check && filename.ends_with(".rmeta")))
224 + {
225 + continue;
226 + }
227 +@@ -905,7 +905,7 @@ pub fn run_cargo(
228 + for (prefix, extension, expected_len) in toplevel {
229 + let candidates = contents.iter().filter(|&&(_, ref filename, ref meta)| {
230 + filename.starts_with(&prefix[..])
231 +- && filename[prefix.len()..].starts_with("-")
232 ++ && filename[prefix.len()..].starts_with('-')
233 + && filename.ends_with(&extension[..])
234 + && meta.len() == expected_len
235 + });
236 +diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
237 +index 110c8b844d54..709cf2908ead 100644
238 +--- a/src/bootstrap/config.rs
239 ++++ b/src/bootstrap/config.rs
240 +@@ -16,7 +16,6 @@ use crate::flags::Flags;
241 + pub use crate::flags::Subcommand;
242 + use build_helper::t;
243 + use serde::Deserialize;
244 +-use toml;
245 +
246 + /// Global configuration for the entire build and/or bootstrap.
247 + ///
248 +@@ -440,7 +439,7 @@ impl Config {
249 + }
250 + }
251 + })
252 +- .unwrap_or_else(|| TomlConfig::default());
253 ++ .unwrap_or_else(TomlConfig::default);
254 +
255 + let build = toml.build.clone().unwrap_or_default();
256 + // set by bootstrap.py
257 +@@ -539,7 +538,7 @@ impl Config {
258 + config.llvm_ldflags = llvm.ldflags.clone();
259 + set(&mut config.llvm_use_libcxx, llvm.use_libcxx);
260 + config.llvm_use_linker = llvm.use_linker.clone();
261 +- config.llvm_allow_old_toolchain = llvm.allow_old_toolchain.clone();
262 ++ config.llvm_allow_old_toolchain = llvm.allow_old_toolchain;
263 + }
264 +
265 + if let Some(ref rust) = toml.rust {
266 +@@ -606,7 +605,7 @@ impl Config {
267 + target.ar = cfg.ar.clone().map(PathBuf::from);
268 + target.ranlib = cfg.ranlib.clone().map(PathBuf::from);
269 + target.linker = cfg.linker.clone().map(PathBuf::from);
270 +- target.crt_static = cfg.crt_static.clone();
271 ++ target.crt_static = cfg.crt_static;
272 + target.musl_root = cfg.musl_root.clone().map(PathBuf::from);
273 + target.wasi_root = cfg.wasi_root.clone().map(PathBuf::from);
274 + target.qemu_rootfs = cfg.qemu_rootfs.clone().map(PathBuf::from);
275 +diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
276 +index 8d13df3ee21a..651506dbaa8a 100644
277 +--- a/src/bootstrap/dist.rs
278 ++++ b/src/bootstrap/dist.rs
279 +@@ -827,7 +827,7 @@ impl Step for Analysis {
280 + assert!(builder.config.extended);
281 + let name = pkgname(builder, "rust-analysis");
282 +
283 +- if &compiler.host != builder.config.build {
284 ++ if compiler.host != builder.config.build {
285 + return distdir(builder).join(format!("{}-{}.tar.gz", name, target));
286 + }
287 +
288 +@@ -876,7 +876,7 @@ fn copy_src_dirs(builder: &Builder<'_>, src_dirs: &[&str], exclude_dirs: &[&str]
289 + Some(path) => path,
290 + None => return false,
291 + };
292 +- if spath.ends_with("~") || spath.ends_with(".pyc") {
293 ++ if spath.ends_with('~') || spath.ends_with(".pyc") {
294 + return false;
295 + }
296 +
297 +diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs
298 +index 204056598d90..b0d9a5b94641 100644
299 +--- a/src/bootstrap/doc.rs
300 ++++ b/src/bootstrap/doc.rs
301 +@@ -560,7 +560,7 @@ impl Step for Rustdoc {
302 + builder.ensure(Rustc { stage, target });
303 +
304 + // Build rustdoc.
305 +- builder.ensure(tool::Rustdoc { compiler: compiler });
306 ++ builder.ensure(tool::Rustdoc { compiler });
307 +
308 + // Symlink compiler docs to the output directory of rustdoc documentation.
309 + let out_dir = builder.stage_out(compiler, Mode::ToolRustc).join(target).join("doc");
310 +diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs
311 +index 2101ef27f9d4..516be6a30c23 100644
312 +--- a/src/bootstrap/flags.rs
313 ++++ b/src/bootstrap/flags.rs
314 +@@ -571,7 +571,7 @@ fn split(s: &[String]) -> Vec<String> {
315 + }
316 +
317 + fn parse_deny_warnings(matches: &getopts::Matches) -> Option<bool> {
318 +- match matches.opt_str("warnings").as_ref().map(|v| v.as_str()) {
319 ++ match matches.opt_str("warnings").as_deref() {
320 + Some("deny") => Some(true),
321 + Some("warn") => Some(false),
322 + Some(value) => {
323 +diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs
324 +index f8734ebdf425..6549262811b9 100644
325 +--- a/src/bootstrap/install.rs
326 ++++ b/src/bootstrap/install.rs
327 +@@ -126,9 +126,8 @@ fn add_destdir(path: &Path, destdir: &Option<PathBuf>) -> PathBuf {
328 + None => return path.to_path_buf(),
329 + };
330 + for part in path.components() {
331 +- match part {
332 +- Component::Normal(s) => ret.push(s),
333 +- _ => {}
334 ++ if let Component::Normal(s) = part {
335 ++ ret.push(s)
336 + }
337 + }
338 + ret
339 +diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
340 +index 1fee3fd9ac1d..0db4fb389010 100644
341 +--- a/src/bootstrap/lib.rs
342 ++++ b/src/bootstrap/lib.rs
343 +@@ -444,7 +444,7 @@ impl Build {
344 + builder.execute_cli();
345 + } else {
346 + let builder = builder::Builder::new(&self);
347 +- let _ = builder.execute_cli();
348 ++ builder.execute_cli();
349 + }
350 +
351 + // Check for postponed failures from `test --no-fail-fast`.
352 +@@ -839,7 +839,7 @@ impl Build {
353 + .target_config
354 + .get(&target)
355 + .and_then(|t| t.musl_root.as_ref())
356 +- .or(self.config.musl_root.as_ref())
357 ++ .or_else(|| self.config.musl_root.as_ref())
358 + .map(|p| &**p)
359 + }
360 +
361 +@@ -1026,7 +1026,7 @@ impl Build {
362 + }
363 +
364 + fn llvm_link_tools_dynamically(&self, target: Interned<String>) -> bool {
365 +- (target.contains("linux-gnu") || target.contains("apple-darwin"))
366 ++ target.contains("linux-gnu") || target.contains("apple-darwin")
367 + }
368 +
369 + /// Returns the `version` string associated with this compiler for Rust
370 +diff --git a/src/bootstrap/metadata.rs b/src/bootstrap/metadata.rs
371 +index 8a26adc7ed50..292aa3b1e24a 100644
372 +--- a/src/bootstrap/metadata.rs
373 ++++ b/src/bootstrap/metadata.rs
374 +@@ -5,7 +5,6 @@ use std::process::Command;
375 +
376 + use build_helper::output;
377 + use serde::Deserialize;
378 +-use serde_json;
379 +
380 + use crate::cache::INTERNER;
381 + use crate::{Build, Crate};
382 +diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs
383 +index 5bbd9f47fc90..1cfb4b2f63b5 100644
384 +--- a/src/bootstrap/native.rs
385 ++++ b/src/bootstrap/native.rs
386 +@@ -15,8 +15,6 @@ use std::path::{Path, PathBuf};
387 + use std::process::Command;
388 +
389 + use build_helper::{output, t};
390 +-use cc;
391 +-use cmake;
392 +
393 + use crate::builder::{Builder, RunConfig, ShouldRun, Step};
394 + use crate::cache::Interned;
395 +@@ -205,7 +203,7 @@ impl Step for Llvm {
396 + cfg.define("LLVM_ENABLE_LIBXML2", "OFF");
397 + }
398 +
399 +- if enabled_llvm_projects.len() > 0 {
400 ++ if !enabled_llvm_projects.is_empty() {
401 + enabled_llvm_projects.sort();
402 + enabled_llvm_projects.dedup();
403 + cfg.define("LLVM_ENABLE_PROJECTS", enabled_llvm_projects.join(";"));
404 +diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs
405 +index 6adf9ddaf343..8d9e62010015 100644
406 +--- a/src/bootstrap/test.rs
407 ++++ b/src/bootstrap/test.rs
408 +@@ -1424,13 +1424,10 @@ impl Step for ErrorIndex {
409 + }
410 +
411 + fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) -> bool {
412 +- match fs::read_to_string(markdown) {
413 +- Ok(contents) => {
414 +- if !contents.contains("```") {
415 +- return true;
416 +- }
417 ++ if let Ok(contents) = fs::read_to_string(markdown) {
418 ++ if !contents.contains("```") {
419 ++ return true;
420 + }
421 +- Err(_) => {}
422 + }
423 +
424 + builder.info(&format!("doc tests for: {}", markdown.display()));
425 +diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs
426 +index 7f24768a4f10..67e0ed5c5802 100644
427 +--- a/src/bootstrap/tool.rs
428 ++++ b/src/bootstrap/tool.rs
429 +@@ -234,7 +234,7 @@ pub fn prepare_tool_cargo(
430 + cargo.env("RUSTC_EXTERNAL_TOOL", "1");
431 + }
432 +
433 +- let mut features = extra_features.iter().cloned().collect::<Vec<_>>();
434 ++ let mut features = extra_features.to_vec();
435 + if builder.build.config.cargo_native_static {
436 + if path.ends_with("cargo")
437 + || path.ends_with("rls")
438 +diff --git a/src/bootstrap/toolstate.rs b/src/bootstrap/toolstate.rs
439 +index b068c8200ace..bb012a388551 100644
440 +--- a/src/bootstrap/toolstate.rs
441 ++++ b/src/bootstrap/toolstate.rs
442 +@@ -124,7 +124,7 @@ fn check_changed_files(toolstates: &HashMap<Box<str>, ToolState>) {
443 + let output = t!(String::from_utf8(output.stdout));
444 +
445 + for (tool, submodule) in STABLE_TOOLS.iter().chain(NIGHTLY_TOOLS.iter()) {
446 +- let changed = output.lines().any(|l| l.starts_with("M") && l.ends_with(submodule));
447 ++ let changed = output.lines().any(|l| l.starts_with('M') && l.ends_with(submodule));
448 + eprintln!("Verifying status of {}...", tool);
449 + if !changed {
450 + continue;
451 +diff --git a/src/bootstrap/util.rs b/src/bootstrap/util.rs
452 +index 7d1efe4610f9..eac790fe504b 100644
453 +--- a/src/bootstrap/util.rs
454 ++++ b/src/bootstrap/util.rs
455 +@@ -98,7 +98,7 @@ impl Drop for TimeIt {
456 + fn drop(&mut self) {
457 + let time = self.1.elapsed();
458 + if !self.0 {
459 +- println!("\tfinished in {}.{:03}", time.as_secs(), time.subsec_nanos() / 1_000_000);
460 ++ println!("\tfinished in {}.{:03}", time.as_secs(), time.subsec_millis());
461 + }
462 + }
463 + }
464
465 diff --git a/dev-lang/rust/rust-1.42.0.ebuild b/dev-lang/rust/rust-1.42.0.ebuild
466 index 89ac74e3331..484af8fa84f 100644
467 --- a/dev-lang/rust/rust-1.42.0.ebuild
468 +++ b/dev-lang/rust/rust-1.42.0.ebuild
469 @@ -107,6 +107,7 @@ QA_SONAME="usr/lib.*/librustc_macros.*.so"
470
471 PATCHES=(
472 "${FILESDIR}"/1.40.0-add-soname.patch
473 + "${FILESDIR}"/1.42.0-fix-bootstrap.patch
474 )
475
476 S="${WORKDIR}/${MY_P}-src"