diff --git a/Cargo.lock b/Cargo.lock index a55ef7b61436e..0939f19cdfe20 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -58,20 +58,14 @@ dependencies = [ "url 2.1.1", ] -[[package]] -name = "annotate-snippets" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7021ce4924a3f25f802b2cccd1af585e39ea1a363a1aa2e72afe54b67a3a7a7" -dependencies = [ - "ansi_term 0.11.0", -] - [[package]] name = "annotate-snippets" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d78ea013094e5ea606b1c05fe35f1dd7ea1eb1ea259908d040b25bd5ec677ee5" +dependencies = [ + "yansi-term", +] [[package]] name = "ansi_term" @@ -103,12 +97,6 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f8cb5d814eb646a863c4f24978cff2880c4be96ad8cde2c0f0678732902e271" -[[package]] -name = "arrayvec" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" - [[package]] name = "arrayvec" version = "0.7.0" @@ -2856,9 +2844,9 @@ dependencies = [ [[package]] name = "racer" -version = "2.1.45" +version = "2.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15408926f6207643150e0fc2c54a75a689b192df03ac6c59d42ea99c6782c7f7" +checksum = "e7cbda48a9124ed2e83766d2c15e3725710d344abca35fad8cf52341a55883b1" dependencies = [ "bitflags", "clap", @@ -3221,9 +3209,9 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_arena" -version = "712.0.0" +version = "718.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "259cca0e975ecb05fd289ace45280c30ff792efc04e856a7f18b7fc86a3cb610" +checksum = "526610f47139efa440178239553b59ea805ff57a532b4e295c71d2a9b18fd676" dependencies = [ "rustc-ap-rustc_data_structures", "smallvec", @@ -3231,9 +3219,9 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_ast" -version = "712.0.0" +version = "718.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb9be435d50c88e94bbad6ea468c8680b52c5043bb298ab8058d05251717f8f8" +checksum = "cf6a9dda0804a7243b0282e3b75a8cf4654c7a61f033e587751941e1fe39391b" dependencies = [ "bitflags", "rustc-ap-rustc_data_structures", @@ -3246,69 +3234,33 @@ dependencies = [ "tracing", ] -[[package]] -name = "rustc-ap-rustc_ast_passes" -version = "712.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75246dd1a95a57f7767e53bde3971baa2d948078e180564709f5ea46cf863ddd" -dependencies = [ - "itertools 0.9.0", - "rustc-ap-rustc_ast", - "rustc-ap-rustc_ast_pretty", - "rustc-ap-rustc_attr", - "rustc-ap-rustc_data_structures", - "rustc-ap-rustc_errors", - "rustc-ap-rustc_feature", - "rustc-ap-rustc_parse", - "rustc-ap-rustc_session", - "rustc-ap-rustc_span", - "tracing", -] - [[package]] name = "rustc-ap-rustc_ast_pretty" -version = "712.0.0" +version = "718.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79bede0b44bed453fd0034b7ba492840391f6486bf3e17a1af12922f0b98d4cc" +checksum = "82f5019be8b41a58664169fd2f4b1a37fe82705681db394b76419e4e87d40ab1" dependencies = [ "rustc-ap-rustc_ast", "rustc-ap-rustc_span", "tracing", ] -[[package]] -name = "rustc-ap-rustc_attr" -version = "712.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a92a4a34b996694ca2dab70361c60d2d48c07adce57e8155b7ec75e069e3ea" -dependencies = [ - "rustc-ap-rustc_ast", - "rustc-ap-rustc_ast_pretty", - "rustc-ap-rustc_data_structures", - "rustc-ap-rustc_errors", - "rustc-ap-rustc_feature", - "rustc-ap-rustc_lexer", - "rustc-ap-rustc_macros", - "rustc-ap-rustc_serialize", - "rustc-ap-rustc_session", - "rustc-ap-rustc_span", -] - [[package]] name = "rustc-ap-rustc_data_structures" -version = "712.0.0" +version = "718.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cbfa7f82517a1b2efe7106c864c3f930b1da8aff07a27fd317af2f36522fd2e" +checksum = "a701717fb14549331085756b9741ae3b4bf35808489f1887d72c1d0e0fe52b77" dependencies = [ - "arrayvec 0.5.2", + "arrayvec", "bitflags", "cfg-if 0.1.10", - "crossbeam-utils 0.7.2", + "crossbeam-utils 0.8.3", "ena", "indexmap", "jobserver", "libc", "measureme", + "memmap2", "parking_lot", "rustc-ap-rustc_graphviz", "rustc-ap-rustc_index", @@ -3327,11 +3279,11 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_errors" -version = "712.0.0" +version = "718.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58a272a5101843bcb40900cc9ccf80ecfec62830bb1f4a242986da4a34c0da89" +checksum = "e3182ce85e8bfc96443475547f2f5aa2b5e67655d9b88721795f36f0ba9e265a" dependencies = [ - "annotate-snippets 0.8.0", + "annotate-snippets", "atty", "rustc-ap-rustc_data_structures", "rustc-ap-rustc_lint_defs", @@ -3345,35 +3297,11 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "rustc-ap-rustc_expand" -version = "712.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bc7988f3facf2402fe057405ef0f7fbacc7e7a483da25e35a35ac09491fbbfb" -dependencies = [ - "rustc-ap-rustc_ast", - "rustc-ap-rustc_ast_passes", - "rustc-ap-rustc_ast_pretty", - "rustc-ap-rustc_attr", - "rustc-ap-rustc_data_structures", - "rustc-ap-rustc_errors", - "rustc-ap-rustc_feature", - "rustc-ap-rustc_lexer", - "rustc-ap-rustc_lint_defs", - "rustc-ap-rustc_macros", - "rustc-ap-rustc_parse", - "rustc-ap-rustc_serialize", - "rustc-ap-rustc_session", - "rustc-ap-rustc_span", - "smallvec", - "tracing", -] - [[package]] name = "rustc-ap-rustc_feature" -version = "712.0.0" +version = "718.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e931cd1580ae60c5737d3fa57633034935e885414e794d83b3e52a81021985c" +checksum = "eed033b93270126ef60963c3ebbd0e026bf53b985172b6366c7b0e7881c9d507" dependencies = [ "rustc-ap-rustc_data_structures", "rustc-ap-rustc_span", @@ -3381,41 +3309,41 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_fs_util" -version = "712.0.0" +version = "718.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fe9422e10d5b441d2a78202667bc85d7cf713a087b9ae6cdea0dfc825d79f07" +checksum = "28ee6531986a205101e09fd143d7bf31897388f33b1814d4bcc45fd62211dca6" [[package]] name = "rustc-ap-rustc_graphviz" -version = "712.0.0" +version = "718.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffffffdef9fd51db69c1d4c045ced8aaab999be5627f2d3a0ce020d74c1f1e50" +checksum = "3398fddc0e23d2db89c036f8952ddf78cadc597f7059752116e69483e164a5b6" [[package]] name = "rustc-ap-rustc_index" -version = "712.0.0" +version = "718.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f6f53afc4f7111c82295cb7ea3878f520bbac6a2c5a12e125b4ca9156498cff" +checksum = "dca4e27eb5b701f6bbd47d8fc9d242378fca3e4107a519a28415c2989c4a3bd3" dependencies = [ - "arrayvec 0.5.2", + "arrayvec", "rustc-ap-rustc_macros", "rustc-ap-rustc_serialize", ] [[package]] name = "rustc-ap-rustc_lexer" -version = "712.0.0" +version = "718.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8056b05346dff7e39164d0434c6ec443a14ab5fbf6221bd1a56e5abbeae5f60c" +checksum = "786bbfe9d4d5264294c1819dbf1497a2480b583d5eda1ca9ae22e12d6661f5df" dependencies = [ "unicode-xid", ] [[package]] name = "rustc-ap-rustc_lint_defs" -version = "712.0.0" +version = "718.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "364c3fb7b3cbdfe3fbb21d4078ff2cb3c58df63cda27995f8b064d21ee6dede5" +checksum = "be2f045e2b999c154ec505d5fea69c994b742f3ebd2f552d11a6c81723921e47" dependencies = [ "rustc-ap-rustc_ast", "rustc-ap-rustc_data_structures", @@ -3428,9 +3356,9 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_macros" -version = "712.0.0" +version = "718.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4607d6879cae3bae4d0369ca4b3a7510fd6295ac32eec088ac975208ba96ca45" +checksum = "27789cd26d6b9e2fdfa68a262a20664d79ca67d31a3886d40fb88ebf6935869c" dependencies = [ "proc-macro2", "quote", @@ -3440,9 +3368,9 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_parse" -version = "712.0.0" +version = "718.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78d22889bff7ca2346037c9df7ea55c66ffb714f5b50fb62b41975f8ac7a2d70" +checksum = "1dc331f4958350679679e619d63a891e8d5d34ef99087068c89aa9e657d52caa" dependencies = [ "bitflags", "rustc-ap-rustc_ast", @@ -3460,9 +3388,9 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_serialize" -version = "712.0.0" +version = "718.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d33c710120953c0214f47a6caf42064d7e241003b4af36c98a6d6156e70335f1" +checksum = "e9a6824a462c4c1a379e911b0faf86d303a54bcf8673d4cc445195085966a4a4" dependencies = [ "indexmap", "smallvec", @@ -3470,9 +3398,9 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_session" -version = "712.0.0" +version = "718.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d35919041429a90713c8f704fa5209ba159cb554ce74d95722cbc18ac4b4c6f" +checksum = "a782a5f6ada0dbe089c6416ad0104f0b8a8bdb4bd26ea95e5fefaec67aed5e8a" dependencies = [ "bitflags", "getopts", @@ -3492,9 +3420,9 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_span" -version = "712.0.0" +version = "718.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73b12170c69603c0bf4b50e5c25fd348aae13b8c6465aa0ef4389c9eaa568e51" +checksum = "a257546cb264b250c7abdb81239bb02f18a274a966211755a3ea89411b122214" dependencies = [ "cfg-if 0.1.10", "md-5", @@ -3512,9 +3440,9 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_target" -version = "712.0.0" +version = "718.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a8329d92e7dc24b974f759e6c6e97e2bbc47b18d0573343028f8135ca367200" +checksum = "b5a72dd689421bcb5750f3ed0dedf367076e714ef0ba56c02ed391b9a8582862" dependencies = [ "bitflags", "rustc-ap-rustc_data_structures", @@ -3797,7 +3725,7 @@ dependencies = [ name = "rustc_data_structures" version = "0.0.0" dependencies = [ - "arrayvec 0.7.0", + "arrayvec", "bitflags", "cfg-if 0.1.10", "crossbeam-utils 0.8.3", @@ -3866,7 +3794,7 @@ version = "0.0.0" name = "rustc_errors" version = "0.0.0" dependencies = [ - "annotate-snippets 0.8.0", + "annotate-snippets", "atty", "rustc_data_structures", "rustc_lint_defs", @@ -3967,7 +3895,7 @@ dependencies = [ name = "rustc_index" version = "0.0.0" dependencies = [ - "arrayvec 0.7.0", + "arrayvec", "rustc_macros", "rustc_serialize", ] @@ -4563,7 +4491,7 @@ dependencies = [ name = "rustdoc" version = "0.0.0" dependencies = [ - "arrayvec 0.7.0", + "arrayvec", "expect-test", "itertools 0.9.0", "minifier", @@ -4625,7 +4553,7 @@ dependencies = [ name = "rustfmt-nightly" version = "1.4.37" dependencies = [ - "annotate-snippets 0.6.1", + "annotate-snippets", "anyhow", "bytecount", "cargo_metadata 0.8.2", @@ -4639,14 +4567,6 @@ dependencies = [ "lazy_static", "log", "regex", - "rustc-ap-rustc_ast", - "rustc-ap-rustc_ast_pretty", - "rustc-ap-rustc_data_structures", - "rustc-ap-rustc_errors", - "rustc-ap-rustc_expand", - "rustc-ap-rustc_parse", - "rustc-ap-rustc_session", - "rustc-ap-rustc_span", "rustc-workspace-hack", "rustfmt-config_proc_macro", "serde", @@ -5796,3 +5716,12 @@ checksum = "39f0c922f1a334134dc2f7a8b67dc5d25f0735263feec974345ff706bcf20b0d" dependencies = [ "linked-hash-map", ] + +[[package]] +name = "yansi-term" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe5c30ade05e61656247b2e334a031dfd0cc466fadef865bdcdea8d537951bf1" +dependencies = [ + "winapi 0.3.9", +] diff --git a/RELEASES.md b/RELEASES.md index 024610bc7a417..1f940e6bc2d3b 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,151 @@ +Version 1.52.0 (2021-05-06) +============================ + +Language +-------- +- [Added the `unsafe_op_in_unsafe_fn` lint, which checks whether the unsafe code + in an `unsafe fn` is wrapped in a `unsafe` block.][79208] This lint + is allowed by default, and may become a warning or hard error in a + future edition. +- [You can now cast mutable references to arrays to a pointer of the same type as + the element.][81479] + +Compiler +-------- +- [Upgraded the default LLVM to LLVM 12.][81451] + +Added tier 3\* support for the following targets. + +- [`s390x-unknown-linux-musl`][82166] +- [`riscv32gc-unknown-linux-musl` & `riscv64gc-unknown-linux-musl`][82202] +- [`powerpc-unknown-openbsd`][82733] + +\* Refer to Rust's [platform support page][platform-support-doc] for more +information on Rust's tiered platform support. + +Libraries +--------- +- [`OsString` now implements `Extend` and `FromIterator`.][82121] +- [`cmp::Reverse` now has `#[repr(transparent)]` representation.][81879] +- [`Arc` now implements `error::Error`.][80553] +- [All integer division and remainder operations are now `const`.][80962] + +Stabilised APIs +------------- +- [`Arguments::as_str`] +- [`char::MAX`] +- [`char::REPLACEMENT_CHARACTER`] +- [`char::UNICODE_VERSION`] +- [`char::decode_utf16`] +- [`char::from_digit`] +- [`char::from_u32_unchecked`] +- [`char::from_u32`] +- [`slice::partition_point`] +- [`str::rsplit_once`] +- [`str::split_once`] + +The following previously stable APIs are now `const`. + +- [`char::len_utf8`] +- [`char::len_utf16`] +- [`char::to_ascii_uppercase`] +- [`char::to_ascii_lowercase`] +- [`char::eq_ignore_ascii_case`] +- [`u8::to_ascii_uppercase`] +- [`u8::to_ascii_lowercase`] +- [`u8::eq_ignore_ascii_case`] + +Rustdoc +------- +- [Rustdoc lints are now treated as a tool lint, meaning that + lints are now prefixed with `rustdoc::` (e.g. `#[warn(rustdoc::non_autolinks)]`).][80527] + Using the old style is still allowed, and will become a warning in + a future release. +- [Rustdoc now supports argument files.][82261] +- [Rustdoc now generates smart punctuation for documentation.][79423] +- [You can now use "task lists" in Rustdoc Markdown.][81766] E.g. + ```markdown + - [x] Complete + - [ ] Todo + ``` + +Misc +---- +- [You can now pass multiple filters to tests.][81356] E.g. + `cargo test -- foo bar` will run all tests that match `foo` and `bar`. +- [Rustup now distributes PDB symbols for the `std` library on Windows, + allowing you to see `std` symbols when debugging.][82218] + +Internal Only +------------- +These changes provide no direct user facing benefits, but represent significant +improvements to the internals and overall performance of rustc and +related tools. + +- [Check the result cache before the DepGraph when ensuring queries][81855] +- [Try fast_reject::simplify_type in coherence before doing full check][81744] +- [Only store a LocalDefId in some HIR nodes][81611] +- [Store HIR attributes in a side table][79519] + +Compatibility Notes +------------------- +- [Cargo build scripts are now forbidden from setting `RUSTC_BOOTSTRAP`.][cargo/9181] +- [Removed support for the `x86_64-rumprun-netbsd` target.][82594] +- [Deprecated the `x86_64-sun-solaris` target in favor of `x86_64-pc-solaris`.][82216] +- [Rustdoc now only accepts `,`, ` `, and `\t` as delimiters for specifying + languages in code blocks.][78429] +- [Rustc now catches more cases of `pub_use_of_private_extern_crate`][80763] +- [Changes in how proc macros handle whitespace may lead to panics when used + with older `proc-macro-hack` versions. A `cargo update` should be sufficient to fix this in all cases.][84136] + +[84136]: https://github.com/rust-lang/rust/issues/84136 +[80763]: https://github.com/rust-lang/rust/pull/80763 +[82166]: https://github.com/rust-lang/rust/pull/82166 +[82121]: https://github.com/rust-lang/rust/pull/82121 +[81879]: https://github.com/rust-lang/rust/pull/81879 +[82261]: https://github.com/rust-lang/rust/pull/82261 +[82218]: https://github.com/rust-lang/rust/pull/82218 +[82216]: https://github.com/rust-lang/rust/pull/82216 +[82202]: https://github.com/rust-lang/rust/pull/82202 +[81855]: https://github.com/rust-lang/rust/pull/81855 +[81766]: https://github.com/rust-lang/rust/pull/81766 +[81744]: https://github.com/rust-lang/rust/pull/81744 +[81611]: https://github.com/rust-lang/rust/pull/81611 +[81479]: https://github.com/rust-lang/rust/pull/81479 +[81451]: https://github.com/rust-lang/rust/pull/81451 +[81356]: https://github.com/rust-lang/rust/pull/81356 +[80962]: https://github.com/rust-lang/rust/pull/80962 +[80553]: https://github.com/rust-lang/rust/pull/80553 +[80527]: https://github.com/rust-lang/rust/pull/80527 +[79519]: https://github.com/rust-lang/rust/pull/79519 +[79423]: https://github.com/rust-lang/rust/pull/79423 +[79208]: https://github.com/rust-lang/rust/pull/79208 +[78429]: https://github.com/rust-lang/rust/pull/78429 +[82733]: https://github.com/rust-lang/rust/pull/82733 +[82594]: https://github.com/rust-lang/rust/pull/82594 +[cargo/9181]: https://github.com/rust-lang/cargo/pull/9181 +[`char::MAX`]: https://doc.rust-lang.org/std/primitive.char.html#associatedconstant.MAX +[`char::REPLACEMENT_CHARACTER`]: https://doc.rust-lang.org/std/primitive.char.html#associatedconstant.REPLACEMENT_CHARACTER +[`char::UNICODE_VERSION`]: https://doc.rust-lang.org/std/primitive.char.html#associatedconstant.UNICODE_VERSION +[`char::decode_utf16`]: https://doc.rust-lang.org/std/primitive.char.html#method.decode_utf16 +[`char::from_u32`]: https://doc.rust-lang.org/std/primitive.char.html#method.from_u32 +[`char::from_u32_unchecked`]: https://doc.rust-lang.org/std/primitive.char.html#method.from_u32_unchecked +[`char::from_digit`]: https://doc.rust-lang.org/std/primitive.char.html#method.from_digit +[`Peekable::next_if`]: https://doc.rust-lang.org/stable/std/iter/struct.Peekable.html#method.next_if +[`Peekable::next_if_eq`]: https://doc.rust-lang.org/stable/std/iter/struct.Peekable.html#method.next_if_eq +[`Arguments::as_str`]: https://doc.rust-lang.org/stable/std/fmt/struct.Arguments.html#method.as_str +[`str::split_once`]: https://doc.rust-lang.org/stable/std/primitive.str.html#method.split_once +[`str::rsplit_once`]: https://doc.rust-lang.org/stable/std/primitive.str.html#method.rsplit_once +[`slice::partition_point`]: https://doc.rust-lang.org/stable/std/primitive.slice.html#method.partition_point +[`char::len_utf8`]: https://doc.rust-lang.org/stable/std/primitive.char.html#method.len_utf8 +[`char::len_utf16`]: https://doc.rust-lang.org/stable/std/primitive.char.html#method.len_utf16 +[`char::to_ascii_uppercase`]: https://doc.rust-lang.org/stable/std/primitive.char.html#method.to_ascii_uppercase +[`char::to_ascii_lowercase`]: https://doc.rust-lang.org/stable/std/primitive.char.html#method.to_ascii_lowercase +[`char::eq_ignore_ascii_case`]: https://doc.rust-lang.org/stable/std/primitive.char.html#method.eq_ignore_ascii_case +[`u8::to_ascii_uppercase`]: https://doc.rust-lang.org/stable/std/primitive.u8.html#method.to_ascii_uppercase +[`u8::to_ascii_lowercase`]: https://doc.rust-lang.org/stable/std/primitive.u8.html#method.to_ascii_lowercase +[`u8::eq_ignore_ascii_case`]: https://doc.rust-lang.org/stable/std/primitive.u8.html#method.eq_ignore_ascii_case + Version 1.51.0 (2021-03-25) ============================ diff --git a/compiler/rustc_codegen_ssa/src/lib.rs b/compiler/rustc_codegen_ssa/src/lib.rs index f0f45b067b352..b761bb4e193d3 100644 --- a/compiler/rustc_codegen_ssa/src/lib.rs +++ b/compiler/rustc_codegen_ssa/src/lib.rs @@ -1,5 +1,4 @@ #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] -#![feature(assert_matches)] #![feature(bool_to_option)] #![feature(box_patterns)] #![feature(drain_filter)] diff --git a/compiler/rustc_middle/src/ich/impls_syntax.rs b/compiler/rustc_middle/src/ich/impls_syntax.rs index b93b25d6b5c9a..f53992172beed 100644 --- a/compiler/rustc_middle/src/ich/impls_syntax.rs +++ b/compiler/rustc_middle/src/ich/impls_syntax.rs @@ -45,11 +45,7 @@ impl<'ctx> rustc_ast::HashStableContext for StableHashingContext<'ctx> { item.hash_stable(self, hasher); style.hash_stable(self, hasher); span.hash_stable(self, hasher); - assert_matches!( - tokens.as_ref(), - None, - "Tokens should have been removed during lowering!" - ); + assert!(tokens.as_ref().is_none(), "Tokens should have been removed during lowering!"); } else { unreachable!(); } diff --git a/compiler/rustc_middle/src/lib.rs b/compiler/rustc_middle/src/lib.rs index 45ea07a3db6b6..2ff271f3981f0 100644 --- a/compiler/rustc_middle/src/lib.rs +++ b/compiler/rustc_middle/src/lib.rs @@ -24,7 +24,6 @@ #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![feature(array_windows)] -#![feature(assert_matches)] #![feature(backtrace)] #![feature(bool_to_option)] #![feature(box_patterns)] diff --git a/compiler/rustc_middle/src/mir/interpret/allocation.rs b/compiler/rustc_middle/src/mir/interpret/allocation.rs index 766d6a06f7e59..898c375e9ae1a 100644 --- a/compiler/rustc_middle/src/mir/interpret/allocation.rs +++ b/compiler/rustc_middle/src/mir/interpret/allocation.rs @@ -339,7 +339,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra> Allocation { for dest in bytes { *dest = src.next().expect("iterator was shorter than it said it would be"); } - assert_matches!(src.next(), None, "iterator was longer than it said it would be"); + assert!(src.next().is_none(), "iterator was longer than it said it would be"); Ok(()) } diff --git a/compiler/rustc_mir/src/interpret/memory.rs b/compiler/rustc_mir/src/interpret/memory.rs index fe5ebf0b6fe97..3648748a90908 100644 --- a/compiler/rustc_mir/src/interpret/memory.rs +++ b/compiler/rustc_mir/src/interpret/memory.rs @@ -854,11 +854,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> { Some(ptr) => ptr, None => { // zero-sized access - assert_matches!( - src.next(), - None, - "iterator said it was empty but returned an element" - ); + assert!(src.next().is_none(), "iterator said it was empty but returned an element"); return Ok(()); } }; @@ -884,11 +880,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> { Some(ptr) => ptr, None => { // zero-sized access - assert_matches!( - src.next(), - None, - "iterator said it was empty but returned an element" - ); + assert!(src.next().is_none(), "iterator said it was empty but returned an element"); return Ok(()); } }; @@ -902,7 +894,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> { let offset_ptr = ptr.offset(Size::from_bytes(idx) * 2, &tcx)?; // `Size` multiplication allocation.write_scalar(&tcx, offset_ptr, val.into(), Size::from_bytes(2))?; } - assert_matches!(src.next(), None, "iterator was longer than it said it would be"); + assert!(src.next().is_none(), "iterator was longer than it said it would be"); Ok(()) } diff --git a/compiler/rustc_mir/src/lib.rs b/compiler/rustc_mir/src/lib.rs index 783aa9465c395..f9adc27116608 100644 --- a/compiler/rustc_mir/src/lib.rs +++ b/compiler/rustc_mir/src/lib.rs @@ -7,7 +7,6 @@ Rust MIR: a lowered representation of Rust. #![feature(nll)] #![feature(in_band_lifetimes)] #![feature(array_windows)] -#![feature(assert_matches)] #![feature(bindings_after_at)] #![feature(bool_to_option)] #![feature(box_patterns)] diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs index d32180525bf70..c671035bb7ba1 100644 --- a/compiler/rustc_passes/src/dead.rs +++ b/compiler/rustc_passes/src/dead.rs @@ -133,22 +133,6 @@ impl<'tcx> MarkSymbolVisitor<'tcx> { } } - fn handle_assign(&mut self, expr: &'tcx hir::Expr<'tcx>) { - if self - .typeck_results() - .expr_adjustments(expr) - .iter() - .any(|adj| matches!(adj.kind, ty::adjustment::Adjust::Deref(_))) - { - self.visit_expr(expr); - } else if let hir::ExprKind::Field(base, ..) = expr.kind { - // Ignore write to field - self.handle_assign(base); - } else { - self.visit_expr(expr); - } - } - fn handle_field_pattern_match( &mut self, lhs: &hir::Pat<'_>, @@ -277,11 +261,6 @@ impl<'tcx> Visitor<'tcx> for MarkSymbolVisitor<'tcx> { hir::ExprKind::MethodCall(..) => { self.lookup_and_handle_method(expr.hir_id); } - hir::ExprKind::Assign(ref left, ref right, ..) => { - self.handle_assign(left); - self.visit_expr(right); - return; - } hir::ExprKind::Field(ref lhs, ..) => { self.handle_field_access(&lhs, expr.hir_id); } diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs index 5d9b0f80d3a6f..66efa3c20b642 100644 --- a/library/core/src/macros/mod.rs +++ b/library/core/src/macros/mod.rs @@ -110,60 +110,6 @@ macro_rules! assert_ne { }); } -/// Asserts that an expression matches any of the given patterns. -/// -/// Like in a `match` expression, the pattern can be optionally followed by `if` -/// and a guard expression that has access to names bound by the pattern. -/// -/// On panic, this macro will print the value of the expression with its -/// debug representation. -/// -/// Like [`assert!`], this macro has a second form, where a custom -/// panic message can be provided. -/// -/// # Examples -/// -/// ``` -/// #![feature(assert_matches)] -/// -/// let a = 1u32.checked_add(2); -/// let b = 1u32.checked_sub(2); -/// assert_matches!(a, Some(_)); -/// assert_matches!(b, None); -/// -/// let c = Ok("abc".to_string()); -/// assert_matches!(c, Ok(x) | Err(x) if x.len() < 100); -/// ``` -#[macro_export] -#[unstable(feature = "assert_matches", issue = "82775")] -#[allow_internal_unstable(core_panic)] -macro_rules! assert_matches { - ($left:expr, $( $pattern:pat )|+ $( if $guard: expr )? $(,)?) => ({ - match $left { - $( $pattern )|+ $( if $guard )? => {} - ref left_val => { - $crate::panicking::assert_matches_failed( - left_val, - $crate::stringify!($($pattern)|+ $(if $guard)?), - $crate::option::Option::None - ); - } - } - }); - ($left:expr, $( $pattern:pat )|+ $( if $guard: expr )?, $($arg:tt)+) => ({ - match $left { - $( $pattern )|+ $( if $guard )? => {} - ref left_val => { - $crate::panicking::assert_matches_failed( - left_val, - $crate::stringify!($($pattern)|+ $(if $guard)?), - $crate::option::Option::Some($crate::format_args!($($arg)+)) - ); - } - } - }); -} - /// Asserts that a boolean expression is `true` at runtime. /// /// This will invoke the [`panic!`] macro if the provided expression cannot be @@ -262,42 +208,6 @@ macro_rules! debug_assert_ne { ($($arg:tt)*) => (if $crate::cfg!(debug_assertions) { $crate::assert_ne!($($arg)*); }) } -/// Asserts that an expression matches any of the given patterns. -/// -/// Like in a `match` expression, the pattern can be optionally followed by `if` -/// and a guard expression that has access to names bound by the pattern. -/// -/// On panic, this macro will print the value of the expression with its -/// debug representation. -/// -/// Unlike [`assert_matches!`], `debug_assert_matches!` statements are only -/// enabled in non optimized builds by default. An optimized build will not -/// execute `debug_assert_matches!` statements unless `-C debug-assertions` is -/// passed to the compiler. This makes `debug_assert_matches!` useful for -/// checks that are too expensive to be present in a release build but may be -/// helpful during development. The result of expanding `debug_assert_matches!` -/// is always type checked. -/// -/// # Examples -/// -/// ``` -/// #![feature(assert_matches)] -/// -/// let a = 1u32.checked_add(2); -/// let b = 1u32.checked_sub(2); -/// debug_assert_matches!(a, Some(_)); -/// debug_assert_matches!(b, None); -/// -/// let c = Ok("abc".to_string()); -/// debug_assert_matches!(c, Ok(x) | Err(x) if x.len() < 100); -/// ``` -#[macro_export] -#[unstable(feature = "assert_matches", issue = "82775")] -#[allow_internal_unstable(assert_matches)] -macro_rules! debug_assert_matches { - ($($arg:tt)*) => (if $crate::cfg!(debug_assertions) { $crate::assert_matches!($($arg)*); }) -} - /// Returns whether the given expression matches any of the given patterns. /// /// Like in a `match` expression, the pattern can be optionally followed by `if` diff --git a/library/core/src/panicking.rs b/library/core/src/panicking.rs index 3e3e96fcd7f78..35d9b2c5d267f 100644 --- a/library/core/src/panicking.rs +++ b/library/core/src/panicking.rs @@ -97,7 +97,6 @@ pub fn panic_fmt(fmt: fmt::Arguments<'_>) -> ! { pub enum AssertKind { Eq, Ne, - Match, } /// Internal function for `assert_eq!` and `assert_ne!` macros @@ -114,54 +113,32 @@ where T: fmt::Debug + ?Sized, U: fmt::Debug + ?Sized, { - assert_failed_inner(kind, &left, &right, args) -} - -/// Internal function for `assert_match!` -#[cold] -#[track_caller] -#[doc(hidden)] -pub fn assert_matches_failed( - left: &T, - right: &str, - args: Option>, -) -> ! { - // Use the Display implementation to display the pattern. - struct Pattern<'a>(&'a str); - impl fmt::Debug for Pattern<'_> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::Display::fmt(self.0, f) - } - } - assert_failed_inner(AssertKind::Match, &left, &Pattern(right), args); -} - -/// Non-generic version of the above functions, to avoid code bloat. -#[track_caller] -fn assert_failed_inner( - kind: AssertKind, - left: &dyn fmt::Debug, - right: &dyn fmt::Debug, - args: Option>, -) -> ! { - let op = match kind { - AssertKind::Eq => "==", - AssertKind::Ne => "!=", - AssertKind::Match => "matches", - }; - - match args { - Some(args) => panic!( - r#"assertion failed: `(left {} right)` + #[track_caller] + fn inner( + kind: AssertKind, + left: &dyn fmt::Debug, + right: &dyn fmt::Debug, + args: Option>, + ) -> ! { + let op = match kind { + AssertKind::Eq => "==", + AssertKind::Ne => "!=", + }; + + match args { + Some(args) => panic!( + r#"assertion failed: `(left {} right)` left: `{:?}`, right: `{:?}`: {}"#, - op, left, right, args - ), - None => panic!( - r#"assertion failed: `(left {} right)` + op, left, right, args + ), + None => panic!( + r#"assertion failed: `(left {} right)` left: `{:?}`, right: `{:?}`"#, - op, left, right, - ), + op, left, right, + ), + } } + inner(kind, &left, &right, args) } diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 0ab9f490fd420..1b764d5a6994e 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -230,7 +230,6 @@ #![feature(arbitrary_self_types)] #![feature(array_error_internals)] #![feature(asm)] -#![feature(assert_matches)] #![feature(associated_type_bounds)] #![feature(atomic_mut_ptr)] #![feature(bench_black_box)] @@ -557,8 +556,8 @@ pub use std_detect::{ #[stable(feature = "rust1", since = "1.0.0")] #[allow(deprecated, deprecated_in_future)] pub use core::{ - assert_eq, assert_matches, assert_ne, debug_assert, debug_assert_eq, debug_assert_matches, - debug_assert_ne, matches, r#try, todo, unimplemented, unreachable, write, writeln, + assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, matches, r#try, todo, + unimplemented, unreachable, write, writeln, }; // Re-export built-in macros defined through libcore. diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index aee3c8324bc11..8224eac823b18 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -1029,7 +1029,13 @@ impl Step for Rls { let rls = builder .ensure(tool::Rls { compiler, target, extra_features: Vec::new() }) .or_else(|| { - missing_tool("RLS", builder.build.config.missing_tools); + // We ignore failure on aarch64 Windows because RLS currently + // fails to build, due to winapi 0.2 not supporting aarch64. + missing_tool( + "RLS", + builder.build.config.missing_tools + || (target.triple.contains("aarch64") && target.triple.contains("windows")), + ); None })?; diff --git a/src/ci/run.sh b/src/ci/run.sh index 1958b6ee41d7f..02d868f8f2a37 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -68,7 +68,7 @@ fi # # FIXME: need a scheme for changing this `nightly` value to `beta` and `stable` # either automatically or manually. -export RUST_RELEASE_CHANNEL=nightly +export RUST_RELEASE_CHANNEL=beta # Always set the release channel for bootstrap; this is normally not important (i.e., only dist # builds would seem to matter) but in practice bootstrap wants to know whether we're targeting diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 5e47144588b3f..ad4a09d45f30a 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -393,10 +393,9 @@ impl Item { Some(&(_, _, ExternalLocation::Remote(ref s))) => { format!("{}/std/", s.trim_end_matches('/')) } - Some(&(_, _, ExternalLocation::Unknown)) | None => format!( - "https://doc.rust-lang.org/{}/std/", - crate::doc_rust_lang_org_channel(), - ), + Some(&(_, _, ExternalLocation::Unknown)) | None => { + "https://doc.rust-lang.org/nightly/std/".to_string() + } }; // This is a primitive so the url is done "by hand". let tail = fragment.find('#').unwrap_or_else(|| fragment.len()); diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index 7df8b442e5acc..b5953d2dc48a9 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -525,14 +525,3 @@ crate fn has_doc_flag(attrs: ty::Attributes<'_>, flag: Symbol) -> bool { && attr.meta_item_list().map_or(false, |l| rustc_attr::list_contains_name(&l, flag)) }) } - -/// Return a channel suitable for using in a `doc.rust-lang.org/{channel}` format string. -crate fn doc_rust_lang_org_channel() -> &'static str { - match env!("CFG_RELEASE_CHANNEL") { - "stable" => env!("CFG_RELEASE_NUM"), - "beta" => "beta", - "nightly" | "dev" => "nightly", - // custom build of rustdoc maybe? link to the stable docs just in case - _ => "", - } -} diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 212aac0e5b43c..1ec4757a9113e 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -450,18 +450,15 @@ crate fn run_global_ctxt( let mut krate = tcx.sess.time("clean_crate", || clean::krate(&mut ctxt)); if krate.module.doc_value().map(|d| d.is_empty()).unwrap_or(true) { - let help = format!( - "The following guide may be of use:\n\ - https://doc.rust-lang.org/{}/rustdoc/how-to-write-documentation.html", - crate::doc_rust_lang_org_channel(), - ); + let help = "The following guide may be of use:\n\ + https://doc.rust-lang.org/nightly/rustdoc/how-to-write-documentation.html"; tcx.struct_lint_node( crate::lint::MISSING_CRATE_LEVEL_DOCS, DocContext::as_local_hir_id(tcx, krate.module.def_id).unwrap(), |lint| { let mut diag = lint.build("no documentation found for this crate's top-level module"); - diag.help(&help); + diag.help(help); diag.emit(); }, ); diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs index 4c8ba0e7b496e..7cb7e070f7041 100644 --- a/src/librustdoc/html/render/context.rs +++ b/src/librustdoc/html/render/context.rs @@ -6,7 +6,7 @@ use std::rc::Rc; use std::sync::mpsc::{channel, Receiver}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; -use rustc_hir::def_id::{DefId, LOCAL_CRATE}; +use rustc_hir::def_id::LOCAL_CRATE; use rustc_middle::ty::TyCtxt; use rustc_session::Session; use rustc_span::edition::Edition; @@ -50,9 +50,6 @@ crate struct Context<'tcx> { pub(super) render_redirect_pages: bool, /// The map used to ensure all generated 'id=' attributes are unique. pub(super) id_map: RefCell, - /// Tracks section IDs for `Deref` targets so they match in both the main - /// body and the sidebar. - pub(super) deref_id_map: RefCell>, /// Shared mutable state. /// /// Issue for improving the situation: [#82381][] @@ -73,7 +70,7 @@ crate struct Context<'tcx> { // `Context` is cloned a lot, so we don't want the size to grow unexpectedly. #[cfg(target_arch = "x86_64")] -rustc_data_structures::static_assert_size!(Context<'_>, 152); +rustc_data_structures::static_assert_size!(Context<'_>, 112); /// Shared mutable state used in [`Context`] and elsewhere. crate struct SharedContext<'tcx> { @@ -470,7 +467,6 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> { dst, render_redirect_pages: false, id_map: RefCell::new(id_map), - deref_id_map: RefCell::new(FxHashMap::default()), shared: Rc::new(scx), cache: Rc::new(cache), }; @@ -488,7 +484,6 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> { dst: self.dst.clone(), render_redirect_pages: self.render_redirect_pages, id_map: RefCell::new(IdMap::new()), - deref_id_map: RefCell::new(FxHashMap::default()), shared: Rc::clone(&self.shared), cache: Rc::clone(&self.cache), } diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 7de72d8198725..15ce3740e05d4 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -1034,17 +1034,12 @@ fn render_assoc_items( RenderMode::Normal } AssocItemRender::DerefFor { trait_, type_, deref_mut_ } => { - let id = - cx.derive_id(small_url_encode(format!("deref-methods-{:#}", type_.print(cx)))); - debug!("Adding {} to deref id map", type_.print(cx)); - cx.deref_id_map.borrow_mut().insert(type_.def_id_full(cache).unwrap(), id.clone()); write!( w, - "

\ + "

\ Methods from {trait_}<Target = {type_}>\ - \ + \

", - id = id, trait_ = trait_.print(cx), type_ = type_.print(cx), ); @@ -1069,6 +1064,9 @@ fn render_assoc_items( ); } } + if let AssocItemRender::DerefFor { .. } = what { + return; + } if !traits.is_empty() { let deref_impl = traits .iter() @@ -1079,13 +1077,6 @@ fn render_assoc_items( .any(|t| t.inner_impl().trait_.def_id_full(cache) == cx.cache.deref_mut_trait_did); render_deref_methods(w, cx, impl_, containing_item, has_deref_mut); } - - // If we were already one level into rendering deref methods, we don't want to render - // anything after recursing into any further deref methods above. - if let AssocItemRender::DerefFor { .. } = what { - return; - } - let (synthetic, concrete): (Vec<&&Impl>, Vec<&&Impl>) = traits.iter().partition(|t| t.inner_impl().synthetic); let (blanket_impl, concrete): (Vec<&&Impl>, _) = @@ -1967,14 +1958,9 @@ fn sidebar_deref_methods(cx: &Context<'_>, out: &mut Buffer, impl_: &Impl, v: &V .flat_map(|i| get_methods(i.inner_impl(), true, &mut used_links, deref_mut, c)) .collect::>(); if !ret.is_empty() { - let deref_id_map = cx.deref_id_map.borrow(); - let id = deref_id_map - .get(&real_target.def_id_full(c).unwrap()) - .expect("Deref section without derived id"); write!( out, - "Methods from {}<Target={}>", - id, + "Methods from {}<Target={}>", Escape(&format!("{:#}", impl_.inner_impl().trait_.as_ref().unwrap().print(cx))), Escape(&format!("{:#}", real_target.print(cx))), ); diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 985aeedabb106..943e2961d3b43 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -82,8 +82,6 @@ use rustc_session::config::{make_crate_type_option, ErrorOutputType, RustcOptGro use rustc_session::getopts; use rustc_session::{early_error, early_warn}; -use crate::clean::utils::doc_rust_lang_org_channel; - /// A macro to create a FxHashMap. /// /// Example: @@ -605,10 +603,7 @@ fn usage(argv0: &str) { } println!("{}", options.usage(&format!("{} [options] ", argv0))); println!(" @path Read newline separated options from `path`\n"); - println!( - "More information available at https://doc.rust-lang.org/{}/rustdoc/what-is-rustdoc.html", - doc_rust_lang_org_channel() - ); + println!("More information available at https://doc.rust-lang.org/rustdoc/what-is-rustdoc.html") } /// A result type used by several functions under `main()`. diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index f1064756fdde7..aeaceeefc08a1 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -1993,14 +1993,7 @@ fn disambiguator_error( msg: &str, ) { diag_info.link_range = disambiguator_range; - report_diagnostic(cx.tcx, BROKEN_INTRA_DOC_LINKS, msg, &diag_info, |diag, _sp| { - let msg = format!( - "see https://doc.rust-lang.org/{}/rustdoc/linking-to-items-by-name.html#namespaces-and-disambiguators \ - for more info about disambiguators", - crate::doc_rust_lang_org_channel(), - ); - diag.note(&msg); - }); + report_diagnostic(cx.tcx, BROKEN_INTRA_DOC_LINKS, msg, &diag_info, |_diag, _sp| {}); } /// Report an ambiguity error, where there were multiple possible resolutions. diff --git a/src/librustdoc/passes/collect_trait_impls.rs b/src/librustdoc/passes/collect_trait_impls.rs index 7b0b2f28fdfff..12f16c9359235 100644 --- a/src/librustdoc/passes/collect_trait_impls.rs +++ b/src/librustdoc/passes/collect_trait_impls.rs @@ -3,7 +3,7 @@ use crate::clean::*; use crate::core::DocContext; use crate::fold::DocFolder; -use rustc_data_structures::fx::{FxHashMap, FxHashSet}; +use rustc_data_structures::fx::FxHashSet; use rustc_hir::def_id::{DefId, LOCAL_CRATE}; use rustc_middle::ty::DefIdTree; use rustc_span::symbol::sym; @@ -53,6 +53,39 @@ crate fn collect_trait_impls(krate: Crate, cx: &mut DocContext<'_>) -> Crate { } } + let mut cleaner = BadImplStripper { prims, items: crate_items }; + + // scan through included items ahead of time to splice in Deref targets to the "valid" sets + for it in &new_items { + if let ImplItem(Impl { ref for_, ref trait_, ref items, .. }) = *it.kind { + if cleaner.keep_impl(for_) && trait_.def_id() == cx.tcx.lang_items().deref_trait() { + let target = items + .iter() + .find_map(|item| match *item.kind { + TypedefItem(ref t, true) => Some(&t.type_), + _ => None, + }) + .expect("Deref impl without Target type"); + + if let Some(prim) = target.primitive_type() { + cleaner.prims.insert(prim); + } else if let Some(did) = target.def_id() { + cleaner.items.insert(did); + } + } + } + } + + new_items.retain(|it| { + if let ImplItem(Impl { ref for_, ref trait_, ref blanket_impl, .. }) = *it.kind { + cleaner.keep_impl(for_) + || trait_.as_ref().map_or(false, |t| cleaner.keep_impl(t)) + || blanket_impl.is_some() + } else { + true + } + }); + // `tcx.crates()` doesn't include the local crate, and `tcx.all_trait_implementations` // doesn't work with it anyway, so pull them from the HIR map instead let mut extra_attrs = Vec::new(); @@ -84,53 +117,6 @@ crate fn collect_trait_impls(krate: Crate, cx: &mut DocContext<'_>) -> Crate { } } - let mut cleaner = BadImplStripper { prims, items: crate_items }; - - let mut type_did_to_deref_target: FxHashMap = FxHashMap::default(); - // Gather all type to `Deref` target edges. - for it in &new_items { - if let ImplItem(Impl { ref for_, ref trait_, ref items, .. }) = *it.kind { - if trait_.def_id() == cx.tcx.lang_items().deref_trait() { - let target = items.iter().find_map(|item| match *item.kind { - TypedefItem(ref t, true) => Some(&t.type_), - _ => None, - }); - if let (Some(for_did), Some(target)) = (for_.def_id(), target) { - type_did_to_deref_target.insert(for_did, target); - } - } - } - } - // Follow all `Deref` targets of included items and recursively add them as valid - fn add_deref_target( - map: &FxHashMap, - cleaner: &mut BadImplStripper, - type_did: &DefId, - ) { - if let Some(target) = map.get(type_did) { - debug!("add_deref_target: type {:?}, target {:?}", type_did, target); - if let Some(target_prim) = target.primitive_type() { - cleaner.prims.insert(target_prim); - } else if let Some(target_did) = target.def_id() { - // `impl Deref for S` - if target_did == *type_did { - // Avoid infinite cycles - return; - } - cleaner.items.insert(target_did); - add_deref_target(map, cleaner, &target_did); - } - } - } - for type_did in type_did_to_deref_target.keys() { - // Since only the `DefId` portion of the `Type` instances is known to be same for both the - // `Deref` target type and the impl for type positions, this map of types is keyed by - // `DefId` and for convenience uses a special cleaner that accepts `DefId`s directly. - if cleaner.keep_impl_with_def_id(type_did) { - add_deref_target(&type_did_to_deref_target, &mut cleaner, type_did); - } - } - let items = if let ModuleItem(Module { ref mut items, .. }) = *krate.module.kind { items } else { @@ -138,19 +124,7 @@ crate fn collect_trait_impls(krate: Crate, cx: &mut DocContext<'_>) -> Crate { }; items.extend(synth_impls); - for it in new_items.drain(..) { - if let ImplItem(Impl { ref for_, ref trait_, ref blanket_impl, .. }) = *it.kind { - if !(cleaner.keep_impl(for_) - || trait_.as_ref().map_or(false, |t| cleaner.keep_impl(t)) - || blanket_impl.is_some()) - { - continue; - } - } - - items.push(it); - } - + items.extend(new_items); krate } @@ -204,13 +178,9 @@ impl BadImplStripper { } else if let Some(prim) = ty.primitive_type() { self.prims.contains(&prim) } else if let Some(did) = ty.def_id() { - self.keep_impl_with_def_id(&did) + self.items.contains(&did) } else { false } } - - fn keep_impl_with_def_id(&self, did: &DefId) -> bool { - self.items.contains(did) - } } diff --git a/src/stage0.txt b/src/stage0.txt index 6ad0f6db42b9f..3a76177474908 100644 --- a/src/stage0.txt +++ b/src/stage0.txt @@ -12,14 +12,14 @@ # stable release's version number. `date` is the date where the release we're # bootstrapping off was released. -date: 2021-04-07 -rustc: beta +date: 2021-05-04 +rustc: 1.52.0 # We use a nightly rustfmt to format the source because it solves some # bootstrapping issues with use of new syntax in this repo. If you're looking at # the beta/stable branch, this key should be omitted, as we don't want to depend # on rustfmt from nightly there. -rustfmt: nightly-2021-03-25 +#rustfmt: nightly-2021-03-25 # When making a stable release the process currently looks like: # @@ -39,4 +39,4 @@ rustfmt: nightly-2021-03-25 # looking at a beta source tarball and it's uncommented we'll shortly comment it # out. -#dev: 1 +dev: 1 diff --git a/src/test/rustdoc-ui/deref-recursive-cycle.rs b/src/test/rustdoc-ui/deref-recursive-cycle.rs deleted file mode 100644 index 4cb518cbbbd5c..0000000000000 --- a/src/test/rustdoc-ui/deref-recursive-cycle.rs +++ /dev/null @@ -1,17 +0,0 @@ -// check-pass -// #26207: Ensure `Deref` cycles are properly handled without errors. - -#[derive(Copy, Clone)] -struct S; - -impl std::ops::Deref for S { - type Target = S; - - fn deref(&self) -> &S { - self - } -} - -fn main() { - let s: S = *******S; -} diff --git a/src/test/rustdoc-ui/intra-doc/email-address-localhost.stderr b/src/test/rustdoc-ui/intra-doc/email-address-localhost.stderr index f287f87408c48..de215b2163bd4 100644 --- a/src/test/rustdoc-ui/intra-doc/email-address-localhost.stderr +++ b/src/test/rustdoc-ui/intra-doc/email-address-localhost.stderr @@ -10,7 +10,6 @@ note: the lint level is defined here LL | #![deny(warnings)] | ^^^^^^^^ = note: `#[deny(rustdoc::broken_intra_doc_links)]` implied by `#[deny(warnings)]` - = note: see https://doc.rust-lang.org/nightly/rustdoc/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators error: aborting due to previous error diff --git a/src/test/rustdoc-ui/intra-doc/unknown-disambiguator.stderr b/src/test/rustdoc-ui/intra-doc/unknown-disambiguator.stderr index 94d6d4616518e..195aaca32a27d 100644 --- a/src/test/rustdoc-ui/intra-doc/unknown-disambiguator.stderr +++ b/src/test/rustdoc-ui/intra-doc/unknown-disambiguator.stderr @@ -10,47 +10,36 @@ note: the lint level is defined here LL | #![deny(warnings)] | ^^^^^^^^ = note: `#[deny(rustdoc::broken_intra_doc_links)]` implied by `#[deny(warnings)]` - = note: see https://doc.rust-lang.org/nightly/rustdoc/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators error: unknown disambiguator `bar` --> $DIR/unknown-disambiguator.rs:3:35 | LL | //! Linking to [foo@banana] and [`bar@banana!()`]. | ^^^ - | - = note: see https://doc.rust-lang.org/nightly/rustdoc/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators error: unknown disambiguator `foo` --> $DIR/unknown-disambiguator.rs:9:34 | LL | //! And with weird backticks: [``foo@hello``] [foo`@`hello]. | ^^^ - | - = note: see https://doc.rust-lang.org/nightly/rustdoc/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators error: unknown disambiguator `foo` --> $DIR/unknown-disambiguator.rs:9:48 | LL | //! And with weird backticks: [``foo@hello``] [foo`@`hello]. | ^^^ - | - = note: see https://doc.rust-lang.org/nightly/rustdoc/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators error: unknown disambiguator `` --> $DIR/unknown-disambiguator.rs:6:31 | LL | //! And to [no disambiguator](@nectarine) and [another](@apricot!()). | ^ - | - = note: see https://doc.rust-lang.org/nightly/rustdoc/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators error: unknown disambiguator `` --> $DIR/unknown-disambiguator.rs:6:57 | LL | //! And to [no disambiguator](@nectarine) and [another](@apricot!()). | ^ - | - = note: see https://doc.rust-lang.org/nightly/rustdoc/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators error: aborting due to 6 previous errors diff --git a/src/test/rustdoc/deref-recursive-pathbuf.rs b/src/test/rustdoc/deref-recursive-pathbuf.rs deleted file mode 100644 index 459a30060c623..0000000000000 --- a/src/test/rustdoc/deref-recursive-pathbuf.rs +++ /dev/null @@ -1,24 +0,0 @@ -// #26207: Show all methods reachable via Deref impls, recursing through multiple dereferencing -// levels and across multiple crates. - -// @has 'foo/struct.Foo.html' -// @has '-' '//*[@id="deref-methods-PathBuf"]' 'Methods from Deref' -// @has '-' '//*[@class="impl-items"]//*[@id="method.as_path"]' 'pub fn as_path(&self)' -// @has '-' '//*[@id="deref-methods-Path"]' 'Methods from Deref' -// @has '-' '//*[@class="impl-items"]//*[@id="method.exists"]' 'pub fn exists(&self)' -// @has '-' '//*[@class="sidebar-title"][@href="#deref-methods-PathBuf"]' 'Methods from Deref' -// @has '-' '//*[@class="sidebar-links"]/a[@href="#method.as_path"]' 'as_path' -// @has '-' '//*[@class="sidebar-title"][@href="#deref-methods-Path"]' 'Methods from Deref' -// @has '-' '//*[@class="sidebar-links"]/a[@href="#method.exists"]' 'exists' - -#![crate_name = "foo"] - -use std::ops::Deref; -use std::path::PathBuf; - -pub struct Foo(PathBuf); - -impl Deref for Foo { - type Target = PathBuf; - fn deref(&self) -> &PathBuf { &self.0 } -} diff --git a/src/test/rustdoc/deref-recursive.rs b/src/test/rustdoc/deref-recursive.rs deleted file mode 100644 index b96b5397ad78b..0000000000000 --- a/src/test/rustdoc/deref-recursive.rs +++ /dev/null @@ -1,40 +0,0 @@ -// #26207: Show all methods reachable via Deref impls, recursing through multiple dereferencing -// levels if needed. - -// @has 'foo/struct.Foo.html' -// @has '-' '//*[@id="deref-methods-Bar"]' 'Methods from Deref' -// @has '-' '//*[@class="impl-items"]//*[@id="method.bar"]' 'pub fn bar(&self)' -// @has '-' '//*[@id="deref-methods-Baz"]' 'Methods from Deref' -// @has '-' '//*[@class="impl-items"]//*[@id="method.baz"]' 'pub fn baz(&self)' -// @has '-' '//*[@class="sidebar-title"][@href="#deref-methods-Bar"]' 'Methods from Deref' -// @has '-' '//*[@class="sidebar-links"]/a[@href="#method.bar"]' 'bar' -// @has '-' '//*[@class="sidebar-title"][@href="#deref-methods-Baz"]' 'Methods from Deref' -// @has '-' '//*[@class="sidebar-links"]/a[@href="#method.baz"]' 'baz' - -#![crate_name = "foo"] - -use std::ops::Deref; - -pub struct Foo(Bar); -pub struct Bar(Baz); -pub struct Baz; - -impl Deref for Foo { - type Target = Bar; - fn deref(&self) -> &Bar { &self.0 } -} - -impl Deref for Bar { - type Target = Baz; - fn deref(&self) -> &Baz { &self.0 } -} - -impl Bar { - /// This appears under `Foo` methods - pub fn bar(&self) {} -} - -impl Baz { - /// This should also appear in `Foo` methods when recursing - pub fn baz(&self) {} -} diff --git a/src/test/rustdoc/deref-typedef.rs b/src/test/rustdoc/deref-typedef.rs index 47009559e6f74..3fc48b46d7410 100644 --- a/src/test/rustdoc/deref-typedef.rs +++ b/src/test/rustdoc/deref-typedef.rs @@ -1,12 +1,12 @@ #![crate_name = "foo"] // @has 'foo/struct.Bar.html' -// @has '-' '//*[@id="deref-methods-FooJ"]' 'Methods from Deref' +// @has '-' '//*[@id="deref-methods"]' 'Methods from Deref' // @has '-' '//*[@class="impl-items"]//*[@id="method.foo_a"]' 'pub fn foo_a(&self)' // @has '-' '//*[@class="impl-items"]//*[@id="method.foo_b"]' 'pub fn foo_b(&self)' // @has '-' '//*[@class="impl-items"]//*[@id="method.foo_c"]' 'pub fn foo_c(&self)' // @has '-' '//*[@class="impl-items"]//*[@id="method.foo_j"]' 'pub fn foo_j(&self)' -// @has '-' '//*[@class="sidebar-title"][@href="#deref-methods-FooJ"]' 'Methods from Deref' +// @has '-' '//*[@class="sidebar-title"][@href="#deref-methods"]' 'Methods from Deref' // @has '-' '//*[@class="sidebar-links"]/a[@href="#method.foo_a"]' 'foo_a' // @has '-' '//*[@class="sidebar-links"]/a[@href="#method.foo_b"]' 'foo_b' // @has '-' '//*[@class="sidebar-links"]/a[@href="#method.foo_c"]' 'foo_c' diff --git a/src/test/rustdoc/issue-82465-asref-for-and-of-local.rs b/src/test/rustdoc/issue-82465-asref-for-and-of-local.rs new file mode 100644 index 0000000000000..618ac20ac487d --- /dev/null +++ b/src/test/rustdoc/issue-82465-asref-for-and-of-local.rs @@ -0,0 +1,16 @@ +use std::convert::AsRef; +pub struct Local; + +// @has issue_82465_asref_for_and_of_local/struct.Local.html '//code' 'impl AsRef for Local' +impl AsRef for Local { + fn as_ref(&self) -> &str { + todo!() + } +} + +// @has - '//code' 'impl AsRef for str' +impl AsRef for str { + fn as_ref(&self) -> &Local { + todo!() + } +} diff --git a/src/test/ui-fulldeps/session-derive-errors.stderr b/src/test/ui-fulldeps/session-derive-errors.stderr index c1be151f1c1ce..303268fae27a1 100644 --- a/src/test/ui-fulldeps/session-derive-errors.stderr +++ b/src/test/ui-fulldeps/session-derive-errors.stderr @@ -1,25 +1,20 @@ error: `#[derive(SessionDiagnostic)]` can only be used on structs --> $DIR/session-derive-errors.rs:28:1 | -LL | / #[error = "E0123"] -LL | | -LL | | enum SessionDiagnosticOnEnum { -LL | | Foo, -LL | | Bar, -LL | | } - | |_^ +LL | #[error = "E0123"] + | ^ error: `#[label = ...]` is not a valid SessionDiagnostic struct attribute --> $DIR/session-derive-errors.rs:37:1 | LL | #[label = "This is in the wrong place"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ error: `#[suggestion = ...]` is not a valid SessionDiagnostic field attribute --> $DIR/session-derive-errors.rs:44:5 | LL | #[suggestion = "this is the wrong kind of attribute"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ error: `error` specified multiple times --> $DIR/session-derive-errors.rs:52:11 @@ -37,7 +32,7 @@ error: `code` not specified --> $DIR/session-derive-errors.rs:67:1 | LL | struct ErrorCodeNotProvided {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^ | = help: use the [code = "..."] attribute to set this diagnostic's error code @@ -45,13 +40,13 @@ error: the `#[message = "..."]` attribute can only be applied to fields of type --> $DIR/session-derive-errors.rs:95:5 | LL | #[message = "this message is applied to a String field"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ error: `name` doesn't refer to a field on this type --> $DIR/session-derive-errors.rs:102:1 | LL | #[message = "This error has a field, and references {name}"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ error: invalid format string: expected `'}'` but string was terminated --> $DIR/session-derive-errors.rs:110:1 @@ -77,59 +72,53 @@ error: The `#[label = ...]` attribute can only be applied to fields of type Span --> $DIR/session-derive-errors.rs:138:5 | LL | #[label = "See here"] - | ^^^^^^^^^^^^^^^^^^^^^ + | ^ error: `nonsense` is not a valid key for `#[suggestion(...)]` --> $DIR/session-derive-errors.rs:163:18 | LL | #[suggestion(nonsense = "This is nonsense")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^ error: `msg` is not a valid key for `#[suggestion(...)]` --> $DIR/session-derive-errors.rs:171:18 | LL | #[suggestion(msg = "This is a suggestion")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^ error: missing suggestion message --> $DIR/session-derive-errors.rs:179:7 | LL | #[suggestion(code = "This is suggested code")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^ | = help: provide a suggestion message using #[suggestion(message = "...")] error: wrong field type for suggestion --> $DIR/session-derive-errors.rs:194:5 | -LL | / #[suggestion(message = "This is a message", code = "This is suggested code")] -LL | | -LL | | suggestion: Applicability, - | |_____________________________^ +LL | #[suggestion(message = "This is a message", code = "This is suggested code")] + | ^ | = help: #[suggestion(...)] should be applied to fields of type Span or (Span, Applicability) error: type of field annotated with `#[suggestion(...)]` contains more than one Span --> $DIR/session-derive-errors.rs:209:5 | -LL | / #[suggestion(message = "This is a message", code = "This is suggested code")] -LL | | -LL | | suggestion: (Span, Span, Applicability), - | |___________________________________________^ +LL | #[suggestion(message = "This is a message", code = "This is suggested code")] + | ^ error: type of field annotated with `#[suggestion(...)]` contains more than one Applicability --> $DIR/session-derive-errors.rs:217:5 | -LL | / #[suggestion(message = "This is a message", code = "This is suggested code")] -LL | | -LL | | suggestion: (Applicability, Applicability, Span), - | |____________________________________________________^ +LL | #[suggestion(message = "This is a message", code = "This is suggested code")] + | ^ error: invalid annotation list `#[label(...)]` --> $DIR/session-derive-errors.rs:225:7 | LL | #[label("wrong kind of annotation for label")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^ error: aborting due to 18 previous errors diff --git a/src/test/ui/borrowck/borrowck-assign-to-subfield.rs b/src/test/ui/borrowck/borrowck-assign-to-subfield.rs index dfa3a561ec7ee..050d702b625ab 100644 --- a/src/test/ui/borrowck/borrowck-assign-to-subfield.rs +++ b/src/test/ui/borrowck/borrowck-assign-to-subfield.rs @@ -1,6 +1,5 @@ // run-pass // pretty-expanded FIXME #23616 -#![allow(dead_code)] pub fn main() { struct A { diff --git a/src/test/ui/lint/dead-code/write-only-field.rs b/src/test/ui/lint/dead-code/write-only-field.rs deleted file mode 100644 index 7b3f1e9f5b6cb..0000000000000 --- a/src/test/ui/lint/dead-code/write-only-field.rs +++ /dev/null @@ -1,69 +0,0 @@ -#![deny(dead_code)] - -struct S { - f: i32, //~ ERROR: field is never read - sub: Sub, //~ ERROR: field is never read -} - -struct Sub { - f: i32, //~ ERROR: field is never read -} - -fn field_write(s: &mut S) { - s.f = 1; - s.sub.f = 2; -} - -fn main() { - let mut s = S { f: 0, sub: Sub { f: 0 } }; - field_write(&mut s); - - auto_deref(); - nested_boxes(); -} - -fn auto_deref() { - struct E { - x: bool, - y: bool, //~ ERROR: field is never read - } - - struct P<'a> { - e: &'a mut E - } - - impl P<'_> { - fn f(&mut self) { - self.e.x = true; - self.e.y = true; - } - } - - let mut e = E { x: false, y: false }; - let mut p = P { e: &mut e }; - p.f(); - assert!(e.x); -} - -fn nested_boxes() { - struct A { - b: Box, - } - - struct B { - c: Box, - } - - struct C { - u: u32, //~ ERROR: field is never read - v: u32, //~ ERROR: field is never read - } - - let mut a = A { - b: Box::new(B { - c: Box::new(C { u: 0, v: 0 }), - }), - }; - a.b.c.v = 10; - a.b.c = Box::new(C { u: 1, v: 2 }); -} diff --git a/src/test/ui/lint/dead-code/write-only-field.stderr b/src/test/ui/lint/dead-code/write-only-field.stderr deleted file mode 100644 index a191d22c8b94c..0000000000000 --- a/src/test/ui/lint/dead-code/write-only-field.stderr +++ /dev/null @@ -1,44 +0,0 @@ -error: field is never read: `f` - --> $DIR/write-only-field.rs:4:5 - | -LL | f: i32, - | ^^^^^^ - | -note: the lint level is defined here - --> $DIR/write-only-field.rs:1:9 - | -LL | #![deny(dead_code)] - | ^^^^^^^^^ - -error: field is never read: `sub` - --> $DIR/write-only-field.rs:5:5 - | -LL | sub: Sub, - | ^^^^^^^^ - -error: field is never read: `f` - --> $DIR/write-only-field.rs:9:5 - | -LL | f: i32, - | ^^^^^^ - -error: field is never read: `y` - --> $DIR/write-only-field.rs:28:9 - | -LL | y: bool, - | ^^^^^^^ - -error: field is never read: `u` - --> $DIR/write-only-field.rs:58:9 - | -LL | u: u32, - | ^^^^^^ - -error: field is never read: `v` - --> $DIR/write-only-field.rs:59:9 - | -LL | v: u32, - | ^^^^^^ - -error: aborting due to 6 previous errors - diff --git a/src/test/ui/macros/assert-matches-macro-msg.rs b/src/test/ui/macros/assert-matches-macro-msg.rs deleted file mode 100644 index 43be9532f5d1c..0000000000000 --- a/src/test/ui/macros/assert-matches-macro-msg.rs +++ /dev/null @@ -1,11 +0,0 @@ -// run-fail -// error-pattern:panicked at 'assertion failed: `(left matches right)` -// error-pattern: left: `2` -// error-pattern:right: `3`: 1 + 1 definitely should be 3' -// ignore-emscripten no processes - -#![feature(assert_matches)] - -fn main() { - assert_matches!(1 + 1, 3, "1 + 1 definitely should be 3"); -} diff --git a/src/tools/rls b/src/tools/rls index 74d1800c25498..359513ce678ef 160000 --- a/src/tools/rls +++ b/src/tools/rls @@ -1 +1 @@ -Subproject commit 74d1800c25498689c5b5120a1e8495fce0cd0d0d +Subproject commit 359513ce678efba186972e4f280dbc7046cac15f diff --git a/src/tools/rustfmt b/src/tools/rustfmt index 0bd2b1927c2b0..2a3635d5d1218 160000 --- a/src/tools/rustfmt +++ b/src/tools/rustfmt @@ -1 +1 @@ -Subproject commit 0bd2b1927c2b02a6fe7447d58e897cf1f1a1d41f +Subproject commit 2a3635d5d1218c726ff58af4bc35418836143f69 diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index 5a843ea61ec6f..b604b39967ec7 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -189,6 +189,8 @@ const PERMITTED_DEPENDENCIES: &[&str] = &[ "winapi-i686-pc-windows-gnu", "winapi-util", "winapi-x86_64-pc-windows-gnu", + // this is a false-positive: it's only used by rustfmt, but because it's enabled through a feature, tidy thinks it's used by rustc as well. + "yansi-term", ]; /// Dependency checks.