From bdc34fd7f7691def549a062439415eb76edd5c8b Mon Sep 17 00:00:00 2001 From: andjo403 <andjo403@users.noreply.github.com> Date: Tue, 9 Jan 2018 22:09:01 +0100 Subject: [PATCH 01/43] 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 45cad0456f6d8624e8c9d66709444106748a1f03 Mon Sep 17 00:00:00 2001 From: Oliver Middleton <olliemail27@gmail.com> Date: Wed, 10 Jan 2018 07:05:30 +0000 Subject: [PATCH 02/43] rustdoc: Populate external_traits with traits only seen in impls This means default methods can always be found and "Important traits" will include all spotlight traits. --- src/librustdoc/clean/inline.rs | 9 ++++++++ src/librustdoc/clean/mod.rs | 3 +-- src/librustdoc/html/render.rs | 5 ++--- .../auxiliary/impl-inline-without-trait.rs | 18 +++++++++++++++ .../inline_cross/impl-inline-without-trait.rs | 22 +++++++++++++++++++ 5 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 src/test/rustdoc/inline_cross/auxiliary/impl-inline-without-trait.rs create mode 100644 src/test/rustdoc/inline_cross/impl-inline-without-trait.rs diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 914365b003e18..26919239bb9a8 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -349,6 +349,9 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec<clean::Item>) { if trait_.def_id() == tcx.lang_items().deref_trait() { super::build_deref_target_impls(cx, &trait_items, ret); } + if let Some(trait_did) = trait_.def_id() { + record_extern_trait(cx, trait_did); + } let provided = trait_.def_id().map(|did| { tcx.provided_trait_methods(did) @@ -504,3 +507,9 @@ fn separate_supertrait_bounds(mut g: clean::Generics) }); (g, ty_bounds) } + +pub fn record_extern_trait(cx: &DocContext, did: DefId) { + cx.external_traits.borrow_mut().entry(did).or_insert_with(|| { + build_external_trait(cx, did) + }); +} diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 265114ae826f4..48b1c46ec01aa 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -3189,8 +3189,7 @@ fn register_def(cx: &DocContext, def: Def) -> DefId { if did.is_local() { return did } inline::record_extern_fqn(cx, did, kind); if let TypeKind::Trait = kind { - let t = inline::build_external_trait(cx, did); - cx.external_traits.borrow_mut().insert(did, t); + inline::record_extern_trait(cx, did); } did } diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 7449c08fcd290..5aa03227d1d33 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -3291,8 +3291,7 @@ fn spotlight_decl(decl: &clean::FnDecl) -> Result<String, fmt::Error> { if let Some(impls) = c.impls.get(&did) { for i in impls { let impl_ = i.inner_impl(); - if impl_.trait_.def_id().and_then(|d| c.traits.get(&d)) - .map_or(false, |t| t.is_spotlight) { + if impl_.trait_.def_id().map_or(false, |d| c.traits[&d].is_spotlight) { if out.is_empty() { out.push_str( &format!("<h3 class=\"important\">Important traits for {}</h3>\ @@ -3458,7 +3457,7 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi } let traits = &cache().traits; - let trait_ = i.trait_did().and_then(|did| traits.get(&did)); + let trait_ = i.trait_did().map(|did| &traits[&did]); if !show_def_docs { write!(w, "<span class='docblock autohide'>")?; diff --git a/src/test/rustdoc/inline_cross/auxiliary/impl-inline-without-trait.rs b/src/test/rustdoc/inline_cross/auxiliary/impl-inline-without-trait.rs new file mode 100644 index 0000000000000..5d4adb28cd83a --- /dev/null +++ b/src/test/rustdoc/inline_cross/auxiliary/impl-inline-without-trait.rs @@ -0,0 +1,18 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub trait MyTrait { + /// docs for my_trait_method + fn my_trait_method() {} +} + +pub struct MyStruct; + +impl MyTrait for MyStruct {} diff --git a/src/test/rustdoc/inline_cross/impl-inline-without-trait.rs b/src/test/rustdoc/inline_cross/impl-inline-without-trait.rs new file mode 100644 index 0000000000000..ea97d9d6ac2c2 --- /dev/null +++ b/src/test/rustdoc/inline_cross/impl-inline-without-trait.rs @@ -0,0 +1,22 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:impl-inline-without-trait.rs +// build-aux-docs +// ignore-cross-compile + +#![crate_name = "foo"] + +extern crate impl_inline_without_trait; + +// @has 'foo/struct.MyStruct.html' +// @has - '//*[@id="method.my_trait_method"]' 'fn my_trait_method()' +// @has - '//*[@class="docblock"]' 'docs for my_trait_method' +pub use impl_inline_without_trait::MyStruct; From f7b48778b1472045bd8b7ee6aacdbf1487efe50b Mon Sep 17 00:00:00 2001 From: Mikko Rantanen <jubjub@jubjubnest.net> Date: Fri, 12 Jan 2018 12:37:48 +0200 Subject: [PATCH 03/43] 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 f18c52b2233b8d1142fea29551e140fd15d3ae70 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez <guillaume1.gomez@gmail.com> Date: Tue, 12 Dec 2017 23:53:24 +0100 Subject: [PATCH 04/43] Start adding js tests --- src/bootstrap/check.rs | 35 ++++++++++++++++++++++++++++++++++ src/bootstrap/tool.rs | 1 + src/test/rustdoc-js/basic.js | 15 +++++++++++++++ src/tools/rustdoc-js/tester.js | 26 +++++++++++++++++++++++++ 4 files changed, 77 insertions(+) create mode 100644 src/test/rustdoc-js/basic.js create mode 100644 src/tools/rustdoc-js/tester.js diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index cc9be3cec3476..d4be0de6a1eae 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -424,6 +424,40 @@ fn path_for_cargo(builder: &Builder, compiler: Compiler) -> OsString { env::join_paths(iter::once(path).chain(env::split_paths(&old_path))).expect("") } +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct RustdocJS { + pub host: Interned<String>, +} + +impl Step for RustdocJS { + type Output = PathBuf; + const DEFAULT: bool = true; + const ONLY_HOSTS: bool = true; + + fn should_run(run: ShouldRun) -> ShouldRun { + run.path("node") + } + + fn make_run(run: RunConfig) { + run.builder.ensure(RustdocJS { + host: run.host, + }); + } + + fn run(self, _: &Builder) { + let cmd = if cfg!(target_os = "windows") { + let command = Command::new("cmd"); + command.args(&["/C", "node src/tools/rustdoc-js/tester.js"]); + command + } else { + let command = Command::new("sh"); + command.args(&["-c", "node src/tools/rustdoc-js/tester.js"]); + command + }; + builder.run(cmd); + } +} + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct Tidy { host: Interned<String>, @@ -570,6 +604,7 @@ static HOST_COMPILETESTS: &[Test] = &[ }, Test { path: "src/test/run-make", mode: "run-make", suite: "run-make" }, Test { path: "src/test/rustdoc", mode: "rustdoc", suite: "rustdoc" }, + Test { path: "src/test/rustdoc-js", mode: "rustdoc-js", suite: "rustdoc-js" }, Test { path: "src/test/pretty", mode: "pretty", suite: "pretty" }, Test { path: "src/test/run-pass/pretty", mode: "pretty", suite: "run-pass" }, diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index ea055cb5d1b99..d80d7732ab266 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -260,6 +260,7 @@ tool!( BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::Libstd; RemoteTestClient, "src/tools/remote-test-client", "remote-test-client", Mode::Libstd; RustInstaller, "src/tools/rust-installer", "fabricate", Mode::Libstd; + RustdocJS, "node", "node", Mode::Tool; ); #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] diff --git a/src/test/rustdoc-js/basic.js b/src/test/rustdoc-js/basic.js new file mode 100644 index 0000000000000..2eada17f0db69 --- /dev/null +++ b/src/test/rustdoc-js/basic.js @@ -0,0 +1,15 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +const QUERY = 'String'; + +const EXPECTED = [ + {'all': ['std::string::String']}, +]; diff --git a/src/tools/rustdoc-js/tester.js b/src/tools/rustdoc-js/tester.js new file mode 100644 index 0000000000000..9789c007d1600 --- /dev/null +++ b/src/tools/rustdoc-js/tester.js @@ -0,0 +1,26 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +const fs = require('fs'); + +const TEST_FOLDER = 'src/test/rustdoc-js/'; + +function loadFile(filePath) { + var src = fs.readFileSync(filePath, 'utf8').split('\n').slice(15, -10).join('\n'); + var Module = module.constructor; + var m = new Module(); + m._compile(src, filePath); + return m; +} + +fs.readdirSync(TEST_FOLDER).forEach(function(file) { + var file = require(TEST_FOLDER + file); + const expected = file.EXPECTED; +}); From 53d8ec0ecb6e16e25d7646d6f6c143ac2d8f1819 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez <guillaume1.gomez@gmail.com> Date: Sun, 7 Jan 2018 16:19:44 +0100 Subject: [PATCH 05/43] Prepare main.js for tests --- src/librustdoc/html/static/main.js | 82 ++++++++++++++---------------- 1 file changed, 39 insertions(+), 43 deletions(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index b4dbd76d0b4d0..a9a5bd5de0552 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -353,35 +353,33 @@ * This code is an unmodified version of the code written by Marco de Wit * and was found at http://stackoverflow.com/a/18514751/745719 */ - var levenshtein = (function() { - var row2 = []; - return function(s1, s2) { - if (s1 === s2) { - return 0; + var levenshtein_row2 = []; + function levenshtein(s1, s2) { + if (s1 === s2) { + return 0; + } + var s1_len = s1.length, s2_len = s2.length; + if (s1_len && s2_len) { + var i1 = 0, i2 = 0, a, b, c, c2, row = levenshtein_row2; + while (i1 < s1_len) { + row[i1] = ++i1; } - var s1_len = s1.length, s2_len = s2.length; - if (s1_len && s2_len) { - var i1 = 0, i2 = 0, a, b, c, c2, row = row2; - while (i1 < s1_len) { - row[i1] = ++i1; - } - while (i2 < s2_len) { - c2 = s2.charCodeAt(i2); - a = i2; - ++i2; - b = i2; - for (i1 = 0; i1 < s1_len; ++i1) { - c = a + (s1.charCodeAt(i1) !== c2 ? 1 : 0); - a = row[i1]; - b = b < a ? (b < c ? b + 1 : c) : (a < c ? a + 1 : c); - row[i1] = b; - } + while (i2 < s2_len) { + c2 = s2.charCodeAt(i2); + a = i2; + ++i2; + b = i2; + for (i1 = 0; i1 < s1_len; ++i1) { + c = a + (s1.charCodeAt(i1) !== c2 ? 1 : 0); + a = row[i1]; + b = b < a ? (b < c ? b + 1 : c) : (a < c ? a + 1 : c); + row[i1] = b; } - return b; } - return s1_len + s2_len; - }; - })(); + return b; + } + return s1_len + s2_len; + } function initSearch(rawSearchIndex) { var currentResults, index, searchIndex; @@ -400,12 +398,20 @@ /** * Executes the query and builds an index of results * @param {[Object]} query [The user query] - * @param {[type]} max [The maximum results returned] * @param {[type]} searchWords [The list of search words to query * against] * @return {[type]} [A search index of results] */ - function execQuery(query, max, searchWords) { + function execQuery(query, searchWords) { + function itemTypeFromName(typename) { + for (var i = 0; i < itemTypes.length; ++i) { + if (itemTypes[i] === typename) { + return i; + } + } + return -1; + } + var valLower = query.query.toLowerCase(), val = valLower, typeFilter = itemTypeFromName(query.type), @@ -1021,9 +1027,8 @@ return true; } - function getQuery() { - var matches, type, query, raw = - document.getElementsByClassName('search-input')[0].value; + function getQuery(raw) { + var matches, type, query; query = raw; matches = query.match(/^(fn|mod|struct|enum|trait|type|const|macro)\s*:\s*/i); @@ -1227,7 +1232,7 @@ } function showResults(results) { - var output, query = getQuery(); + var output, query = getQuery(document.getElementsByClassName('search-input')[0].value); currentResults = query.id; output = '<h1>Results for ' + escape(query.query) + @@ -1271,7 +1276,7 @@ resultIndex; var params = getQueryStringParams(); - query = getQuery(); + query = getQuery(document.getElementsByClassName('search-input')[0].value); if (e) { e.preventDefault(); } @@ -1293,19 +1298,10 @@ } } - results = execQuery(query, 20000, index); + results = execQuery(query, index); showResults(results); } - function itemTypeFromName(typename) { - for (var i = 0; i < itemTypes.length; ++i) { - if (itemTypes[i] === typename) { - return i; - } - } - return -1; - } - function buildIndex(rawSearchIndex) { searchIndex = []; var searchWords = []; From 43acd233b396383a30860108e437829521eba114 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez <guillaume1.gomez@gmail.com> Date: Sun, 7 Jan 2018 16:20:25 +0100 Subject: [PATCH 06/43] Add tester and a few tests --- src/test/rustdoc-js/basic.js | 18 ++- src/test/rustdoc-js/enum-option.js | 17 +++ src/test/rustdoc-js/fn-forget.js | 18 +++ src/test/rustdoc-js/from_u.js | 22 +++ src/test/rustdoc-js/macro-print.js | 20 +++ src/test/rustdoc-js/string-from_ut.js | 21 +++ src/test/rustdoc-js/struct-vec.js | 19 +++ src/tools/rustdoc-js/tester.js | 202 ++++++++++++++++++++++++-- 8 files changed, 324 insertions(+), 13 deletions(-) create mode 100644 src/test/rustdoc-js/enum-option.js create mode 100644 src/test/rustdoc-js/fn-forget.js create mode 100644 src/test/rustdoc-js/from_u.js create mode 100644 src/test/rustdoc-js/macro-print.js create mode 100644 src/test/rustdoc-js/string-from_ut.js create mode 100644 src/test/rustdoc-js/struct-vec.js diff --git a/src/test/rustdoc-js/basic.js b/src/test/rustdoc-js/basic.js index 2eada17f0db69..863437cac91d4 100644 --- a/src/test/rustdoc-js/basic.js +++ b/src/test/rustdoc-js/basic.js @@ -1,4 +1,4 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// 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. // @@ -10,6 +10,16 @@ const QUERY = 'String'; -const EXPECTED = [ - {'all': ['std::string::String']}, -]; +const EXPECTED = { + 'others': [ + { 'path': 'std::string', 'name': 'String' }, + { 'path': 'std::ffi', 'name': 'OsString' }, + { 'path': 'std::ffi', 'name': 'CString' }, + ], + 'in_args': [ + { 'path': 'std::str', 'name': 'eq' }, + ], + 'returned': [ + { 'path': 'std::string::String', 'name': 'add' }, + ], +}; diff --git a/src/test/rustdoc-js/enum-option.js b/src/test/rustdoc-js/enum-option.js new file mode 100644 index 0000000000000..3dac983b11b0e --- /dev/null +++ b/src/test/rustdoc-js/enum-option.js @@ -0,0 +1,17 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +const QUERY = 'enum:Option'; + +const EXPECTED = { + 'others': [ + { 'path': 'std::option', 'name': 'Option' }, + ], +}; diff --git a/src/test/rustdoc-js/fn-forget.js b/src/test/rustdoc-js/fn-forget.js new file mode 100644 index 0000000000000..10310d5eaf7b9 --- /dev/null +++ b/src/test/rustdoc-js/fn-forget.js @@ -0,0 +1,18 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +const QUERY = 'fn:forget'; + +const EXPECTED = { + 'others': [ + { 'path': 'std::mem', 'name': 'forget' }, + { 'path': 'std::fmt', 'name': 'format' }, + ], +}; diff --git a/src/test/rustdoc-js/from_u.js b/src/test/rustdoc-js/from_u.js new file mode 100644 index 0000000000000..920620a9aeed5 --- /dev/null +++ b/src/test/rustdoc-js/from_u.js @@ -0,0 +1,22 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +const QUERY = 'from_u'; + +const EXPECTED = { + 'others': [ + { 'path': 'std::char', 'name': 'from_u32' }, + { 'path': 'std::str', 'name': 'from_utf8' }, + { 'path': 'std::string::String', 'name': 'from_utf8' }, + { 'path': 'std::boxed::Box', 'name': 'from_unique' }, + { 'path': 'std::i32', 'name': 'from_unsigned' }, + { 'path': 'std::i128', 'name': 'from_unsigned' }, + ], +}; diff --git a/src/test/rustdoc-js/macro-print.js b/src/test/rustdoc-js/macro-print.js new file mode 100644 index 0000000000000..811ba3474afa0 --- /dev/null +++ b/src/test/rustdoc-js/macro-print.js @@ -0,0 +1,20 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +const QUERY = 'macro:print'; + +const EXPECTED = { + 'others': [ + { 'path': 'std', 'name': 'print' }, + { 'path': 'std', 'name': 'eprint' }, + { 'path': 'std', 'name': 'println' }, + { 'path': 'std', 'name': 'eprintln' }, + ], +}; diff --git a/src/test/rustdoc-js/string-from_ut.js b/src/test/rustdoc-js/string-from_ut.js new file mode 100644 index 0000000000000..3d08ee3736612 --- /dev/null +++ b/src/test/rustdoc-js/string-from_ut.js @@ -0,0 +1,21 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +const QUERY = 'String::from_ut'; + +const EXPECTED = { + 'others': [ + { 'path': 'std::string::String', 'name': 'from_utf8' }, + { 'path': 'std::string::String', 'name': 'from_utf8' }, + { 'path': 'std::string::String', 'name': 'from_utf8_lossy' }, + { 'path': 'std::string::String', 'name': 'from_utf16_lossy' }, + { 'path': 'std::string::String', 'name': 'from_utf8_unchecked' }, + ], +}; diff --git a/src/test/rustdoc-js/struct-vec.js b/src/test/rustdoc-js/struct-vec.js new file mode 100644 index 0000000000000..a91bc2d0da288 --- /dev/null +++ b/src/test/rustdoc-js/struct-vec.js @@ -0,0 +1,19 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +const QUERY = 'struct:Vec'; + +const EXPECTED = { + 'others': [ + { 'path': 'std::vec', 'name': 'Vec' }, + { 'path': 'std::collections', 'name': 'VecDeque' }, + { 'path': 'alloc::raw_vec', 'name': 'RawVec' }, + ], +}; diff --git a/src/tools/rustdoc-js/tester.js b/src/tools/rustdoc-js/tester.js index 9789c007d1600..9b7e151b1ffec 100644 --- a/src/tools/rustdoc-js/tester.js +++ b/src/tools/rustdoc-js/tester.js @@ -1,4 +1,4 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// 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. // @@ -12,15 +12,199 @@ const fs = require('fs'); const TEST_FOLDER = 'src/test/rustdoc-js/'; -function loadFile(filePath) { - var src = fs.readFileSync(filePath, 'utf8').split('\n').slice(15, -10).join('\n'); +// Stupid function extractor based on indent. +function extractFunction(content, functionName) { + var x = content.split('\n'); + var in_func = false; + var indent = 0; + var lines = []; + + for (var i = 0; i < x.length; ++i) { + if (in_func === false) { + var splitter = "function " + functionName + "("; + if (x[i].trim().startsWith(splitter)) { + in_func = true; + indent = x[i].split(splitter)[0].length; + lines.push(x[i]); + } + } else { + lines.push(x[i]); + if (x[i].trim() === "}" && x[i].split("}")[0].length === indent) { + return lines.join("\n"); + } + } + } + return null; +} + +// Stupid function extractor for array. +function extractArrayVariable(content, arrayName) { + var x = content.split('\n'); + var found_var = false; + var lines = []; + + for (var i = 0; i < x.length; ++i) { + if (found_var === false) { + var splitter = "var " + arrayName + " = ["; + if (x[i].trim().startsWith(splitter)) { + found_var = true; + i -= 1; + } + } else { + lines.push(x[i]); + if (x[i].endsWith('];')) { + return lines.join("\n"); + } + } + } + return null; +} + +// Stupid function extractor for variable. +function extractVariable(content, varName) { + var x = content.split('\n'); + var found_var = false; + var lines = []; + + for (var i = 0; i < x.length; ++i) { + if (found_var === false) { + var splitter = "var " + varName + " = "; + if (x[i].trim().startsWith(splitter)) { + found_var = true; + i -= 1; + } + } else { + lines.push(x[i]); + if (x[i].endsWith(';')) { + return lines.join("\n"); + } + } + } + return null; +} + +function loadContent(content) { var Module = module.constructor; var m = new Module(); - m._compile(src, filePath); - return m; + m._compile(content, "tmp.js"); + return m.exports; +} + +function readFile(filePath) { + return fs.readFileSync(filePath, 'utf8'); +} + +function loadThings(thingsToLoad, kindOfLoad, funcToCall, fileContent) { + var content = ''; + for (var i = 0; i < thingsToLoad.length; ++i) { + var tmp = funcToCall(fileContent, thingsToLoad[i]); + if (tmp === null) { + console.error('enable to find ' + kindOfLoad + ' "' + thingsToLoad[i] + '"'); + process.exit(1); + } + content += tmp; + content += 'exports.' + thingsToLoad[i] + ' = ' + thingsToLoad[i] + ';'; + } + return content; +} + +function lookForEntry(entry, data) { + for (var i = 0; i < data.length; ++i) { + var allGood = true; + for (var key in entry) { + if (!entry.hasOwnProperty(key)) { + continue; + } + let value = data[i][key]; + // To make our life easier, if there is a "parent" type, we add it to the path. + if (key === 'path' && data[i]['parent'] !== undefined) { + if (value.length > 0) { + value += '::' + data[i]['parent']['name']; + } else { + value = data[i]['parent']['name']; + } + } + if (value !== entry[key]) { + allGood = false; + break; + } + } + if (allGood === true) { + return true; + } + } + return false; +} + +function main(argv) { + if (argv.length !== 3) { + console.error("Expected toolchain to check as argument (for example 'x86_64-apple-darwin'"); + return 1; + } + var toolchain = argv[2]; + + var mainJs = readFile("build/" + toolchain + "/doc/main.js"); + var searchIndex = readFile("build/" + toolchain + "/doc/search-index.js").split("\n"); + if (searchIndex[searchIndex.length - 1].length === 0) { + searchIndex.pop(); + } + searchIndex.pop(); + searchIndex = loadContent(searchIndex.join("\n") + '\nexports.searchIndex = searchIndex;'); + finalJS = ""; + + var arraysToLoad = ["itemTypes"]; + var variablesToLoad = ["MAX_LEV_DISTANCE", "MAX_RESULTS", "TY_PRIMITIVE", "levenshtein_row2"]; + // execQuery first parameter is built in getQuery (which takes in the search input). + // execQuery last parameter is built in buildIndex. + // buildIndex requires the hashmap from search-index. + var functionsToLoad = ["levenshtein", "validateResult", "getQuery", "buildIndex", "execQuery"]; + + finalJS += 'window = { "currentCrate": "std" };\n'; + finalJS += loadThings(arraysToLoad, 'array', extractArrayVariable, mainJs); + finalJS += loadThings(variablesToLoad, 'variable', extractVariable, mainJs); + finalJS += loadThings(functionsToLoad, 'function', extractFunction, mainJs); + + var loaded = loadContent(finalJS); + var index = loaded.buildIndex(searchIndex.searchIndex); + + var errors = 0; + + fs.readdirSync(TEST_FOLDER).forEach(function(file) { + var loadedFile = loadContent(readFile(TEST_FOLDER + file) + + 'exports.QUERY = QUERY;exports.EXPECTED = EXPECTED;'); + const expected = loadedFile.EXPECTED; + const query = loadedFile.QUERY; + var results = loaded.execQuery(loaded.getQuery(query), index); + process.stdout.write('Checking "' + file + '" ... '); + var error_text = []; + for (var key in expected) { + if (!expected.hasOwnProperty(key)) { + continue; + } + if (!results.hasOwnProperty(key)) { + error_text.push('==> Unknown key "' + key + '"'); + break; + } + var entry = expected[key]; + var found = false; + for (var i = 0; i < entry.length; ++i) { + if (lookForEntry(entry[i], results[key]) === true) { + found = true; + } else { + error_text.push("==> Result not found in '" + key + "': '" + + JSON.stringify(entry[i]) + "'"); + } + } + } + if (error_text.length !== 0) { + errors += 1; + console.error("FAILED"); + console.error(error_text.join("\n")); + } else { + console.log("OK"); + } + }); + return errors; } -fs.readdirSync(TEST_FOLDER).forEach(function(file) { - var file = require(TEST_FOLDER + file); - const expected = file.EXPECTED; -}); +process.exit(main(process.argv)); From 50bb6ba13eeb66e96db5455d0dc2a7cab5b02e1e Mon Sep 17 00:00:00 2001 From: Guillaume Gomez <guillaume1.gomez@gmail.com> Date: Mon, 8 Jan 2018 23:43:20 +0100 Subject: [PATCH 07/43] Move forward to add rustdoc test --- src/bootstrap/builder.rs | 4 +++- src/bootstrap/check.rs | 21 +++++++-------------- src/bootstrap/tool.rs | 2 +- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index ce30d1f4cec42..be62ce3bf3a0a 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -254,7 +254,9 @@ impl<'a> Builder<'a> { Kind::Test => describe!(check::Tidy, check::Bootstrap, check::DefaultCompiletest, check::HostCompiletest, check::Crate, check::CrateLibrustc, check::Rustdoc, check::Linkcheck, check::Cargotest, check::Cargo, check::Rls, check::Docs, - check::ErrorIndex, check::Distcheck, check::Rustfmt, check::Miri, check::Clippy), + check::ErrorIndex, check::Distcheck, check::Rustfmt, check::Miri, check::Clippy, + check::RustdocJS), + Kind::Bench => describe!(check::Crate, check::CrateLibrustc), Kind::Doc => describe!(doc::UnstableBook, doc::UnstableBookGen, doc::TheBook, doc::Standalone, doc::Std, doc::Test, doc::Rustc, doc::ErrorIndex, doc::Nomicon, diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index d4be0de6a1eae..265e7721a97c0 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -430,12 +430,12 @@ pub struct RustdocJS { } impl Step for RustdocJS { - type Output = PathBuf; + type Output = (); const DEFAULT: bool = true; const ONLY_HOSTS: bool = true; fn should_run(run: ShouldRun) -> ShouldRun { - run.path("node") + run.path("src/tests/rustdoc-js") } fn make_run(run: RunConfig) { @@ -444,17 +444,11 @@ impl Step for RustdocJS { }); } - fn run(self, _: &Builder) { - let cmd = if cfg!(target_os = "windows") { - let command = Command::new("cmd"); - command.args(&["/C", "node src/tools/rustdoc-js/tester.js"]); - command - } else { - let command = Command::new("sh"); - command.args(&["-c", "node src/tools/rustdoc-js/tester.js"]); - command - }; - builder.run(cmd); + fn run(self, builder: &Builder) { + let nodejs = builder.config.nodejs.clone(); + let mut command = Command::new(&nodejs.expect("no nodejs found")); + command.args(&["src/tools/rustdoc-js/tester.js", &*self.host]); + builder.run(&mut command); } } @@ -604,7 +598,6 @@ static HOST_COMPILETESTS: &[Test] = &[ }, Test { path: "src/test/run-make", mode: "run-make", suite: "run-make" }, Test { path: "src/test/rustdoc", mode: "rustdoc", suite: "rustdoc" }, - Test { path: "src/test/rustdoc-js", mode: "rustdoc-js", suite: "rustdoc-js" }, Test { path: "src/test/pretty", mode: "pretty", suite: "pretty" }, Test { path: "src/test/run-pass/pretty", mode: "pretty", suite: "run-pass" }, diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index d80d7732ab266..96947800d44b6 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -260,7 +260,7 @@ tool!( BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::Libstd; RemoteTestClient, "src/tools/remote-test-client", "remote-test-client", Mode::Libstd; RustInstaller, "src/tools/rust-installer", "fabricate", Mode::Libstd; - RustdocJS, "node", "node", Mode::Tool; + RustdocJS, "rustdoc-js", "js-tests", Mode::Tool; ); #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] From 69521996c802e519f2b8f37d92259a7f389cde19 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez <guillaume1.gomez@gmail.com> Date: Fri, 12 Jan 2018 23:40:00 +0100 Subject: [PATCH 08/43] End of rustdoc-js tool add into builder --- src/bootstrap/builder.rs | 3 ++- src/bootstrap/check.rs | 8 +++++++- src/bootstrap/doc.rs | 4 ++-- src/bootstrap/tool.rs | 1 - 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index be62ce3bf3a0a..4db522ebd137e 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -445,7 +445,8 @@ impl<'a> Builder<'a> { let out_dir = self.stage_out(compiler, mode); cargo.env("CARGO_TARGET_DIR", out_dir) .arg(cmd) - .arg("--target").arg(target); + .arg("--target") + .arg(target); // If we were invoked from `make` then that's already got a jobserver // set up for us so no need to tell Cargo about jobs all over again. diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index 265e7721a97c0..bfc0009fcfb0d 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -427,6 +427,7 @@ fn path_for_cargo(builder: &Builder, compiler: Compiler) -> OsString { #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct RustdocJS { pub host: Interned<String>, + pub target: Interned<String>, } impl Step for RustdocJS { @@ -435,12 +436,13 @@ impl Step for RustdocJS { const ONLY_HOSTS: bool = true; fn should_run(run: ShouldRun) -> ShouldRun { - run.path("src/tests/rustdoc-js") + run.path("src/test/rustdoc-js") } fn make_run(run: RunConfig) { run.builder.ensure(RustdocJS { host: run.host, + target: run.target, }); } @@ -448,6 +450,10 @@ impl Step for RustdocJS { let nodejs = builder.config.nodejs.clone(); let mut command = Command::new(&nodejs.expect("no nodejs found")); command.args(&["src/tools/rustdoc-js/tester.js", &*self.host]); + builder.ensure(::doc::Std { + target: self.target, + stage: builder.top_stage, + }); builder.run(&mut command); } } diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 832da24c994db..0930bc15de131 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -418,8 +418,8 @@ impl Step for Standalone { #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct Std { - stage: u32, - target: Interned<String>, + pub stage: u32, + pub target: Interned<String>, } impl Step for Std { diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index 96947800d44b6..ea055cb5d1b99 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -260,7 +260,6 @@ tool!( BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::Libstd; RemoteTestClient, "src/tools/remote-test-client", "remote-test-client", Mode::Libstd; RustInstaller, "src/tools/rust-installer", "fabricate", Mode::Libstd; - RustdocJS, "rustdoc-js", "js-tests", Mode::Tool; ); #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] From 4cedbfc6ee8ef3d35abc22c69903ab3b9573939f Mon Sep 17 00:00:00 2001 From: Gauri <f2013002@goa.bits-pilani.ac.in> Date: Sat, 13 Jan 2018 11:59:35 +0530 Subject: [PATCH 09/43] 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<T>(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 <f2013002@goa.bits-pilani.ac.in> Date: Sat, 13 Jan 2018 13:33:10 +0530 Subject: [PATCH 10/43] 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<T>(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 <f2013002@goa.bits-pilani.ac.in> Date: Sat, 13 Jan 2018 17:13:18 +0530 Subject: [PATCH 11/43] 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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 026c7499895a7c251cc9f72345600195738f22fc Mon Sep 17 00:00:00 2001 From: Guillaume Gomez <guillaume1.gomez@gmail.com> Date: Sat, 13 Jan 2018 22:35:41 +0100 Subject: [PATCH 12/43] Only run rustdoc-js test suite when nodejs is available --- src/bootstrap/check.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index bfc0009fcfb0d..25f2f6bc1d0f6 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -447,14 +447,17 @@ impl Step for RustdocJS { } fn run(self, builder: &Builder) { - let nodejs = builder.config.nodejs.clone(); - let mut command = Command::new(&nodejs.expect("no nodejs found")); - command.args(&["src/tools/rustdoc-js/tester.js", &*self.host]); - builder.ensure(::doc::Std { - target: self.target, - stage: builder.top_stage, - }); - builder.run(&mut command); + if let Some(ref nodejs) = builder.config.nodejs { + let mut command = Command::new(nodejs); + command.args(&["src/tools/rustdoc-js/tester.js", &*self.host]); + builder.ensure(::doc::Std { + target: self.target, + stage: builder.top_stage, + }); + builder.run(&mut command); + } else { + println!("No nodejs found, skipping \"src/test/rustdoc-js\" tests"); + } } } From a22e71685a05478db8f7959db2511d5f1704c40d Mon Sep 17 00:00:00 2001 From: varkor <github@varkor.com> Date: Sun, 14 Jan 2018 17:15:39 +0000 Subject: [PATCH 13/43] 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<String> = (None, parse_opt_string, [UNTRACKED], "dump MIR state at various points in translation"), - dump_mir_dir: Option<String> = (None, parse_opt_string, [UNTRACKED], + dump_mir_dir: Option<String> = (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 <github@varkor.com> Date: Sun, 14 Jan 2018 20:02:07 +0000 Subject: [PATCH 14/43] 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<String> = (None, parse_opt_string, [UNTRACKED], "dump MIR state at various points in translation"), - dump_mir_dir: Option<String> = (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 394b95fdd671a8c9fd252f5288c88d5afba486c7 Mon Sep 17 00:00:00 2001 From: varkor <github@varkor.com> Date: Mon, 15 Jan 2018 00:09:39 +0000 Subject: [PATCH 15/43] 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 <etaoins@gmail.com> Date: Mon, 15 Jan 2018 08:08:22 +1100 Subject: [PATCH 16/43] 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 b726204b3b2142a989fb0eba8c37834867464177 Mon Sep 17 00:00:00 2001 From: Michael Woerister <michaelwoerister@posteo> Date: Mon, 15 Jan 2018 16:38:04 +0100 Subject: [PATCH 17/43] incr.comp.: Cache type_of and some other queries. --- src/librustc/ty/maps/config.rs | 3 +++ src/librustc/ty/maps/on_disk_cache.rs | 6 ++++-- src/librustc/ty/maps/plumbing.rs | 3 +++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/librustc/ty/maps/config.rs b/src/librustc/ty/maps/config.rs index 8dedcb24c2fb6..1dad74fb28e77 100644 --- a/src/librustc/ty/maps/config.rs +++ b/src/librustc/ty/maps/config.rs @@ -662,3 +662,6 @@ impl_disk_cacheable_query!(mir_const_qualif, |def_id| def_id.is_local()); impl_disk_cacheable_query!(check_match, |def_id| def_id.is_local()); impl_disk_cacheable_query!(contains_extern_indicator, |_| true); impl_disk_cacheable_query!(def_symbol_name, |_| true); +impl_disk_cacheable_query!(type_of, |def_id| def_id.is_local()); +impl_disk_cacheable_query!(predicates_of, |def_id| def_id.is_local()); +impl_disk_cacheable_query!(used_trait_imports, |def_id| def_id.is_local()); diff --git a/src/librustc/ty/maps/on_disk_cache.rs b/src/librustc/ty/maps/on_disk_cache.rs index 4e2421dad2161..a489bec5b27d0 100644 --- a/src/librustc/ty/maps/on_disk_cache.rs +++ b/src/librustc/ty/maps/on_disk_cache.rs @@ -204,8 +204,11 @@ impl<'sess> OnDiskCache<'sess> { let enc = &mut encoder; let qri = &mut query_result_index; - // Encode TypeckTables + encode_query_results::<type_of, _>(tcx, enc, qri)?; + encode_query_results::<predicates_of, _>(tcx, enc, qri)?; + encode_query_results::<used_trait_imports, _>(tcx, enc, qri)?; encode_query_results::<typeck_tables_of, _>(tcx, enc, qri)?; + encode_query_results::<trans_fulfill_obligation, _>(tcx, enc, qri)?; encode_query_results::<optimized_mir, _>(tcx, enc, qri)?; encode_query_results::<unsafety_check_result, _>(tcx, enc, qri)?; encode_query_results::<borrowck, _>(tcx, enc, qri)?; @@ -215,7 +218,6 @@ impl<'sess> OnDiskCache<'sess> { encode_query_results::<const_is_rvalue_promotable_to_static, _>(tcx, enc, qri)?; encode_query_results::<contains_extern_indicator, _>(tcx, enc, qri)?; encode_query_results::<symbol_name, _>(tcx, enc, qri)?; - encode_query_results::<trans_fulfill_obligation, _>(tcx, enc, qri)?; encode_query_results::<check_match, _>(tcx, enc, qri)?; } diff --git a/src/librustc/ty/maps/plumbing.rs b/src/librustc/ty/maps/plumbing.rs index d670ecc2691ae..a0db3c7bca8fa 100644 --- a/src/librustc/ty/maps/plumbing.rs +++ b/src/librustc/ty/maps/plumbing.rs @@ -982,4 +982,7 @@ impl_load_from_cache!( ConstIsRvaluePromotableToStatic => const_is_rvalue_promotable_to_static, ContainsExternIndicator => contains_extern_indicator, CheckMatch => check_match, + TypeOfItem => type_of, + PredicatesOfItem => predicates_of, + UsedTraitImports => used_trait_imports, ); From f9e1b9c2c2fba742d1c4f6b8ab413ed614ed63d6 Mon Sep 17 00:00:00 2001 From: Christopher Vittal <christopher.vittal@gmail.com> Date: Mon, 15 Jan 2018 11:14:47 -0500 Subject: [PATCH 18/43] 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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)" <carol.nichols@gmail.com> Date: Fri, 12 Jan 2018 16:58:33 -0500 Subject: [PATCH 19/43] 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!("<li><a href=\"#{id}\">{name}</a></li>", 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)" <carol.nichols@gmail.com> Date: Fri, 12 Jan 2018 16:41:45 -0500 Subject: [PATCH 20/43] 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)" <carol.nichols@gmail.com> Date: Fri, 12 Jan 2018 16:41:25 -0500 Subject: [PATCH 21/43] 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<T>`, 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<ty::Visibility>, // The visibility of the greatest reexport. - // n.b. `max_vis` is only used in `finalize_import` to check for reexport errors. + max_vis: Cell<ty::Visibility>, // 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<Name>), 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<clean::Item>) { - // 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 <ariel.byd@gmail.com> Date: Mon, 15 Jan 2018 23:57:44 +0200 Subject: [PATCH 22/43] 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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 <segev208@gmail.com> Date: Tue, 16 Jan 2018 07:27:04 +0200 Subject: [PATCH 23/43] 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?= <esteban@kuber.com.ar> Date: Mon, 15 Jan 2018 21:38:12 -0800 Subject: [PATCH 24/43] 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<MultiSpan>` 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<S: Into<MultiSpan>>(&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<S: Into<MultiSpan>>(&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<S: Into<MultiSpan>>(&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<S: Into<MultiSpan>>(&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<S: Into<MultiSpan>>(&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<S: Into<MultiSpan>>(&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<S: Into<MultiSpan>>(&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<S: Into<MultiSpan>>(&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<S: Into<MultiSpan>>(&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<S: Into<MultiSpan>>(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<S: Into<MultiSpan>>(&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<S: Into<MultiSpan>>(&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<S: Into<MultiSpan>>(&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<S: Into<MultiSpan>>(&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<S: Into<MultiSpan>>(&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<S: Into<MultiSpan>>(&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<S: Into<MultiSpan>>(&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<S: Into<MultiSpan>>(&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::<Vec<Span>>(), + "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" <code@zackmdavis.net> Date: Mon, 15 Jan 2018 18:32:18 -0800 Subject: [PATCH 25/43] 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: 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 26/43] implement "only-<platforms>" for test headers This patch implements "only-<platforms>" 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-<platforms>". 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 27/43] 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 28/43] 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 29/43] 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-<platform> 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 3a7e247acb6cd9c1bc9707d0b37ebba34f788006 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez <guillaume1.gomez@gmail.com> Date: Tue, 16 Jan 2018 15:38:08 +0100 Subject: [PATCH 30/43] Fix for older JS versions --- src/tools/rustdoc-js/tester.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/rustdoc-js/tester.js b/src/tools/rustdoc-js/tester.js index 9b7e151b1ffec..7c9ee2a49430b 100644 --- a/src/tools/rustdoc-js/tester.js +++ b/src/tools/rustdoc-js/tester.js @@ -115,7 +115,7 @@ function lookForEntry(entry, data) { if (!entry.hasOwnProperty(key)) { continue; } - let value = data[i][key]; + var value = data[i][key]; // To make our life easier, if there is a "parent" type, we add it to the path. if (key === 'path' && data[i]['parent'] !== undefined) { if (value.length > 0) { From 24c3a6db9bb0471e0f280b338b53b8bd55f52314 Mon Sep 17 00:00:00 2001 From: Ed Schouten <ed@nuxi.nl> Date: Sun, 14 Jan 2018 18:37:52 +0100 Subject: [PATCH 31/43] 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 <LICENSE-APACHE or +# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +# <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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 <ed@nuxi.nl> Date: Sun, 14 Jan 2018 19:47:41 +0100 Subject: [PATCH 32/43] 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 <goffrie@gmail.com> Date: Tue, 16 Jan 2018 11:43:57 -0800 Subject: [PATCH 33/43] 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<T> Option<T> { } /// 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<T> Option<T> { } /// 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<T: Default> Option<T> { /// 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<T: Default> Option<T> { /// /// [`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 <dominikwinecki@gmail.com> Date: Tue, 16 Jan 2018 14:47:14 -0500 Subject: [PATCH 34/43] 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<String> { let mut names = Vec::new(); fn collect_mod(names: &mut Vec<Ident>, 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::<Vec<_>>()) + .collect::<Vec<_>>())) } 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 <f2013002@goa.bits-pilani.ac.in> Date: Wed, 17 Jan 2018 01:31:21 +0530 Subject: [PATCH 35/43] 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 @@ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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 @@ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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 <f2013002@goa.bits-pilani.ac.in> Date: Wed, 17 Jan 2018 02:00:09 +0530 Subject: [PATCH 36/43] 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 @@ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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 <f2013002@goa.bits-pilani.ac.in> Date: Wed, 17 Jan 2018 02:07:07 +0530 Subject: [PATCH 37/43] 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 @@ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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 <ed@nuxi.nl> Date: Tue, 16 Jan 2018 22:23:18 +0100 Subject: [PATCH 38/43] 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 <markm@cs.wisc.edu> Date: Mon, 15 Jan 2018 10:29:30 -0600 Subject: [PATCH 39/43] 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 <ed@nuxi.nl> Date: Tue, 16 Jan 2018 23:21:51 +0100 Subject: [PATCH 40/43] 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 <segev208@gmail.com> Date: Wed, 17 Jan 2018 01:18:04 +0200 Subject: [PATCH 41/43] 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 <alex@alexcrichton.com> Date: Tue, 16 Jan 2018 15:49:58 -0800 Subject: [PATCH 42/43] 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 eb3da09333870e94b122d863402d993fb7ecd78f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= <esteban@kuber.com.ar> Date: Tue, 16 Jan 2018 18:11:35 -0800 Subject: [PATCH 43/43] 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::<Vec<Span>>(), - "multiple unused formatting arguments") + let mut diag = cx.ecx.struct_span_err( + errs.iter().map(|&(sp, _)| sp).collect::<Vec<Span>>(), + "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