From bdc34fd7f7691def549a062439415eb76edd5c8b Mon Sep 17 00:00:00 2001 From: andjo403 Date: Tue, 9 Jan 2018 22:09:01 +0100 Subject: [PATCH 01/38] fix faulty comment --- src/librustc_trans/back/write.rs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs index 4d1bcd9bf467d..034ed5aeeae6a 100644 --- a/src/librustc_trans/back/write.rs +++ b/src/librustc_trans/back/write.rs @@ -1363,15 +1363,10 @@ fn start_executing_work(tcx: TyCtxt, let sess = tcx.sess; // First up, convert our jobserver into a helper thread so we can use normal - // mpsc channels to manage our messages and such. Once we've got the helper - // thread then request `n-1` tokens because all of our work items are ready - // to go. - // - // Note that the `n-1` is here because we ourselves have a token (our - // process) and we'll use that token to execute at least one unit of work. - // - // After we've requested all these tokens then we'll, when we can, get - // tokens on `rx` above which will get managed in the main loop below. + // mpsc channels to manage our messages and such. + // After we've requested tokens then we'll, when we can, + // get tokens on `coordinator_receive` which will + // get managed in the main loop below. let coordinator_send2 = coordinator_send.clone(); let helper = jobserver.into_helper_thread(move |token| { drop(coordinator_send2.send(Box::new(Message::Token(token)))); From f7b48778b1472045bd8b7ee6aacdbf1487efe50b Mon Sep 17 00:00:00 2001 From: Mikko Rantanen Date: Fri, 12 Jan 2018 12:37:48 +0200 Subject: [PATCH 02/38] Report errors instead of panic!() --- src/tools/linkchecker/main.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/tools/linkchecker/main.rs b/src/tools/linkchecker/main.rs index 6458ec02669aa..f6eaa09f55d99 100644 --- a/src/tools/linkchecker/main.rs +++ b/src/tools/linkchecker/main.rs @@ -192,7 +192,17 @@ fn check(cache: &mut Cache, for part in Path::new(base).join(url).components() { match part { Component::Prefix(_) | - Component::RootDir => panic!(), + Component::RootDir => { + // Avoid absolute paths as they make the docs not + // relocatable by making assumptions on where the docs + // are hosted relative to the site root. + *errors = true; + println!("{}:{}: absolute path - {}", + pretty_file.display(), + i + 1, + Path::new(base).join(url).display()); + return; + } Component::CurDir => {} Component::ParentDir => { path.pop(); } Component::Normal(s) => { path.push(s); } From 0b56ab0f7b0c5e01611b7ea6a28c77bc09c26275 Mon Sep 17 00:00:00 2001 From: arthurprs Date: Wed, 10 Jan 2018 20:39:11 +0100 Subject: [PATCH 03/38] Optimize slice.{r}position result bounds check --- src/libcore/slice/mod.rs | 37 +++++++++++++++++++++++++++++++++++++ src/libcore/tests/slice.rs | 19 +++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index e6b79314aa96d..d088d4e663496 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -1215,6 +1215,43 @@ macro_rules! iterator { } accum } + + #[inline] + #[rustc_inherit_overflow_checks] + fn position

(&mut self, mut predicate: P) -> Option where + Self: Sized, + P: FnMut(Self::Item) -> bool, + { + // The addition might panic on overflow + let n = self.len(); + self.try_fold(0, move |i, x| { + if predicate(x) { Err(i) } + else { Ok(i + 1) } + }).err() + .map(|i| { + unsafe { assume(i < n) }; + i + }) + } + + #[inline] + fn rposition

(&mut self, mut predicate: P) -> Option where + P: FnMut(Self::Item) -> bool, + Self: Sized + ExactSizeIterator + DoubleEndedIterator + { + // No need for an overflow check here, because `ExactSizeIterator` + // implies that the number of elements fits into a `usize`. + let n = self.len(); + self.try_rfold(n, move |i, x| { + let i = i - 1; + if predicate(x) { Err(i) } + else { Ok(i) } + }).err() + .map(|i| { + unsafe { assume(i < n) }; + i + }) + } } #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/tests/slice.rs b/src/libcore/tests/slice.rs index 40e5fe5758ac9..d6bff43bc7292 100644 --- a/src/libcore/tests/slice.rs +++ b/src/libcore/tests/slice.rs @@ -10,6 +10,25 @@ use core::result::Result::{Ok, Err}; + +#[test] +fn test_position() { + let b = [1, 2, 3, 5, 5]; + assert!(b.iter().position(|&v| v == 9) == None); + assert!(b.iter().position(|&v| v == 5) == Some(3)); + assert!(b.iter().position(|&v| v == 3) == Some(2)); + assert!(b.iter().position(|&v| v == 0) == None); +} + +#[test] +fn test_rposition() { + let b = [1, 2, 3, 5, 5]; + assert!(b.iter().rposition(|&v| v == 9) == None); + assert!(b.iter().rposition(|&v| v == 5) == Some(4)); + assert!(b.iter().rposition(|&v| v == 3) == Some(2)); + assert!(b.iter().rposition(|&v| v == 0) == None); +} + #[test] fn test_binary_search() { let b: [i32; 0] = []; From 4cedbfc6ee8ef3d35abc22c69903ab3b9573939f Mon Sep 17 00:00:00 2001 From: Gauri Date: Sat, 13 Jan 2018 11:59:35 +0530 Subject: [PATCH 04/38] fix mispositioned span --- src/librustc_errors/emitter.rs | 2 +- src/test/ui/lint/use_suggestion_json.stderr | 67 +-------------------- 2 files changed, 2 insertions(+), 67 deletions(-) diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index af556c576c035..ae0766eeeefc3 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -1187,7 +1187,7 @@ impl EmitterWriter { let sub_len = parts[0].snippet.trim().chars().fold(0, |acc, ch| { acc + unicode_width::UnicodeWidthChar::width(ch).unwrap_or(0) }); - let underline_start = span_start_pos.col.0 + start; + let underline_start = span_start_pos.col_display + start; let underline_end = span_start_pos.col.0 + start + sub_len; for p in underline_start..underline_end { buffer.putc(row_num, diff --git a/src/test/ui/lint/use_suggestion_json.stderr b/src/test/ui/lint/use_suggestion_json.stderr index 86c2ad4c0e7a4..abbf3da513a6f 100644 --- a/src/test/ui/lint/use_suggestion_json.stderr +++ b/src/test/ui/lint/use_suggestion_json.stderr @@ -2,72 +2,7 @@ "message": "cannot find type `Iter` in this scope", "code": { "code": "E0412", - "explanation": " -The type name used is not in scope. - -Erroneous code examples: - -```compile_fail,E0412 -impl Something {} // error: type name `Something` is not in scope - -// or: - -trait Foo { - fn bar(N); // error: type name `N` is not in scope -} - -// or: - -fn foo(x: T) {} // type name `T` is not in scope -``` - -To fix this error, please verify you didn't misspell the type name, you did -declare it or imported it into the scope. Examples: - -``` -struct Something; - -impl Something {} // ok! - -// or: - -trait Foo { - type N; - - fn bar(_: Self::N); // ok! -} - -// or: - -fn foo(x: T) {} // ok! -``` - -Another case that causes this error is when a type is imported into a parent -module. To fix this, you can follow the suggestion and use File directly or -`use super::File;` which will import the types from the parent namespace. An -example that causes this error is below: - -```compile_fail,E0412 -use std::fs::File; - -mod foo { - fn some_function(f: File) {} -} -``` - -``` -use std::fs::File; - -mod foo { - // either - use super::File; - // or - // use std::fs::File; - fn foo(f: File) {} -} -# fn main() {} // don't insert it for us; that'll break imports -``` -" + "explanation": null }, "level": "error", "spans": [ From eb1ada27816df80170f5d33753b9ea2049483e82 Mon Sep 17 00:00:00 2001 From: Gauri Date: Sat, 13 Jan 2018 13:33:10 +0530 Subject: [PATCH 05/38] revert changes to ui test --- src/test/ui/lint/use_suggestion_json.stderr | 67 ++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/src/test/ui/lint/use_suggestion_json.stderr b/src/test/ui/lint/use_suggestion_json.stderr index abbf3da513a6f..86c2ad4c0e7a4 100644 --- a/src/test/ui/lint/use_suggestion_json.stderr +++ b/src/test/ui/lint/use_suggestion_json.stderr @@ -2,7 +2,72 @@ "message": "cannot find type `Iter` in this scope", "code": { "code": "E0412", - "explanation": null + "explanation": " +The type name used is not in scope. + +Erroneous code examples: + +```compile_fail,E0412 +impl Something {} // error: type name `Something` is not in scope + +// or: + +trait Foo { + fn bar(N); // error: type name `N` is not in scope +} + +// or: + +fn foo(x: T) {} // type name `T` is not in scope +``` + +To fix this error, please verify you didn't misspell the type name, you did +declare it or imported it into the scope. Examples: + +``` +struct Something; + +impl Something {} // ok! + +// or: + +trait Foo { + type N; + + fn bar(_: Self::N); // ok! +} + +// or: + +fn foo(x: T) {} // ok! +``` + +Another case that causes this error is when a type is imported into a parent +module. To fix this, you can follow the suggestion and use File directly or +`use super::File;` which will import the types from the parent namespace. An +example that causes this error is below: + +```compile_fail,E0412 +use std::fs::File; + +mod foo { + fn some_function(f: File) {} +} +``` + +``` +use std::fs::File; + +mod foo { + // either + use super::File; + // or + // use std::fs::File; + fn foo(f: File) {} +} +# fn main() {} // don't insert it for us; that'll break imports +``` +" }, "level": "error", "spans": [ From 3c8c5051b18c604a4a1c0a01a6515ff3852341e1 Mon Sep 17 00:00:00 2001 From: Gauri Date: Sat, 13 Jan 2018 17:13:18 +0530 Subject: [PATCH 06/38] add ui test --- src/librustc_errors/emitter.rs | 2 +- src/test/ui/issue-47377-1.rs | 14 ++++++++++++++ src/test/ui/issue-47377-1.stderr | 12 ++++++++++++ src/test/ui/issue-47377.rs | 14 ++++++++++++++ src/test/ui/issue-47377.stderr | 12 ++++++++++++ 5 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/issue-47377-1.rs create mode 100644 src/test/ui/issue-47377-1.stderr create mode 100644 src/test/ui/issue-47377.rs create mode 100644 src/test/ui/issue-47377.stderr diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index ae0766eeeefc3..84d5a8df4adbe 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -1188,7 +1188,7 @@ impl EmitterWriter { acc + unicode_width::UnicodeWidthChar::width(ch).unwrap_or(0) }); let underline_start = span_start_pos.col_display + start; - let underline_end = span_start_pos.col.0 + start + sub_len; + let underline_end = span_start_pos.col_display + start + sub_len; for p in underline_start..underline_end { buffer.putc(row_num, max_line_num_len + 3 + p, diff --git a/src/test/ui/issue-47377-1.rs b/src/test/ui/issue-47377-1.rs new file mode 100644 index 0000000000000..f173d0096381b --- /dev/null +++ b/src/test/ui/issue-47377-1.rs @@ -0,0 +1,14 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main(){ + let b = "hello"; + println!("🦀🦀🦀🦀🦀"); let _a = b + ", World!"; //~ERROR 13:37: 13:51: binary operation `+` cannot be applied to type `&str` [E0369] +} \ No newline at end of file diff --git a/src/test/ui/issue-47377-1.stderr b/src/test/ui/issue-47377-1.stderr new file mode 100644 index 0000000000000..aad5373ae00dd --- /dev/null +++ b/src/test/ui/issue-47377-1.stderr @@ -0,0 +1,12 @@ +error[E0369]: binary operation `+` cannot be applied to type `&str` + --> $DIR/issue-47377-1.rs:13:37 + | +13 | println!("🦀🦀🦀🦀🦀"); let _a = b + ", World!"; //~ERROR 13:37: 13:51: binary operation `+` cannot be applied to type `&str` [E0369] + | ^^^^^^^^^^^^^^ `+` can't be used to concatenate two `&str` strings +help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left + | +13 | println!("🦀🦀🦀🦀🦀"); let _a = b.to_owned() + ", World!"; //~ERROR 13:37: 13:51: binary operation `+` cannot be applied to type `&str` [E0369] + | ^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/issue-47377.rs b/src/test/ui/issue-47377.rs new file mode 100644 index 0000000000000..2a8f2e30c0e88 --- /dev/null +++ b/src/test/ui/issue-47377.rs @@ -0,0 +1,14 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main(){ + let b = "hello"; + let _a = b + ", World!"; //~ERROR 13:14: 13:28: binary operation `+` cannot be applied to type `&str` [E0369] +} \ No newline at end of file diff --git a/src/test/ui/issue-47377.stderr b/src/test/ui/issue-47377.stderr new file mode 100644 index 0000000000000..e9f285a19c3d9 --- /dev/null +++ b/src/test/ui/issue-47377.stderr @@ -0,0 +1,12 @@ +error[E0369]: binary operation `+` cannot be applied to type `&str` + --> $DIR/issue-47377.rs:13:14 + | +13 | let _a = b + ", World!"; //~ERROR 13:14: 13:28: binary operation `+` cannot be applied to type `&str` [E0369] + | ^^^^^^^^^^^^^^ `+` can't be used to concatenate two `&str` strings +help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left + | +13 | let _a = b.to_owned() + ", World!"; //~ERROR 13:14: 13:28: binary operation `+` cannot be applied to type `&str` [E0369] + | ^^^^^^^^^^^^ + +error: aborting due to previous error + From a22e71685a05478db8f7959db2511d5f1704c40d Mon Sep 17 00:00:00 2001 From: varkor Date: Sun, 14 Jan 2018 17:15:39 +0000 Subject: [PATCH 07/38] Add a default directory for -Zmir-dump-dir The current behaviour of dumping in the current directory is rarely desirable: a sensible default directory for dumping is much more convenient. --- src/librustc/session/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 8c8108b060468..6645d6f90ffad 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1172,7 +1172,7 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, "emit noalias metadata for mutable references"), dump_mir: Option = (None, parse_opt_string, [UNTRACKED], "dump MIR state at various points in translation"), - dump_mir_dir: Option = (None, parse_opt_string, [UNTRACKED], + dump_mir_dir: Option = (Some(String::from("mir_dump")), parse_opt_string, [UNTRACKED], "the directory the MIR is dumped into"), dump_mir_graphviz: bool = (false, parse_bool, [UNTRACKED], "in addition to `.mir` files, create graphviz `.dot` files"), From 2ccc82e27e21f301bb4ace178bfec9fcb2570245 Mon Sep 17 00:00:00 2001 From: varkor Date: Sun, 14 Jan 2018 20:02:07 +0000 Subject: [PATCH 08/38] Make dump_mir_dir non-optional --- src/librustc/session/config.rs | 2 +- src/librustc_mir/util/liveness.rs | 5 +---- src/librustc_mir/util/pretty.rs | 6 +----- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 6645d6f90ffad..9adffb526f092 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1172,7 +1172,7 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, "emit noalias metadata for mutable references"), dump_mir: Option = (None, parse_opt_string, [UNTRACKED], "dump MIR state at various points in translation"), - dump_mir_dir: Option = (Some(String::from("mir_dump")), parse_opt_string, [UNTRACKED], + dump_mir_dir: String = (String::from("mir_dump"), parse_string, [UNTRACKED], "the directory the MIR is dumped into"), dump_mir_graphviz: bool = (false, parse_bool, [UNTRACKED], "in addition to `.mir` files, create graphviz `.dot` files"), diff --git a/src/librustc_mir/util/liveness.rs b/src/librustc_mir/util/liveness.rs index 765d50b400613..6251b64bb279d 100644 --- a/src/librustc_mir/util/liveness.rs +++ b/src/librustc_mir/util/liveness.rs @@ -407,10 +407,7 @@ fn dump_matched_mir_node<'a, 'tcx>( result: &LivenessResult, ) { let mut file_path = PathBuf::new(); - if let Some(ref file_dir) = tcx.sess.opts.debugging_opts.dump_mir_dir { - let p = Path::new(file_dir); - file_path.push(p); - }; + file_path.push(Path::new(&tcx.sess.opts.debugging_opts.dump_mir_dir)); let item_id = tcx.hir.as_local_node_id(source.def_id).unwrap(); let file_name = format!("rustc.node{}{}-liveness.mir", item_id, pass_name); file_path.push(&file_name); diff --git a/src/librustc_mir/util/pretty.rs b/src/librustc_mir/util/pretty.rs index 37f59773cd6f0..78d55ad34ed45 100644 --- a/src/librustc_mir/util/pretty.rs +++ b/src/librustc_mir/util/pretty.rs @@ -189,11 +189,7 @@ fn dump_path( }; let mut file_path = PathBuf::new(); - - if let Some(ref file_dir) = tcx.sess.opts.debugging_opts.dump_mir_dir { - let p = Path::new(file_dir); - file_path.push(p); - }; + file_path.push(Path::new(&tcx.sess.opts.debugging_opts.dump_mir_dir)); let item_name = tcx.hir .def_path(source.def_id) From e2bd0e15dc7c875750dfb5fc27b9a3afee5e9fca Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 15 Jan 2018 00:40:49 +0100 Subject: [PATCH 09/38] Update html-diff crate => fix unicode parsing and invalid paths --- src/Cargo.lock | 6 +++--- src/librustdoc/Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index 8fbf3535264fc..5b44f0ea34e04 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -838,7 +838,7 @@ dependencies = [ [[package]] name = "html-diff" -version = "0.0.5" +version = "0.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kuchiki 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2127,7 +2127,7 @@ version = "0.0.0" dependencies = [ "build_helper 0.1.0", "cc 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "html-diff 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "html-diff 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "pulldown-cmark 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2855,7 +2855,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum handlebars 0.29.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fb04af2006ea09d985fef82b81e0eb25337e51b691c76403332378a53d521edc" "checksum hex 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d6a22814455d41612f41161581c2883c0c6a1c41852729b17d5ed88f01e153aa" "checksum home 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9f25ae61099d8f3fee8b483df0bd4ecccf4b2731897aad40d50eca1b641fe6db" -"checksum html-diff 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "9778743e3b3c3679f471f0ed1833c690f19f4a0919e33b281f12ef5f77ad64c6" +"checksum html-diff 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ee4cfdf62a484a3ac0d9b80f562d37f99366db08a63621b917ea3056565345f7" "checksum html5ever 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5bfb46978eb757a603b7dfe2dafb1c62cb4dee3428d8ac1de734d83d6b022d06" "checksum idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "014b298351066f1512874135335d62a789ffe78a9974f94b43ed5621951eaf7d" "checksum if_chain 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "61bb90bdd39e3af69b0172dfc6130f6cd6332bf040fbb9bdd4401d37adbd48b8" diff --git a/src/librustdoc/Cargo.toml b/src/librustdoc/Cargo.toml index 1e574964b12dc..608adcb43d6c3 100644 --- a/src/librustdoc/Cargo.toml +++ b/src/librustdoc/Cargo.toml @@ -12,7 +12,7 @@ doctest = false [dependencies] pulldown-cmark = { version = "0.1.0", default-features = false } -html-diff = "0.0.5" +html-diff = "0.0.6" tempdir = "0.3" [build-dependencies] From 394b95fdd671a8c9fd252f5288c88d5afba486c7 Mon Sep 17 00:00:00 2001 From: varkor Date: Mon, 15 Jan 2018 00:09:39 +0000 Subject: [PATCH 10/38] Fix test --- src/librustc/session/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 9adffb526f092..abc00a63a84f0 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -2793,7 +2793,7 @@ mod tests { assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash()); opts.debugging_opts.dump_mir = Some(String::from("abc")); assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash()); - opts.debugging_opts.dump_mir_dir = Some(String::from("abc")); + opts.debugging_opts.dump_mir_dir = String::from("abc"); assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash()); opts.debugging_opts.dump_mir_graphviz = true; assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash()); From ecd47a91c7c5eb22fba5fcdec7fa8d78a8bcac51 Mon Sep 17 00:00:00 2001 From: Ryan Cumming Date: Mon, 15 Jan 2018 08:08:22 +1100 Subject: [PATCH 11/38] Don't include bang in macro replacement suggestion When we suggest the replacement for a macro we include the "!" in the suggested replacement but the span only contains the name of the macro itself. Using that replacement would cause a duplicate "!" in the resulting code. I originally tried to extend the span to be replaced by 1 byte in rust-lang/rust#47424. However, @zackmdavis pointed out that there can be whitespace between the macro name and the bang. Instead, just remove the bang from the suggested replacement. Fixes #47418 --- src/librustc_resolve/macros.rs | 3 +-- src/test/ui-fulldeps/resolve-error.stderr | 6 +++--- src/test/ui/macros/macro-name-typo.stderr | 2 +- src/test/ui/macros/macro_undefined.stderr | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index 2b0c839152ccb..ceb39aea108c8 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -691,8 +691,7 @@ impl<'a> Resolver<'a> { if let Some(suggestion) = suggestion { if suggestion != name { if let MacroKind::Bang = kind { - err.span_suggestion(span, "you could try the macro", - format!("{}!", suggestion)); + err.span_suggestion(span, "you could try the macro", suggestion.to_string()); } else { err.span_suggestion(span, "try", suggestion.to_string()); } diff --git a/src/test/ui-fulldeps/resolve-error.stderr b/src/test/ui-fulldeps/resolve-error.stderr index be7ebae70adf5..9121ce1720c98 100644 --- a/src/test/ui-fulldeps/resolve-error.stderr +++ b/src/test/ui-fulldeps/resolve-error.stderr @@ -38,13 +38,13 @@ error: cannot find macro `FooWithLongNama!` in this scope --> $DIR/resolve-error.rs:62:5 | 62 | FooWithLongNama!(); - | ^^^^^^^^^^^^^^^ help: you could try the macro: `FooWithLongNam!` + | ^^^^^^^^^^^^^^^ help: you could try the macro: `FooWithLongNam` error: cannot find macro `attr_proc_macra!` in this scope --> $DIR/resolve-error.rs:65:5 | 65 | attr_proc_macra!(); - | ^^^^^^^^^^^^^^^ help: you could try the macro: `attr_proc_mac!` + | ^^^^^^^^^^^^^^^ help: you could try the macro: `attr_proc_mac` error: cannot find macro `Dlona!` in this scope --> $DIR/resolve-error.rs:68:5 @@ -56,7 +56,7 @@ error: cannot find macro `bang_proc_macrp!` in this scope --> $DIR/resolve-error.rs:71:5 | 71 | bang_proc_macrp!(); - | ^^^^^^^^^^^^^^^ help: you could try the macro: `bang_proc_macro!` + | ^^^^^^^^^^^^^^^ help: you could try the macro: `bang_proc_macro` error: aborting due to 10 previous errors diff --git a/src/test/ui/macros/macro-name-typo.stderr b/src/test/ui/macros/macro-name-typo.stderr index 84851749c7074..ebe95356c26eb 100644 --- a/src/test/ui/macros/macro-name-typo.stderr +++ b/src/test/ui/macros/macro-name-typo.stderr @@ -2,7 +2,7 @@ error: cannot find macro `printlx!` in this scope --> $DIR/macro-name-typo.rs:12:5 | 12 | printlx!("oh noes!"); //~ ERROR cannot find - | ^^^^^^^ help: you could try the macro: `println!` + | ^^^^^^^ help: you could try the macro: `println` error: aborting due to previous error diff --git a/src/test/ui/macros/macro_undefined.stderr b/src/test/ui/macros/macro_undefined.stderr index 6cfb05e786703..8d6da6a4732fc 100644 --- a/src/test/ui/macros/macro_undefined.stderr +++ b/src/test/ui/macros/macro_undefined.stderr @@ -10,7 +10,7 @@ error: cannot find macro `k!` in this scope --> $DIR/macro_undefined.rs:21:5 | 21 | k!(); //~ ERROR cannot find - | ^ help: you could try the macro: `kl!` + | ^ help: you could try the macro: `kl` error: aborting due to 2 previous errors From f9e1b9c2c2fba742d1c4f6b8ab413ed614ed63d6 Mon Sep 17 00:00:00 2001 From: Christopher Vittal Date: Mon, 15 Jan 2018 11:14:47 -0500 Subject: [PATCH 12/38] Add NLL test for #45045 Closes #45045 --- src/test/ui/nll/borrowed-match-issue-45045.rs | 30 +++++++++++++++++++ .../ui/nll/borrowed-match-issue-45045.stderr | 11 +++++++ 2 files changed, 41 insertions(+) create mode 100644 src/test/ui/nll/borrowed-match-issue-45045.rs create mode 100644 src/test/ui/nll/borrowed-match-issue-45045.stderr diff --git a/src/test/ui/nll/borrowed-match-issue-45045.rs b/src/test/ui/nll/borrowed-match-issue-45045.rs new file mode 100644 index 0000000000000..8688bfa86dc6f --- /dev/null +++ b/src/test/ui/nll/borrowed-match-issue-45045.rs @@ -0,0 +1,30 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Regression test for issue #45045 + +#![feature(nll)] + +enum Xyz { + A, + B, +} + +fn main() { + let mut e = Xyz::A; + let f = &mut e; + let g = f; + match e { + Xyz::A => println!("a"), + //~^ cannot use `e` because it was mutably borrowed [E0503] + Xyz::B => println!("b"), + }; + *g = Xyz::B; +} diff --git a/src/test/ui/nll/borrowed-match-issue-45045.stderr b/src/test/ui/nll/borrowed-match-issue-45045.stderr new file mode 100644 index 0000000000000..15ca30010a55d --- /dev/null +++ b/src/test/ui/nll/borrowed-match-issue-45045.stderr @@ -0,0 +1,11 @@ +error[E0503]: cannot use `e` because it was mutably borrowed + --> $DIR/borrowed-match-issue-45045.rs:25:9 + | +22 | let f = &mut e; + | ------ borrow of `e` occurs here +... +25 | Xyz::A => println!("a"), + | ^^^^^^ use of borrowed `e` + +error: aborting due to previous error + From c698496f8489e471024c60b3b4abc3c405ce7280 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Fri, 12 Jan 2018 16:58:33 -0500 Subject: [PATCH 13/38] Reexport -> re-export in documentation section headings --- src/doc/rustdoc/src/the-doc-attribute.md | 6 +++--- src/librustdoc/html/render.rs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/doc/rustdoc/src/the-doc-attribute.md b/src/doc/rustdoc/src/the-doc-attribute.md index aadd72d1c902d..296422744fa40 100644 --- a/src/doc/rustdoc/src/the-doc-attribute.md +++ b/src/doc/rustdoc/src/the-doc-attribute.md @@ -1,7 +1,7 @@ # The `#[doc]` attribute The `#[doc]` attribute lets you control various aspects of how `rustdoc` does -its job. +its job. The most basic function of `#[doc]` is to handle the actual documentation text. That is, `///` is syntax sugar for `#[doc]`. This means that these two @@ -143,7 +143,7 @@ pub mod bar { } ``` -The documentation will generate a "Reexports" section, and say `pub use bar::Bar;`, where +The documentation will generate a "Re-exports" section, and say `pub use bar::Bar;`, where `Bar` is a link to its page. If we change the `use` line like this: @@ -184,7 +184,7 @@ mod bar { } ``` -Now we'll have a `Reexports` line, and `Bar` will not link to anywhere. +Now we'll have a `Re-exports` line, and `Bar` will not link to anywhere. ## `#[doc(hidden)]` diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 6e4980c9e919b..bf3e37b8dfcc9 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -2059,7 +2059,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context, curty = myty; let (short, name) = match myty.unwrap() { ItemType::ExternCrate | - ItemType::Import => ("reexports", "Reexports"), + ItemType::Import => ("reexports", "Re-exports"), ItemType::Module => ("modules", "Modules"), ItemType::Struct => ("structs", "Structs"), ItemType::Union => ("unions", "Unions"), @@ -3959,7 +3959,7 @@ fn sidebar_module(fmt: &mut fmt::Formatter, _it: &clean::Item, it.type_() == ItemType::Import) { sidebar.push_str(&format!("

  • {name}
  • ", id = "reexports", - name = "Reexports")); + name = "Re-exports")); } // ordering taken from item_module, reorder, where it prioritized elements in a certain order @@ -3972,7 +3972,7 @@ fn sidebar_module(fmt: &mut fmt::Formatter, _it: &clean::Item, if items.iter().any(|it| !it.is_stripped() && it.type_() == myty) { let (short, name) = match myty { ItemType::ExternCrate | - ItemType::Import => ("reexports", "Reexports"), + ItemType::Import => ("reexports", "Re-exports"), ItemType::Module => ("modules", "Modules"), ItemType::Struct => ("structs", "Structs"), ItemType::Union => ("unions", "Unions"), From 90fcd4476c6346fad0aa4a952da0ebec39ff9d4e Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Fri, 12 Jan 2018 16:41:45 -0500 Subject: [PATCH 14/38] Reexport -> re-export in error messages --- src/librustc/lint/builtin.rs | 2 +- src/librustc_resolve/build_reduced_graph.rs | 4 ++-- src/librustc_resolve/diagnostics.rs | 10 +++++----- src/librustc_resolve/lib.rs | 2 +- src/librustc_resolve/resolve_imports.rs | 15 ++++++++------- src/libsyntax/feature_gate.rs | 2 +- .../gated-macro-reexports.rs | 2 +- src/test/compile-fail/E0365.rs | 2 +- src/test/compile-fail/imports/reexports.rs | 8 ++++---- .../issue-46209-private-enum-variant-reexport.rs | 10 +++++----- .../compile-fail/macro-reexport-malformed-1.rs | 2 +- .../compile-fail/macro-reexport-malformed-2.rs | 2 +- .../compile-fail/macro-reexport-malformed-3.rs | 2 +- src/test/compile-fail/macro-reexport-undef.rs | 2 +- .../privacy/legacy-ctor-visibility.rs | 4 +++- src/test/compile-fail/privacy/restricted/test.rs | 2 +- src/test/compile-fail/private-variant-reexport.rs | 8 ++++---- .../pub-reexport-priv-extern-crate.rs | 6 +++--- 18 files changed, 44 insertions(+), 41 deletions(-) diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 7410386c6f45b..143d2c2ea28bb 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -127,7 +127,7 @@ declare_lint! { declare_lint! { pub PUB_USE_OF_PRIVATE_EXTERN_CRATE, Deny, - "detect public reexports of private extern crates" + "detect public re-exports of private extern crates" } declare_lint! { diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index 10bd72ac4a00a..c55bf395d71b3 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -683,7 +683,7 @@ impl<'a> Resolver<'a> { let (def, vis) = (binding.def(), binding.vis); self.macro_exports.push(Export { ident, def, vis, span, is_import: true }); } else { - span_err!(self.session, span, E0470, "reexported macro not found"); + span_err!(self.session, span, E0470, "re-exported macro not found"); } } used @@ -729,7 +729,7 @@ impl<'a> Resolver<'a> { } } else if attr.check_name("macro_reexport") { let bad_macro_reexport = |this: &mut Self, span| { - span_err!(this.session, span, E0467, "bad macro reexport"); + span_err!(this.session, span, E0467, "bad macro re-export"); }; if let Some(names) = attr.meta_item_list() { for attr in names { diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 564626ac39885..3f0f1a1a4cb58 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -1374,7 +1374,7 @@ arguments. "##, E0467: r##" -Macro reexport declarations were empty or malformed. +Macro re-export declarations were empty or malformed. Erroneous code examples: @@ -1389,12 +1389,12 @@ extern crate core as other_macros_for_good; This is a syntax error at the level of attribute declarations. Currently, `macro_reexport` requires at least one macro name to be listed. -Unlike `macro_use`, listing no names does not reexport all macros from the +Unlike `macro_use`, listing no names does not re-export all macros from the given crate. Decide which macros you would like to export and list them properly. -These are proper reexport declarations: +These are proper re-export declarations: ```ignore (cannot-doctest-multicrate-project) #[macro_reexport(some_macro, another_macro)] @@ -1475,7 +1475,7 @@ extern crate some_crate; //ok! "##, E0470: r##" -A macro listed for reexport was not found. +A macro listed for re-export was not found. Erroneous code example: @@ -1493,7 +1493,7 @@ exported from the given crate. This could be caused by a typo. Did you misspell the macro's name? -Double-check the names of the macros listed for reexport, and that the crate +Double-check the names of the macros listed for re-export, and that the crate in question exports them. A working version: diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 0a29441cef7ef..3aedc84052166 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -2751,7 +2751,7 @@ impl<'a> Resolver<'a> { let lint = lint::builtin::LEGACY_CONSTRUCTOR_VISIBILITY; self.session.buffer_lint(lint, id, span, "private struct constructors are not usable through \ - reexports in outer modules", + re-exports in outer modules", ); res = Some(PathResolution::new(ctor_def)); } diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 132119e961bc3..b5a949b30878c 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -803,8 +803,9 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> { if !any_successful_reexport { let (ns, binding) = reexport_error.unwrap(); if ns == TypeNS && binding.is_extern_crate() { - let msg = format!("extern crate `{}` is private, and cannot be reexported \ - (error E0365), consider declaring with `pub`", + let msg = format!("extern crate `{}` is private, and cannot be \ + re-exported (error E0365), consider declaring with \ + `pub`", ident); self.session.buffer_lint(PUB_USE_OF_PRIVATE_EXTERN_CRATE, directive.id, @@ -812,12 +813,12 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> { &msg); } else if ns == TypeNS { struct_span_err!(self.session, directive.span, E0365, - "`{}` is private, and cannot be reexported", ident) - .span_label(directive.span, format!("reexport of private `{}`", ident)) + "`{}` is private, and cannot be re-exported", ident) + .span_label(directive.span, format!("re-export of private `{}`", ident)) .note(&format!("consider declaring type or module `{}` with `pub`", ident)) .emit(); } else { - let msg = format!("`{}` is private, and cannot be reexported", ident); + let msg = format!("`{}` is private, and cannot be re-exported", ident); let note_msg = format!("consider marking `{}` as `pub` in the imported module", ident); struct_span_err!(self.session, directive.span, E0364, "{}", &msg) @@ -932,12 +933,12 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> { !orig_binding.vis.is_at_least(binding.vis, &*self) { let msg = match directive.subclass { ImportDirectiveSubclass::SingleImport { .. } => { - format!("variant `{}` is private and cannot be reexported", + format!("variant `{}` is private and cannot be re-exported", ident) }, ImportDirectiveSubclass::GlobImport { .. } => { let msg = "enum is private and its variants \ - cannot be reexported".to_owned(); + cannot be re-exported".to_owned(); let error_id = (DiagnosticMessageId::ErrorId(0), // no code?! Some(binding.span), msg.clone()); diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 196fadcc997f5..fb0ef2ea730a7 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -1479,7 +1479,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { ast::ItemKind::ExternCrate(_) => { if let Some(attr) = attr::find_by_name(&i.attrs[..], "macro_reexport") { gate_feature_post!(&self, macro_reexport, attr.span, - "macros reexports are experimental \ + "macros re-exports are experimental \ and possibly buggy"); } } diff --git a/src/test/compile-fail-fulldeps/gated-macro-reexports.rs b/src/test/compile-fail-fulldeps/gated-macro-reexports.rs index 2a20c28cfb871..c11f4356176a6 100644 --- a/src/test/compile-fail-fulldeps/gated-macro-reexports.rs +++ b/src/test/compile-fail-fulldeps/gated-macro-reexports.rs @@ -16,6 +16,6 @@ #![crate_type = "dylib"] #[macro_reexport(reexported)] -//~^ ERROR macros reexports are experimental and possibly buggy +//~^ ERROR macros re-exports are experimental and possibly buggy #[macro_use] #[no_link] extern crate macro_reexport_1; diff --git a/src/test/compile-fail/E0365.rs b/src/test/compile-fail/E0365.rs index a1efcde42b05b..18a72b0ff9a55 100644 --- a/src/test/compile-fail/E0365.rs +++ b/src/test/compile-fail/E0365.rs @@ -13,6 +13,6 @@ mod foo { } pub use foo as foo2; -//~^ ERROR `foo` is private, and cannot be reexported [E0365] +//~^ ERROR `foo` is private, and cannot be re-exported [E0365] fn main() {} diff --git a/src/test/compile-fail/imports/reexports.rs b/src/test/compile-fail/imports/reexports.rs index 65e6e8d01b05f..f50b5b0e84999 100644 --- a/src/test/compile-fail/imports/reexports.rs +++ b/src/test/compile-fail/imports/reexports.rs @@ -13,7 +13,7 @@ mod a { mod foo {} mod a { - pub use super::foo; //~ ERROR cannot be reexported + pub use super::foo; //~ ERROR cannot be re-exported pub use super::*; //~ ERROR must import something with the glob's visibility } } @@ -24,17 +24,17 @@ mod b { pub mod a { pub use super::foo; // This is OK since the value `foo` is visible enough. - fn f(_: foo::S) {} // `foo` is imported in the type namespace (but not `pub` reexported). + fn f(_: foo::S) {} // `foo` is imported in the type namespace (but not `pub` re-exported). } pub mod b { pub use super::*; // This is also OK since the value `foo` is visible enough. - fn f(_: foo::S) {} // Again, the module `foo` is imported (but not `pub` reexported). + fn f(_: foo::S) {} // Again, the module `foo` is imported (but not `pub` re-exported). } } mod c { - // Test that `foo` is not reexported. + // Test that `foo` is not re-exported. use b::a::foo::S; //~ ERROR `foo` use b::b::foo::S as T; //~ ERROR `foo` } diff --git a/src/test/compile-fail/issue-46209-private-enum-variant-reexport.rs b/src/test/compile-fail/issue-46209-private-enum-variant-reexport.rs index 5b23e5e815053..f5a20dd96dc90 100644 --- a/src/test/compile-fail/issue-46209-private-enum-variant-reexport.rs +++ b/src/test/compile-fail/issue-46209-private-enum-variant-reexport.rs @@ -12,14 +12,14 @@ mod rank { pub use self::Professor::*; - //~^ ERROR enum is private and its variants cannot be reexported + //~^ ERROR enum is private and its variants cannot be re-exported pub use self::Lieutenant::{JuniorGrade, Full}; - //~^ ERROR variant `JuniorGrade` is private and cannot be reexported - //~| ERROR variant `Full` is private and cannot be reexported + //~^ ERROR variant `JuniorGrade` is private and cannot be re-exported + //~| ERROR variant `Full` is private and cannot be re-exported pub use self::PettyOfficer::*; - //~^ ERROR enum is private and its variants cannot be reexported + //~^ ERROR enum is private and its variants cannot be re-exported pub use self::Crewman::*; - //~^ ERROR enum is private and its variants cannot be reexported + //~^ ERROR enum is private and its variants cannot be re-exported enum Professor { Adjunct, diff --git a/src/test/compile-fail/macro-reexport-malformed-1.rs b/src/test/compile-fail/macro-reexport-malformed-1.rs index a2778a831306b..36a6fce00a13a 100644 --- a/src/test/compile-fail/macro-reexport-malformed-1.rs +++ b/src/test/compile-fail/macro-reexport-malformed-1.rs @@ -12,5 +12,5 @@ #![feature(macro_reexport)] #[allow(unused_extern_crates)] -#[macro_reexport] //~ ERROR bad macro reexport +#[macro_reexport] //~ ERROR bad macro re-export extern crate std; diff --git a/src/test/compile-fail/macro-reexport-malformed-2.rs b/src/test/compile-fail/macro-reexport-malformed-2.rs index c5af9e3799de7..5f741d010de80 100644 --- a/src/test/compile-fail/macro-reexport-malformed-2.rs +++ b/src/test/compile-fail/macro-reexport-malformed-2.rs @@ -12,5 +12,5 @@ #![feature(macro_reexport)] #[allow(unused_extern_crates)] -#[macro_reexport="foo"] //~ ERROR bad macro reexport +#[macro_reexport="foo"] //~ ERROR bad macro re-export extern crate std; diff --git a/src/test/compile-fail/macro-reexport-malformed-3.rs b/src/test/compile-fail/macro-reexport-malformed-3.rs index d72d1ee004ef7..1a7e3b918cd96 100644 --- a/src/test/compile-fail/macro-reexport-malformed-3.rs +++ b/src/test/compile-fail/macro-reexport-malformed-3.rs @@ -12,5 +12,5 @@ #![feature(macro_reexport)] #[allow(unused_extern_crates)] -#[macro_reexport(foo="bar")] //~ ERROR bad macro reexport +#[macro_reexport(foo="bar")] //~ ERROR bad macro re-export extern crate std; diff --git a/src/test/compile-fail/macro-reexport-undef.rs b/src/test/compile-fail/macro-reexport-undef.rs index 5bb0b8759f486..50ac89e49e08f 100644 --- a/src/test/compile-fail/macro-reexport-undef.rs +++ b/src/test/compile-fail/macro-reexport-undef.rs @@ -13,7 +13,7 @@ #![feature(macro_reexport)] #[macro_use(macro_two)] -#[macro_reexport(no_way)] //~ ERROR reexported macro not found +#[macro_reexport(no_way)] //~ ERROR re-exported macro not found extern crate two_macros; pub fn main() { diff --git a/src/test/compile-fail/privacy/legacy-ctor-visibility.rs b/src/test/compile-fail/privacy/legacy-ctor-visibility.rs index fb65af230ace5..95144916fd785 100644 --- a/src/test/compile-fail/privacy/legacy-ctor-visibility.rs +++ b/src/test/compile-fail/privacy/legacy-ctor-visibility.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-tidy-linelength + #![allow(unused)] use m::S; @@ -19,7 +21,7 @@ mod m { use S; fn f() { S(10); - //~^ ERROR private struct constructors are not usable through reexports in outer modules + //~^ ERROR private struct constructors are not usable through re-exports in outer modules //~| WARN this was previously accepted } } diff --git a/src/test/compile-fail/privacy/restricted/test.rs b/src/test/compile-fail/privacy/restricted/test.rs index 7f076ebf287e2..8c1d609e24467 100644 --- a/src/test/compile-fail/privacy/restricted/test.rs +++ b/src/test/compile-fail/privacy/restricted/test.rs @@ -28,7 +28,7 @@ mod foo { fn f() { use foo::bar::S; pub(self) use foo::bar::f; // ok - pub(super) use foo::bar::f as g; //~ ERROR cannot be reexported + pub(super) use foo::bar::f as g; //~ ERROR cannot be re-exported S::default().x; // ok S::default().f(); // ok S::g(); // ok diff --git a/src/test/compile-fail/private-variant-reexport.rs b/src/test/compile-fail/private-variant-reexport.rs index 1280aba3076ab..5d770f88155ec 100644 --- a/src/test/compile-fail/private-variant-reexport.rs +++ b/src/test/compile-fail/private-variant-reexport.rs @@ -9,19 +9,19 @@ // except according to those terms. mod m1 { - pub use ::E::V; //~ ERROR variant `V` is private and cannot be reexported + pub use ::E::V; //~ ERROR variant `V` is private and cannot be re-exported } mod m2 { - pub use ::E::{V}; //~ ERROR variant `V` is private and cannot be reexported + pub use ::E::{V}; //~ ERROR variant `V` is private and cannot be re-exported } mod m3 { - pub use ::E::V::{self}; //~ ERROR variant `V` is private and cannot be reexported + pub use ::E::V::{self}; //~ ERROR variant `V` is private and cannot be re-exported } mod m4 { - pub use ::E::*; //~ ERROR enum is private and its variants cannot be reexported + pub use ::E::*; //~ ERROR enum is private and its variants cannot be re-exported } enum E { V } diff --git a/src/test/compile-fail/pub-reexport-priv-extern-crate.rs b/src/test/compile-fail/pub-reexport-priv-extern-crate.rs index 5479be54533e0..2e71e007e9eed 100644 --- a/src/test/compile-fail/pub-reexport-priv-extern-crate.rs +++ b/src/test/compile-fail/pub-reexport-priv-extern-crate.rs @@ -11,7 +11,7 @@ #![allow(unused)] extern crate core; -pub use core as reexported_core; //~ ERROR `core` is private, and cannot be reexported +pub use core as reexported_core; //~ ERROR `core` is private, and cannot be re-exported //~^ WARN this was previously accepted mod foo1 { @@ -19,7 +19,7 @@ mod foo1 { } mod foo2 { - use foo1::core; //~ ERROR `core` is private, and cannot be reexported + use foo1::core; //~ ERROR `core` is private, and cannot be re-exported //~^ WARN this was previously accepted pub mod bar { extern crate core; @@ -27,7 +27,7 @@ mod foo2 { } mod baz { - pub use foo2::bar::core; //~ ERROR `core` is private, and cannot be reexported + pub use foo2::bar::core; //~ ERROR `core` is private, and cannot be re-exported //~^ WARN this was previously accepted } From e168aa385b9afb6c84071a09910724bdde3dfc5f Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Fri, 12 Jan 2018 16:41:25 -0500 Subject: [PATCH 15/38] Reexport -> re-export in prose and documentation comments --- RELEASES.md | 14 +++++++------- src/liballoc/lib.rs | 4 ++-- src/libcore/prelude/v1.rs | 8 ++++---- src/libcore/slice/mod.rs | 2 +- src/librustc/hir/lowering.rs | 2 +- src/librustc/middle/privacy.rs | 4 ++-- src/librustc_metadata/decoder.rs | 4 ++-- src/librustc_privacy/lib.rs | 4 ++-- src/librustc_resolve/resolve_imports.rs | 6 +++--- src/librustdoc/clean/inline.rs | 6 +++--- src/librustdoc/html/render.rs | 8 ++++---- src/librustdoc/visit_ast.rs | 4 ++-- src/libstd/lib.rs | 6 +++--- src/libstd/prelude/mod.rs | 2 +- src/libstd/prelude/v1.rs | 6 +++--- src/libstd/rt.rs | 2 +- src/libstd_unicode/char.rs | 4 ++-- src/libsyntax/ext/build.rs | 2 +- src/libsyntax/feature_gate.rs | 2 +- .../compile-fail-fulldeps/gated-macro-reexports.rs | 2 +- .../auxiliary/static_priv_by_default.rs | 2 +- src/test/compile-fail/lint-unused-extern-crate.rs | 2 +- .../type-mismatch-same-crate-name/crateC.rs | 2 +- src/test/run-pass/unboxed-closures-prelude.rs | 2 +- .../auxiliary/rustdoc-nonreachable-impls.rs | 2 +- src/test/ui/issue-46112.rs | 2 +- 26 files changed, 52 insertions(+), 52 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index a4e6f22ba3db4..45c389d72afc7 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -577,7 +577,7 @@ Compatibility Notes a warning. - [From the pound escape, lines consisting of multiple `#`s are now visible][41785] -- [It is an error to reexport private enum variants][42460]. This is +- [It is an error to re-export private enum variants][42460]. This is known to break a number of crates that depend on an older version of mustache. - [On Windows, if `VCINSTALLDIR` is set incorrectly, `rustc` will try @@ -2251,10 +2251,10 @@ Rustdoc ------- * [Fix empty implementation section on some module pages](https://github.com/rust-lang/rust/pull/34536) -* [Fix inlined renamed reexports in import lists](https://github.com/rust-lang/rust/pull/34479) +* [Fix inlined renamed re-exports in import lists](https://github.com/rust-lang/rust/pull/34479) * [Fix search result layout for enum variants and struct fields](https://github.com/rust-lang/rust/pull/34477) * [Fix issues with source links to external crates](https://github.com/rust-lang/rust/pull/34387) -* [Fix redirect pages for renamed reexports](https://github.com/rust-lang/rust/pull/34245) +* [Fix redirect pages for renamed re-exports](https://github.com/rust-lang/rust/pull/34245) Tooling ------- @@ -4988,7 +4988,7 @@ Version 0.10 (2014-04-03) * std: The `vec` module has been renamed to `slice`. * std: A new vector type, `Vec`, has been added in preparation for DST. This will become the only growable vector in the future. - * std: `std::io` now has more public-reexports. Types such as `BufferedReader` + * std: `std::io` now has more public re-exports. Types such as `BufferedReader` are now found at `std::io::BufferedReader` instead of `std::io::buffered::BufferedReader`. * std: `print` and `println` are no longer in the prelude, the `print!` and @@ -5079,8 +5079,8 @@ Version 0.10 (2014-04-03) * render standalone markdown files. * the --test flag tests all code blocks by default. * exported macros are displayed. - * reexported types have their documentation inlined at the location of the - first reexport. + * re-exported types have their documentation inlined at the location of the + first re-export. * search works across crates that have been rendered to the same output directory. @@ -5467,7 +5467,7 @@ Version 0.7 (2013-07-03) incl. `any`, `all`. removed. * std: The `finalize` method of `Drop` renamed to `drop`. * std: The `drop` method now takes `&mut self` instead of `&self`. - * std: The prelude no longer reexports any modules, only types and traits. + * std: The prelude no longer re-exports any modules, only types and traits. * std: Prelude additions: `print`, `println`, `FromStr`, `ApproxEq`, `Equiv`, `Iterator`, `IteratorUtil`, many numeric traits, many tuple traits. * std: New numeric traits: `Fractional`, `Real`, `RealExt`, `Integer`, `Ratio`, diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index d8ce28695ab6f..6ee4f802802ab 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -15,7 +15,7 @@ //! //! This library, like libcore, is not intended for general usage, but rather as //! a building block of other libraries. The types and interfaces in this -//! library are reexported through the [standard library](../std/index.html), +//! library are re-exported through the [standard library](../std/index.html), //! and should not be used through this library. //! //! ## Boxed values @@ -52,7 +52,7 @@ //! ## Collections //! //! Implementations of the most common general purpose data structures are -//! defined in this library. They are reexported through the +//! defined in this library. They are re-exported through the //! [standard collections library](../std/collections/index.html). //! //! ## Heap interfaces diff --git a/src/libcore/prelude/v1.rs b/src/libcore/prelude/v1.rs index 3fa6a97d4cd15..d43496c387cb8 100644 --- a/src/libcore/prelude/v1.rs +++ b/src/libcore/prelude/v1.rs @@ -16,7 +16,7 @@ #![stable(feature = "core_prelude", since = "1.4.0")] -// Reexported core operators +// Re-exported core operators #[stable(feature = "core_prelude", since = "1.4.0")] #[doc(no_inline)] pub use marker::{Copy, Send, Sized, Sync}; @@ -24,12 +24,12 @@ pub use marker::{Copy, Send, Sized, Sync}; #[doc(no_inline)] pub use ops::{Drop, Fn, FnMut, FnOnce}; -// Reexported functions +// Re-exported functions #[stable(feature = "core_prelude", since = "1.4.0")] #[doc(no_inline)] pub use mem::drop; -// Reexported types and traits +// Re-exported types and traits #[stable(feature = "core_prelude", since = "1.4.0")] #[doc(no_inline)] pub use clone::Clone; @@ -55,7 +55,7 @@ pub use option::Option::{self, Some, None}; #[doc(no_inline)] pub use result::Result::{self, Ok, Err}; -// Reexported extension traits for primitive types +// Re-exported extension traits for primitive types #[stable(feature = "core_prelude", since = "1.4.0")] #[doc(no_inline)] pub use slice::SliceExt; diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 48e82666d3515..281d8e5ddadb9 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -22,7 +22,7 @@ // a lot of stuff defined here. Let's keep it clean. // // Since slices don't support inherent methods; all operations -// on them are defined on traits, which are then reexported from +// on them are defined on traits, which are then re-exported from // the prelude for convenience. So there are a lot of traits here. // // The layout of this file is thus: diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 1af7bd46ad413..238145a061f55 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -2119,7 +2119,7 @@ impl<'a> LoweringContext<'a> { // Privatize the degenerate import base, used only to check // the stability of `use a::{};`, to avoid it showing up as - // a reexport by accident when `pub`, e.g. in documentation. + // a re-export by accident when `pub`, e.g. in documentation. let path = P(self.lower_path(id, &prefix, ParamMode::Explicit, true)); *vis = hir::Inherited; hir::ItemUse(path, hir::UseKind::ListStem) diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs index 1376886968f74..e2de0b6bd013d 100644 --- a/src/librustc/middle/privacy.rs +++ b/src/librustc/middle/privacy.rs @@ -26,9 +26,9 @@ pub enum AccessLevel { // public, then type `T` is reachable. Its values can be obtained by other crates // even if the type itself is not nameable. Reachable, - // Public items + items accessible to other crates with help of `pub use` reexports + // Public items + items accessible to other crates with help of `pub use` re-exports Exported, - // Items accessible to other crates directly, without help of reexports + // Items accessible to other crates directly, without help of re-exports Public, } diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index bd63396cd35ab..06728b2e6257c 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -702,8 +702,8 @@ impl<'a, 'tcx> CrateMetadata { let vis = self.get_visibility(child_index); let is_import = false; callback(def::Export { def, ident, vis, span, is_import }); - // For non-reexport structs and variants add their constructors to children. - // Reexport lists automatically contain constructors when necessary. + // For non-re-export structs and variants add their constructors to children. + // Re-export lists automatically contain constructors when necessary. match def { Def::Struct(..) => { if let Some(ctor_def_id) = self.get_struct_ctor_def_id(child_index) { diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index b525ab852a7e5..b46882f054df9 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -219,7 +219,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> { hir::ItemExternCrate(..) => {} // All nested items are checked by visit_item hir::ItemMod(..) => {} - // Reexports are handled in visit_mod + // Re-exports are handled in visit_mod hir::ItemUse(..) => {} // The interface is empty hir::ItemGlobalAsm(..) => {} @@ -1049,7 +1049,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> { fn visit_item(&mut self, item: &'tcx hir::Item) { match item.node { - // contents of a private mod can be reexported, so we need + // contents of a private mod can be re-exported, so we need // to check internals. hir::ItemMod(_) => {} diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index b5a949b30878c..31f3493010c3a 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -46,8 +46,8 @@ pub enum ImportDirectiveSubclass<'a> { }, GlobImport { is_prelude: bool, - max_vis: Cell, // The visibility of the greatest reexport. - // n.b. `max_vis` is only used in `finalize_import` to check for reexport errors. + max_vis: Cell, // The visibility of the greatest re-export. + // n.b. `max_vis` is only used in `finalize_import` to check for re-export errors. }, ExternCrate(Option), MacroUse, @@ -877,7 +877,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> { self.record_def(directive.id, PathResolution::new(module.def().unwrap())); } - // Miscellaneous post-processing, including recording reexports, + // Miscellaneous post-processing, including recording re-exports, // reporting conflicts, and reporting unresolved imports. fn finalize_resolutions_in(&mut self, module: Module<'b>) { // Since import resolution is finished, globs will not define any more names. diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 496389da7f2f1..d284757df63fa 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -82,9 +82,9 @@ pub fn try_inline(cx: &DocContext, def: Def, name: ast::Name) ret.extend(build_impls(cx, did)); clean::ForeignTypeItem } - // Never inline enum variants but leave them shown as reexports. + // Never inline enum variants but leave them shown as re-exports. Def::Variant(..) => return None, - // Assume that enum variants and struct types are reexported next to + // Assume that enum variants and struct types are re-exported next to // their constructors. Def::VariantCtor(..) | Def::StructCtor(..) => return Some(Vec::new()), @@ -365,7 +365,7 @@ fn build_module(cx: &DocContext, did: DefId) -> clean::Module { }; fn fill_in(cx: &DocContext, did: DefId, items: &mut Vec) { - // If we're reexporting a reexport it may actually reexport something in + // If we're re-exporting a re-export it may actually re-export something in // two namespaces, so the target may be listed twice. Make sure we only // visit each node at most once. let mut visited = FxHashSet(); diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index bf3e37b8dfcc9..2293e31b5794d 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -1286,9 +1286,9 @@ impl DocFolder for Cache { clean::ConstantItem(..) | clean::StaticItem(..) | clean::UnionItem(..) | clean::ForeignTypeItem if !self.stripped_mod => { - // Reexported items mean that the same id can show up twice + // Re-exported items mean that the same id can show up twice // in the rustdoc ast that we're looking at. We know, - // however, that a reexported item doesn't show up in the + // however, that a re-exported item doesn't show up in the // `public_items` map, so we can skip inserting into the // paths map if there was already an entry present and we're // not a public item. @@ -1545,7 +1545,7 @@ impl Context { { // Stripped modules survive the rustdoc passes (i.e. `strip-private`) // if they contain impls for public types. These modules can also - // contain items such as publicly reexported structures. + // contain items such as publicly re-exported structures. // // External crates will provide links to these structures, so // these modules are recursed into, but not rendered normally @@ -2008,7 +2008,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context, if cx.shared.sort_modules_alphabetically { indices.sort_by(|&i1, &i2| cmp(&items[i1], &items[i2], i1, i2)); } - // This call is to remove reexport duplicates in cases such as: + // This call is to remove re-export duplicates in cases such as: // // ``` // pub mod foo { diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index 95531b468f41e..1cb52d735bb18 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -55,7 +55,7 @@ pub struct RustdocVisitor<'a, 'tcx: 'a> { impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { pub fn new(cstore: &'tcx CrateStore, cx: &'a core::DocContext<'a, 'tcx>) -> RustdocVisitor<'a, 'tcx> { - // If the root is reexported, terminate all recursion. + // If the root is re-exported, terminate all recursion. let mut stack = FxHashSet(); stack.insert(ast::CRATE_NODE_ID); RustdocVisitor { @@ -214,7 +214,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { let imported_from = self.cx.tcx.original_crate_name(def_id.krate); let def = match self.cstore.load_macro_untracked(def_id, self.cx.sess()) { LoadedMacro::MacroDef(macro_def) => macro_def, - // FIXME(jseyfried): document proc macro reexports + // FIXME(jseyfried): document proc macro re-exports LoadedMacro::ProcMacro(..) => continue, }; diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 28040bc20e2e0..bb38fc550917f 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -351,9 +351,9 @@ use prelude::v1::*; #[cfg(test)] extern crate test; #[cfg(test)] extern crate rand; -// We want to reexport a few macros from core but libcore has already been +// We want to re-export a few macros from core but libcore has already been // imported by the compiler (via our #[no_std] attribute) In this case we just -// add a new crate name so we can attach the reexports to it. +// add a new crate name so we can attach the re-exports to it. #[macro_reexport(assert, assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, unreachable, unimplemented, write, writeln, try)] extern crate core as __core; @@ -390,7 +390,7 @@ mod macros; // The Rust prelude pub mod prelude; -// Public module declarations and reexports +// Public module declarations and re-exports #[stable(feature = "rust1", since = "1.0.0")] pub use core::any; #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libstd/prelude/mod.rs b/src/libstd/prelude/mod.rs index 538753d86923e..919e033f2b4bd 100644 --- a/src/libstd/prelude/mod.rs +++ b/src/libstd/prelude/mod.rs @@ -52,7 +52,7 @@ //! # Prelude contents //! //! The current version of the prelude (version 1) lives in -//! [`std::prelude::v1`], and reexports the following. +//! [`std::prelude::v1`], and re-exports the following. //! //! * [`std::marker`]::{[`Copy`], [`Send`], [`Sized`], [`Sync`]}. The marker //! traits indicate fundamental properties of types. diff --git a/src/libstd/prelude/v1.rs b/src/libstd/prelude/v1.rs index 9ca5b445c86a9..feedd4e1abe5f 100644 --- a/src/libstd/prelude/v1.rs +++ b/src/libstd/prelude/v1.rs @@ -14,17 +14,17 @@ #![stable(feature = "rust1", since = "1.0.0")] -// Reexported core operators +// Re-exported core operators #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] pub use marker::{Copy, Send, Sized, Sync}; #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] pub use ops::{Drop, Fn, FnMut, FnOnce}; -// Reexported functions +// Re-exported functions #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] pub use mem::drop; -// Reexported types and traits +// Re-exported types and traits #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] pub use boxed::Box; #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libstd/rt.rs b/src/libstd/rt.rs index af414d25b5f94..9dbaf784f89e0 100644 --- a/src/libstd/rt.rs +++ b/src/libstd/rt.rs @@ -23,7 +23,7 @@ #![doc(hidden)] -// Reexport some of our utilities which are expected by other crates. +// Re-export some of our utilities which are expected by other crates. pub use panicking::{begin_panic, begin_panic_fmt, update_panic_count}; // To reduce the generated code of the new `lang_start`, this function is doing diff --git a/src/libstd_unicode/char.rs b/src/libstd_unicode/char.rs index c1daf6439868f..b4be4a9691183 100644 --- a/src/libstd_unicode/char.rs +++ b/src/libstd_unicode/char.rs @@ -33,7 +33,7 @@ use core::iter::FusedIterator; use core::fmt::{self, Write}; use tables::{conversions, derived_property, general_category, property}; -// stable reexports +// stable re-exports #[stable(feature = "rust1", since = "1.0.0")] pub use core::char::{MAX, from_digit, from_u32, from_u32_unchecked}; #[stable(feature = "rust1", since = "1.0.0")] @@ -41,7 +41,7 @@ pub use core::char::{EscapeDebug, EscapeDefault, EscapeUnicode}; #[stable(feature = "char_from_str", since = "1.20.0")] pub use core::char::ParseCharError; -// unstable reexports +// unstable re-exports #[unstable(feature = "try_from", issue = "33417")] pub use core::char::CharTryFromError; #[unstable(feature = "decode_utf8", issue = "33906")] diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index be0bfd6677bd8..7f7ff56fd7fbe 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -17,7 +17,7 @@ use ext::base::ExtCtxt; use ptr::P; use symbol::{Symbol, keywords}; -// Transitional reexports so qquote can find the paths it is looking for +// Transitional re-exports so qquote can find the paths it is looking for mod syntax { pub use ext; pub use parse; diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index fb0ef2ea730a7..0c4bcf4f6c766 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -155,7 +155,7 @@ declare_features! ( // OIBIT specific features (active, optin_builtin_traits, "1.0.0", Some(13231)), - // macro reexport needs more discussion and stabilization + // macro re-export needs more discussion and stabilization (active, macro_reexport, "1.0.0", Some(29638)), // Allows use of #[staged_api] diff --git a/src/test/compile-fail-fulldeps/gated-macro-reexports.rs b/src/test/compile-fail-fulldeps/gated-macro-reexports.rs index c11f4356176a6..8b448e401bd25 100644 --- a/src/test/compile-fail-fulldeps/gated-macro-reexports.rs +++ b/src/test/compile-fail-fulldeps/gated-macro-reexports.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Test that macro reexports item are gated by `macro_reexport` feature gate. +// Test that macro re-exports item are gated by `macro_reexport` feature gate. // aux-build:macro_reexport_1.rs // gate-test-macro_reexport diff --git a/src/test/compile-fail/auxiliary/static_priv_by_default.rs b/src/test/compile-fail/auxiliary/static_priv_by_default.rs index 859f38e809f91..73597e51f0802 100644 --- a/src/test/compile-fail/auxiliary/static_priv_by_default.rs +++ b/src/test/compile-fail/auxiliary/static_priv_by_default.rs @@ -32,7 +32,7 @@ mod foo { fn foo() {} } - // these are public so the parent can reexport them. + // these are public so the parent can re-export them. pub static reexported_a: isize = 0; pub fn reexported_b() {} pub struct reexported_c; diff --git a/src/test/compile-fail/lint-unused-extern-crate.rs b/src/test/compile-fail/lint-unused-extern-crate.rs index a3cfa1349831d..8f0b53fd59971 100644 --- a/src/test/compile-fail/lint-unused-extern-crate.rs +++ b/src/test/compile-fail/lint-unused-extern-crate.rs @@ -20,7 +20,7 @@ extern crate lint_unused_extern_crate5; //~ ERROR: unused extern crate -pub extern crate lint_unused_extern_crate4; // no error, it is reexported +pub extern crate lint_unused_extern_crate4; // no error, it is re-exported extern crate lint_unused_extern_crate3; // no error, it is used diff --git a/src/test/run-make/type-mismatch-same-crate-name/crateC.rs b/src/test/run-make/type-mismatch-same-crate-name/crateC.rs index da869d2145fe1..210bc4c8320c5 100644 --- a/src/test/run-make/type-mismatch-same-crate-name/crateC.rs +++ b/src/test/run-make/type-mismatch-same-crate-name/crateC.rs @@ -18,7 +18,7 @@ // compile-fail/type-mismatch-same-crate-name.rs // but deals with the case where one of the crates // is only introduced as an indirect dependency. -// and the type is accessed via a reexport. +// and the type is accessed via a re-export. // This is similar to how the error can be introduced // when using cargo's automatic dependency resolution. diff --git a/src/test/run-pass/unboxed-closures-prelude.rs b/src/test/run-pass/unboxed-closures-prelude.rs index b7835324010cf..f82b04f37c502 100644 --- a/src/test/run-pass/unboxed-closures-prelude.rs +++ b/src/test/run-pass/unboxed-closures-prelude.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Tests that the reexports of `FnOnce` et al from the prelude work. +// Tests that the re-exports of `FnOnce` et al from the prelude work. // pretty-expanded FIXME #23616 diff --git a/src/test/rustdoc/inline_cross/auxiliary/rustdoc-nonreachable-impls.rs b/src/test/rustdoc/inline_cross/auxiliary/rustdoc-nonreachable-impls.rs index 22a311d579745..5fee36959c23d 100644 --- a/src/test/rustdoc/inline_cross/auxiliary/rustdoc-nonreachable-impls.rs +++ b/src/test/rustdoc/inline_cross/auxiliary/rustdoc-nonreachable-impls.rs @@ -36,7 +36,7 @@ pub mod hidden { pub struct Wobble; - // these should only be shown if they're reexported correctly + // these should only be shown if they're re-exported correctly impl Qux for ::Foo {} impl Qux for Wobble {} impl ::Bark for Wobble {} diff --git a/src/test/ui/issue-46112.rs b/src/test/ui/issue-46112.rs index c292f73bf0b23..698005b5d3068 100644 --- a/src/test/ui/issue-46112.rs +++ b/src/test/ui/issue-46112.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Issue 46112: An extern crate pub reexporting libcore was causing +// Issue 46112: An extern crate pub re-exporting libcore was causing // paths rooted from `std` to be misrendered in the diagnostic output. // ignore-windows From dc44d41b984610406af00dc60d8e1903c9a6751b Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Mon, 15 Jan 2018 23:57:44 +0200 Subject: [PATCH 16/38] remove noop landing pads in cleanup shims These are already removed in the normal optimization pipeline - so this should slightly improve codegen performance, as these cleanup blocks are known to hurt LLVM. This un-regresses and is therefore a fix for #47442. However, the reporter of that issue should try using `-C panic=abort` instead of carefully avoiding panics. --- src/librustc_mir/shim.rs | 3 +- .../transform/remove_noop_landing_pads.rs | 19 +++++++---- src/test/codegen/issue-47442.rs | 32 +++++++++++++++++++ 3 files changed, 47 insertions(+), 7 deletions(-) create mode 100644 src/test/codegen/issue-47442.rs diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index 89e3e7e0b6027..c206d0ea9b5fd 100644 --- a/src/librustc_mir/shim.rs +++ b/src/librustc_mir/shim.rs @@ -28,7 +28,7 @@ use std::fmt; use std::iter; use transform::{add_moves_for_packed_drops, add_call_guards}; -use transform::{no_landing_pads, simplify}; +use transform::{remove_noop_landing_pads, no_landing_pads, simplify}; use util::elaborate_drops::{self, DropElaborator, DropStyle, DropFlagMode}; use util::patch::MirPatch; @@ -118,6 +118,7 @@ fn make_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, add_moves_for_packed_drops::add_moves_for_packed_drops( tcx, &mut result, instance.def_id()); no_landing_pads::no_landing_pads(tcx, &mut result); + remove_noop_landing_pads::remove_noop_landing_pads(tcx, &mut result); simplify::simplify_cfg(&mut result); add_call_guards::CriticalCallEdges.add_call_guards(&mut result); debug!("make_shim({:?}) = {:?}", instance, result); diff --git a/src/librustc_mir/transform/remove_noop_landing_pads.rs b/src/librustc_mir/transform/remove_noop_landing_pads.rs index 23274cdedf2c7..e7cab469bc222 100644 --- a/src/librustc_mir/transform/remove_noop_landing_pads.rs +++ b/src/librustc_mir/transform/remove_noop_landing_pads.rs @@ -20,17 +20,24 @@ use util::patch::MirPatch; /// code for these. pub struct RemoveNoopLandingPads; +pub fn remove_noop_landing_pads<'a, 'tcx>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + mir: &mut Mir<'tcx>) +{ + if tcx.sess.no_landing_pads() { + return + } + debug!("remove_noop_landing_pads({:?})", mir); + + RemoveNoopLandingPads.remove_nop_landing_pads(mir) +} + impl MirPass for RemoveNoopLandingPads { fn run_pass<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, _src: MirSource, mir: &mut Mir<'tcx>) { - if tcx.sess.no_landing_pads() { - return - } - - debug!("remove_noop_landing_pads({:?})", mir); - self.remove_nop_landing_pads(mir); + remove_noop_landing_pads(tcx, mir); } } diff --git a/src/test/codegen/issue-47442.rs b/src/test/codegen/issue-47442.rs new file mode 100644 index 0000000000000..d0c9932e4e20f --- /dev/null +++ b/src/test/codegen/issue-47442.rs @@ -0,0 +1,32 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// check that we don't emit unneeded `resume` cleanup blocks for every +// destructor. + +// CHECK-NOT: Unwind + +#![feature(test)] +#![crate_type="rlib"] + +extern crate test; + +struct Foo {} + +impl Drop for Foo { + fn drop(&mut self) { + test::black_box(()); + } +} + +#[no_mangle] +pub fn foo() { + let _foo = Foo {}; +} From bfde33f2fb00864302d034e91cd40f17d43ce961 Mon Sep 17 00:00:00 2001 From: Segev Finer Date: Tue, 16 Jan 2018 07:27:04 +0200 Subject: [PATCH 17/38] Add "-lmsvcrt" twice to get rustc to build with the latest mingw64 --- src/librustc_back/target/windows_base.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/librustc_back/target/windows_base.rs b/src/librustc_back/target/windows_base.rs index e6aa745d54e9d..7a901dc913f94 100644 --- a/src/librustc_back/target/windows_base.rs +++ b/src/librustc_back/target/windows_base.rs @@ -59,6 +59,7 @@ pub fn opts() -> TargetOptions { "-lmingw32".to_string(), "-lgcc".to_string(), // alas, mingw* libraries above depend on libgcc "-lmsvcrt".to_string(), + "-lmsvcrt".to_string(), // mingw is insane...? "-luser32".to_string(), "-lkernel32".to_string(), ]); From a4660dfea230638dea504c24ca67b49a1d67e1a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 15 Jan 2018 21:38:12 -0800 Subject: [PATCH 18/38] Point at unused arguments for format string Avoid overlapping spans by only pointing at the arguments that are not being used in the argument string. Enable libsyntax to have diagnostics with multiple primary spans by accepting `Into` instead of `Span`. --- src/libsyntax/ext/base.rs | 38 ++++++------- src/libsyntax/parse/parser.rs | 25 +++++---- src/libsyntax_ext/format.rs | 12 +---- src/test/ui/macros/format-foreign.rs | 2 +- src/test/ui/macros/format-foreign.stderr | 11 ++-- src/test/ui/macros/format-unused-lables.rs | 5 +- .../ui/macros/format-unused-lables.stderr | 53 +++++++------------ 7 files changed, 62 insertions(+), 84 deletions(-) diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 0d3be28ffefe5..612d8501fb2af 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -13,7 +13,7 @@ pub use self::SyntaxExtension::*; use ast::{self, Attribute, Name, PatKind, MetaItem}; use attr::HasAttrs; use codemap::{self, CodeMap, Spanned, respan}; -use syntax_pos::{Span, DUMMY_SP}; +use syntax_pos::{Span, MultiSpan, DUMMY_SP}; use errors::DiagnosticBuilder; use ext::expand::{self, Expansion, Invocation}; use ext::hygiene::{Mark, SyntaxContext}; @@ -754,22 +754,22 @@ impl<'a> ExtCtxt<'a> { last_macro } - pub fn struct_span_warn(&self, - sp: Span, - msg: &str) - -> DiagnosticBuilder<'a> { + pub fn struct_span_warn>(&self, + sp: S, + msg: &str) + -> DiagnosticBuilder<'a> { self.parse_sess.span_diagnostic.struct_span_warn(sp, msg) } - pub fn struct_span_err(&self, - sp: Span, - msg: &str) - -> DiagnosticBuilder<'a> { + pub fn struct_span_err>(&self, + sp: S, + msg: &str) + -> DiagnosticBuilder<'a> { self.parse_sess.span_diagnostic.struct_span_err(sp, msg) } - pub fn struct_span_fatal(&self, - sp: Span, - msg: &str) - -> DiagnosticBuilder<'a> { + pub fn struct_span_fatal>(&self, + sp: S, + msg: &str) + -> DiagnosticBuilder<'a> { self.parse_sess.span_diagnostic.struct_span_fatal(sp, msg) } @@ -785,7 +785,7 @@ impl<'a> ExtCtxt<'a> { /// in most cases one can construct a dummy expression/item to /// substitute; we never hit resolve/type-checking so the dummy /// value doesn't have to match anything) - pub fn span_fatal(&self, sp: Span, msg: &str) -> ! { + pub fn span_fatal>(&self, sp: S, msg: &str) -> ! { panic!(self.parse_sess.span_diagnostic.span_fatal(sp, msg)); } @@ -794,20 +794,20 @@ impl<'a> ExtCtxt<'a> { /// /// Compilation will be stopped in the near future (at the end of /// the macro expansion phase). - pub fn span_err(&self, sp: Span, msg: &str) { + pub fn span_err>(&self, sp: S, msg: &str) { self.parse_sess.span_diagnostic.span_err(sp, msg); } - pub fn mut_span_err(&self, sp: Span, msg: &str) + pub fn mut_span_err>(&self, sp: S, msg: &str) -> DiagnosticBuilder<'a> { self.parse_sess.span_diagnostic.mut_span_err(sp, msg) } - pub fn span_warn(&self, sp: Span, msg: &str) { + pub fn span_warn>(&self, sp: S, msg: &str) { self.parse_sess.span_diagnostic.span_warn(sp, msg); } - pub fn span_unimpl(&self, sp: Span, msg: &str) -> ! { + pub fn span_unimpl>(&self, sp: S, msg: &str) -> ! { self.parse_sess.span_diagnostic.span_unimpl(sp, msg); } - pub fn span_bug(&self, sp: Span, msg: &str) -> ! { + pub fn span_bug>(&self, sp: S, msg: &str) -> ! { self.parse_sess.span_diagnostic.span_bug(sp, msg); } pub fn trace_macros_diag(&mut self) { diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index e7565d357397c..3d58104260f9a 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -42,7 +42,7 @@ use ast::{BinOpKind, UnOp}; use ast::{RangeEnd, RangeSyntax}; use {ast, attr}; use codemap::{self, CodeMap, Spanned, respan}; -use syntax_pos::{self, Span, BytePos, FileName, DUMMY_SP}; +use syntax_pos::{self, Span, MultiSpan, BytePos, FileName, DUMMY_SP}; use errors::{self, DiagnosticBuilder}; use parse::{self, classify, token}; use parse::common::SeqSep; @@ -447,7 +447,9 @@ pub enum Error { } impl Error { - pub fn span_err(self, sp: Span, handler: &errors::Handler) -> DiagnosticBuilder { + pub fn span_err>(self, + sp: S, + handler: &errors::Handler) -> DiagnosticBuilder { match self { Error::FileNotFoundForModule { ref mod_name, ref default_path, @@ -1266,13 +1268,16 @@ impl<'a> Parser<'a> { pub fn fatal(&self, m: &str) -> DiagnosticBuilder<'a> { self.sess.span_diagnostic.struct_span_fatal(self.span, m) } - pub fn span_fatal(&self, sp: Span, m: &str) -> DiagnosticBuilder<'a> { + pub fn span_fatal>(&self, sp: S, m: &str) -> DiagnosticBuilder<'a> { self.sess.span_diagnostic.struct_span_fatal(sp, m) } - pub fn span_fatal_err(&self, sp: Span, err: Error) -> DiagnosticBuilder<'a> { + pub fn span_fatal_err>(&self, sp: S, err: Error) -> DiagnosticBuilder<'a> { err.span_err(sp, self.diagnostic()) } - pub fn span_fatal_help(&self, sp: Span, m: &str, help: &str) -> DiagnosticBuilder<'a> { + pub fn span_fatal_help>(&self, + sp: S, + m: &str, + help: &str) -> DiagnosticBuilder<'a> { let mut err = self.sess.span_diagnostic.struct_span_fatal(sp, m); err.help(help); err @@ -1283,21 +1288,21 @@ impl<'a> Parser<'a> { pub fn warn(&self, m: &str) { self.sess.span_diagnostic.span_warn(self.span, m) } - pub fn span_warn(&self, sp: Span, m: &str) { + pub fn span_warn>(&self, sp: S, m: &str) { self.sess.span_diagnostic.span_warn(sp, m) } - pub fn span_err(&self, sp: Span, m: &str) { + pub fn span_err>(&self, sp: S, m: &str) { self.sess.span_diagnostic.span_err(sp, m) } - pub fn struct_span_err(&self, sp: Span, m: &str) -> DiagnosticBuilder<'a> { + pub fn struct_span_err>(&self, sp: S, m: &str) -> DiagnosticBuilder<'a> { self.sess.span_diagnostic.struct_span_err(sp, m) } - pub fn span_err_help(&self, sp: Span, m: &str, h: &str) { + pub fn span_err_help>(&self, sp: S, m: &str, h: &str) { let mut err = self.sess.span_diagnostic.mut_span_err(sp, m); err.help(h); err.emit(); } - pub fn span_bug(&self, sp: Span, m: &str) -> ! { + pub fn span_bug>(&self, sp: S, m: &str) -> ! { self.sess.span_diagnostic.span_bug(sp, m) } pub fn abort_if_errors(&self) { diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index ad5bd39a45341..29280d203c79f 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -814,16 +814,8 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, let (sp, msg) = errs.into_iter().next().unwrap(); cx.ecx.struct_span_err(sp, msg) } else { - let mut diag = cx.ecx.struct_span_err(cx.fmtsp, - "multiple unused formatting arguments"); - - // Ignoring message, as it gets repetitive - // Then use MultiSpan to not clutter up errors - for (sp, _) in errs { - diag.span_label(sp, "unused"); - } - - diag + cx.ecx.struct_span_err(errs.iter().map(|&(sp, _)| sp).collect::>(), + "multiple unused formatting arguments") } }; diff --git a/src/test/ui/macros/format-foreign.rs b/src/test/ui/macros/format-foreign.rs index 91ca8f5ff7602..ec0eaed43aea6 100644 --- a/src/test/ui/macros/format-foreign.rs +++ b/src/test/ui/macros/format-foreign.rs @@ -9,7 +9,7 @@ // except according to those terms. fn main() { - println!("%.*3$s %s!\n", "Hello,", "World", 4); + println!("%.*3$s %s!\n", "Hello,", "World", 4); //~ ERROR multiple unused formatting arguments println!("%1$*2$.*3$f", 123.456); //~ ERROR never used // This should *not* produce hints, on the basis that there's equally as diff --git a/src/test/ui/macros/format-foreign.stderr b/src/test/ui/macros/format-foreign.stderr index d0229957b682e..31804ca4c40d1 100644 --- a/src/test/ui/macros/format-foreign.stderr +++ b/src/test/ui/macros/format-foreign.stderr @@ -1,17 +1,12 @@ error: multiple unused formatting arguments - --> $DIR/format-foreign.rs:12:5 + --> $DIR/format-foreign.rs:12:30 | -12 | println!("%.*3$s %s!/n", "Hello,", "World", 4); - | ^^^^^^^^^^^^^^^^^^^^^^^^^--------^^-------^^-^^ - | | | | - | | | unused - | | unused - | unused +12 | println!("%.*3$s %s!/n", "Hello,", "World", 4); //~ ERROR multiple unused formatting arguments + | ^^^^^^^^ ^^^^^^^ ^ | = help: `%.*3$s` should be written as `{:.2$}` = help: `%s` should be written as `{}` = note: printf formatting not supported; see the documentation for `std::fmt` - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: argument never used --> $DIR/format-foreign.rs:13:29 diff --git a/src/test/ui/macros/format-unused-lables.rs b/src/test/ui/macros/format-unused-lables.rs index 7a32d932ba386..3347a1215cede 100644 --- a/src/test/ui/macros/format-unused-lables.rs +++ b/src/test/ui/macros/format-unused-lables.rs @@ -10,9 +10,10 @@ fn main() { println!("Test", 123, 456, 789); + //~^ ERROR multiple unused formatting arguments println!("Test2", - 123, + 123, //~ ERROR multiple unused formatting arguments 456, 789 ); @@ -20,7 +21,7 @@ fn main() { println!("Some stuff", UNUSED="args"); //~ ERROR named argument never used println!("Some more $STUFF", - "woo!", + "woo!", //~ ERROR multiple unused formatting arguments STUFF= "things" , UNUSED="args"); diff --git a/src/test/ui/macros/format-unused-lables.stderr b/src/test/ui/macros/format-unused-lables.stderr index 9efdca12dea03..59aed9d8bc6fb 100644 --- a/src/test/ui/macros/format-unused-lables.stderr +++ b/src/test/ui/macros/format-unused-lables.stderr @@ -1,53 +1,38 @@ error: multiple unused formatting arguments - --> $DIR/format-unused-lables.rs:12:5 + --> $DIR/format-unused-lables.rs:12:22 | 12 | println!("Test", 123, 456, 789); - | ^^^^^^^^^^^^^^^^^---^^---^^---^^ - | | | | - | | | unused - | | unused - | unused - | - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + | ^^^ ^^^ ^^^ error: multiple unused formatting arguments - --> $DIR/format-unused-lables.rs:14:5 - | -14 | / println!("Test2", -15 | | 123, - | | --- unused -16 | | 456, - | | --- unused -17 | | 789 - | | --- unused -18 | | ); - | |______^ + --> $DIR/format-unused-lables.rs:16:9 | - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) +16 | 123, //~ ERROR multiple unused formatting arguments + | ^^^ +17 | 456, + | ^^^ +18 | 789 + | ^^^ error: named argument never used - --> $DIR/format-unused-lables.rs:20:35 + --> $DIR/format-unused-lables.rs:21:35 | -20 | println!("Some stuff", UNUSED="args"); //~ ERROR named argument never used +21 | println!("Some stuff", UNUSED="args"); //~ ERROR named argument never used | ^^^^^^ error: multiple unused formatting arguments - --> $DIR/format-unused-lables.rs:22:5 + --> $DIR/format-unused-lables.rs:24:9 | -22 | / println!("Some more $STUFF", -23 | | "woo!", - | | ------ unused -24 | | STUFF= -25 | | "things" - | | -------- unused -26 | | , UNUSED="args"); - | |_______________________------_^ - | | - | unused +24 | "woo!", //~ ERROR multiple unused formatting arguments + | ^^^^^^ +25 | STUFF= +26 | "things" + | ^^^^^^^^ +27 | , UNUSED="args"); + | ^^^^^^ | = help: `$STUFF` should be written as `{STUFF}` = note: shell formatting not supported; see the documentation for `std::fmt` - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: aborting due to 4 previous errors From 661e03383c99c577db3791e0846e165fe5c21510 Mon Sep 17 00:00:00 2001 From: "Zack M. Davis" Date: Mon, 15 Jan 2018 18:32:18 -0800 Subject: [PATCH 19/38] in which the private no-mangle lints receive a valued lesson in humility The incompetent fool who added these suggestions in 38e5a964f2 apparently thought it was safe to assume that, because the offending function or static was unreachable, it would therefore have not have any existing visibility modifiers, making it safe for us to unconditionally suggest inserting `pub`. This isn't true. This resolves #47383. --- src/librustc_lint/builtin.rs | 16 +++++++++------ src/test/ui/lint/suggestions.rs | 10 +++++++++ src/test/ui/lint/suggestions.stderr | 32 ++++++++++++++++++++--------- 3 files changed, 42 insertions(+), 16 deletions(-) diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index c5c27c92ab49a..de55710bdf3d0 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -1154,9 +1154,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidNoMangleItems { let msg = "function is marked #[no_mangle], but not exported"; let mut err = cx.struct_span_lint(PRIVATE_NO_MANGLE_FNS, it.span, msg); let insertion_span = it.span.with_hi(it.span.lo()); - err.span_suggestion(insertion_span, - "try making it public", - "pub ".to_owned()); + if it.vis == hir::Visibility::Inherited { + err.span_suggestion(insertion_span, + "try making it public", + "pub ".to_owned()); + } err.emit(); } if generics.is_type_parameterized() { @@ -1177,9 +1179,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidNoMangleItems { let msg = "static is marked #[no_mangle], but not exported"; let mut err = cx.struct_span_lint(PRIVATE_NO_MANGLE_STATICS, it.span, msg); let insertion_span = it.span.with_hi(it.span.lo()); - err.span_suggestion(insertion_span, - "try making it public", - "pub ".to_owned()); + if it.vis == hir::Visibility::Inherited { + err.span_suggestion(insertion_span, + "try making it public", + "pub ".to_owned()); + } err.emit(); } } diff --git a/src/test/ui/lint/suggestions.rs b/src/test/ui/lint/suggestions.rs index 3789b6dfc8b3a..dfcaede1402da 100644 --- a/src/test/ui/lint/suggestions.rs +++ b/src/test/ui/lint/suggestions.rs @@ -24,6 +24,16 @@ pub fn defiant(_t: T) {} fn rio_grande() {} // should suggest `pub` //~^ WARN function is marked +mod badlands { + // The private-no-mangle lints shouldn't suggest inserting `pub` when the + // item is already `pub` (but triggered the lint because, e.g., it's in a + // private module). (Issue #47383) + #[no_mangle] pub static DAUNTLESS: bool = true; + //~^ WARN static is marked + #[no_mangle] pub fn val_jean() {} + //~^ WARN function is marked +} + struct Equinox { warp_factor: f32, } diff --git a/src/test/ui/lint/suggestions.stderr b/src/test/ui/lint/suggestions.stderr index 701a95222183a..8b30f552d3771 100644 --- a/src/test/ui/lint/suggestions.stderr +++ b/src/test/ui/lint/suggestions.stderr @@ -1,7 +1,7 @@ warning: unnecessary parentheses around assigned value - --> $DIR/suggestions.rs:36:21 + --> $DIR/suggestions.rs:46:21 | -36 | let mut a = (1); // should suggest no `mut`, no parens +46 | let mut a = (1); // should suggest no `mut`, no parens | ^^^ help: remove these parentheses | note: lint level defined here @@ -11,17 +11,17 @@ note: lint level defined here | ^^^^^^^^^^^^^ warning: use of deprecated attribute `no_debug`: the `#[no_debug]` attribute was an experimental feature that has been deprecated due to lack of demand. See https://github.com/rust-lang/rust/issues/29721 - --> $DIR/suggestions.rs:31:1 + --> $DIR/suggestions.rs:41:1 | -31 | #[no_debug] // should suggest removal of deprecated attribute +41 | #[no_debug] // should suggest removal of deprecated attribute | ^^^^^^^^^^^ help: remove this attribute | = note: #[warn(deprecated)] on by default warning: variable does not need to be mutable - --> $DIR/suggestions.rs:36:13 + --> $DIR/suggestions.rs:46:13 | -36 | let mut a = (1); // should suggest no `mut`, no parens +46 | let mut a = (1); // should suggest no `mut`, no parens | ---^^ | | | help: remove this `mut` @@ -72,18 +72,30 @@ warning: function is marked #[no_mangle], but not exported | = note: #[warn(private_no_mangle_fns)] on by default +warning: static is marked #[no_mangle], but not exported + --> $DIR/suggestions.rs:31:18 + | +31 | #[no_mangle] pub static DAUNTLESS: bool = true; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: function is marked #[no_mangle], but not exported + --> $DIR/suggestions.rs:33:18 + | +33 | #[no_mangle] pub fn val_jean() {} + | ^^^^^^^^^^^^^^^^^^^^ + warning: denote infinite loops with `loop { ... }` - --> $DIR/suggestions.rs:34:5 + --> $DIR/suggestions.rs:44:5 | -34 | while true { // should suggest `loop` +44 | while true { // should suggest `loop` | ^^^^^^^^^^ help: use `loop` | = note: #[warn(while_true)] on by default warning: the `warp_factor:` in this pattern is redundant - --> $DIR/suggestions.rs:41:23 + --> $DIR/suggestions.rs:51:23 | -41 | Equinox { warp_factor: warp_factor } => {} // should suggest shorthand +51 | Equinox { warp_factor: warp_factor } => {} // should suggest shorthand | ------------^^^^^^^^^^^^ | | | help: remove this From fd075c6f2144b33385a596b36eece02ed5d8be62 Mon Sep 17 00:00:00 2001 From: Pulkit Goyal <7895pulkit@gmail.com> Date: Tue, 16 Jan 2018 14:37:05 +0530 Subject: [PATCH 20/38] implement "only-" for test headers This patch implements "only-" for tests headers using which one can specify just the platforms on which the test should run rather than listing all the platforms to ignore using "ignore-". This is a fix for issues #33581 and #47459. --- src/tools/compiletest/src/header.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 1f736e33c8b2a..475991d7b8be4 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -44,6 +44,8 @@ impl EarlyProps { props.ignore = props.ignore || config.parse_cfg_name_directive(ln, "ignore") || + (config.parse_cfg_prefix(ln, "only") && + !config.parse_cfg_name_directive(ln, "only")) || ignore_gdb(config, ln) || ignore_lldb(config, ln) || ignore_llvm(config, ln); @@ -564,6 +566,17 @@ impl Config { } } + fn parse_cfg_prefix(&self, line: &str, prefix: &str) -> bool { + // returns whether this line contains this prefix or not. For prefix + // "ignore", returns true if line says "ignore-x86_64", "ignore-arch", + // "ignore-andorid" etc. + if line.starts_with(prefix) && line.as_bytes().get(prefix.len()) == Some(&b'-') { + true + } else { + false + } + } + fn parse_name_directive(&self, line: &str, directive: &str) -> bool { // Ensure the directive is a whole word. Do not match "ignore-x86" when // the line says "ignore-x86_64". From 1e436eb236b2f6ae37971669d2a633cb0a778be6 Mon Sep 17 00:00:00 2001 From: Pulkit Goyal <7895pulkit@gmail.com> Date: Tue, 16 Jan 2018 15:02:29 +0530 Subject: [PATCH 21/38] return the boolean value directly instead of using if-else Previous patch introduced something like if x {true} else {false} which can be simply replaced by returning x here. Thanks to @kennytm for spotting it. --- src/tools/compiletest/src/header.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 475991d7b8be4..478a692df9190 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -570,11 +570,7 @@ impl Config { // returns whether this line contains this prefix or not. For prefix // "ignore", returns true if line says "ignore-x86_64", "ignore-arch", // "ignore-andorid" etc. - if line.starts_with(prefix) && line.as_bytes().get(prefix.len()) == Some(&b'-') { - true - } else { - false - } + line.starts_with(prefix) && line.as_bytes().get(prefix.len()) == Some(&b'-') } fn parse_name_directive(&self, line: &str, directive: &str) -> bool { From 567b07c9e693758b3f4607573a2f276f43116f7b Mon Sep 17 00:00:00 2001 From: Pulkit Goyal <7895pulkit@gmail.com> Date: Tue, 16 Jan 2018 19:00:42 +0530 Subject: [PATCH 22/38] rename parse_cfg_prefix() to has_cfg_prefix() The function parse_cfg_prefix() is not really parsing. It's just checking whether the prefix is present or not. So the new function name as suggested by @Mark-Simulacrum is better. --- src/tools/compiletest/src/header.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 478a692df9190..a10372fd74597 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -44,7 +44,7 @@ impl EarlyProps { props.ignore = props.ignore || config.parse_cfg_name_directive(ln, "ignore") || - (config.parse_cfg_prefix(ln, "only") && + (config.has_cfg_prefix(ln, "only") && !config.parse_cfg_name_directive(ln, "only")) || ignore_gdb(config, ln) || ignore_lldb(config, ln) || @@ -566,7 +566,7 @@ impl Config { } } - fn parse_cfg_prefix(&self, line: &str, prefix: &str) -> bool { + fn has_cfg_prefix(&self, line: &str, prefix: &str) -> bool { // returns whether this line contains this prefix or not. For prefix // "ignore", returns true if line says "ignore-x86_64", "ignore-arch", // "ignore-andorid" etc. From bd70f0fa66853125797bfa4cdea37b9ca2120159 Mon Sep 17 00:00:00 2001 From: Pulkit Goyal <7895pulkit@gmail.com> Date: Tue, 16 Jan 2018 19:09:32 +0530 Subject: [PATCH 23/38] add a comment about parsing only prefix in header.rs --- src/tools/compiletest/src/header.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index a10372fd74597..ff662736bdd1b 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -41,6 +41,8 @@ impl EarlyProps { iter_header(testfile, None, &mut |ln| { + // we should check if any only- exists and if it exists + // and does not matches the current platform, skip the test props.ignore = props.ignore || config.parse_cfg_name_directive(ln, "ignore") || From 24c3a6db9bb0471e0f280b338b53b8bd55f52314 Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Sun, 14 Jan 2018 18:37:52 +0100 Subject: [PATCH 24/38] Add a Docker container for doing automated builds for CloudABI. Setting up a cross compilation toolchain for CloudABI is relatively easy. It's just a matter of installing a somewhat recent version of Clang (5.0 preferred) and installing the corresponding ${target}-cxx-runtime package, containing a set of core C/C++ libraries (libc, libc++, libunwind, etc). Eventually it would be nice if we could also run 'x.py test'. That, however still requires some more work. Both libtest and compiletest would need to be adjusted to deal with CloudABI's requirement of having all of an application's dependencies injected. Let's settle for just doing 'x.py dist' for now. --- .travis.yml | 2 + src/ci/docker/dist-cloudabi/Dockerfile | 30 +++++++++++ src/ci/docker/scripts/cloudabi-toolchain.sh | 59 +++++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 src/ci/docker/dist-cloudabi/Dockerfile create mode 100755 src/ci/docker/scripts/cloudabi-toolchain.sh diff --git a/.travis.yml b/.travis.yml index 6e242b74894c5..1642a39955293 100644 --- a/.travis.yml +++ b/.travis.yml @@ -126,6 +126,8 @@ matrix: if: branch = auto - env: IMAGE=dist-armv7-linux DEPLOY=1 if: branch = auto + - env: IMAGE=dist-cloudabi DEPLOY=1 + if: branch = auto - env: IMAGE=dist-i586-gnu-i586-i686-musl DEPLOY=1 if: branch = auto - env: IMAGE=dist-i686-freebsd DEPLOY=1 diff --git a/src/ci/docker/dist-cloudabi/Dockerfile b/src/ci/docker/dist-cloudabi/Dockerfile new file mode 100644 index 0000000000000..f1f6f0ff6cac9 --- /dev/null +++ b/src/ci/docker/dist-cloudabi/Dockerfile @@ -0,0 +1,30 @@ +FROM ubuntu:17.10 + +ENV TARGETS=aarch64-unknown-cloudabi +# FIXME(EdSchouten): Enable ARMv7 support once libc ≥0.2.37 has been merged. +# ENV TARGETS=armv7-unknown-cloudabi-eabihf +ENV TARGETS=$TARGETS,i686-unknown-cloudabi +ENV TARGETS=$TARGETS,x86_64-unknown-cloudabi + +COPY scripts/cloudabi-toolchain.sh /tmp/ +RUN /tmp/cloudabi-toolchain.sh + +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh + +# FIXME(EdSchouten): Remove this once cc ≥1.0.4 has been merged. It can +# automatically pick the right compiler path. +ENV \ + AR_aarch64_unknown_cloudabi=aarch64-unknown-cloudabi-ar \ + CC_aarch64_unknown_cloudabi=aarch64-unknown-cloudabi-clang \ + CXX_aarch64_unknown_cloudabi=aarch64-unknown-cloudabi-clang++ \ + AR_i686_unknown_cloudabi=i686-unknown-cloudabi-ar \ + CC_i686_unknown_cloudabi=i686-unknown-cloudabi-clang \ + CXX_i686_unknown_cloudabi=i686-unknown-cloudabi-clang++ \ + AR_x86_64_unknown_cloudabi=x86_64-unknown-cloudabi-ar \ + CC_x86_64_unknown_cloudabi=x86_64-unknown-cloudabi-clang \ + CXX_x86_64_unknown_cloudabi=x86_64-unknown-cloudabi-clang++ + +# FIXME(EdSchouten): Work towards being able to run 'x.py test'. +ENV RUST_CONFIGURE_ARGS --target=${TARGETS} --disable-jemalloc +ENV SCRIPT python2.7 /checkout/x.py dist --target ${TARGETS} diff --git a/src/ci/docker/scripts/cloudabi-toolchain.sh b/src/ci/docker/scripts/cloudabi-toolchain.sh new file mode 100755 index 0000000000000..5d6ecb48d3cae --- /dev/null +++ b/src/ci/docker/scripts/cloudabi-toolchain.sh @@ -0,0 +1,59 @@ +#!/bin/bash +# Copyright 2018 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +set -eux + +# Install prerequisites. +apt-get update +apt-get install -y --no-install-recommends \ + apt-transport-https \ + ca-certificates \ + clang-5.0 \ + cmake \ + curl \ + file \ + g++ \ + gdb \ + git \ + lld-5.0 \ + make \ + python \ + sudo \ + xz-utils + +# Set up a Clang-based cross compiler toolchain. +# Based on the steps described at https://nuxi.nl/cloudabi/debian/ +IFS=, +for target in ${TARGETS}; do + for tool in ar nm objdump ranlib size; do + ln -s ../lib/llvm-5.0/bin/llvm-${tool} /usr/bin/${target}-${tool} + done + ln -s ../lib/llvm-5.0/bin/clang /usr/bin/${target}-cc + ln -s ../lib/llvm-5.0/bin/clang /usr/bin/${target}-c++ + ln -s ../lib/llvm-5.0/bin/lld /usr/bin/${target}-ld + ln -s ../../${target} /usr/lib/llvm-5.0/${target} + + # FIXME(EdSchouten): Remove this once cc ≥1.0.4 has been merged. It + # can make use of ${target}-cc and ${target}-c++, without incorrectly + # assuming it's MSVC. + ln -s ../lib/llvm-5.0/bin/clang /usr/bin/${target}-clang + ln -s ../lib/llvm-5.0/bin/clang /usr/bin/${target}-clang++ +done + +# Install the C++ runtime libraries from CloudABI Ports. +echo deb https://nuxi.nl/distfiles/cloudabi-ports/debian/ cloudabi cloudabi > \ + /etc/apt/sources.list.d/cloudabi.list +curl 'https://pgp.mit.edu/pks/lookup?op=get&search=0x0DA51B8531344B15' | \ + apt-key add - +apt-get update +for target in ${TARGETS}; do + apt-get install -y $(echo ${target} | sed -e s/_/-/g)-cxx-runtime +done From 5801f95cbc2183285bc4423b3405f2767e448ef6 Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Sun, 14 Jan 2018 19:47:41 +0100 Subject: [PATCH 25/38] Move dist-cloudabi/ into disabled/. There is not enough capacity to do automated builds for CloudABI at this time. --- .travis.yml | 2 -- src/ci/docker/{ => disabled}/dist-cloudabi/Dockerfile | 0 2 files changed, 2 deletions(-) rename src/ci/docker/{ => disabled}/dist-cloudabi/Dockerfile (100%) diff --git a/.travis.yml b/.travis.yml index 1642a39955293..6e242b74894c5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -126,8 +126,6 @@ matrix: if: branch = auto - env: IMAGE=dist-armv7-linux DEPLOY=1 if: branch = auto - - env: IMAGE=dist-cloudabi DEPLOY=1 - if: branch = auto - env: IMAGE=dist-i586-gnu-i586-i686-musl DEPLOY=1 if: branch = auto - env: IMAGE=dist-i686-freebsd DEPLOY=1 diff --git a/src/ci/docker/dist-cloudabi/Dockerfile b/src/ci/docker/disabled/dist-cloudabi/Dockerfile similarity index 100% rename from src/ci/docker/dist-cloudabi/Dockerfile rename to src/ci/docker/disabled/dist-cloudabi/Dockerfile From 46c20c099051fe6f20a963913b2afa3d1a8414ea Mon Sep 17 00:00:00 2001 From: Geoffry Song Date: Tue, 16 Jan 2018 11:43:57 -0800 Subject: [PATCH 26/38] Remove incorrect `Default::default` links, add a new one `map_or` and `map_or_else` don't use `Default::default`, but `unwrap_or_default` does. --- src/libcore/option.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index d8f3ec38cf38c..15181dab8531c 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -407,9 +407,7 @@ impl Option { } /// Applies a function to the contained value (if any), - /// or returns a [`default`][] (if not). - /// - /// [`default`]: ../default/trait.Default.html#tymethod.default + /// or returns the provided default (if not). /// /// # Examples /// @@ -430,9 +428,7 @@ impl Option { } /// Applies a function to the contained value (if any), - /// or computes a [`default`][] (if not). - /// - /// [`default`]: ../default/trait.Default.html#tymethod.default + /// or computes a default (if not). /// /// # Examples /// @@ -850,7 +846,7 @@ impl Option { /// Returns the contained value or a default /// /// Consumes the `self` argument then, if [`Some`], returns the contained - /// value, otherwise if [`None`], returns the default value for that + /// value, otherwise if [`None`], returns the [default value] for that /// type. /// /// # Examples @@ -872,6 +868,7 @@ impl Option { /// /// [`Some`]: #variant.Some /// [`None`]: #variant.None + /// [default value]: ../default/trait.Default.html#tymethod.default /// [`parse`]: ../../std/primitive.str.html#method.parse /// [`FromStr`]: ../../std/str/trait.FromStr.html #[inline] From 1dcfd144b95dedce607c764dec6c5931f5be0ceb Mon Sep 17 00:00:00 2001 From: Dominik Winecki Date: Tue, 16 Jan 2018 14:47:14 -0500 Subject: [PATCH 27/38] Make non-found module name optional No longer uses a magic string for missing or root module. --- src/librustc_resolve/lib.rs | 8 ++++---- src/librustc_resolve/resolve_imports.rs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 0a29441cef7ef..71bebc3273259 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -4062,7 +4062,7 @@ fn show_candidates(err: &mut DiagnosticBuilder, } /// A somewhat inefficient routine to obtain the name of a module. -fn module_to_string(module: Module) -> String { +fn module_to_string(module: Module) -> Option { let mut names = Vec::new(); fn collect_mod(names: &mut Vec, module: Module) { @@ -4080,12 +4080,12 @@ fn module_to_string(module: Module) -> String { collect_mod(&mut names, module); if names.is_empty() { - return "???".to_string(); + return None; } - names_to_string(&names.into_iter() + Some(names_to_string(&names.into_iter() .rev() .map(|n| dummy_spanned(n)) - .collect::>()) + .collect::>())) } fn err_path_resolution() -> PathResolution { diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 132119e961bc3..b03f040ba9854 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -524,7 +524,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> { fn resolve_import(&mut self, directive: &'b ImportDirective<'b>) -> bool { debug!("(resolving import for module) resolving import `{}::...` in `{}`", names_to_string(&directive.module_path[..]), - module_to_string(self.current_module)); + module_to_string(self.current_module).unwrap_or("???".to_string())); self.current_module = directive.parent; @@ -773,10 +773,10 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> { None => "".to_owned(), }; let module_str = module_to_string(module); - let msg = if &module_str == "???" { - format!("no `{}` in the root{}", ident, lev_suggestion) - } else { + let msg = if let Some(module_str) = module_str { format!("no `{}` in `{}`{}", ident, module_str, lev_suggestion) + } else { + format!("no `{}` in the root{}", ident, lev_suggestion) }; Some((span, msg)) } else { From d769539f428fb48ea9bb0f8c703b805eb9664fee Mon Sep 17 00:00:00 2001 From: Gauri Date: Wed, 17 Jan 2018 01:31:21 +0530 Subject: [PATCH 28/38] fix tidy checks --- src/test/ui/issue-47377-1.stderr | 12 ------------ src/test/ui/issue-47377.rs | 6 +++--- src/test/ui/issue-47377.stderr | 6 +++--- src/test/ui/{issue-47377-1.rs => issue-47380.rs} | 7 ++++--- src/test/ui/issue-47380.stderr | 12 ++++++++++++ 5 files changed, 22 insertions(+), 21 deletions(-) delete mode 100644 src/test/ui/issue-47377-1.stderr rename src/test/ui/{issue-47377-1.rs => issue-47380.rs} (76%) create mode 100644 src/test/ui/issue-47380.stderr diff --git a/src/test/ui/issue-47377-1.stderr b/src/test/ui/issue-47377-1.stderr deleted file mode 100644 index aad5373ae00dd..0000000000000 --- a/src/test/ui/issue-47377-1.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0369]: binary operation `+` cannot be applied to type `&str` - --> $DIR/issue-47377-1.rs:13:37 - | -13 | println!("🦀🦀🦀🦀🦀"); let _a = b + ", World!"; //~ERROR 13:37: 13:51: binary operation `+` cannot be applied to type `&str` [E0369] - | ^^^^^^^^^^^^^^ `+` can't be used to concatenate two `&str` strings -help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left - | -13 | println!("🦀🦀🦀🦀🦀"); let _a = b.to_owned() + ", World!"; //~ERROR 13:37: 13:51: binary operation `+` cannot be applied to type `&str` [E0369] - | ^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/issue-47377.rs b/src/test/ui/issue-47377.rs index 2a8f2e30c0e88..f2e18590ddef5 100644 --- a/src/test/ui/issue-47377.rs +++ b/src/test/ui/issue-47377.rs @@ -7,8 +7,8 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. - fn main(){ let b = "hello"; - let _a = b + ", World!"; //~ERROR 13:14: 13:28: binary operation `+` cannot be applied to type `&str` [E0369] -} \ No newline at end of file + let _a = b + ", World!"; + //~^ ERROR E0369 +} diff --git a/src/test/ui/issue-47377.stderr b/src/test/ui/issue-47377.stderr index e9f285a19c3d9..b80867f1714a0 100644 --- a/src/test/ui/issue-47377.stderr +++ b/src/test/ui/issue-47377.stderr @@ -1,11 +1,11 @@ error[E0369]: binary operation `+` cannot be applied to type `&str` - --> $DIR/issue-47377.rs:13:14 + --> $DIR/issue-47377.rs:12:14 | -13 | let _a = b + ", World!"; //~ERROR 13:14: 13:28: binary operation `+` cannot be applied to type `&str` [E0369] +12 | let _a = b + ", World!"; | ^^^^^^^^^^^^^^ `+` can't be used to concatenate two `&str` strings help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left | -13 | let _a = b.to_owned() + ", World!"; //~ERROR 13:14: 13:28: binary operation `+` cannot be applied to type `&str` [E0369] +12 | let _a = b.to_owned() + ", World!"; | ^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/issue-47377-1.rs b/src/test/ui/issue-47380.rs similarity index 76% rename from src/test/ui/issue-47377-1.rs rename to src/test/ui/issue-47380.rs index f173d0096381b..748891fad5aab 100644 --- a/src/test/ui/issue-47377-1.rs +++ b/src/test/ui/issue-47380.rs @@ -7,8 +7,9 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. - +// ignore-tidy-tab fn main(){ let b = "hello"; - println!("🦀🦀🦀🦀🦀"); let _a = b + ", World!"; //~ERROR 13:37: 13:51: binary operation `+` cannot be applied to type `&str` [E0369] -} \ No newline at end of file + println!("🦀🦀🦀🦀🦀"); let _a = b + ", World!"; + //~^ ERROR E0369 +} diff --git a/src/test/ui/issue-47380.stderr b/src/test/ui/issue-47380.stderr new file mode 100644 index 0000000000000..8ead1697c7f68 --- /dev/null +++ b/src/test/ui/issue-47380.stderr @@ -0,0 +1,12 @@ +error[E0369]: binary operation `+` cannot be applied to type `&str` + --> $DIR/blah.rs:13:33 + | +13 | println!("🦀🦀🦀🦀🦀"); let _a = b + ", World!"; + | ^^^^^^^^^^^^^^ `+` can't be used to concatenate two `&str` strings +help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left + | +13 | println!("🦀🦀🦀🦀🦀"); let _a = b.to_owned() + ", World!"; + | ^^^^^^^^^^^^ + +error: aborting due to previous error + From a4e3f361ba74303545150bc1db7260f70eb59566 Mon Sep 17 00:00:00 2001 From: Gauri Date: Wed, 17 Jan 2018 02:00:09 +0530 Subject: [PATCH 29/38] using tabs in ui tests --- src/test/ui/issue-47377.rs | 3 ++- src/test/ui/issue-47377.stderr | 6 +++--- src/test/ui/issue-47380.rs | 2 +- src/test/ui/issue-47380.stderr | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/test/ui/issue-47377.rs b/src/test/ui/issue-47377.rs index f2e18590ddef5..a492b4b5567e8 100644 --- a/src/test/ui/issue-47377.rs +++ b/src/test/ui/issue-47377.rs @@ -7,7 +7,8 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main(){ +// ignore-tidy-tab +fn main() { let b = "hello"; let _a = b + ", World!"; //~^ ERROR E0369 diff --git a/src/test/ui/issue-47377.stderr b/src/test/ui/issue-47377.stderr index b80867f1714a0..09640c841b8e4 100644 --- a/src/test/ui/issue-47377.stderr +++ b/src/test/ui/issue-47377.stderr @@ -1,11 +1,11 @@ error[E0369]: binary operation `+` cannot be applied to type `&str` - --> $DIR/issue-47377.rs:12:14 + --> $DIR/issue-47377.rs:13:14 | -12 | let _a = b + ", World!"; +13 | let _a = b + ", World!"; | ^^^^^^^^^^^^^^ `+` can't be used to concatenate two `&str` strings help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left | -12 | let _a = b.to_owned() + ", World!"; +13 | let _a = b.to_owned() + ", World!"; | ^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/issue-47380.rs b/src/test/ui/issue-47380.rs index 748891fad5aab..88d4faedb7a1c 100644 --- a/src/test/ui/issue-47380.rs +++ b/src/test/ui/issue-47380.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. // ignore-tidy-tab -fn main(){ +fn main() { let b = "hello"; println!("🦀🦀🦀🦀🦀"); let _a = b + ", World!"; //~^ ERROR E0369 diff --git a/src/test/ui/issue-47380.stderr b/src/test/ui/issue-47380.stderr index 8ead1697c7f68..e220b4551e7f5 100644 --- a/src/test/ui/issue-47380.stderr +++ b/src/test/ui/issue-47380.stderr @@ -1,5 +1,5 @@ error[E0369]: binary operation `+` cannot be applied to type `&str` - --> $DIR/blah.rs:13:33 + --> $DIR/issue-47380.rs:13:33 | 13 | println!("🦀🦀🦀🦀🦀"); let _a = b + ", World!"; | ^^^^^^^^^^^^^^ `+` can't be used to concatenate two `&str` strings From efe3d69ad827cc359b1a120b0e5c58dd87a2935b Mon Sep 17 00:00:00 2001 From: Gauri Date: Wed, 17 Jan 2018 02:07:07 +0530 Subject: [PATCH 30/38] fix minor errors --- src/test/ui/issue-47377.rs | 6 +++--- src/test/ui/issue-47377.stderr | 10 +++++----- src/test/ui/issue-47380.rs | 1 - src/test/ui/issue-47380.stderr | 6 +++--- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/test/ui/issue-47377.rs b/src/test/ui/issue-47377.rs index a492b4b5567e8..f294008cfd0d5 100644 --- a/src/test/ui/issue-47377.rs +++ b/src/test/ui/issue-47377.rs @@ -9,7 +9,7 @@ // except according to those terms. // ignore-tidy-tab fn main() { - let b = "hello"; - let _a = b + ", World!"; - //~^ ERROR E0369 + let b = "hello"; + let _a = b + ", World!"; + //~^ ERROR E0369 } diff --git a/src/test/ui/issue-47377.stderr b/src/test/ui/issue-47377.stderr index 09640c841b8e4..13b3ff5869783 100644 --- a/src/test/ui/issue-47377.stderr +++ b/src/test/ui/issue-47377.stderr @@ -1,12 +1,12 @@ error[E0369]: binary operation `+` cannot be applied to type `&str` - --> $DIR/issue-47377.rs:13:14 + --> $DIR/issue-47377.rs:13:12 | -13 | let _a = b + ", World!"; - | ^^^^^^^^^^^^^^ `+` can't be used to concatenate two `&str` strings +13 | let _a = b + ", World!"; + | ^^^^^^^^^^^^^^ `+` can't be used to concatenate two `&str` strings help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left | -13 | let _a = b.to_owned() + ", World!"; - | ^^^^^^^^^^^^ +13 | let _a = b.to_owned() + ", World!"; + | ^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/issue-47380.rs b/src/test/ui/issue-47380.rs index 88d4faedb7a1c..e43a967253ca8 100644 --- a/src/test/ui/issue-47380.rs +++ b/src/test/ui/issue-47380.rs @@ -7,7 +7,6 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-tidy-tab fn main() { let b = "hello"; println!("🦀🦀🦀🦀🦀"); let _a = b + ", World!"; diff --git a/src/test/ui/issue-47380.stderr b/src/test/ui/issue-47380.stderr index e220b4551e7f5..6c9f79b5a9417 100644 --- a/src/test/ui/issue-47380.stderr +++ b/src/test/ui/issue-47380.stderr @@ -1,11 +1,11 @@ error[E0369]: binary operation `+` cannot be applied to type `&str` - --> $DIR/issue-47380.rs:13:33 + --> $DIR/issue-47380.rs:12:33 | -13 | println!("🦀🦀🦀🦀🦀"); let _a = b + ", World!"; +12 | println!("🦀🦀🦀🦀🦀"); let _a = b + ", World!"; | ^^^^^^^^^^^^^^ `+` can't be used to concatenate two `&str` strings help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left | -13 | println!("🦀🦀🦀🦀🦀"); let _a = b.to_owned() + ", World!"; +12 | println!("🦀🦀🦀🦀🦀"); let _a = b.to_owned() + ", World!"; | ^^^^^^^^^^^^ error: aborting due to previous error From ae4288f9ffd2fd431dba04a5906b5304e9106755 Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Tue, 16 Jan 2018 22:23:18 +0100 Subject: [PATCH 31/38] Integrate dist-cloudabi into dist-various-2. As discussed in #47427, let's not have a separate container for doing CloudABI builds. It's a lot faster if we integrate it into an existing container, so there's less duplication of what's being built. Upgrade the existing container to Ubuntu 17.10, which is required for CloudABI builds. The version of Clang shipped with 16.04 is not recent enough to support CloudABI properly. --- .../docker/disabled/dist-cloudabi/Dockerfile | 30 ----------------- src/ci/docker/dist-various-2/Dockerfile | 29 +++++++++++++++-- .../build-cloudabi-toolchain.sh} | 32 ++++++++----------- 3 files changed, 40 insertions(+), 51 deletions(-) delete mode 100644 src/ci/docker/disabled/dist-cloudabi/Dockerfile rename src/ci/docker/{scripts/cloudabi-toolchain.sh => dist-various-2/build-cloudabi-toolchain.sh} (59%) diff --git a/src/ci/docker/disabled/dist-cloudabi/Dockerfile b/src/ci/docker/disabled/dist-cloudabi/Dockerfile deleted file mode 100644 index f1f6f0ff6cac9..0000000000000 --- a/src/ci/docker/disabled/dist-cloudabi/Dockerfile +++ /dev/null @@ -1,30 +0,0 @@ -FROM ubuntu:17.10 - -ENV TARGETS=aarch64-unknown-cloudabi -# FIXME(EdSchouten): Enable ARMv7 support once libc ≥0.2.37 has been merged. -# ENV TARGETS=armv7-unknown-cloudabi-eabihf -ENV TARGETS=$TARGETS,i686-unknown-cloudabi -ENV TARGETS=$TARGETS,x86_64-unknown-cloudabi - -COPY scripts/cloudabi-toolchain.sh /tmp/ -RUN /tmp/cloudabi-toolchain.sh - -COPY scripts/sccache.sh /scripts/ -RUN sh /scripts/sccache.sh - -# FIXME(EdSchouten): Remove this once cc ≥1.0.4 has been merged. It can -# automatically pick the right compiler path. -ENV \ - AR_aarch64_unknown_cloudabi=aarch64-unknown-cloudabi-ar \ - CC_aarch64_unknown_cloudabi=aarch64-unknown-cloudabi-clang \ - CXX_aarch64_unknown_cloudabi=aarch64-unknown-cloudabi-clang++ \ - AR_i686_unknown_cloudabi=i686-unknown-cloudabi-ar \ - CC_i686_unknown_cloudabi=i686-unknown-cloudabi-clang \ - CXX_i686_unknown_cloudabi=i686-unknown-cloudabi-clang++ \ - AR_x86_64_unknown_cloudabi=x86_64-unknown-cloudabi-ar \ - CC_x86_64_unknown_cloudabi=x86_64-unknown-cloudabi-clang \ - CXX_x86_64_unknown_cloudabi=x86_64-unknown-cloudabi-clang++ - -# FIXME(EdSchouten): Work towards being able to run 'x.py test'. -ENV RUST_CONFIGURE_ARGS --target=${TARGETS} --disable-jemalloc -ENV SCRIPT python2.7 /checkout/x.py dist --target ${TARGETS} diff --git a/src/ci/docker/dist-various-2/Dockerfile b/src/ci/docker/dist-various-2/Dockerfile index c7885db559a64..5284a1c875ce4 100644 --- a/src/ci/docker/dist-various-2/Dockerfile +++ b/src/ci/docker/dist-various-2/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:16.04 +FROM ubuntu:17.10 COPY scripts/cross-apt-packages.sh /scripts/ RUN sh /scripts/cross-apt-packages.sh @@ -21,9 +21,14 @@ RUN apt-key adv --batch --yes --keyserver keyserver.ubuntu.com --recv-keys 74DA7 RUN add-apt-repository -y 'deb http://apt.dilos.org/dilos dilos2-testing main' WORKDIR /tmp -COPY dist-various-2/shared.sh dist-various-2/build-fuchsia-toolchain.sh /tmp/ -COPY dist-various-2/build-solaris-toolchain.sh /tmp/ +COPY dist-various-2/shared.sh /tmp/ +COPY dist-various-2/build-cloudabi-toolchain.sh /tmp/ +RUN /tmp/build-cloudabi-toolchain.sh aarch64-unknown-cloudabi +RUN /tmp/build-cloudabi-toolchain.sh i686-unknown-cloudabi +RUN /tmp/build-cloudabi-toolchain.sh x86_64-unknown-cloudabi +COPY dist-various-2/build-fuchsia-toolchain.sh /tmp/ RUN /tmp/build-fuchsia-toolchain.sh +COPY dist-various-2/build-solaris-toolchain.sh /tmp/ RUN /tmp/build-solaris-toolchain.sh x86_64 amd64 solaris-i386 RUN /tmp/build-solaris-toolchain.sh sparcv9 sparcv9 solaris-sparc @@ -44,12 +49,30 @@ ENV \ CC_x86_64_sun_solaris=x86_64-sun-solaris2.10-gcc \ CXX_x86_64_sun_solaris=x86_64-sun-solaris2.10-g++ +# FIXME(EdSchouten): Remove this once cc ≥1.0.4 has been merged. It can +# automatically pick the right compiler path. +ENV \ + AR_aarch64_unknown_cloudabi=aarch64-unknown-cloudabi-ar \ + CC_aarch64_unknown_cloudabi=aarch64-unknown-cloudabi-clang \ + CXX_aarch64_unknown_cloudabi=aarch64-unknown-cloudabi-clang++ \ + AR_i686_unknown_cloudabi=i686-unknown-cloudabi-ar \ + CC_i686_unknown_cloudabi=i686-unknown-cloudabi-clang \ + CXX_i686_unknown_cloudabi=i686-unknown-cloudabi-clang++ \ + AR_x86_64_unknown_cloudabi=x86_64-unknown-cloudabi-ar \ + CC_x86_64_unknown_cloudabi=x86_64-unknown-cloudabi-clang \ + CXX_x86_64_unknown_cloudabi=x86_64-unknown-cloudabi-clang++ + ENV TARGETS=x86_64-unknown-fuchsia ENV TARGETS=$TARGETS,aarch64-unknown-fuchsia ENV TARGETS=$TARGETS,sparcv9-sun-solaris ENV TARGETS=$TARGETS,wasm32-unknown-unknown ENV TARGETS=$TARGETS,x86_64-sun-solaris ENV TARGETS=$TARGETS,x86_64-unknown-linux-gnux32 +ENV TARGETS=$TARGETS,aarch64-unknown-cloudabi +# FIXME(EdSchouten): Enable ARMv7 support once libc ≥0.2.37 has been merged. +# ENV TARGETS=$TARGETS,armv7-unknown-cloudabi-eabihf +ENV TARGETS=$TARGETS,i686-unknown-cloudabi +ENV TARGETS=$TARGETS,x86_64-unknown-cloudabi ENV RUST_CONFIGURE_ARGS --target=$TARGETS --enable-extended ENV SCRIPT python2.7 ../x.py dist --target $TARGETS diff --git a/src/ci/docker/scripts/cloudabi-toolchain.sh b/src/ci/docker/dist-various-2/build-cloudabi-toolchain.sh similarity index 59% rename from src/ci/docker/scripts/cloudabi-toolchain.sh rename to src/ci/docker/dist-various-2/build-cloudabi-toolchain.sh index 5d6ecb48d3cae..d64da43663997 100755 --- a/src/ci/docker/scripts/cloudabi-toolchain.sh +++ b/src/ci/docker/dist-various-2/build-cloudabi-toolchain.sh @@ -31,22 +31,20 @@ apt-get install -y --no-install-recommends \ # Set up a Clang-based cross compiler toolchain. # Based on the steps described at https://nuxi.nl/cloudabi/debian/ -IFS=, -for target in ${TARGETS}; do - for tool in ar nm objdump ranlib size; do - ln -s ../lib/llvm-5.0/bin/llvm-${tool} /usr/bin/${target}-${tool} - done - ln -s ../lib/llvm-5.0/bin/clang /usr/bin/${target}-cc - ln -s ../lib/llvm-5.0/bin/clang /usr/bin/${target}-c++ - ln -s ../lib/llvm-5.0/bin/lld /usr/bin/${target}-ld - ln -s ../../${target} /usr/lib/llvm-5.0/${target} - - # FIXME(EdSchouten): Remove this once cc ≥1.0.4 has been merged. It - # can make use of ${target}-cc and ${target}-c++, without incorrectly - # assuming it's MSVC. - ln -s ../lib/llvm-5.0/bin/clang /usr/bin/${target}-clang - ln -s ../lib/llvm-5.0/bin/clang /usr/bin/${target}-clang++ +target=$1 +for tool in ar nm objdump ranlib size; do + ln -s ../lib/llvm-5.0/bin/llvm-${tool} /usr/bin/${target}-${tool} done +ln -s ../lib/llvm-5.0/bin/clang /usr/bin/${target}-cc +ln -s ../lib/llvm-5.0/bin/clang /usr/bin/${target}-c++ +ln -s ../lib/llvm-5.0/bin/lld /usr/bin/${target}-ld +ln -s ../../${target} /usr/lib/llvm-5.0/${target} + +# FIXME(EdSchouten): Remove this once cc ≥1.0.4 has been merged. It +# can make use of ${target}-cc and ${target}-c++, without incorrectly +# assuming it's MSVC. +ln -s ../lib/llvm-5.0/bin/clang /usr/bin/${target}-clang +ln -s ../lib/llvm-5.0/bin/clang /usr/bin/${target}-clang++ # Install the C++ runtime libraries from CloudABI Ports. echo deb https://nuxi.nl/distfiles/cloudabi-ports/debian/ cloudabi cloudabi > \ @@ -54,6 +52,4 @@ echo deb https://nuxi.nl/distfiles/cloudabi-ports/debian/ cloudabi cloudabi > \ curl 'https://pgp.mit.edu/pks/lookup?op=get&search=0x0DA51B8531344B15' | \ apt-key add - apt-get update -for target in ${TARGETS}; do - apt-get install -y $(echo ${target} | sed -e s/_/-/g)-cxx-runtime -done +apt-get install -y $(echo ${target} | sed -e s/_/-/g)-cxx-runtime From f81c2ded5e7f8d3288fa0daccb8c92396e9b7e14 Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Mon, 15 Jan 2018 10:29:30 -0600 Subject: [PATCH 32/38] Allow a trailing comma in lint_array; fix #47428 --- src/librustc/lint/mod.rs | 13 +++-- .../auxiliary/lint_for_crate.rs | 57 ++++++++++++++----- .../run-pass-fulldeps/issue-15778-pass.rs | 4 ++ 3 files changed, 55 insertions(+), 19 deletions(-) diff --git a/src/librustc/lint/mod.rs b/src/librustc/lint/mod.rs index f4abc54ad2e4e..b2a9859f68a3e 100644 --- a/src/librustc/lint/mod.rs +++ b/src/librustc/lint/mod.rs @@ -97,12 +97,13 @@ macro_rules! declare_lint { /// Declare a static `LintArray` and return it as an expression. #[macro_export] -macro_rules! lint_array { ($( $lint:expr ),*) => ( - { - static ARRAY: LintArray = &[ $( &$lint ),* ]; - ARRAY - } -) } +macro_rules! lint_array { + ($( $lint:expr ),*,) => { lint_array!( $( $lint ),* ) }; + ($( $lint:expr ),*) => {{ + static ARRAY: LintArray = &[ $( &$lint ),* ]; + ARRAY + }} +} pub type LintArray = &'static [&'static &'static Lint]; diff --git a/src/test/run-pass-fulldeps/auxiliary/lint_for_crate.rs b/src/test/run-pass-fulldeps/auxiliary/lint_for_crate.rs index d3f921e0878ae..878d64c3473b1 100644 --- a/src/test/run-pass-fulldeps/auxiliary/lint_for_crate.rs +++ b/src/test/run-pass-fulldeps/auxiliary/lint_for_crate.rs @@ -23,26 +23,57 @@ use rustc_plugin::Registry; use rustc::hir; use syntax::attr; -declare_lint!(CRATE_NOT_OKAY, Warn, "crate not marked with #![crate_okay]"); +macro_rules! fake_lint_pass { + ($struct:ident, $lints:expr, $($attr:expr),*) => { + struct $struct; + + impl LintPass for $struct { + fn get_lints(&self) -> LintArray { + $lints + } + } -struct Pass; + impl<'a, 'tcx> LateLintPass<'a, 'tcx> for $struct { + fn check_crate(&mut self, cx: &LateContext, krate: &hir::Crate) { + $( + if !attr::contains_name(&krate.attrs, $attr) { + cx.span_lint(CRATE_NOT_OKAY, krate.span, + &format!("crate is not marked with #![{}]", $attr)); + } + )* + } + } -impl LintPass for Pass { - fn get_lints(&self) -> LintArray { - lint_array!(CRATE_NOT_OKAY) } } -impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { - fn check_crate(&mut self, cx: &LateContext, krate: &hir::Crate) { - if !attr::contains_name(&krate.attrs, "crate_okay") { - cx.span_lint(CRATE_NOT_OKAY, krate.span, - "crate is not marked with #![crate_okay]"); - } - } +declare_lint!(CRATE_NOT_OKAY, Warn, "crate not marked with #![crate_okay]"); +declare_lint!(CRATE_NOT_RED, Warn, "crate not marked with #![crate_red]"); +declare_lint!(CRATE_NOT_BLUE, Warn, "crate not marked with #![crate_blue]"); +declare_lint!(CRATE_NOT_GREY, Warn, "crate not marked with #![crate_grey]"); +declare_lint!(CRATE_NOT_GREEN, Warn, "crate not marked with #![crate_green]"); + +fake_lint_pass! { + PassOkay, + lint_array!(CRATE_NOT_OKAY), // Single lint + "crate_okay" +} + +fake_lint_pass! { + PassRedBlue, + lint_array!(CRATE_NOT_RED, CRATE_NOT_BLUE), // Multiple lints + "crate_red", "crate_blue" +} + +fake_lint_pass! { + PassGreyGreen, + lint_array!(CRATE_NOT_GREY, CRATE_NOT_GREEN, ), // Trailing comma + "crate_grey", "crate_green" } #[plugin_registrar] pub fn plugin_registrar(reg: &mut Registry) { - reg.register_late_lint_pass(box Pass); + reg.register_late_lint_pass(box PassOkay); + reg.register_late_lint_pass(box PassRedBlue); + reg.register_late_lint_pass(box PassGreyGreen); } diff --git a/src/test/run-pass-fulldeps/issue-15778-pass.rs b/src/test/run-pass-fulldeps/issue-15778-pass.rs index a767779687a3d..25800d40e71ae 100644 --- a/src/test/run-pass-fulldeps/issue-15778-pass.rs +++ b/src/test/run-pass-fulldeps/issue-15778-pass.rs @@ -15,5 +15,9 @@ #![feature(plugin, custom_attribute)] #![plugin(lint_for_crate)] #![crate_okay] +#![crate_blue] +#![crate_red] +#![crate_grey] +#![crate_green] pub fn main() { } From dcf0cd0ac00a91afcc24e4c073dd99befa188091 Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Tue, 16 Jan 2018 23:21:51 +0100 Subject: [PATCH 33/38] Only enable CloudABI builds for x86-64 for now. We'll turn on other architectures if it turns out we have enough capacity. --- src/ci/docker/dist-various-2/Dockerfile | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/ci/docker/dist-various-2/Dockerfile b/src/ci/docker/dist-various-2/Dockerfile index 5284a1c875ce4..d8f09bf47a491 100644 --- a/src/ci/docker/dist-various-2/Dockerfile +++ b/src/ci/docker/dist-various-2/Dockerfile @@ -23,8 +23,6 @@ RUN add-apt-repository -y 'deb http://apt.dilos.org/dilos dilos2-testing main' WORKDIR /tmp COPY dist-various-2/shared.sh /tmp/ COPY dist-various-2/build-cloudabi-toolchain.sh /tmp/ -RUN /tmp/build-cloudabi-toolchain.sh aarch64-unknown-cloudabi -RUN /tmp/build-cloudabi-toolchain.sh i686-unknown-cloudabi RUN /tmp/build-cloudabi-toolchain.sh x86_64-unknown-cloudabi COPY dist-various-2/build-fuchsia-toolchain.sh /tmp/ RUN /tmp/build-fuchsia-toolchain.sh @@ -52,12 +50,6 @@ ENV \ # FIXME(EdSchouten): Remove this once cc ≥1.0.4 has been merged. It can # automatically pick the right compiler path. ENV \ - AR_aarch64_unknown_cloudabi=aarch64-unknown-cloudabi-ar \ - CC_aarch64_unknown_cloudabi=aarch64-unknown-cloudabi-clang \ - CXX_aarch64_unknown_cloudabi=aarch64-unknown-cloudabi-clang++ \ - AR_i686_unknown_cloudabi=i686-unknown-cloudabi-ar \ - CC_i686_unknown_cloudabi=i686-unknown-cloudabi-clang \ - CXX_i686_unknown_cloudabi=i686-unknown-cloudabi-clang++ \ AR_x86_64_unknown_cloudabi=x86_64-unknown-cloudabi-ar \ CC_x86_64_unknown_cloudabi=x86_64-unknown-cloudabi-clang \ CXX_x86_64_unknown_cloudabi=x86_64-unknown-cloudabi-clang++ @@ -68,10 +60,6 @@ ENV TARGETS=$TARGETS,sparcv9-sun-solaris ENV TARGETS=$TARGETS,wasm32-unknown-unknown ENV TARGETS=$TARGETS,x86_64-sun-solaris ENV TARGETS=$TARGETS,x86_64-unknown-linux-gnux32 -ENV TARGETS=$TARGETS,aarch64-unknown-cloudabi -# FIXME(EdSchouten): Enable ARMv7 support once libc ≥0.2.37 has been merged. -# ENV TARGETS=$TARGETS,armv7-unknown-cloudabi-eabihf -ENV TARGETS=$TARGETS,i686-unknown-cloudabi ENV TARGETS=$TARGETS,x86_64-unknown-cloudabi ENV RUST_CONFIGURE_ARGS --target=$TARGETS --enable-extended From 16063416979e1f8643375e62e331b019a3ac8d4c Mon Sep 17 00:00:00 2001 From: Segev Finer Date: Wed, 17 Jan 2018 01:18:04 +0200 Subject: [PATCH 34/38] Document the mingw -lmsvcrt hack better --- src/librustc_back/target/windows_base.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/librustc_back/target/windows_base.rs b/src/librustc_back/target/windows_base.rs index 7a901dc913f94..cc40b8b052983 100644 --- a/src/librustc_back/target/windows_base.rs +++ b/src/librustc_back/target/windows_base.rs @@ -59,7 +59,15 @@ pub fn opts() -> TargetOptions { "-lmingw32".to_string(), "-lgcc".to_string(), // alas, mingw* libraries above depend on libgcc "-lmsvcrt".to_string(), - "-lmsvcrt".to_string(), // mingw is insane...? + // mingw's msvcrt is a weird hybrid import library and static library. + // And it seems that the linker fails to use import symbols from msvcrt + // that are required from functions in msvcrt in certain cases. For example + // `_fmode` that is used by an implementation of `__p__fmode` in x86_64. + // Listing the library twice seems to fix that, and seems to also be done + // by mingw's gcc (Though not sure if it's done on purpose, or by mistake). + // + // See https://github.com/rust-lang/rust/pull/47483 + "-lmsvcrt".to_string(), "-luser32".to_string(), "-lkernel32".to_string(), ]); From 6defae31f6bf548f75974c555b4cceaef4b8ef15 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 16 Jan 2018 15:49:58 -0800 Subject: [PATCH 35/38] rustc: Spawn `cmd /c` for `.bat` scripts This fixes an accidental regression #46335 where the behavior of `Path::ends_with` is different from `str::ends_with` (paths operate over components, strs operate over chars). --- src/librustc_trans/back/link.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index 13a319d31bf06..f53c5b3f58131 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -69,13 +69,14 @@ pub fn get_linker(sess: &Session) -> (PathBuf, Command, Vec<(OsString, OsString) // was tagged as #42791) and some more info can be found on #44443 for // emscripten itself. let cmd = |linker: &Path| { - if cfg!(windows) && linker.ends_with(".bat") { - let mut cmd = Command::new("cmd"); - cmd.arg("/c").arg(linker); - cmd - } else { - Command::new(linker) + if let Some(linker) = linker.to_str() { + if cfg!(windows) && linker.ends_with(".bat") { + let mut cmd = Command::new("cmd"); + cmd.arg("/c").arg(linker); + return cmd + } } + Command::new(linker) }; if let Some(ref linker) = sess.opts.cg.linker { From 2c5542fcec2ebcd58235070a72a322be67bd3199 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 16 Jan 2018 18:06:32 -0800 Subject: [PATCH 36/38] Update rust-installer for streaming parallelism Pull in rust-lang/rust-installer#76 to get streamed tarball generation, rather than batching it all in memory, while still getting the benefit of compressing in parallel. --- src/Cargo.lock | 7 ++++--- src/tools/rust-installer | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index 8fbf3535264fc..779e5e914583f 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -907,10 +907,11 @@ dependencies = [ "flate2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "tar 0.4.14 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "xz2 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "xz2 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2776,7 +2777,7 @@ dependencies = [ [[package]] name = "xz2" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lzma-sys 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3005,5 +3006,5 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum wincolor 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a39ee4464208f6430992ff20154216ab2357772ac871d994c51628d60e58b8b0" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" "checksum xattr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "5f04de8a1346489a2f9e9bd8526b73d135ec554227b17568456e86aa35b6f3fc" -"checksum xz2 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e9510bdf100731599107c61f77daf46713a69a568f75458999c1f9dbf6ba25b0" +"checksum xz2 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "98df591c3504d014dd791d998123ed00a476c7e26dc6b2e873cb55c6ac9e59fa" "checksum yaml-rust 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e66366e18dc58b46801afbf2ca7661a9f59cc8c5962c29892b6039b4f86fa992" diff --git a/src/tools/rust-installer b/src/tools/rust-installer index 745a020e924c0..b55e0fc77590c 160000 --- a/src/tools/rust-installer +++ b/src/tools/rust-installer @@ -1 +1 @@ -Subproject commit 745a020e924c0532b01e8f017ed72820913642ee +Subproject commit b55e0fc77590cf5d23a01dedeb2104d8cbb48efc From eb3da09333870e94b122d863402d993fb7ecd78f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 16 Jan 2018 18:11:35 -0800 Subject: [PATCH 37/38] Add secondary span pointing at the statement (error span) --- src/libsyntax_ext/format.rs | 8 +++- src/test/ui/macros/format-foreign.stderr | 3 +- .../ui/macros/format-unused-lables.stderr | 37 ++++++++++++------- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index 29280d203c79f..a7822414c6959 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -814,8 +814,12 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, let (sp, msg) = errs.into_iter().next().unwrap(); cx.ecx.struct_span_err(sp, msg) } else { - cx.ecx.struct_span_err(errs.iter().map(|&(sp, _)| sp).collect::>(), - "multiple unused formatting arguments") + let mut diag = cx.ecx.struct_span_err( + errs.iter().map(|&(sp, _)| sp).collect::>(), + "multiple unused formatting arguments" + ); + diag.span_label(cx.fmtsp, "multiple unused arguments in this statement"); + diag } }; diff --git a/src/test/ui/macros/format-foreign.stderr b/src/test/ui/macros/format-foreign.stderr index 31804ca4c40d1..f9852c5477332 100644 --- a/src/test/ui/macros/format-foreign.stderr +++ b/src/test/ui/macros/format-foreign.stderr @@ -2,11 +2,12 @@ error: multiple unused formatting arguments --> $DIR/format-foreign.rs:12:30 | 12 | println!("%.*3$s %s!/n", "Hello,", "World", 4); //~ ERROR multiple unused formatting arguments - | ^^^^^^^^ ^^^^^^^ ^ + | -------------------------^^^^^^^^--^^^^^^^--^-- multiple unused arguments in this statement | = help: `%.*3$s` should be written as `{:.2$}` = help: `%s` should be written as `{}` = note: printf formatting not supported; see the documentation for `std::fmt` + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: argument never used --> $DIR/format-foreign.rs:13:29 diff --git a/src/test/ui/macros/format-unused-lables.stderr b/src/test/ui/macros/format-unused-lables.stderr index 59aed9d8bc6fb..64ea5626c1d62 100644 --- a/src/test/ui/macros/format-unused-lables.stderr +++ b/src/test/ui/macros/format-unused-lables.stderr @@ -2,17 +2,24 @@ error: multiple unused formatting arguments --> $DIR/format-unused-lables.rs:12:22 | 12 | println!("Test", 123, 456, 789); - | ^^^ ^^^ ^^^ + | -----------------^^^--^^^--^^^-- multiple unused arguments in this statement + | + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: multiple unused formatting arguments --> $DIR/format-unused-lables.rs:16:9 | -16 | 123, //~ ERROR multiple unused formatting arguments - | ^^^ -17 | 456, - | ^^^ -18 | 789 - | ^^^ +15 | / println!("Test2", +16 | | 123, //~ ERROR multiple unused formatting arguments + | | ^^^ +17 | | 456, + | | ^^^ +18 | | 789 + | | ^^^ +19 | | ); + | |______- multiple unused arguments in this statement + | + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: named argument never used --> $DIR/format-unused-lables.rs:21:35 @@ -23,16 +30,18 @@ error: named argument never used error: multiple unused formatting arguments --> $DIR/format-unused-lables.rs:24:9 | -24 | "woo!", //~ ERROR multiple unused formatting arguments - | ^^^^^^ -25 | STUFF= -26 | "things" - | ^^^^^^^^ -27 | , UNUSED="args"); - | ^^^^^^ +23 | / println!("Some more $STUFF", +24 | | "woo!", //~ ERROR multiple unused formatting arguments + | | ^^^^^^ +25 | | STUFF= +26 | | "things" + | | ^^^^^^^^ +27 | | , UNUSED="args"); + | |_______________________^^^^^^_- multiple unused arguments in this statement | = help: `$STUFF` should be written as `{STUFF}` = note: shell formatting not supported; see the documentation for `std::fmt` + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: aborting due to 4 previous errors From 86d630104667dc7ce3e606bcccf910d4c11785db Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 17 Jan 2018 12:21:14 +0100 Subject: [PATCH 38/38] whitelist x86 fxsr feature --- src/librustc_trans/llvm_util.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/librustc_trans/llvm_util.rs b/src/librustc_trans/llvm_util.rs index 8112a9eeab1ef..214fdbded4e90 100644 --- a/src/librustc_trans/llvm_util.rs +++ b/src/librustc_trans/llvm_util.rs @@ -85,7 +85,8 @@ const X86_WHITELIST: &'static [&'static str] = &["avx\0", "avx2\0", "bmi\0", "bm "avx512dq\0", "avx512er\0", "avx512f\0", "avx512ifma\0", "avx512pf\0", "avx512vbmi\0", - "avx512vl\0", "avx512vpopcntdq\0", "mmx\0"]; + "avx512vl\0", "avx512vpopcntdq\0", + "mmx\0", "fxsr\0"]; const HEXAGON_WHITELIST: &'static [&'static str] = &["hvx\0", "hvx-double\0"];