From 0f197bc918635d48c2e96e681cb0ce317a8db320 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Thu, 17 Jun 2021 15:00:41 -0400 Subject: [PATCH 01/14] Bootstrap from stable --- src/ci/channel | 2 +- src/stage0.txt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ci/channel b/src/ci/channel index bf867e0ae5b6c..65b2df87f7df3 100644 --- a/src/ci/channel +++ b/src/ci/channel @@ -1 +1 @@ -nightly +beta diff --git a/src/stage0.txt b/src/stage0.txt index 1027057f38552..2af238ff6a358 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-05-23 -rustc: beta +date: 2021-06-17 +rustc: 1.53.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: # From 593a02b1b3edf6f00ae2578717b2376d0d2ca8c8 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Thu, 17 Jun 2021 15:07:53 -0400 Subject: [PATCH 02/14] Cherry pick release notes from stable --- RELEASES.md | 204 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 203 insertions(+), 1 deletion(-) diff --git a/RELEASES.md b/RELEASES.md index 60b3359c1b68a..28b0c5c4586a2 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,205 @@ +Version 1.53.0 (2021-06-17) +============================ + +Language +----------------------- +- [You can now use unicode for identifiers.][83799] This allows multilingual + identifiers but still doesn't allow glyphs that are not considered characters + such as `◆` or `🦀`. More specifically you can now use any identifier that + matches the UAX #31 "Unicode Identifier and Pattern Syntax" standard. This + is the same standard as languages like Python, however Rust uses NFC + normalization which may be different from other languages. +- [You can now specify "or patterns" inside pattern matches.][79278] + Previously you could only use `|` (OR) on complete patterns. E.g. + ```rust + let x = Some(2u8); + // Before + matches!(x, Some(1) | Some(2)); + // Now + matches!(x, Some(1 | 2)); + ``` +- [Added the `:pat_param` `macro_rules!` matcher.][83386] This matcher + has the same semantics as the `:pat` matcher. This is to allow `:pat` + to change semantics to being a pattern fragment in a future edition. + +Compiler +----------------------- +- [Updated the minimum external LLVM version to LLVM 10.][83387] +- [Added Tier 3\* support for the `wasm64-unknown-unknown` target.][80525] +- [Improved debuginfo for closures and async functions on Windows MSVC.][83941] + +\* Refer to Rust's [platform support page][platform-support-doc] for more +information on Rust's tiered platform support. + +Libraries +----------------------- +- [Abort messages will now forward to `android_set_abort_message` on + Android platforms when available.][81469] +- [`slice::IterMut<'_, T>` now implements `AsRef<[T]>`][82771] +- [Arrays of any length now implement `IntoIterator`.][84147] + Currently calling `.into_iter()` as a method on an array will + return `impl Iterator`, but this may change in a + future edition to change `Item` to `T`. Calling `IntoIterator::into_iter` + directly on arrays will provide `impl Iterator` as expected. +- [`leading_zeros`, and `trailing_zeros` are now available on all + `NonZero` integer types.][84082] +- [`{f32, f64}::from_str` now parse and print special values + (`NaN`, `-0`) according to IEEE RFC 754.][78618] +- [You can now index into slices using `(Bound, Bound)`.][77704] +- [Add the `BITS` associated constant to all numeric types.][82565] + +Stabilised APIs +--------------- +- [`AtomicBool::fetch_update`] +- [`AtomicPtr::fetch_update`] +- [`BTreeMap::retain`] +- [`BTreeSet::retain`] +- [`BufReader::seek_relative`] +- [`DebugStruct::non_exhaustive`] +- [`Duration::MAX`] +- [`Duration::ZERO`] +- [`Duration::is_zero`] +- [`Duration::saturating_add`] +- [`Duration::saturating_mul`] +- [`Duration::saturating_sub`] +- [`ErrorKind::Unsupported`] +- [`Option::insert`] +- [`Ordering::is_eq`] +- [`Ordering::is_ge`] +- [`Ordering::is_gt`] +- [`Ordering::is_le`] +- [`Ordering::is_lt`] +- [`Ordering::is_ne`] +- [`OsStr::is_ascii`] +- [`OsStr::make_ascii_lowercase`] +- [`OsStr::make_ascii_uppercase`] +- [`OsStr::to_ascii_lowercase`] +- [`OsStr::to_ascii_uppercase`] +- [`Peekable::peek_mut`] +- [`Rc::decrement_strong_count`] +- [`Rc::increment_strong_count`] +- [`Vec::extend_from_within`] +- [`array::from_mut`] +- [`array::from_ref`] +- [`char::MAX`] +- [`char::REPLACEMENT_CHARACTER`] +- [`char::UNICODE_VERSION`] +- [`char::decode_utf16`] +- [`char::from_digit`] +- [`char::from_u32_unchecked`] +- [`char::from_u32`] +- [`cmp::max_by_key`] +- [`cmp::max_by`] +- [`cmp::min_by_key`] +- [`cmp::min_by`] +- [`f32::is_subnormal`] +- [`f64::is_subnormal`] + +Cargo +----------------------- +- [Cargo now supports git repositories where the default `HEAD` branch is not + "master".][cargo/9392] This also includes a switch to the version 3 `Cargo.lock` format + which can handle default branches correctly. +- [macOS targets now default to `unpacked` split-debuginfo.][cargo/9298] +- [The `authors` field is no longer included in `Cargo.toml` for new + projects.][cargo/9282] + +Rustdoc +----------------------- +- [Added the `rustdoc::bare_urls` lint that warns when you have URLs + without hyperlinks.][81764] + +Compatibility Notes +------------------- +- [Implement token-based handling of attributes during expansion][82608] +- [`Ipv4::from_str` will now reject octal format IP addresses in addition + to rejecting hexadecimal IP addresses.][83652] The octal format can lead + to confusion and potential security vulnerabilities and [is no + longer recommended][ietf6943]. + + +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. + +- [Rework the `std::sys::windows::alloc` implementation.][83065] +- [rustdoc: Don't enter an infer_ctxt in get_blanket_impls for impls that aren't blanket impls.][82864] +- [rustdoc: Only look at blanket impls in `get_blanket_impls`][83681] +- [Rework rustdoc const type][82873] + +[83386]: https://github.com/rust-lang/rust/pull/83386 +[82771]: https://github.com/rust-lang/rust/pull/82771 +[84147]: https://github.com/rust-lang/rust/pull/84147 +[84082]: https://github.com/rust-lang/rust/pull/84082 +[83799]: https://github.com/rust-lang/rust/pull/83799 +[83681]: https://github.com/rust-lang/rust/pull/83681 +[83652]: https://github.com/rust-lang/rust/pull/83652 +[83387]: https://github.com/rust-lang/rust/pull/83387 +[82873]: https://github.com/rust-lang/rust/pull/82873 +[82864]: https://github.com/rust-lang/rust/pull/82864 +[82608]: https://github.com/rust-lang/rust/pull/82608 +[82565]: https://github.com/rust-lang/rust/pull/82565 +[80525]: https://github.com/rust-lang/rust/pull/80525 +[79278]: https://github.com/rust-lang/rust/pull/79278 +[78618]: https://github.com/rust-lang/rust/pull/78618 +[77704]: https://github.com/rust-lang/rust/pull/77704 +[83941]: https://github.com/rust-lang/rust/pull/83941 +[83065]: https://github.com/rust-lang/rust/pull/83065 +[81764]: https://github.com/rust-lang/rust/pull/81764 +[81469]: https://github.com/rust-lang/rust/pull/81469 +[cargo/9298]: https://github.com/rust-lang/cargo/pull/9298 +[cargo/9282]: https://github.com/rust-lang/cargo/pull/9282 +[cargo/9392]: https://github.com/rust-lang/cargo/pull/9392 +[`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 +[`AtomicBool::fetch_update`]: https://doc.rust-lang.org/std/sync/atomic/struct.AtomicBool.html#method.fetch_update +[`AtomicPtr::fetch_update`]: https://doc.rust-lang.org/std/sync/atomic/struct.AtomicPtr.html#method.fetch_update +[`BTreeMap::retain`]: https://doc.rust-lang.org/std/collections/struct.BTreeMap.html#method.retain +[`BTreeSet::retain`]: https://doc.rust-lang.org/std/collections/struct.BTreeSet.html#method.retain +[`BufReader::seek_relative`]: https://doc.rust-lang.org/std/io/struct.BufReader.html#method.seek_relative +[`DebugStruct::non_exhaustive`]: https://doc.rust-lang.org/std/fmt/struct.DebugStruct.html#method.finish_non_exhaustive +[`Duration::MAX`]: https://doc.rust-lang.org/std/time/struct.Duration.html#associatedconstant.MAX +[`Duration::ZERO`]: https://doc.rust-lang.org/std/time/struct.Duration.html#associatedconstant.ZERO +[`Duration::is_zero`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.is_zero +[`Duration::saturating_add`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.saturating_add +[`Duration::saturating_mul`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.saturating_mul +[`Duration::saturating_sub`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.saturating_sub +[`ErrorKind::Unsupported`]: https://doc.rust-lang.org/std/io/enum.ErrorKind.html#variant.Unsupported +[`Option::insert`]: https://doc.rust-lang.org/std/option/enum.Option.html#method.insert +[`Ordering::is_eq`]: https://doc.rust-lang.org/std/cmp/enum.Ordering.html#method.is_eq +[`Ordering::is_ge`]: https://doc.rust-lang.org/std/cmp/enum.Ordering.html#method.is_ge +[`Ordering::is_gt`]: https://doc.rust-lang.org/std/cmp/enum.Ordering.html#method.is_gt +[`Ordering::is_le`]: https://doc.rust-lang.org/std/cmp/enum.Ordering.html#method.is_le +[`Ordering::is_lt`]: https://doc.rust-lang.org/std/cmp/enum.Ordering.html#method.is_lt +[`Ordering::is_ne`]: https://doc.rust-lang.org/std/cmp/enum.Ordering.html#method.is_ne +[`OsStr::eq_ignore_ascii_case`]: https://doc.rust-lang.org/std/ffi/struct.OsStr.html#method.eq_ignore_ascii_case +[`OsStr::is_ascii`]: https://doc.rust-lang.org/std/ffi/struct.OsStr.html#method.is_ascii +[`OsStr::make_ascii_lowercase`]: https://doc.rust-lang.org/std/ffi/struct.OsStr.html#method.make_ascii_lowercase +[`OsStr::make_ascii_uppercase`]: https://doc.rust-lang.org/std/ffi/struct.OsStr.html#method.make_ascii_uppercase +[`OsStr::to_ascii_lowercase`]: https://doc.rust-lang.org/std/ffi/struct.OsStr.html#method.to_ascii_lowercase +[`OsStr::to_ascii_uppercase`]: https://doc.rust-lang.org/std/ffi/struct.OsStr.html#method.to_ascii_uppercase +[`Peekable::peek_mut`]: https://doc.rust-lang.org/std/iter/struct.Peekable.html#method.peek_mut +[`Rc::decrement_strong_count`]: https://doc.rust-lang.org/std/rc/struct.Rc.html#method.increment_strong_count +[`Rc::increment_strong_count`]: https://doc.rust-lang.org/std/rc/struct.Rc.html#method.increment_strong_count +[`Vec::extend_from_within`]: https://doc.rust-lang.org/beta/std/vec/struct.Vec.html#method.extend_from_within +[`array::from_mut`]: https://doc.rust-lang.org/beta/std/array/fn.from_mut.html +[`array::from_ref`]: https://doc.rust-lang.org/beta/std/array/fn.from_ref.html +[`cmp::max_by_key`]: https://doc.rust-lang.org/beta/std/cmp/fn.max_by_key.html +[`cmp::max_by`]: https://doc.rust-lang.org/beta/std/cmp/fn.max_by.html +[`cmp::min_by_key`]: https://doc.rust-lang.org/beta/std/cmp/fn.min_by_key.html +[`cmp::min_by`]: https://doc.rust-lang.org/beta/std/cmp/fn.min_by.html +[`f32::is_subnormal`]: https://doc.rust-lang.org/std/primitive.f64.html#method.is_subnormal +[`f64::is_subnormal`]: https://doc.rust-lang.org/std/primitive.f64.html#method.is_subnormal +[ietf6943]: https://datatracker.ietf.org/doc/html/rfc6943#section-3.1.1 + + Version 1.52.1 (2021-05-10) ============================ @@ -174,7 +376,7 @@ Language -------- - [You can now parameterize items such as functions, traits, and `struct`s by constant values in addition to by types and lifetimes.][79135] Also known as "const generics" - E.g. you can now write the following. Note: Only values of primitive integers, + E.g. you can now write the following. Note: Only values of primitive integers, `bool`, or `char` types are currently permitted. ```rust struct GenericArray { From f370346f8c88357838d4a4bf1f7b18a7ba51054e Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 16 Jun 2021 14:04:33 -0700 Subject: [PATCH 03/14] Add a compatibility note for BITS in 1.53 --- RELEASES.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/RELEASES.md b/RELEASES.md index 28b0c5c4586a2..ced712ffb530b 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -116,7 +116,10 @@ Compatibility Notes to rejecting hexadecimal IP addresses.][83652] The octal format can lead to confusion and potential security vulnerabilities and [is no longer recommended][ietf6943]. - +- [The added `BITS` constant may conflict with external definitions.][85667] + In particular, this was known to be a problem in the `lexical-core` crate, + but they have published fixes for semantic versions 0.4 through 0.7. To + update this dependency alone, use `cargo update -p lexical-core`. Internal Only ------------- @@ -129,6 +132,7 @@ related tools. - [rustdoc: Only look at blanket impls in `get_blanket_impls`][83681] - [Rework rustdoc const type][82873] +[85667]: https://github.com/rust-lang/rust/pull/85667 [83386]: https://github.com/rust-lang/rust/pull/83386 [82771]: https://github.com/rust-lang/rust/pull/82771 [84147]: https://github.com/rust-lang/rust/pull/84147 From f07bf3a428599902466015b4ea88c0a9d7f696d5 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Thu, 17 Jun 2021 15:16:46 -0400 Subject: [PATCH 04/14] Revert "Allow specifying alignment for functions" This reverts commit 448d07683a6defd567996114793a09c9a8aef5df. --- compiler/rustc_attr/src/builtin.rs | 50 +++++++++++++------ compiler/rustc_codegen_llvm/src/attributes.rs | 3 -- compiler/rustc_feature/src/active.rs | 3 -- .../src/middle/codegen_fn_attrs.rs | 4 -- compiler/rustc_passes/src/check_attr.rs | 46 +++-------------- compiler/rustc_span/src/symbol.rs | 1 - compiler/rustc_typeck/src/collect.rs | 32 ------------ src/test/codegen/align-fn.rs | 9 ---- .../ui/attributes/nonterminal-expansion.rs | 1 + .../attributes/nonterminal-expansion.stderr | 14 +++++- src/test/ui/error-codes/E0565.rs | 5 +- src/test/ui/error-codes/E0565.stderr | 8 ++- .../ui/feature-gates/feature-gate-fn_align.rs | 4 -- .../feature-gate-fn_align.stderr | 12 ----- src/test/ui/issues/issue-43988.rs | 4 +- src/test/ui/issues/issue-43988.stderr | 18 ++++--- src/test/ui/repr/repr-disallow-on-variant.rs | 2 +- .../ui/repr/repr-disallow-on-variant.stderr | 4 +- 18 files changed, 83 insertions(+), 137 deletions(-) delete mode 100644 src/test/codegen/align-fn.rs delete mode 100644 src/test/ui/feature-gates/feature-gate-fn_align.rs delete mode 100644 src/test/ui/feature-gates/feature-gate-fn_align.stderr diff --git a/compiler/rustc_attr/src/builtin.rs b/compiler/rustc_attr/src/builtin.rs index 20971ebb95748..e58b266fdb9e1 100644 --- a/compiler/rustc_attr/src/builtin.rs +++ b/compiler/rustc_attr/src/builtin.rs @@ -862,6 +862,18 @@ pub fn find_repr_attrs(sess: &Session, attr: &Attribute) -> Vec { if let Some(items) = attr.meta_item_list() { sess.mark_attr_used(attr); for item in items { + if !item.is_meta_item() { + handle_errors( + &sess.parse_sess, + item.span(), + AttrError::UnsupportedLiteral( + "meta item in `repr` must be an identifier", + false, + ), + ); + continue; + } + let mut recognised = false; if item.is_word() { let hint = match item.name_or_empty() { @@ -878,6 +890,23 @@ pub fn find_repr_attrs(sess: &Session, attr: &Attribute) -> Vec { acc.push(h); } } else if let Some((name, value)) = item.name_value_literal() { + let parse_alignment = |node: &ast::LitKind| -> Result { + if let ast::LitKind::Int(literal, ast::LitIntType::Unsuffixed) = node { + if literal.is_power_of_two() { + // rustc_middle::ty::layout::Align restricts align to <= 2^29 + if *literal <= 1 << 29 { + Ok(*literal as u32) + } else { + Err("larger than 2^29") + } + } else { + Err("not a power of two") + } + } else { + Err("not an unsuffixed integer") + } + }; + let mut literal_error = None; if name == sym::align { recognised = true; @@ -937,7 +966,13 @@ pub fn find_repr_attrs(sess: &Session, attr: &Attribute) -> Vec { } if !recognised { // Not a word we recognize - diagnostic.delay_span_bug(item.span(), "unrecognized representation hint"); + struct_span_err!( + diagnostic, + item.span(), + E0552, + "unrecognized representation hint" + ) + .emit(); } } } @@ -1045,16 +1080,3 @@ fn allow_unstable<'a>( name }) } - -pub fn parse_alignment(node: &ast::LitKind) -> Result { - if let ast::LitKind::Int(literal, ast::LitIntType::Unsuffixed) = node { - if literal.is_power_of_two() { - // rustc_middle::ty::layout::Align restricts align to <= 2^29 - if *literal <= 1 << 29 { Ok(*literal as u32) } else { Err("larger than 2^29") } - } else { - Err("not a power of two") - } - } else { - Err("not an unsuffixed integer") - } -} diff --git a/compiler/rustc_codegen_llvm/src/attributes.rs b/compiler/rustc_codegen_llvm/src/attributes.rs index 6a032b9be723b..f1c45d8dc3647 100644 --- a/compiler/rustc_codegen_llvm/src/attributes.rs +++ b/compiler/rustc_codegen_llvm/src/attributes.rs @@ -279,9 +279,6 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty:: if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::CMSE_NONSECURE_ENTRY) { llvm::AddFunctionAttrString(llfn, Function, cstr!("cmse_nonsecure_entry")); } - if let Some(align) = codegen_fn_attrs.alignment { - llvm::set_alignment(llfn, align as usize); - } sanitize(cx, codegen_fn_attrs.no_sanitize, llfn); // Always annotate functions with the target-cpu they are compiled for. diff --git a/compiler/rustc_feature/src/active.rs b/compiler/rustc_feature/src/active.rs index 56a320c8d3bce..16f67783c1e36 100644 --- a/compiler/rustc_feature/src/active.rs +++ b/compiler/rustc_feature/src/active.rs @@ -626,9 +626,6 @@ declare_features! ( /// Allows `extern "C-unwind" fn` to enable unwinding across ABI boundaries. (active, c_unwind, "1.52.0", Some(74990), None), - /// Allows using `#[repr(align(...))]` on function items - (active, fn_align, "1.53.0", Some(82232), None), - /// Allows `extern "wasm" fn` (active, wasm_abi, "1.53.0", Some(83788), None), diff --git a/compiler/rustc_middle/src/middle/codegen_fn_attrs.rs b/compiler/rustc_middle/src/middle/codegen_fn_attrs.rs index 93e7aeaffce37..fc3dafe99e5ec 100644 --- a/compiler/rustc_middle/src/middle/codegen_fn_attrs.rs +++ b/compiler/rustc_middle/src/middle/codegen_fn_attrs.rs @@ -38,9 +38,6 @@ pub struct CodegenFnAttrs { /// be generated against a specific instruction set. Only usable on architectures which allow /// switching between multiple instruction sets. pub instruction_set: Option, - /// The `#[repr(align(...))]` attribute. Indicates the value of which the function should be - /// aligned to. - pub alignment: Option, } bitflags! { @@ -110,7 +107,6 @@ impl CodegenFnAttrs { link_section: None, no_sanitize: SanitizerSet::empty(), instruction_set: None, - alignment: None, } } diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index b18ef30296237..9c42a42fe6024 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -1193,41 +1193,17 @@ impl CheckAttrVisitor<'tcx> { let mut is_transparent = false; for hint in &hints { - if !hint.is_meta_item() { - struct_span_err!( - self.tcx.sess, - hint.span(), - E0565, - "meta item in `repr` must be an identifier" - ) - .emit(); - continue; - } - let (article, allowed_targets) = match hint.name_or_empty() { - sym::C => { - is_c = true; + _ if !matches!(target, Target::Struct | Target::Enum | Target::Union) => { + ("a", "struct, enum, or union") + } + name @ sym::C | name @ sym::align => { + is_c |= name == sym::C; match target { Target::Struct | Target::Union | Target::Enum => continue, _ => ("a", "struct, enum, or union"), } } - sym::align => { - if let (Target::Fn, true) = (target, !self.tcx.features().fn_align) { - feature_err( - &self.tcx.sess.parse_sess, - sym::fn_align, - hint.span(), - "`repr(align)` attributes on functions are unstable", - ) - .emit(); - } - - match target { - Target::Struct | Target::Union | Target::Enum | Target::Fn => continue, - _ => ("a", "struct, enum, function, or union"), - } - } sym::packed => { if target != Target::Struct && target != Target::Union { ("a", "struct or union") @@ -1284,17 +1260,7 @@ impl CheckAttrVisitor<'tcx> { continue; } } - _ => { - struct_span_err!( - self.tcx.sess, - hint.span(), - E0552, - "unrecognized representation hint" - ) - .emit(); - - continue; - } + _ => continue, }; struct_span_err!( diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index fb37c5e9c1eff..a31ab5b350e4e 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -569,7 +569,6 @@ symbols! { fmt, fmt_internals, fmul_fast, - fn_align, fn_must_use, fn_mut, fn_once, diff --git a/compiler/rustc_typeck/src/collect.rs b/compiler/rustc_typeck/src/collect.rs index ee3ac3b62d9ec..aebae0d47c903 100644 --- a/compiler/rustc_typeck/src/collect.rs +++ b/compiler/rustc_typeck/src/collect.rs @@ -15,8 +15,6 @@ //! At present, however, we do run collection across all items in the //! crate as a kind of pass. This should eventually be factored away. -// ignore-tidy-filelength - use crate::astconv::{AstConv, SizedByDefault}; use crate::bounds::Bounds; use crate::check::intrinsic::intrinsic_operation_unsafety; @@ -2922,36 +2920,6 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, id: DefId) -> CodegenFnAttrs { None } }; - } else if tcx.sess.check_name(attr, sym::repr) { - codegen_fn_attrs.alignment = match attr.meta_item_list() { - Some(items) => match items.as_slice() { - [item] => match item.name_value_literal() { - Some((sym::align, literal)) => { - let alignment = rustc_attr::parse_alignment(&literal.kind); - - match alignment { - Ok(align) => Some(align), - Err(msg) => { - struct_span_err!( - tcx.sess.diagnostic(), - attr.span, - E0589, - "invalid `repr(align)` attribute: {}", - msg - ) - .emit(); - - None - } - } - } - _ => None, - }, - [] => None, - _ => None, - }, - None => None, - }; } } diff --git a/src/test/codegen/align-fn.rs b/src/test/codegen/align-fn.rs deleted file mode 100644 index c5886cf28081a..0000000000000 --- a/src/test/codegen/align-fn.rs +++ /dev/null @@ -1,9 +0,0 @@ -// compile-flags: -C no-prepopulate-passes -Z mir-opt-level=0 - -#![crate_type = "lib"] -#![feature(fn_align)] - -// CHECK: align 16 -#[no_mangle] -#[repr(align(16))] -pub fn fn_align() {} diff --git a/src/test/ui/attributes/nonterminal-expansion.rs b/src/test/ui/attributes/nonterminal-expansion.rs index d663431d6836f..b4f523936a0b0 100644 --- a/src/test/ui/attributes/nonterminal-expansion.rs +++ b/src/test/ui/attributes/nonterminal-expansion.rs @@ -3,6 +3,7 @@ macro_rules! pass_nonterminal { ($n:expr) => { #[repr(align($n))] //~ ERROR expected unsuffixed literal or identifier, found `n!()` + //~| ERROR unrecognized representation hint struct S; }; } diff --git a/src/test/ui/attributes/nonterminal-expansion.stderr b/src/test/ui/attributes/nonterminal-expansion.stderr index 4124f8cea8ebf..e6a36b68d47c3 100644 --- a/src/test/ui/attributes/nonterminal-expansion.stderr +++ b/src/test/ui/attributes/nonterminal-expansion.stderr @@ -9,5 +9,17 @@ LL | pass_nonterminal!(n!()); | = note: this error originates in the macro `pass_nonterminal` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to previous error +error[E0552]: unrecognized representation hint + --> $DIR/nonterminal-expansion.rs:5:16 + | +LL | #[repr(align($n))] + | ^^^^^^^^^ +... +LL | pass_nonterminal!(n!()); + | ------------------------ in this macro invocation + | + = note: this error originates in the macro `pass_nonterminal` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0552`. diff --git a/src/test/ui/error-codes/E0565.rs b/src/test/ui/error-codes/E0565.rs index df76f6b13af9b..3bf428676105d 100644 --- a/src/test/ui/error-codes/E0565.rs +++ b/src/test/ui/error-codes/E0565.rs @@ -1,5 +1,6 @@ // repr currently doesn't support literals #[repr("C")] //~ ERROR E0565 -struct A {} + //~| ERROR E0565 +struct A { } -fn main() {} +fn main() { } diff --git a/src/test/ui/error-codes/E0565.stderr b/src/test/ui/error-codes/E0565.stderr index 6ed90c0ae4ffe..aa0951528e1ed 100644 --- a/src/test/ui/error-codes/E0565.stderr +++ b/src/test/ui/error-codes/E0565.stderr @@ -4,6 +4,12 @@ error[E0565]: meta item in `repr` must be an identifier LL | #[repr("C")] | ^^^ -error: aborting due to previous error +error[E0565]: meta item in `repr` must be an identifier + --> $DIR/E0565.rs:2:8 + | +LL | #[repr("C")] + | ^^^ + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0565`. diff --git a/src/test/ui/feature-gates/feature-gate-fn_align.rs b/src/test/ui/feature-gates/feature-gate-fn_align.rs deleted file mode 100644 index ea873dba269c4..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-fn_align.rs +++ /dev/null @@ -1,4 +0,0 @@ -#![crate_type = "lib"] - -#[repr(align(16))] //~ ERROR `repr(align)` attributes on functions are unstable -fn requires_alignment() {} diff --git a/src/test/ui/feature-gates/feature-gate-fn_align.stderr b/src/test/ui/feature-gates/feature-gate-fn_align.stderr deleted file mode 100644 index 5ff124e48dca9..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-fn_align.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0658]: `repr(align)` attributes on functions are unstable - --> $DIR/feature-gate-fn_align.rs:3:8 - | -LL | #[repr(align(16))] - | ^^^^^^^^^ - | - = note: see issue #82232 for more information - = help: add `#![feature(fn_align)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/issues/issue-43988.rs b/src/test/ui/issues/issue-43988.rs index b114e8e03333d..4b3a0269baea2 100644 --- a/src/test/ui/issues/issue-43988.rs +++ b/src/test/ui/issues/issue-43988.rs @@ -13,13 +13,13 @@ fn main() { #[repr(nothing)] let _x = 0; - //~^^ ERROR E0552 + //~^^ ERROR attribute should be applied to a struct, enum, or union #[repr(something_not_real)] loop { () }; - //~^^^^ ERROR E0552 + //~^^^^ ERROR attribute should be applied to a struct, enum, or union #[repr] let _y = "123"; diff --git a/src/test/ui/issues/issue-43988.stderr b/src/test/ui/issues/issue-43988.stderr index 03aa37f52075f..f1205d447e4ba 100644 --- a/src/test/ui/issues/issue-43988.stderr +++ b/src/test/ui/issues/issue-43988.stderr @@ -26,17 +26,23 @@ LL | #[inline(XYZ)] LL | let _b = 4; | ----------- not a function or closure -error[E0552]: unrecognized representation hint +error[E0517]: attribute should be applied to a struct, enum, or union --> $DIR/issue-43988.rs:14:12 | LL | #[repr(nothing)] | ^^^^^^^ +LL | let _x = 0; + | ----------- not a struct, enum, or union -error[E0552]: unrecognized representation hint +error[E0517]: attribute should be applied to a struct, enum, or union --> $DIR/issue-43988.rs:18:12 | -LL | #[repr(something_not_real)] - | ^^^^^^^^^^^^^^^^^^ +LL | #[repr(something_not_real)] + | ^^^^^^^^^^^^^^^^^^ +LL | / loop { +LL | | () +LL | | }; + | |_____- not a struct, enum, or union error[E0518]: attribute should be applied to function or closure --> $DIR/issue-43988.rs:30:5 @@ -48,5 +54,5 @@ LL | foo(); error: aborting due to 7 previous errors -Some errors have detailed explanations: E0518, E0552. -For more information about an error, try `rustc --explain E0518`. +Some errors have detailed explanations: E0517, E0518. +For more information about an error, try `rustc --explain E0517`. diff --git a/src/test/ui/repr/repr-disallow-on-variant.rs b/src/test/ui/repr/repr-disallow-on-variant.rs index d9bd0b0e38a69..90cad7e647b05 100644 --- a/src/test/ui/repr/repr-disallow-on-variant.rs +++ b/src/test/ui/repr/repr-disallow-on-variant.rs @@ -2,7 +2,7 @@ struct Test; enum Foo { #[repr(u8)] - //~^ ERROR attribute should be applied to an enum + //~^ ERROR attribute should be applied to a struct, enum, or union Variant, } diff --git a/src/test/ui/repr/repr-disallow-on-variant.stderr b/src/test/ui/repr/repr-disallow-on-variant.stderr index f7e4dcc9d81be..70b45e393fcf1 100644 --- a/src/test/ui/repr/repr-disallow-on-variant.stderr +++ b/src/test/ui/repr/repr-disallow-on-variant.stderr @@ -1,11 +1,11 @@ -error[E0517]: attribute should be applied to an enum +error[E0517]: attribute should be applied to a struct, enum, or union --> $DIR/repr-disallow-on-variant.rs:4:12 | LL | #[repr(u8)] | ^^ LL | LL | Variant, - | ------- not an enum + | ------- not a struct, enum, or union error: aborting due to previous error From c5b826502b24a8233684072f3172f5a4b0a07e19 Mon Sep 17 00:00:00 2001 From: Peter Todd Date: Thu, 27 May 2021 14:01:16 -0400 Subject: [PATCH 05/14] Revert #85176 addition of `clone_from` for `ManuallyDrop` Forwarding `clone_from` to the inner value changes the observable behavior, as previously the inner value would *not* be dropped by the default implementation. --- library/core/src/mem/manually_drop.rs | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/library/core/src/mem/manually_drop.rs b/library/core/src/mem/manually_drop.rs index 5b99f6954e62b..d86939454be5b 100644 --- a/library/core/src/mem/manually_drop.rs +++ b/library/core/src/mem/manually_drop.rs @@ -44,7 +44,7 @@ use crate::ptr; /// [`MaybeUninit`]: crate::mem::MaybeUninit #[stable(feature = "manually_drop", since = "1.20.0")] #[lang = "manually_drop"] -#[derive(Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] #[repr(transparent)] pub struct ManuallyDrop { value: T, @@ -160,16 +160,3 @@ impl DerefMut for ManuallyDrop { &mut self.value } } - -#[stable(feature = "manually_drop", since = "1.20.0")] -impl Clone for ManuallyDrop { - #[inline] - fn clone(&self) -> ManuallyDrop { - ManuallyDrop { value: self.value.clone() } - } - - #[inline] - fn clone_from(&mut self, other: &Self) { - self.value.clone_from(&other.value) - } -} From 93d9ec726f26e9a5e10af08906c923a8b4c1abaf Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Mon, 3 May 2021 09:21:52 -0400 Subject: [PATCH 06/14] manually crafted revert of PR #80653, to address issue #82465. (update: placated tidy) (update: rebased post PR #84707 ) merge me --- src/librustdoc/html/render/context.rs | 9 +- src/librustdoc/html/render/mod.rs | 26 ++---- src/librustdoc/passes/collect_trait_impls.rs | 97 +++++++------------- src/test/rustdoc-ui/deref-recursive-cycle.rs | 17 ---- src/test/rustdoc/deref-recursive-pathbuf.rs | 24 ----- src/test/rustdoc/deref-recursive.rs | 40 -------- src/test/rustdoc/deref-typedef.rs | 4 +- 7 files changed, 45 insertions(+), 172 deletions(-) delete mode 100644 src/test/rustdoc-ui/deref-recursive-cycle.rs delete mode 100644 src/test/rustdoc/deref-recursive-pathbuf.rs delete mode 100644 src/test/rustdoc/deref-recursive.rs diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs index d80b2db00ac8e..1898f5feed2cd 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; @@ -51,9 +51,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][] @@ -74,7 +71,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> { @@ -486,7 +483,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), }; @@ -504,7 +500,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 2e940a31c2aff..ebb4cfb7d48bd 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -1045,17 +1045,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), ); @@ -1080,6 +1075,9 @@ fn render_assoc_items( ); } } + if let AssocItemRender::DerefFor { .. } = what { + return; + } if !traits.is_empty() { let deref_impl = traits .iter() @@ -1090,13 +1088,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>, _) = @@ -2017,14 +2008,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/passes/collect_trait_impls.rs b/src/librustdoc/passes/collect_trait_impls.rs index 4e621e100e354..6d7c45f6eeacb 100644 --- a/src/librustdoc/passes/collect_trait_impls.rs +++ b/src/librustdoc/passes/collect_trait_impls.rs @@ -3,8 +3,7 @@ use crate::clean::*; use crate::core::DocContext; use crate::fold::DocFolder; -use rustc_data_structures::fx::{FxHashMap, FxHashSet}; -use rustc_hir::def_id::DefId; +use rustc_data_structures::fx::FxHashSet; use rustc_middle::ty::DefIdTree; use rustc_span::symbol::sym; @@ -53,6 +52,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.into()); + } + } + } + } + + 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 +116,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.into()); - add_deref_target(map, cleaner, &target_did.into()); - } - } - } - 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(FakeDefId::Real(*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 +123,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 } 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/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' From 86b232362921783b7b30d4705eff81fdfbbec461 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Mon, 3 May 2021 10:06:57 -0400 Subject: [PATCH 07/14] regression test for issue 82465. --- .../issue-82465-asref-for-and-of-local.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/test/rustdoc/issue-82465-asref-for-and-of-local.rs 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!() + } +} From 6affded132db0881cd09410957b0bd9a42d8a9d1 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 19 Jun 2021 10:08:13 -0400 Subject: [PATCH 08/14] Fix CI to fetch master on beta channel --- src/ci/init_repo.sh | 2 +- src/ci/run.sh | 6 +----- src/ci/shared.sh | 8 ++++++++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/ci/init_repo.sh b/src/ci/init_repo.sh index 060b3079dad5f..3c61dcc9d9c7b 100755 --- a/src/ci/init_repo.sh +++ b/src/ci/init_repo.sh @@ -31,7 +31,7 @@ mkdir "$CACHE_DIR" # On the beta channel we'll be automatically calculating the prerelease version # via the git history, so unshallow our shallow clone from CI. -if grep -q RUST_RELEASE_CHANNEL=beta src/ci/run.sh; then +if [ "$(releaseChannel)" = "beta" ]; then git fetch origin --unshallow beta master fi diff --git a/src/ci/run.sh b/src/ci/run.sh index c5e225c7cd17d..b5019d83af45b 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -65,11 +65,7 @@ fi # 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 # master, beta, or stable with a build to determine whether to run some checks (notably toolstate). -if [[ -z "${RUST_CI_OVERRIDE_RELEASE_CHANNEL+x}" ]]; then - export RUST_RELEASE_CHANNEL="$(cat "${ci_dir}/channel")" -else - export RUST_RELEASE_CHANNEL="${RUST_CI_OVERRIDE_RELEASE_CHANNEL}" -fi +export RUST_RELEASE_CHANNEL=$(releaseChannel) RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --release-channel=$RUST_RELEASE_CHANNEL" if [ "$DEPLOY$DEPLOY_ALT" = "1" ]; then diff --git a/src/ci/shared.sh b/src/ci/shared.sh index 332a949a4dc51..b095afb542d83 100644 --- a/src/ci/shared.sh +++ b/src/ci/shared.sh @@ -141,3 +141,11 @@ function ciCommandSetEnv { exit 1 fi } + +function releaseChannel { + if [[ -z "${RUST_CI_OVERRIDE_RELEASE_CHANNEL+x}" ]]; then + cat "${ci_dir}/channel" + else + echo $RUST_CI_OVERRIDE_RELEASE_CHANNEL + fi +} From 793b0055d2aa8dd63b6d24425bf1e3abdafaa89b Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Tue, 22 Jun 2021 16:03:42 -0400 Subject: [PATCH 09/14] Disable pgo-branch-weights test on aarch64 This will let us produce a beta and investigate a proper fix on a longer timescale. --- src/test/run-make-fulldeps/pgo-branch-weights/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/run-make-fulldeps/pgo-branch-weights/Makefile b/src/test/run-make-fulldeps/pgo-branch-weights/Makefile index 18828b66ce874..0656346e95868 100644 --- a/src/test/run-make-fulldeps/pgo-branch-weights/Makefile +++ b/src/test/run-make-fulldeps/pgo-branch-weights/Makefile @@ -1,5 +1,6 @@ # needs-profiler-support # ignore-windows-gnu +# ignore-aarch64 # FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works # properly. Since we only have GCC on the CI ignore the test for now. From 84d831ef252e0b54c35870b02b395feb6dc19b76 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Tue, 22 Jun 2021 17:31:16 -0700 Subject: [PATCH 10/14] [beta] Update cargo --- src/tools/cargo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/cargo b/src/tools/cargo index aa8b09297bb31..5ae8d74b3b2d5 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit aa8b09297bb3156b849e73db48af4cd050492fe6 +Subproject commit 5ae8d74b3b2d58f32c8d357e5cfa04d430a70e0b From c064a3120699a2b0741bb82be50d2cc4ddedb4a0 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Tue, 22 Jun 2021 22:10:25 -0700 Subject: [PATCH 11/14] Don't dist miri on stable or beta. --- src/bootstrap/dist.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 71ed0af4a7c04..e0c33f7357741 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -1171,6 +1171,9 @@ impl Step for Miri { } fn run(self, builder: &Builder<'_>) -> Option { + if !builder.build.unstable_features() { + return None; + } let compiler = self.compiler; let target = self.target; assert!(builder.config.extended); From b36bc9e7e5db40427a1dd0281710943ee9f0b441 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Wed, 23 Jun 2021 07:03:42 -0700 Subject: [PATCH 12/14] Comment and include rust-analyzer. --- src/bootstrap/dist.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index e0c33f7357741..19895baf08f16 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -1072,6 +1072,12 @@ impl Step for RustAnalyzer { } fn run(self, builder: &Builder<'_>) -> Option { + // This prevents rust-analyzer from being built for "dist" or "install" + // on the stable/beta channels. It is a nightly-only tool and should + // not be included. + if !builder.build.unstable_features() { + return None; + } let compiler = self.compiler; let target = self.target; assert!(builder.config.extended); @@ -1171,6 +1177,9 @@ impl Step for Miri { } fn run(self, builder: &Builder<'_>) -> Option { + // This prevents miri from being built for "dist" or "install" + // on the stable/beta channels. It is a nightly-only tool and should + // not be included. if !builder.build.unstable_features() { return None; } From 680c6cea45c1a0de1880cf44c1656121f05daba2 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Wed, 23 Jun 2021 10:37:52 -0400 Subject: [PATCH 13/14] Bump expat to 2.4.1 --- .../dist-riscv64-linux/riscv64-unknown-linux-gnu.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ci/docker/host-x86_64/dist-riscv64-linux/riscv64-unknown-linux-gnu.config b/src/ci/docker/host-x86_64/dist-riscv64-linux/riscv64-unknown-linux-gnu.config index 7124ee3aeb53b..ffb2e9195b116 100644 --- a/src/ci/docker/host-x86_64/dist-riscv64-linux/riscv64-unknown-linux-gnu.config +++ b/src/ci/docker/host-x86_64/dist-riscv64-linux/riscv64-unknown-linux-gnu.config @@ -644,7 +644,7 @@ CT_EXPAT_PATCH_GLOBAL=y CT_EXPAT_PATCH_ORDER="global" CT_EXPAT_V_2_2=y # CT_EXPAT_NO_VERSIONS is not set -CT_EXPAT_VERSION="2.3.0" +CT_EXPAT_VERSION="2.4.1" CT_EXPAT_MIRRORS="http://downloads.sourceforge.net/project/expat/expat/${CT_EXPAT_VERSION}" CT_EXPAT_ARCHIVE_FILENAME="@{pkg_name}-@{version}" CT_EXPAT_ARCHIVE_DIRNAME="@{pkg_name}-@{version}" From c4aeccdf45fdf8e543929298c4ad5bcfc7e00111 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Tue, 17 Nov 2020 16:00:41 -0500 Subject: [PATCH 14/14] Ignore failures of RLS on aarch64 Windows --- src/bootstrap/dist.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 19895baf08f16..16d148db61814 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -1033,7 +1033,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 })?;