From 81d792f31d02ac461f5ea3f9f65f14cfc95a0e6f Mon Sep 17 00:00:00 2001 From: moxian Date: Fri, 16 Jul 2021 03:45:27 +0000 Subject: [PATCH 01/14] Copy item path rather than full `use` statement. --- src/librustdoc/html/render/print_item.rs | 5 ++--- src/librustdoc/html/static/js/main.js | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index f7073a8751fa1..58375ab09ade9 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -84,11 +84,10 @@ pub(super) fn print_item(cx: &Context<'_>, item: &clean::Item, buf: &mut Buffer, write!(buf, "{}", item.type_(), item.name.as_ref().unwrap()); write!( buf, - "", static_root_path = page.get_static_root_path(), suffix = page.resource_suffix, diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index 38ddbb3ad7427..5917927fb932f 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -985,7 +985,7 @@ function hideThemeButtonState() { }); var el = document.createElement('textarea'); - el.value = 'use ' + path.join('::') + ';'; + el.value = path.join('::'); el.setAttribute('readonly', ''); // To not make it appear on the screen. el.style.position = 'absolute'; From 4ffb1ef90fb5c39edd4dbbce8316b541de07bc5a Mon Sep 17 00:00:00 2001 From: Ali Malik Date: Mon, 2 Aug 2021 22:21:15 -0400 Subject: [PATCH 02/14] Explicit notification of lack of support for `rust-docs` component for Tier 2 targets --- src/doc/rustc/src/platform-support.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index 90ef48798ddab..f431260520620 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -73,6 +73,8 @@ Tier Policy. All tier 2 targets with host tools support the full standard library. +**NOTE:** Tier 2 targets currently do not build the `rust-docs` component. + target | notes -------|------- `aarch64-apple-darwin` | ARM64 macOS (11.0+, Big Sur+) @@ -112,6 +114,8 @@ The `std` column in the table below has the following meanings: [`no_std`]: https://rust-embedded.github.io/book/intro/no-std.html +**NOTE:** Tier 2 targets currently do not build the `rust-docs` component. + target | std | notes -------|:---:|------- `aarch64-apple-ios` | ✓ | ARM64 iOS From 079bf755a3449a61e61714a17d00f21337f2471e Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Thu, 12 Aug 2021 14:56:41 +0200 Subject: [PATCH 03/14] Detect fake spans in non_fmt_panic lint. --- compiler/rustc_lint/src/non_fmt_panic.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_lint/src/non_fmt_panic.rs b/compiler/rustc_lint/src/non_fmt_panic.rs index a32caf1bc433d..b93158d7812a8 100644 --- a/compiler/rustc_lint/src/non_fmt_panic.rs +++ b/compiler/rustc_lint/src/non_fmt_panic.rs @@ -95,7 +95,7 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc let mut l = lint.build("panic message is not a string literal"); l.note("this usage of panic!() is deprecated; it will be a hard error in Rust 2021"); l.note("for more information, see "); - if !span.contains(arg_span) { + if !is_arg_inside_call(arg_span, span) { // No clue where this argument is coming from. l.emit(); return; @@ -180,7 +180,7 @@ fn check_panic_str<'tcx>( _ => "panic message contains unused formatting placeholders", }); l.note("this message is not used as a format string when given without arguments, but will be in Rust 2021"); - if span.contains(arg.span) { + if is_arg_inside_call(arg.span, span) { l.span_suggestion( arg.span.shrink_to_hi(), &format!("add the missing argument{}", pluralize!(n_arguments)), @@ -211,7 +211,7 @@ fn check_panic_str<'tcx>( cx.struct_span_lint(NON_FMT_PANICS, brace_spans.unwrap_or_else(|| vec![span]), |lint| { let mut l = lint.build(msg); l.note("this message is not used as a format string, but will be in Rust 2021"); - if span.contains(arg.span) { + if is_arg_inside_call(arg.span, span) { l.span_suggestion( arg.span.shrink_to_lo(), "add a \"{}\" format string to use the message literally", @@ -259,3 +259,11 @@ fn panic_call<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>) -> (Span, if let hygiene::ExpnKind::Macro(_, symbol) = expn.kind { symbol } else { sym::panic }; (expn.call_site, panic_macro, macro_symbol.as_str()) } + +fn is_arg_inside_call(arg: Span, call: Span) -> bool { + // We only add suggestions if the argument we're looking at appears inside the + // panic call in the source file, to avoid invalid suggestions when macros are involved. + // We specifically check for the spans to not be identical, as that happens sometimes when + // proc_macros lie about spans and apply the same span to all the tokens they produce. + call.contains(arg) && !call.source_equal(&arg) +} From c6f4eed45c940ed214cc377505aea9bb7d9f8df2 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Fri, 13 Aug 2021 11:03:17 -0500 Subject: [PATCH 04/14] Enable `--all-targets` for `x.py check` unconditionally Now that Cargo deduplicates diagnostics from different targets, this doesn't flood the console with duplicate errors. Note that this doesn't add `--all-targets` in `Builder::cargo` directly because `impl Step for Std` actually wants to omit `--all-targets` the first time while it's still building libtest. When passed `--all-targets`, this warns that the option isn't needed, but still continues to compile. --- src/bootstrap/builder.rs | 2 +- src/bootstrap/check.rs | 66 ++++++++++++++++++---------------------- src/bootstrap/flags.rs | 10 +++--- 3 files changed, 36 insertions(+), 42 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 3904c718a2544..e2f348261112e 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -578,7 +578,7 @@ impl<'a> Builder<'a> { pub fn new(build: &Build) -> Builder<'_> { let (kind, paths) = match build.config.cmd { Subcommand::Build { ref paths } => (Kind::Build, &paths[..]), - Subcommand::Check { ref paths, all_targets: _ } => (Kind::Check, &paths[..]), + Subcommand::Check { ref paths } => (Kind::Check, &paths[..]), Subcommand::Clippy { ref paths, .. } => (Kind::Clippy, &paths[..]), Subcommand::Fix { ref paths } => (Kind::Fix, &paths[..]), Subcommand::Doc { ref paths, .. } => (Kind::Doc, &paths[..]), diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index bc106746e57e0..4eb335979b983 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -113,38 +113,35 @@ impl Step for Std { // since we initialize with an empty sysroot. // // Currently only the "libtest" tree of crates does this. + let mut cargo = builder.cargo( + compiler, + Mode::Std, + SourceType::InTree, + target, + cargo_subcommand(builder.kind), + ); + cargo.arg("--all-targets"); + std_cargo(builder, target, compiler.stage, &mut cargo); - if let Subcommand::Check { all_targets: true, .. } = builder.config.cmd { - let mut cargo = builder.cargo( - compiler, - Mode::Std, - SourceType::InTree, - target, - cargo_subcommand(builder.kind), - ); - std_cargo(builder, target, compiler.stage, &mut cargo); - cargo.arg("--all-targets"); - - // Explicitly pass -p for all dependencies krates -- this will force cargo - // to also check the tests/benches/examples for these crates, rather - // than just the leaf crate. - for krate in builder.in_tree_crates("test", Some(target)) { - cargo.arg("-p").arg(krate.name); - } - - builder.info(&format!( - "Checking stage{} std test/bench/example targets ({} -> {})", - builder.top_stage, &compiler.host, target - )); - run_cargo( - builder, - cargo, - args(builder), - &libstd_test_stamp(builder, compiler, target), - vec![], - true, - ); + // Explicitly pass -p for all dependencies krates -- this will force cargo + // to also check the tests/benches/examples for these crates, rather + // than just the leaf crate. + for krate in builder.in_tree_crates("test", Some(target)) { + cargo.arg("-p").arg(krate.name); } + + builder.info(&format!( + "Checking stage{} std test/bench/example targets ({} -> {})", + builder.top_stage, &compiler.host, target + )); + run_cargo( + builder, + cargo, + args(builder), + &libstd_test_stamp(builder, compiler, target), + vec![], + true, + ); } } @@ -195,9 +192,7 @@ impl Step for Rustc { cargo_subcommand(builder.kind), ); rustc_cargo(builder, &mut cargo, target); - if let Subcommand::Check { all_targets: true, .. } = builder.config.cmd { - cargo.arg("--all-targets"); - } + cargo.arg("--all-targets"); // Explicitly pass -p for all compiler krates -- this will force cargo // to also check the tests/benches/examples for these crates, rather @@ -318,10 +313,7 @@ macro_rules! tool_check_step { $source_type, &[], ); - - if let Subcommand::Check { all_targets: true, .. } = builder.config.cmd { - cargo.arg("--all-targets"); - } + cargo.arg("--all-targets"); // Enable internal lints for clippy and rustdoc // NOTE: this doesn't enable lints for any other tools unless they explicitly add `#![warn(rustc::internal)]` diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs index 7b74a909c286e..80c33fa4d7c97 100644 --- a/src/bootstrap/flags.rs +++ b/src/bootstrap/flags.rs @@ -78,9 +78,6 @@ pub enum Subcommand { paths: Vec, }, Check { - // Whether to run checking over all targets (e.g., unit / integration - // tests). - all_targets: bool, paths: Vec, }, Clippy { @@ -553,7 +550,12 @@ Arguments: let cmd = match subcommand.as_str() { "build" | "b" => Subcommand::Build { paths }, "check" | "c" => { - Subcommand::Check { paths, all_targets: matches.opt_present("all-targets") } + if matches.opt_present("all-targets") { + eprintln!( + "Warning: --all-targets is now on by default and does not need to be passed explicitly." + ); + } + Subcommand::Check { paths } } "clippy" => Subcommand::Clippy { paths, fix: matches.opt_present("fix") }, "fix" => Subcommand::Fix { paths }, From f25d2bd53b939a9f4e5adf5af7e9ebb3787f730a Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Sat, 14 Aug 2021 15:57:46 +0000 Subject: [PATCH 05/14] Assign FIXMEs to me and remove obsolete ones Also fixed capitalization of documentation --- compiler/rustc_infer/src/traits/engine.rs | 2 +- .../src/traits/select/mod.rs | 2 +- compiler/rustc_traits/src/type_op.rs | 15 ++------------- library/alloc/tests/const_fns.rs | 2 +- library/alloc/tests/lib.rs | 2 -- 5 files changed, 5 insertions(+), 18 deletions(-) diff --git a/compiler/rustc_infer/src/traits/engine.rs b/compiler/rustc_infer/src/traits/engine.rs index d60388b31c13c..42333dc29bc7c 100644 --- a/compiler/rustc_infer/src/traits/engine.rs +++ b/compiler/rustc_infer/src/traits/engine.rs @@ -63,7 +63,7 @@ pub trait TraitEngine<'tcx>: 'tcx { infcx: &InferCtxt<'_, 'tcx>, ) -> Result<(), Vec>>; - // FIXME this should not provide a default body for chalk as chalk should be updated + // FIXME(fee1-dead) this should not provide a default body for chalk as chalk should be updated fn select_with_constness_where_possible( &mut self, infcx: &InferCtxt<'_, 'tcx>, diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index dcf5ac63b78ea..38dbacbf2ae6c 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -316,7 +316,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { self.infcx.tcx } - /// returns `true` if the predicate is considered `const` to + /// Returns `true` if the predicate is considered `const` to /// this selection context. pub fn is_predicate_const(&self, pred: ty::Predicate<'_>) -> bool { match pred.kind().skip_binder() { diff --git a/compiler/rustc_traits/src/type_op.rs b/compiler/rustc_traits/src/type_op.rs index f4a0cc6767f09..bd0acb0e53b6c 100644 --- a/compiler/rustc_traits/src/type_op.rs +++ b/compiler/rustc_traits/src/type_op.rs @@ -6,9 +6,7 @@ use rustc_infer::infer::{InferCtxt, TyCtxtInferExt}; use rustc_infer::traits::TraitEngineExt as _; use rustc_middle::ty::query::Providers; use rustc_middle::ty::subst::{GenericArg, Subst, UserSelfTy, UserSubsts}; -use rustc_middle::ty::{ - self, FnSig, Lift, PolyFnSig, PredicateKind, Ty, TyCtxt, TypeFoldable, Variance, -}; +use rustc_middle::ty::{self, FnSig, Lift, PolyFnSig, Ty, TyCtxt, TypeFoldable, Variance}; use rustc_middle::ty::{ParamEnv, ParamEnvAnd, Predicate, ToPredicate}; use rustc_span::DUMMY_SP; use rustc_trait_selection::infer::InferCtxtBuilderExt; @@ -87,16 +85,7 @@ impl AscribeUserTypeCx<'me, 'tcx> { Ok(()) } - fn prove_predicate(&mut self, mut predicate: Predicate<'tcx>) { - if let PredicateKind::Trait(mut tr) = predicate.kind().skip_binder() { - if let hir::Constness::Const = tr.constness { - // FIXME check if we actually want to prove const predicates inside AscribeUserType - tr.constness = hir::Constness::NotConst; - predicate = - predicate.kind().rebind(PredicateKind::Trait(tr)).to_predicate(self.tcx()); - } - } - + fn prove_predicate(&mut self, predicate: Predicate<'tcx>) { self.fulfill_cx.register_predicate_obligation( self.infcx, Obligation::new(ObligationCause::dummy(), self.param_env, predicate), diff --git a/library/alloc/tests/const_fns.rs b/library/alloc/tests/const_fns.rs index 02e8f8f40228f..b6ef3eee291fb 100644 --- a/library/alloc/tests/const_fns.rs +++ b/library/alloc/tests/const_fns.rs @@ -10,7 +10,7 @@ pub const MY_VEC: Vec = Vec::new(); #[allow(dead_code)] pub const MY_STRING: String = String::new(); -// FIXME remove this struct once we put `K: ?const Ord` on BTreeMap::new. +// FIXME(fee1-dead) remove this struct once we put `K: ?const Ord` on BTreeMap::new. #[derive(PartialEq, Eq, PartialOrd)] pub struct MyType; diff --git a/library/alloc/tests/lib.rs b/library/alloc/tests/lib.rs index f7d68b5a89e99..7284c05d5ff16 100644 --- a/library/alloc/tests/lib.rs +++ b/library/alloc/tests/lib.rs @@ -25,8 +25,6 @@ #![feature(string_remove_matches)] #![feature(const_btree_new)] #![feature(const_trait_impl)] -// FIXME remove this when const_trait_impl is not incomplete anymore -#![allow(incomplete_features)] use std::collections::hash_map::DefaultHasher; use std::hash::{Hash, Hasher}; From 856dd71bac5add26ed538e408de3c31e66ff53e4 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 15 Aug 2021 18:40:40 +0200 Subject: [PATCH 06/14] Update redox_syscall The currently pinned version doesn't compile with the latest rustc nightly --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 940608975c5ec..8cd85e1232ef6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2955,9 +2955,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.5" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94341e4e44e24f6b591b59e47a8a027df12e008d73fd5672dbea9cc22f4507d9" +checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" dependencies = [ "bitflags", ] From 0455fe342f585eedb69075b4121ff0e285ebbced Mon Sep 17 00:00:00 2001 From: Erin Power Date: Fri, 30 Jul 2021 13:32:16 +0200 Subject: [PATCH 07/14] Update RELEASES.md for 1.55.0 Co-authored-by: Eric Huss Co-authored-by: inquisitivecrystal <22333129+inquisitivecrystal@users.noreply.github.com> Co-authored-by: Mark Rousskov Co-authored-by: Daniel Giger --- RELEASES.md | 142 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) diff --git a/RELEASES.md b/RELEASES.md index 19fe97deacca6..1d9ad3160f77e 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,145 @@ +Version 1.55.0 (2021-09-09) +============================ + +Language +-------- +- [You can now write open "from" range patterns (`X..`), which will start at `X` and + will end at the maximum value of the integer.][83918] +- [You can now explicitly import the prelude of different editions + through `std::prelude` (e.g. `use std::prelude::rust_2021::*;`).][86294] + +Compiler +-------- +- [Added tier 3\* support for `powerpc-unknown-freebsd`.][87370] +- [Added tier 3 support for `powerpc64le-unknown-freebsd`.][83572] + +\* Refer to Rust's [platform support page][platform-support-doc] for more + information on Rust's tiered platform support. + +Libraries +--------- + +- [Updated std's float parsing to use the Eisel-Lemire algorithm.][86761] + These improvements should in general provide faster string parsing of floats, + no longer reject certain valid floating point values, and reduce + the produced code size for non-stripped artifacts. +- [`string::Drain` now implements `AsRef` and `AsRef<[u8]>`.][86858] +- [`collections::{BinaryHeap, BTreeSet, HashSet, LinkedList, VecDeque}` now + implement `From<[T; N]>`.][84111] +- [`collections::{BTreeMap, HashMap}` now implement `From<[(K, V); N]>`.][84111] + This allows you to write the following; + ```rust + let highscores = std::collections::HashMap::from([ + ("Alice", 9000u32), + ("Bob", 7250), + ("Charlie", 5500), + ]); + ``` + +Stabilised APIs +--------------- + +- [`Bound::cloned`] +- [`Drain::as_str`] +- [`IntoInnerError::into_error`] +- [`IntoInnerError::into_parts`] +- [`MaybeUninit::assume_init_mut`] +- [`MaybeUninit::assume_init_ref`] +- [`MaybeUninit::write`] +- [`array::map`] +- [`ops::ControlFlow`] +- [`x86::_bittest`] +- [`x86::_bittestandcomplement`] +- [`x86::_bittestandreset`] +- [`x86::_bittestandset`] +- [`x86_64::_bittest64`] +- [`x86_64::_bittestandcomplement64`] +- [`x86_64::_bittestandreset64`] +- [`x86_64::_bittestandset64`] + +The following previously stable functions are now `const`. + +- [`str::from_utf8_unchecked`] +- [`mem::transmute`] + + +Cargo +----- +- [Cargo will now deduplicate compiler diagnostics to the terminal when invoking + rustc in parallel such as when using `cargo test`.][cargo/9675] +- [The package definition in `cargo metadata` now includes the `"default_run"` + field from the manifest.][cargo/9550] +- [Added `cargo d` as an alias for `cargo doc`.][cargo/9680] + +Rustdoc +------- +- [Added "Go to item on exact match" search option.][85876] +- [The "Implementors" section on traits no longer shows redundant + method definitions.][85970] +- [Trait implementations are toggled open by default.][86260] This should make the + implementations more searchable by tools like `CTRL+F` in your browser. +- [Intra-doc links should now correctly resolve associated items (e.g. methods) + through type aliases.][86334] +- [Traits which are marked with `#[doc(hidden)]` will no longer appear in the + "Trait Implementations" section.][86513] + + +Compatibility Notes +------------------- +- [std functions that return an `io::Error` will no longer use the + `ErrorKind::Other` variant.][85746] This is to better reflect that these + kinds of errors could be categorised [into newer more specific `ErrorKind` + variants][79965], and that they do not represent a user error. +- [Using environment variable names with `process::Command` on Windows now + behaves as expected.][85270] Previously using envionment variables with + `Command` would cause them to be ASCII-uppercased. +- [Rustdoc will now warn on using rustdoc lints that aren't prefixed + with `rustdoc::`][86849] + +[86849]: https://github.com/rust-lang/rust/pull/86849 +[86513]: https://github.com/rust-lang/rust/pull/86513 +[86334]: https://github.com/rust-lang/rust/pull/86334 +[86260]: https://github.com/rust-lang/rust/pull/86260 +[85970]: https://github.com/rust-lang/rust/pull/85970 +[85876]: https://github.com/rust-lang/rust/pull/85876 +[83572]: https://github.com/rust-lang/rust/pull/83572 +[86294]: https://github.com/rust-lang/rust/pull/86294 +[86858]: https://github.com/rust-lang/rust/pull/86858 +[86761]: https://github.com/rust-lang/rust/pull/86761 +[85769]: https://github.com/rust-lang/rust/pull/85769 +[85746]: https://github.com/rust-lang/rust/pull/85746 +[85305]: https://github.com/rust-lang/rust/pull/85305 +[85270]: https://github.com/rust-lang/rust/pull/85270 +[84111]: https://github.com/rust-lang/rust/pull/84111 +[83918]: https://github.com/rust-lang/rust/pull/83918 +[79965]: https://github.com/rust-lang/rust/pull/79965 +[87370]: https://github.com/rust-lang/rust/pull/87370 +[87298]: https://github.com/rust-lang/rust/pull/87298 +[cargo/9675]: https://github.com/rust-lang/cargo/pull/9675 +[cargo/9550]: https://github.com/rust-lang/cargo/pull/9550 +[cargo/9680]: https://github.com/rust-lang/cargo/pull/9680 +[`array::map`]: https://doc.rust-lang.org/stable/std/primitive.array.html#method.map +[`Bound::cloned`]: https://doc.rust-lang.org/stable/std/ops/enum.Bound.html#method.cloned +[`Drain::as_str`]: https://doc.rust-lang.org/stable/std/string/struct.Drain.html#method.as_str +[`IntoInnerError::into_error`]: https://doc.rust-lang.org/stable/std/io/struct.IntoInnerError.html#method.into_error +[`IntoInnerError::into_parts`]: https://doc.rust-lang.org/stable/std/io/struct.IntoInnerError.html#method.into_parts +[`MaybeUninit::assume_init_mut`]: https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#method.assume_init_mut +[`MaybeUninit::assume_init_ref`]: https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#method.assume_init_ref +[`MaybeUninit::write`]: https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#method.write +[`Seek::rewind`]: https://doc.rust-lang.org/stable/std/io/trait.Seek.html#method.rewind +[`mem::transmute`]: https://doc.rust-lang.org/stable/std/mem/fn.transmute.html +[`ops::ControlFlow`]: https://doc.rust-lang.org/stable/std/ops/enum.ControlFlow.html +[`str::from_utf8_unchecked`]: https://doc.rust-lang.org/stable/std/str/fn.from_utf8_unchecked.html +[`x86::_bittest`]: https://doc.rust-lang.org/stable/core/arch/x86/fn._bittest.html +[`x86::_bittestandcomplement`]: https://doc.rust-lang.org/stable/core/arch/x86/fn._bittestandcomplement.html +[`x86::_bittestandreset`]: https://doc.rust-lang.org/stable/core/arch/x86/fn._bittestandreset.html +[`x86::_bittestandset`]: https://doc.rust-lang.org/stable/core/arch/x86/fn._bittestandset.html +[`x86_64::_bittest64`]: https://doc.rust-lang.org/stable/core/arch/x86_64/fn._bittest64.html +[`x86_64::_bittestandcomplement64`]: https://doc.rust-lang.org/stable/core/arch/x86_64/fn._bittestandcomplement64.html +[`x86_64::_bittestandreset64`]: https://doc.rust-lang.org/stable/core/arch/x86_64/fn._bittestandreset64.html +[`x86_64::_bittestandset64`]: https://doc.rust-lang.org/stable/core/arch/x86_64/fn._bittestandset64.html + + Version 1.54.0 (2021-07-29) ============================ From 111201d27c4262d66834e495ffa515792e3a5771 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Thu, 12 Aug 2021 12:17:25 +0200 Subject: [PATCH 08/14] Use multi span suggestions for closure migrations. --- compiler/rustc_typeck/src/check/upvar.rs | 90 ++++++++++++++---------- 1 file changed, 53 insertions(+), 37 deletions(-) diff --git a/compiler/rustc_typeck/src/check/upvar.rs b/compiler/rustc_typeck/src/check/upvar.rs index 46f360075c09d..f4da3d3c8704e 100644 --- a/compiler/rustc_typeck/src/check/upvar.rs +++ b/compiler/rustc_typeck/src/check/upvar.rs @@ -47,7 +47,7 @@ use rustc_middle::ty::{ }; use rustc_session::lint; use rustc_span::sym; -use rustc_span::{MultiSpan, Span, Symbol, DUMMY_SP}; +use rustc_span::{BytePos, MultiSpan, Pos, Span, Symbol, DUMMY_SP}; use rustc_trait_selection::infer::InferCtxtExt; use rustc_data_structures::stable_map::FxHashMap; @@ -645,6 +645,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } diagnostics_builder.note("for more information, see "); + let diagnostic_msg = format!( + "add a dummy let to cause {} to be fully captured", + migrated_variables_concat + ); + let mut closure_body_span = self.tcx.hir().span(body_id.hir_id); // If the body was entirely expanded from a macro @@ -655,43 +660,54 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { closure_body_span = closure_body_span.parent().unwrap_or(DUMMY_SP); } - let (span, sugg, app) = - match self.tcx.sess.source_map().span_to_snippet(closure_body_span) { - Ok(s) => { - let trimmed = s.trim_start(); - let mut lines = trimmed.lines(); - let line1 = lines.next().unwrap_or_default(); - - // If the closure contains a block then replace the opening brace - // with "{ let _ = (..); " - let sugg = if line1.trim_end() == "{" { - // This is a multi-line closure with just a `{` on the first line, - // so we put the `let` on its own line. - // We take the indentation from the next non-empty line. - let line2 = lines.filter(|line| !line.is_empty()).next().unwrap_or_default(); - let indent = line2.split_once(|c: char| !c.is_whitespace()).unwrap_or_default().0; - format!("{{\n{}{};{}", indent, migration_string, &trimmed[line1.len()..]) - } else if line1.starts_with('{') { - format!("{{ {}; {}", migration_string, &trimmed[1..].trim_start()) - } else { - format!("{{ {}; {} }}", migration_string, s) - }; - (closure_body_span, sugg, Applicability::MachineApplicable) - } - Err(_) => (closure_span, migration_string.clone(), Applicability::HasPlaceholders), - }; - - let diagnostic_msg = format!( - "add a dummy let to cause {} to be fully captured", - migrated_variables_concat - ); + if let Ok(s) = self.tcx.sess.source_map().span_to_snippet(closure_body_span) { + let mut lines = s.lines(); + let line1 = lines.next().unwrap_or_default(); + + if line1.trim_end() == "{" { + // This is a multi-line closure with just a `{` on the first line, + // so we put the `let` on its own line. + // We take the indentation from the next non-empty line. + let line2 = lines.filter(|line| !line.is_empty()).next().unwrap_or_default(); + let indent = line2.split_once(|c: char| !c.is_whitespace()).unwrap_or_default().0; + diagnostics_builder.span_suggestion( + closure_body_span.with_lo(closure_body_span.lo() + BytePos::from_usize(line1.len())).shrink_to_lo(), + &diagnostic_msg, + format!("\n{}{};", indent, migration_string), + Applicability::MachineApplicable, + ); + } else if line1.starts_with('{') { + // This is a closure with its body wrapped in + // braces, but with more than just the opening + // brace on the first line. We put the `let` + // directly after the `{`. + diagnostics_builder.span_suggestion( + closure_body_span.with_lo(closure_body_span.lo() + BytePos(1)).shrink_to_lo(), + &diagnostic_msg, + format!(" {};", migration_string), + Applicability::MachineApplicable, + ); + } else { + // This is a closure without braces around the body. + // We add braces to add the `let` before the body. + diagnostics_builder.multipart_suggestion( + &diagnostic_msg, + vec![ + (closure_body_span.shrink_to_lo(), format!("{{ {}; ", migration_string)), + (closure_body_span.shrink_to_hi(), " }".to_string()), + ], + Applicability::MachineApplicable + ); + } + } else { + diagnostics_builder.span_suggestion( + closure_span, + &diagnostic_msg, + migration_string, + Applicability::HasPlaceholders + ); + } - diagnostics_builder.span_suggestion( - span, - &diagnostic_msg, - sugg, - app, - ); diagnostics_builder.emit(); }, ); From 64310977e6e890563d9dfd6d9b2d6d6442ffd281 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Thu, 12 Aug 2021 12:17:35 +0200 Subject: [PATCH 09/14] Update test output. --- .../migrations/auto_traits.stderr | 26 ++++----- .../migrations/insignificant_drop.stderr | 42 +++------------ .../insignificant_drop_attr_migrations.stderr | 12 +---- .../migrations/macro.stderr | 2 +- .../migrations/migrations_rustfix.stderr | 8 +-- .../migrations/mir_calls_to_shims.stderr | 6 +-- .../migrations/multi_diagnostics.stderr | 34 ++++-------- .../migrations/precise.stderr | 12 +---- .../migrations/significant_drop.stderr | 54 ++++--------------- 9 files changed, 44 insertions(+), 152 deletions(-) diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.stderr b/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.stderr index e8dd81ede2547..98396abb6ff66 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.stderr +++ b/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.stderr @@ -16,11 +16,11 @@ LL | #![deny(rust_2021_incompatible_closure_captures)] help: add a dummy let to cause `fptr` to be fully captured | LL ~ thread::spawn(move || { let _ = &fptr; unsafe { -LL + -LL + -LL + -LL + -LL + *fptr.0 = 20; +LL | +LL | +LL | +LL | +LL | *fptr.0 = 20; ... error: changes to closure capture in Rust 2021 will affect `Sync`, `Send` trait implementation for closure @@ -36,11 +36,11 @@ LL | *fptr.0.0 = 20; help: add a dummy let to cause `fptr` to be fully captured | LL ~ thread::spawn(move || { let _ = &fptr; unsafe { -LL + -LL + -LL + -LL + -LL + *fptr.0.0 = 20; +LL | +LL | +LL | +LL | +LL | *fptr.0.0 = 20; ... error: changes to closure capture in Rust 2021 will affect `Clone` trait implementation for closure and drop order @@ -60,11 +60,7 @@ help: add a dummy let to cause `f` to be fully captured | LL ~ let c = || { LL + let _ = &f; -LL + -LL + -LL + -LL + - ... + | error: aborting due to 3 previous errors diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.stderr b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.stderr index b719b89f5fcbc..7989a8fa5ccae 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.stderr +++ b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.stderr @@ -30,11 +30,7 @@ help: add a dummy let to cause `t`, `t1`, `t2` to be fully captured | LL ~ let c = || { LL + let _ = (&t, &t1, &t2); -LL + -LL + -LL + -LL + - ... + | error: changes to closure capture in Rust 2021 will affect drop order --> $DIR/insignificant_drop.rs:41:13 @@ -59,11 +55,7 @@ help: add a dummy let to cause `t`, `t1` to be fully captured | LL ~ let c = || { LL + let _ = (&t, &t1); -LL + -LL + -LL + -LL + let _t = t.0; - ... + | error: changes to closure capture in Rust 2021 will affect drop order --> $DIR/insignificant_drop.rs:62:13 @@ -82,11 +74,7 @@ help: add a dummy let to cause `t` to be fully captured | LL ~ let c = || { LL + let _ = &t; -LL + -LL + -LL + -LL + let _t = t.0; - ... + | error: changes to closure capture in Rust 2021 will affect drop order --> $DIR/insignificant_drop.rs:83:13 @@ -105,11 +93,7 @@ help: add a dummy let to cause `t` to be fully captured | LL ~ let c = || { LL + let _ = &t; -LL + -LL + -LL + -LL + let _t = t.0; - ... + | error: changes to closure capture in Rust 2021 will affect drop order --> $DIR/insignificant_drop.rs:104:13 @@ -128,11 +112,7 @@ help: add a dummy let to cause `t` to be fully captured | LL ~ let c = || { LL + let _ = &t; -LL + -LL + -LL + -LL + let _t = t.0; - ... + | error: changes to closure capture in Rust 2021 will affect drop order --> $DIR/insignificant_drop.rs:122:13 @@ -156,11 +136,7 @@ help: add a dummy let to cause `t1`, `t` to be fully captured | LL ~ let c = move || { LL + let _ = (&t1, &t); -LL + -LL + -LL + -LL + println!("{} {}", t1.1, t.1); - ... + | error: changes to closure capture in Rust 2021 will affect drop order --> $DIR/insignificant_drop.rs:142:13 @@ -179,11 +155,7 @@ help: add a dummy let to cause `t` to be fully captured | LL ~ let c = || { LL + let _ = &t; -LL + -LL + -LL + -LL + let _t = t.0; - ... + | error: aborting due to 7 previous errors diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.stderr b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.stderr index 669614fee0a93..961834aca194d 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.stderr +++ b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.stderr @@ -20,11 +20,7 @@ help: add a dummy let to cause `t` to be fully captured | LL ~ let c = || { LL + let _ = &t; -LL + -LL + -LL + -LL + let _t = t.0; - ... + | error: changes to closure capture in Rust 2021 will affect drop order --> $DIR/insignificant_drop_attr_migrations.rs:57:13 @@ -43,11 +39,7 @@ help: add a dummy let to cause `t` to be fully captured | LL ~ let c = move || { LL + let _ = &t; -LL + -LL + -LL + -LL + let _t = t.1; - ... + | error: aborting due to 2 previous errors diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/macro.stderr b/src/test/ui/closures/2229_closure_analysis/migrations/macro.stderr index 0614b78a7437b..d1f959dfc520e 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/macro.stderr +++ b/src/test/ui/closures/2229_closure_analysis/migrations/macro.stderr @@ -18,7 +18,7 @@ LL | #![deny(rust_2021_incompatible_closure_captures)] help: add a dummy let to cause `a` to be fully captured | LL | let _ = || { let _ = &a; dbg!(a.0) }; - | ~~~~~~~~~~~~~~~~~~~~~~~~~ + | +++++++++++++ + error: aborting due to previous error diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/migrations_rustfix.stderr b/src/test/ui/closures/2229_closure_analysis/migrations/migrations_rustfix.stderr index 8d4819fe2e221..3589a6150d064 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/migrations_rustfix.stderr +++ b/src/test/ui/closures/2229_closure_analysis/migrations/migrations_rustfix.stderr @@ -20,11 +20,7 @@ help: add a dummy let to cause `t` to be fully captured | LL ~ let c = || { LL + let _ = &t; -LL + -LL + -LL + -LL + let _t = t.0; - ... + | error: changes to closure capture in Rust 2021 will affect drop order --> $DIR/migrations_rustfix.rs:33:13 @@ -41,7 +37,7 @@ LL | } help: add a dummy let to cause `t` to be fully captured | LL | let c = || { let _ = &t; t.0 }; - | ~~~~~~~~~~~~~~~~~~~ + | +++++++++++++ + error: aborting due to 2 previous errors diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.stderr b/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.stderr index b6ee5edb59e79..10816b7bc3adf 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.stderr +++ b/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.stderr @@ -17,11 +17,7 @@ help: add a dummy let to cause `f` to be fully captured | LL ~ let result = panic::catch_unwind(move || { LL + let _ = &f; -LL + -LL + -LL + -LL + - ... + | error: aborting due to previous error diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.stderr b/src/test/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.stderr index b887b212e3d45..8bee950c13eca 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.stderr +++ b/src/test/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.stderr @@ -23,11 +23,7 @@ help: add a dummy let to cause `f1`, `f2` to be fully captured | LL ~ let c = || { LL + let _ = (&f1, &f2); -LL + -LL + -LL + -LL + - ... + | error: changes to closure capture in Rust 2021 will affect `Clone` trait implementation for closure --> $DIR/multi_diagnostics.rs:42:13 @@ -43,11 +39,7 @@ help: add a dummy let to cause `f1` to be fully captured | LL ~ let c = || { LL + let _ = &f1; -LL + -LL + -LL + -LL + - ... + | error: changes to closure capture in Rust 2021 will affect `Clone` trait implementation for closure --> $DIR/multi_diagnostics.rs:67:13 @@ -69,11 +61,7 @@ help: add a dummy let to cause `f1` to be fully captured | LL ~ let c = || { LL + let _ = &f1; -LL + -LL + -LL + -LL + - ... + | error: changes to closure capture in Rust 2021 will affect `Clone` trait implementation for closure and drop order --> $DIR/multi_diagnostics.rs:86:13 @@ -98,11 +86,7 @@ help: add a dummy let to cause `f1` to be fully captured | LL ~ let c = || { LL + let _ = &f1; -LL + -LL + -LL + -LL + - ... + | error: changes to closure capture in Rust 2021 will affect `Sync`, `Send` trait implementation for closure --> $DIR/multi_diagnostics.rs:119:19 @@ -123,11 +107,11 @@ LL | *fptr2.0 = 20; help: add a dummy let to cause `fptr1`, `fptr2` to be fully captured | LL ~ thread::spawn(move || { let _ = (&fptr1, &fptr2); unsafe { -LL + -LL + -LL + -LL + -LL + +LL | +LL | +LL | +LL | +LL | ... error: aborting due to 5 previous errors diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/precise.stderr b/src/test/ui/closures/2229_closure_analysis/migrations/precise.stderr index 51b4e11819f45..aa9b8672a0ffb 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/precise.stderr +++ b/src/test/ui/closures/2229_closure_analysis/migrations/precise.stderr @@ -20,11 +20,7 @@ help: add a dummy let to cause `t` to be fully captured | LL ~ let c = || { LL + let _ = &t; -LL + -LL + -LL + -LL + let _t = t.0; - ... + | error: changes to closure capture in Rust 2021 will affect drop order --> $DIR/precise.rs:45:13 @@ -53,11 +49,7 @@ help: add a dummy let to cause `u` to be fully captured | LL ~ let c = || { LL + let _ = &u; -LL + -LL + -LL + -LL + let _x = u.0.0; - ... + | error: aborting due to 2 previous errors diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.stderr b/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.stderr index 81700e32b5f40..e9170eba3f176 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.stderr +++ b/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.stderr @@ -30,11 +30,7 @@ help: add a dummy let to cause `t`, `t1`, `t2` to be fully captured | LL ~ let c = || { LL + let _ = (&t, &t1, &t2); -LL + -LL + -LL + -LL + let _t = t.0; - ... + | error: changes to closure capture in Rust 2021 will affect drop order --> $DIR/significant_drop.rs:50:13 @@ -59,11 +55,7 @@ help: add a dummy let to cause `t`, `t1` to be fully captured | LL ~ let c = || { LL + let _ = (&t, &t1); -LL + -LL + -LL + -LL + let _t = t.0; - ... + | error: changes to closure capture in Rust 2021 will affect drop order --> $DIR/significant_drop.rs:71:13 @@ -82,11 +74,7 @@ help: add a dummy let to cause `t` to be fully captured | LL ~ let c = || { LL + let _ = &t; -LL + -LL + -LL + -LL + let _t = t.0; - ... + | error: changes to closure capture in Rust 2021 will affect drop order --> $DIR/significant_drop.rs:91:13 @@ -105,11 +93,7 @@ help: add a dummy let to cause `t` to be fully captured | LL ~ let c = || { LL + let _ = &t; -LL + -LL + -LL + -LL + let _t = t.0; - ... + | error: changes to closure capture in Rust 2021 will affect drop order --> $DIR/significant_drop.rs:109:13 @@ -128,11 +112,7 @@ help: add a dummy let to cause `t` to be fully captured | LL ~ let c = || { LL + let _ = &t; -LL + -LL + -LL + -LL + let _t = t.0; - ... + | error: changes to closure capture in Rust 2021 will affect drop order --> $DIR/significant_drop.rs:125:13 @@ -151,11 +131,7 @@ help: add a dummy let to cause `t` to be fully captured | LL ~ let c = || { LL + let _ = &t; -LL + -LL + -LL + -LL + let _t = t.1; - ... + | error: changes to closure capture in Rust 2021 will affect drop order --> $DIR/significant_drop.rs:143:13 @@ -179,11 +155,7 @@ help: add a dummy let to cause `t1`, `t` to be fully captured | LL ~ let c = move || { LL + let _ = (&t1, &t); -LL + -LL + -LL + -LL + println!("{:?} {:?}", t1.1, t.1); - ... + | error: changes to closure capture in Rust 2021 will affect drop order --> $DIR/significant_drop.rs:163:21 @@ -202,11 +174,7 @@ help: add a dummy let to cause `tuple` to be fully captured | LL ~ let c = || { LL + let _ = &tuple; -LL + -LL + -LL + -LL + tuple.0; - ... + | error: changes to closure capture in Rust 2021 will affect drop order --> $DIR/significant_drop.rs:181:17 @@ -225,11 +193,7 @@ help: add a dummy let to cause `tuple` to be fully captured | LL ~ let c = || { LL + let _ = &tuple; -LL + -LL + -LL + -LL + tuple.0; - ... + | error: aborting due to 9 previous errors From ee85704c0434e8453ee7d1113012331387cb6ee0 Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Mon, 16 Aug 2021 11:29:05 +0000 Subject: [PATCH 10/14] Skip assert ICE with default_method_body_is_const functions marked with #[default_method_body_is_const] would ICE when being const checked due to it not being a const function: `tcx.is_const_fn_raw(did)` returns false. We should skip this assert when it is marked with that attribute. --- compiler/rustc_mir/src/transform/check_consts/mod.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_mir/src/transform/check_consts/mod.rs b/compiler/rustc_mir/src/transform/check_consts/mod.rs index 7e22ed22db4fe..a5cb0f4e14b17 100644 --- a/compiler/rustc_mir/src/transform/check_consts/mod.rs +++ b/compiler/rustc_mir/src/transform/check_consts/mod.rs @@ -9,7 +9,7 @@ use rustc_hir as hir; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_middle::mir; use rustc_middle::ty::{self, TyCtxt}; -use rustc_span::Symbol; +use rustc_span::{sym, Symbol}; pub use self::qualifs::Qualif; @@ -104,6 +104,13 @@ pub fn rustc_allow_const_fn_unstable( pub fn is_const_stable_const_fn(tcx: TyCtxt<'tcx>, def_id: DefId) -> bool { use attr::{ConstStability, Stability, StabilityLevel}; + // A default body marked const is not const-stable because const + // trait fns currently cannot be const-stable. We shouldn't + // restrict default bodies to only call const-stable functions. + if tcx.has_attr(def_id, sym::default_method_body_is_const) { + return false; + } + // Const-stability is only relevant for `const fn`. assert!(tcx.is_const_fn_raw(def_id)); From 85abdf07578f14b9c07b3aed9f6b23b1bbf23f8f Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Mon, 16 Aug 2021 14:46:08 +0000 Subject: [PATCH 11/14] Add ui test --- ...ult-method-body-is-const-with-staged-api.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/test/ui/rfc-2632-const-trait-impl/default-method-body-is-const-with-staged-api.rs diff --git a/src/test/ui/rfc-2632-const-trait-impl/default-method-body-is-const-with-staged-api.rs b/src/test/ui/rfc-2632-const-trait-impl/default-method-body-is-const-with-staged-api.rs new file mode 100644 index 0000000000000..d5b1a9073acea --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/default-method-body-is-const-with-staged-api.rs @@ -0,0 +1,18 @@ +// check-pass + +// This was an ICE, because the compiler ensures the +// function to be const when performing const checking, +// but functions marked with the attribute are not const +// *and* subject to const checking. + +#![feature(staged_api)] +#![feature(const_trait_impl)] +#![feature(const_fn_trait_bound)] +#![stable(since = "1", feature = "foo")] + +trait Tr { + #[default_method_body_is_const] + fn a() {} +} + +fn main() {} From 5e4657d3f7af84a0507eb341d7c51f6b9215295e Mon Sep 17 00:00:00 2001 From: Stefan Schindler Date: Mon, 16 Aug 2021 20:40:23 +0200 Subject: [PATCH 12/14] Fix double output of the summary line --- src/tools/rustdoc-gui/tester.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/tools/rustdoc-gui/tester.js b/src/tools/rustdoc-gui/tester.js index 4e77d27d399c2..d1cf5fb803d63 100644 --- a/src/tools/rustdoc-gui/tester.js +++ b/src/tools/rustdoc-gui/tester.js @@ -93,8 +93,13 @@ function char_printer(n_tests) { } }, finish: function() { - const spaces = " ".repeat(max_per_line - (current % max_per_line)); - process.stdout.write(`${spaces} (${current}/${n_tests})${os.EOL}${os.EOL}`); + if (current % max_per_line === 0) { + // Don't output if we are already at a matching line end + console.log(""); + } else { + const spaces = " ".repeat(max_per_line - (current % max_per_line)); + process.stdout.write(`${spaces} (${current}/${n_tests})${os.EOL}${os.EOL}`); + } }, }; } From ee4521e19b3d3518a3ead06b1bebec77f0955319 Mon Sep 17 00:00:00 2001 From: Stefan Schindler Date: Mon, 16 Aug 2021 20:41:15 +0200 Subject: [PATCH 13/14] Add a font test based on #85669 --- src/test/rustdoc-gui/module-item-font.goml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/test/rustdoc-gui/module-item-font.goml diff --git a/src/test/rustdoc-gui/module-item-font.goml b/src/test/rustdoc-gui/module-item-font.goml new file mode 100644 index 0000000000000..12dbd0195978a --- /dev/null +++ b/src/test/rustdoc-gui/module-item-font.goml @@ -0,0 +1,21 @@ +goto: file://|DOC_PATH|/test_docs/index.html +// This test ensures that the correct font is applied on the modules listed items. + +// modules +assert-css: ("#modules + .item-table .item-left a", {"font-family": '"Fira Sans", Arial, sans-serif'}) +assert-css: ("#modules + .item-table .item-right.docblock-short", {"font-family": '"Source Serif 4", "Noto Sans KR", serif'}) +// structs +assert-css: ("#structs + .item-table .item-left a", {"font-family": '"Fira Sans", Arial, sans-serif'}) +assert-css: ("#structs + .item-table .item-right.docblock-short", {"font-family": '"Source Serif 4", "Noto Sans KR", serif'}) +// enums +assert-css: ("#enums + .item-table .item-left a", {"font-family": '"Fira Sans", Arial, sans-serif'}) +assert-css: ("#enums + .item-table .item-right.docblock-short", {"font-family": '"Source Serif 4", "Noto Sans KR", serif'}) +// traits +assert-css: ("#traits + .item-table .item-left a", {"font-family": '"Fira Sans", Arial, sans-serif'}) +assert-css: ("#traits + .item-table .item-right.docblock-short", {"font-family": '"Source Serif 4", "Noto Sans KR", serif'}) +// functions +assert-css: ("#functions + .item-table .item-left a", {"font-family": '"Fira Sans", Arial, sans-serif'}) +assert-css: ("#functions + .item-table .item-right.docblock-short", {"font-family": '"Source Serif 4", "Noto Sans KR", serif'}) +// keywords +assert-css: ("#keywords + .item-table .item-left a", {"font-family": '"Fira Sans", Arial, sans-serif'}) +assert-css: ("#keywords + .item-table .item-right.docblock-short", {"font-family": '"Source Serif 4", "Noto Sans KR", serif'}) From 2f486d5f8d77256c4bba91b135f62e66fcc85e04 Mon Sep 17 00:00:00 2001 From: Stefan Schindler Date: Mon, 16 Aug 2021 21:38:30 +0200 Subject: [PATCH 14/14] Merge the two test files as they are testing the same features --- src/test/rustdoc-gui/module-item-font.goml | 21 --------------------- src/test/rustdoc-gui/module-items-font.goml | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 21 deletions(-) delete mode 100644 src/test/rustdoc-gui/module-item-font.goml diff --git a/src/test/rustdoc-gui/module-item-font.goml b/src/test/rustdoc-gui/module-item-font.goml deleted file mode 100644 index 12dbd0195978a..0000000000000 --- a/src/test/rustdoc-gui/module-item-font.goml +++ /dev/null @@ -1,21 +0,0 @@ -goto: file://|DOC_PATH|/test_docs/index.html -// This test ensures that the correct font is applied on the modules listed items. - -// modules -assert-css: ("#modules + .item-table .item-left a", {"font-family": '"Fira Sans", Arial, sans-serif'}) -assert-css: ("#modules + .item-table .item-right.docblock-short", {"font-family": '"Source Serif 4", "Noto Sans KR", serif'}) -// structs -assert-css: ("#structs + .item-table .item-left a", {"font-family": '"Fira Sans", Arial, sans-serif'}) -assert-css: ("#structs + .item-table .item-right.docblock-short", {"font-family": '"Source Serif 4", "Noto Sans KR", serif'}) -// enums -assert-css: ("#enums + .item-table .item-left a", {"font-family": '"Fira Sans", Arial, sans-serif'}) -assert-css: ("#enums + .item-table .item-right.docblock-short", {"font-family": '"Source Serif 4", "Noto Sans KR", serif'}) -// traits -assert-css: ("#traits + .item-table .item-left a", {"font-family": '"Fira Sans", Arial, sans-serif'}) -assert-css: ("#traits + .item-table .item-right.docblock-short", {"font-family": '"Source Serif 4", "Noto Sans KR", serif'}) -// functions -assert-css: ("#functions + .item-table .item-left a", {"font-family": '"Fira Sans", Arial, sans-serif'}) -assert-css: ("#functions + .item-table .item-right.docblock-short", {"font-family": '"Source Serif 4", "Noto Sans KR", serif'}) -// keywords -assert-css: ("#keywords + .item-table .item-left a", {"font-family": '"Fira Sans", Arial, sans-serif'}) -assert-css: ("#keywords + .item-table .item-right.docblock-short", {"font-family": '"Source Serif 4", "Noto Sans KR", serif'}) diff --git a/src/test/rustdoc-gui/module-items-font.goml b/src/test/rustdoc-gui/module-items-font.goml index 817b148bee1a6..ab595d2801921 100644 --- a/src/test/rustdoc-gui/module-items-font.goml +++ b/src/test/rustdoc-gui/module-items-font.goml @@ -2,3 +2,22 @@ goto: file://|DOC_PATH|/test_docs/index.html assert-css: (".item-table .module-item a", {"font-family": '"Fira Sans", Arial, sans-serif'}, ALL) assert-css: (".item-table .docblock-short", {"font-family": '"Source Serif 4", "Noto Sans KR", serif'}, ALL) + +// modules +assert-css: ("#modules + .item-table .item-left a", {"font-family": '"Fira Sans", Arial, sans-serif'}) +assert-css: ("#modules + .item-table .item-right.docblock-short", {"font-family": '"Source Serif 4", "Noto Sans KR", serif'}) +// structs +assert-css: ("#structs + .item-table .item-left a", {"font-family": '"Fira Sans", Arial, sans-serif'}) +assert-css: ("#structs + .item-table .item-right.docblock-short", {"font-family": '"Source Serif 4", "Noto Sans KR", serif'}) +// enums +assert-css: ("#enums + .item-table .item-left a", {"font-family": '"Fira Sans", Arial, sans-serif'}) +assert-css: ("#enums + .item-table .item-right.docblock-short", {"font-family": '"Source Serif 4", "Noto Sans KR", serif'}) +// traits +assert-css: ("#traits + .item-table .item-left a", {"font-family": '"Fira Sans", Arial, sans-serif'}) +assert-css: ("#traits + .item-table .item-right.docblock-short", {"font-family": '"Source Serif 4", "Noto Sans KR", serif'}) +// functions +assert-css: ("#functions + .item-table .item-left a", {"font-family": '"Fira Sans", Arial, sans-serif'}) +assert-css: ("#functions + .item-table .item-right.docblock-short", {"font-family": '"Source Serif 4", "Noto Sans KR", serif'}) +// keywords +assert-css: ("#keywords + .item-table .item-left a", {"font-family": '"Fira Sans", Arial, sans-serif'}) +assert-css: ("#keywords + .item-table .item-right.docblock-short", {"font-family": '"Source Serif 4", "Noto Sans KR", serif'})