Skip to content

Commit e99e642

Browse files
committed
Auto merge of #74219 - Mark-Simulacrum:beta-next, r=Mark-Simulacrum
[beta] next Backports of: * rustdoc: Fix doc aliases with crate filtering #73644 * rustdoc: Rename invalid_codeblock_attribute lint to be plural #74131 * rustc_lexer: Simplify shebang parsing once more #73596 * Perform obligation deduplication to avoid buggy `ExistentialMismatch` #73485 * Reorder order in which MinGW libs are linked to fix recent breakage #73184 * Change how compiler-builtins gets many CGUs #73136 * Fix wasm32 being broken due to a NodeJS version bump #73885
2 parents 8196407 + 9ce2d97 commit e99e642

File tree

26 files changed

+157
-95
lines changed

26 files changed

+157
-95
lines changed

src/bootstrap/bin/rustc.rs

+14
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,20 @@ fn main() {
125125
} else {
126126
cmd.arg("-C").arg(format!("debug-assertions={}", debug_assertions));
127127
}
128+
129+
// For compiler-builtins we always use a high number of codegen units.
130+
// The goal here is to place every single intrinsic into its own object
131+
// file to avoid symbol clashes with the system libgcc if possible. Note
132+
// that this number doesn't actually produce this many object files, we
133+
// just don't create more than this number of object files.
134+
//
135+
// It's a bit of a bummer that we have to pass this here, unfortunately.
136+
// Ideally this would be specified through an env var to Cargo so Cargo
137+
// knows how many CGUs are for this specific crate, but for now
138+
// per-crate configuration isn't specifiable in the environment.
139+
if crate_name == Some("compiler_builtins") {
140+
cmd.arg("-Ccodegen-units=10000");
141+
}
128142
} else {
129143
// FIXME(rust-lang/cargo#5754) we shouldn't be using special env vars
130144
// here, but rather Cargo should know what flags to pass rustc itself.

src/ci/docker/wasm32/Dockerfile

+12-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,18 @@ RUN ln `which python3` /usr/bin/python
2525

2626
ENV PATH=$PATH:/emsdk-portable
2727
ENV PATH=$PATH:/emsdk-portable/upstream/emscripten/
28-
ENV PATH=$PATH:/emsdk-portable/node/12.9.1_64bit/bin/
28+
29+
# Rust's build system requires NodeJS to be in the path, but the directory in
30+
# which emsdk stores it contains the version number. This caused breakages in
31+
# the past when emsdk bumped the node version causing the path to point to a
32+
# missing directory.
33+
#
34+
# To avoid the problem this symlinks the latest NodeJs version available to
35+
# "latest", and adds that to the path.
36+
RUN ln -s /emsdk-portable/node/$(ls /emsdk-portable/node | sort -V | tail -n 1) \
37+
/emsdk-portable/node/latest
38+
ENV PATH=$PATH:/emsdk-portable/node/latest/bin/
39+
2940
ENV BINARYEN_ROOT=/emsdk-portable/upstream/
3041
ENV EMSDK=/emsdk-portable
3142
ENV EM_CONFIG=/emsdk-portable/.emscripten

src/librustc_lexer/src/lib.rs

+12-15
Original file line numberDiff line numberDiff line change
@@ -239,21 +239,18 @@ pub enum Base {
239239
/// but shebang isn't a part of rust syntax.
240240
pub fn strip_shebang(input: &str) -> Option<usize> {
241241
// Shebang must start with `#!` literally, without any preceding whitespace.
242-
if input.starts_with("#!") {
243-
let input_tail = &input[2..];
244-
// Shebang must have something non-whitespace after `#!` on the first line.
245-
let first_line_tail = input_tail.lines().next()?;
246-
if first_line_tail.contains(|c| !is_whitespace(c)) {
247-
// Ok, this is a shebang but if the next non-whitespace token is `[` or maybe
248-
// a doc comment (due to `TokenKind::(Line,Block)Comment` ambiguity at lexer level),
249-
// then it may be valid Rust code, so consider it Rust code.
250-
let next_non_whitespace_token = tokenize(input_tail).map(|tok| tok.kind).filter(|tok|
251-
!matches!(tok, TokenKind::Whitespace | TokenKind::LineComment | TokenKind::BlockComment { .. })
252-
).next();
253-
if next_non_whitespace_token != Some(TokenKind::OpenBracket) {
254-
// No other choice than to consider this a shebang.
255-
return Some(2 + first_line_tail.len());
256-
}
242+
// For simplicity we consider any line starting with `#!` a shebang,
243+
// regardless of restrictions put on shebangs by specific platforms.
244+
if let Some(input_tail) = input.strip_prefix("#!") {
245+
// Ok, this is a shebang but if the next non-whitespace token is `[` or maybe
246+
// a doc comment (due to `TokenKind::(Line,Block)Comment` ambiguity at lexer level),
247+
// then it may be valid Rust code, so consider it Rust code.
248+
let next_non_whitespace_token = tokenize(input_tail).map(|tok| tok.kind).find(|tok|
249+
!matches!(tok, TokenKind::Whitespace | TokenKind::LineComment | TokenKind::BlockComment { .. })
250+
);
251+
if next_non_whitespace_token != Some(TokenKind::OpenBracket) {
252+
// No other choice than to consider this a shebang.
253+
return Some(2 + input_tail.lines().next().unwrap_or_default().len());
257254
}
258255
}
259256
None

src/librustc_lint/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ use rustc_middle::ty::query::Providers;
6161
use rustc_middle::ty::TyCtxt;
6262
use rustc_session::lint::builtin::{
6363
BARE_TRAIT_OBJECTS, ELIDED_LIFETIMES_IN_PATHS, EXPLICIT_OUTLIVES_REQUIREMENTS,
64-
INTRA_DOC_LINK_RESOLUTION_FAILURE, INVALID_CODEBLOCK_ATTRIBUTE, MISSING_DOC_CODE_EXAMPLES,
64+
INTRA_DOC_LINK_RESOLUTION_FAILURE, INVALID_CODEBLOCK_ATTRIBUTES, MISSING_DOC_CODE_EXAMPLES,
6565
PRIVATE_DOC_TESTS,
6666
};
6767
use rustc_span::symbol::{Ident, Symbol};
@@ -301,7 +301,7 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) {
301301
add_lint_group!(
302302
"rustdoc",
303303
INTRA_DOC_LINK_RESOLUTION_FAILURE,
304-
INVALID_CODEBLOCK_ATTRIBUTE,
304+
INVALID_CODEBLOCK_ATTRIBUTES,
305305
MISSING_DOC_CODE_EXAMPLES,
306306
PRIVATE_DOC_TESTS
307307
);

src/librustc_middle/ty/relate.rs

+13-3
Original file line numberDiff line numberDiff line change
@@ -617,12 +617,22 @@ impl<'tcx> Relate<'tcx> for &'tcx ty::List<ty::ExistentialPredicate<'tcx>> {
617617
a: &Self,
618618
b: &Self,
619619
) -> RelateResult<'tcx, Self> {
620-
if a.len() != b.len() {
620+
let tcx = relation.tcx();
621+
622+
// FIXME: this is wasteful, but want to do a perf run to see how slow it is.
623+
// We need to perform this deduplication as we sometimes generate duplicate projections
624+
// in `a`.
625+
let mut a_v: Vec<_> = a.into_iter().collect();
626+
let mut b_v: Vec<_> = b.into_iter().collect();
627+
a_v.sort_by(|a, b| a.stable_cmp(tcx, b));
628+
a_v.dedup();
629+
b_v.sort_by(|a, b| a.stable_cmp(tcx, b));
630+
b_v.dedup();
631+
if a_v.len() != b_v.len() {
621632
return Err(TypeError::ExistentialMismatch(expected_found(relation, a, b)));
622633
}
623634

624-
let tcx = relation.tcx();
625-
let v = a.iter().zip(b.iter()).map(|(ep_a, ep_b)| {
635+
let v = a_v.into_iter().zip(b_v.into_iter()).map(|(ep_a, ep_b)| {
626636
use crate::ty::ExistentialPredicate::*;
627637
match (ep_a, ep_b) {
628638
(Trait(ref a), Trait(ref b)) => Ok(Trait(relation.relate(a, b)?)),

src/librustc_mir/monomorphize/partitioning.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -454,18 +454,11 @@ fn default_visibility(tcx: TyCtxt<'_>, id: DefId, is_generic: bool) -> Visibilit
454454
fn merge_codegen_units<'tcx>(
455455
tcx: TyCtxt<'tcx>,
456456
initial_partitioning: &mut PreInliningPartitioning<'tcx>,
457-
mut target_cgu_count: usize,
457+
target_cgu_count: usize,
458458
) {
459459
assert!(target_cgu_count >= 1);
460460
let codegen_units = &mut initial_partitioning.codegen_units;
461461

462-
if tcx.is_compiler_builtins(LOCAL_CRATE) {
463-
// Compiler builtins require some degree of control over how mono items
464-
// are partitioned into compilation units. Provide it by keeping the
465-
// original partitioning when compiling the compiler builtins crate.
466-
target_cgu_count = codegen_units.len();
467-
}
468-
469462
// Note that at this point in time the `codegen_units` here may not be in a
470463
// deterministic order (but we know they're deterministically the same set).
471464
// We want this merging to produce a deterministic ordering of codegen units

src/librustc_session/lint/builtin.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ declare_lint! {
399399
}
400400

401401
declare_lint! {
402-
pub INVALID_CODEBLOCK_ATTRIBUTE,
402+
pub INVALID_CODEBLOCK_ATTRIBUTES,
403403
Warn,
404404
"codeblock attribute looks a lot like a known one"
405405
}
@@ -585,7 +585,7 @@ declare_lint_pass! {
585585
UNSTABLE_NAME_COLLISIONS,
586586
IRREFUTABLE_LET_PATTERNS,
587587
INTRA_DOC_LINK_RESOLUTION_FAILURE,
588-
INVALID_CODEBLOCK_ATTRIBUTE,
588+
INVALID_CODEBLOCK_ATTRIBUTES,
589589
MISSING_CRATE_LEVEL_DOCS,
590590
MISSING_DOC_CODE_EXAMPLES,
591591
PRIVATE_DOC_TESTS,

src/librustc_target/spec/windows_gnu_base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ pub fn opts() -> TargetOptions {
2020
late_link_args.insert(
2121
LinkerFlavor::Gcc,
2222
vec![
23+
"-lmsvcrt".to_string(),
2324
"-lmingwex".to_string(),
2425
"-lmingw32".to_string(),
25-
"-lmsvcrt".to_string(),
2626
// mingw's msvcrt is a weird hybrid import library and static library.
2727
// And it seems that the linker fails to use import symbols from msvcrt
2828
// that are required from functions in msvcrt in certain cases. For example

src/librustdoc/core.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ pub fn new_handler(
205205

206206
/// This function is used to setup the lint initialization. By default, in rustdoc, everything
207207
/// is "allowed". Depending if we run in test mode or not, we want some of them to be at their
208-
/// default level. For example, the "INVALID_CODEBLOCK_ATTRIBUTE" lint is activated in both
208+
/// default level. For example, the "INVALID_CODEBLOCK_ATTRIBUTES" lint is activated in both
209209
/// modes.
210210
///
211211
/// 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
311311
let missing_doc_example = rustc_lint::builtin::MISSING_DOC_CODE_EXAMPLES.name;
312312
let private_doc_tests = rustc_lint::builtin::PRIVATE_DOC_TESTS.name;
313313
let no_crate_level_docs = rustc_lint::builtin::MISSING_CRATE_LEVEL_DOCS.name;
314-
let invalid_codeblock_attribute_name = rustc_lint::builtin::INVALID_CODEBLOCK_ATTRIBUTE.name;
314+
let invalid_codeblock_attribute_name = rustc_lint::builtin::INVALID_CODEBLOCK_ATTRIBUTES.name;
315315

316316
// In addition to those specific lints, we also need to whitelist those given through
317317
// command line, otherwise they'll get ignored and we don't want that.

src/librustdoc/html/markdown.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ impl<'a, 'b> ExtraInfo<'a, 'b> {
657657
(None, None) => return,
658658
};
659659
self.tcx.struct_span_lint_hir(
660-
lint::builtin::INVALID_CODEBLOCK_ATTRIBUTE,
660+
lint::builtin::INVALID_CODEBLOCK_ATTRIBUTES,
661661
hir_id,
662662
self.sp,
663663
|lint| {

src/librustdoc/html/static/main.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -1006,12 +1006,13 @@ function defocusSearchBar() {
10061006
var aliases = [];
10071007
var crateAliases = [];
10081008
var i;
1009-
if (filterCrates !== undefined &&
1010-
ALIASES[filterCrates] &&
1011-
ALIASES[filterCrates][query.search]) {
1012-
for (i = 0; i < ALIASES[crate][query.search].length; ++i) {
1013-
aliases.push(
1014-
createAliasFromItem(searchIndex[ALIASES[filterCrates][query.search]]));
1009+
if (filterCrates !== undefined) {
1010+
if (ALIASES[filterCrates] && ALIASES[filterCrates][query.search]) {
1011+
for (i = 0; i < ALIASES[filterCrates][query.search].length; ++i) {
1012+
aliases.push(
1013+
createAliasFromItem(
1014+
searchIndex[ALIASES[filterCrates][query.search][i]]));
1015+
}
10151016
}
10161017
} else {
10171018
Object.keys(ALIASES).forEach(function(crate) {

src/librustdoc/test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub struct TestOptions {
4646
pub fn run(options: Options) -> Result<(), String> {
4747
let input = config::Input::File(options.input.clone());
4848

49-
let invalid_codeblock_attribute_name = rustc_lint::builtin::INVALID_CODEBLOCK_ATTRIBUTE.name;
49+
let invalid_codeblock_attribute_name = rustc_lint::builtin::INVALID_CODEBLOCK_ATTRIBUTES.name;
5050

5151
// In addition to those specific lints, we also need to whitelist those given through
5252
// command line, otherwise they'll get ignored and we don't want that.

src/test/codegen-units/partitioning/compiler-builtins.rs

-40
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// exact-check
2+
3+
const QUERY = 'true';
4+
5+
const FILTER_CRATE = 'some_other_crate';
6+
7+
const EXPECTED = {
8+
'others': [],
9+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#![feature(doc_alias)]
2+
3+
#[doc(alias = "true")]
4+
pub struct Foo;
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// exact-check
2+
3+
const QUERY = 'true';
4+
5+
const FILTER_CRATE = 'doc_alias_filter';
6+
7+
const EXPECTED = {
8+
'others': [
9+
{
10+
'path': 'doc_alias_filter',
11+
'name': 'Foo',
12+
'alias': 'true',
13+
'href': '../doc_alias_filter/struct.Foo.html',
14+
'is_alias': true
15+
},
16+
],
17+
};
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#![feature(doc_alias)]
2+
3+
#[doc(alias = "true")]
4+
pub struct Foo;
5+
6+
#[doc(alias = "false")]
7+
pub struct Bar;

src/test/rustdoc-ui/check-attr-test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// compile-flags:--test
22

3-
#![deny(invalid_codeblock_attribute)]
3+
#![deny(invalid_codeblock_attributes)]
44

55
/// foo
66
///

src/test/rustdoc-ui/check-attr-test.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ error: unknown attribute `compile-fail`. Did you mean `compile_fail`?
1111
note: the lint level is defined here
1212
--> $DIR/check-attr-test.rs:3:9
1313
|
14-
3 | #![deny(invalid_codeblock_attribute)]
15-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
3 | #![deny(invalid_codeblock_attributes)]
15+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1616
= help: the code block will either not be tested if not marked as a rust one or won't fail if it compiles successfully
1717

1818
error: unknown attribute `compilefail`. Did you mean `compile_fail`?

src/test/rustdoc-ui/check-attr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(invalid_codeblock_attribute)]
1+
#![deny(invalid_codeblock_attributes)]
22

33
/// foo
44
//~^ ERROR

src/test/rustdoc-ui/check-attr.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ LL | | /// ```
1313
note: the lint level is defined here
1414
--> $DIR/check-attr.rs:1:9
1515
|
16-
LL | #![deny(invalid_codeblock_attribute)]
17-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
16+
LL | #![deny(invalid_codeblock_attributes)]
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1818
= help: the code block will either not be tested if not marked as a rust one or won't fail if it compiles successfully
1919

2020
error: unknown attribute `compilefail`. Did you mean `compile_fail`?

src/test/ui/issues/issue-59326.rs

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// check-pass
2+
trait Service {
3+
type S;
4+
}
5+
6+
trait Framing {
7+
type F;
8+
}
9+
10+
impl Framing for () {
11+
type F = ();
12+
}
13+
14+
trait HttpService<F: Framing>: Service<S = F::F> {}
15+
16+
type BoxService = Box<dyn HttpService<(), S = ()>>;
17+
18+
fn build_server<F: FnOnce() -> BoxService>(_: F) {}
19+
20+
fn make_server<F: Framing>() -> Box<dyn HttpService<F, S = F::F>> {
21+
unimplemented!()
22+
}
23+
24+
fn main() {
25+
build_server(|| make_server())
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!
2+
3+
// check-pass
4+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!
2+
3+
// check-pass
4+
// ignore-tidy-end-whitespace
5+
fn main() {}

src/test/ui/shebang.rs

-5
This file was deleted.

0 commit comments

Comments
 (0)