Skip to content

Commit

Permalink
Auto merge of rust-lang#74219 - Mark-Simulacrum:beta-next, r=Mark-Sim…
Browse files Browse the repository at this point in the history
…ulacrum

[beta] next

Backports of:

* rustdoc: Fix doc aliases with crate filtering rust-lang#73644
* rustdoc: Rename invalid_codeblock_attribute lint to be plural rust-lang#74131
* rustc_lexer: Simplify shebang parsing once more rust-lang#73596
* Perform obligation deduplication to avoid buggy `ExistentialMismatch` rust-lang#73485
* Reorder order in which MinGW libs are linked to fix recent breakage rust-lang#73184
* Change how compiler-builtins gets many CGUs rust-lang#73136
* Fix wasm32 being broken due to a NodeJS version bump rust-lang#73885
  • Loading branch information
bors committed Jul 13, 2020
2 parents 8196407 + 9ce2d97 commit e99e642
Show file tree
Hide file tree
Showing 26 changed files with 157 additions and 95 deletions.
14 changes: 14 additions & 0 deletions src/bootstrap/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 12 additions & 1 deletion src/ci/docker/wasm32/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 12 additions & 15 deletions src/librustc_lexer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,21 +239,18 @@ pub enum Base {
/// but shebang isn't a part of rust syntax.
pub fn strip_shebang(input: &str) -> Option<usize> {
// 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
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_lint/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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
);
Expand Down
16 changes: 13 additions & 3 deletions src/librustc_middle/ty/relate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,12 +617,22 @@ impl<'tcx> Relate<'tcx> for &'tcx ty::List<ty::ExistentialPredicate<'tcx>> {
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)?)),
Expand Down
9 changes: 1 addition & 8 deletions src/librustc_mir/monomorphize/partitioning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_session/lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_target/spec/windows_gnu_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down
13 changes: 7 additions & 6 deletions src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
40 changes: 0 additions & 40 deletions src/test/codegen-units/partitioning/compiler-builtins.rs

This file was deleted.

9 changes: 9 additions & 0 deletions src/test/rustdoc-js/doc-alias-filter-out.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// exact-check

const QUERY = 'true';

const FILTER_CRATE = 'some_other_crate';

const EXPECTED = {
'others': [],
};
4 changes: 4 additions & 0 deletions src/test/rustdoc-js/doc-alias-filter-out.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#![feature(doc_alias)]

#[doc(alias = "true")]
pub struct Foo;
17 changes: 17 additions & 0 deletions src/test/rustdoc-js/doc-alias-filter.js
Original file line number Diff line number Diff line change
@@ -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
},
],
};
7 changes: 7 additions & 0 deletions src/test/rustdoc-js/doc-alias-filter.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#![feature(doc_alias)]

#[doc(alias = "true")]
pub struct Foo;

#[doc(alias = "false")]
pub struct Bar;
2 changes: 1 addition & 1 deletion src/test/rustdoc-ui/check-attr-test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// compile-flags:--test

#![deny(invalid_codeblock_attribute)]
#![deny(invalid_codeblock_attributes)]

/// foo
///
Expand Down
4 changes: 2 additions & 2 deletions src/test/rustdoc-ui/check-attr-test.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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`?
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-ui/check-attr.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![deny(invalid_codeblock_attribute)]
#![deny(invalid_codeblock_attributes)]

/// foo
//~^ ERROR
Expand Down
4 changes: 2 additions & 2 deletions src/test/rustdoc-ui/check-attr.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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`?
Expand Down
26 changes: 26 additions & 0 deletions src/test/ui/issues/issue-59326.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// check-pass
trait Service {
type S;
}

trait Framing {
type F;
}

impl Framing for () {
type F = ();
}

trait HttpService<F: Framing>: Service<S = F::F> {}

type BoxService = Box<dyn HttpService<(), S = ()>>;

fn build_server<F: FnOnce() -> BoxService>(_: F) {}

fn make_server<F: Framing>() -> Box<dyn HttpService<F, S = F::F>> {
unimplemented!()
}

fn main() {
build_server(|| make_server())
}
4 changes: 4 additions & 0 deletions src/test/ui/parser/shebang/shebang-empty.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!

// check-pass
fn main() {}
5 changes: 5 additions & 0 deletions src/test/ui/parser/shebang/shebang-space.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!

// check-pass
// ignore-tidy-end-whitespace
fn main() {}
5 changes: 0 additions & 5 deletions src/test/ui/shebang.rs

This file was deleted.

Loading

0 comments on commit e99e642

Please sign in to comment.