diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index a8c00c8c3ca88..047957e225e8b 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -125,6 +125,20 @@ fn main() { } else { cmd.arg("-C").arg(format!("debug-assertions={}", debug_assertions)); } + + // For compiler-builtins we always use a high number of codegen units. + // The goal here is to place every single intrinsic into its own object + // file to avoid symbol clashes with the system libgcc if possible. Note + // that this number doesn't actually produce this many object files, we + // just don't create more than this number of object files. + // + // It's a bit of a bummer that we have to pass this here, unfortunately. + // Ideally this would be specified through an env var to Cargo so Cargo + // knows how many CGUs are for this specific crate, but for now + // per-crate configuration isn't specifiable in the environment. + if crate_name == Some("compiler_builtins") { + cmd.arg("-Ccodegen-units=10000"); + } } else { // FIXME(rust-lang/cargo#5754) we shouldn't be using special env vars // here, but rather Cargo should know what flags to pass rustc itself. diff --git a/src/ci/docker/wasm32/Dockerfile b/src/ci/docker/wasm32/Dockerfile index 8232539edda77..92461305320ee 100644 --- a/src/ci/docker/wasm32/Dockerfile +++ b/src/ci/docker/wasm32/Dockerfile @@ -25,7 +25,18 @@ RUN ln `which python3` /usr/bin/python ENV PATH=$PATH:/emsdk-portable ENV PATH=$PATH:/emsdk-portable/upstream/emscripten/ -ENV PATH=$PATH:/emsdk-portable/node/12.9.1_64bit/bin/ + +# Rust's build system requires NodeJS to be in the path, but the directory in +# which emsdk stores it contains the version number. This caused breakages in +# the past when emsdk bumped the node version causing the path to point to a +# missing directory. +# +# To avoid the problem this symlinks the latest NodeJs version available to +# "latest", and adds that to the path. +RUN ln -s /emsdk-portable/node/$(ls /emsdk-portable/node | sort -V | tail -n 1) \ + /emsdk-portable/node/latest +ENV PATH=$PATH:/emsdk-portable/node/latest/bin/ + ENV BINARYEN_ROOT=/emsdk-portable/upstream/ ENV EMSDK=/emsdk-portable ENV EM_CONFIG=/emsdk-portable/.emscripten diff --git a/src/librustc_lexer/src/lib.rs b/src/librustc_lexer/src/lib.rs index c2139d07f378a..9256bd0086541 100644 --- a/src/librustc_lexer/src/lib.rs +++ b/src/librustc_lexer/src/lib.rs @@ -239,21 +239,18 @@ pub enum Base { /// but shebang isn't a part of rust syntax. pub fn strip_shebang(input: &str) -> Option { // Shebang must start with `#!` literally, without any preceding whitespace. - if input.starts_with("#!") { - let input_tail = &input[2..]; - // Shebang must have something non-whitespace after `#!` on the first line. - let first_line_tail = input_tail.lines().next()?; - if first_line_tail.contains(|c| !is_whitespace(c)) { - // Ok, this is a shebang but if the next non-whitespace token is `[` or maybe - // a doc comment (due to `TokenKind::(Line,Block)Comment` ambiguity at lexer level), - // then it may be valid Rust code, so consider it Rust code. - let next_non_whitespace_token = tokenize(input_tail).map(|tok| tok.kind).filter(|tok| - !matches!(tok, TokenKind::Whitespace | TokenKind::LineComment | TokenKind::BlockComment { .. }) - ).next(); - if next_non_whitespace_token != Some(TokenKind::OpenBracket) { - // No other choice than to consider this a shebang. - return Some(2 + first_line_tail.len()); - } + // For simplicity we consider any line starting with `#!` a shebang, + // regardless of restrictions put on shebangs by specific platforms. + if let Some(input_tail) = input.strip_prefix("#!") { + // Ok, this is a shebang but if the next non-whitespace token is `[` or maybe + // a doc comment (due to `TokenKind::(Line,Block)Comment` ambiguity at lexer level), + // then it may be valid Rust code, so consider it Rust code. + let next_non_whitespace_token = tokenize(input_tail).map(|tok| tok.kind).find(|tok| + !matches!(tok, TokenKind::Whitespace | TokenKind::LineComment | TokenKind::BlockComment { .. }) + ); + if next_non_whitespace_token != Some(TokenKind::OpenBracket) { + // No other choice than to consider this a shebang. + return Some(2 + input_tail.lines().next().unwrap_or_default().len()); } } None diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index b791d313fc4f4..c57a407edbb88 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -61,7 +61,7 @@ use rustc_middle::ty::query::Providers; use rustc_middle::ty::TyCtxt; use rustc_session::lint::builtin::{ BARE_TRAIT_OBJECTS, ELIDED_LIFETIMES_IN_PATHS, EXPLICIT_OUTLIVES_REQUIREMENTS, - INTRA_DOC_LINK_RESOLUTION_FAILURE, INVALID_CODEBLOCK_ATTRIBUTE, MISSING_DOC_CODE_EXAMPLES, + INTRA_DOC_LINK_RESOLUTION_FAILURE, INVALID_CODEBLOCK_ATTRIBUTES, MISSING_DOC_CODE_EXAMPLES, PRIVATE_DOC_TESTS, }; use rustc_span::symbol::{Ident, Symbol}; @@ -301,7 +301,7 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) { add_lint_group!( "rustdoc", INTRA_DOC_LINK_RESOLUTION_FAILURE, - INVALID_CODEBLOCK_ATTRIBUTE, + INVALID_CODEBLOCK_ATTRIBUTES, MISSING_DOC_CODE_EXAMPLES, PRIVATE_DOC_TESTS ); diff --git a/src/librustc_middle/ty/relate.rs b/src/librustc_middle/ty/relate.rs index aeb3a0716fb42..7fb41a1dc5ac2 100644 --- a/src/librustc_middle/ty/relate.rs +++ b/src/librustc_middle/ty/relate.rs @@ -617,12 +617,22 @@ impl<'tcx> Relate<'tcx> for &'tcx ty::List> { a: &Self, b: &Self, ) -> RelateResult<'tcx, Self> { - if a.len() != b.len() { + let tcx = relation.tcx(); + + // FIXME: this is wasteful, but want to do a perf run to see how slow it is. + // We need to perform this deduplication as we sometimes generate duplicate projections + // in `a`. + let mut a_v: Vec<_> = a.into_iter().collect(); + let mut b_v: Vec<_> = b.into_iter().collect(); + a_v.sort_by(|a, b| a.stable_cmp(tcx, b)); + a_v.dedup(); + b_v.sort_by(|a, b| a.stable_cmp(tcx, b)); + b_v.dedup(); + if a_v.len() != b_v.len() { return Err(TypeError::ExistentialMismatch(expected_found(relation, a, b))); } - let tcx = relation.tcx(); - let v = a.iter().zip(b.iter()).map(|(ep_a, ep_b)| { + let v = a_v.into_iter().zip(b_v.into_iter()).map(|(ep_a, ep_b)| { use crate::ty::ExistentialPredicate::*; match (ep_a, ep_b) { (Trait(ref a), Trait(ref b)) => Ok(Trait(relation.relate(a, b)?)), diff --git a/src/librustc_mir/monomorphize/partitioning.rs b/src/librustc_mir/monomorphize/partitioning.rs index db1ea72c0a531..a945c1d626a9a 100644 --- a/src/librustc_mir/monomorphize/partitioning.rs +++ b/src/librustc_mir/monomorphize/partitioning.rs @@ -454,18 +454,11 @@ fn default_visibility(tcx: TyCtxt<'_>, id: DefId, is_generic: bool) -> Visibilit fn merge_codegen_units<'tcx>( tcx: TyCtxt<'tcx>, initial_partitioning: &mut PreInliningPartitioning<'tcx>, - mut target_cgu_count: usize, + target_cgu_count: usize, ) { assert!(target_cgu_count >= 1); let codegen_units = &mut initial_partitioning.codegen_units; - if tcx.is_compiler_builtins(LOCAL_CRATE) { - // Compiler builtins require some degree of control over how mono items - // are partitioned into compilation units. Provide it by keeping the - // original partitioning when compiling the compiler builtins crate. - target_cgu_count = codegen_units.len(); - } - // Note that at this point in time the `codegen_units` here may not be in a // deterministic order (but we know they're deterministically the same set). // We want this merging to produce a deterministic ordering of codegen units diff --git a/src/librustc_session/lint/builtin.rs b/src/librustc_session/lint/builtin.rs index 7112ac35b082b..1c4ff05b81f25 100644 --- a/src/librustc_session/lint/builtin.rs +++ b/src/librustc_session/lint/builtin.rs @@ -399,7 +399,7 @@ declare_lint! { } declare_lint! { - pub INVALID_CODEBLOCK_ATTRIBUTE, + pub INVALID_CODEBLOCK_ATTRIBUTES, Warn, "codeblock attribute looks a lot like a known one" } @@ -585,7 +585,7 @@ declare_lint_pass! { UNSTABLE_NAME_COLLISIONS, IRREFUTABLE_LET_PATTERNS, INTRA_DOC_LINK_RESOLUTION_FAILURE, - INVALID_CODEBLOCK_ATTRIBUTE, + INVALID_CODEBLOCK_ATTRIBUTES, MISSING_CRATE_LEVEL_DOCS, MISSING_DOC_CODE_EXAMPLES, PRIVATE_DOC_TESTS, diff --git a/src/librustc_target/spec/windows_gnu_base.rs b/src/librustc_target/spec/windows_gnu_base.rs index f556bf03f02a0..744f26239cada 100644 --- a/src/librustc_target/spec/windows_gnu_base.rs +++ b/src/librustc_target/spec/windows_gnu_base.rs @@ -20,9 +20,9 @@ pub fn opts() -> TargetOptions { late_link_args.insert( LinkerFlavor::Gcc, vec![ + "-lmsvcrt".to_string(), "-lmingwex".to_string(), "-lmingw32".to_string(), - "-lmsvcrt".to_string(), // 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 diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 06293a987124e..fd17757f31134 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -205,7 +205,7 @@ pub fn new_handler( /// This function is used to setup the lint initialization. By default, in rustdoc, everything /// is "allowed". Depending if we run in test mode or not, we want some of them to be at their -/// default level. For example, the "INVALID_CODEBLOCK_ATTRIBUTE" lint is activated in both +/// default level. For example, the "INVALID_CODEBLOCK_ATTRIBUTES" lint is activated in both /// modes. /// /// A little detail easy to forget is that there is a way to set the lint level for all lints @@ -311,7 +311,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt let missing_doc_example = rustc_lint::builtin::MISSING_DOC_CODE_EXAMPLES.name; let private_doc_tests = rustc_lint::builtin::PRIVATE_DOC_TESTS.name; let no_crate_level_docs = rustc_lint::builtin::MISSING_CRATE_LEVEL_DOCS.name; - let invalid_codeblock_attribute_name = rustc_lint::builtin::INVALID_CODEBLOCK_ATTRIBUTE.name; + let invalid_codeblock_attribute_name = rustc_lint::builtin::INVALID_CODEBLOCK_ATTRIBUTES.name; // In addition to those specific lints, we also need to whitelist those given through // command line, otherwise they'll get ignored and we don't want that. diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index c129e54c0f28a..5e523bf8fda5f 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -657,7 +657,7 @@ impl<'a, 'b> ExtraInfo<'a, 'b> { (None, None) => return, }; self.tcx.struct_span_lint_hir( - lint::builtin::INVALID_CODEBLOCK_ATTRIBUTE, + lint::builtin::INVALID_CODEBLOCK_ATTRIBUTES, hir_id, self.sp, |lint| { diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index ac5a2f96b26c6..596c19fb0a057 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -1006,12 +1006,13 @@ function defocusSearchBar() { var aliases = []; var crateAliases = []; var i; - if (filterCrates !== undefined && - ALIASES[filterCrates] && - ALIASES[filterCrates][query.search]) { - for (i = 0; i < ALIASES[crate][query.search].length; ++i) { - aliases.push( - createAliasFromItem(searchIndex[ALIASES[filterCrates][query.search]])); + if (filterCrates !== undefined) { + if (ALIASES[filterCrates] && ALIASES[filterCrates][query.search]) { + for (i = 0; i < ALIASES[filterCrates][query.search].length; ++i) { + aliases.push( + createAliasFromItem( + searchIndex[ALIASES[filterCrates][query.search][i]])); + } } } else { Object.keys(ALIASES).forEach(function(crate) { diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 4b15a591da71f..eb89c749bfe39 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -46,7 +46,7 @@ pub struct TestOptions { pub fn run(options: Options) -> Result<(), String> { let input = config::Input::File(options.input.clone()); - let invalid_codeblock_attribute_name = rustc_lint::builtin::INVALID_CODEBLOCK_ATTRIBUTE.name; + let invalid_codeblock_attribute_name = rustc_lint::builtin::INVALID_CODEBLOCK_ATTRIBUTES.name; // In addition to those specific lints, we also need to whitelist those given through // command line, otherwise they'll get ignored and we don't want that. diff --git a/src/test/codegen-units/partitioning/compiler-builtins.rs b/src/test/codegen-units/partitioning/compiler-builtins.rs deleted file mode 100644 index 25195743b0400..0000000000000 --- a/src/test/codegen-units/partitioning/compiler-builtins.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Verifies that during compiler_builtins compilation the codegen units are kept -// unmerged. Even when only a single codegen unit is requested with -Ccodegen-units=1. -// -// compile-flags: -Zprint-mono-items=eager -Ccodegen-units=1 - -#![compiler_builtins] -#![crate_type="lib"] -#![feature(compiler_builtins)] - -mod atomics { - //~ MONO_ITEM fn compiler_builtins::atomics[0]::sync_1[0] @@ compiler_builtins-cgu.0[External] - #[no_mangle] - pub extern "C" fn sync_1() {} - - //~ MONO_ITEM fn compiler_builtins::atomics[0]::sync_2[0] @@ compiler_builtins-cgu.0[External] - #[no_mangle] - pub extern "C" fn sync_2() {} - - //~ MONO_ITEM fn compiler_builtins::atomics[0]::sync_3[0] @@ compiler_builtins-cgu.0[External] - #[no_mangle] - pub extern "C" fn sync_3() {} -} - -mod x { - //~ MONO_ITEM fn compiler_builtins::x[0]::x[0] @@ compiler_builtins-cgu.1[External] - #[no_mangle] - pub extern "C" fn x() {} -} - -mod y { - //~ MONO_ITEM fn compiler_builtins::y[0]::y[0] @@ compiler_builtins-cgu.2[External] - #[no_mangle] - pub extern "C" fn y() {} -} - -mod z { - //~ MONO_ITEM fn compiler_builtins::z[0]::z[0] @@ compiler_builtins-cgu.3[External] - #[no_mangle] - pub extern "C" fn z() {} -} diff --git a/src/test/rustdoc-js/doc-alias-filter-out.js b/src/test/rustdoc-js/doc-alias-filter-out.js new file mode 100644 index 0000000000000..46a089d06ebef --- /dev/null +++ b/src/test/rustdoc-js/doc-alias-filter-out.js @@ -0,0 +1,9 @@ +// exact-check + +const QUERY = 'true'; + +const FILTER_CRATE = 'some_other_crate'; + +const EXPECTED = { + 'others': [], +}; diff --git a/src/test/rustdoc-js/doc-alias-filter-out.rs b/src/test/rustdoc-js/doc-alias-filter-out.rs new file mode 100644 index 0000000000000..815e8cedd16da --- /dev/null +++ b/src/test/rustdoc-js/doc-alias-filter-out.rs @@ -0,0 +1,4 @@ +#![feature(doc_alias)] + +#[doc(alias = "true")] +pub struct Foo; diff --git a/src/test/rustdoc-js/doc-alias-filter.js b/src/test/rustdoc-js/doc-alias-filter.js new file mode 100644 index 0000000000000..4b1e2e2970479 --- /dev/null +++ b/src/test/rustdoc-js/doc-alias-filter.js @@ -0,0 +1,17 @@ +// exact-check + +const QUERY = 'true'; + +const FILTER_CRATE = 'doc_alias_filter'; + +const EXPECTED = { + 'others': [ + { + 'path': 'doc_alias_filter', + 'name': 'Foo', + 'alias': 'true', + 'href': '../doc_alias_filter/struct.Foo.html', + 'is_alias': true + }, + ], +}; diff --git a/src/test/rustdoc-js/doc-alias-filter.rs b/src/test/rustdoc-js/doc-alias-filter.rs new file mode 100644 index 0000000000000..8887f8c2b0149 --- /dev/null +++ b/src/test/rustdoc-js/doc-alias-filter.rs @@ -0,0 +1,7 @@ +#![feature(doc_alias)] + +#[doc(alias = "true")] +pub struct Foo; + +#[doc(alias = "false")] +pub struct Bar; diff --git a/src/test/rustdoc-ui/check-attr-test.rs b/src/test/rustdoc-ui/check-attr-test.rs index c4140bbb70a78..665f330e34ea5 100644 --- a/src/test/rustdoc-ui/check-attr-test.rs +++ b/src/test/rustdoc-ui/check-attr-test.rs @@ -1,6 +1,6 @@ // compile-flags:--test -#![deny(invalid_codeblock_attribute)] +#![deny(invalid_codeblock_attributes)] /// foo /// diff --git a/src/test/rustdoc-ui/check-attr-test.stderr b/src/test/rustdoc-ui/check-attr-test.stderr index 45a2d6ec15e7d..1e067a5d21c44 100644 --- a/src/test/rustdoc-ui/check-attr-test.stderr +++ b/src/test/rustdoc-ui/check-attr-test.stderr @@ -11,8 +11,8 @@ error: unknown attribute `compile-fail`. Did you mean `compile_fail`? note: the lint level is defined here --> $DIR/check-attr-test.rs:3:9 | -3 | #![deny(invalid_codeblock_attribute)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 | #![deny(invalid_codeblock_attributes)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: the code block will either not be tested if not marked as a rust one or won't fail if it compiles successfully error: unknown attribute `compilefail`. Did you mean `compile_fail`? diff --git a/src/test/rustdoc-ui/check-attr.rs b/src/test/rustdoc-ui/check-attr.rs index a93ec29131907..9e02eab753e26 100644 --- a/src/test/rustdoc-ui/check-attr.rs +++ b/src/test/rustdoc-ui/check-attr.rs @@ -1,4 +1,4 @@ -#![deny(invalid_codeblock_attribute)] +#![deny(invalid_codeblock_attributes)] /// foo //~^ ERROR diff --git a/src/test/rustdoc-ui/check-attr.stderr b/src/test/rustdoc-ui/check-attr.stderr index 5d6939bd09205..919eb047eefb5 100644 --- a/src/test/rustdoc-ui/check-attr.stderr +++ b/src/test/rustdoc-ui/check-attr.stderr @@ -13,8 +13,8 @@ LL | | /// ``` note: the lint level is defined here --> $DIR/check-attr.rs:1:9 | -LL | #![deny(invalid_codeblock_attribute)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #![deny(invalid_codeblock_attributes)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: the code block will either not be tested if not marked as a rust one or won't fail if it compiles successfully error: unknown attribute `compilefail`. Did you mean `compile_fail`? diff --git a/src/test/ui/issues/issue-59326.rs b/src/test/ui/issues/issue-59326.rs new file mode 100644 index 0000000000000..c0e8837749eb4 --- /dev/null +++ b/src/test/ui/issues/issue-59326.rs @@ -0,0 +1,26 @@ +// check-pass +trait Service { + type S; +} + +trait Framing { + type F; +} + +impl Framing for () { + type F = (); +} + +trait HttpService: Service {} + +type BoxService = Box>; + +fn build_server BoxService>(_: F) {} + +fn make_server() -> Box> { + unimplemented!() +} + +fn main() { + build_server(|| make_server()) +} diff --git a/src/test/ui/parser/shebang/shebang-empty.rs b/src/test/ui/parser/shebang/shebang-empty.rs new file mode 100644 index 0000000000000..e38cc637e945e --- /dev/null +++ b/src/test/ui/parser/shebang/shebang-empty.rs @@ -0,0 +1,4 @@ +#! + +// check-pass +fn main() {} diff --git a/src/test/ui/parser/shebang/shebang-space.rs b/src/test/ui/parser/shebang/shebang-space.rs new file mode 100644 index 0000000000000..0978b759d2a6e --- /dev/null +++ b/src/test/ui/parser/shebang/shebang-space.rs @@ -0,0 +1,5 @@ +#! + +// check-pass +// ignore-tidy-end-whitespace +fn main() {} diff --git a/src/test/ui/shebang.rs b/src/test/ui/shebang.rs deleted file mode 100644 index 3d3ba468be955..0000000000000 --- a/src/test/ui/shebang.rs +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env rustx - -// run-pass - -pub fn main() { println!("Hello World"); } diff --git a/src/tools/rustdoc-js/tester.js b/src/tools/rustdoc-js/tester.js index 163571bc5b988..139e6f73f4216 100644 --- a/src/tools/rustdoc-js/tester.js +++ b/src/tools/rustdoc-js/tester.js @@ -269,6 +269,12 @@ function runSearch(query, expected, index, loaded, loadedFile, queryName) { break; } var entry = expected[key]; + + if (exact_check == true && entry.length !== results[key].length) { + error_text.push(queryName + "==> Expected exactly " + entry.length + + " results but found " + results[key].length + " in '" + key + "'"); + } + var prev_pos = -1; for (var i = 0; i < entry.length; ++i) { var entry_pos = lookForEntry(entry[i], results[key]); @@ -307,8 +313,11 @@ function checkResult(error_text, loadedFile, displaySuccess) { } function runChecks(testFile, loaded, index) { - var loadedFile = loadContent( - readFile(testFile) + 'exports.QUERY = QUERY;exports.EXPECTED = EXPECTED;'); + var testFileContent = readFile(testFile) + 'exports.QUERY = QUERY;exports.EXPECTED = EXPECTED;'; + if (testFileContent.indexOf("FILTER_CRATE") !== -1) { + testFileContent += "exports.FILTER_CRATE = FILTER_CRATE;"; + } + var loadedFile = loadContent(testFileContent); const expected = loadedFile.EXPECTED; const query = loadedFile.QUERY;