From 718ea90f6793148c4d268a4f6d905b5ce820807e Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 29 Sep 2022 10:03:34 -0700 Subject: [PATCH 1/7] Don't export `main` on WebAssembly. On `default_hidden_visibility = true` platforms, which is currently just WebAssembly, don't automatically export `main`. On such platforms, `main` in C defaults to being hidden, and therefore not automatically exported. --- .../src/back/symbol_export.rs | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs index 8d7e2c5cf3939..090e4aca7c263 100644 --- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs +++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs @@ -179,17 +179,22 @@ fn exported_symbols_provider_local<'tcx>( .map(|(&def_id, &info)| (ExportedSymbol::NonGeneric(def_id), info)) .collect(); - if tcx.entry_fn(()).is_some() { - let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new(tcx, "main")); + // Export `main`, on platforms where it has "default" visibility. On platforms + // where C functions are "hidden", `main` is "hidden" too, which means we aren't + // expected to export it. + if !tcx.sess.target.default_hidden_visibility { + if tcx.entry_fn(()).is_some() { + let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new(tcx, "main")); - symbols.push(( - exported_symbol, - SymbolExportInfo { - level: SymbolExportLevel::C, - kind: SymbolExportKind::Text, - used: false, - }, - )); + symbols.push(( + exported_symbol, + SymbolExportInfo { + level: SymbolExportLevel::C, + kind: SymbolExportKind::Text, + used: false, + }, + )); + } } if tcx.allocator_kind(()).is_some() { From 0501d615bb1484fbbd6e2035cff4c3c44e94f10d Mon Sep 17 00:00:00 2001 From: Yiming Lei Date: Wed, 5 Oct 2022 14:00:51 -0700 Subject: [PATCH 2/7] do not reverse the expected type and found type for ObligationCauseCode of IfExpressionWithNoElse this will fix #102397 --- compiler/rustc_hir_analysis/src/check/_match.rs | 2 +- src/test/ui/async-await/issue-66387-if-without-else.stderr | 2 +- src/test/ui/consts/control-flow/issue-50577.stderr | 2 +- src/test/ui/expr/if/if-without-else-result.rs | 2 +- src/test/ui/expr/if/if-without-else-result.stderr | 2 +- src/test/ui/expr/if/issue-4201.rs | 2 +- src/test/ui/expr/if/issue-4201.stderr | 2 +- src/test/ui/issues/issue-19991.rs | 2 +- src/test/ui/issues/issue-19991.stderr | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/check/_match.rs b/compiler/rustc_hir_analysis/src/check/_match.rs index 201927091a60a..143508b785f1e 100644 --- a/compiler/rustc_hir_analysis/src/check/_match.rs +++ b/compiler/rustc_hir_analysis/src/check/_match.rs @@ -259,7 +259,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err.help("consider adding an `else` block that evaluates to the expected type"); error = true; }, - ret_reason.is_none(), + false, ); error } diff --git a/src/test/ui/async-await/issue-66387-if-without-else.stderr b/src/test/ui/async-await/issue-66387-if-without-else.stderr index e8e2a48983c89..8155fcb56b697 100644 --- a/src/test/ui/async-await/issue-66387-if-without-else.stderr +++ b/src/test/ui/async-await/issue-66387-if-without-else.stderr @@ -4,7 +4,7 @@ error[E0317]: `if` may be missing an `else` clause LL | / if true { LL | | return 0; LL | | } - | |_____^ expected `()`, found `i32` + | |_____^ expected `i32`, found `()` | = note: `if` expressions without `else` evaluate to `()` = help: consider adding an `else` block that evaluates to the expected type diff --git a/src/test/ui/consts/control-flow/issue-50577.stderr b/src/test/ui/consts/control-flow/issue-50577.stderr index b6e73f889adab..a931c89f47e72 100644 --- a/src/test/ui/consts/control-flow/issue-50577.stderr +++ b/src/test/ui/consts/control-flow/issue-50577.stderr @@ -2,7 +2,7 @@ error[E0317]: `if` may be missing an `else` clause --> $DIR/issue-50577.rs:3:16 | LL | Drop = assert_eq!(1, 1), - | ^^^^^^^^^^^^^^^^ expected `()`, found `isize` + | ^^^^^^^^^^^^^^^^ expected `isize`, found `()` | = note: `if` expressions without `else` evaluate to `()` = help: consider adding an `else` block that evaluates to the expected type diff --git a/src/test/ui/expr/if/if-without-else-result.rs b/src/test/ui/expr/if/if-without-else-result.rs index cf84a99e53fa1..95604758a6b3e 100644 --- a/src/test/ui/expr/if/if-without-else-result.rs +++ b/src/test/ui/expr/if/if-without-else-result.rs @@ -1,6 +1,6 @@ fn main() { let a = if true { true }; //~^ ERROR `if` may be missing an `else` clause [E0317] - //~| expected `()`, found `bool` + //~| expected `bool`, found `()` println!("{}", a); } diff --git a/src/test/ui/expr/if/if-without-else-result.stderr b/src/test/ui/expr/if/if-without-else-result.stderr index 821635d3768f3..317faf7c619f6 100644 --- a/src/test/ui/expr/if/if-without-else-result.stderr +++ b/src/test/ui/expr/if/if-without-else-result.stderr @@ -5,7 +5,7 @@ LL | let a = if true { true }; | ^^^^^^^^^^----^^ | | | | | found here - | expected `()`, found `bool` + | expected `bool`, found `()` | = note: `if` expressions without `else` evaluate to `()` = help: consider adding an `else` block that evaluates to the expected type diff --git a/src/test/ui/expr/if/issue-4201.rs b/src/test/ui/expr/if/issue-4201.rs index 1f292229fd6cd..59c465b9e1492 100644 --- a/src/test/ui/expr/if/issue-4201.rs +++ b/src/test/ui/expr/if/issue-4201.rs @@ -3,7 +3,7 @@ fn main() { 0 } else if false { //~^ ERROR `if` may be missing an `else` clause -//~| expected `()`, found integer +//~| expected integer, found `()` 1 }; } diff --git a/src/test/ui/expr/if/issue-4201.stderr b/src/test/ui/expr/if/issue-4201.stderr index bc638ddf55be0..612fe77642ce5 100644 --- a/src/test/ui/expr/if/issue-4201.stderr +++ b/src/test/ui/expr/if/issue-4201.stderr @@ -8,7 +8,7 @@ LL | | LL | | 1 | | - found here LL | | }; - | |_____^ expected `()`, found integer + | |_____^ expected integer, found `()` | = note: `if` expressions without `else` evaluate to `()` = help: consider adding an `else` block that evaluates to the expected type diff --git a/src/test/ui/issues/issue-19991.rs b/src/test/ui/issues/issue-19991.rs index 1f3b73f96d8b9..dd0efa972ba3e 100644 --- a/src/test/ui/issues/issue-19991.rs +++ b/src/test/ui/issues/issue-19991.rs @@ -3,7 +3,7 @@ fn main() { if let Some(homura) = Some("madoka") { //~ ERROR missing an `else` clause - //~| expected `()`, found integer + //~| expected integer, found `()` 765 }; } diff --git a/src/test/ui/issues/issue-19991.stderr b/src/test/ui/issues/issue-19991.stderr index 6e92be87a02e9..57b0882b636e3 100644 --- a/src/test/ui/issues/issue-19991.stderr +++ b/src/test/ui/issues/issue-19991.stderr @@ -6,7 +6,7 @@ LL | | LL | | 765 | | --- found here LL | | }; - | |_____^ expected `()`, found integer + | |_____^ expected integer, found `()` | = note: `if` expressions without `else` evaluate to `()` = help: consider adding an `else` block that evaluates to the expected type From 50f662e99ec372a3c9558876d4164e8665859217 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Thu, 6 Oct 2022 10:18:16 -0700 Subject: [PATCH 3/7] rustdoc: remove unused CSS `.content .item-list` When these rules were added in 4fd061c426902b0904c65e64a3780b21f9ab3afb (yeah, that's the very first commit of rustdoc_ng), `.item-list` was a `
    `, and this would override the default style for that tag. In c1b1d6804bfce1aee3a95b3cbff3eaeb15bad9a4, it was changed to use a `
    ` tag, so these rules are both no-ops. --- src/librustdoc/html/static/css/rustdoc.css | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index b86b8f9dbf864..6a0acb908b25e 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -690,11 +690,6 @@ pre, .rustdoc.source .example-wrap { border: 1px solid var(--border-color); } -.content .item-list { - list-style-type: none; - padding: 0; -} - /* Shift "where ..." part of method or fn definition down a line */ .content .method .where, .content .fn .where, From 0997b28a8917d46875cfd6622f794d28dc346140 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Thu, 6 Oct 2022 10:20:47 -0700 Subject: [PATCH 4/7] rustdoc: remove unused HTML `class="item-list"` Since 50f662e99ec372a3c9558876d4164e8665859217, there is no CSS or JS targeting this class. --- src/librustdoc/html/render/print_item.rs | 8 ++++---- src/test/rustdoc/impl-disambiguation.rs | 10 +++++----- src/test/rustdoc/impl-parts.rs | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 7bd0dbf9325fa..7999373511b6c 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -890,7 +890,7 @@ fn item_trait(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean: w, "implementors", "Implementors", - "
    ", + "
    ", ); for implementor in concrete { render_implementor(cx, implementor, it, w, &implementor_dups, &[]); @@ -902,7 +902,7 @@ fn item_trait(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean: w, "synthetic-implementors", "Auto implementors", - "
    ", + "
    ", ); for implementor in synthetic { render_implementor( @@ -923,7 +923,7 @@ fn item_trait(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean: w, "implementors", "Implementors", - "
    ", + "
    ", ); if t.is_auto(cx.tcx()) { @@ -931,7 +931,7 @@ fn item_trait(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean: w, "synthetic-implementors", "Auto implementors", - "
    ", + "
    ", ); } } diff --git a/src/test/rustdoc/impl-disambiguation.rs b/src/test/rustdoc/impl-disambiguation.rs index bb978dc0f3ec8..9e74ede8ff7b3 100644 --- a/src/test/rustdoc/impl-disambiguation.rs +++ b/src/test/rustdoc/impl-disambiguation.rs @@ -4,13 +4,13 @@ pub trait Foo {} pub struct Bar { field: T } -// @has foo/trait.Foo.html '//*[@class="item-list"]//h3[@class="code-header"]' \ +// @has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ // "impl Foo for Bar" impl Foo for Bar {} -// @has foo/trait.Foo.html '//*[@class="item-list"]//h3[@class="code-header"]' \ +// @has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ // "impl Foo for Bar" impl Foo for Bar {} -// @has foo/trait.Foo.html '//*[@class="item-list"]//h3[@class="code-header"]' \ +// @has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ // "impl<'a> Foo for &'a Bar" impl<'a> Foo for &'a Bar {} @@ -22,9 +22,9 @@ pub mod mod2 { pub enum Baz {} } -// @has foo/trait.Foo.html '//*[@class="item-list"]//h3[@class="code-header"]' \ +// @has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ // "impl Foo for foo::mod1::Baz" impl Foo for mod1::Baz {} -// @has foo/trait.Foo.html '//*[@class="item-list"]//h3[@class="code-header"]' \ +// @has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ // "impl<'a> Foo for &'a foo::mod2::Baz" impl<'a> Foo for &'a mod2::Baz {} diff --git a/src/test/rustdoc/impl-parts.rs b/src/test/rustdoc/impl-parts.rs index 0a8c2c8d2a9e6..7b931727e446d 100644 --- a/src/test/rustdoc/impl-parts.rs +++ b/src/test/rustdoc/impl-parts.rs @@ -7,6 +7,6 @@ pub struct Foo { field: T } // @has impl_parts/struct.Foo.html '//*[@class="impl has-srclink"]//h3[@class="code-header"]' \ // "impl !AnAutoTrait for Foowhere T: Sync," -// @has impl_parts/trait.AnAutoTrait.html '//*[@class="item-list"]//h3[@class="code-header"]' \ +// @has impl_parts/trait.AnAutoTrait.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ // "impl !AnAutoTrait for Foowhere T: Sync," impl !AnAutoTrait for Foo where T: Sync {} From 28b26b7aa6668162bb443d712da8c2bc7b223df2 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Thu, 6 Oct 2022 11:20:37 -0700 Subject: [PATCH 5/7] rustdoc: remove unused CSS `.docblock a:not(.srclink)` This selector was added in c7312fbae4979c6d4fdfbd1f55a71cd47d82a480, because the list of impl items could be nested below `docblock`. https://github.com/rust-lang/rust/blob/c7312fbae4979c6d4fdfbd1f55a71cd47d82a480/src/librustdoc/html/render.rs#L3841-L3845 Now that rustdoc toggles have been switched to `
    `, there shouldn't be any need to put things inside docblock containers just to give them disclosure toggles. --- src/librustdoc/html/static/css/rustdoc.css | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index b86b8f9dbf864..881f114785f48 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -773,8 +773,9 @@ h2.small-section-header > .anchor { } .all-items a:hover, -.docblock a:not(.srclink):not(.test-arrow):not(.scrape-help):hover, -.docblock-short a:not(.srclink):not(.test-arrow):not(.scrape-help):hover, .item-info a { +.docblock a:not(.test-arrow):not(.scrape-help):hover, +.docblock-short a:not(.test-arrow):not(.scrape-help):hover, +.item-info a { text-decoration: underline; } From 11583986887d0ebab90f4b77faa20668112259b8 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Thu, 6 Oct 2022 12:13:23 -0700 Subject: [PATCH 6/7] Disable compressed debug sections on i586-gnu Compressed debug is enabled by default for gas (assembly) on Linux/x86 targets, and we started building our own in #102530, but that made our `compiler_builtins` incompatible with binutils < 2.32. Add an explicit option to disable that in our crosstool-ng config. Fixes #102703. --- src/ci/docker/README.md | 4 ++++ .../dist-i586-gnu-i586-i686-musl/i586-linux-gnu.config | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ci/docker/README.md b/src/ci/docker/README.md index 64faaf4f19bfb..38629c4fae7e2 100644 --- a/src/ci/docker/README.md +++ b/src/ci/docker/README.md @@ -242,10 +242,14 @@ For targets: `i586-unknown-linux-gnu` - Operating System > Target OS = linux - Operating System > Linux kernel version = 3.2.101 - Binary utilities > Version of binutils = 2.32 +- Binary utilities > binutils extra config = --enable-compressed-debug-sections=none -- (\*) - C-library > glibc version = 2.17.0 - C compiler > gcc version = 8.3.0 - C compiler > C++ = ENABLE +(\*) Compressed debug is enabled by default for gas (assembly) on Linux/x86 targets, + but that makes our `compiler_builtins` incompatible with binutils < 2.32. + ### `powerpc-linux-gnu.config` For targets: `powerpc-unknown-linux-gnu` diff --git a/src/ci/docker/host-x86_64/dist-i586-gnu-i586-i686-musl/i586-linux-gnu.config b/src/ci/docker/host-x86_64/dist-i586-gnu-i586-i686-musl/i586-linux-gnu.config index ef2e9467f4a22..cdbd52d23bc37 100644 --- a/src/ci/docker/host-x86_64/dist-i586-gnu-i586-i686-musl/i586-linux-gnu.config +++ b/src/ci/docker/host-x86_64/dist-i586-gnu-i586-i686-musl/i586-linux-gnu.config @@ -336,7 +336,7 @@ CT_BINUTILS_LINKERS_LIST="ld" CT_BINUTILS_LINKER_DEFAULT="bfd" # CT_BINUTILS_PLUGINS is not set CT_BINUTILS_RELRO=m -CT_BINUTILS_EXTRA_CONFIG_ARRAY="" +CT_BINUTILS_EXTRA_CONFIG_ARRAY="--enable-compressed-debug-sections=none" # CT_BINUTILS_FOR_TARGET is not set CT_ALL_BINUTILS_CHOICES="BINUTILS" From 9b3db34072551680c12da4192ad528a01579ce61 Mon Sep 17 00:00:00 2001 From: Kornel Date: Sun, 2 Oct 2022 13:18:54 +0100 Subject: [PATCH 7/7] Warn about Visual Studio Code branding confusion --- compiler/rustc_codegen_ssa/src/back/link.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index bb57fca74a21e..ce832def4392d 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -979,9 +979,10 @@ fn link_natively<'a>( but `link.exe` was not found", ); sess.note_without_error( - "please ensure that VS 2013, VS 2015, VS 2017, VS 2019 or VS 2022 \ - was installed with the Visual C++ option", + "please ensure that Visual Studio 2017 or later, or Build Tools \ + for Visual Studio were installed with the Visual C++ option.", ); + sess.note_without_error("VS Code is a different product, and is not sufficient."); } sess.abort_if_errors(); }