diff options
| -rw-r--r-- | compiler/rustc_parse/src/parser/expr.rs | 28 | ||||
| -rw-r--r-- | library/alloc/src/vec/in_place_collect.rs | 13 | ||||
| -rw-r--r-- | library/alloc/src/vec/spec_from_iter.rs | 14 | ||||
| -rw-r--r-- | library/core/src/error.rs | 2 | ||||
| -rw-r--r-- | src/bootstrap/src/core/build_steps/setup.rs | 1 | ||||
| -rw-r--r-- | src/etc/rust_analyzer_settings.json | 1 | ||||
| -rw-r--r-- | src/librustdoc/passes/stripper.rs | 31 | ||||
| -rw-r--r-- | src/tools/clippy/clippy_lints/src/derive.rs | 4 | ||||
| -rw-r--r-- | src/tools/clippy/clippy_lints/src/loops/explicit_iter_loop.rs | 2 | ||||
| -rw-r--r-- | src/tools/clippy/clippy_utils/src/ty.rs | 32 | ||||
| -rw-r--r-- | tests/rustdoc/async-fn.rs | 18 | ||||
| -rw-r--r-- | tests/rustdoc/impl-on-ty-alias-issue-119015.rs | 27 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-box.fixed (renamed from tests/ui/parser/removed-syntax-box.fixed) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-box.rs (renamed from tests/ui/parser/removed-syntax-box.rs) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-box.stderr (renamed from tests/ui/parser/removed-syntax-box.stderr) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-closure-lifetime.rs (renamed from tests/ui/parser/removed-syntax-closure-lifetime.rs) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-closure-lifetime.stderr (renamed from tests/ui/parser/removed-syntax-closure-lifetime.stderr) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-enum-newtype.rs (renamed from tests/ui/parser/removed-syntax-enum-newtype.rs) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-enum-newtype.stderr (renamed from tests/ui/parser/removed-syntax-enum-newtype.stderr) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-field-let-2.rs (renamed from tests/ui/parser/removed-syntax-field-let-2.rs) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-field-let-2.stderr (renamed from tests/ui/parser/removed-syntax-field-let-2.stderr) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-field-let.rs (renamed from tests/ui/parser/removed-syntax-field-let.rs) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-field-let.stderr (renamed from tests/ui/parser/removed-syntax-field-let.stderr) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-field-semicolon.rs (renamed from tests/ui/parser/removed-syntax-field-semicolon.rs) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-field-semicolon.stderr (renamed from tests/ui/parser/removed-syntax-field-semicolon.stderr) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-fixed-vec.rs (renamed from tests/ui/parser/removed-syntax-fixed-vec.rs) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-fixed-vec.stderr (renamed from tests/ui/parser/removed-syntax-fixed-vec.stderr) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-fn-sigil.rs (renamed from tests/ui/parser/removed-syntax-fn-sigil.rs) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-fn-sigil.stderr (renamed from tests/ui/parser/removed-syntax-fn-sigil.stderr) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-mode.rs (renamed from tests/ui/parser/removed-syntax-mode.rs) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-mode.stderr (renamed from tests/ui/parser/removed-syntax-mode.stderr) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-mut-vec-expr.rs (renamed from tests/ui/parser/removed-syntax-mut-vec-expr.rs) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-mut-vec-expr.stderr (renamed from tests/ui/parser/removed-syntax-mut-vec-expr.stderr) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-mut-vec-ty.rs (renamed from tests/ui/parser/removed-syntax-mut-vec-ty.rs) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-mut-vec-ty.stderr (renamed from tests/ui/parser/removed-syntax-mut-vec-ty.stderr) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-ptr-lifetime.rs (renamed from tests/ui/parser/removed-syntax-ptr-lifetime.rs) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-ptr-lifetime.stderr (renamed from tests/ui/parser/removed-syntax-ptr-lifetime.stderr) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-record.rs (renamed from tests/ui/parser/removed-syntax-record.rs) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-record.stderr (renamed from tests/ui/parser/removed-syntax-record.stderr) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-static-fn.rs (renamed from tests/ui/parser/removed-syntax-static-fn.rs) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-static-fn.stderr (renamed from tests/ui/parser/removed-syntax-static-fn.stderr) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-uniq-mut-expr.rs (renamed from tests/ui/parser/removed-syntax-uniq-mut-expr.rs) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-uniq-mut-expr.stderr (renamed from tests/ui/parser/removed-syntax-uniq-mut-expr.stderr) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-uniq-mut-ty.rs (renamed from tests/ui/parser/removed-syntax-uniq-mut-ty.rs) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-uniq-mut-ty.stderr (renamed from tests/ui/parser/removed-syntax-uniq-mut-ty.stderr) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-with-1.rs (renamed from tests/ui/parser/removed-syntax-with-1.rs) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-with-1.stderr (renamed from tests/ui/parser/removed-syntax-with-1.stderr) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-with-2.rs (renamed from tests/ui/parser/removed-syntax-with-2.rs) | 0 | ||||
| -rw-r--r-- | tests/ui/parser/removed-syntax/removed-syntax-with-2.stderr (renamed from tests/ui/parser/removed-syntax-with-2.stderr) | 0 |
49 files changed, 97 insertions, 76 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index f858706805d..ae3661a530b 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -33,7 +33,6 @@ use rustc_session::errors::{report_lit_error, ExprParenthesesNeeded}; use rustc_session::lint::builtin::BREAK_WITH_LABEL_AND_LOOP; use rustc_session::lint::BuiltinLintDiagnostics; use rustc_span::source_map::{self, Spanned}; -use rustc_span::symbol::kw::PathRoot; use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::{BytePos, Pos, Span}; use thin_vec::{thin_vec, ThinVec}; @@ -642,26 +641,13 @@ impl<'a> Parser<'a> { } /// Parse `box expr` - this syntax has been removed, but we still parse this - /// for now to provide an automated way to fix usages of it - fn parse_expr_box(&mut self, lo: Span) -> PResult<'a, (Span, ExprKind)> { - let (span, expr) = self.parse_expr_prefix_common(lo)?; - let code = self.sess.source_map().span_to_snippet(span.with_lo(lo.hi())).unwrap(); - self.dcx().emit_err(errors::BoxSyntaxRemoved { span, code: code.trim() }); - // So typechecking works, parse `box <expr>` as `::std::boxed::Box::new(expr)` - let path = Path { - span, - segments: [ - PathSegment::from_ident(Ident::with_dummy_span(PathRoot)), - PathSegment::from_ident(Ident::with_dummy_span(sym::std)), - PathSegment::from_ident(Ident::from_str("boxed")), - PathSegment::from_ident(Ident::from_str("Box")), - PathSegment::from_ident(Ident::with_dummy_span(sym::new)), - ] - .into(), - tokens: None, - }; - let path = self.mk_expr(span, ExprKind::Path(None, path)); - Ok((span, self.mk_call(path, ThinVec::from([expr])))) + /// for now to provide a more useful error + fn parse_expr_box(&mut self, box_kw: Span) -> PResult<'a, (Span, ExprKind)> { + let (span, _) = self.parse_expr_prefix_common(box_kw)?; + let inner_span = span.with_lo(box_kw.hi()); + let code = self.sess.source_map().span_to_snippet(inner_span).unwrap(); + self.dcx().emit_err(errors::BoxSyntaxRemoved { span: span, code: code.trim() }); + Ok((span, ExprKind::Err)) } fn is_mistaken_not_ident_negation(&self) -> bool { diff --git a/library/alloc/src/vec/in_place_collect.rs b/library/alloc/src/vec/in_place_collect.rs index ec5f32539f2..5a783e66752 100644 --- a/library/alloc/src/vec/in_place_collect.rs +++ b/library/alloc/src/vec/in_place_collect.rs @@ -168,7 +168,9 @@ const fn in_place_collectible<DEST, SRC>( step_merge: Option<NonZeroUsize>, step_expand: Option<NonZeroUsize>, ) -> bool { - if const { SRC::IS_ZST || DEST::IS_ZST || mem::align_of::<SRC>() < mem::align_of::<DEST>() } { + // Require matching alignments because an alignment-changing realloc is inefficient on many + // system allocators and better implementations would require the unstable Allocator trait. + if const { SRC::IS_ZST || DEST::IS_ZST || mem::align_of::<SRC>() != mem::align_of::<DEST>() } { return false; } @@ -188,7 +190,8 @@ const fn in_place_collectible<DEST, SRC>( const fn needs_realloc<SRC, DEST>(src_cap: usize, dst_cap: usize) -> bool { if const { mem::align_of::<SRC>() != mem::align_of::<DEST>() } { - return src_cap > 0; + // FIXME: use unreachable! once that works in const + panic!("in_place_collectible() prevents this"); } // If src type size is an integer multiple of the destination type size then @@ -276,8 +279,8 @@ where let dst_guard = InPlaceDstBufDrop { ptr: dst_buf, len, cap: dst_cap }; src.forget_allocation_drop_remaining(); - // Adjust the allocation if the alignment didn't match or the source had a capacity in bytes - // that wasn't a multiple of the destination type size. + // Adjust the allocation if the source had a capacity in bytes that wasn't a multiple + // of the destination type size. // Since the discrepancy should generally be small this should only result in some // bookkeeping updates and no memmove. if needs_realloc::<I::Src, T>(src_cap, dst_cap) { @@ -290,7 +293,7 @@ where let src_size = mem::size_of::<I::Src>().unchecked_mul(src_cap); let old_layout = Layout::from_size_align_unchecked(src_size, src_align); - // The must be equal or smaller for in-place iteration to be possible + // The allocation must be equal or smaller for in-place iteration to be possible // therefore the new layout must be ≤ the old one and therefore valid. let dst_align = mem::align_of::<T>(); let dst_size = mem::size_of::<T>().unchecked_mul(dst_cap); diff --git a/library/alloc/src/vec/spec_from_iter.rs b/library/alloc/src/vec/spec_from_iter.rs index e976552cf2b..33dd4139bc0 100644 --- a/library/alloc/src/vec/spec_from_iter.rs +++ b/library/alloc/src/vec/spec_from_iter.rs @@ -13,13 +13,13 @@ use super::{IntoIter, SpecExtend, SpecFromIterNested, Vec}; /// +-+-----------+ /// | /// v -/// +-+-------------------------------+ +---------------------+ -/// |SpecFromIter +---->+SpecFromIterNested | -/// |where I: | | |where I: | -/// | Iterator (default)----------+ | | Iterator (default) | -/// | vec::IntoIter | | | TrustedLen | -/// | SourceIterMarker---fallback-+ | +---------------------+ -/// +---------------------------------+ +/// +-+---------------------------------+ +---------------------+ +/// |SpecFromIter +---->+SpecFromIterNested | +/// |where I: | | |where I: | +/// | Iterator (default)------------+ | | Iterator (default) | +/// | vec::IntoIter | | | TrustedLen | +/// | InPlaceCollect--(fallback to)-+ | +---------------------+ +/// +-----------------------------------+ /// ``` pub(super) trait SpecFromIter<T, I> { fn from_iter(iter: I) -> Self; diff --git a/library/core/src/error.rs b/library/core/src/error.rs index f1a7ad93548..ded17e69bd9 100644 --- a/library/core/src/error.rs +++ b/library/core/src/error.rs @@ -415,7 +415,7 @@ where // Request and its methods /////////////////////////////////////////////////////////////////////////////// -/// `Request` supports generic, type-driven access to data. It's use is currently restricted to the +/// `Request` supports generic, type-driven access to data. Its use is currently restricted to the /// standard library in cases where trait authors wish to allow trait implementors to share generic /// information across trait boundaries. The motivating and prototypical use case is /// `core::error::Error` which would otherwise require a method per concrete type (eg. diff --git a/src/bootstrap/src/core/build_steps/setup.rs b/src/bootstrap/src/core/build_steps/setup.rs index 9c897ae1bb7..dd9c68aba7f 100644 --- a/src/bootstrap/src/core/build_steps/setup.rs +++ b/src/bootstrap/src/core/build_steps/setup.rs @@ -37,6 +37,7 @@ static SETTINGS_HASHES: &[&str] = &[ "3468fea433c25fff60be6b71e8a215a732a7b1268b6a83bf10d024344e140541", "47d227f424bf889b0d899b9cc992d5695e1b78c406e183cd78eafefbe5488923", "b526bd58d0262dd4dda2bff5bc5515b705fb668a46235ace3e057f807963a11a", + "828666b021d837a33e78d870b56d34c88a5e2c85de58b693607ec574f0c27000", ]; static RUST_ANALYZER_SETTINGS: &str = include_str!("../../../../etc/rust_analyzer_settings.json"); diff --git a/src/etc/rust_analyzer_settings.json b/src/etc/rust_analyzer_settings.json index 32a04cfd5d1..d329fe997cd 100644 --- a/src/etc/rust_analyzer_settings.json +++ b/src/etc/rust_analyzer_settings.json @@ -1,4 +1,5 @@ { + "git.detectSubmodulesLimit": 20, "rust-analyzer.check.invocationLocation": "root", "rust-analyzer.check.invocationStrategy": "once", "rust-analyzer.check.overrideCommand": [ diff --git a/src/librustdoc/passes/stripper.rs b/src/librustdoc/passes/stripper.rs index df955421ba4..1bea93c7842 100644 --- a/src/librustdoc/passes/stripper.rs +++ b/src/librustdoc/passes/stripper.rs @@ -56,13 +56,10 @@ impl<'a, 'tcx> DocFolder for Stripper<'a, 'tcx> { | clean::TraitItem(..) | clean::FunctionItem(..) | clean::VariantItem(..) - | clean::MethodItem(..) | clean::ForeignFunctionItem(..) | clean::ForeignStaticItem(..) | clean::ConstantItem(..) | clean::UnionItem(..) - | clean::AssocConstItem(..) - | clean::AssocTypeItem(..) | clean::TraitAliasItem(..) | clean::MacroItem(..) | clean::ForeignTypeItem => { @@ -80,6 +77,16 @@ impl<'a, 'tcx> DocFolder for Stripper<'a, 'tcx> { } } + clean::MethodItem(..) | clean::AssocConstItem(..) | clean::AssocTypeItem(..) => { + let item_id = i.item_id; + if item_id.is_local() + && !self.effective_visibilities.is_reachable(self.tcx, item_id.expect_def_id()) + { + debug!("Stripper: stripping {:?} {:?}", i.type_(), i.name); + return None; + } + } + clean::StructFieldItem(..) => { if i.visibility(self.tcx) != Some(Visibility::Public) { return Some(strip_item(i)); @@ -192,16 +199,16 @@ impl<'a> DocFolder for ImplStripper<'a, '_> { && imp.items.iter().all(|i| { let item_id = i.item_id; item_id.is_local() - && !is_item_reachable( - self.tcx, - self.is_json_output, - &self.cache.effective_visibilities, - item_id, - ) + && !self + .cache + .effective_visibilities + .is_reachable(self.tcx, item_id.expect_def_id()) }) { + debug!("ImplStripper: no public item; removing {imp:?}"); return None; } else if imp.items.is_empty() && i.doc_value().is_empty() { + debug!("ImplStripper: no item and no doc; removing {imp:?}"); return None; } } @@ -212,13 +219,13 @@ impl<'a> DocFolder for ImplStripper<'a, '_> { && !imp.for_.is_assoc_ty() && !self.should_keep_impl(&i, did) { - debug!("ImplStripper: impl item for stripped type; removing"); + debug!("ImplStripper: impl item for stripped type; removing {imp:?}"); return None; } if let Some(did) = imp.trait_.as_ref().map(|t| t.def_id()) && !self.should_keep_impl(&i, did) { - debug!("ImplStripper: impl item for stripped trait; removing"); + debug!("ImplStripper: impl item for stripped trait; removing {imp:?}"); return None; } if let Some(generics) = imp.trait_.as_ref().and_then(|t| t.generics()) { @@ -226,7 +233,7 @@ impl<'a> DocFolder for ImplStripper<'a, '_> { if let Some(did) = typaram.def_id(self.cache) && !self.should_keep_impl(&i, did) { - debug!("ImplStripper: stripped item in trait's generics; removing impl"); + debug!("ImplStripper: stripped item in trait's generics; removing {imp:?}"); return None; } } diff --git a/src/tools/clippy/clippy_lints/src/derive.rs b/src/tools/clippy/clippy_lints/src/derive.rs index d1fe9f5cbec..df596338b95 100644 --- a/src/tools/clippy/clippy_lints/src/derive.rs +++ b/src/tools/clippy/clippy_lints/src/derive.rs @@ -451,12 +451,12 @@ fn check_partial_eq_without_eq<'tcx>(cx: &LateContext<'tcx>, span: Span, trait_r && let Some(def_id) = trait_ref.trait_def_id() && cx.tcx.is_diagnostic_item(sym::PartialEq, def_id) && let param_env = param_env_for_derived_eq(cx.tcx, adt.did(), eq_trait_def_id) - && !implements_trait_with_env(cx.tcx, param_env, ty, eq_trait_def_id, adt.did(),&[]) + && !implements_trait_with_env(cx.tcx, param_env, ty, eq_trait_def_id, None, &[]) // If all of our fields implement `Eq`, we can implement `Eq` too && adt .all_fields() .map(|f| f.ty(cx.tcx, args)) - .all(|ty| implements_trait_with_env(cx.tcx, param_env, ty, eq_trait_def_id, adt.did(), &[])) + .all(|ty| implements_trait_with_env(cx.tcx, param_env, ty, eq_trait_def_id, None, &[])) { span_lint_and_sugg( cx, diff --git a/src/tools/clippy/clippy_lints/src/loops/explicit_iter_loop.rs b/src/tools/clippy/clippy_lints/src/loops/explicit_iter_loop.rs index c7980060807..814ccaa36f5 100644 --- a/src/tools/clippy/clippy_lints/src/loops/explicit_iter_loop.rs +++ b/src/tools/clippy/clippy_lints/src/loops/explicit_iter_loop.rs @@ -118,7 +118,7 @@ fn is_ref_iterable<'tcx>( .liberate_late_bound_regions(fn_id, cx.tcx.fn_sig(fn_id).skip_binder()) && let &[req_self_ty, req_res_ty] = &**sig.inputs_and_output && let param_env = cx.tcx.param_env(fn_id) - && implements_trait_with_env(cx.tcx, param_env, req_self_ty, trait_id, fn_id, &[]) + && implements_trait_with_env(cx.tcx, param_env, req_self_ty, trait_id, Some(fn_id), &[]) && let Some(into_iter_ty) = make_normalized_projection_with_regions(cx.tcx, param_env, trait_id, sym!(IntoIter), [req_self_ty]) && let req_res_ty = normalize_with_regions(cx.tcx, param_env, req_res_ty) diff --git a/src/tools/clippy/clippy_utils/src/ty.rs b/src/tools/clippy/clippy_utils/src/ty.rs index 61d0663aa83..59ebe685c11 100644 --- a/src/tools/clippy/clippy_utils/src/ty.rs +++ b/src/tools/clippy/clippy_utils/src/ty.rs @@ -214,36 +214,21 @@ pub fn implements_trait<'tcx>( trait_id: DefId, args: &[GenericArg<'tcx>], ) -> bool { - let callee_id = cx - .enclosing_body - .map(|body| cx.tcx.hir().body_owner(body).owner.to_def_id()); - implements_trait_with_env_from_iter( - cx.tcx, - cx.param_env, - ty, - trait_id, - callee_id, - args.iter().map(|&x| Some(x)), - ) + implements_trait_with_env_from_iter(cx.tcx, cx.param_env, ty, trait_id, None, args.iter().map(|&x| Some(x))) } /// Same as `implements_trait` but allows using a `ParamEnv` different from the lint context. +/// +/// The `callee_id` argument is used to determine whether this is a function call in a `const fn` environment, used for checking const traits. pub fn implements_trait_with_env<'tcx>( tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>, ty: Ty<'tcx>, trait_id: DefId, - callee_id: DefId, + callee_id: Option<DefId>, args: &[GenericArg<'tcx>], ) -> bool { - implements_trait_with_env_from_iter( - tcx, - param_env, - ty, - trait_id, - Some(callee_id), - args.iter().map(|&x| Some(x)), - ) + implements_trait_with_env_from_iter(tcx, param_env, ty, trait_id, callee_id, args.iter().map(|&x| Some(x))) } /// Same as `implements_trait_from_env` but takes the arguments as an iterator. @@ -258,6 +243,13 @@ pub fn implements_trait_with_env_from_iter<'tcx>( // Clippy shouldn't have infer types assert!(!ty.has_infer()); + // If a `callee_id` is passed, then we assert that it is a body owner + // through calling `body_owner_kind`, which would panic if the callee + // does not have a body. + if let Some(callee_id) = callee_id { + let _ = tcx.hir().body_owner_kind(callee_id); + } + let ty = tcx.erase_regions(ty); if ty.has_escaping_bound_vars() { return false; diff --git a/tests/rustdoc/async-fn.rs b/tests/rustdoc/async-fn.rs index 70bcbcb6ff4..b3c35c8c3f3 100644 --- a/tests/rustdoc/async-fn.rs +++ b/tests/rustdoc/async-fn.rs @@ -48,6 +48,8 @@ impl Foo { pub trait Pattern<'a> {} +impl Pattern<'_> for () {} + pub trait Trait<const N: usize> {} // @has async_fn/fn.const_generics.html // @has - '//pre[@class="rust item-decl"]' 'pub async fn const_generics<const N: usize>(_: impl Trait<N>)' @@ -57,18 +59,18 @@ pub async fn const_generics<const N: usize>(_: impl Trait<N>) {} // regression test for #63037 // @has async_fn/fn.elided.html // @has - '//pre[@class="rust item-decl"]' 'pub async fn elided(foo: &str) -> &str' -pub async fn elided(foo: &str) -> &str {} +pub async fn elided(foo: &str) -> &str { "" } // This should really be shown as written, but for implementation reasons it's difficult. // See `impl Clean for TyKind::Ref`. // @has async_fn/fn.user_elided.html // @has - '//pre[@class="rust item-decl"]' 'pub async fn user_elided(foo: &str) -> &str' -pub async fn user_elided(foo: &'_ str) -> &str {} +pub async fn user_elided(foo: &'_ str) -> &str { "" } // @has async_fn/fn.static_trait.html // @has - '//pre[@class="rust item-decl"]' 'pub async fn static_trait(foo: &str) -> Box<dyn Bar>' -pub async fn static_trait(foo: &str) -> Box<dyn Bar> {} +pub async fn static_trait(foo: &str) -> Box<dyn Bar> { Box::new(()) } // @has async_fn/fn.lifetime_for_trait.html // @has - '//pre[@class="rust item-decl"]' "pub async fn lifetime_for_trait(foo: &str) -> Box<dyn Bar + '_>" -pub async fn lifetime_for_trait(foo: &str) -> Box<dyn Bar + '_> {} +pub async fn lifetime_for_trait(foo: &str) -> Box<dyn Bar + '_> { Box::new(()) } // @has async_fn/fn.elided_in_input_trait.html // @has - '//pre[@class="rust item-decl"]' "pub async fn elided_in_input_trait(t: impl Pattern<'_>)" pub async fn elided_in_input_trait(t: impl Pattern<'_>) {} @@ -78,10 +80,12 @@ struct AsyncFdReadyGuard<'a, T> { x: &'a T } impl Foo { // @has async_fn/struct.Foo.html // @has - '//*[@class="method"]' 'pub async fn complicated_lifetimes( &self, context: &impl Bar ) -> impl Iterator<Item = &usize>' - pub async fn complicated_lifetimes(&self, context: &impl Bar) -> impl Iterator<Item = &usize> {} + pub async fn complicated_lifetimes(&self, context: &impl Bar) -> impl Iterator<Item = &usize> { + [0].iter() + } // taken from `tokio` as an example of a method that was particularly bad before // @has - '//*[@class="method"]' "pub async fn readable<T>(&self) -> Result<AsyncFdReadyGuard<'_, T>, ()>" - pub async fn readable<T>(&self) -> Result<AsyncFdReadyGuard<'_, T>, ()> {} + pub async fn readable<T>(&self) -> Result<AsyncFdReadyGuard<'_, T>, ()> { Err(()) } // @has - '//*[@class="method"]' "pub async fn mut_self(&mut self)" pub async fn mut_self(&mut self) {} } @@ -89,7 +93,7 @@ impl Foo { // test named lifetimes, just in case // @has async_fn/fn.named.html // @has - '//pre[@class="rust item-decl"]' "pub async fn named<'a, 'b>(foo: &'a str) -> &'b str" -pub async fn named<'a, 'b>(foo: &'a str) -> &'b str {} +pub async fn named<'a, 'b>(foo: &'a str) -> &'b str { "" } // @has async_fn/fn.named_trait.html // @has - '//pre[@class="rust item-decl"]' "pub async fn named_trait<'a, 'b>(foo: impl Pattern<'a>) -> impl Pattern<'b>" pub async fn named_trait<'a, 'b>(foo: impl Pattern<'a>) -> impl Pattern<'b> {} diff --git a/tests/rustdoc/impl-on-ty-alias-issue-119015.rs b/tests/rustdoc/impl-on-ty-alias-issue-119015.rs new file mode 100644 index 00000000000..68996deae6f --- /dev/null +++ b/tests/rustdoc/impl-on-ty-alias-issue-119015.rs @@ -0,0 +1,27 @@ +#![crate_name = "foo"] + +// @has 'foo/index.html' +// There should be only `type A`. +// @count - '//*[@class="item-table"]//*[@class="item-name"]' 1 +// @has - '//*[@class="item-name"]/a[@href="type.A.html"]' 'A' + +mod foo { + pub struct S; +} + +use foo::S; + +pub type A = S; + +// @has 'foo/type.A.html' +// @has - '//*[@id="method.default"]/h4' 'fn default() -> Self' +impl Default for A { + fn default() -> Self { + S + } +} + +// @has - '//*[@id="method.a"]/h4' 'pub fn a(&self)' +impl A { + pub fn a(&self) {} +} diff --git a/tests/ui/parser/removed-syntax-box.fixed b/tests/ui/parser/removed-syntax/removed-syntax-box.fixed index 09d1304b775..09d1304b775 100644 --- a/tests/ui/parser/removed-syntax-box.fixed +++ b/tests/ui/parser/removed-syntax/removed-syntax-box.fixed diff --git a/tests/ui/parser/removed-syntax-box.rs b/tests/ui/parser/removed-syntax/removed-syntax-box.rs index 1f5061b02c7..1f5061b02c7 100644 --- a/tests/ui/parser/removed-syntax-box.rs +++ b/tests/ui/parser/removed-syntax/removed-syntax-box.rs diff --git a/tests/ui/parser/removed-syntax-box.stderr b/tests/ui/parser/removed-syntax/removed-syntax-box.stderr index 46b891587d5..46b891587d5 100644 --- a/tests/ui/parser/removed-syntax-box.stderr +++ b/tests/ui/parser/removed-syntax/removed-syntax-box.stderr diff --git a/tests/ui/parser/removed-syntax-closure-lifetime.rs b/tests/ui/parser/removed-syntax/removed-syntax-closure-lifetime.rs index e807a179473..e807a179473 100644 --- a/tests/ui/parser/removed-syntax-closure-lifetime.rs +++ b/tests/ui/parser/removed-syntax/removed-syntax-closure-lifetime.rs diff --git a/tests/ui/parser/removed-syntax-closure-lifetime.stderr b/tests/ui/parser/removed-syntax/removed-syntax-closure-lifetime.stderr index 4c991d67ea7..4c991d67ea7 100644 --- a/tests/ui/parser/removed-syntax-closure-lifetime.stderr +++ b/tests/ui/parser/removed-syntax/removed-syntax-closure-lifetime.stderr diff --git a/tests/ui/parser/removed-syntax-enum-newtype.rs b/tests/ui/parser/removed-syntax/removed-syntax-enum-newtype.rs index 518f90b2b83..518f90b2b83 100644 --- a/tests/ui/parser/removed-syntax-enum-newtype.rs +++ b/tests/ui/parser/removed-syntax/removed-syntax-enum-newtype.rs diff --git a/tests/ui/parser/removed-syntax-enum-newtype.stderr b/tests/ui/parser/removed-syntax/removed-syntax-enum-newtype.stderr index 5b917e93853..5b917e93853 100644 --- a/tests/ui/parser/removed-syntax-enum-newtype.stderr +++ b/tests/ui/parser/removed-syntax/removed-syntax-enum-newtype.stderr diff --git a/tests/ui/parser/removed-syntax-field-let-2.rs b/tests/ui/parser/removed-syntax/removed-syntax-field-let-2.rs index 7ff91b476ae..7ff91b476ae 100644 --- a/tests/ui/parser/removed-syntax-field-let-2.rs +++ b/tests/ui/parser/removed-syntax/removed-syntax-field-let-2.rs diff --git a/tests/ui/parser/removed-syntax-field-let-2.stderr b/tests/ui/parser/removed-syntax/removed-syntax-field-let-2.stderr index fda0919b9b6..fda0919b9b6 100644 --- a/tests/ui/parser/removed-syntax-field-let-2.stderr +++ b/tests/ui/parser/removed-syntax/removed-syntax-field-let-2.stderr diff --git a/tests/ui/parser/removed-syntax-field-let.rs b/tests/ui/parser/removed-syntax/removed-syntax-field-let.rs index 6d64de296f1..6d64de296f1 100644 --- a/tests/ui/parser/removed-syntax-field-let.rs +++ b/tests/ui/parser/removed-syntax/removed-syntax-field-let.rs diff --git a/tests/ui/parser/removed-syntax-field-let.stderr b/tests/ui/parser/removed-syntax/removed-syntax-field-let.stderr index 339d056e636..339d056e636 100644 --- a/tests/ui/parser/removed-syntax-field-let.stderr +++ b/tests/ui/parser/removed-syntax/removed-syntax-field-let.stderr diff --git a/tests/ui/parser/removed-syntax-field-semicolon.rs b/tests/ui/parser/removed-syntax/removed-syntax-field-semicolon.rs index 808f2a5cc38..808f2a5cc38 100644 --- a/tests/ui/parser/removed-syntax-field-semicolon.rs +++ b/tests/ui/parser/removed-syntax/removed-syntax-field-semicolon.rs diff --git a/tests/ui/parser/removed-syntax-field-semicolon.stderr b/tests/ui/parser/removed-syntax/removed-syntax-field-semicolon.stderr index 522912a9e1c..522912a9e1c 100644 --- a/tests/ui/parser/removed-syntax-field-semicolon.stderr +++ b/tests/ui/parser/removed-syntax/removed-syntax-field-semicolon.stderr diff --git a/tests/ui/parser/removed-syntax-fixed-vec.rs b/tests/ui/parser/removed-syntax/removed-syntax-fixed-vec.rs index 560efecb91c..560efecb91c 100644 --- a/tests/ui/parser/removed-syntax-fixed-vec.rs +++ b/tests/ui/parser/removed-syntax/removed-syntax-fixed-vec.rs diff --git a/tests/ui/parser/removed-syntax-fixed-vec.stderr b/tests/ui/parser/removed-syntax/removed-syntax-fixed-vec.stderr index 5bc9c2ccf00..5bc9c2ccf00 100644 --- a/tests/ui/parser/removed-syntax-fixed-vec.stderr +++ b/tests/ui/parser/removed-syntax/removed-syntax-fixed-vec.stderr diff --git a/tests/ui/parser/removed-syntax-fn-sigil.rs b/tests/ui/parser/removed-syntax/removed-syntax-fn-sigil.rs index d55a032d1f2..d55a032d1f2 100644 --- a/tests/ui/parser/removed-syntax-fn-sigil.rs +++ b/tests/ui/parser/removed-syntax/removed-syntax-fn-sigil.rs diff --git a/tests/ui/parser/removed-syntax-fn-sigil.stderr b/tests/ui/parser/removed-syntax/removed-syntax-fn-sigil.stderr index 0d377416700..0d377416700 100644 --- a/tests/ui/parser/removed-syntax-fn-sigil.stderr +++ b/tests/ui/parser/removed-syntax/removed-syntax-fn-sigil.stderr diff --git a/tests/ui/parser/removed-syntax-mode.rs b/tests/ui/parser/removed-syntax/removed-syntax-mode.rs index a438db3b0c1..a438db3b0c1 100644 --- a/tests/ui/parser/removed-syntax-mode.rs +++ b/tests/ui/parser/removed-syntax/removed-syntax-mode.rs diff --git a/tests/ui/parser/removed-syntax-mode.stderr b/tests/ui/parser/removed-syntax/removed-syntax-mode.stderr index fd964c4b7f0..fd964c4b7f0 100644 --- a/tests/ui/parser/removed-syntax-mode.stderr +++ b/tests/ui/parser/removed-syntax/removed-syntax-mode.stderr diff --git a/tests/ui/parser/removed-syntax-mut-vec-expr.rs b/tests/ui/parser/removed-syntax/removed-syntax-mut-vec-expr.rs index 2ee95db5a25..2ee95db5a25 100644 --- a/tests/ui/parser/removed-syntax-mut-vec-expr.rs +++ b/tests/ui/parser/removed-syntax/removed-syntax-mut-vec-expr.rs diff --git a/tests/ui/parser/removed-syntax-mut-vec-expr.stderr b/tests/ui/parser/removed-syntax/removed-syntax-mut-vec-expr.stderr index a1aa1ae49e3..a1aa1ae49e3 100644 --- a/tests/ui/parser/removed-syntax-mut-vec-expr.stderr +++ b/tests/ui/parser/removed-syntax/removed-syntax-mut-vec-expr.stderr diff --git a/tests/ui/parser/removed-syntax-mut-vec-ty.rs b/tests/ui/parser/removed-syntax/removed-syntax-mut-vec-ty.rs index 923a7ea37a4..923a7ea37a4 100644 --- a/tests/ui/parser/removed-syntax-mut-vec-ty.rs +++ b/tests/ui/parser/removed-syntax/removed-syntax-mut-vec-ty.rs diff --git a/tests/ui/parser/removed-syntax-mut-vec-ty.stderr b/tests/ui/parser/removed-syntax/removed-syntax-mut-vec-ty.stderr index beaae7cddaa..beaae7cddaa 100644 --- a/tests/ui/parser/removed-syntax-mut-vec-ty.stderr +++ b/tests/ui/parser/removed-syntax/removed-syntax-mut-vec-ty.stderr diff --git a/tests/ui/parser/removed-syntax-ptr-lifetime.rs b/tests/ui/parser/removed-syntax/removed-syntax-ptr-lifetime.rs index cc69af44a13..cc69af44a13 100644 --- a/tests/ui/parser/removed-syntax-ptr-lifetime.rs +++ b/tests/ui/parser/removed-syntax/removed-syntax-ptr-lifetime.rs diff --git a/tests/ui/parser/removed-syntax-ptr-lifetime.stderr b/tests/ui/parser/removed-syntax/removed-syntax-ptr-lifetime.stderr index 5c74efffabf..5c74efffabf 100644 --- a/tests/ui/parser/removed-syntax-ptr-lifetime.stderr +++ b/tests/ui/parser/removed-syntax/removed-syntax-ptr-lifetime.stderr diff --git a/tests/ui/parser/removed-syntax-record.rs b/tests/ui/parser/removed-syntax/removed-syntax-record.rs index d1d91c8f7dc..d1d91c8f7dc 100644 --- a/tests/ui/parser/removed-syntax-record.rs +++ b/tests/ui/parser/removed-syntax/removed-syntax-record.rs diff --git a/tests/ui/parser/removed-syntax-record.stderr b/tests/ui/parser/removed-syntax/removed-syntax-record.stderr index dbf09f1c75b..dbf09f1c75b 100644 --- a/tests/ui/parser/removed-syntax-record.stderr +++ b/tests/ui/parser/removed-syntax/removed-syntax-record.stderr diff --git a/tests/ui/parser/removed-syntax-static-fn.rs b/tests/ui/parser/removed-syntax/removed-syntax-static-fn.rs index cd643b874db..cd643b874db 100644 --- a/tests/ui/parser/removed-syntax-static-fn.rs +++ b/tests/ui/parser/removed-syntax/removed-syntax-static-fn.rs diff --git a/tests/ui/parser/removed-syntax-static-fn.stderr b/tests/ui/parser/removed-syntax/removed-syntax-static-fn.stderr index 52e0658949d..52e0658949d 100644 --- a/tests/ui/parser/removed-syntax-static-fn.stderr +++ b/tests/ui/parser/removed-syntax/removed-syntax-static-fn.stderr diff --git a/tests/ui/parser/removed-syntax-uniq-mut-expr.rs b/tests/ui/parser/removed-syntax/removed-syntax-uniq-mut-expr.rs index 08ef4b43269..08ef4b43269 100644 --- a/tests/ui/parser/removed-syntax-uniq-mut-expr.rs +++ b/tests/ui/parser/removed-syntax/removed-syntax-uniq-mut-expr.rs diff --git a/tests/ui/parser/removed-syntax-uniq-mut-expr.stderr b/tests/ui/parser/removed-syntax/removed-syntax-uniq-mut-expr.stderr index 7aaedad19d8..7aaedad19d8 100644 --- a/tests/ui/parser/removed-syntax-uniq-mut-expr.stderr +++ b/tests/ui/parser/removed-syntax/removed-syntax-uniq-mut-expr.stderr diff --git a/tests/ui/parser/removed-syntax-uniq-mut-ty.rs b/tests/ui/parser/removed-syntax/removed-syntax-uniq-mut-ty.rs index a8dee5bbda4..a8dee5bbda4 100644 --- a/tests/ui/parser/removed-syntax-uniq-mut-ty.rs +++ b/tests/ui/parser/removed-syntax/removed-syntax-uniq-mut-ty.rs diff --git a/tests/ui/parser/removed-syntax-uniq-mut-ty.stderr b/tests/ui/parser/removed-syntax/removed-syntax-uniq-mut-ty.stderr index 5ae1f4f587e..5ae1f4f587e 100644 --- a/tests/ui/parser/removed-syntax-uniq-mut-ty.stderr +++ b/tests/ui/parser/removed-syntax/removed-syntax-uniq-mut-ty.stderr diff --git a/tests/ui/parser/removed-syntax-with-1.rs b/tests/ui/parser/removed-syntax/removed-syntax-with-1.rs index 2c1e152dcee..2c1e152dcee 100644 --- a/tests/ui/parser/removed-syntax-with-1.rs +++ b/tests/ui/parser/removed-syntax/removed-syntax-with-1.rs diff --git a/tests/ui/parser/removed-syntax-with-1.stderr b/tests/ui/parser/removed-syntax/removed-syntax-with-1.stderr index 78042678a87..78042678a87 100644 --- a/tests/ui/parser/removed-syntax-with-1.stderr +++ b/tests/ui/parser/removed-syntax/removed-syntax-with-1.stderr diff --git a/tests/ui/parser/removed-syntax-with-2.rs b/tests/ui/parser/removed-syntax/removed-syntax-with-2.rs index 451057c66a1..451057c66a1 100644 --- a/tests/ui/parser/removed-syntax-with-2.rs +++ b/tests/ui/parser/removed-syntax/removed-syntax-with-2.rs diff --git a/tests/ui/parser/removed-syntax-with-2.stderr b/tests/ui/parser/removed-syntax/removed-syntax-with-2.stderr index e75c5bcd643..e75c5bcd643 100644 --- a/tests/ui/parser/removed-syntax-with-2.stderr +++ b/tests/ui/parser/removed-syntax/removed-syntax-with-2.stderr |
