From f44d116e1f9a513b8730c1629bf17592bcd9784a Mon Sep 17 00:00:00 2001 From: cui fliter Date: Thu, 28 Sep 2023 16:15:41 +0800 Subject: [PATCH 01/10] Fix misuses of a vs an Signed-off-by: cui fliter --- compiler/rustc_ast/src/token.rs | 2 +- compiler/rustc_attr/src/builtin.rs | 2 +- compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs | 2 +- compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs | 4 ++-- compiler/rustc_borrowck/src/lib.rs | 2 +- compiler/rustc_borrowck/src/universal_regions.rs | 4 ++-- compiler/rustc_codegen_cranelift/src/abi/mod.rs | 2 +- compiler/rustc_codegen_llvm/src/type_.rs | 2 +- compiler/rustc_codegen_ssa/src/traits/type_.rs | 2 +- compiler/rustc_mir_build/src/build/expr/mod.rs | 2 +- compiler/rustc_ty_utils/src/abi.rs | 2 +- library/alloc/src/collections/btree/dedup_sorted_iter.rs | 2 +- src/doc/rustc/src/platform-support/mips-release-6.md | 2 +- tests/ui/codegen/issue-79865-llvm-miscompile.rs | 2 +- tests/ui/consts/const-adt-align-mismatch.rs | 2 +- tests/ui/debuginfo/sroa-fragment-debuginfo.rs | 2 +- 16 files changed, 18 insertions(+), 18 deletions(-) diff --git a/compiler/rustc_ast/src/token.rs b/compiler/rustc_ast/src/token.rs index 300b1486f9ba0..09bfbd02198c0 100644 --- a/compiler/rustc_ast/src/token.rs +++ b/compiler/rustc_ast/src/token.rs @@ -446,7 +446,7 @@ impl Token { } } - /// Returns `true` if the token can appear at the start of an pattern. + /// Returns `true` if the token can appear at the start of a pattern. /// /// Shamelessly borrowed from `can_begin_expr`, only used for diagnostics right now. pub fn can_begin_pattern(&self) -> bool { diff --git a/compiler/rustc_attr/src/builtin.rs b/compiler/rustc_attr/src/builtin.rs index ca4b3662a089f..8f146eb065328 100644 --- a/compiler/rustc_attr/src/builtin.rs +++ b/compiler/rustc_attr/src/builtin.rs @@ -162,7 +162,7 @@ pub enum StabilityLevel { is_soft: bool, /// If part of a feature is stabilized and a new feature is added for the remaining parts, /// then the `implied_by` attribute is used to indicate which now-stable feature previously - /// contained a item. + /// contained an item. /// /// ```pseudo-Rust /// #[unstable(feature = "foo", issue = "...")] diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index 48d09f2c2b2a4..a9586a0bf3098 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -1364,7 +1364,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { err.note(format!( "a for loop advances the iterator for you, the result is stored in `{loop_bind}`." )); - err.help("if you want to call `next` on a iterator within the loop, consider using `while let`."); + err.help("if you want to call `next` on an iterator within the loop, consider using `while let`."); } } diff --git a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs index a0edeec59d058..e3f3e7432fd94 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs @@ -1358,9 +1358,9 @@ fn suggest_ampmut<'tcx>( None => (false, decl_span), }; - // if the binding already exists and is a reference with a explicit + // if the binding already exists and is a reference with an explicit // lifetime, then we can suggest adding ` mut`. this is special-cased from - // the path without a explicit lifetime. + // the path without an explicit lifetime. if let Ok(src) = tcx.sess.source_map().span_to_snippet(span) && src.starts_with("&'") // note that `& 'a T` is invalid so this is correct. diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs index 8115c61e89d30..1c982a1ce167e 100644 --- a/compiler/rustc_borrowck/src/lib.rs +++ b/compiler/rustc_borrowck/src/lib.rs @@ -1966,7 +1966,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { Reservation(WriteKind::MutableBorrow(BorrowKind::Mut { kind: mut_borrow_kind })) | Write(WriteKind::MutableBorrow(BorrowKind::Mut { kind: mut_borrow_kind })) => { let is_local_mutation_allowed = match mut_borrow_kind { - // `ClosureCapture` is used for mutable variable with a immutable binding. + // `ClosureCapture` is used for mutable variable with an immutable binding. // This is only behaviour difference between `ClosureCapture` and mutable borrows. MutBorrowKind::ClosureCapture => LocalMutationIsAllowed::Yes, MutBorrowKind::Default | MutBorrowKind::TwoPhaseBorrow => { diff --git a/compiler/rustc_borrowck/src/universal_regions.rs b/compiler/rustc_borrowck/src/universal_regions.rs index af437f36b9f84..c73192f440451 100644 --- a/compiler/rustc_borrowck/src/universal_regions.rs +++ b/compiler/rustc_borrowck/src/universal_regions.rs @@ -164,7 +164,7 @@ struct UniversalRegionIndices<'tcx> { /// be able to map them to our internal `RegionVid`. This is /// basically equivalent to an `GenericArgs`, except that it also /// contains an entry for `ReStatic` -- it might be nice to just - /// use a args, and then handle `ReStatic` another way. + /// use an args, and then handle `ReStatic` another way. indices: FxHashMap, RegionVid>, /// The vid assigned to `'static`. Used only for diagnostics. @@ -290,7 +290,7 @@ impl<'tcx> UniversalRegions<'tcx> { (FIRST_GLOBAL_INDEX..self.num_universals).map(RegionVid::from_usize) } - /// Returns `true` if `r` is classified as an local region. + /// Returns `true` if `r` is classified as a local region. pub fn is_local_free_region(&self, r: RegionVid) -> bool { self.region_classification(r) == Some(RegionClassification::Local) } diff --git a/compiler/rustc_codegen_cranelift/src/abi/mod.rs b/compiler/rustc_codegen_cranelift/src/abi/mod.rs index 5d775b9b53229..5c7d7b20c5de2 100644 --- a/compiler/rustc_codegen_cranelift/src/abi/mod.rs +++ b/compiler/rustc_codegen_cranelift/src/abi/mod.rs @@ -30,7 +30,7 @@ fn clif_sig_from_fn_abi<'tcx>( let inputs = fn_abi.args.iter().flat_map(|arg_abi| arg_abi.get_abi_param(tcx).into_iter()); let (return_ptr, returns) = fn_abi.ret.get_abi_return(tcx); - // Sometimes the first param is an pointer to the place where the return value needs to be stored. + // Sometimes the first param is a pointer to the place where the return value needs to be stored. let params: Vec<_> = return_ptr.into_iter().chain(inputs).collect(); Signature { params, returns, call_conv } diff --git a/compiler/rustc_codegen_llvm/src/type_.rs b/compiler/rustc_codegen_llvm/src/type_.rs index 8db6195d931f0..06b7703672fe8 100644 --- a/compiler/rustc_codegen_llvm/src/type_.rs +++ b/compiler/rustc_codegen_llvm/src/type_.rs @@ -112,7 +112,7 @@ impl<'ll> CodegenCx<'ll, '_> { } } - /// Return a LLVM type that has at most the required alignment, + /// Return an LLVM type that has at most the required alignment, /// and exactly the required size, as a best-effort padding array. pub(crate) fn type_padding_filler(&self, size: Size, align: Align) -> &'ll Type { let unit = Integer::approximate_align(self, align); diff --git a/compiler/rustc_codegen_ssa/src/traits/type_.rs b/compiler/rustc_codegen_ssa/src/traits/type_.rs index dc3dbd9d81949..b1fde8e4d8638 100644 --- a/compiler/rustc_codegen_ssa/src/traits/type_.rs +++ b/compiler/rustc_codegen_ssa/src/traits/type_.rs @@ -30,7 +30,7 @@ pub trait BaseTypeMethods<'tcx>: Backend<'tcx> { fn type_ptr_ext(&self, address_space: AddressSpace) -> Self::Type; fn element_type(&self, ty: Self::Type) -> Self::Type; - /// Returns the number of elements in `self` if it is a LLVM vector type. + /// Returns the number of elements in `self` if it is an LLVM vector type. fn vector_length(&self, ty: Self::Type) -> usize; fn float_width(&self, ty: Self::Type) -> usize; diff --git a/compiler/rustc_mir_build/src/build/expr/mod.rs b/compiler/rustc_mir_build/src/build/expr/mod.rs index f5ae060d603f6..dfe85b858cd0d 100644 --- a/compiler/rustc_mir_build/src/build/expr/mod.rs +++ b/compiler/rustc_mir_build/src/build/expr/mod.rs @@ -44,7 +44,7 @@ //! the most suitable spot to implement it, and then just let the //! other fns cycle around. The handoff works like this: //! -//! - `into(place)` -> fallback is to create a rvalue with `as_rvalue` and assign it to `place` +//! - `into(place)` -> fallback is to create an rvalue with `as_rvalue` and assign it to `place` //! - `as_rvalue` -> fallback is to create an Operand with `as_operand` and use `Rvalue::use` //! - `as_operand` -> either invokes `as_constant` or `as_temp` //! - `as_constant` -> (no fallback) diff --git a/compiler/rustc_ty_utils/src/abi.rs b/compiler/rustc_ty_utils/src/abi.rs index 16183403d67aa..b118ddaab2b8d 100644 --- a/compiler/rustc_ty_utils/src/abi.rs +++ b/compiler/rustc_ty_utils/src/abi.rs @@ -528,7 +528,7 @@ fn fn_abi_adjust_for_abi<'tcx>( arg.make_indirect(); } else { // We want to pass small aggregates as immediates, but using - // a LLVM aggregate type for this leads to bad optimizations, + // an LLVM aggregate type for this leads to bad optimizations, // so we pick an appropriately sized integer type instead. arg.cast_to(Reg { kind: RegKind::Integer, size }); } diff --git a/library/alloc/src/collections/btree/dedup_sorted_iter.rs b/library/alloc/src/collections/btree/dedup_sorted_iter.rs index 17ee78045a9b2..cd6a88f329125 100644 --- a/library/alloc/src/collections/btree/dedup_sorted_iter.rs +++ b/library/alloc/src/collections/btree/dedup_sorted_iter.rs @@ -1,6 +1,6 @@ use core::iter::Peekable; -/// A iterator for deduping the key of a sorted iterator. +/// An iterator for deduping the key of a sorted iterator. /// When encountering the duplicated key, only the last key-value pair is yielded. /// /// Used by [`BTreeMap::bulk_build_from_sorted_iter`][1]. diff --git a/src/doc/rustc/src/platform-support/mips-release-6.md b/src/doc/rustc/src/platform-support/mips-release-6.md index 3f1912fc6f951..9203a31e9f4e7 100644 --- a/src/doc/rustc/src/platform-support/mips-release-6.md +++ b/src/doc/rustc/src/platform-support/mips-release-6.md @@ -67,7 +67,7 @@ The following procedure outlines the build process for the MIPS64 R6 target with ### Prerequisite: Disable debuginfo -A LLVM bug makes rustc crash if debug or debug info generation is enabled. You need to edit `config.toml` to disable this: +An LLVM bug makes rustc crash if debug or debug info generation is enabled. You need to edit `config.toml` to disable this: ```toml [rust] diff --git a/tests/ui/codegen/issue-79865-llvm-miscompile.rs b/tests/ui/codegen/issue-79865-llvm-miscompile.rs index b77f09f8e9a70..6f994a5cb741b 100644 --- a/tests/ui/codegen/issue-79865-llvm-miscompile.rs +++ b/tests/ui/codegen/issue-79865-llvm-miscompile.rs @@ -4,7 +4,7 @@ // Regression test for issue #79865. // The assertion will fail when compiled with Rust 1.56..=1.59 -// due to a LLVM miscompilation. +// due to an LLVM miscompilation. use std::arch::x86_64::*; diff --git a/tests/ui/consts/const-adt-align-mismatch.rs b/tests/ui/consts/const-adt-align-mismatch.rs index bd51bc9f215b4..89b3a9b744bc0 100644 --- a/tests/ui/consts/const-adt-align-mismatch.rs +++ b/tests/ui/consts/const-adt-align-mismatch.rs @@ -12,7 +12,7 @@ enum Foo { } // NOTE(eddyb) Don't make this a const, needs to be a static -// so it is always instantiated as a LLVM constant value. +// so it is always instantiated as an LLVM constant value. static FOO: Foo = Foo::C; fn main() { diff --git a/tests/ui/debuginfo/sroa-fragment-debuginfo.rs b/tests/ui/debuginfo/sroa-fragment-debuginfo.rs index 9c3c359e395d5..fc3bbb88efe83 100644 --- a/tests/ui/debuginfo/sroa-fragment-debuginfo.rs +++ b/tests/ui/debuginfo/sroa-fragment-debuginfo.rs @@ -1,4 +1,4 @@ -// Verify that we do not trigger a LLVM assertion by creating zero-sized DWARF fragments. +// Verify that we do not trigger an LLVM assertion by creating zero-sized DWARF fragments. // // build-pass // compile-flags: -g -Zmir-opt-level=0 -Zmir-enable-passes=+ScalarReplacementOfAggregates From a198aff4a4b1b83476497438cfc4771fb19c7bc4 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Wed, 4 Oct 2023 12:08:47 -0700 Subject: [PATCH 02/10] Add `crate_name` to test so that it can be renamed --- tests/rustdoc/issue-21092.rs | 2 ++ tests/rustdoc/issue-21474.rs | 2 ++ tests/rustdoc/issue-21801.rs | 2 ++ tests/rustdoc/issue-22025.rs | 2 ++ tests/rustdoc/issue-22038.rs | 2 ++ tests/rustdoc/issue-23106.rs | 2 ++ tests/rustdoc/issue-23207.rs | 2 ++ tests/rustdoc/issue-23511.rs | 2 ++ tests/rustdoc/issue-23744.rs | 2 ++ tests/rustdoc/issue-23812.rs | 2 ++ tests/rustdoc/issue-25001.rs | 2 ++ tests/rustdoc/issue-25944.rs | 2 ++ tests/rustdoc/issue-26606.rs | 4 +++- tests/rustdoc/issue-26995.rs | 2 ++ tests/rustdoc/issue-27104.rs | 2 ++ tests/rustdoc/issue-27362.rs | 2 ++ tests/rustdoc/issue-27759.rs | 2 ++ tests/rustdoc/issue-27862.rs | 2 ++ tests/rustdoc/issue-28478.rs | 2 ++ tests/rustdoc/issue-28927.rs | 2 ++ 20 files changed, 41 insertions(+), 1 deletion(-) diff --git a/tests/rustdoc/issue-21092.rs b/tests/rustdoc/issue-21092.rs index b054145a4831a..214be755e94f5 100644 --- a/tests/rustdoc/issue-21092.rs +++ b/tests/rustdoc/issue-21092.rs @@ -1,6 +1,8 @@ // aux-build:issue-21092.rs // ignore-cross-compile +#![crate_name="issue_21092"] + extern crate issue_21092; // @has issue_21092/struct.Bar.html diff --git a/tests/rustdoc/issue-21474.rs b/tests/rustdoc/issue-21474.rs index 5de26abace6fa..bedf89236aae2 100644 --- a/tests/rustdoc/issue-21474.rs +++ b/tests/rustdoc/issue-21474.rs @@ -1,3 +1,5 @@ +#![crate_name="issue_21474"] + pub use inner::*; mod inner { diff --git a/tests/rustdoc/issue-21801.rs b/tests/rustdoc/issue-21801.rs index 29d2ec64c206d..131bf38c3cb75 100644 --- a/tests/rustdoc/issue-21801.rs +++ b/tests/rustdoc/issue-21801.rs @@ -1,6 +1,8 @@ // aux-build:issue-21801.rs // ignore-cross-compile +#![crate_name="issue_21801"] + extern crate issue_21801; // @has issue_21801/struct.Foo.html diff --git a/tests/rustdoc/issue-22025.rs b/tests/rustdoc/issue-22025.rs index a721a15f463b4..d01c1f5c427b9 100644 --- a/tests/rustdoc/issue-22025.rs +++ b/tests/rustdoc/issue-22025.rs @@ -1,6 +1,8 @@ // aux-build:issue-22025.rs // ignore-cross-compile +#![crate_name="issue_22025"] + extern crate issue_22025; pub use issue_22025::foo::{Foo, Bar}; diff --git a/tests/rustdoc/issue-22038.rs b/tests/rustdoc/issue-22038.rs index de6cc78707c6d..52c9280f82676 100644 --- a/tests/rustdoc/issue-22038.rs +++ b/tests/rustdoc/issue-22038.rs @@ -1,3 +1,5 @@ +#![crate_name="issue_22038"] + extern "C" { // @has issue_22038/fn.foo1.html \ // '//pre[@class="rust item-decl"]' 'pub unsafe extern "C" fn foo1()' diff --git a/tests/rustdoc/issue-23106.rs b/tests/rustdoc/issue-23106.rs index 8cda2fc33805d..27c0bd0913045 100644 --- a/tests/rustdoc/issue-23106.rs +++ b/tests/rustdoc/issue-23106.rs @@ -1,5 +1,7 @@ // compile-flags:--test +#![crate_name="issue_23106"] + /// ``` /// # /// ``` diff --git a/tests/rustdoc/issue-23207.rs b/tests/rustdoc/issue-23207.rs index 1a4b849ee8209..24cba4ad2942b 100644 --- a/tests/rustdoc/issue-23207.rs +++ b/tests/rustdoc/issue-23207.rs @@ -2,6 +2,8 @@ // aux-build:issue-23207-2.rs // ignore-cross-compile +#![crate_name="issue_23207"] + extern crate issue_23207_2; // @has issue_23207/fmt/index.html diff --git a/tests/rustdoc/issue-23511.rs b/tests/rustdoc/issue-23511.rs index 21d02842431d0..d6b931850e2b5 100644 --- a/tests/rustdoc/issue-23511.rs +++ b/tests/rustdoc/issue-23511.rs @@ -2,6 +2,8 @@ #![feature(rustdoc_internals)] #![no_std] +#![crate_name="issue_23511"] + pub mod str { #![rustc_doc_primitive = "str"] diff --git a/tests/rustdoc/issue-23744.rs b/tests/rustdoc/issue-23744.rs index 642817396b2a0..45cc1bf3f4142 100644 --- a/tests/rustdoc/issue-23744.rs +++ b/tests/rustdoc/issue-23744.rs @@ -1,5 +1,7 @@ // compile-flags:--test +#![crate_name="issue_23744"] + /// Example of rustdoc incorrectly parsing ```rust,should_panic. /// /// ```should_panic diff --git a/tests/rustdoc/issue-23812.rs b/tests/rustdoc/issue-23812.rs index 08fd1833bcef3..43b422fc9928e 100644 --- a/tests/rustdoc/issue-23812.rs +++ b/tests/rustdoc/issue-23812.rs @@ -1,3 +1,5 @@ +#![crate_name="issue_23812"] + macro_rules! doc { (#[$outer:meta] mod $i:ident { #![$inner:meta] }) => ( diff --git a/tests/rustdoc/issue-25001.rs b/tests/rustdoc/issue-25001.rs index 268fae59496ac..d20268f176cec 100644 --- a/tests/rustdoc/issue-25001.rs +++ b/tests/rustdoc/issue-25001.rs @@ -1,3 +1,5 @@ +#![crate_name="issue_25001"] + // @has issue_25001/struct.Foo.html pub struct Foo(T); diff --git a/tests/rustdoc/issue-25944.rs b/tests/rustdoc/issue-25944.rs index 49625294bbea0..17f3431593024 100644 --- a/tests/rustdoc/issue-25944.rs +++ b/tests/rustdoc/issue-25944.rs @@ -1,5 +1,7 @@ // compile-flags:--test +#![crate_name="issue_25944"] + /// ``` /// let a = r#" /// foo diff --git a/tests/rustdoc/issue-26606.rs b/tests/rustdoc/issue-26606.rs index d5cb2c710cde8..1b62b32a4a705 100644 --- a/tests/rustdoc/issue-26606.rs +++ b/tests/rustdoc/issue-26606.rs @@ -2,10 +2,12 @@ // ignore-cross-compile // build-aux-docs +#![crate_name="issue_26606"] + // @has issue_26606_macro/macro.make_item.html #[macro_use] extern crate issue_26606_macro; // @has issue_26606/constant.FOO.html -// @has - '//a[@href="../src/issue_26606/issue-26606.rs.html#11"]' 'source' +// @has - '//a[@href="../src/issue_26606/issue-26606.rs.html#13"]' 'source' make_item!(FOO); diff --git a/tests/rustdoc/issue-26995.rs b/tests/rustdoc/issue-26995.rs index fedc9f5174920..e2cad215d6775 100644 --- a/tests/rustdoc/issue-26995.rs +++ b/tests/rustdoc/issue-26995.rs @@ -1,6 +1,8 @@ // ignore-windows // compile-flags: --no-defaults +#![crate_name="issue_26995"] + // @has src/issue_26995/dev/null.html // @has issue_26995/null/index.html '//a/@href' '../../src/issue_26995/dev/null.html' #[path="/dev/null"] diff --git a/tests/rustdoc/issue-27104.rs b/tests/rustdoc/issue-27104.rs index 9f2fd9071144f..220df629686ef 100644 --- a/tests/rustdoc/issue-27104.rs +++ b/tests/rustdoc/issue-27104.rs @@ -2,6 +2,8 @@ // aux-build:empty.rs // ignore-cross-compile +#![crate_name="issue_27104"] + // @has issue_27104/index.html // @!hasraw - 'extern crate std' // @!hasraw - 'use std::prelude::' diff --git a/tests/rustdoc/issue-27362.rs b/tests/rustdoc/issue-27362.rs index 097e4e3b03d9d..d2e8879dd25f5 100644 --- a/tests/rustdoc/issue-27362.rs +++ b/tests/rustdoc/issue-27362.rs @@ -1,6 +1,8 @@ // aux-build:issue-27362-aux.rs // ignore-cross-compile +#![crate_name="issue_27362"] + extern crate issue_27362_aux; pub use issue_27362_aux::*; diff --git a/tests/rustdoc/issue-27759.rs b/tests/rustdoc/issue-27759.rs index 65e0f7cb87b0c..28ea515d81f44 100644 --- a/tests/rustdoc/issue-27759.rs +++ b/tests/rustdoc/issue-27759.rs @@ -1,3 +1,5 @@ +#![crate_name="issue_27759"] + #![feature(staged_api)] #![doc(issue_tracker_base_url = "http://issue_url/")] diff --git a/tests/rustdoc/issue-27862.rs b/tests/rustdoc/issue-27862.rs index 77522f1be2307..19adcb9450802 100644 --- a/tests/rustdoc/issue-27862.rs +++ b/tests/rustdoc/issue-27862.rs @@ -1,3 +1,5 @@ +#![crate_name="issue_27862"] + /// Tests | Table /// ------|------------- /// t = b | id = \|x\| x diff --git a/tests/rustdoc/issue-28478.rs b/tests/rustdoc/issue-28478.rs index 497276e6826a1..60ba9090f71db 100644 --- a/tests/rustdoc/issue-28478.rs +++ b/tests/rustdoc/issue-28478.rs @@ -1,3 +1,5 @@ +#![crate_name="issue_28478"] + #![feature(associated_type_defaults)] // @has issue_28478/trait.Bar.html diff --git a/tests/rustdoc/issue-28927.rs b/tests/rustdoc/issue-28927.rs index 38a520850b6dd..ca07add2ba8da 100644 --- a/tests/rustdoc/issue-28927.rs +++ b/tests/rustdoc/issue-28927.rs @@ -2,5 +2,7 @@ // aux-build:issue-28927-1.rs // ignore-cross-compile +#![crate_name="issue_28927"] + pub extern crate issue_28927_1 as inner1; pub use inner1 as foo; From 867cc41b5b2f0e84de6a1fd10099e9383cecc807 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Wed, 4 Oct 2023 19:10:35 +0200 Subject: [PATCH 03/10] clean up struct field suggestions --- compiler/rustc_hir_typeck/src/expr.rs | 100 +++++------------- .../src/fn_ctxt/suggestions.rs | 19 ++++ compiler/rustc_hir_typeck/src/pat.rs | 41 +++---- .../auxiliary/doc-hidden-fields.rs | 6 ++ .../dont-suggest-doc-hidden-fields.rs | 38 +++++++ .../dont-suggest-doc-hidden-fields.stderr | 27 +++++ .../dont-suggest-hygienic-fields.rs | 47 ++++++++ .../dont-suggest-hygienic-fields.stderr | 50 +++++++++ .../issue-93210-ignore-doc-hidden.rs | 24 ----- .../issue-93210-ignore-doc-hidden.stderr | 19 ---- 10 files changed, 226 insertions(+), 145 deletions(-) create mode 100644 tests/ui/did_you_mean/auxiliary/doc-hidden-fields.rs create mode 100644 tests/ui/did_you_mean/dont-suggest-doc-hidden-fields.rs create mode 100644 tests/ui/did_you_mean/dont-suggest-doc-hidden-fields.stderr create mode 100644 tests/ui/did_you_mean/dont-suggest-hygienic-fields.rs create mode 100644 tests/ui/did_you_mean/dont-suggest-hygienic-fields.stderr delete mode 100644 tests/ui/did_you_mean/issue-93210-ignore-doc-hidden.rs delete mode 100644 tests/ui/did_you_mean/issue-93210-ignore-doc-hidden.stderr diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index eead4da5e3ef8..d9d0dd93010c7 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -41,7 +41,6 @@ use rustc_infer::infer::DefineOpaqueTypes; use rustc_infer::infer::InferOk; use rustc_infer::traits::query::NoSolution; use rustc_infer::traits::ObligationCause; -use rustc_middle::middle::stability; use rustc_middle::ty::adjustment::{Adjust, Adjustment, AllowTwoPhase}; use rustc_middle::ty::error::{ ExpectedFound, @@ -1585,12 +1584,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.check_expr_struct_fields( adt_ty, expected, - expr.hir_id, + expr, qpath.span(), variant, fields, base_expr, - expr.span, ); self.require_type_is_sized(adt_ty, expr.span, traits::StructInitializerSized); @@ -1601,12 +1599,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &self, adt_ty: Ty<'tcx>, expected: Expectation<'tcx>, - expr_id: hir::HirId, + expr: &hir::Expr<'_>, span: Span, variant: &'tcx ty::VariantDef, ast_fields: &'tcx [hir::ExprField<'tcx>], base_expr: &'tcx Option<&'tcx hir::Expr<'tcx>>, - expr_span: Span, ) { let tcx = self.tcx; @@ -1646,7 +1643,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // struct-like enums (yet...), but it's definitely not // a bug to have constructed one. if adt_kind != AdtKind::Enum { - tcx.check_stability(v_field.did, Some(expr_id), field.span, None); + tcx.check_stability(v_field.did, Some(expr.hir_id), field.span, None); } self.field_ty(field.span, v_field, args) @@ -1662,10 +1659,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.report_unknown_field( adt_ty, variant, + expr, field, ast_fields, adt.variant_descr(), - expr_span, ) }; @@ -1731,7 +1728,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .iter() .map(|f| { let fru_ty = self - .normalize(expr_span, self.field_ty(base_expr.span, f, fresh_args)); + .normalize(expr.span, self.field_ty(base_expr.span, f, fresh_args)); let ident = self.tcx.adjust_ident(f.ident(self.tcx), variant.def_id); if let Some(_) = remaining_fields.remove(&ident) { let target_ty = self.field_ty(base_expr.span, f, args); @@ -1814,7 +1811,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ty::Adt(adt, args) if adt.is_struct() => variant .fields .iter() - .map(|f| self.normalize(expr_span, f.ty(self.tcx, args))) + .map(|f| self.normalize(expr.span, f.ty(self.tcx, args))) .collect(), _ => { self.tcx @@ -1824,13 +1821,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } }; - self.typeck_results.borrow_mut().fru_field_types_mut().insert(expr_id, fru_tys); + self.typeck_results.borrow_mut().fru_field_types_mut().insert(expr.hir_id, fru_tys); } else if adt_kind != AdtKind::Union && !remaining_fields.is_empty() { debug!(?remaining_fields); let private_fields: Vec<&ty::FieldDef> = variant .fields .iter() - .filter(|field| !field.vis.is_accessible_from(tcx.parent_module(expr_id), tcx)) + .filter(|field| !field.vis.is_accessible_from(tcx.parent_module(expr.hir_id), tcx)) .collect(); if !private_fields.is_empty() { @@ -2049,16 +2046,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &self, ty: Ty<'tcx>, variant: &'tcx ty::VariantDef, + expr: &hir::Expr<'_>, field: &hir::ExprField<'_>, skip_fields: &[hir::ExprField<'_>], kind_name: &str, - expr_span: Span, ) -> ErrorGuaranteed { if variant.is_recovered() { let guar = self .tcx .sess - .delay_span_bug(expr_span, "parser recovered but no error was emitted"); + .delay_span_bug(expr.span, "parser recovered but no error was emitted"); self.set_tainted_by_errors(guar); return guar; } @@ -2102,7 +2099,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); err.span_label(field.ident.span, "field does not exist"); err.span_suggestion_verbose( - expr_span, + expr.span, format!( "`{adt}::{variant}` is a tuple {kind_name}, use the appropriate syntax", adt = ty, @@ -2120,7 +2117,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err.span_label(variant_ident_span, format!("`{ty}` defined here")); err.span_label(field.ident.span, "field does not exist"); err.span_suggestion_verbose( - expr_span, + expr.span, format!("`{ty}` is a tuple {kind_name}, use the appropriate syntax",), format!("{ty}(/* fields */)"), Applicability::HasPlaceholders, @@ -2129,9 +2126,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }, _ => { // prevent all specified fields from being suggested - let skip_fields: Vec<_> = skip_fields.iter().map(|x| x.ident.name).collect(); + let available_field_names = self.available_field_names(variant, expr, skip_fields); if let Some(field_name) = - self.suggest_field_name(variant, field.ident.name, &skip_fields, expr_span) + find_best_match_for_name(&available_field_names, field.ident.name, None) { err.span_suggestion( field.ident.span, @@ -2153,10 +2150,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { format!("`{ty}` does not have this field"), ); } - let mut available_field_names = - self.available_field_names(variant, expr_span); - available_field_names - .retain(|name| skip_fields.iter().all(|skip| name != skip)); if available_field_names.is_empty() { err.note("all struct fields are already assigned"); } else { @@ -2174,63 +2167,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err.emit() } - // Return a hint about the closest match in field names - fn suggest_field_name( - &self, - variant: &'tcx ty::VariantDef, - field: Symbol, - skip: &[Symbol], - // The span where stability will be checked - span: Span, - ) -> Option { - let names = variant - .fields - .iter() - .filter_map(|field| { - // ignore already set fields and private fields from non-local crates - // and unstable fields. - if skip.iter().any(|&x| x == field.name) - || (!variant.def_id.is_local() && !field.vis.is_public()) - || matches!( - self.tcx.eval_stability(field.did, None, span, None), - stability::EvalResult::Deny { .. } - ) - { - None - } else { - Some(field.name) - } - }) - .collect::>(); - - find_best_match_for_name(&names, field, None) - } - fn available_field_names( &self, variant: &'tcx ty::VariantDef, - access_span: Span, + expr: &hir::Expr<'_>, + skip_fields: &[hir::ExprField<'_>], ) -> Vec { - let body_owner_hir_id = self.tcx.hir().local_def_id_to_hir_id(self.body_id); variant .fields .iter() .filter(|field| { - let def_scope = self - .tcx - .adjust_ident_and_get_scope( - field.ident(self.tcx), - variant.def_id, - body_owner_hir_id, - ) - .1; - field.vis.is_accessible_from(def_scope, self.tcx) - && !matches!( - self.tcx.eval_stability(field.did, None, access_span, None), - stability::EvalResult::Deny { .. } - ) + skip_fields.iter().all(|&skip| skip.ident.name != field.name) + && self.is_field_suggestable(field, expr.hir_id, expr.span) }) - .filter(|field| !self.tcx.is_doc_hidden(field.did)) .map(|field| field.name) .collect() } @@ -2460,7 +2409,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.suggest_first_deref_field(&mut err, expr, base, ident); } ty::Adt(def, _) if !def.is_enum() => { - self.suggest_fields_on_recordish(&mut err, def, ident, expr.span); + self.suggest_fields_on_recordish(&mut err, expr, def, ident); } ty::Param(param_ty) => { self.point_at_param_definition(&mut err, param_ty); @@ -2622,12 +2571,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn suggest_fields_on_recordish( &self, err: &mut Diagnostic, + expr: &hir::Expr<'_>, def: ty::AdtDef<'tcx>, field: Ident, - access_span: Span, ) { + let available_field_names = self.available_field_names(def.non_enum_variant(), expr, &[]); if let Some(suggested_field_name) = - self.suggest_field_name(def.non_enum_variant(), field.name, &[], access_span) + find_best_match_for_name(&available_field_names, field.name, None) { err.span_suggestion( field.span, @@ -2637,12 +2587,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); } else { err.span_label(field.span, "unknown field"); - let struct_variant_def = def.non_enum_variant(); - let field_names = self.available_field_names(struct_variant_def, access_span); - if !field_names.is_empty() { + if !available_field_names.is_empty() { err.note(format!( "available fields are: {}", - self.name_series_display(field_names), + self.name_series_display(available_field_names), )); } } diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs index abb689892183c..5aef7cf3432f3 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs @@ -1687,4 +1687,23 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { false } } + + pub(crate) fn is_field_suggestable( + &self, + field: &ty::FieldDef, + hir_id: HirId, + span: Span, + ) -> bool { + // The field must be visible in the containing module. + field.vis.is_accessible_from(self.tcx.parent_module(hir_id), self.tcx) + // The field must not be unstable. + && !matches!( + self.tcx.eval_stability(field.did, None, rustc_span::DUMMY_SP, None), + rustc_middle::middle::stability::EvalResult::Deny { .. } + ) + // If the field is from an external crate it must not be `doc(hidden)`. + && (field.did.is_local() || !self.tcx.is_doc_hidden(field.did)) + // If the field is hygienic it must come from the same syntax context. + && self.tcx.def_ident_span(field.did).unwrap().normalize_to_macros_2_0().eq_ctxt(span) + } } diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs index 8fc236f46b226..3f9c9b3381baa 100644 --- a/compiler/rustc_hir_typeck/src/pat.rs +++ b/compiler/rustc_hir_typeck/src/pat.rs @@ -12,7 +12,6 @@ use rustc_hir::pat_util::EnumerateAndAdjustIterator; use rustc_hir::{HirId, Pat, PatKind}; use rustc_infer::infer; use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; -use rustc_middle::middle::stability::EvalResult; use rustc_middle::ty::{self, Adt, BindingMode, Ty, TypeVisitableExt}; use rustc_session::lint::builtin::NON_EXHAUSTIVE_OMITTED_PATTERNS; use rustc_span::edit_distance::find_best_match_for_name; @@ -1408,6 +1407,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { adt.variant_descr(), &inexistent_fields, &mut unmentioned_fields, + pat, variant, args, )) @@ -1434,15 +1434,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let accessible_unmentioned_fields: Vec<_> = unmentioned_fields .iter() .copied() - .filter(|(field, _)| { - field.vis.is_accessible_from(tcx.parent_module(pat.hir_id), tcx) - && !matches!( - tcx.eval_stability(field.did, None, DUMMY_SP, None), - EvalResult::Deny { .. } - ) - // We only want to report the error if it is hidden and not local - && !(tcx.is_doc_hidden(field.did) && !field.did.is_local()) - }) + .filter(|(field, _)| self.is_field_suggestable(field, pat.hir_id, pat.span)) .collect(); if !has_rest_pat { @@ -1578,12 +1570,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { kind_name: &str, inexistent_fields: &[&hir::PatField<'tcx>], unmentioned_fields: &mut Vec<(&'tcx ty::FieldDef, Ident)>, + pat: &'tcx Pat<'tcx>, variant: &ty::VariantDef, args: &'tcx ty::List>, ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> { let tcx = self.tcx; - let (field_names, t, plural) = if inexistent_fields.len() == 1 { - (format!("a field named `{}`", inexistent_fields[0].ident), "this", "") + let (field_names, t, plural) = if let [field] = inexistent_fields { + (format!("a field named `{}`", field.ident), "this", "") } else { ( format!( @@ -1620,10 +1613,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ), ); - if unmentioned_fields.len() == 1 { - let input = - unmentioned_fields.iter().map(|(_, field)| field.name).collect::>(); - let suggested_name = find_best_match_for_name(&input, pat_field.ident.name, None); + if let [(field_def, field)] = unmentioned_fields.as_slice() + && self.is_field_suggestable(field_def, pat.hir_id, pat.span) + { + let suggested_name = + find_best_match_for_name(&[field.name], pat_field.ident.name, None); if let Some(suggested_name) = suggested_name { err.span_suggestion( pat_field.ident.span, @@ -1646,22 +1640,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { PatKind::Lit(expr) if !self.can_coerce( self.typeck_results.borrow().expr_ty(expr), - self.field_ty( - unmentioned_fields[0].1.span, - unmentioned_fields[0].0, - args, - ), + self.field_ty(field.span, field_def, args), ) => {} _ => { - let unmentioned_field = unmentioned_fields[0].1.name; err.span_suggestion_short( pat_field.ident.span, format!( "`{}` has a field named `{}`", tcx.def_path_str(variant.def_id), - unmentioned_field + field.name, ), - unmentioned_field.to_string(), + field.name, Applicability::MaybeIncorrect, ); } @@ -1871,8 +1860,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fields: &'tcx [hir::PatField<'tcx>], ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> { let inaccessible = if have_inaccessible_fields { " and inaccessible fields" } else { "" }; - let field_names = if unmentioned_fields.len() == 1 { - format!("field `{}`{}", unmentioned_fields[0].1, inaccessible) + let field_names = if let [(_, field)] = unmentioned_fields { + format!("field `{field}`{inaccessible}") } else { let fields = unmentioned_fields .iter() diff --git a/tests/ui/did_you_mean/auxiliary/doc-hidden-fields.rs b/tests/ui/did_you_mean/auxiliary/doc-hidden-fields.rs new file mode 100644 index 0000000000000..4e2ee97403c5c --- /dev/null +++ b/tests/ui/did_you_mean/auxiliary/doc-hidden-fields.rs @@ -0,0 +1,6 @@ +#[derive(Default)] +pub struct B { + #[doc(hidden)] + pub hello: i32, + pub bye: i32, +} diff --git a/tests/ui/did_you_mean/dont-suggest-doc-hidden-fields.rs b/tests/ui/did_you_mean/dont-suggest-doc-hidden-fields.rs new file mode 100644 index 0000000000000..6040f3f30a7b5 --- /dev/null +++ b/tests/ui/did_you_mean/dont-suggest-doc-hidden-fields.rs @@ -0,0 +1,38 @@ +// Regression test for issue #93210. + +// aux-crate:doc_hidden_fields=doc-hidden-fields.rs +// edition: 2021 + +#[derive(Default)] +pub struct A { + #[doc(hidden)] + pub hello: i32, + pub bye: i32, +} + +#[derive(Default)] +pub struct C { + pub hello: i32, + pub bye: i32, +} + +fn main() { + // We want to list the field `hello` despite being marked + // `doc(hidden)` because it's defined in this crate. + A::default().hey; + //~^ ERROR no field `hey` on type `A` + //~| NOTE unknown field + //~| NOTE available fields are: `hello`, `bye` + + // Here we want to hide the field `hello` since it's marked + // `doc(hidden)` and comes from an external crate. + doc_hidden_fields::B::default().hey; + //~^ ERROR no field `hey` on type `B` + //~| NOTE unknown field + //~| NOTE available fields are: `bye` + + C::default().hey; + //~^ ERROR no field `hey` on type `C` + //~| NOTE unknown field + //~| NOTE available fields are: `hello`, `bye` +} diff --git a/tests/ui/did_you_mean/dont-suggest-doc-hidden-fields.stderr b/tests/ui/did_you_mean/dont-suggest-doc-hidden-fields.stderr new file mode 100644 index 0000000000000..b7fe3b79b475b --- /dev/null +++ b/tests/ui/did_you_mean/dont-suggest-doc-hidden-fields.stderr @@ -0,0 +1,27 @@ +error[E0609]: no field `hey` on type `A` + --> $DIR/dont-suggest-doc-hidden-fields.rs:22:18 + | +LL | A::default().hey; + | ^^^ unknown field + | + = note: available fields are: `hello`, `bye` + +error[E0609]: no field `hey` on type `B` + --> $DIR/dont-suggest-doc-hidden-fields.rs:29:37 + | +LL | doc_hidden_fields::B::default().hey; + | ^^^ unknown field + | + = note: available fields are: `bye` + +error[E0609]: no field `hey` on type `C` + --> $DIR/dont-suggest-doc-hidden-fields.rs:34:18 + | +LL | C::default().hey; + | ^^^ unknown field + | + = note: available fields are: `hello`, `bye` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0609`. diff --git a/tests/ui/did_you_mean/dont-suggest-hygienic-fields.rs b/tests/ui/did_you_mean/dont-suggest-hygienic-fields.rs new file mode 100644 index 0000000000000..fb7040b2df095 --- /dev/null +++ b/tests/ui/did_you_mean/dont-suggest-hygienic-fields.rs @@ -0,0 +1,47 @@ +// Regression test for issue #116334. +// Don't include hygienic fields from different syntax contexts in +// the list of available or similarly named fields. + +#![feature(decl_macro)] + +macro compound($Ty:ident) { + #[derive(Default)] + struct $Ty { + field: u32, // field `field` is hygienic + } +} + +macro component($Ty:ident) { + struct $Ty(u64); // field `0` is hygienic (but still accessible via the constructor) +} + +compound! { Compound } +component! { Component } + +fn main() { + let ty = Compound::default(); + + let _ = ty.field; //~ ERROR no field `field` on type `Compound` + let _ = ty.fieeld; //~ ERROR no field `fieeld` on type `Compound` + + let Compound { field } = ty; + //~^ ERROR struct `Compound` does not have a field named `field` + //~| ERROR pattern requires `..` due to inaccessible fields + //~| HELP ignore the inaccessible and unused fields + + let ty = Component(90); + + let _ = ty.0; //~ ERROR no field `0` on type `Component` +} + +environment!(); + +macro environment() { + struct Crate { field: () } + + // Here, we do want to suggest `field` even though it's hygienic + // precisely because they come from the same syntax context. + const CRATE: Crate = Crate { fiel: () }; + //~^ ERROR struct `Crate` has no field named `fiel` + //~| HELP a field with a similar name exists +} diff --git a/tests/ui/did_you_mean/dont-suggest-hygienic-fields.stderr b/tests/ui/did_you_mean/dont-suggest-hygienic-fields.stderr new file mode 100644 index 0000000000000..7066d29760e7c --- /dev/null +++ b/tests/ui/did_you_mean/dont-suggest-hygienic-fields.stderr @@ -0,0 +1,50 @@ +error[E0560]: struct `Crate` has no field named `fiel` + --> $DIR/dont-suggest-hygienic-fields.rs:44:34 + | +LL | environment!(); + | -------------- in this macro invocation +... +LL | const CRATE: Crate = Crate { fiel: () }; + | ^^^^ help: a field with a similar name exists: `field` + | + = note: this error originates in the macro `environment` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0609]: no field `field` on type `Compound` + --> $DIR/dont-suggest-hygienic-fields.rs:24:16 + | +LL | let _ = ty.field; + | ^^^^^ unknown field + +error[E0609]: no field `fieeld` on type `Compound` + --> $DIR/dont-suggest-hygienic-fields.rs:25:16 + | +LL | let _ = ty.fieeld; + | ^^^^^^ unknown field + +error[E0026]: struct `Compound` does not have a field named `field` + --> $DIR/dont-suggest-hygienic-fields.rs:27:20 + | +LL | let Compound { field } = ty; + | ^^^^^ struct `Compound` does not have this field + +error: pattern requires `..` due to inaccessible fields + --> $DIR/dont-suggest-hygienic-fields.rs:27:9 + | +LL | let Compound { field } = ty; + | ^^^^^^^^^^^^^^^^^^ + | +help: ignore the inaccessible and unused fields + | +LL | let Compound { field, .. } = ty; + | ++++ + +error[E0609]: no field `0` on type `Component` + --> $DIR/dont-suggest-hygienic-fields.rs:34:16 + | +LL | let _ = ty.0; + | ^ unknown field + +error: aborting due to 6 previous errors + +Some errors have detailed explanations: E0026, E0560, E0609. +For more information about an error, try `rustc --explain E0026`. diff --git a/tests/ui/did_you_mean/issue-93210-ignore-doc-hidden.rs b/tests/ui/did_you_mean/issue-93210-ignore-doc-hidden.rs deleted file mode 100644 index 0efc7daa3e17b..0000000000000 --- a/tests/ui/did_you_mean/issue-93210-ignore-doc-hidden.rs +++ /dev/null @@ -1,24 +0,0 @@ -#[derive(Default)] -pub struct A { - #[doc(hidden)] - pub hello: i32, - pub bye: i32, -} - -#[derive(Default)] -pub struct B { - pub hello: i32, - pub bye: i32, -} - -fn main() { - A::default().hey; - //~^ ERROR no field `hey` on type `A` - //~| NOTE unknown field - //~| NOTE available fields are: `bye` - - B::default().hey; - //~^ ERROR no field `hey` on type `B` - //~| NOTE unknown field - //~| NOTE available fields are: `hello`, `bye` -} diff --git a/tests/ui/did_you_mean/issue-93210-ignore-doc-hidden.stderr b/tests/ui/did_you_mean/issue-93210-ignore-doc-hidden.stderr deleted file mode 100644 index 784986d3b95fb..0000000000000 --- a/tests/ui/did_you_mean/issue-93210-ignore-doc-hidden.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0609]: no field `hey` on type `A` - --> $DIR/issue-93210-ignore-doc-hidden.rs:15:18 - | -LL | A::default().hey; - | ^^^ unknown field - | - = note: available fields are: `bye` - -error[E0609]: no field `hey` on type `B` - --> $DIR/issue-93210-ignore-doc-hidden.rs:20:18 - | -LL | B::default().hey; - | ^^^ unknown field - | - = note: available fields are: `hello`, `bye` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0609`. From 041e54bd92abaadc8c26a619976f76a77d022a39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 4 Oct 2023 19:51:43 +0000 Subject: [PATCH 04/10] Tweak wording of E0562 Fix #80476. --- compiler/rustc_ast_lowering/messages.ftl | 2 +- .../ui/associated-consts/issue-105330.stderr | 2 +- .../async-await/in-trait/fn-not-async-err2.rs | 2 +- .../in-trait/fn-not-async-err2.stderr | 2 +- .../feature-gate-associated_type_bounds.rs | 6 +- ...feature-gate-associated_type_bounds.stderr | 6 +- ...ture-gate-impl_trait_in_fn_trait_return.rs | 4 +- ...-gate-impl_trait_in_fn_trait_return.stderr | 4 +- ...ate-return_position_impl_trait_in_trait.rs | 6 +- ...return_position_impl_trait_in_trait.stderr | 6 +- tests/ui/impl-trait/issues/issue-54600.rs | 2 +- tests/ui/impl-trait/issues/issue-54600.stderr | 2 +- tests/ui/impl-trait/issues/issue-54840.rs | 2 +- tests/ui/impl-trait/issues/issue-54840.stderr | 2 +- tests/ui/impl-trait/issues/issue-58504.rs | 2 +- tests/ui/impl-trait/issues/issue-58504.stderr | 2 +- tests/ui/impl-trait/issues/issue-58956.rs | 4 +- tests/ui/impl-trait/issues/issue-58956.stderr | 4 +- tests/ui/impl-trait/issues/issue-70971.rs | 2 +- tests/ui/impl-trait/issues/issue-70971.stderr | 2 +- tests/ui/impl-trait/issues/issue-79099.rs | 2 +- tests/ui/impl-trait/issues/issue-79099.stderr | 2 +- ...sue-83929-impl-trait-in-generic-default.rs | 4 +- ...83929-impl-trait-in-generic-default.stderr | 4 +- tests/ui/impl-trait/issues/issue-84919.rs | 2 +- tests/ui/impl-trait/issues/issue-84919.stderr | 2 +- tests/ui/impl-trait/issues/issue-86642.rs | 2 +- tests/ui/impl-trait/issues/issue-86642.stderr | 2 +- tests/ui/impl-trait/issues/issue-87295.rs | 2 +- tests/ui/impl-trait/issues/issue-87295.stderr | 2 +- tests/ui/impl-trait/nested_impl_trait.rs | 2 +- tests/ui/impl-trait/nested_impl_trait.stderr | 2 +- tests/ui/impl-trait/where-allowed.rs | 78 +++++++++---------- tests/ui/impl-trait/where-allowed.stderr | 78 +++++++++---------- tests/ui/issues/issue-47715.rs | 8 +- tests/ui/issues/issue-47715.stderr | 8 +- .../type-alias-impl-trait-fn-type.rs | 2 +- .../type-alias-impl-trait-fn-type.stderr | 2 +- tests/ui/typeck/issue-104513-ice.rs | 2 +- tests/ui/typeck/issue-104513-ice.stderr | 2 +- 40 files changed, 136 insertions(+), 136 deletions(-) diff --git a/compiler/rustc_ast_lowering/messages.ftl b/compiler/rustc_ast_lowering/messages.ftl index 8115c4b55b0af..aaeef1ff77d3d 100644 --- a/compiler/rustc_ast_lowering/messages.ftl +++ b/compiler/rustc_ast_lowering/messages.ftl @@ -99,7 +99,7 @@ ast_lowering_misplaced_double_dot = .note = only allowed in tuple, tuple struct, and slice patterns ast_lowering_misplaced_impl_trait = - `impl Trait` only allowed in function and inherent method return types, not in {$position} + `impl Trait` only allowed in function and inherent method argument and return types, not in {$position} ast_lowering_misplaced_relax_trait_bound = `?Trait` bounds are only permitted at the point where a type parameter is declared diff --git a/tests/ui/associated-consts/issue-105330.stderr b/tests/ui/associated-consts/issue-105330.stderr index 927422fa8dcaf..200856caa2518 100644 --- a/tests/ui/associated-consts/issue-105330.stderr +++ b/tests/ui/associated-consts/issue-105330.stderr @@ -33,7 +33,7 @@ LL | fn main>() { = note: see issue #92827 for more information = help: add `#![feature(associated_const_equality)]` to the crate attributes to enable -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in impl headers +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in impl headers --> $DIR/issue-105330.rs:6:27 | LL | impl TraitWAssocConst for impl Demo { diff --git a/tests/ui/async-await/in-trait/fn-not-async-err2.rs b/tests/ui/async-await/in-trait/fn-not-async-err2.rs index 78017429f73d5..e1703415dbd5a 100644 --- a/tests/ui/async-await/in-trait/fn-not-async-err2.rs +++ b/tests/ui/async-await/in-trait/fn-not-async-err2.rs @@ -11,7 +11,7 @@ trait MyTrait { impl MyTrait for i32 { fn foo(&self) -> impl Future { - //~^ ERROR `impl Trait` only allowed in function and inherent method return types, not in `impl` method return types + //~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types, not in `impl` method return types async { *self } } } diff --git a/tests/ui/async-await/in-trait/fn-not-async-err2.stderr b/tests/ui/async-await/in-trait/fn-not-async-err2.stderr index 37d9669c0124b..a7c897f786e4a 100644 --- a/tests/ui/async-await/in-trait/fn-not-async-err2.stderr +++ b/tests/ui/async-await/in-trait/fn-not-async-err2.stderr @@ -1,4 +1,4 @@ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `impl` method return types +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `impl` method return types --> $DIR/fn-not-async-err2.rs:13:22 | LL | fn foo(&self) -> impl Future { diff --git a/tests/ui/feature-gates/feature-gate-associated_type_bounds.rs b/tests/ui/feature-gates/feature-gate-associated_type_bounds.rs index 49fb10e602959..152c7a8de66a1 100644 --- a/tests/ui/feature-gates/feature-gate-associated_type_bounds.rs +++ b/tests/ui/feature-gates/feature-gate-associated_type_bounds.rs @@ -54,20 +54,20 @@ fn _rpit_dyn() -> Box> { Box::new(S1) } const _cdef: impl Tr1 = S1; //~^ ERROR associated type bounds are unstable -//~| ERROR `impl Trait` only allowed in function and inherent method return types +//~| ERROR `impl Trait` only allowed in function and inherent method argument and return types // FIXME: uncomment when `impl_trait_in_bindings` feature is fixed. // const _cdef_dyn: &dyn Tr1 = &S1; static _sdef: impl Tr1 = S1; //~^ ERROR associated type bounds are unstable -//~| ERROR `impl Trait` only allowed in function and inherent method return types +//~| ERROR `impl Trait` only allowed in function and inherent method argument and return types // FIXME: uncomment when `impl_trait_in_bindings` feature is fixed. // static _sdef_dyn: &dyn Tr1 = &S1; fn main() { let _: impl Tr1 = S1; //~^ ERROR associated type bounds are unstable - //~| ERROR `impl Trait` only allowed in function and inherent method return types + //~| ERROR `impl Trait` only allowed in function and inherent method argument and return types // FIXME: uncomment when `impl_trait_in_bindings` feature is fixed. // let _: &dyn Tr1 = &S1; } diff --git a/tests/ui/feature-gates/feature-gate-associated_type_bounds.stderr b/tests/ui/feature-gates/feature-gate-associated_type_bounds.stderr index 4233a8af9b6a6..f2bceda9bea71 100644 --- a/tests/ui/feature-gates/feature-gate-associated_type_bounds.stderr +++ b/tests/ui/feature-gates/feature-gate-associated_type_bounds.stderr @@ -115,19 +115,19 @@ LL | let _: impl Tr1 = S1; = note: see issue #52662 for more information = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in const types +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in const types --> $DIR/feature-gate-associated_type_bounds.rs:55:14 | LL | const _cdef: impl Tr1 = S1; | ^^^^^^^^^^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in const types +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in const types --> $DIR/feature-gate-associated_type_bounds.rs:61:15 | LL | static _sdef: impl Tr1 = S1; | ^^^^^^^^^^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable bindings +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in variable bindings --> $DIR/feature-gate-associated_type_bounds.rs:68:12 | LL | let _: impl Tr1 = S1; diff --git a/tests/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.rs b/tests/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.rs index 0db8088f7eea4..1b9530fa82f38 100644 --- a/tests/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.rs +++ b/tests/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.rs @@ -1,6 +1,6 @@ fn f() -> impl Fn() -> impl Sized { || () } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return +//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types, not in `Fn` trait return fn g() -> &'static dyn Fn() -> impl Sized { &|| () } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return +//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types, not in `Fn` trait return fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.stderr b/tests/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.stderr index c8c3e13d7fc5a..f0c0cd040e03c 100644 --- a/tests/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.stderr +++ b/tests/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.stderr @@ -1,4 +1,4 @@ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return types +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `Fn` trait return types --> $DIR/feature-gate-impl_trait_in_fn_trait_return.rs:1:24 | LL | fn f() -> impl Fn() -> impl Sized { || () } @@ -7,7 +7,7 @@ LL | fn f() -> impl Fn() -> impl Sized { || () } = note: see issue #99697 for more information = help: add `#![feature(impl_trait_in_fn_trait_return)]` to the crate attributes to enable -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return types +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `Fn` trait return types --> $DIR/feature-gate-impl_trait_in_fn_trait_return.rs:3:32 | LL | fn g() -> &'static dyn Fn() -> impl Sized { &|| () } diff --git a/tests/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.rs b/tests/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.rs index 637765fff11e4..a8d6365ca79ac 100644 --- a/tests/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.rs +++ b/tests/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.rs @@ -5,14 +5,14 @@ #![feature(async_fn_in_trait)] trait Foo { - fn bar() -> impl Sized; //~ ERROR `impl Trait` only allowed in function and inherent method return types, not in trait method return - fn baz() -> Box; //~ ERROR `impl Trait` only allowed in function and inherent method return types, not in trait method return + fn bar() -> impl Sized; //~ ERROR `impl Trait` only allowed in function and inherent method argument and return types, not in trait method return + fn baz() -> Box; //~ ERROR `impl Trait` only allowed in function and inherent method argument and return types, not in trait method return } // Both return_position_impl_trait_in_trait and async_fn_in_trait are required for this (see also // feature-gate-async_fn_in_trait.rs) trait AsyncFoo { - async fn bar() -> impl Sized; //~ ERROR `impl Trait` only allowed in function and inherent method return types, not in trait method return + async fn bar() -> impl Sized; //~ ERROR `impl Trait` only allowed in function and inherent method argument and return types, not in trait method return } fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.stderr b/tests/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.stderr index 0082b6fafee8f..86f138fabdb9d 100644 --- a/tests/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.stderr +++ b/tests/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.stderr @@ -1,4 +1,4 @@ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait method return types +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in trait method return types --> $DIR/feature-gate-return_position_impl_trait_in_trait.rs:8:17 | LL | fn bar() -> impl Sized; @@ -7,7 +7,7 @@ LL | fn bar() -> impl Sized; = note: see issue #91611 for more information = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait method return types +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in trait method return types --> $DIR/feature-gate-return_position_impl_trait_in_trait.rs:9:21 | LL | fn baz() -> Box; @@ -16,7 +16,7 @@ LL | fn baz() -> Box; = note: see issue #91611 for more information = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait method return types +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in trait method return types --> $DIR/feature-gate-return_position_impl_trait_in_trait.rs:15:23 | LL | async fn bar() -> impl Sized; diff --git a/tests/ui/impl-trait/issues/issue-54600.rs b/tests/ui/impl-trait/issues/issue-54600.rs index 3024fedf7b5fb..ccf2767012e6d 100644 --- a/tests/ui/impl-trait/issues/issue-54600.rs +++ b/tests/ui/impl-trait/issues/issue-54600.rs @@ -2,6 +2,6 @@ use std::fmt::Debug; fn main() { let x: Option = Some(44_u32); - //~^ `impl Trait` only allowed in function and inherent method return types + //~^ `impl Trait` only allowed in function and inherent method argument and return types println!("{:?}", x); } diff --git a/tests/ui/impl-trait/issues/issue-54600.stderr b/tests/ui/impl-trait/issues/issue-54600.stderr index 7ef063af95222..9a8e3675b9569 100644 --- a/tests/ui/impl-trait/issues/issue-54600.stderr +++ b/tests/ui/impl-trait/issues/issue-54600.stderr @@ -1,4 +1,4 @@ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable bindings +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in variable bindings --> $DIR/issue-54600.rs:4:19 | LL | let x: Option = Some(44_u32); diff --git a/tests/ui/impl-trait/issues/issue-54840.rs b/tests/ui/impl-trait/issues/issue-54840.rs index 8f1e0ece03a62..910d23f1d9386 100644 --- a/tests/ui/impl-trait/issues/issue-54840.rs +++ b/tests/ui/impl-trait/issues/issue-54840.rs @@ -3,5 +3,5 @@ use std::ops::Add; fn main() { let i: i32 = 0; let j: &impl Add = &i; - //~^ `impl Trait` only allowed in function and inherent method return types + //~^ `impl Trait` only allowed in function and inherent method argument and return types } diff --git a/tests/ui/impl-trait/issues/issue-54840.stderr b/tests/ui/impl-trait/issues/issue-54840.stderr index 1d1316f0e110b..67cabf4495067 100644 --- a/tests/ui/impl-trait/issues/issue-54840.stderr +++ b/tests/ui/impl-trait/issues/issue-54840.stderr @@ -1,4 +1,4 @@ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable bindings +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in variable bindings --> $DIR/issue-54840.rs:5:13 | LL | let j: &impl Add = &i; diff --git a/tests/ui/impl-trait/issues/issue-58504.rs b/tests/ui/impl-trait/issues/issue-58504.rs index e5865d0dfff34..f1d7b94ef2dbd 100644 --- a/tests/ui/impl-trait/issues/issue-58504.rs +++ b/tests/ui/impl-trait/issues/issue-58504.rs @@ -8,5 +8,5 @@ fn mk_gen() -> impl Generator { fn main() { let gens: [impl Generator;2] = [ mk_gen(), mk_gen() ]; - //~^ `impl Trait` only allowed in function and inherent method return types + //~^ `impl Trait` only allowed in function and inherent method argument and return types } diff --git a/tests/ui/impl-trait/issues/issue-58504.stderr b/tests/ui/impl-trait/issues/issue-58504.stderr index 26ec2a4f9cfe5..1be676ee075d3 100644 --- a/tests/ui/impl-trait/issues/issue-58504.stderr +++ b/tests/ui/impl-trait/issues/issue-58504.stderr @@ -1,4 +1,4 @@ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable bindings +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in variable bindings --> $DIR/issue-58504.rs:10:16 | LL | let gens: [impl Generator;2] = [ mk_gen(), mk_gen() ]; diff --git a/tests/ui/impl-trait/issues/issue-58956.rs b/tests/ui/impl-trait/issues/issue-58956.rs index 68cfcd9ba4f9e..5d5566860c0fc 100644 --- a/tests/ui/impl-trait/issues/issue-58956.rs +++ b/tests/ui/impl-trait/issues/issue-58956.rs @@ -5,9 +5,9 @@ impl Lam for B {} pub struct Wrap(T); const _A: impl Lam = { - //~^ `impl Trait` only allowed in function and inherent method return types + //~^ `impl Trait` only allowed in function and inherent method argument and return types let x: Wrap = Wrap(B); - //~^ `impl Trait` only allowed in function and inherent method return types + //~^ `impl Trait` only allowed in function and inherent method argument and return types x.0 }; diff --git a/tests/ui/impl-trait/issues/issue-58956.stderr b/tests/ui/impl-trait/issues/issue-58956.stderr index 2b4d0abdffca8..5ee33352afa2a 100644 --- a/tests/ui/impl-trait/issues/issue-58956.stderr +++ b/tests/ui/impl-trait/issues/issue-58956.stderr @@ -1,10 +1,10 @@ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in const types +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in const types --> $DIR/issue-58956.rs:7:11 | LL | const _A: impl Lam = { | ^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable bindings +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in variable bindings --> $DIR/issue-58956.rs:9:17 | LL | let x: Wrap = Wrap(B); diff --git a/tests/ui/impl-trait/issues/issue-70971.rs b/tests/ui/impl-trait/issues/issue-70971.rs index f8ae18bacd67d..c24259a71eb22 100644 --- a/tests/ui/impl-trait/issues/issue-70971.rs +++ b/tests/ui/impl-trait/issues/issue-70971.rs @@ -1,4 +1,4 @@ fn main() { let x : (impl Copy,) = (true,); - //~^ `impl Trait` only allowed in function and inherent method return types + //~^ `impl Trait` only allowed in function and inherent method argument and return types } diff --git a/tests/ui/impl-trait/issues/issue-70971.stderr b/tests/ui/impl-trait/issues/issue-70971.stderr index d066256bfb09d..5609f8b9b012c 100644 --- a/tests/ui/impl-trait/issues/issue-70971.stderr +++ b/tests/ui/impl-trait/issues/issue-70971.stderr @@ -1,4 +1,4 @@ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable bindings +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in variable bindings --> $DIR/issue-70971.rs:2:14 | LL | let x : (impl Copy,) = (true,); diff --git a/tests/ui/impl-trait/issues/issue-79099.rs b/tests/ui/impl-trait/issues/issue-79099.rs index da53594f3d091..22c66491ce988 100644 --- a/tests/ui/impl-trait/issues/issue-79099.rs +++ b/tests/ui/impl-trait/issues/issue-79099.rs @@ -1,7 +1,7 @@ struct Bug { V1: [(); { let f: impl core::future::Future = async { 1 }; - //~^ `impl Trait` only allowed in function and inherent method return types + //~^ `impl Trait` only allowed in function and inherent method argument and return types //~| expected identifier 1 }], diff --git a/tests/ui/impl-trait/issues/issue-79099.stderr b/tests/ui/impl-trait/issues/issue-79099.stderr index 580250a62fecd..82fc03c61b3b3 100644 --- a/tests/ui/impl-trait/issues/issue-79099.stderr +++ b/tests/ui/impl-trait/issues/issue-79099.stderr @@ -9,7 +9,7 @@ LL | let f: impl core::future::Future = async { 1 }; = help: pass `--edition 2021` to `rustc` = note: for more on editions, read https://doc.rust-lang.org/edition-guide -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable bindings +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in variable bindings --> $DIR/issue-79099.rs:3:16 | LL | let f: impl core::future::Future = async { 1 }; diff --git a/tests/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.rs b/tests/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.rs index 344f359529b61..3224145bffeb4 100644 --- a/tests/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.rs +++ b/tests/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.rs @@ -1,8 +1,8 @@ struct Foo(T); -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types type Result = std::result::Result; -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types // should not cause ICE fn x() -> Foo { diff --git a/tests/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.stderr b/tests/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.stderr index 656bd04706124..56be4577d51a0 100644 --- a/tests/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.stderr +++ b/tests/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.stderr @@ -1,10 +1,10 @@ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generic parameter defaults +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in generic parameter defaults --> $DIR/issue-83929-impl-trait-in-generic-default.rs:1:16 | LL | struct Foo(T); | ^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generic parameter defaults +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in generic parameter defaults --> $DIR/issue-83929-impl-trait-in-generic-default.rs:4:20 | LL | type Result = std::result::Result; diff --git a/tests/ui/impl-trait/issues/issue-84919.rs b/tests/ui/impl-trait/issues/issue-84919.rs index a0b73743a2b2d..77d27d7c06b6c 100644 --- a/tests/ui/impl-trait/issues/issue-84919.rs +++ b/tests/ui/impl-trait/issues/issue-84919.rs @@ -3,7 +3,7 @@ impl Trait for () {} fn foo<'a: 'a>() { let _x: impl Trait = (); - //~^ `impl Trait` only allowed in function and inherent method return types + //~^ `impl Trait` only allowed in function and inherent method argument and return types } fn main() {} diff --git a/tests/ui/impl-trait/issues/issue-84919.stderr b/tests/ui/impl-trait/issues/issue-84919.stderr index 36010fdef36c3..20b131b8bd200 100644 --- a/tests/ui/impl-trait/issues/issue-84919.stderr +++ b/tests/ui/impl-trait/issues/issue-84919.stderr @@ -1,4 +1,4 @@ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable bindings +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in variable bindings --> $DIR/issue-84919.rs:5:13 | LL | let _x: impl Trait = (); diff --git a/tests/ui/impl-trait/issues/issue-86642.rs b/tests/ui/impl-trait/issues/issue-86642.rs index e6e95771400d3..49f8944ac4af0 100644 --- a/tests/ui/impl-trait/issues/issue-86642.rs +++ b/tests/ui/impl-trait/issues/issue-86642.rs @@ -1,5 +1,5 @@ static x: impl Fn(&str) -> Result<&str, ()> = move |source| { - //~^ `impl Trait` only allowed in function and inherent method return types + //~^ `impl Trait` only allowed in function and inherent method argument and return types let res = (move |source| Ok(source))(source); let res = res.or((move |source| Ok(source))(source)); res diff --git a/tests/ui/impl-trait/issues/issue-86642.stderr b/tests/ui/impl-trait/issues/issue-86642.stderr index b6f8a54f35ae8..6d3be3fff0e10 100644 --- a/tests/ui/impl-trait/issues/issue-86642.stderr +++ b/tests/ui/impl-trait/issues/issue-86642.stderr @@ -1,4 +1,4 @@ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in const types +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in const types --> $DIR/issue-86642.rs:1:11 | LL | static x: impl Fn(&str) -> Result<&str, ()> = move |source| { diff --git a/tests/ui/impl-trait/issues/issue-87295.rs b/tests/ui/impl-trait/issues/issue-87295.rs index aeb8f83326e4d..eb44020ac0e72 100644 --- a/tests/ui/impl-trait/issues/issue-87295.rs +++ b/tests/ui/impl-trait/issues/issue-87295.rs @@ -14,5 +14,5 @@ impl Struct { fn main() { let _do_not_waste: Struct> = Struct::new(()); - //~^ `impl Trait` only allowed in function and inherent method return types + //~^ `impl Trait` only allowed in function and inherent method argument and return types } diff --git a/tests/ui/impl-trait/issues/issue-87295.stderr b/tests/ui/impl-trait/issues/issue-87295.stderr index ec59b719c10e1..3fe4ee73c80c3 100644 --- a/tests/ui/impl-trait/issues/issue-87295.stderr +++ b/tests/ui/impl-trait/issues/issue-87295.stderr @@ -1,4 +1,4 @@ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable bindings +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in variable bindings --> $DIR/issue-87295.rs:16:31 | LL | let _do_not_waste: Struct> = Struct::new(()); diff --git a/tests/ui/impl-trait/nested_impl_trait.rs b/tests/ui/impl-trait/nested_impl_trait.rs index e95fab3b65057..c036b9e367a17 100644 --- a/tests/ui/impl-trait/nested_impl_trait.rs +++ b/tests/ui/impl-trait/nested_impl_trait.rs @@ -9,7 +9,7 @@ fn bad_in_ret_position(x: impl Into) -> impl Into { x } fn bad_in_fn_syntax(x: fn() -> impl Into) {} //~^ ERROR nested `impl Trait` is not allowed -//~| `impl Trait` only allowed in function and inherent method return types +//~| `impl Trait` only allowed in function and inherent method argument and return types fn bad_in_arg_position(_: impl Into) { } //~^ ERROR nested `impl Trait` is not allowed diff --git a/tests/ui/impl-trait/nested_impl_trait.stderr b/tests/ui/impl-trait/nested_impl_trait.stderr index ffe84b8e86fc4..f1cafd958b05e 100644 --- a/tests/ui/impl-trait/nested_impl_trait.stderr +++ b/tests/ui/impl-trait/nested_impl_trait.stderr @@ -34,7 +34,7 @@ LL | fn bad(x: impl Into) -> impl Into { x } | | nested `impl Trait` here | outer `impl Trait` -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer return types +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `fn` pointer return types --> $DIR/nested_impl_trait.rs:10:32 | LL | fn bad_in_fn_syntax(x: fn() -> impl Into) {} diff --git a/tests/ui/impl-trait/where-allowed.rs b/tests/ui/impl-trait/where-allowed.rs index 509d2716649e5..d3fab326e748a 100644 --- a/tests/ui/impl-trait/where-allowed.rs +++ b/tests/ui/impl-trait/where-allowed.rs @@ -16,47 +16,47 @@ fn in_adt_in_parameters(_: Vec) { panic!() } // Disallowed fn in_fn_parameter_in_parameters(_: fn(impl Debug)) { panic!() } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types // Disallowed fn in_fn_return_in_parameters(_: fn() -> impl Debug) { panic!() } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types // Disallowed fn in_fn_parameter_in_return() -> fn(impl Debug) { panic!() } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types // Disallowed fn in_fn_return_in_return() -> fn() -> impl Debug { panic!() } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types // Disallowed fn in_dyn_Fn_parameter_in_parameters(_: &dyn Fn(impl Debug)) { panic!() } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types // Disallowed fn in_dyn_Fn_return_in_parameters(_: &dyn Fn() -> impl Debug) { panic!() } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types // Disallowed fn in_dyn_Fn_parameter_in_return() -> &'static dyn Fn(impl Debug) { panic!() } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types // Allowed fn in_dyn_Fn_return_in_return() -> &'static dyn Fn() -> impl Debug { panic!() } // Disallowed fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types //~^^ ERROR nested `impl Trait` is not allowed // Disallowed fn in_impl_Fn_return_in_parameters(_: &impl Fn() -> impl Debug) { panic!() } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types // Disallowed fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types //~| ERROR nested `impl Trait` is not allowed // Allowed @@ -64,11 +64,11 @@ fn in_impl_Fn_return_in_return() -> &'static impl Fn() -> impl Debug { panic!() // Disallowed fn in_Fn_parameter_in_generics (_: F) { panic!() } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types // Disallowed fn in_Fn_return_in_generics impl Debug> (_: F) { panic!() } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types // Allowed @@ -81,22 +81,22 @@ fn in_impl_Trait_in_return() -> impl IntoIterator { // Disallowed struct InBraceStructField { x: impl Debug } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types // Disallowed struct InAdtInBraceStructField { x: Vec } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types // Disallowed struct InTupleStructField(impl Debug); -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types // Disallowed enum InEnum { InBraceVariant { x: impl Debug }, - //~^ ERROR `impl Trait` only allowed in function and inherent method return types + //~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types InTupleVariant(impl Debug), - //~^ ERROR `impl Trait` only allowed in function and inherent method return types + //~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types } // Allowed @@ -107,7 +107,7 @@ trait InTraitDefnParameters { // Disallowed trait InTraitDefnReturn { fn in_return() -> impl Debug; - //~^ ERROR `impl Trait` only allowed in function and inherent method return types + //~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types } // Allowed and disallowed in trait impls @@ -124,7 +124,7 @@ impl DummyTrait for () { // Allowed fn in_trait_impl_return() -> impl Debug { () } - //~^ ERROR `impl Trait` only allowed in function and inherent method return types + //~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types } // Allowed @@ -137,10 +137,10 @@ impl DummyType { // Disallowed extern "C" { fn in_foreign_parameters(_: impl Debug); - //~^ ERROR `impl Trait` only allowed in function and inherent method return types + //~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types fn in_foreign_return() -> impl Debug; - //~^ ERROR `impl Trait` only allowed in function and inherent method return types + //~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types } // Allowed @@ -156,97 +156,97 @@ type InTypeAlias = impl Debug; //~^ ERROR `impl Trait` in type aliases is unstable type InReturnInTypeAlias = fn() -> impl Debug; -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types //~| ERROR `impl Trait` in type aliases is unstable // Disallowed in impl headers impl PartialEq for () { - //~^ ERROR `impl Trait` only allowed in function and inherent method return types + //~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types } // Disallowed in impl headers impl PartialEq<()> for impl Debug { - //~^ ERROR `impl Trait` only allowed in function and inherent method return types + //~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types } // Disallowed in inherent impls impl impl Debug { - //~^ ERROR `impl Trait` only allowed in function and inherent method return types + //~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types } // Disallowed in inherent impls struct InInherentImplAdt { t: T } impl InInherentImplAdt { - //~^ ERROR `impl Trait` only allowed in function and inherent method return types + //~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types } // Disallowed in where clauses fn in_fn_where_clause() where impl Debug: Debug -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types { } // Disallowed in where clauses fn in_adt_in_fn_where_clause() where Vec: Debug -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types { } // Disallowed fn in_trait_parameter_in_fn_where_clause() where T: PartialEq -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types { } // Disallowed fn in_Fn_parameter_in_fn_where_clause() where T: Fn(impl Debug) -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types { } // Disallowed fn in_Fn_return_in_fn_where_clause() where T: Fn() -> impl Debug -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types { } // Disallowed struct InStructGenericParamDefault(T); -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types // Disallowed enum InEnumGenericParamDefault { Variant(T) } -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types // Disallowed trait InTraitGenericParamDefault {} -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types // Disallowed type InTypeAliasGenericParamDefault = T; -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types // Disallowed impl T {} //~^ ERROR defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions //~| WARNING this was previously accepted by the compiler but is being phased out -//~| ERROR `impl Trait` only allowed in function and inherent method return types +//~| ERROR `impl Trait` only allowed in function and inherent method argument and return types //~| ERROR no nominal type found // Disallowed fn in_method_generic_param_default(_: T) {} //~^ ERROR defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions //~| WARNING this was previously accepted by the compiler but is being phased out -//~| ERROR `impl Trait` only allowed in function and inherent method return types +//~| ERROR `impl Trait` only allowed in function and inherent method argument and return types fn main() { let _in_local_variable: impl Fn() = || {}; - //~^ ERROR `impl Trait` only allowed in function and inherent method return types + //~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types let _in_return_in_local_variable = || -> impl Fn() { || {} }; - //~^ ERROR `impl Trait` only allowed in function and inherent method return types + //~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types } diff --git a/tests/ui/impl-trait/where-allowed.stderr b/tests/ui/impl-trait/where-allowed.stderr index 3e29343797554..bd7c9a947932d 100644 --- a/tests/ui/impl-trait/where-allowed.stderr +++ b/tests/ui/impl-trait/where-allowed.stderr @@ -43,109 +43,109 @@ LL | type InReturnInTypeAlias = fn() -> impl Debug; = note: see issue #63063 for more information = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer params +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `fn` pointer params --> $DIR/where-allowed.rs:18:40 | LL | fn in_fn_parameter_in_parameters(_: fn(impl Debug)) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer return types +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `fn` pointer return types --> $DIR/where-allowed.rs:22:42 | LL | fn in_fn_return_in_parameters(_: fn() -> impl Debug) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer params +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `fn` pointer params --> $DIR/where-allowed.rs:26:38 | LL | fn in_fn_parameter_in_return() -> fn(impl Debug) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer return types +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `fn` pointer return types --> $DIR/where-allowed.rs:30:40 | LL | fn in_fn_return_in_return() -> fn() -> impl Debug { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait params +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `Fn` trait params --> $DIR/where-allowed.rs:34:49 | LL | fn in_dyn_Fn_parameter_in_parameters(_: &dyn Fn(impl Debug)) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return types +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `Fn` trait return types --> $DIR/where-allowed.rs:38:51 | LL | fn in_dyn_Fn_return_in_parameters(_: &dyn Fn() -> impl Debug) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait params +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `Fn` trait params --> $DIR/where-allowed.rs:42:55 | LL | fn in_dyn_Fn_parameter_in_return() -> &'static dyn Fn(impl Debug) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait params +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `Fn` trait params --> $DIR/where-allowed.rs:49:51 | LL | fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return types +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `Fn` trait return types --> $DIR/where-allowed.rs:54:53 | LL | fn in_impl_Fn_return_in_parameters(_: &impl Fn() -> impl Debug) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait params +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `Fn` trait params --> $DIR/where-allowed.rs:58:57 | LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait params +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `Fn` trait params --> $DIR/where-allowed.rs:66:38 | LL | fn in_Fn_parameter_in_generics (_: F) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return types +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `Fn` trait return types --> $DIR/where-allowed.rs:70:40 | LL | fn in_Fn_return_in_generics impl Debug> (_: F) { panic!() } | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in field types +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in field types --> $DIR/where-allowed.rs:83:32 | LL | struct InBraceStructField { x: impl Debug } | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in field types +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in field types --> $DIR/where-allowed.rs:87:41 | LL | struct InAdtInBraceStructField { x: Vec } | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in field types +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in field types --> $DIR/where-allowed.rs:91:27 | LL | struct InTupleStructField(impl Debug); | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in field types +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in field types --> $DIR/where-allowed.rs:96:25 | LL | InBraceVariant { x: impl Debug }, | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in field types +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in field types --> $DIR/where-allowed.rs:98:20 | LL | InTupleVariant(impl Debug), | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait method return types +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in trait method return types --> $DIR/where-allowed.rs:109:23 | LL | fn in_return() -> impl Debug; @@ -154,7 +154,7 @@ LL | fn in_return() -> impl Debug; = note: see issue #91611 for more information = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `impl` method return types +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `impl` method return types --> $DIR/where-allowed.rs:126:34 | LL | fn in_trait_impl_return() -> impl Debug { () } @@ -163,121 +163,121 @@ LL | fn in_trait_impl_return() -> impl Debug { () } = note: see issue #91611 for more information = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `extern fn` params +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `extern fn` params --> $DIR/where-allowed.rs:139:33 | LL | fn in_foreign_parameters(_: impl Debug); | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `extern fn` return types +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `extern fn` return types --> $DIR/where-allowed.rs:142:31 | LL | fn in_foreign_return() -> impl Debug; | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer return types +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `fn` pointer return types --> $DIR/where-allowed.rs:158:39 | LL | type InReturnInTypeAlias = fn() -> impl Debug; | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in traits +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in traits --> $DIR/where-allowed.rs:163:16 | LL | impl PartialEq for () { | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in impl headers +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in impl headers --> $DIR/where-allowed.rs:168:24 | LL | impl PartialEq<()> for impl Debug { | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in impl headers +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in impl headers --> $DIR/where-allowed.rs:173:6 | LL | impl impl Debug { | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in impl headers +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in impl headers --> $DIR/where-allowed.rs:179:24 | LL | impl InInherentImplAdt { | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in bounds +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in bounds --> $DIR/where-allowed.rs:185:11 | LL | where impl Debug: Debug | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in bounds +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in bounds --> $DIR/where-allowed.rs:192:15 | LL | where Vec: Debug | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in bounds +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in bounds --> $DIR/where-allowed.rs:199:24 | LL | where T: PartialEq | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait params +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `Fn` trait params --> $DIR/where-allowed.rs:206:17 | LL | where T: Fn(impl Debug) | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return types +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `Fn` trait return types --> $DIR/where-allowed.rs:213:22 | LL | where T: Fn() -> impl Debug | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generic parameter defaults +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in generic parameter defaults --> $DIR/where-allowed.rs:219:40 | LL | struct InStructGenericParamDefault(T); | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generic parameter defaults +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in generic parameter defaults --> $DIR/where-allowed.rs:223:36 | LL | enum InEnumGenericParamDefault { Variant(T) } | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generic parameter defaults +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in generic parameter defaults --> $DIR/where-allowed.rs:227:38 | LL | trait InTraitGenericParamDefault {} | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generic parameter defaults +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in generic parameter defaults --> $DIR/where-allowed.rs:231:41 | LL | type InTypeAliasGenericParamDefault = T; | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generic parameter defaults +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in generic parameter defaults --> $DIR/where-allowed.rs:235:11 | LL | impl T {} | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generic parameter defaults +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in generic parameter defaults --> $DIR/where-allowed.rs:242:40 | LL | fn in_method_generic_param_default(_: T) {} | ^^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable bindings +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in variable bindings --> $DIR/where-allowed.rs:248:29 | LL | let _in_local_variable: impl Fn() = || {}; | ^^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in closure return types +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in closure return types --> $DIR/where-allowed.rs:250:46 | LL | let _in_return_in_local_variable = || -> impl Fn() { || {} }; diff --git a/tests/ui/issues/issue-47715.rs b/tests/ui/issues/issue-47715.rs index b8088c18dadfe..0a770593bc9ce 100644 --- a/tests/ui/issues/issue-47715.rs +++ b/tests/ui/issues/issue-47715.rs @@ -7,22 +7,22 @@ trait Iterable { } struct Container> { - //~^ ERROR `impl Trait` only allowed in function and inherent method return types + //~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types field: T } enum Enum> { - //~^ ERROR `impl Trait` only allowed in function and inherent method return types + //~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types A(T), } union Union + Copy> { - //~^ ERROR `impl Trait` only allowed in function and inherent method return types + //~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types x: T, } type Type> = T; -//~^ ERROR `impl Trait` only allowed in function and inherent method return types +//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types fn main() { } diff --git a/tests/ui/issues/issue-47715.stderr b/tests/ui/issues/issue-47715.stderr index dadea34b68836..2ded98781c643 100644 --- a/tests/ui/issues/issue-47715.stderr +++ b/tests/ui/issues/issue-47715.stderr @@ -1,22 +1,22 @@ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generics +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in generics --> $DIR/issue-47715.rs:9:37 | LL | struct Container> { | ^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generics +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in generics --> $DIR/issue-47715.rs:14:30 | LL | enum Enum> { | ^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generics +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in generics --> $DIR/issue-47715.rs:19:32 | LL | union Union + Copy> { | ^^^^^^^^ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generics +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in generics --> $DIR/issue-47715.rs:24:30 | LL | type Type> = T; diff --git a/tests/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.rs b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.rs index 857066c78c902..9796823a72440 100644 --- a/tests/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.rs +++ b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.rs @@ -4,7 +4,7 @@ // FIXME: this is ruled out for now but should work type Foo = fn() -> impl Send; -//~^ ERROR: `impl Trait` only allowed in function and inherent method return types +//~^ ERROR: `impl Trait` only allowed in function and inherent method argument and return types fn make_foo() -> Foo { || 15 diff --git a/tests/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.stderr b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.stderr index ff375b2ff863f..e57c59d616578 100644 --- a/tests/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.stderr +++ b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.stderr @@ -1,4 +1,4 @@ -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer return types +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `fn` pointer return types --> $DIR/type-alias-impl-trait-fn-type.rs:6:20 | LL | type Foo = fn() -> impl Send; diff --git a/tests/ui/typeck/issue-104513-ice.rs b/tests/ui/typeck/issue-104513-ice.rs index bcac0fa1e70ea..4968d3f51fe80 100644 --- a/tests/ui/typeck/issue-104513-ice.rs +++ b/tests/ui/typeck/issue-104513-ice.rs @@ -1,6 +1,6 @@ struct S; fn f() { let _: S = S; //~ ERROR cannot find trait `Oops` in this scope - //~^ ERROR `impl Trait` only allowed in function and inherent method return types + //~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types } fn main() {} diff --git a/tests/ui/typeck/issue-104513-ice.stderr b/tests/ui/typeck/issue-104513-ice.stderr index 09187d7863a6b..56c6b33615462 100644 --- a/tests/ui/typeck/issue-104513-ice.stderr +++ b/tests/ui/typeck/issue-104513-ice.stderr @@ -4,7 +4,7 @@ error[E0405]: cannot find trait `Oops` in this scope LL | let _: S = S; | ^^^^ not found in this scope -error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable bindings +error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in variable bindings --> $DIR/issue-104513-ice.rs:3:14 | LL | let _: S = S; From 9266270ef55e3138de0c58b9cd4c0949aa2eb04c Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Wed, 4 Oct 2023 12:58:06 -0700 Subject: [PATCH 05/10] Rename issue-\d+.rs tests to have meaningful names --- ...{issue-25001.rs => anchor-id-duplicate-method-name-25001.rs} | 0 .../{issue-28478.rs => anchor-id-trait-tymethod-28478.rs} | 0 .../{issue-21474.rs => deduplicate-glob-import-impl-21474.rs} | 0 .../rustdoc/{issue-22025.rs => deduplicate-trait-impl-22025.rs} | 0 .../{issue-23106.rs => doctest-hide-empty-line-23106.rs} | 0 .../{issue-23744.rs => doctest-markdown-inline-parse-23744.rs} | 0 ...ssue-25944.rs => doctest-multi-line-string-literal-25944.rs} | 0 tests/rustdoc/{issue-22038.rs => extern-fn-22038.rs} | 0 .../{issue-28927.rs => ice-reexport-crate-root-28927.rs} | 0 tests/rustdoc/{issue-21092.rs => impl-assoc-type-21092.rs} | 0 tests/rustdoc/{ => inline_cross}/auxiliary/issue-21801.rs | 0 tests/rustdoc/{ => inline_cross}/auxiliary/issue-23207-1.rs | 0 tests/rustdoc/{ => inline_cross}/auxiliary/issue-23207-2.rs | 0 tests/rustdoc/{ => inline_cross}/auxiliary/issue-27362-aux.rs | 0 .../rustdoc/{issue-27362.rs => inline_cross/const-fn-27362.rs} | 0 .../deduplicate-inlined-items-23207.rs} | 0 .../sugar-closure-crate-21801.rs} | 0 tests/rustdoc/{issue-23812.rs => macro-doc-comment-23812.rs} | 0 .../{issue-27862.rs => markdown-table-escape-pipe-27862.rs} | 0 ...23511.rs => search-index-primitive-inherent-method-23511.rs} | 0 .../{issue-26606.rs => src-link-external-macro-26606.rs} | 2 +- .../rustdoc/{issue-26995.rs => src-mod-path-absolute-26995.rs} | 0 .../{issue-27759.rs => staged-api-feature-issue-27759.rs} | 0 .../{issue-27104.rs => strip-priv-imports-pass-27104.rs} | 0 24 files changed, 1 insertion(+), 1 deletion(-) rename tests/rustdoc/{issue-25001.rs => anchor-id-duplicate-method-name-25001.rs} (100%) rename tests/rustdoc/{issue-28478.rs => anchor-id-trait-tymethod-28478.rs} (100%) rename tests/rustdoc/{issue-21474.rs => deduplicate-glob-import-impl-21474.rs} (100%) rename tests/rustdoc/{issue-22025.rs => deduplicate-trait-impl-22025.rs} (100%) rename tests/rustdoc/{issue-23106.rs => doctest-hide-empty-line-23106.rs} (100%) rename tests/rustdoc/{issue-23744.rs => doctest-markdown-inline-parse-23744.rs} (100%) rename tests/rustdoc/{issue-25944.rs => doctest-multi-line-string-literal-25944.rs} (100%) rename tests/rustdoc/{issue-22038.rs => extern-fn-22038.rs} (100%) rename tests/rustdoc/{issue-28927.rs => ice-reexport-crate-root-28927.rs} (100%) rename tests/rustdoc/{issue-21092.rs => impl-assoc-type-21092.rs} (100%) rename tests/rustdoc/{ => inline_cross}/auxiliary/issue-21801.rs (100%) rename tests/rustdoc/{ => inline_cross}/auxiliary/issue-23207-1.rs (100%) rename tests/rustdoc/{ => inline_cross}/auxiliary/issue-23207-2.rs (100%) rename tests/rustdoc/{ => inline_cross}/auxiliary/issue-27362-aux.rs (100%) rename tests/rustdoc/{issue-27362.rs => inline_cross/const-fn-27362.rs} (100%) rename tests/rustdoc/{issue-23207.rs => inline_cross/deduplicate-inlined-items-23207.rs} (100%) rename tests/rustdoc/{issue-21801.rs => inline_cross/sugar-closure-crate-21801.rs} (100%) rename tests/rustdoc/{issue-23812.rs => macro-doc-comment-23812.rs} (100%) rename tests/rustdoc/{issue-27862.rs => markdown-table-escape-pipe-27862.rs} (100%) rename tests/rustdoc/{issue-23511.rs => search-index-primitive-inherent-method-23511.rs} (100%) rename tests/rustdoc/{issue-26606.rs => src-link-external-macro-26606.rs} (73%) rename tests/rustdoc/{issue-26995.rs => src-mod-path-absolute-26995.rs} (100%) rename tests/rustdoc/{issue-27759.rs => staged-api-feature-issue-27759.rs} (100%) rename tests/rustdoc/{issue-27104.rs => strip-priv-imports-pass-27104.rs} (100%) diff --git a/tests/rustdoc/issue-25001.rs b/tests/rustdoc/anchor-id-duplicate-method-name-25001.rs similarity index 100% rename from tests/rustdoc/issue-25001.rs rename to tests/rustdoc/anchor-id-duplicate-method-name-25001.rs diff --git a/tests/rustdoc/issue-28478.rs b/tests/rustdoc/anchor-id-trait-tymethod-28478.rs similarity index 100% rename from tests/rustdoc/issue-28478.rs rename to tests/rustdoc/anchor-id-trait-tymethod-28478.rs diff --git a/tests/rustdoc/issue-21474.rs b/tests/rustdoc/deduplicate-glob-import-impl-21474.rs similarity index 100% rename from tests/rustdoc/issue-21474.rs rename to tests/rustdoc/deduplicate-glob-import-impl-21474.rs diff --git a/tests/rustdoc/issue-22025.rs b/tests/rustdoc/deduplicate-trait-impl-22025.rs similarity index 100% rename from tests/rustdoc/issue-22025.rs rename to tests/rustdoc/deduplicate-trait-impl-22025.rs diff --git a/tests/rustdoc/issue-23106.rs b/tests/rustdoc/doctest-hide-empty-line-23106.rs similarity index 100% rename from tests/rustdoc/issue-23106.rs rename to tests/rustdoc/doctest-hide-empty-line-23106.rs diff --git a/tests/rustdoc/issue-23744.rs b/tests/rustdoc/doctest-markdown-inline-parse-23744.rs similarity index 100% rename from tests/rustdoc/issue-23744.rs rename to tests/rustdoc/doctest-markdown-inline-parse-23744.rs diff --git a/tests/rustdoc/issue-25944.rs b/tests/rustdoc/doctest-multi-line-string-literal-25944.rs similarity index 100% rename from tests/rustdoc/issue-25944.rs rename to tests/rustdoc/doctest-multi-line-string-literal-25944.rs diff --git a/tests/rustdoc/issue-22038.rs b/tests/rustdoc/extern-fn-22038.rs similarity index 100% rename from tests/rustdoc/issue-22038.rs rename to tests/rustdoc/extern-fn-22038.rs diff --git a/tests/rustdoc/issue-28927.rs b/tests/rustdoc/ice-reexport-crate-root-28927.rs similarity index 100% rename from tests/rustdoc/issue-28927.rs rename to tests/rustdoc/ice-reexport-crate-root-28927.rs diff --git a/tests/rustdoc/issue-21092.rs b/tests/rustdoc/impl-assoc-type-21092.rs similarity index 100% rename from tests/rustdoc/issue-21092.rs rename to tests/rustdoc/impl-assoc-type-21092.rs diff --git a/tests/rustdoc/auxiliary/issue-21801.rs b/tests/rustdoc/inline_cross/auxiliary/issue-21801.rs similarity index 100% rename from tests/rustdoc/auxiliary/issue-21801.rs rename to tests/rustdoc/inline_cross/auxiliary/issue-21801.rs diff --git a/tests/rustdoc/auxiliary/issue-23207-1.rs b/tests/rustdoc/inline_cross/auxiliary/issue-23207-1.rs similarity index 100% rename from tests/rustdoc/auxiliary/issue-23207-1.rs rename to tests/rustdoc/inline_cross/auxiliary/issue-23207-1.rs diff --git a/tests/rustdoc/auxiliary/issue-23207-2.rs b/tests/rustdoc/inline_cross/auxiliary/issue-23207-2.rs similarity index 100% rename from tests/rustdoc/auxiliary/issue-23207-2.rs rename to tests/rustdoc/inline_cross/auxiliary/issue-23207-2.rs diff --git a/tests/rustdoc/auxiliary/issue-27362-aux.rs b/tests/rustdoc/inline_cross/auxiliary/issue-27362-aux.rs similarity index 100% rename from tests/rustdoc/auxiliary/issue-27362-aux.rs rename to tests/rustdoc/inline_cross/auxiliary/issue-27362-aux.rs diff --git a/tests/rustdoc/issue-27362.rs b/tests/rustdoc/inline_cross/const-fn-27362.rs similarity index 100% rename from tests/rustdoc/issue-27362.rs rename to tests/rustdoc/inline_cross/const-fn-27362.rs diff --git a/tests/rustdoc/issue-23207.rs b/tests/rustdoc/inline_cross/deduplicate-inlined-items-23207.rs similarity index 100% rename from tests/rustdoc/issue-23207.rs rename to tests/rustdoc/inline_cross/deduplicate-inlined-items-23207.rs diff --git a/tests/rustdoc/issue-21801.rs b/tests/rustdoc/inline_cross/sugar-closure-crate-21801.rs similarity index 100% rename from tests/rustdoc/issue-21801.rs rename to tests/rustdoc/inline_cross/sugar-closure-crate-21801.rs diff --git a/tests/rustdoc/issue-23812.rs b/tests/rustdoc/macro-doc-comment-23812.rs similarity index 100% rename from tests/rustdoc/issue-23812.rs rename to tests/rustdoc/macro-doc-comment-23812.rs diff --git a/tests/rustdoc/issue-27862.rs b/tests/rustdoc/markdown-table-escape-pipe-27862.rs similarity index 100% rename from tests/rustdoc/issue-27862.rs rename to tests/rustdoc/markdown-table-escape-pipe-27862.rs diff --git a/tests/rustdoc/issue-23511.rs b/tests/rustdoc/search-index-primitive-inherent-method-23511.rs similarity index 100% rename from tests/rustdoc/issue-23511.rs rename to tests/rustdoc/search-index-primitive-inherent-method-23511.rs diff --git a/tests/rustdoc/issue-26606.rs b/tests/rustdoc/src-link-external-macro-26606.rs similarity index 73% rename from tests/rustdoc/issue-26606.rs rename to tests/rustdoc/src-link-external-macro-26606.rs index 1b62b32a4a705..4cd735b38712f 100644 --- a/tests/rustdoc/issue-26606.rs +++ b/tests/rustdoc/src-link-external-macro-26606.rs @@ -9,5 +9,5 @@ extern crate issue_26606_macro; // @has issue_26606/constant.FOO.html -// @has - '//a[@href="../src/issue_26606/issue-26606.rs.html#13"]' 'source' +// @has - '//a[@href="../src/issue_26606/src-link-external-macro-26606.rs.html#13"]' 'source' make_item!(FOO); diff --git a/tests/rustdoc/issue-26995.rs b/tests/rustdoc/src-mod-path-absolute-26995.rs similarity index 100% rename from tests/rustdoc/issue-26995.rs rename to tests/rustdoc/src-mod-path-absolute-26995.rs diff --git a/tests/rustdoc/issue-27759.rs b/tests/rustdoc/staged-api-feature-issue-27759.rs similarity index 100% rename from tests/rustdoc/issue-27759.rs rename to tests/rustdoc/staged-api-feature-issue-27759.rs diff --git a/tests/rustdoc/issue-27104.rs b/tests/rustdoc/strip-priv-imports-pass-27104.rs similarity index 100% rename from tests/rustdoc/issue-27104.rs rename to tests/rustdoc/strip-priv-imports-pass-27104.rs From a46ccd8d3f4813d6f0d3422040898f41eaae0e8d Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Wed, 4 Oct 2023 13:04:45 -0700 Subject: [PATCH 06/10] Add URL to test case issues --- tests/rustdoc/anchor-id-duplicate-method-name-25001.rs | 1 + tests/rustdoc/anchor-id-trait-tymethod-28478.rs | 1 + tests/rustdoc/deduplicate-glob-import-impl-21474.rs | 1 + tests/rustdoc/deduplicate-trait-impl-22025.rs | 1 + tests/rustdoc/doctest-hide-empty-line-23106.rs | 1 + tests/rustdoc/doctest-markdown-inline-parse-23744.rs | 1 + tests/rustdoc/doctest-multi-line-string-literal-25944.rs | 1 + tests/rustdoc/extern-fn-22038.rs | 1 + tests/rustdoc/ice-reexport-crate-root-28927.rs | 1 + tests/rustdoc/impl-assoc-type-21092.rs | 1 + tests/rustdoc/inline_cross/const-fn-27362.rs | 1 + tests/rustdoc/inline_cross/deduplicate-inlined-items-23207.rs | 1 + tests/rustdoc/inline_cross/sugar-closure-crate-21801.rs | 1 + tests/rustdoc/macro-doc-comment-23812.rs | 1 + tests/rustdoc/markdown-table-escape-pipe-27862.rs | 1 + tests/rustdoc/search-index-primitive-inherent-method-23511.rs | 1 + tests/rustdoc/src-link-external-macro-26606.rs | 3 ++- tests/rustdoc/src-mod-path-absolute-26995.rs | 1 + tests/rustdoc/staged-api-feature-issue-27759.rs | 1 + tests/rustdoc/strip-priv-imports-pass-27104.rs | 1 + 20 files changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/rustdoc/anchor-id-duplicate-method-name-25001.rs b/tests/rustdoc/anchor-id-duplicate-method-name-25001.rs index d20268f176cec..ffb0765d3c3f6 100644 --- a/tests/rustdoc/anchor-id-duplicate-method-name-25001.rs +++ b/tests/rustdoc/anchor-id-duplicate-method-name-25001.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/25001 #![crate_name="issue_25001"] // @has issue_25001/struct.Foo.html diff --git a/tests/rustdoc/anchor-id-trait-tymethod-28478.rs b/tests/rustdoc/anchor-id-trait-tymethod-28478.rs index 60ba9090f71db..5685040dc1e1b 100644 --- a/tests/rustdoc/anchor-id-trait-tymethod-28478.rs +++ b/tests/rustdoc/anchor-id-trait-tymethod-28478.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/28478 #![crate_name="issue_28478"] #![feature(associated_type_defaults)] diff --git a/tests/rustdoc/deduplicate-glob-import-impl-21474.rs b/tests/rustdoc/deduplicate-glob-import-impl-21474.rs index bedf89236aae2..2a675b4b6ef54 100644 --- a/tests/rustdoc/deduplicate-glob-import-impl-21474.rs +++ b/tests/rustdoc/deduplicate-glob-import-impl-21474.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/21474 #![crate_name="issue_21474"] pub use inner::*; diff --git a/tests/rustdoc/deduplicate-trait-impl-22025.rs b/tests/rustdoc/deduplicate-trait-impl-22025.rs index d01c1f5c427b9..65a556e3a70f1 100644 --- a/tests/rustdoc/deduplicate-trait-impl-22025.rs +++ b/tests/rustdoc/deduplicate-trait-impl-22025.rs @@ -1,6 +1,7 @@ // aux-build:issue-22025.rs // ignore-cross-compile +// https://github.com/rust-lang/rust/issues/22025 #![crate_name="issue_22025"] extern crate issue_22025; diff --git a/tests/rustdoc/doctest-hide-empty-line-23106.rs b/tests/rustdoc/doctest-hide-empty-line-23106.rs index 27c0bd0913045..8e1e2cf098cf2 100644 --- a/tests/rustdoc/doctest-hide-empty-line-23106.rs +++ b/tests/rustdoc/doctest-hide-empty-line-23106.rs @@ -1,5 +1,6 @@ // compile-flags:--test +// https://github.com/rust-lang/rust/issues/23106 #![crate_name="issue_23106"] /// ``` diff --git a/tests/rustdoc/doctest-markdown-inline-parse-23744.rs b/tests/rustdoc/doctest-markdown-inline-parse-23744.rs index 45cc1bf3f4142..128e2daba071a 100644 --- a/tests/rustdoc/doctest-markdown-inline-parse-23744.rs +++ b/tests/rustdoc/doctest-markdown-inline-parse-23744.rs @@ -1,5 +1,6 @@ // compile-flags:--test +// https://github.com/rust-lang/rust/issues/23744 #![crate_name="issue_23744"] /// Example of rustdoc incorrectly parsing ```rust,should_panic. diff --git a/tests/rustdoc/doctest-multi-line-string-literal-25944.rs b/tests/rustdoc/doctest-multi-line-string-literal-25944.rs index 17f3431593024..eec796e4fbf29 100644 --- a/tests/rustdoc/doctest-multi-line-string-literal-25944.rs +++ b/tests/rustdoc/doctest-multi-line-string-literal-25944.rs @@ -1,5 +1,6 @@ // compile-flags:--test +// https://github.com/rust-lang/rust/issues/25944 #![crate_name="issue_25944"] /// ``` diff --git a/tests/rustdoc/extern-fn-22038.rs b/tests/rustdoc/extern-fn-22038.rs index 52c9280f82676..72d39c32a1c64 100644 --- a/tests/rustdoc/extern-fn-22038.rs +++ b/tests/rustdoc/extern-fn-22038.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/22038 #![crate_name="issue_22038"] extern "C" { diff --git a/tests/rustdoc/ice-reexport-crate-root-28927.rs b/tests/rustdoc/ice-reexport-crate-root-28927.rs index ca07add2ba8da..26debfc60e464 100644 --- a/tests/rustdoc/ice-reexport-crate-root-28927.rs +++ b/tests/rustdoc/ice-reexport-crate-root-28927.rs @@ -2,6 +2,7 @@ // aux-build:issue-28927-1.rs // ignore-cross-compile +// https://github.com/rust-lang/rust/issues/28927 #![crate_name="issue_28927"] pub extern crate issue_28927_1 as inner1; diff --git a/tests/rustdoc/impl-assoc-type-21092.rs b/tests/rustdoc/impl-assoc-type-21092.rs index 214be755e94f5..f01f098a92f5d 100644 --- a/tests/rustdoc/impl-assoc-type-21092.rs +++ b/tests/rustdoc/impl-assoc-type-21092.rs @@ -1,6 +1,7 @@ // aux-build:issue-21092.rs // ignore-cross-compile +// https://github.com/rust-lang/rust/issues/21092 #![crate_name="issue_21092"] extern crate issue_21092; diff --git a/tests/rustdoc/inline_cross/const-fn-27362.rs b/tests/rustdoc/inline_cross/const-fn-27362.rs index d2e8879dd25f5..39b904662e065 100644 --- a/tests/rustdoc/inline_cross/const-fn-27362.rs +++ b/tests/rustdoc/inline_cross/const-fn-27362.rs @@ -1,6 +1,7 @@ // aux-build:issue-27362-aux.rs // ignore-cross-compile +// https://github.com/rust-lang/rust/issues/27362 #![crate_name="issue_27362"] extern crate issue_27362_aux; diff --git a/tests/rustdoc/inline_cross/deduplicate-inlined-items-23207.rs b/tests/rustdoc/inline_cross/deduplicate-inlined-items-23207.rs index 24cba4ad2942b..4e9596db589e2 100644 --- a/tests/rustdoc/inline_cross/deduplicate-inlined-items-23207.rs +++ b/tests/rustdoc/inline_cross/deduplicate-inlined-items-23207.rs @@ -2,6 +2,7 @@ // aux-build:issue-23207-2.rs // ignore-cross-compile +// https://github.com/rust-lang/rust/issues/23207 #![crate_name="issue_23207"] extern crate issue_23207_2; diff --git a/tests/rustdoc/inline_cross/sugar-closure-crate-21801.rs b/tests/rustdoc/inline_cross/sugar-closure-crate-21801.rs index 131bf38c3cb75..bcbb2e9f4088e 100644 --- a/tests/rustdoc/inline_cross/sugar-closure-crate-21801.rs +++ b/tests/rustdoc/inline_cross/sugar-closure-crate-21801.rs @@ -1,6 +1,7 @@ // aux-build:issue-21801.rs // ignore-cross-compile +// https://github.com/rust-lang/rust/issues/21801 #![crate_name="issue_21801"] extern crate issue_21801; diff --git a/tests/rustdoc/macro-doc-comment-23812.rs b/tests/rustdoc/macro-doc-comment-23812.rs index 43b422fc9928e..57c18510b1e05 100644 --- a/tests/rustdoc/macro-doc-comment-23812.rs +++ b/tests/rustdoc/macro-doc-comment-23812.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/23812 #![crate_name="issue_23812"] macro_rules! doc { diff --git a/tests/rustdoc/markdown-table-escape-pipe-27862.rs b/tests/rustdoc/markdown-table-escape-pipe-27862.rs index 19adcb9450802..9af75d248884a 100644 --- a/tests/rustdoc/markdown-table-escape-pipe-27862.rs +++ b/tests/rustdoc/markdown-table-escape-pipe-27862.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/27862 #![crate_name="issue_27862"] /// Tests | Table diff --git a/tests/rustdoc/search-index-primitive-inherent-method-23511.rs b/tests/rustdoc/search-index-primitive-inherent-method-23511.rs index d6b931850e2b5..1d0fe27e19273 100644 --- a/tests/rustdoc/search-index-primitive-inherent-method-23511.rs +++ b/tests/rustdoc/search-index-primitive-inherent-method-23511.rs @@ -2,6 +2,7 @@ #![feature(rustdoc_internals)] #![no_std] +// https://github.com/rust-lang/rust/issues/23511 #![crate_name="issue_23511"] pub mod str { diff --git a/tests/rustdoc/src-link-external-macro-26606.rs b/tests/rustdoc/src-link-external-macro-26606.rs index 4cd735b38712f..de717a5273bb9 100644 --- a/tests/rustdoc/src-link-external-macro-26606.rs +++ b/tests/rustdoc/src-link-external-macro-26606.rs @@ -2,6 +2,7 @@ // ignore-cross-compile // build-aux-docs +// https://github.com/rust-lang/rust/issues/26606 #![crate_name="issue_26606"] // @has issue_26606_macro/macro.make_item.html @@ -9,5 +10,5 @@ extern crate issue_26606_macro; // @has issue_26606/constant.FOO.html -// @has - '//a[@href="../src/issue_26606/src-link-external-macro-26606.rs.html#13"]' 'source' +// @has - '//a[@href="../src/issue_26606/src-link-external-macro-26606.rs.html#14"]' 'source' make_item!(FOO); diff --git a/tests/rustdoc/src-mod-path-absolute-26995.rs b/tests/rustdoc/src-mod-path-absolute-26995.rs index e2cad215d6775..b67fd9b26db4b 100644 --- a/tests/rustdoc/src-mod-path-absolute-26995.rs +++ b/tests/rustdoc/src-mod-path-absolute-26995.rs @@ -1,6 +1,7 @@ // ignore-windows // compile-flags: --no-defaults +// https://github.com/rust-lang/rust/issues/26995 #![crate_name="issue_26995"] // @has src/issue_26995/dev/null.html diff --git a/tests/rustdoc/staged-api-feature-issue-27759.rs b/tests/rustdoc/staged-api-feature-issue-27759.rs index 28ea515d81f44..56a45a600da61 100644 --- a/tests/rustdoc/staged-api-feature-issue-27759.rs +++ b/tests/rustdoc/staged-api-feature-issue-27759.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/27759 #![crate_name="issue_27759"] #![feature(staged_api)] diff --git a/tests/rustdoc/strip-priv-imports-pass-27104.rs b/tests/rustdoc/strip-priv-imports-pass-27104.rs index 220df629686ef..e400a8f501181 100644 --- a/tests/rustdoc/strip-priv-imports-pass-27104.rs +++ b/tests/rustdoc/strip-priv-imports-pass-27104.rs @@ -2,6 +2,7 @@ // aux-build:empty.rs // ignore-cross-compile +// https://github.com/rust-lang/rust/issues/27104 #![crate_name="issue_27104"] // @has issue_27104/index.html From 137b6d0b01e880b8a8163cd7a14141afc080a9ee Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sat, 30 Sep 2023 19:29:41 +0000 Subject: [PATCH 07/10] Point to where missing return type should go --- .../src/check/compare_impl_item.rs | 2 +- compiler/rustc_hir_typeck/src/errors.rs | 4 +- .../src/fn_ctxt/suggestions.rs | 38 +++++++++---------- compiler/rustc_infer/src/errors/mod.rs | 10 ++--- compiler/rustc_parse/src/parser/ty.rs | 2 +- .../issue-71443-1.stderr | 2 +- .../block-must-not-have-result-res.stderr | 2 +- tests/ui/block-result/issue-20862.stderr | 2 +- tests/ui/block-result/issue-22645.stderr | 2 +- tests/ui/block-result/issue-5500.stderr | 2 +- .../add_semicolon_non_block_closure.stderr | 2 +- .../ui/closures/binder/implicit-return.stderr | 4 +- .../ui/closures/binder/implicit-stuff.stderr | 4 +- tests/ui/codemap_tests/tab.stderr | 2 +- tests/ui/compare-method/bad-self-type.stderr | 4 +- tests/ui/impl-trait/in-trait/refine.stderr | 4 +- .../issue-66667-function-cmp-cycle.stderr | 6 +-- .../start_lang_item_args.missing_ret.stderr | 4 +- tests/ui/loops/loop-break-value.stderr | 2 +- tests/ui/mismatched_types/issue-19109.stderr | 2 +- .../ui/offset-of/offset-of-output-type.stderr | 2 +- .../parser/recover-quantified-closure.stderr | 4 +- tests/ui/proc-macro/issue-37788.stderr | 2 +- .../ui/proc-macro/resolved-located-at.stderr | 2 +- tests/ui/proc-macro/span-preservation.stderr | 8 ++-- tests/ui/return/return-struct.stderr | 4 +- tests/ui/suggestions/issue-83892.stderr | 2 +- tests/ui/suggestions/return-closures.stderr | 4 +- .../suggest-ret-on-async-w-late.fixed | 14 +++++++ .../suggest-ret-on-async-w-late.rs | 3 ++ .../suggest-ret-on-async-w-late.stderr | 4 +- ...e-57673-ice-on-deref-of-boxed-trait.stderr | 2 +- ...ue-90027-async-fn-return-suggestion.stderr | 4 +- tests/ui/typeck/issue-91267.stderr | 2 +- 34 files changed, 86 insertions(+), 71 deletions(-) create mode 100644 tests/ui/suggestions/suggest-ret-on-async-w-late.fixed diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs index b5a3437c992cd..6a1da615055b5 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs @@ -1189,7 +1189,7 @@ fn report_trait_method_mismatch<'tcx>( let ap = Applicability::MachineApplicable; match sig.decl.output { hir::FnRetTy::DefaultReturn(sp) => { - let sugg = format!("-> {} ", trait_sig.output()); + let sugg = format!(" -> {}", trait_sig.output()); diag.span_suggestion_verbose(sp, msg, sugg, ap); } hir::FnRetTy::Return(hir_ty) => { diff --git a/compiler/rustc_hir_typeck/src/errors.rs b/compiler/rustc_hir_typeck/src/errors.rs index 1526988fbd926..8efccd5ba3eef 100644 --- a/compiler/rustc_hir_typeck/src/errors.rs +++ b/compiler/rustc_hir_typeck/src/errors.rs @@ -110,7 +110,7 @@ pub struct AddressOfTemporaryTaken { pub enum AddReturnTypeSuggestion { #[suggestion( hir_typeck_add_return_type_add, - code = "-> {found} ", + code = " -> {found}", applicability = "machine-applicable" )] Add { @@ -120,7 +120,7 @@ pub enum AddReturnTypeSuggestion { }, #[suggestion( hir_typeck_add_return_type_missing_here, - code = "-> _ ", + code = " -> _", applicability = "has-placeholders" )] MissingHere { diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs index abb689892183c..c8234633a3038 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs @@ -782,8 +782,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } hir::FnRetTy::Return(hir_ty) => { - let span = hir_ty.span; - if let hir::TyKind::OpaqueDef(item_id, ..) = hir_ty.kind && let hir::Node::Item(hir::Item { kind: hir::ItemKind::OpaqueTy(op_ty), @@ -799,28 +797,28 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { debug!(?found); if found.is_suggestable(self.tcx, false) { if term.span.is_empty() { - err.subdiagnostic(errors::AddReturnTypeSuggestion::Add { span, found: found.to_string() }); + err.subdiagnostic(errors::AddReturnTypeSuggestion::Add { span: term.span, found: found.to_string() }); return true; } else { - err.subdiagnostic(errors::ExpectedReturnTypeLabel::Other { span, expected }); + err.subdiagnostic(errors::ExpectedReturnTypeLabel::Other { span: term.span, expected }); } } - } - - // Only point to return type if the expected type is the return type, as if they - // are not, the expectation must have been caused by something else. - debug!("return type {:?}", hir_ty); - let ty = self.astconv().ast_ty_to_ty(hir_ty); - debug!("return type {:?}", ty); - debug!("expected type {:?}", expected); - let bound_vars = self.tcx.late_bound_vars(hir_ty.hir_id.owner.into()); - let ty = Binder::bind_with_vars(ty, bound_vars); - let ty = self.normalize(span, ty); - let ty = self.tcx.erase_late_bound_regions(ty); - if self.can_coerce(expected, ty) { - err.subdiagnostic(errors::ExpectedReturnTypeLabel::Other { span, expected }); - self.try_suggest_return_impl_trait(err, expected, ty, fn_id); - return true; + } else { + // Only point to return type if the expected type is the return type, as if they + // are not, the expectation must have been caused by something else. + debug!("return type {:?}", hir_ty); + let ty = self.astconv().ast_ty_to_ty(hir_ty); + debug!("return type {:?}", ty); + debug!("expected type {:?}", expected); + let bound_vars = self.tcx.late_bound_vars(hir_ty.hir_id.owner.into()); + let ty = Binder::bind_with_vars(ty, bound_vars); + let ty = self.normalize(hir_ty.span, ty); + let ty = self.tcx.erase_late_bound_regions(ty); + if self.can_coerce(expected, ty) { + err.subdiagnostic(errors::ExpectedReturnTypeLabel::Other { span: hir_ty.span, expected }); + self.try_suggest_return_impl_trait(err, expected, ty, fn_id); + return true; + } } } _ => {} diff --git a/compiler/rustc_infer/src/errors/mod.rs b/compiler/rustc_infer/src/errors/mod.rs index ad4525c922b43..3ff1a5c0c14b0 100644 --- a/compiler/rustc_infer/src/errors/mod.rs +++ b/compiler/rustc_infer/src/errors/mod.rs @@ -194,13 +194,13 @@ impl<'a> SourceKindMultiSuggestion<'a> { data: &'a FnRetTy<'a>, should_wrap_expr: Option, ) -> Self { - let (arrow, post) = match data { - FnRetTy::DefaultReturn(_) => ("-> ", " "), - _ => ("", ""), + let arrow = match data { + FnRetTy::DefaultReturn(_) => " -> ", + _ => "", }; let (start_span, start_span_code, end_span) = match should_wrap_expr { - Some(end_span) => (data.span(), format!("{arrow}{ty_info}{post}{{ "), Some(end_span)), - None => (data.span(), format!("{arrow}{ty_info}{post}"), None), + Some(end_span) => (data.span(), format!("{arrow}{ty_info} {{"), Some(end_span)), + None => (data.span(), format!("{arrow}{ty_info}"), None), }; Self::ClosureReturn { start_span, start_span_code, end_span } } diff --git a/compiler/rustc_parse/src/parser/ty.rs b/compiler/rustc_parse/src/parser/ty.rs index a25b0f1f8930e..0a64b2f806a5f 100644 --- a/compiler/rustc_parse/src/parser/ty.rs +++ b/compiler/rustc_parse/src/parser/ty.rs @@ -247,7 +247,7 @@ impl<'a> Parser<'a> { )?; FnRetTy::Ty(ty) } else { - FnRetTy::Default(self.token.span.shrink_to_lo()) + FnRetTy::Default(self.prev_token.span.shrink_to_hi()) }) } diff --git a/tests/ui/associated-type-bounds/issue-71443-1.stderr b/tests/ui/associated-type-bounds/issue-71443-1.stderr index 15cc9646b2c8e..09c8ec2e289f5 100644 --- a/tests/ui/associated-type-bounds/issue-71443-1.stderr +++ b/tests/ui/associated-type-bounds/issue-71443-1.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/issue-71443-1.rs:6:5 | LL | fn hello Iterator>() { - | - help: try adding a return type: `-> Incorrect` + | - help: try adding a return type: `-> Incorrect` LL | Incorrect | ^^^^^^^^^ expected `()`, found `Incorrect` diff --git a/tests/ui/block-result/block-must-not-have-result-res.stderr b/tests/ui/block-result/block-must-not-have-result-res.stderr index 0080d06dd207a..b7427462bcbd5 100644 --- a/tests/ui/block-result/block-must-not-have-result-res.stderr +++ b/tests/ui/block-result/block-must-not-have-result-res.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/block-must-not-have-result-res.rs:5:9 | LL | fn drop(&mut self) { - | - expected `()` because of default return type + | - expected `()` because of default return type LL | true | ^^^^ expected `()`, found `bool` diff --git a/tests/ui/block-result/issue-20862.stderr b/tests/ui/block-result/issue-20862.stderr index 17b524fe31171..1df3a6836206b 100644 --- a/tests/ui/block-result/issue-20862.stderr +++ b/tests/ui/block-result/issue-20862.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/issue-20862.rs:2:5 | LL | fn foo(x: i32) { - | - help: a return type might be missing here: `-> _` + | - help: a return type might be missing here: `-> _` LL | |y| x + y | ^^^^^^^^^ expected `()`, found closure | diff --git a/tests/ui/block-result/issue-22645.stderr b/tests/ui/block-result/issue-22645.stderr index 677b40aaa9dad..1064848f5139e 100644 --- a/tests/ui/block-result/issue-22645.stderr +++ b/tests/ui/block-result/issue-22645.stderr @@ -17,7 +17,7 @@ error[E0308]: mismatched types --> $DIR/issue-22645.rs:15:3 | LL | fn main() { - | - expected `()` because of default return type + | - expected `()` because of default return type LL | let b = Bob + 3.5; LL | b + 3 | ^^^^^ expected `()`, found `Bob` diff --git a/tests/ui/block-result/issue-5500.stderr b/tests/ui/block-result/issue-5500.stderr index 8cd4bd65871a3..417991e9e0bbd 100644 --- a/tests/ui/block-result/issue-5500.stderr +++ b/tests/ui/block-result/issue-5500.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/issue-5500.rs:2:5 | LL | fn main() { - | - expected `()` because of default return type + | - expected `()` because of default return type LL | &panic!() | ^^^^^^^^^ expected `()`, found `&_` | diff --git a/tests/ui/closures/add_semicolon_non_block_closure.stderr b/tests/ui/closures/add_semicolon_non_block_closure.stderr index ed829fc98f86f..6f9c309edda2e 100644 --- a/tests/ui/closures/add_semicolon_non_block_closure.stderr +++ b/tests/ui/closures/add_semicolon_non_block_closure.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/add_semicolon_non_block_closure.rs:8:12 | LL | fn main() { - | - expected `()` because of default return type + | - expected `()` because of default return type LL | foo(|| bar()) | ^^^^^ expected `()`, found `i32` | diff --git a/tests/ui/closures/binder/implicit-return.stderr b/tests/ui/closures/binder/implicit-return.stderr index 5bfb97113344a..35db34ce21d1c 100644 --- a/tests/ui/closures/binder/implicit-return.stderr +++ b/tests/ui/closures/binder/implicit-return.stderr @@ -1,8 +1,8 @@ error: implicit types in closure signatures are forbidden when `for<...>` is present - --> $DIR/implicit-return.rs:4:34 + --> $DIR/implicit-return.rs:4:33 | LL | let _f = for<'a> |_: &'a ()| {}; - | ------- ^ + | ------- ^ | | | `for<...>` is here diff --git a/tests/ui/closures/binder/implicit-stuff.stderr b/tests/ui/closures/binder/implicit-stuff.stderr index 779a08a44e5a8..cec2a60ba28c8 100644 --- a/tests/ui/closures/binder/implicit-stuff.stderr +++ b/tests/ui/closures/binder/implicit-stuff.stderr @@ -41,10 +41,10 @@ LL | let _ = for<'a> |x: &'a ()| -> &() { x }; | ^ explicit lifetime name needed here error: implicit types in closure signatures are forbidden when `for<...>` is present - --> $DIR/implicit-stuff.rs:5:22 + --> $DIR/implicit-stuff.rs:5:21 | LL | let _ = for<> || {}; - | ----- ^ + | ----- ^ | | | `for<...>` is here diff --git a/tests/ui/codemap_tests/tab.stderr b/tests/ui/codemap_tests/tab.stderr index c3f19d20d3952..d2de7486557f7 100644 --- a/tests/ui/codemap_tests/tab.stderr +++ b/tests/ui/codemap_tests/tab.stderr @@ -8,7 +8,7 @@ error[E0308]: mismatched types --> $DIR/tab.rs:8:2 | LL | fn foo() { - | - help: try adding a return type: `-> &'static str` + | - help: try adding a return type: `-> &'static str` LL | "bar boo" | ^^^^^^^^^^^^^^^^^^^^ expected `()`, found `&str` diff --git a/tests/ui/compare-method/bad-self-type.stderr b/tests/ui/compare-method/bad-self-type.stderr index f632a53f264e0..a87b713c2b4bd 100644 --- a/tests/ui/compare-method/bad-self-type.stderr +++ b/tests/ui/compare-method/bad-self-type.stderr @@ -28,10 +28,10 @@ LL | fn foo(self); found signature `fn(Box)` error[E0053]: method `bar` has an incompatible type for trait - --> $DIR/bad-self-type.rs:24:18 + --> $DIR/bad-self-type.rs:24:17 | LL | fn bar(self) {} - | ^ expected `Option<()>`, found `()` + | ^ expected `Option<()>`, found `()` | note: type in trait --> $DIR/bad-self-type.rs:18:21 diff --git a/tests/ui/impl-trait/in-trait/refine.stderr b/tests/ui/impl-trait/in-trait/refine.stderr index 29aa08e25bb91..1d9852c682cdb 100644 --- a/tests/ui/impl-trait/in-trait/refine.stderr +++ b/tests/ui/impl-trait/in-trait/refine.stderr @@ -30,8 +30,8 @@ LL | fn bar() {} = note: add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate help: replace the return type so that it matches the trait | -LL | fn bar() -> impl Sized {} - | +++++++++++++ +LL | fn bar()-> impl Sized {} + | +++++++++++++ error: impl trait in impl method signature does not match trait method signature --> $DIR/refine.rs:22:17 diff --git a/tests/ui/issues/issue-66667-function-cmp-cycle.stderr b/tests/ui/issues/issue-66667-function-cmp-cycle.stderr index d9a960ce19730..cec8117702a9b 100644 --- a/tests/ui/issues/issue-66667-function-cmp-cycle.stderr +++ b/tests/ui/issues/issue-66667-function-cmp-cycle.stderr @@ -19,7 +19,7 @@ error[E0308]: mismatched types --> $DIR/issue-66667-function-cmp-cycle.rs:2:5 | LL | fn first() { - | - help: try adding a return type: `-> bool` + | - help: try adding a return type: `-> bool` LL | second == 1 | ^^^^^^^^^^^ expected `()`, found `bool` @@ -44,7 +44,7 @@ error[E0308]: mismatched types --> $DIR/issue-66667-function-cmp-cycle.rs:8:5 | LL | fn second() { - | - help: try adding a return type: `-> bool` + | - help: try adding a return type: `-> bool` LL | first == 1 | ^^^^^^^^^^ expected `()`, found `bool` @@ -69,7 +69,7 @@ error[E0308]: mismatched types --> $DIR/issue-66667-function-cmp-cycle.rs:14:5 | LL | fn bar() { - | - help: try adding a return type: `-> bool` + | - help: try adding a return type: `-> bool` LL | bar == 1 | ^^^^^^^^ expected `()`, found `bool` diff --git a/tests/ui/lang-items/start_lang_item_args.missing_ret.stderr b/tests/ui/lang-items/start_lang_item_args.missing_ret.stderr index 2bb29f911a125..14bfcc3d04d9c 100644 --- a/tests/ui/lang-items/start_lang_item_args.missing_ret.stderr +++ b/tests/ui/lang-items/start_lang_item_args.missing_ret.stderr @@ -1,8 +1,8 @@ error[E0308]: lang item `start` function has wrong type - --> $DIR/start_lang_item_args.rs:29:84 + --> $DIR/start_lang_item_args.rs:29:83 | LL | fn start(_main: fn() -> T, _argc: isize, _argv: *const *const u8, _sigpipe: u8) {} - | ^ expected `isize`, found `()` + | ^ expected `isize`, found `()` | = note: expected signature `fn(fn() -> _, _, _, _) -> isize` found signature `fn(fn() -> _, _, _, _)` diff --git a/tests/ui/loops/loop-break-value.stderr b/tests/ui/loops/loop-break-value.stderr index 6c83bc7575c37..a691960f96257 100644 --- a/tests/ui/loops/loop-break-value.stderr +++ b/tests/ui/loops/loop-break-value.stderr @@ -319,7 +319,7 @@ error[E0308]: mismatched types --> $DIR/loop-break-value.rs:159:15 | LL | fn main() { - | - expected `()` because of this return type + | - expected `()` because of this return type ... LL | loop { // point at the return type | ---- this loop is expected to be of type `()` diff --git a/tests/ui/mismatched_types/issue-19109.stderr b/tests/ui/mismatched_types/issue-19109.stderr index 5cef64bb16926..ca819d93a50a4 100644 --- a/tests/ui/mismatched_types/issue-19109.stderr +++ b/tests/ui/mismatched_types/issue-19109.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/issue-19109.rs:4:5 | LL | fn function(t: &mut dyn Trait) { - | - help: try adding a return type: `-> *mut dyn Trait` + | - help: try adding a return type: `-> *mut dyn Trait` LL | t as *mut dyn Trait | ^^^^^^^^^^^^^^^^^^^ expected `()`, found `*mut dyn Trait` | diff --git a/tests/ui/offset-of/offset-of-output-type.stderr b/tests/ui/offset-of/offset-of-output-type.stderr index 6133f3263ab64..233d49876436a 100644 --- a/tests/ui/offset-of/offset-of-output-type.stderr +++ b/tests/ui/offset-of/offset-of-output-type.stderr @@ -42,7 +42,7 @@ error[E0308]: mismatched types --> $DIR/offset-of-output-type.rs:19:5 | LL | fn main() { - | - expected `()` because of default return type + | - expected `()` because of default return type ... LL | offset_of!(S, v) | ^^^^^^^^^^^^^^^^ expected `()`, found `usize` diff --git a/tests/ui/parser/recover-quantified-closure.stderr b/tests/ui/parser/recover-quantified-closure.stderr index 39eec80f658ad..37e93cbee7be7 100644 --- a/tests/ui/parser/recover-quantified-closure.stderr +++ b/tests/ui/parser/recover-quantified-closure.stderr @@ -25,10 +25,10 @@ LL | for ::Bar in x {} = help: consider removing `for<...>` error: implicit types in closure signatures are forbidden when `for<...>` is present - --> $DIR/recover-quantified-closure.rs:2:25 + --> $DIR/recover-quantified-closure.rs:2:24 | LL | for<'a> |x: &'a u8| *x + 1; - | ------- ^ + | ------- ^ | | | `for<...>` is here diff --git a/tests/ui/proc-macro/issue-37788.stderr b/tests/ui/proc-macro/issue-37788.stderr index e437bb90b1dfa..0a116d6f80d35 100644 --- a/tests/ui/proc-macro/issue-37788.stderr +++ b/tests/ui/proc-macro/issue-37788.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/issue-37788.rs:8:5 | LL | fn main() { - | - expected `()` because of default return type + | - expected `()` because of default return type LL | // Test that constructing the `visible_parent_map` (in `cstore_impl.rs`) does not ICE. LL | std::cell::Cell::new(0) | ^^^^^^^^^^^^^^^^^^^^^^^- help: consider using a semicolon here: `;` diff --git a/tests/ui/proc-macro/resolved-located-at.stderr b/tests/ui/proc-macro/resolved-located-at.stderr index 0b4dbcba68287..a4f838521fdd6 100644 --- a/tests/ui/proc-macro/resolved-located-at.stderr +++ b/tests/ui/proc-macro/resolved-located-at.stderr @@ -10,7 +10,7 @@ error[E0308]: mismatched types --> $DIR/resolved-located-at.rs:7:27 | LL | fn main() { - | - expected `()` because of default return type + | - expected `()` because of default return type LL | resolve_located_at!(a b) | ^ expected `()`, found `S` | diff --git a/tests/ui/proc-macro/span-preservation.stderr b/tests/ui/proc-macro/span-preservation.stderr index 8c15cb9de9823..3ad9c539f8474 100644 --- a/tests/ui/proc-macro/span-preservation.stderr +++ b/tests/ui/proc-macro/span-preservation.stderr @@ -38,7 +38,7 @@ error[E0308]: mismatched types --> $DIR/span-preservation.rs:39:5 | LL | extern "C" fn bar() { - | - help: try adding a return type: `-> i32` + | - help: try adding a return type: `-> i32` LL | 0 | ^ expected `()`, found integer @@ -46,7 +46,7 @@ error[E0308]: mismatched types --> $DIR/span-preservation.rs:44:5 | LL | extern "C" fn baz() { - | - help: try adding a return type: `-> i32` + | - help: try adding a return type: `-> i32` LL | 0 | ^ expected `()`, found integer @@ -54,7 +54,7 @@ error[E0308]: mismatched types --> $DIR/span-preservation.rs:49:5 | LL | extern "Rust" fn rust_abi() { - | - help: try adding a return type: `-> i32` + | - help: try adding a return type: `-> i32` LL | 0 | ^ expected `()`, found integer @@ -62,7 +62,7 @@ error[E0308]: mismatched types --> $DIR/span-preservation.rs:54:5 | LL | extern "\x43" fn c_abi_escaped() { - | - help: try adding a return type: `-> i32` + | - help: try adding a return type: `-> i32` LL | 0 | ^ expected `()`, found integer diff --git a/tests/ui/return/return-struct.stderr b/tests/ui/return/return-struct.stderr index e6c0363e36310..282e6498ebe3e 100644 --- a/tests/ui/return/return-struct.stderr +++ b/tests/ui/return/return-struct.stderr @@ -17,7 +17,7 @@ error[E0308]: mismatched types --> $DIR/return-struct.rs:15:5 | LL | fn bar() { - | - help: try adding a return type: `-> Age` + | - help: try adding a return type: `-> Age` LL | let mut age = 29; LL | Age::Years(age, 55) | ^^^^^^^^^^^^^^^^^^^ expected `()`, found `Age` @@ -26,7 +26,7 @@ error[E0308]: mismatched types --> $DIR/return-struct.rs:20:5 | LL | fn baz() { - | - help: try adding a return type: `-> S` + | - help: try adding a return type: `-> S` LL | S | ^ expected `()`, found `S` diff --git a/tests/ui/suggestions/issue-83892.stderr b/tests/ui/suggestions/issue-83892.stderr index baf6b1447e69d..5e471819b27b8 100644 --- a/tests/ui/suggestions/issue-83892.stderr +++ b/tests/ui/suggestions/issue-83892.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/issue-83892.rs:9:15 | LL | fn main() { - | - expected `()` because of default return type + | - expected `()` because of default return type LL | match () { LL | () => func() | ^^^^^^ expected `()`, found `u8` diff --git a/tests/ui/suggestions/return-closures.stderr b/tests/ui/suggestions/return-closures.stderr index f0810bbb2541e..97c13200ac36b 100644 --- a/tests/ui/suggestions/return-closures.stderr +++ b/tests/ui/suggestions/return-closures.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/return-closures.rs:3:5 | LL | fn foo() { - | - help: try adding a return type: `-> impl for<'a> Fn(&'a i32) -> i32` + | - help: try adding a return type: `-> impl for<'a> Fn(&'a i32) -> i32` LL | LL | |x: &i32| 1i32 | ^^^^^^^^^^^^^^ expected `()`, found closure @@ -14,7 +14,7 @@ error[E0308]: mismatched types --> $DIR/return-closures.rs:9:5 | LL | fn bar(i: impl Sized) { - | - help: a return type might be missing here: `-> _` + | - help: a return type might be missing here: `-> _` LL | LL | || i | ^^^^ expected `()`, found closure diff --git a/tests/ui/suggestions/suggest-ret-on-async-w-late.fixed b/tests/ui/suggestions/suggest-ret-on-async-w-late.fixed new file mode 100644 index 0000000000000..0a08383317f76 --- /dev/null +++ b/tests/ui/suggestions/suggest-ret-on-async-w-late.fixed @@ -0,0 +1,14 @@ +// edition: 2021 +// run-rustfix + +#![allow(unused)] + +// Make sure we don't ICE when suggesting a return type +// for an async fn that has late-bound vars... + +async fn ice(_: &i32) -> bool { + true + //~^ ERROR mismatched types +} + +fn main() {} diff --git a/tests/ui/suggestions/suggest-ret-on-async-w-late.rs b/tests/ui/suggestions/suggest-ret-on-async-w-late.rs index 459b94f943b50..5c8f185bd4b07 100644 --- a/tests/ui/suggestions/suggest-ret-on-async-w-late.rs +++ b/tests/ui/suggestions/suggest-ret-on-async-w-late.rs @@ -1,4 +1,7 @@ // edition: 2021 +// run-rustfix + +#![allow(unused)] // Make sure we don't ICE when suggesting a return type // for an async fn that has late-bound vars... diff --git a/tests/ui/suggestions/suggest-ret-on-async-w-late.stderr b/tests/ui/suggestions/suggest-ret-on-async-w-late.stderr index 36cabab758f15..352f6da3607bc 100644 --- a/tests/ui/suggestions/suggest-ret-on-async-w-late.stderr +++ b/tests/ui/suggestions/suggest-ret-on-async-w-late.stderr @@ -1,8 +1,8 @@ error[E0308]: mismatched types - --> $DIR/suggest-ret-on-async-w-late.rs:7:5 + --> $DIR/suggest-ret-on-async-w-late.rs:10:5 | LL | async fn ice(_: &i32) { - | --------------------- help: try adding a return type: `-> bool` + | - help: try adding a return type: `-> bool` LL | true | ^^^^ expected `()`, found `bool` diff --git a/tests/ui/typeck/issue-57673-ice-on-deref-of-boxed-trait.stderr b/tests/ui/typeck/issue-57673-ice-on-deref-of-boxed-trait.stderr index dc4bc5b5f44bb..6c3302f29c2dc 100644 --- a/tests/ui/typeck/issue-57673-ice-on-deref-of-boxed-trait.stderr +++ b/tests/ui/typeck/issue-57673-ice-on-deref-of-boxed-trait.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/issue-57673-ice-on-deref-of-boxed-trait.rs:5:5 | LL | fn ice(x: Box>) { - | - help: try adding a return type: `-> (dyn Iterator + 'static)` + | - help: try adding a return type: `-> (dyn Iterator + 'static)` LL | *x | ^^ expected `()`, found `dyn Iterator` | diff --git a/tests/ui/typeck/issue-90027-async-fn-return-suggestion.stderr b/tests/ui/typeck/issue-90027-async-fn-return-suggestion.stderr index e367e04c37580..c46f4ec1ec301 100644 --- a/tests/ui/typeck/issue-90027-async-fn-return-suggestion.stderr +++ b/tests/ui/typeck/issue-90027-async-fn-return-suggestion.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/issue-90027-async-fn-return-suggestion.rs:4:5 | LL | async fn hello() { - | ---------------- help: try adding a return type: `-> i32` + | - help: try adding a return type: `-> i32` LL | 0 | ^ expected `()`, found integer @@ -10,7 +10,7 @@ error[E0308]: mismatched types --> $DIR/issue-90027-async-fn-return-suggestion.rs:9:5 | LL | async fn world() -> () { - | ---------------------- expected `()` because of return type + | -- expected `()` because of return type LL | 0 | ^ expected `()`, found integer diff --git a/tests/ui/typeck/issue-91267.stderr b/tests/ui/typeck/issue-91267.stderr index 72acd9c673b63..7e48b251980e8 100644 --- a/tests/ui/typeck/issue-91267.stderr +++ b/tests/ui/typeck/issue-91267.stderr @@ -14,7 +14,7 @@ error[E0308]: mismatched types --> $DIR/issue-91267.rs:4:5 | LL | fn main() { - | - expected `()` because of default return type + | - expected `()` because of default return type LL | type_ascribe!(0, u8=e>) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `u8` From 89b14ae212e50f7a92800c4cb4f7cdefd2b1495e Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Mon, 2 Oct 2023 21:24:23 +0000 Subject: [PATCH 08/10] Fix clippy --- .../src/methods/unnecessary_literal_unwrap.rs | 8 ++------ .../ui-toml/too_many_arguments/too_many_arguments.stderr | 2 +- src/tools/clippy/tests/ui/crashes/ice-6251.stderr | 4 ++-- src/tools/clippy/tests/ui/functions.stderr | 6 +++--- src/tools/clippy/tests/ui/must_use_unit.stderr | 4 ++-- .../clippy/tests/ui/unnecessary_literal_unwrap.fixed | 4 ++-- .../clippy/tests/ui/unnecessary_literal_unwrap.stderr | 4 ++-- 7 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/tools/clippy/clippy_lints/src/methods/unnecessary_literal_unwrap.rs b/src/tools/clippy/clippy_lints/src/methods/unnecessary_literal_unwrap.rs index 937aac8d25ef0..24c0ea3f60a99 100644 --- a/src/tools/clippy/clippy_lints/src/methods/unnecessary_literal_unwrap.rs +++ b/src/tools/clippy/clippy_lints/src/methods/unnecessary_literal_unwrap.rs @@ -102,14 +102,10 @@ pub(super) fn check( ]), ("None", "unwrap_or_else", _) => match args[0].kind { hir::ExprKind::Closure(hir::Closure { - fn_decl: - hir::FnDecl { - output: hir::FnRetTy::DefaultReturn(span) | hir::FnRetTy::Return(hir::Ty { span, .. }), - .. - }, + body, .. }) => Some(vec![ - (expr.span.with_hi(span.hi()), String::new()), + (expr.span.with_hi(cx.tcx.hir().body(*body).value.span.lo()), String::new()), (expr.span.with_lo(args[0].span.hi()), String::new()), ]), _ => None, diff --git a/src/tools/clippy/tests/ui-toml/too_many_arguments/too_many_arguments.stderr b/src/tools/clippy/tests/ui-toml/too_many_arguments/too_many_arguments.stderr index a52e1fcb9e3a8..8b9d159b59c3a 100644 --- a/src/tools/clippy/tests/ui-toml/too_many_arguments/too_many_arguments.stderr +++ b/src/tools/clippy/tests/ui-toml/too_many_arguments/too_many_arguments.stderr @@ -2,7 +2,7 @@ error: this function has too many arguments (11/10) --> $DIR/too_many_arguments.rs:4:1 | LL | fn too_many(p1: u8, p2: u8, p3: u8, p4: u8, p5: u8, p6: u8, p7: u8, p8: u8, p9: u8, p10: u8, p11: u8) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::too-many-arguments` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::too_many_arguments)]` diff --git a/src/tools/clippy/tests/ui/crashes/ice-6251.stderr b/src/tools/clippy/tests/ui/crashes/ice-6251.stderr index 11081dc8087e2..aaebdabcbd5e3 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-6251.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-6251.stderr @@ -12,10 +12,10 @@ LL | fn bug() -> impl Iterator { | + error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/ice-6251.rs:4:54 + --> $DIR/ice-6251.rs:4:53 | LL | fn bug() -> impl Iterator { - | ^ doesn't have a size known at compile-time + | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[u8]` = note: the return type of a function must have a statically known size diff --git a/src/tools/clippy/tests/ui/functions.stderr b/src/tools/clippy/tests/ui/functions.stderr index 371ea1612601e..4b06cd0388990 100644 --- a/src/tools/clippy/tests/ui/functions.stderr +++ b/src/tools/clippy/tests/ui/functions.stderr @@ -2,7 +2,7 @@ error: this function has too many arguments (8/7) --> $DIR/functions.rs:8:1 | LL | fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::too-many-arguments` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::too_many_arguments)]` @@ -17,7 +17,7 @@ LL | | two: u32, ... | LL | | eight: () LL | | ) { - | |__^ + | |_^ error: this function has too many arguments (8/7) --> $DIR/functions.rs:48:5 @@ -29,7 +29,7 @@ error: this function has too many arguments (8/7) --> $DIR/functions.rs:58:5 | LL | fn bad_method(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this public function might dereference a raw pointer but is not marked `unsafe` --> $DIR/functions.rs:68:34 diff --git a/src/tools/clippy/tests/ui/must_use_unit.stderr b/src/tools/clippy/tests/ui/must_use_unit.stderr index e67d9b5b9d8d3..f2ee185857d3e 100644 --- a/src/tools/clippy/tests/ui/must_use_unit.stderr +++ b/src/tools/clippy/tests/ui/must_use_unit.stderr @@ -4,7 +4,7 @@ error: this unit-returning function has a `#[must_use]` attribute LL | #[must_use] | ----------- help: remove the attribute LL | pub fn must_use_default() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::must-use-unit` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::must_use_unit)]` @@ -23,7 +23,7 @@ error: this unit-returning function has a `#[must_use]` attribute LL | #[must_use = "With note"] | ------------------------- help: remove the attribute LL | pub fn must_use_with_note() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/src/tools/clippy/tests/ui/unnecessary_literal_unwrap.fixed b/src/tools/clippy/tests/ui/unnecessary_literal_unwrap.fixed index 87df1f8cb08fb..b17343aa9ba5a 100644 --- a/src/tools/clippy/tests/ui/unnecessary_literal_unwrap.fixed +++ b/src/tools/clippy/tests/ui/unnecessary_literal_unwrap.fixed @@ -23,7 +23,7 @@ fn unwrap_option_none() { let _val: u16 = 234; let _val: u16 = 234; let _val: u16 = { 234 }; - let _val: u16 = { 234 }; + let _val: u16 = { 234 }; panic!(); panic!("this always happens"); @@ -31,7 +31,7 @@ fn unwrap_option_none() { 234; 234; { 234 }; - { 234 }; + { 234 }; } fn unwrap_result_ok() { diff --git a/src/tools/clippy/tests/ui/unnecessary_literal_unwrap.stderr b/src/tools/clippy/tests/ui/unnecessary_literal_unwrap.stderr index 013907f59c46f..4940091be60ae 100644 --- a/src/tools/clippy/tests/ui/unnecessary_literal_unwrap.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_literal_unwrap.stderr @@ -116,7 +116,7 @@ LL | let _val: u16 = None.unwrap_or_else(|| -> u16 { 234 }); help: remove the `None` and `unwrap_or_else()` | LL - let _val: u16 = None.unwrap_or_else(|| -> u16 { 234 }); -LL + let _val: u16 = { 234 }; +LL + let _val: u16 = { 234 }; | error: used `unwrap()` on `None` value @@ -187,7 +187,7 @@ LL | None::.unwrap_or_else(|| -> u16 { 234 }); help: remove the `None` and `unwrap_or_else()` | LL - None::.unwrap_or_else(|| -> u16 { 234 }); -LL + { 234 }; +LL + { 234 }; | error: used `unwrap()` on `Ok` value From 1f079cfb440c05578fce656999d363d916500850 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Mon, 2 Oct 2023 21:39:07 +0000 Subject: [PATCH 09/10] Point to closure return instead of output if defaulted --- compiler/rustc_hir_typeck/src/check.rs | 6 +++++- src/tools/clippy/tests/ui/crashes/ice-6251.stderr | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/check.rs b/compiler/rustc_hir_typeck/src/check.rs index 1fa0ec173a7e4..c8ffd7d15067d 100644 --- a/compiler/rustc_hir_typeck/src/check.rs +++ b/compiler/rustc_hir_typeck/src/check.rs @@ -113,7 +113,11 @@ pub(super) fn check_fn<'a, 'tcx>( fcx.typeck_results.borrow_mut().liberated_fn_sigs_mut().insert(fn_id, fn_sig); - fcx.require_type_is_sized(declared_ret_ty, decl.output.span(), traits::SizedReturnType); + let return_or_body_span = match decl.output { + hir::FnRetTy::DefaultReturn(_) => body.value.span, + hir::FnRetTy::Return(ty) => ty.span, + }; + fcx.require_type_is_sized(declared_ret_ty, return_or_body_span, traits::SizedReturnType); fcx.check_return_expr(&body.value, false); // We insert the deferred_generator_interiors entry after visiting the body. diff --git a/src/tools/clippy/tests/ui/crashes/ice-6251.stderr b/src/tools/clippy/tests/ui/crashes/ice-6251.stderr index aaebdabcbd5e3..11081dc8087e2 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-6251.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-6251.stderr @@ -12,10 +12,10 @@ LL | fn bug() -> impl Iterator { | + error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/ice-6251.rs:4:53 + --> $DIR/ice-6251.rs:4:54 | LL | fn bug() -> impl Iterator { - | ^ doesn't have a size known at compile-time + | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[u8]` = note: the return type of a function must have a statically known size From dd5f26c42dbe24491cc2aae12bca747d1701936c Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Wed, 4 Oct 2023 21:09:50 +0000 Subject: [PATCH 10/10] Fix spans for comments in rustfmt --- src/tools/rustfmt/src/items.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tools/rustfmt/src/items.rs b/src/tools/rustfmt/src/items.rs index d5bc38303e004..002cffa9b0c0f 100644 --- a/src/tools/rustfmt/src/items.rs +++ b/src/tools/rustfmt/src/items.rs @@ -2599,7 +2599,8 @@ fn rewrite_fn_base( if where_clause_str.is_empty() { if let ast::FnRetTy::Default(ret_span) = fd.output { match recover_missing_comment_in_span( - mk_sp(params_span.hi(), ret_span.hi()), + // from after the closing paren to right before block or semicolon + mk_sp(ret_span.lo(), span.hi()), shape, context, last_line_width(&result),