From 56211738ea8e5b5ca0d5b460a73944f0618aaa4f Mon Sep 17 00:00:00 2001 From: CoCo-Japan-pan <115922543+CoCo-Japan-pan@users.noreply.github.com> Date: Sun, 19 Apr 2026 01:16:23 +0900 Subject: [PATCH 01/20] Reorder keywords to place restrictions next to visibility --- compiler/rustc_parse/src/parser/item.rs | 122 ++++++++++-------------- 1 file changed, 49 insertions(+), 73 deletions(-) diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index ccfc9438f1ccf..0be16e35b7b35 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -1052,80 +1052,58 @@ impl<'a> Parser<'a> { } } - /// Is there an `[ impl(in? path) ]? trait` item `dist` tokens ahead? - fn is_trait_with_maybe_impl_restriction_in_front(&self, dist: usize) -> bool { - // `trait` - if self.is_keyword_ahead(dist, &[kw::Trait]) { - return true; - } - // `impl(` - if !self.is_keyword_ahead(dist, &[kw::Impl]) - || !self.look_ahead(dist + 1, |t| t == &token::OpenParen) - { - return false; - } - // `crate | super | self) trait` - if self.is_keyword_ahead(dist + 2, &[kw::Crate, kw::Super, kw::SelfLower]) - && self.look_ahead(dist + 3, |t| t == &token::CloseParen) - && self.is_keyword_ahead(dist + 4, &[kw::Trait]) - { - return true; - } - // `impl(in? something) trait` - // We catch cases where the `in` keyword is missing to provide a - // better error message. This is handled later in - // `self.recover_incorrect_impl_restriction`. - self.tree_look_ahead(dist + 2, |t| { - if let TokenTree::Token(token, _) = t { token.is_keyword(kw::Trait) } else { false } - }) - .unwrap_or(false) - } - - /// Is this an `(const unsafe? auto? [ impl(in? path) ]? | unsafe auto? [ impl(in? path) ]? | auto [ impl(in? path) ]? | [ impl(in? path) ]?) trait` item? + /// Is this an `[impl(in? path)]? const? unsafe? auto? trait` item? fn check_trait_front_matter(&mut self) -> bool { - // `[ impl(in? path) ]? trait` - if self.is_trait_with_maybe_impl_restriction_in_front(0) { - return true; - } - // `auto [ impl(in? path) ]? trait` - if self.check_keyword(exp!(Auto)) && self.is_trait_with_maybe_impl_restriction_in_front(1) { - return true; - } - // `unsafe auto? [ impl(in? path) ]? trait` - if self.check_keyword(exp!(Unsafe)) - && (self.is_trait_with_maybe_impl_restriction_in_front(1) - || self.is_keyword_ahead(1, &[kw::Auto]) - && self.is_trait_with_maybe_impl_restriction_in_front(2)) - { - return true; - } - // `const` ... - if !self.check_keyword(exp!(Const)) { - return false; - } - // `const [ impl(in? path) ]? trait` - if self.is_trait_with_maybe_impl_restriction_in_front(1) { - return true; - } - // `const (unsafe | auto) [ impl(in? path) ]? trait` - if self.is_keyword_ahead(1, &[kw::Unsafe, kw::Auto]) - && self.is_trait_with_maybe_impl_restriction_in_front(2) - { - return true; + const SUFFIXES: &[&[Symbol]] = &[ + &[kw::Trait], + &[kw::Auto, kw::Trait], + &[kw::Unsafe, kw::Trait], + &[kw::Unsafe, kw::Auto, kw::Trait], + &[kw::Const, kw::Trait], + &[kw::Const, kw::Auto, kw::Trait], + &[kw::Const, kw::Unsafe, kw::Trait], + &[kw::Const, kw::Unsafe, kw::Auto, kw::Trait], + ]; + // `impl(` + if self.check_keyword(exp!(Impl)) && self.look_ahead(1, |t| t == &token::OpenParen) { + // Since the `path` in `impl(in? path)` can be arbitrarily long, + // we treat `(in? path)` as a `TokenTree::Delimited`, + // so we look ahead over token trees rather than tokens. + SUFFIXES.iter().any(|suffix| { + suffix.iter().enumerate().all(|(i, kw)| { + self.tree_look_ahead(i + 2, |t| { + if let TokenTree::Token(token, _) = t { + token.is_keyword(*kw) + } else { + false + } + }) + .unwrap_or(false) + }) + }) + } else { + SUFFIXES.iter().any(|suffix| { + suffix.iter().enumerate().all(|(i, kw)| { + // We use `check_keyword` for the first token to include it in the expected tokens. + if i == 0 { + match *kw { + kw::Const => self.check_keyword(exp!(Const)), + kw::Unsafe => self.check_keyword(exp!(Unsafe)), + kw::Auto => self.check_keyword(exp!(Auto)), + kw::Trait => self.check_keyword(exp!(Trait)), + _ => unreachable!(), + } + } else { + self.is_keyword_ahead(i, &[*kw]) + } + }) + }) } - // `const unsafe auto [ impl(in? path) ]? trait` - self.is_keyword_ahead(1, &[kw::Unsafe]) - && self.is_keyword_ahead(2, &[kw::Auto]) - && self.is_trait_with_maybe_impl_restriction_in_front(3) } - /// Parses `const? unsafe? auto? [impl(in? path)]? trait Foo { ... }` or `trait Foo = Bar;`. - /// - /// FIXME(restrictions): The current keyword order follows the grammar specified in RFC 3323. - /// However, whether the restriction should be grouped closer to the visibility modifier - /// (e.g., `pub impl(crate) const unsafe auto trait`) remains an unresolved design question. - /// This ordering must be kept in sync with the logic in `check_trait_front_matter`. + /// Parses `[impl(in? path)]? const? unsafe? auto? trait Foo { ... }` or `trait Foo = Bar;`. fn parse_item_trait(&mut self, attrs: &mut AttrVec, lo: Span) -> PResult<'a, ItemKind> { + let impl_restriction = self.parse_impl_restriction()?; let constness = self.parse_constness(Case::Sensitive); if let Const::Yes(span) = constness { self.psess.gated_spans.gate(sym::const_trait_impl, span); @@ -1139,8 +1117,6 @@ impl<'a> Parser<'a> { IsAuto::No }; - let impl_restriction = self.parse_impl_restriction()?; - self.expect_keyword(exp!(Trait))?; let ident = self.parse_ident()?; let mut generics = self.parse_generics()?; @@ -2966,8 +2942,8 @@ impl<'a> Parser<'a> { && !self.is_unsafe_foreign_mod() // Rule out `async gen {` and `async gen move {` && !self.is_async_gen_block() - // Rule out `const unsafe auto` and `const unsafe trait` and `const unsafe impl`. - && !self.is_keyword_ahead(2, &[kw::Auto, kw::Trait, kw::Impl]) + // Rule out `const unsafe auto` and `const unsafe trait` + && !self.is_keyword_ahead(2, &[kw::Auto, kw::Trait]) ) }) // `extern ABI fn` From 5d8a2977b1f07c04ed8d687f8deb0aa46f87e80e Mon Sep 17 00:00:00 2001 From: CoCo-Japan-pan <115922543+CoCo-Japan-pan@users.noreply.github.com> Date: Sat, 18 Apr 2026 23:41:16 +0900 Subject: [PATCH 02/20] Update `rustfmt` --- src/tools/rustfmt/src/items.rs | 2 +- .../rustfmt/tests/source/impl-restriction.rs | 19 ++++++++++--------- .../rustfmt/tests/target/impl-restriction.rs | 8 ++++---- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/tools/rustfmt/src/items.rs b/src/tools/rustfmt/src/items.rs index a4251a9a3bd4e..baa1cd38237bf 100644 --- a/src/tools/rustfmt/src/items.rs +++ b/src/tools/rustfmt/src/items.rs @@ -1169,10 +1169,10 @@ pub(crate) fn format_trait( let header = format!( "{}{}{}{}{}trait ", format_visibility(context, &item.vis), + format_impl_restriction(context, impl_restriction), format_constness(constness), format_safety(safety), format_auto(is_auto), - format_impl_restriction(context, impl_restriction), ); result.push_str(&header); diff --git a/src/tools/rustfmt/tests/source/impl-restriction.rs b/src/tools/rustfmt/tests/source/impl-restriction.rs index 4459d9a8ba2b5..3203626eaaae8 100644 --- a/src/tools/rustfmt/tests/source/impl-restriction.rs +++ b/src/tools/rustfmt/tests/source/impl-restriction.rs @@ -18,24 +18,25 @@ bar ) trait Baz {} pub -const impl (self) +const trait QuxConst {} -pub -auto impl( +pub +impl( super -) +) auto trait QuxAuto {} -pub -unsafe impl -(in crate) +pub +impl +(in crate) unsafe trait QuxUnsafe {} -pub const -unsafe impl +pub +impl (in super ::foo) +const unsafe trait QuxConstUnsafe {} diff --git a/src/tools/rustfmt/tests/target/impl-restriction.rs b/src/tools/rustfmt/tests/target/impl-restriction.rs index 4ff617af0f257..f5e1f3b7f6b5f 100644 --- a/src/tools/rustfmt/tests/target/impl-restriction.rs +++ b/src/tools/rustfmt/tests/target/impl-restriction.rs @@ -6,10 +6,10 @@ pub impl(in crate) trait Bar {} pub impl(in foo::bar) trait Baz {} -pub const impl(self) trait QuxConst {} +pub impl(self) const trait QuxConst {} -pub auto impl(super) trait QuxAuto {} +pub impl(super) auto trait QuxAuto {} -pub unsafe impl(in crate) trait QuxUnsafe {} +pub impl(in crate) unsafe trait QuxUnsafe {} -pub const unsafe impl(in super::foo) trait QuxConstUnsafe {} +pub impl(in super::foo) const unsafe trait QuxConstUnsafe {} From a0b8e894564662a0eeee0d6230a83c82c1ef5da7 Mon Sep 17 00:00:00 2001 From: CoCo-Japan-pan <115922543+CoCo-Japan-pan@users.noreply.github.com> Date: Sun, 19 Apr 2026 00:01:43 +0900 Subject: [PATCH 03/20] Update AST pretty printing --- compiler/rustc_ast/src/ast.rs | 2 +- compiler/rustc_ast_lowering/src/item.rs | 2 +- compiler/rustc_ast_pretty/src/pprust/state/item.rs | 4 ++-- compiler/rustc_parse/src/parser/item.rs | 2 +- src/tools/clippy/clippy_utils/src/ast_utils/mod.rs | 8 ++++---- src/tools/rustfmt/src/items.rs | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index b2c573c23f891..4eff1352d7e66 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -3786,10 +3786,10 @@ pub struct TraitAlias { #[derive(Clone, Encodable, Decodable, Debug, Walkable)] pub struct Trait { + pub impl_restriction: ImplRestriction, pub constness: Const, pub safety: Safety, pub is_auto: IsAuto, - pub impl_restriction: ImplRestriction, pub ident: Ident, pub generics: Generics, #[visitable(extra = BoundKind::SuperTraits)] diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index 239daecd3d1fb..6d5d34268ea18 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -543,10 +543,10 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> { }) } ItemKind::Trait(box Trait { + impl_restriction, constness, is_auto, safety, - impl_restriction, ident, generics, bounds, diff --git a/compiler/rustc_ast_pretty/src/pprust/state/item.rs b/compiler/rustc_ast_pretty/src/pprust/state/item.rs index cb9bbf014e013..5154e5dc005cd 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state/item.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state/item.rs @@ -371,10 +371,10 @@ impl<'a> State<'a> { self.bclose(item.span, empty, cb); } ast::ItemKind::Trait(box ast::Trait { + impl_restriction, constness, safety, is_auto, - impl_restriction, ident, generics, bounds, @@ -382,10 +382,10 @@ impl<'a> State<'a> { }) => { let (cb, ib) = self.head(""); self.print_visibility(&item.vis); + self.print_impl_restriction(impl_restriction); self.print_constness(*constness); self.print_safety(*safety); self.print_is_auto(*is_auto); - self.print_impl_restriction(impl_restriction); self.word_nbsp("trait"); self.print_ident(*ident); self.print_generic_params(&generics.params); diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 0be16e35b7b35..e72cf491004e3 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -1157,10 +1157,10 @@ impl<'a> Parser<'a> { generics.where_clause = self.parse_where_clause()?; let items = self.parse_item_list(attrs, |p| p.parse_trait_item(ForceCollect::No))?; Ok(ItemKind::Trait(Box::new(Trait { + impl_restriction, constness, is_auto, safety, - impl_restriction, ident, generics, bounds, diff --git a/src/tools/clippy/clippy_utils/src/ast_utils/mod.rs b/src/tools/clippy/clippy_utils/src/ast_utils/mod.rs index c96c0649753fd..82142d55e21d8 100644 --- a/src/tools/clippy/clippy_utils/src/ast_utils/mod.rs +++ b/src/tools/clippy/clippy_utils/src/ast_utils/mod.rs @@ -448,30 +448,30 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool { }, ( Trait(box ast::Trait { + impl_restriction: liprt, constness: lc, is_auto: la, safety: lu, - impl_restriction: liprt, ident: li, generics: lg, bounds: lb, items: lis, }), Trait(box ast::Trait { + impl_restriction: riprt, constness: rc, is_auto: ra, safety: ru, - impl_restriction: riprt, ident: ri, generics: rg, bounds: rb, items: ris, }), ) => { - matches!(lc, ast::Const::No) == matches!(rc, ast::Const::No) + eq_impl_restriction(liprt, riprt) + && matches!(lc, ast::Const::No) == matches!(rc, ast::Const::No) && la == ra && matches!(lu, Safety::Default) == matches!(ru, Safety::Default) - && eq_impl_restriction(liprt, riprt) && eq_id(*li, *ri) && eq_generics(lg, rg) && over(lb, rb, eq_generic_bound) diff --git a/src/tools/rustfmt/src/items.rs b/src/tools/rustfmt/src/items.rs index baa1cd38237bf..32f71703e019f 100644 --- a/src/tools/rustfmt/src/items.rs +++ b/src/tools/rustfmt/src/items.rs @@ -1155,10 +1155,10 @@ pub(crate) fn format_trait( offset: Indent, ) -> RewriteResult { let ast::Trait { + ref impl_restriction, constness, is_auto, safety, - ref impl_restriction, ident, ref generics, ref bounds, From 614994fb8bc91593b21bc780adaf892e166841d0 Mon Sep 17 00:00:00 2001 From: CoCo-Japan-pan <115922543+CoCo-Japan-pan@users.noreply.github.com> Date: Sun, 19 Apr 2026 00:22:40 +0900 Subject: [PATCH 04/20] Update HIR pretty printing --- compiler/rustc_ast_lowering/src/item.rs | 2 +- compiler/rustc_hir/src/hir.rs | 8 ++++---- compiler/rustc_hir/src/intravisit.rs | 2 +- compiler/rustc_hir_analysis/src/collect.rs | 4 ++-- compiler/rustc_hir_pretty/src/lib.rs | 4 ++-- compiler/rustc_hir_typeck/src/method/suggest.rs | 2 +- compiler/rustc_middle/src/ty/trait_def.rs | 6 +++--- .../src/error_reporting/traits/suggestions.rs | 2 +- src/librustdoc/clean/mod.rs | 2 +- .../clippy_lints/src/arbitrary_source_item_ordering.rs | 2 +- src/tools/clippy/clippy_lints/src/doc/mod.rs | 2 +- src/tools/clippy/clippy_utils/src/check_proc_macro.rs | 4 ++-- 12 files changed, 20 insertions(+), 20 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index 6d5d34268ea18..8262681517ff4 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -573,10 +573,10 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> { }, ); hir::ItemKind::Trait( + impl_restriction, constness, *is_auto, safety, - impl_restriction, ident, generics, bounds, diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index c662b88209bd5..4398db10239f9 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -4327,17 +4327,17 @@ impl<'hir> Item<'hir> { expect_trait, ( + &'hir ImplRestriction<'hir>, Constness, IsAuto, Safety, - &'hir ImplRestriction<'hir>, Ident, &'hir Generics<'hir>, GenericBounds<'hir>, &'hir [TraitItemId] ), - ItemKind::Trait(constness, is_auto, safety, impl_restriction, ident, generics, bounds, items), - (*constness, *is_auto, *safety, impl_restriction, *ident, generics, bounds, items); + ItemKind::Trait(impl_restriction, constness, is_auto, safety, ident, generics, bounds, items), + (impl_restriction, *constness, *is_auto, *safety, *ident, generics, bounds, items); expect_trait_alias, (Constness, Ident, &'hir Generics<'hir>, GenericBounds<'hir>), ItemKind::TraitAlias(constness, ident, generics, bounds), (*constness, *ident, generics, bounds); @@ -4529,10 +4529,10 @@ pub enum ItemKind<'hir> { Union(Ident, &'hir Generics<'hir>, VariantData<'hir>), /// A trait definition. Trait( + &'hir ImplRestriction<'hir>, Constness, IsAuto, Safety, - &'hir ImplRestriction<'hir>, Ident, &'hir Generics<'hir>, GenericBounds<'hir>, diff --git a/compiler/rustc_hir/src/intravisit.rs b/compiler/rustc_hir/src/intravisit.rs index 99511189e9283..7c7c9939479fe 100644 --- a/compiler/rustc_hir/src/intravisit.rs +++ b/compiler/rustc_hir/src/intravisit.rs @@ -619,10 +619,10 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) -> V:: try_visit!(visitor.visit_variant_data(struct_definition)); } ItemKind::Trait( + ref impl_restriction, _constness, _is_auto, _safety, - ref impl_restriction, ident, ref generics, bounds, diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index 91f6c1a08f152..f6a18c33b9507 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -894,7 +894,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef { let item = tcx.hir_expect_item(def_id); let (constness, is_alias, is_auto, safety, impl_restriction) = match item.kind { - hir::ItemKind::Trait(constness, is_auto, safety, impl_restriction, ..) => ( + hir::ItemKind::Trait(impl_restriction, constness, is_auto, safety, ..) => ( constness, false, is_auto == hir::IsAuto::Yes, @@ -958,9 +958,9 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef { ty::TraitDef { def_id: def_id.to_def_id(), + impl_restriction, safety, constness, - impl_restriction, paren_sugar, has_auto_impl: is_auto, is_marker, diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs index 6f64d07b01d66..a387db74c8760 100644 --- a/compiler/rustc_hir_pretty/src/lib.rs +++ b/compiler/rustc_hir_pretty/src/lib.rs @@ -758,20 +758,20 @@ impl<'a> State<'a> { self.bclose(item.span, cb); } hir::ItemKind::Trait( + impl_restriction, constness, is_auto, safety, - impl_restriction, ident, generics, bounds, trait_items, ) => { let (cb, ib) = self.head(""); + self.print_impl_restriction(impl_restriction); self.print_constness(constness); self.print_is_auto(is_auto); self.print_safety(safety); - self.print_impl_restriction(impl_restriction); self.word_nbsp("trait"); self.print_ident(ident); self.print_generic_params(generics.params); diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index 3fcc3f03f7aa5..1af34fcc73a16 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -1886,7 +1886,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { entry.1.insert((self_ty.span, String::new())); } Some(Node::Item(hir::Item { - kind: hir::ItemKind::Trait(_, rustc_ast::ast::IsAuto::Yes, ..), + kind: hir::ItemKind::Trait(_, _, rustc_ast::ast::IsAuto::Yes, ..), span: item_span, .. })) => { diff --git a/compiler/rustc_middle/src/ty/trait_def.rs b/compiler/rustc_middle/src/ty/trait_def.rs index af5d81a108ba7..4ebd6f860ee90 100644 --- a/compiler/rustc_middle/src/ty/trait_def.rs +++ b/compiler/rustc_middle/src/ty/trait_def.rs @@ -20,14 +20,14 @@ use crate::ty::{Ident, Ty, TyCtxt}; pub struct TraitDef { pub def_id: DefId, + /// Restrictions on trait implementations. + pub impl_restriction: ImplRestrictionKind, + pub safety: hir::Safety, /// Whether this trait is `const`. pub constness: hir::Constness, - /// Restrictions on trait implementations. - pub impl_restriction: ImplRestrictionKind, - /// If `true`, then this trait had the `#[rustc_paren_sugar]` /// attribute, indicating that it should be used with `Foo()` /// sugar. This is a temporary thing -- eventually any trait will diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs index 9a9238f5c7994..64c1148b359a8 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -3888,7 +3888,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { let mut is_auto_trait = false; match tcx.hir_get_if_local(data.impl_or_alias_def_id) { Some(Node::Item(hir::Item { - kind: hir::ItemKind::Trait(_, is_auto, _, _, ident, _, _, _), + kind: hir::ItemKind::Trait(_, _, is_auto, _, ident, _, _, _), .. })) => { // FIXME: we should do something else so that it works even on crate foreign diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 501420bdc88fc..d4df6978a4e21 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -2916,7 +2916,7 @@ fn clean_maybe_renamed_item<'tcx>( clean_fn_or_proc_macro(item, sig, generics, body_id, &mut name, cx) } // FIXME: rustdoc will need to handle `impl` restrictions at some point - ItemKind::Trait(_, _, _, _impl_restriction, _, generics, bounds, item_ids) => { + ItemKind::Trait(_impl_restriction, _, _, _, _, generics, bounds, item_ids) => { let items = item_ids .iter() .map(|&ti| clean_trait_item(cx.tcx.hir_trait_item(ti), cx)) diff --git a/src/tools/clippy/clippy_lints/src/arbitrary_source_item_ordering.rs b/src/tools/clippy/clippy_lints/src/arbitrary_source_item_ordering.rs index dae0c8439ea82..4a6c024cac9a6 100644 --- a/src/tools/clippy/clippy_lints/src/arbitrary_source_item_ordering.rs +++ b/src/tools/clippy/clippy_lints/src/arbitrary_source_item_ordering.rs @@ -307,10 +307,10 @@ impl<'tcx> LateLintPass<'tcx> for ArbitrarySourceItemOrdering { } }, ItemKind::Trait( + _impl_restriction, _constness, is_auto, _safety, - _impl_restriction, _ident, _generics, _generic_bounds, diff --git a/src/tools/clippy/clippy_lints/src/doc/mod.rs b/src/tools/clippy/clippy_lints/src/doc/mod.rs index a94133376cbfb..81812880a743a 100644 --- a/src/tools/clippy/clippy_lints/src/doc/mod.rs +++ b/src/tools/clippy/clippy_lints/src/doc/mod.rs @@ -769,7 +769,7 @@ impl<'tcx> LateLintPass<'tcx> for Documentation { { missing_headers::check(cx, item.owner_id, sig, headers, Some(body), self.check_private_items); }, - ItemKind::Trait(_, _, unsafety, ..) => match (headers.safety, unsafety) { + ItemKind::Trait(_, _, _, unsafety, ..) => match (headers.safety, unsafety) { (false, Safety::Unsafe) => span_lint( cx, MISSING_SAFETY_DOC, diff --git a/src/tools/clippy/clippy_utils/src/check_proc_macro.rs b/src/tools/clippy/clippy_utils/src/check_proc_macro.rs index 601cf564062bb..44b9084cd4f69 100644 --- a/src/tools/clippy/clippy_utils/src/check_proc_macro.rs +++ b/src/tools/clippy/clippy_utils/src/check_proc_macro.rs @@ -265,14 +265,14 @@ fn item_search_pat(item: &Item<'_>) -> (Pat, Pat) { ItemKind::Struct(_, _, VariantData::Struct { .. }) => (Pat::Str("struct"), Pat::Str("}")), ItemKind::Struct(..) => (Pat::Str("struct"), Pat::Str(";")), ItemKind::Union(..) => (Pat::Str("union"), Pat::Str("}")), - ItemKind::Trait(_, _, Safety::Unsafe, ..) + ItemKind::Trait(_, _, _, Safety::Unsafe, ..) | ItemKind::Impl(Impl { of_trait: Some(TraitImplHeader { safety: Safety::Unsafe, .. }), .. }) => (Pat::Str("unsafe"), Pat::Str("}")), - ItemKind::Trait(_, IsAuto::Yes, ..) => (Pat::Str("auto"), Pat::Str("}")), + ItemKind::Trait(_, _, IsAuto::Yes, ..) => (Pat::Str("auto"), Pat::Str("}")), ItemKind::Trait(..) => (Pat::Str("trait"), Pat::Str("}")), ItemKind::Impl(_) => (Pat::Str("impl"), Pat::Str("}")), ItemKind::Mod(..) => (Pat::Str("mod"), Pat::Str("")), From 0e6efe57d7081c1ceb3f55b5b8853ea5a8b6d1d3 Mon Sep 17 00:00:00 2001 From: CoCo-Japan-pan <115922543+CoCo-Japan-pan@users.noreply.github.com> Date: Sun, 19 Apr 2026 01:16:38 +0900 Subject: [PATCH 05/20] Update UI tests --- .../feature-gate-impl-restriction.rs | 20 +-- ...-gate-impl-restriction.without_gate.stderr | 60 +++---- .../recover-incorrect-impl-restriction.rs | 43 +++-- ...recover-incorrect-impl-restriction.stderr} | 69 ++++---- ...rrect-impl-restriction.without_gate.stderr | 159 ------------------ .../trait-alias-cannot-be-impl-restricted.rs | 27 +-- ...it-alias-cannot-be-impl-restricted.stderr} | 59 +++---- ...not-be-impl-restricted.without_gate.stderr | 145 ---------------- tests/ui/macros/stringify.rs | 52 +++--- 9 files changed, 155 insertions(+), 479 deletions(-) rename tests/ui/impl-restriction/{recover-incorrect-impl-restriction.with_gate.stderr => recover-incorrect-impl-restriction.stderr} (62%) delete mode 100644 tests/ui/impl-restriction/recover-incorrect-impl-restriction.without_gate.stderr rename tests/ui/impl-restriction/{trait-alias-cannot-be-impl-restricted.with_gate.stderr => trait-alias-cannot-be-impl-restricted.stderr} (50%) delete mode 100644 tests/ui/impl-restriction/trait-alias-cannot-be-impl-restricted.without_gate.stderr diff --git a/tests/ui/impl-restriction/feature-gate-impl-restriction.rs b/tests/ui/impl-restriction/feature-gate-impl-restriction.rs index 95a050fe444ab..737af7488c44a 100644 --- a/tests/ui/impl-restriction/feature-gate-impl-restriction.rs +++ b/tests/ui/impl-restriction/feature-gate-impl-restriction.rs @@ -11,14 +11,14 @@ pub impl(in crate) trait BarInCrate {} //[without_gate]~ ERROR `impl` restrictio mod foo { pub impl(in crate::foo) trait Baz {} //[without_gate]~ ERROR `impl` restrictions are experimental - pub unsafe impl(super) trait BazUnsafeSuper {} //[without_gate]~ ERROR `impl` restrictions are experimental - pub auto impl(self) trait BazAutoSelf {} //[without_gate]~ ERROR `impl` restrictions are experimental - pub const impl(in self) trait BazConst {} //[without_gate]~ ERROR `impl` restrictions are experimental + pub impl(super) unsafe trait BazUnsafeSuper {} //[without_gate]~ ERROR `impl` restrictions are experimental + pub impl(self) auto trait BazAutoSelf {} //[without_gate]~ ERROR `impl` restrictions are experimental + pub impl(in self) const trait BazConst {} //[without_gate]~ ERROR `impl` restrictions are experimental mod foo_inner { pub impl(in crate::foo::foo_inner) trait Qux {} //[without_gate]~ ERROR `impl` restrictions are experimental - pub unsafe auto impl(in crate::foo::foo_inner) trait QuxAutoUnsafe {} //[without_gate]~ ERROR `impl` restrictions are experimental - pub const unsafe impl(in crate::foo::foo_inner) trait QuxConstUnsafe {} //[without_gate]~ ERROR `impl` restrictions are experimental + pub impl(in crate::foo::foo_inner) unsafe auto trait QuxAutoUnsafe {} //[without_gate]~ ERROR `impl` restrictions are experimental + pub impl(in crate::foo::foo_inner) const unsafe trait QuxConstUnsafe {} //[without_gate]~ ERROR `impl` restrictions are experimental } #[cfg(false)] @@ -26,17 +26,17 @@ mod foo { #[cfg(false)] pub impl(in crate) trait BarInCrate {} //[without_gate]~ ERROR `impl` restrictions are experimental #[cfg(false)] - pub unsafe impl(self) trait BazUnsafeSelf {} //[without_gate]~ ERROR `impl` restrictions are experimental + pub impl(self) unsafe trait BazUnsafeSelf {} //[without_gate]~ ERROR `impl` restrictions are experimental #[cfg(false)] - pub auto impl(in super) trait BazAutoSuper {} //[without_gate]~ ERROR `impl` restrictions are experimental + pub impl(in super) auto trait BazAutoSuper {} //[without_gate]~ ERROR `impl` restrictions are experimental #[cfg(false)] - pub const impl(super) trait BazConstSuper {} //[without_gate]~ ERROR `impl` restrictions are experimental + pub impl(super) const trait BazConstSuper {} //[without_gate]~ ERROR `impl` restrictions are experimental #[cfg(false)] mod cfged_out_foo { pub impl(in crate::foo::cfged_out_foo) trait CfgedOutQux {} //[without_gate]~ ERROR `impl` restrictions are experimental - pub unsafe auto impl(in crate::foo::cfged_out_foo) trait CfgedOutQuxUnsafeAuto {} //[without_gate]~ ERROR `impl` restrictions are experimental - pub const unsafe impl(in crate::foo::cfged_out_foo) trait CfgedOutQuxConstUnsafe {} //[without_gate]~ ERROR `impl` restrictions are experimental + pub impl(in crate::foo::cfged_out_foo) unsafe auto trait CfgedOutQuxUnsafeAuto {} //[without_gate]~ ERROR `impl` restrictions are experimental + pub impl(in crate::foo::cfged_out_foo) const unsafe trait CfgedOutQuxConstUnsafe {} //[without_gate]~ ERROR `impl` restrictions are experimental } // auto traits cannot be const, so we do not include these combinations in the test. diff --git a/tests/ui/impl-restriction/feature-gate-impl-restriction.without_gate.stderr b/tests/ui/impl-restriction/feature-gate-impl-restriction.without_gate.stderr index 4f99d962d4bb7..d1f27350d1ba7 100644 --- a/tests/ui/impl-restriction/feature-gate-impl-restriction.without_gate.stderr +++ b/tests/ui/impl-restriction/feature-gate-impl-restriction.without_gate.stderr @@ -29,30 +29,30 @@ LL | pub impl(in crate::foo) trait Baz {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `impl` restrictions are experimental - --> $DIR/feature-gate-impl-restriction.rs:14:16 + --> $DIR/feature-gate-impl-restriction.rs:14:9 | -LL | pub unsafe impl(super) trait BazUnsafeSuper {} - | ^^^^^^^^^^^ +LL | pub impl(super) unsafe trait BazUnsafeSuper {} + | ^^^^^^^^^^^ | = note: see issue #105077 for more information = help: add `#![feature(impl_restriction)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `impl` restrictions are experimental - --> $DIR/feature-gate-impl-restriction.rs:15:14 + --> $DIR/feature-gate-impl-restriction.rs:15:9 | -LL | pub auto impl(self) trait BazAutoSelf {} - | ^^^^^^^^^^ +LL | pub impl(self) auto trait BazAutoSelf {} + | ^^^^^^^^^^ | = note: see issue #105077 for more information = help: add `#![feature(impl_restriction)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `impl` restrictions are experimental - --> $DIR/feature-gate-impl-restriction.rs:16:15 + --> $DIR/feature-gate-impl-restriction.rs:16:9 | -LL | pub const impl(in self) trait BazConst {} - | ^^^^^^^^^^^^^ +LL | pub impl(in self) const trait BazConst {} + | ^^^^^^^^^^^^^ | = note: see issue #105077 for more information = help: add `#![feature(impl_restriction)]` to the crate attributes to enable @@ -69,20 +69,20 @@ LL | pub impl(in crate::foo::foo_inner) trait Qux {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `impl` restrictions are experimental - --> $DIR/feature-gate-impl-restriction.rs:20:25 + --> $DIR/feature-gate-impl-restriction.rs:20:13 | -LL | ... pub unsafe auto impl(in crate::foo::foo_inner) trait QuxAutoUnsafe {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | ... pub impl(in crate::foo::foo_inner) unsafe auto trait QuxAutoUnsafe {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #105077 for more information = help: add `#![feature(impl_restriction)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `impl` restrictions are experimental - --> $DIR/feature-gate-impl-restriction.rs:21:26 + --> $DIR/feature-gate-impl-restriction.rs:21:13 | -LL | ... pub const unsafe impl(in crate::foo::foo_inner) trait QuxConstUnsafe {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | ... pub impl(in crate::foo::foo_inner) const unsafe trait QuxConstUnsafe {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #105077 for more information = help: add `#![feature(impl_restriction)]` to the crate attributes to enable @@ -109,30 +109,30 @@ LL | pub impl(in crate) trait BarInCrate {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `impl` restrictions are experimental - --> $DIR/feature-gate-impl-restriction.rs:29:16 + --> $DIR/feature-gate-impl-restriction.rs:29:9 | -LL | pub unsafe impl(self) trait BazUnsafeSelf {} - | ^^^^^^^^^^ +LL | pub impl(self) unsafe trait BazUnsafeSelf {} + | ^^^^^^^^^^ | = note: see issue #105077 for more information = help: add `#![feature(impl_restriction)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `impl` restrictions are experimental - --> $DIR/feature-gate-impl-restriction.rs:31:14 + --> $DIR/feature-gate-impl-restriction.rs:31:9 | -LL | pub auto impl(in super) trait BazAutoSuper {} - | ^^^^^^^^^^^^^^ +LL | pub impl(in super) auto trait BazAutoSuper {} + | ^^^^^^^^^^^^^^ | = note: see issue #105077 for more information = help: add `#![feature(impl_restriction)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `impl` restrictions are experimental - --> $DIR/feature-gate-impl-restriction.rs:33:15 + --> $DIR/feature-gate-impl-restriction.rs:33:9 | -LL | pub const impl(super) trait BazConstSuper {} - | ^^^^^^^^^^^ +LL | pub impl(super) const trait BazConstSuper {} + | ^^^^^^^^^^^ | = note: see issue #105077 for more information = help: add `#![feature(impl_restriction)]` to the crate attributes to enable @@ -149,20 +149,20 @@ LL | pub impl(in crate::foo::cfged_out_foo) trait CfgedOutQux {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `impl` restrictions are experimental - --> $DIR/feature-gate-impl-restriction.rs:38:25 + --> $DIR/feature-gate-impl-restriction.rs:38:13 | -LL | ... pub unsafe auto impl(in crate::foo::cfged_out_foo) trait CfgedOutQuxUnsafeAuto {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | ... pub impl(in crate::foo::cfged_out_foo) unsafe auto trait CfgedOutQuxUnsafeAuto {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #105077 for more information = help: add `#![feature(impl_restriction)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `impl` restrictions are experimental - --> $DIR/feature-gate-impl-restriction.rs:39:26 + --> $DIR/feature-gate-impl-restriction.rs:39:13 | -LL | ... pub const unsafe impl(in crate::foo::cfged_out_foo) trait CfgedOutQuxConstUnsafe {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | ... pub impl(in crate::foo::cfged_out_foo) const unsafe trait CfgedOutQuxConstUnsafe {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #105077 for more information = help: add `#![feature(impl_restriction)]` to the crate attributes to enable diff --git a/tests/ui/impl-restriction/recover-incorrect-impl-restriction.rs b/tests/ui/impl-restriction/recover-incorrect-impl-restriction.rs index dc47eba2b3c63..a11c7659ba780 100644 --- a/tests/ui/impl-restriction/recover-incorrect-impl-restriction.rs +++ b/tests/ui/impl-restriction/recover-incorrect-impl-restriction.rs @@ -1,21 +1,30 @@ -//@ compile-flags: --crate-type=lib -//@ revisions: with_gate without_gate -#![warn(incomplete_features)] -#![cfg_attr(with_gate, feature(impl_restriction))] -//[with_gate]~^ WARN the feature `impl_restriction` is incomplete and may not be safe to use and/or cause compiler crashes -#![feature(auto_traits, const_trait_impl)] +#![feature(impl_restriction, auto_traits, const_trait_impl)] +#![expect(incomplete_features)] mod foo { pub impl(crate::foo) trait Baz {} //~ ERROR incorrect `impl` restriction - //[without_gate]~^ ERROR `impl` restrictions are experimental - pub unsafe impl(crate::foo) trait BazUnsafe {} //~ ERROR incorrect `impl` restriction - //[without_gate]~^ ERROR `impl` restrictions are experimental - pub auto impl(crate::foo) trait BazAuto {} //~ ERROR incorrect `impl` restriction - //[without_gate]~^ ERROR `impl` restrictions are experimental - pub const impl(crate::foo) trait BazConst {} //~ ERROR incorrect `impl` restriction - //[without_gate]~^ ERROR `impl` restrictions are experimental - pub const unsafe impl(crate::foo) trait BazConstUnsafe {} //~ ERROR incorrect `impl` restriction - //[without_gate]~^ ERROR `impl` restrictions are experimental - pub unsafe auto impl(crate::foo) trait BazUnsafeAuto {} //~ ERROR incorrect `impl` restriction - //[without_gate]~^ ERROR `impl` restrictions are experimental + pub impl(crate::foo) unsafe trait BazUnsafe {} //~ ERROR incorrect `impl` restriction + pub impl(crate::foo) auto trait BazAuto {} //~ ERROR incorrect `impl` restriction + pub impl(crate::foo) const trait BazConst {} //~ ERROR incorrect `impl` restriction + pub impl(crate::foo) const unsafe trait BazConstUnsafe {} //~ ERROR incorrect `impl` restriction + pub impl(crate::foo) unsafe auto trait BazUnsafeAuto {} //~ ERROR incorrect `impl` restriction + + // FIXME: The positioning of `impl(..)` may be confusing. + // When users get the keyword order wrong, the compiler currently emits + // a generic "unexpected token" error, which is not very helpful. + // In the future, we could improve diagnostics by detecting misordered + // keywords and suggesting the correct order. + pub unsafe impl(crate::foo) trait BadOrder1 {} //~ ERROR expected one of `for`, `where`, or `{`, found keyword `trait` + + // FIXME: The following cases are not checked for now, + // as the compiler aborts due to the previous syntax error in `BadOrder1`. + // In the future, we could recover from such errors and continue compilation. + pub auto impl(crate::foo) trait BadOrder2 {} + pub const impl(crate::foo) trait BadOrder3 {} + pub unsafe auto impl(crate::foo) trait BadOrder4 {} + pub const unsafe impl(crate::foo) trait BadOrder5 {} + pub unsafe impl(crate::foo) auto trait BadOrder6 {} + pub const impl(crate::foo) unsafe trait BadOrder7 {} } + +fn main() {} diff --git a/tests/ui/impl-restriction/recover-incorrect-impl-restriction.with_gate.stderr b/tests/ui/impl-restriction/recover-incorrect-impl-restriction.stderr similarity index 62% rename from tests/ui/impl-restriction/recover-incorrect-impl-restriction.with_gate.stderr rename to tests/ui/impl-restriction/recover-incorrect-impl-restriction.stderr index 834cc99f07553..23aff244bb71b 100644 --- a/tests/ui/impl-restriction/recover-incorrect-impl-restriction.with_gate.stderr +++ b/tests/ui/impl-restriction/recover-incorrect-impl-restriction.stderr @@ -1,5 +1,5 @@ error: incorrect `impl` restriction - --> $DIR/recover-incorrect-impl-restriction.rs:9:14 + --> $DIR/recover-incorrect-impl-restriction.rs:5:14 | LL | pub impl(crate::foo) trait Baz {} | ^^^^^^^^^^ @@ -15,10 +15,10 @@ LL | pub impl(in crate::foo) trait Baz {} | ++ error: incorrect `impl` restriction - --> $DIR/recover-incorrect-impl-restriction.rs:11:21 + --> $DIR/recover-incorrect-impl-restriction.rs:6:14 | -LL | pub unsafe impl(crate::foo) trait BazUnsafe {} - | ^^^^^^^^^^ +LL | pub impl(crate::foo) unsafe trait BazUnsafe {} + | ^^^^^^^^^^ | = help: some possible `impl` restrictions are: `impl(crate)`: can only be implemented in the current crate @@ -27,14 +27,14 @@ LL | pub unsafe impl(crate::foo) trait BazUnsafe {} `impl(in path::to::module)`: can only be implemented in the specified path help: help: use `in` to restrict implementations to the path `crate::foo` | -LL | pub unsafe impl(in crate::foo) trait BazUnsafe {} - | ++ +LL | pub impl(in crate::foo) unsafe trait BazUnsafe {} + | ++ error: incorrect `impl` restriction - --> $DIR/recover-incorrect-impl-restriction.rs:13:19 + --> $DIR/recover-incorrect-impl-restriction.rs:7:14 | -LL | pub auto impl(crate::foo) trait BazAuto {} - | ^^^^^^^^^^ +LL | pub impl(crate::foo) auto trait BazAuto {} + | ^^^^^^^^^^ | = help: some possible `impl` restrictions are: `impl(crate)`: can only be implemented in the current crate @@ -43,14 +43,14 @@ LL | pub auto impl(crate::foo) trait BazAuto {} `impl(in path::to::module)`: can only be implemented in the specified path help: help: use `in` to restrict implementations to the path `crate::foo` | -LL | pub auto impl(in crate::foo) trait BazAuto {} - | ++ +LL | pub impl(in crate::foo) auto trait BazAuto {} + | ++ error: incorrect `impl` restriction - --> $DIR/recover-incorrect-impl-restriction.rs:15:20 + --> $DIR/recover-incorrect-impl-restriction.rs:8:14 | -LL | pub const impl(crate::foo) trait BazConst {} - | ^^^^^^^^^^ +LL | pub impl(crate::foo) const trait BazConst {} + | ^^^^^^^^^^ | = help: some possible `impl` restrictions are: `impl(crate)`: can only be implemented in the current crate @@ -59,14 +59,14 @@ LL | pub const impl(crate::foo) trait BazConst {} `impl(in path::to::module)`: can only be implemented in the specified path help: help: use `in` to restrict implementations to the path `crate::foo` | -LL | pub const impl(in crate::foo) trait BazConst {} - | ++ +LL | pub impl(in crate::foo) const trait BazConst {} + | ++ error: incorrect `impl` restriction - --> $DIR/recover-incorrect-impl-restriction.rs:17:27 + --> $DIR/recover-incorrect-impl-restriction.rs:9:14 | -LL | pub const unsafe impl(crate::foo) trait BazConstUnsafe {} - | ^^^^^^^^^^ +LL | pub impl(crate::foo) const unsafe trait BazConstUnsafe {} + | ^^^^^^^^^^ | = help: some possible `impl` restrictions are: `impl(crate)`: can only be implemented in the current crate @@ -75,14 +75,14 @@ LL | pub const unsafe impl(crate::foo) trait BazConstUnsafe {} `impl(in path::to::module)`: can only be implemented in the specified path help: help: use `in` to restrict implementations to the path `crate::foo` | -LL | pub const unsafe impl(in crate::foo) trait BazConstUnsafe {} - | ++ +LL | pub impl(in crate::foo) const unsafe trait BazConstUnsafe {} + | ++ error: incorrect `impl` restriction - --> $DIR/recover-incorrect-impl-restriction.rs:19:26 + --> $DIR/recover-incorrect-impl-restriction.rs:10:14 | -LL | pub unsafe auto impl(crate::foo) trait BazUnsafeAuto {} - | ^^^^^^^^^^ +LL | pub impl(crate::foo) unsafe auto trait BazUnsafeAuto {} + | ^^^^^^^^^^ | = help: some possible `impl` restrictions are: `impl(crate)`: can only be implemented in the current crate @@ -91,21 +91,14 @@ LL | pub unsafe auto impl(crate::foo) trait BazUnsafeAuto {} `impl(in path::to::module)`: can only be implemented in the specified path help: help: use `in` to restrict implementations to the path `crate::foo` | -LL | pub unsafe auto impl(in crate::foo) trait BazUnsafeAuto {} - | ++ +LL | pub impl(in crate::foo) unsafe auto trait BazUnsafeAuto {} + | ++ -warning: the feature `impl_restriction` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/recover-incorrect-impl-restriction.rs:4:32 - | -LL | #![cfg_attr(with_gate, feature(impl_restriction))] - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #105077 for more information -note: the lint level is defined here - --> $DIR/recover-incorrect-impl-restriction.rs:3:9 +error: expected one of `for`, `where`, or `{`, found keyword `trait` + --> $DIR/recover-incorrect-impl-restriction.rs:17:33 | -LL | #![warn(incomplete_features)] - | ^^^^^^^^^^^^^^^^^^^ +LL | pub unsafe impl(crate::foo) trait BadOrder1 {} + | ^^^^^ expected one of `for`, `where`, or `{` -error: aborting due to 6 previous errors; 1 warning emitted +error: aborting due to 7 previous errors diff --git a/tests/ui/impl-restriction/recover-incorrect-impl-restriction.without_gate.stderr b/tests/ui/impl-restriction/recover-incorrect-impl-restriction.without_gate.stderr deleted file mode 100644 index 223a7cd47cfb4..0000000000000 --- a/tests/ui/impl-restriction/recover-incorrect-impl-restriction.without_gate.stderr +++ /dev/null @@ -1,159 +0,0 @@ -error: incorrect `impl` restriction - --> $DIR/recover-incorrect-impl-restriction.rs:9:14 - | -LL | pub impl(crate::foo) trait Baz {} - | ^^^^^^^^^^ - | - = help: some possible `impl` restrictions are: - `impl(crate)`: can only be implemented in the current crate - `impl(super)`: can only be implemented in the parent module - `impl(self)`: can only be implemented in current module - `impl(in path::to::module)`: can only be implemented in the specified path -help: help: use `in` to restrict implementations to the path `crate::foo` - | -LL | pub impl(in crate::foo) trait Baz {} - | ++ - -error: incorrect `impl` restriction - --> $DIR/recover-incorrect-impl-restriction.rs:11:21 - | -LL | pub unsafe impl(crate::foo) trait BazUnsafe {} - | ^^^^^^^^^^ - | - = help: some possible `impl` restrictions are: - `impl(crate)`: can only be implemented in the current crate - `impl(super)`: can only be implemented in the parent module - `impl(self)`: can only be implemented in current module - `impl(in path::to::module)`: can only be implemented in the specified path -help: help: use `in` to restrict implementations to the path `crate::foo` - | -LL | pub unsafe impl(in crate::foo) trait BazUnsafe {} - | ++ - -error: incorrect `impl` restriction - --> $DIR/recover-incorrect-impl-restriction.rs:13:19 - | -LL | pub auto impl(crate::foo) trait BazAuto {} - | ^^^^^^^^^^ - | - = help: some possible `impl` restrictions are: - `impl(crate)`: can only be implemented in the current crate - `impl(super)`: can only be implemented in the parent module - `impl(self)`: can only be implemented in current module - `impl(in path::to::module)`: can only be implemented in the specified path -help: help: use `in` to restrict implementations to the path `crate::foo` - | -LL | pub auto impl(in crate::foo) trait BazAuto {} - | ++ - -error: incorrect `impl` restriction - --> $DIR/recover-incorrect-impl-restriction.rs:15:20 - | -LL | pub const impl(crate::foo) trait BazConst {} - | ^^^^^^^^^^ - | - = help: some possible `impl` restrictions are: - `impl(crate)`: can only be implemented in the current crate - `impl(super)`: can only be implemented in the parent module - `impl(self)`: can only be implemented in current module - `impl(in path::to::module)`: can only be implemented in the specified path -help: help: use `in` to restrict implementations to the path `crate::foo` - | -LL | pub const impl(in crate::foo) trait BazConst {} - | ++ - -error: incorrect `impl` restriction - --> $DIR/recover-incorrect-impl-restriction.rs:17:27 - | -LL | pub const unsafe impl(crate::foo) trait BazConstUnsafe {} - | ^^^^^^^^^^ - | - = help: some possible `impl` restrictions are: - `impl(crate)`: can only be implemented in the current crate - `impl(super)`: can only be implemented in the parent module - `impl(self)`: can only be implemented in current module - `impl(in path::to::module)`: can only be implemented in the specified path -help: help: use `in` to restrict implementations to the path `crate::foo` - | -LL | pub const unsafe impl(in crate::foo) trait BazConstUnsafe {} - | ++ - -error: incorrect `impl` restriction - --> $DIR/recover-incorrect-impl-restriction.rs:19:26 - | -LL | pub unsafe auto impl(crate::foo) trait BazUnsafeAuto {} - | ^^^^^^^^^^ - | - = help: some possible `impl` restrictions are: - `impl(crate)`: can only be implemented in the current crate - `impl(super)`: can only be implemented in the parent module - `impl(self)`: can only be implemented in current module - `impl(in path::to::module)`: can only be implemented in the specified path -help: help: use `in` to restrict implementations to the path `crate::foo` - | -LL | pub unsafe auto impl(in crate::foo) trait BazUnsafeAuto {} - | ++ - -error[E0658]: `impl` restrictions are experimental - --> $DIR/recover-incorrect-impl-restriction.rs:9:9 - | -LL | pub impl(crate::foo) trait Baz {} - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #105077 for more information - = help: add `#![feature(impl_restriction)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: `impl` restrictions are experimental - --> $DIR/recover-incorrect-impl-restriction.rs:11:16 - | -LL | pub unsafe impl(crate::foo) trait BazUnsafe {} - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #105077 for more information - = help: add `#![feature(impl_restriction)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: `impl` restrictions are experimental - --> $DIR/recover-incorrect-impl-restriction.rs:13:14 - | -LL | pub auto impl(crate::foo) trait BazAuto {} - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #105077 for more information - = help: add `#![feature(impl_restriction)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: `impl` restrictions are experimental - --> $DIR/recover-incorrect-impl-restriction.rs:15:15 - | -LL | pub const impl(crate::foo) trait BazConst {} - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #105077 for more information - = help: add `#![feature(impl_restriction)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: `impl` restrictions are experimental - --> $DIR/recover-incorrect-impl-restriction.rs:17:22 - | -LL | pub const unsafe impl(crate::foo) trait BazConstUnsafe {} - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #105077 for more information - = help: add `#![feature(impl_restriction)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: `impl` restrictions are experimental - --> $DIR/recover-incorrect-impl-restriction.rs:19:21 - | -LL | pub unsafe auto impl(crate::foo) trait BazUnsafeAuto {} - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #105077 for more information - = help: add `#![feature(impl_restriction)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 12 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/impl-restriction/trait-alias-cannot-be-impl-restricted.rs b/tests/ui/impl-restriction/trait-alias-cannot-be-impl-restricted.rs index ce36a49b145b0..d191950ec40ef 100644 --- a/tests/ui/impl-restriction/trait-alias-cannot-be-impl-restricted.rs +++ b/tests/ui/impl-restriction/trait-alias-cannot-be-impl-restricted.rs @@ -1,29 +1,20 @@ -//@ compile-flags: --crate-type=lib -//@ revisions: with_gate without_gate -#![warn(incomplete_features)] -#![cfg_attr(with_gate, feature(impl_restriction))] -//[with_gate]~^ WARN the feature `impl_restriction` is incomplete and may not be safe to use and/or cause compiler crashes -#![feature(auto_traits, const_trait_impl, trait_alias)] +#![feature(impl_restriction, auto_traits, const_trait_impl, trait_alias)] +#![expect(incomplete_features)] impl(crate) trait Alias = Copy; //~ ERROR trait aliases cannot be `impl`-restricted -//[without_gate]~^ ERROR `impl` restrictions are experimental -auto impl(in crate) trait AutoAlias = Copy; //~ ERROR trait aliases cannot be `impl`-restricted +impl(in crate) auto trait AutoAlias = Copy; //~ ERROR trait aliases cannot be `impl`-restricted //~^ ERROR trait aliases cannot be `auto` -//[without_gate]~| ERROR `impl` restrictions are experimental -unsafe impl(self) trait UnsafeAlias = Copy; //~ ERROR trait aliases cannot be `impl`-restricted +impl(self) unsafe trait UnsafeAlias = Copy; //~ ERROR trait aliases cannot be `impl`-restricted //~^ ERROR trait aliases cannot be `unsafe` -//[without_gate]~| ERROR `impl` restrictions are experimental -const impl(in self) trait ConstAlias = Copy; //~ ERROR trait aliases cannot be `impl`-restricted -//[without_gate]~^ ERROR `impl` restrictions are experimental +impl(in self) const trait ConstAlias = Copy; //~ ERROR trait aliases cannot be `impl`-restricted mod foo { impl(super) trait InnerAlias = Copy; //~ ERROR trait aliases cannot be `impl`-restricted - //[without_gate]~^ ERROR `impl` restrictions are experimental - const unsafe impl(in crate::foo) trait InnerConstUnsafeAlias = Copy; //~ ERROR trait aliases cannot be `impl`-restricted + impl(in crate::foo) const unsafe trait InnerConstUnsafeAlias = Copy; //~ ERROR trait aliases cannot be `impl`-restricted //~^ ERROR trait aliases cannot be `unsafe` - //[without_gate]~| ERROR `impl` restrictions are experimental - unsafe auto impl(in crate::foo) trait InnerUnsafeAutoAlias = Copy; //~ ERROR trait aliases cannot be `impl`-restricted + impl(in crate::foo) unsafe auto trait InnerUnsafeAutoAlias = Copy; //~ ERROR trait aliases cannot be `impl`-restricted //~^ ERROR trait aliases cannot be `auto` //~^^ ERROR trait aliases cannot be `unsafe` - //[without_gate]~| ERROR `impl` restrictions are experimental } + +fn main() {} diff --git a/tests/ui/impl-restriction/trait-alias-cannot-be-impl-restricted.with_gate.stderr b/tests/ui/impl-restriction/trait-alias-cannot-be-impl-restricted.stderr similarity index 50% rename from tests/ui/impl-restriction/trait-alias-cannot-be-impl-restricted.with_gate.stderr rename to tests/ui/impl-restriction/trait-alias-cannot-be-impl-restricted.stderr index 7be030052df50..def89574b041d 100644 --- a/tests/ui/impl-restriction/trait-alias-cannot-be-impl-restricted.with_gate.stderr +++ b/tests/ui/impl-restriction/trait-alias-cannot-be-impl-restricted.stderr @@ -1,87 +1,74 @@ error: trait aliases cannot be `impl`-restricted - --> $DIR/trait-alias-cannot-be-impl-restricted.rs:8:1 + --> $DIR/trait-alias-cannot-be-impl-restricted.rs:4:1 | LL | impl(crate) trait Alias = Copy; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait aliases cannot be `impl`-restricted error: trait aliases cannot be `auto` - --> $DIR/trait-alias-cannot-be-impl-restricted.rs:10:1 + --> $DIR/trait-alias-cannot-be-impl-restricted.rs:5:1 | -LL | auto impl(in crate) trait AutoAlias = Copy; +LL | impl(in crate) auto trait AutoAlias = Copy; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait aliases cannot be `auto` error: trait aliases cannot be `impl`-restricted - --> $DIR/trait-alias-cannot-be-impl-restricted.rs:10:1 + --> $DIR/trait-alias-cannot-be-impl-restricted.rs:5:1 | -LL | auto impl(in crate) trait AutoAlias = Copy; +LL | impl(in crate) auto trait AutoAlias = Copy; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait aliases cannot be `impl`-restricted error: trait aliases cannot be `unsafe` - --> $DIR/trait-alias-cannot-be-impl-restricted.rs:13:1 + --> $DIR/trait-alias-cannot-be-impl-restricted.rs:7:1 | -LL | unsafe impl(self) trait UnsafeAlias = Copy; +LL | impl(self) unsafe trait UnsafeAlias = Copy; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait aliases cannot be `unsafe` error: trait aliases cannot be `impl`-restricted - --> $DIR/trait-alias-cannot-be-impl-restricted.rs:13:1 + --> $DIR/trait-alias-cannot-be-impl-restricted.rs:7:1 | -LL | unsafe impl(self) trait UnsafeAlias = Copy; +LL | impl(self) unsafe trait UnsafeAlias = Copy; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait aliases cannot be `impl`-restricted error: trait aliases cannot be `impl`-restricted - --> $DIR/trait-alias-cannot-be-impl-restricted.rs:16:1 + --> $DIR/trait-alias-cannot-be-impl-restricted.rs:9:1 | -LL | const impl(in self) trait ConstAlias = Copy; +LL | impl(in self) const trait ConstAlias = Copy; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait aliases cannot be `impl`-restricted error: trait aliases cannot be `impl`-restricted - --> $DIR/trait-alias-cannot-be-impl-restricted.rs:20:5 + --> $DIR/trait-alias-cannot-be-impl-restricted.rs:12:5 | LL | impl(super) trait InnerAlias = Copy; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait aliases cannot be `impl`-restricted error: trait aliases cannot be `unsafe` - --> $DIR/trait-alias-cannot-be-impl-restricted.rs:22:5 + --> $DIR/trait-alias-cannot-be-impl-restricted.rs:13:5 | -LL | const unsafe impl(in crate::foo) trait InnerConstUnsafeAlias = Copy; +LL | impl(in crate::foo) const unsafe trait InnerConstUnsafeAlias = Copy; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait aliases cannot be `unsafe` error: trait aliases cannot be `impl`-restricted - --> $DIR/trait-alias-cannot-be-impl-restricted.rs:22:5 + --> $DIR/trait-alias-cannot-be-impl-restricted.rs:13:5 | -LL | const unsafe impl(in crate::foo) trait InnerConstUnsafeAlias = Copy; +LL | impl(in crate::foo) const unsafe trait InnerConstUnsafeAlias = Copy; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait aliases cannot be `impl`-restricted error: trait aliases cannot be `auto` - --> $DIR/trait-alias-cannot-be-impl-restricted.rs:25:5 + --> $DIR/trait-alias-cannot-be-impl-restricted.rs:15:5 | -LL | unsafe auto impl(in crate::foo) trait InnerUnsafeAutoAlias = Copy; +LL | impl(in crate::foo) unsafe auto trait InnerUnsafeAutoAlias = Copy; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait aliases cannot be `auto` error: trait aliases cannot be `unsafe` - --> $DIR/trait-alias-cannot-be-impl-restricted.rs:25:5 + --> $DIR/trait-alias-cannot-be-impl-restricted.rs:15:5 | -LL | unsafe auto impl(in crate::foo) trait InnerUnsafeAutoAlias = Copy; +LL | impl(in crate::foo) unsafe auto trait InnerUnsafeAutoAlias = Copy; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait aliases cannot be `unsafe` error: trait aliases cannot be `impl`-restricted - --> $DIR/trait-alias-cannot-be-impl-restricted.rs:25:5 + --> $DIR/trait-alias-cannot-be-impl-restricted.rs:15:5 | -LL | unsafe auto impl(in crate::foo) trait InnerUnsafeAutoAlias = Copy; +LL | impl(in crate::foo) unsafe auto trait InnerUnsafeAutoAlias = Copy; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait aliases cannot be `impl`-restricted -warning: the feature `impl_restriction` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/trait-alias-cannot-be-impl-restricted.rs:4:32 - | -LL | #![cfg_attr(with_gate, feature(impl_restriction))] - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #105077 for more information -note: the lint level is defined here - --> $DIR/trait-alias-cannot-be-impl-restricted.rs:3:9 - | -LL | #![warn(incomplete_features)] - | ^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 12 previous errors; 1 warning emitted +error: aborting due to 12 previous errors diff --git a/tests/ui/impl-restriction/trait-alias-cannot-be-impl-restricted.without_gate.stderr b/tests/ui/impl-restriction/trait-alias-cannot-be-impl-restricted.without_gate.stderr deleted file mode 100644 index c99bfce5da2c5..0000000000000 --- a/tests/ui/impl-restriction/trait-alias-cannot-be-impl-restricted.without_gate.stderr +++ /dev/null @@ -1,145 +0,0 @@ -error: trait aliases cannot be `impl`-restricted - --> $DIR/trait-alias-cannot-be-impl-restricted.rs:8:1 - | -LL | impl(crate) trait Alias = Copy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait aliases cannot be `impl`-restricted - -error: trait aliases cannot be `auto` - --> $DIR/trait-alias-cannot-be-impl-restricted.rs:10:1 - | -LL | auto impl(in crate) trait AutoAlias = Copy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait aliases cannot be `auto` - -error: trait aliases cannot be `impl`-restricted - --> $DIR/trait-alias-cannot-be-impl-restricted.rs:10:1 - | -LL | auto impl(in crate) trait AutoAlias = Copy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait aliases cannot be `impl`-restricted - -error: trait aliases cannot be `unsafe` - --> $DIR/trait-alias-cannot-be-impl-restricted.rs:13:1 - | -LL | unsafe impl(self) trait UnsafeAlias = Copy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait aliases cannot be `unsafe` - -error: trait aliases cannot be `impl`-restricted - --> $DIR/trait-alias-cannot-be-impl-restricted.rs:13:1 - | -LL | unsafe impl(self) trait UnsafeAlias = Copy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait aliases cannot be `impl`-restricted - -error: trait aliases cannot be `impl`-restricted - --> $DIR/trait-alias-cannot-be-impl-restricted.rs:16:1 - | -LL | const impl(in self) trait ConstAlias = Copy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait aliases cannot be `impl`-restricted - -error: trait aliases cannot be `impl`-restricted - --> $DIR/trait-alias-cannot-be-impl-restricted.rs:20:5 - | -LL | impl(super) trait InnerAlias = Copy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait aliases cannot be `impl`-restricted - -error: trait aliases cannot be `unsafe` - --> $DIR/trait-alias-cannot-be-impl-restricted.rs:22:5 - | -LL | const unsafe impl(in crate::foo) trait InnerConstUnsafeAlias = Copy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait aliases cannot be `unsafe` - -error: trait aliases cannot be `impl`-restricted - --> $DIR/trait-alias-cannot-be-impl-restricted.rs:22:5 - | -LL | const unsafe impl(in crate::foo) trait InnerConstUnsafeAlias = Copy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait aliases cannot be `impl`-restricted - -error: trait aliases cannot be `auto` - --> $DIR/trait-alias-cannot-be-impl-restricted.rs:25:5 - | -LL | unsafe auto impl(in crate::foo) trait InnerUnsafeAutoAlias = Copy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait aliases cannot be `auto` - -error: trait aliases cannot be `unsafe` - --> $DIR/trait-alias-cannot-be-impl-restricted.rs:25:5 - | -LL | unsafe auto impl(in crate::foo) trait InnerUnsafeAutoAlias = Copy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait aliases cannot be `unsafe` - -error: trait aliases cannot be `impl`-restricted - --> $DIR/trait-alias-cannot-be-impl-restricted.rs:25:5 - | -LL | unsafe auto impl(in crate::foo) trait InnerUnsafeAutoAlias = Copy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait aliases cannot be `impl`-restricted - -error[E0658]: `impl` restrictions are experimental - --> $DIR/trait-alias-cannot-be-impl-restricted.rs:8:1 - | -LL | impl(crate) trait Alias = Copy; - | ^^^^^^^^^^^ - | - = note: see issue #105077 for more information - = help: add `#![feature(impl_restriction)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: `impl` restrictions are experimental - --> $DIR/trait-alias-cannot-be-impl-restricted.rs:10:6 - | -LL | auto impl(in crate) trait AutoAlias = Copy; - | ^^^^^^^^^^^^^^ - | - = note: see issue #105077 for more information - = help: add `#![feature(impl_restriction)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: `impl` restrictions are experimental - --> $DIR/trait-alias-cannot-be-impl-restricted.rs:13:8 - | -LL | unsafe impl(self) trait UnsafeAlias = Copy; - | ^^^^^^^^^^ - | - = note: see issue #105077 for more information - = help: add `#![feature(impl_restriction)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: `impl` restrictions are experimental - --> $DIR/trait-alias-cannot-be-impl-restricted.rs:16:7 - | -LL | const impl(in self) trait ConstAlias = Copy; - | ^^^^^^^^^^^^^ - | - = note: see issue #105077 for more information - = help: add `#![feature(impl_restriction)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: `impl` restrictions are experimental - --> $DIR/trait-alias-cannot-be-impl-restricted.rs:20:5 - | -LL | impl(super) trait InnerAlias = Copy; - | ^^^^^^^^^^^ - | - = note: see issue #105077 for more information - = help: add `#![feature(impl_restriction)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: `impl` restrictions are experimental - --> $DIR/trait-alias-cannot-be-impl-restricted.rs:22:18 - | -LL | const unsafe impl(in crate::foo) trait InnerConstUnsafeAlias = Copy; - | ^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #105077 for more information - = help: add `#![feature(impl_restriction)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: `impl` restrictions are experimental - --> $DIR/trait-alias-cannot-be-impl-restricted.rs:25:17 - | -LL | unsafe auto impl(in crate::foo) trait InnerUnsafeAutoAlias = Copy; - | ^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #105077 for more information - = help: add `#![feature(impl_restriction)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 19 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/macros/stringify.rs b/tests/ui/macros/stringify.rs index 46f50593c4e95..b48b037b22949 100644 --- a/tests/ui/macros/stringify.rs +++ b/tests/ui/macros/stringify.rs @@ -864,56 +864,56 @@ fn test_impl_restriction() { ); assert_eq!( - stringify!(pub auto impl(crate) trait Foo {}), - "pub auto impl(crate) trait Foo {}" + stringify!(pub impl(crate) auto trait Foo {}), + "pub impl(crate) auto trait Foo {}" ); assert_eq!( - stringify!(pub auto impl(in crate::path::to) trait Foo {}), - "pub auto impl(in crate::path::to) trait Foo {}" + stringify!(pub impl(in crate::path::to) auto trait Foo {}), + "pub impl(in crate::path::to) auto trait Foo {}" ); assert_eq!( - stringify!(pub unsafe impl(crate) trait Foo {}), - "pub unsafe impl(crate) trait Foo {}" + stringify!(pub impl(crate) unsafe trait Foo {}), + "pub impl(crate) unsafe trait Foo {}" ); assert_eq!( - stringify!(pub unsafe impl(in crate::path::to) trait Foo {}), - "pub unsafe impl(in crate::path::to) trait Foo {}" + stringify!(pub impl(in crate::path::to) unsafe trait Foo {}), + "pub impl(in crate::path::to) unsafe trait Foo {}" ); assert_eq!( - stringify!(pub const impl(crate) trait Foo {}), - "pub const impl(crate) trait Foo {}" + stringify!(pub impl(crate) const trait Foo {}), + "pub impl(crate) const trait Foo {}" ); assert_eq!( - stringify!(pub const impl(in crate::path::to) trait Foo {}), - "pub const impl(in crate::path::to) trait Foo {}" + stringify!(pub impl(in crate::path::to) const trait Foo {}), + "pub impl(in crate::path::to) const trait Foo {}" ); assert_eq!( - stringify!(pub unsafe auto impl(crate) trait Foo {}), - "pub unsafe auto impl(crate) trait Foo {}" + stringify!(pub impl(crate) unsafe auto trait Foo {}), + "pub impl(crate) unsafe auto trait Foo {}" ); assert_eq!( - stringify!(pub unsafe auto impl(in crate::path::to) trait Foo {}), - "pub unsafe auto impl(in crate::path::to) trait Foo {}" + stringify!(pub impl(in crate::path::to) unsafe auto trait Foo {}), + "pub impl(in crate::path::to) unsafe auto trait Foo {}" ); assert_eq!( - stringify!(pub const auto impl(crate) trait Foo {}), - "pub const auto impl(crate) trait Foo {}" + stringify!(pub impl(crate) const auto trait Foo {}), + "pub impl(crate) const auto trait Foo {}" ); assert_eq!( - stringify!(pub const auto impl(in crate::path::to) trait Foo {}), - "pub const auto impl(in crate::path::to) trait Foo {}" + stringify!(pub impl(in crate::path::to) const auto trait Foo {}), + "pub impl(in crate::path::to) const auto trait Foo {}" ); assert_eq!( - stringify!(pub const unsafe impl(crate) trait Foo {}), - "pub const unsafe impl(crate) trait Foo {}" + stringify!(pub impl(crate) const unsafe trait Foo {}), + "pub impl(crate) const unsafe trait Foo {}" ); assert_eq!( - stringify!(pub const unsafe impl(in crate::path::to) trait Foo {}), - "pub const unsafe impl(in crate::path::to) trait Foo {}" + stringify!(pub impl(in crate::path::to) const unsafe trait Foo {}), + "pub impl(in crate::path::to) const unsafe trait Foo {}" ); assert_eq!( - stringify!(pub const unsafe auto impl(crate) trait Foo {}), - "pub const unsafe auto impl(crate) trait Foo {}" + stringify!(pub impl(crate) const unsafe auto trait Foo {}), + "pub impl(crate) const unsafe auto trait Foo {}" ); assert_eq!( stringify!(pub const unsafe auto impl(in crate::path::to) trait Foo {}), From ffcbfc1cf49990f7f98abe2b052ba1885242d015 Mon Sep 17 00:00:00 2001 From: cijiugechu Date: Mon, 20 Apr 2026 22:21:51 +0800 Subject: [PATCH 06/20] Use singular wording for single _ placeholders in type suggestions --- .../error_reporting/infer/need_type_info.rs | 28 ++++++++++++++----- compiler/rustc_trait_selection/src/errors.rs | 3 +- ...eref-ambiguity-becomes-nonambiguous.stderr | 2 +- .../edition-raw-pointer-method-2018.stderr | 2 +- .../recursive-in-exhaustiveness.next.stderr | 4 +-- .../ambiguity-after-deref-step.stderr | 2 +- .../underscore-placeholder-wording.rs | 16 +++++++++++ .../underscore-placeholder-wording.stderr | 25 +++++++++++++++++ .../call_method_unknown_pointee.stderr | 4 +-- ...closing-angle-bracket-eq-constraint.stderr | 4 +-- .../pattern/slice-patterns-irrefutable.stderr | 2 +- ...opy-inference-side-effects-are-lazy.stderr | 2 +- .../cannot_infer_local_or_array.stderr | 2 +- .../cannot_infer_local_or_vec.stderr | 2 +- ...cannot_infer_local_or_vec_in_tuples.stderr | 2 +- tests/ui/typeck/issue-7813.stderr | 2 +- ...oxed-closures-failed-recursive-fn-2.stderr | 2 +- 17 files changed, 80 insertions(+), 24 deletions(-) create mode 100644 tests/ui/inference/need_type_info/underscore-placeholder-wording.rs create mode 100644 tests/ui/inference/need_type_info/underscore-placeholder-wording.stderr diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs index 86b6a3c7b7663..cdda3dc843057 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs @@ -27,7 +27,7 @@ use crate::errors::{ AmbiguousImpl, AmbiguousReturn, AnnotationRequired, InferenceBadError, SourceKindMultiSuggestion, SourceKindSubdiag, }; -use crate::infer::InferCtxt; +use crate::infer::{InferCtxt, TyOrConstInferVar}; pub enum TypeAnnotationNeeded { /// ```compile_fail,E0282 @@ -81,13 +81,27 @@ impl InferenceDiagnosticsData { !(self.name == "_" && matches!(self.kind, UnderspecifiedArgKind::Type { .. })) } - fn where_x_is_kind(&self, in_type: Ty<'_>) -> &'static str { + fn where_x_is_kind<'tcx>(&self, infcx: &InferCtxt<'tcx>, in_type: Ty<'tcx>) -> &'static str { if in_type.is_ty_or_numeric_infer() { "" } else if self.name == "_" { - // FIXME: Consider specializing this message if there is a single `_` - // in the type. - "underscore" + let displayed_ty = infcx + .resolve_vars_if_possible(in_type) + .fold_with(&mut ClosureEraser { infcx, depth: 0 }); + if displayed_ty.is_ty_or_numeric_infer() { + "" + } else { + match displayed_ty + .walk() + .filter_map(TyOrConstInferVar::maybe_from_generic_arg) + .take(2) + .count() + { + 0 => "", + 1 => "underscore_single", + _ => "underscore_multiple", + } + } } else { "has_name" } @@ -554,7 +568,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { infer_subdiags.push(SourceKindSubdiag::LetLike { span: insert_span, name: pattern_name.map(|name| name.to_string()).unwrap_or_else(String::new), - x_kind: arg_data.where_x_is_kind(ty), + x_kind: arg_data.where_x_is_kind(self.infcx, ty), prefix_kind: arg_data.kind.clone(), prefix: arg_data.kind.try_get_prefix().unwrap_or_default(), arg_name: arg_data.name, @@ -566,7 +580,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { infer_subdiags.push(SourceKindSubdiag::LetLike { span: insert_span, name: String::new(), - x_kind: arg_data.where_x_is_kind(ty), + x_kind: arg_data.where_x_is_kind(self.infcx, ty), prefix_kind: arg_data.kind.clone(), prefix: arg_data.kind.try_get_prefix().unwrap_or_default(), arg_name: arg_data.name, diff --git a/compiler/rustc_trait_selection/src/errors.rs b/compiler/rustc_trait_selection/src/errors.rs index 1edb3f172149f..8db2720edb0f7 100644 --- a/compiler/rustc_trait_selection/src/errors.rs +++ b/compiler/rustc_trait_selection/src/errors.rs @@ -277,7 +277,8 @@ pub enum SourceKindSubdiag<'a> { [const_with_param] value of const parameter [const] value of the constant } `{$arg_name}` is specified - [underscore] , where the placeholders `_` are specified + [underscore_single] , where the placeholder `_` is specified + [underscore_multiple] , where the placeholders `_` are specified *[empty] {\"\"} }", style = "verbose", diff --git a/tests/ui/autoref-autoderef/deref-ambiguity-becomes-nonambiguous.stderr b/tests/ui/autoref-autoderef/deref-ambiguity-becomes-nonambiguous.stderr index bad799b2550b9..e5d9485e1797b 100644 --- a/tests/ui/autoref-autoderef/deref-ambiguity-becomes-nonambiguous.stderr +++ b/tests/ui/autoref-autoderef/deref-ambiguity-becomes-nonambiguous.stderr @@ -7,7 +7,7 @@ LL | let var_fn = Value::wrap(); LL | let _ = var_fn.clone(); | ------ type must be known at this point | -help: consider giving `var_fn` an explicit type, where the placeholders `_` are specified +help: consider giving `var_fn` an explicit type, where the placeholder `_` is specified | LL | let var_fn: Value> = Value::wrap(); | ++++++++++++++ diff --git a/tests/ui/editions/edition-raw-pointer-method-2018.stderr b/tests/ui/editions/edition-raw-pointer-method-2018.stderr index 2792d1e740056..a95d7dff9caac 100644 --- a/tests/ui/editions/edition-raw-pointer-method-2018.stderr +++ b/tests/ui/editions/edition-raw-pointer-method-2018.stderr @@ -7,7 +7,7 @@ LL | LL | let _ = y.is_null(); | ------- cannot call a method on a raw pointer with an unknown pointee type | -help: consider giving `y` an explicit type, where the placeholders `_` are specified +help: consider giving `y` an explicit type, where the placeholder `_` is specified | LL | let y: *const _ = &x as *const _; | ++++++++++ diff --git a/tests/ui/impl-trait/recursive-in-exhaustiveness.next.stderr b/tests/ui/impl-trait/recursive-in-exhaustiveness.next.stderr index 10e8dbf41ccbf..4b7e312644d25 100644 --- a/tests/ui/impl-trait/recursive-in-exhaustiveness.next.stderr +++ b/tests/ui/impl-trait/recursive-in-exhaustiveness.next.stderr @@ -4,7 +4,7 @@ error[E0282]: type annotations needed for `(_,)` LL | let (x,) = (build(x),); | ^^^^ | -help: consider giving this pattern a type, where the placeholders `_` are specified +help: consider giving this pattern a type, where the placeholder `_` is specified | LL | let (x,): (_,) = (build(x),); | ++++++ @@ -15,7 +15,7 @@ error[E0282]: type annotations needed for `((_,),)` LL | let (x,) = (build2(x),); | ^^^^ | -help: consider giving this pattern a type, where the placeholders `_` are specified +help: consider giving this pattern a type, where the placeholder `_` is specified | LL | let (x,): ((_,),) = (build2(x),); | +++++++++ diff --git a/tests/ui/indexing/ambiguity-after-deref-step.stderr b/tests/ui/indexing/ambiguity-after-deref-step.stderr index c7ddd4731c7cb..458f83d721217 100644 --- a/tests/ui/indexing/ambiguity-after-deref-step.stderr +++ b/tests/ui/indexing/ambiguity-after-deref-step.stderr @@ -7,7 +7,7 @@ LL | LL | x[1]; | - type must be known at this point | -help: consider giving `x` an explicit type, where the placeholders `_` are specified +help: consider giving `x` an explicit type, where the placeholder `_` is specified | LL | let x: &_ = &Default::default(); | ++++ diff --git a/tests/ui/inference/need_type_info/underscore-placeholder-wording.rs b/tests/ui/inference/need_type_info/underscore-placeholder-wording.rs new file mode 100644 index 0000000000000..db1d909f85b17 --- /dev/null +++ b/tests/ui/inference/need_type_info/underscore-placeholder-wording.rs @@ -0,0 +1,16 @@ +// Check that `need_type_info` distinguishes between a single placeholder and +// multiple placeholders when suggesting an explicit type. + +fn singular() { + let v = &[]; + //~^ ERROR type annotations needed + let _ = v.iter(); +} + +fn plural() { + let x = (vec![], vec![]); + //~^ ERROR type annotations needed + let _ = x; +} + +fn main() {} diff --git a/tests/ui/inference/need_type_info/underscore-placeholder-wording.stderr b/tests/ui/inference/need_type_info/underscore-placeholder-wording.stderr new file mode 100644 index 0000000000000..322fcddc8a488 --- /dev/null +++ b/tests/ui/inference/need_type_info/underscore-placeholder-wording.stderr @@ -0,0 +1,25 @@ +error[E0282]: type annotations needed for `&[_; 0]` + --> $DIR/underscore-placeholder-wording.rs:5:9 + | +LL | let v = &[]; + | ^ --- type must be known at this point + | +help: consider giving `v` an explicit type, where the placeholder `_` is specified + | +LL | let v: &[_; 0] = &[]; + | +++++++++ + +error[E0282]: type annotations needed for `(Vec<_>, Vec<_>)` + --> $DIR/underscore-placeholder-wording.rs:11:9 + | +LL | let x = (vec![], vec![]); + | ^ ---------------- type must be known at this point + | +help: consider giving `x` an explicit type, where the placeholders `_` are specified + | +LL | let x: (Vec<_>, Vec<_>) = (vec![], vec![]); + | ++++++++++++++++++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/methods/call_method_unknown_pointee.stderr b/tests/ui/methods/call_method_unknown_pointee.stderr index c123533b51bc1..e21d516e79fb4 100644 --- a/tests/ui/methods/call_method_unknown_pointee.stderr +++ b/tests/ui/methods/call_method_unknown_pointee.stderr @@ -15,7 +15,7 @@ LL | LL | let _b: u8 = b.read(); | ---- cannot call a method on a raw pointer with an unknown pointee type | -help: consider giving `b` an explicit type, where the placeholders `_` are specified +help: consider giving `b` an explicit type, where the placeholder `_` is specified | LL | let b: *const _ = ptr as *const _; | ++++++++++ @@ -37,7 +37,7 @@ LL | LL | let _d: u8 = d.read(); | ---- cannot call a method on a raw pointer with an unknown pointee type | -help: consider giving `d` an explicit type, where the placeholders `_` are specified +help: consider giving `d` an explicit type, where the placeholder `_` is specified | LL | let d: *mut _ = ptr as *mut _; | ++++++++ diff --git a/tests/ui/parser/missing-closing-angle-bracket-eq-constraint.stderr b/tests/ui/parser/missing-closing-angle-bracket-eq-constraint.stderr index f01da7a38f3e1..487a6abc8c43a 100644 --- a/tests/ui/parser/missing-closing-angle-bracket-eq-constraint.stderr +++ b/tests/ui/parser/missing-closing-angle-bracket-eq-constraint.stderr @@ -43,7 +43,7 @@ error[E0282]: type annotations needed for `Vec<_>` LL | let v : Vec<(u32,_) = vec![]; | ^ ------ type must be known at this point | -help: consider giving `v` an explicit type, where the placeholders `_` are specified +help: consider giving `v` an explicit type, where the placeholder `_` is specified | LL | let v: Vec<_> : Vec<(u32,_) = vec![]; | ++++++++ @@ -54,7 +54,7 @@ error[E0282]: type annotations needed for `Vec<_>` LL | let v : Vec<'a = vec![]; | ^ ------ type must be known at this point | -help: consider giving `v` an explicit type, where the placeholders `_` are specified +help: consider giving `v` an explicit type, where the placeholder `_` is specified | LL | let v: Vec<_> : Vec<'a = vec![]; | ++++++++ diff --git a/tests/ui/pattern/slice-patterns-irrefutable.stderr b/tests/ui/pattern/slice-patterns-irrefutable.stderr index 9b46f8a885468..4619a0d798d4b 100644 --- a/tests/ui/pattern/slice-patterns-irrefutable.stderr +++ b/tests/ui/pattern/slice-patterns-irrefutable.stderr @@ -7,7 +7,7 @@ LL | LL | [a, b] = Default::default(); | - type must be known at this point | -help: consider giving `b` an explicit type, where the placeholders `_` are specified +help: consider giving `b` an explicit type, where the placeholder `_` is specified | LL | let b: [_; 3]; | ++++++++ diff --git a/tests/ui/repeat-expr/copy-inference-side-effects-are-lazy.stderr b/tests/ui/repeat-expr/copy-inference-side-effects-are-lazy.stderr index c98b9bb38fdb0..79da0319749ad 100644 --- a/tests/ui/repeat-expr/copy-inference-side-effects-are-lazy.stderr +++ b/tests/ui/repeat-expr/copy-inference-side-effects-are-lazy.stderr @@ -7,7 +7,7 @@ LL | LL | extract(x).max(2); | ---------- type must be known at this point | -help: consider giving `x` an explicit type, where the placeholders `_` are specified +help: consider giving `x` an explicit type, where the placeholder `_` is specified | LL | let x: [Foo; 2] = [Foo(PhantomData); 2]; | +++++++++++++ diff --git a/tests/ui/type/type-check/cannot_infer_local_or_array.stderr b/tests/ui/type/type-check/cannot_infer_local_or_array.stderr index dafbab8278d1b..c58900a66a2b6 100644 --- a/tests/ui/type/type-check/cannot_infer_local_or_array.stderr +++ b/tests/ui/type/type-check/cannot_infer_local_or_array.stderr @@ -4,7 +4,7 @@ error[E0282]: type annotations needed for `[_; 0]` LL | let x = []; | ^ -- type must be known at this point | -help: consider giving `x` an explicit type, where the placeholders `_` are specified +help: consider giving `x` an explicit type, where the placeholder `_` is specified | LL | let x: [_; 0] = []; | ++++++++ diff --git a/tests/ui/type/type-check/cannot_infer_local_or_vec.stderr b/tests/ui/type/type-check/cannot_infer_local_or_vec.stderr index fa90240d34e4c..c4133bf4b56c2 100644 --- a/tests/ui/type/type-check/cannot_infer_local_or_vec.stderr +++ b/tests/ui/type/type-check/cannot_infer_local_or_vec.stderr @@ -4,7 +4,7 @@ error[E0282]: type annotations needed for `Vec<_>` LL | let x = vec![]; | ^ ------ type must be known at this point | -help: consider giving `x` an explicit type, where the placeholders `_` are specified +help: consider giving `x` an explicit type, where the placeholder `_` is specified | LL | let x: Vec<_> = vec![]; | ++++++++ diff --git a/tests/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.stderr b/tests/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.stderr index 5f389bee71074..2aa66799f4f6b 100644 --- a/tests/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.stderr +++ b/tests/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.stderr @@ -4,7 +4,7 @@ error[E0282]: type annotations needed for `(Vec<_>,)` LL | let (x, ) = (vec![], ); | ^^^^^ ---------- type must be known at this point | -help: consider giving this pattern a type, where the placeholders `_` are specified +help: consider giving this pattern a type, where the placeholder `_` is specified | LL | let (x, ): (Vec<_>,) = (vec![], ); | +++++++++++ diff --git a/tests/ui/typeck/issue-7813.stderr b/tests/ui/typeck/issue-7813.stderr index 953cbd206dc77..613a0c2fe4833 100644 --- a/tests/ui/typeck/issue-7813.stderr +++ b/tests/ui/typeck/issue-7813.stderr @@ -4,7 +4,7 @@ error[E0282]: type annotations needed for `&[_; 0]` LL | let v = &[]; | ^ --- type must be known at this point | -help: consider giving `v` an explicit type, where the placeholders `_` are specified +help: consider giving `v` an explicit type, where the placeholder `_` is specified | LL | let v: &[_; 0] = &[]; | +++++++++ diff --git a/tests/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-2.stderr b/tests/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-2.stderr index 739182e120b4f..29b426d42d229 100644 --- a/tests/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-2.stderr +++ b/tests/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-2.stderr @@ -7,7 +7,7 @@ LL | let mut closure0 = None; LL | return c(); | - type must be known at this point | -help: consider giving `closure0` an explicit type, where the placeholders `_` are specified +help: consider giving `closure0` an explicit type, where the placeholder `_` is specified | LL | let mut closure0: Option = None; | +++++++++++ From 470e4623db006aeb49504177c51ef04824124319 Mon Sep 17 00:00:00 2001 From: CoCo-Japan-pan <115922543+CoCo-Japan-pan@users.noreply.github.com> Date: Tue, 21 Apr 2026 22:13:46 +0900 Subject: [PATCH 07/20] Rule out `const unsafe impl` from `FnHeader` to correctly parse `const unsafe trait` implementations. --- compiler/rustc_parse/src/parser/item.rs | 4 ++-- tests/ui/traits/const-traits/const-unsafe-impl.rs | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 tests/ui/traits/const-traits/const-unsafe-impl.rs diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index e72cf491004e3..f56e5eda33ee7 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -2942,8 +2942,8 @@ impl<'a> Parser<'a> { && !self.is_unsafe_foreign_mod() // Rule out `async gen {` and `async gen move {` && !self.is_async_gen_block() - // Rule out `const unsafe auto` and `const unsafe trait` - && !self.is_keyword_ahead(2, &[kw::Auto, kw::Trait]) + // Rule out `const unsafe auto` and `const unsafe trait` and `const unsafe impl` + && !self.is_keyword_ahead(2, &[kw::Auto, kw::Trait, kw::Impl]) ) }) // `extern ABI fn` diff --git a/tests/ui/traits/const-traits/const-unsafe-impl.rs b/tests/ui/traits/const-traits/const-unsafe-impl.rs new file mode 100644 index 0000000000000..f6aeb22309b0d --- /dev/null +++ b/tests/ui/traits/const-traits/const-unsafe-impl.rs @@ -0,0 +1,10 @@ +// Reported in . +//@ check-pass + +#![feature(const_trait_impl)] + +const unsafe impl Trait for () {} + +const unsafe trait Trait {} + +fn main() {} From cbba81e0e212896fdd0c32270b75e82fc0266ade Mon Sep 17 00:00:00 2001 From: CoCo-Japan-pan <115922543+CoCo-Japan-pan@users.noreply.github.com> Date: Tue, 21 Apr 2026 22:55:35 +0900 Subject: [PATCH 08/20] Add early returns in `check_trait_front_matter` --- compiler/rustc_parse/src/parser/item.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index f56e5eda33ee7..96bd59e2519e1 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -1066,9 +1066,20 @@ impl<'a> Parser<'a> { ]; // `impl(` if self.check_keyword(exp!(Impl)) && self.look_ahead(1, |t| t == &token::OpenParen) { - // Since the `path` in `impl(in? path)` can be arbitrarily long, - // we treat `(in? path)` as a `TokenTree::Delimited`, - // so we look ahead over token trees rather than tokens. + // `impl(in` unambiguously introduces an `impl` restriction + if self.is_keyword_ahead(2, &[kw::In]) { + return true; + } + // `impl(crate | self | super)` + SUFFIX + if self.is_keyword_ahead(2, &[kw::Crate, kw::SelfLower, kw::Super]) + && self.look_ahead(3, |t| t == &token::CloseParen) + && SUFFIXES.iter().any(|suffix| { + suffix.iter().enumerate().all(|(i, kw)| self.is_keyword_ahead(i + 4, &[*kw])) + }) + { + return true; + } + // Recover cases like `impl(path::to::module)` + SUFFIX to suggest inserting `in`. SUFFIXES.iter().any(|suffix| { suffix.iter().enumerate().all(|(i, kw)| { self.tree_look_ahead(i + 2, |t| { From 9be8fca54e0e91965bbb928f21b8c22928da9f73 Mon Sep 17 00:00:00 2001 From: lapla Date: Tue, 7 Apr 2026 21:16:06 +0900 Subject: [PATCH 09/20] Fix ICE when const closure appears inside a non-const trait method --- compiler/rustc_middle/src/hir/map.rs | 12 +++++++++++- ...-closure-in-non-const-trait-impl-method.rs | 17 +++++++++++++++++ ...sure-in-non-const-trait-impl-method.stderr | 19 +++++++++++++++++++ ...const-closure-in-non-const-trait-method.rs | 12 ++++++++++++ ...t-closure-in-non-const-trait-method.stderr | 12 ++++++++++++ 5 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 tests/ui/traits/const-traits/const-closure-in-non-const-trait-impl-method.rs create mode 100644 tests/ui/traits/const-traits/const-closure-in-non-const-trait-impl-method.stderr create mode 100644 tests/ui/traits/const-traits/const-closure-in-non-const-trait-method.rs create mode 100644 tests/ui/traits/const-traits/const-closure-in-non-const-trait-method.stderr diff --git a/compiler/rustc_middle/src/hir/map.rs b/compiler/rustc_middle/src/hir/map.rs index 68357212bebe8..d63034ed1d2bb 100644 --- a/compiler/rustc_middle/src/hir/map.rs +++ b/compiler/rustc_middle/src/hir/map.rs @@ -319,7 +319,17 @@ impl<'tcx> TyCtxt<'tcx> { BodyOwnerKind::Fn if self.is_constructor(def_id) => return None, // Const closures use their parent's const context BodyOwnerKind::Closure if self.is_const_fn(def_id) => { - return self.hir_body_const_context(self.local_parent(local_def_id)); + return Some( + self.hir_body_const_context(self.local_parent(local_def_id)).unwrap_or_else( + || { + assert!( + self.dcx().has_errors().is_some(), + "`const` closure with no enclosing const context", + ); + ConstContext::ConstFn + }, + ), + ); } BodyOwnerKind::Fn if self.is_const_fn(def_id) => ConstContext::ConstFn, BodyOwnerKind::Fn | BodyOwnerKind::Closure | BodyOwnerKind::GlobalAsm => return None, diff --git a/tests/ui/traits/const-traits/const-closure-in-non-const-trait-impl-method.rs b/tests/ui/traits/const-traits/const-closure-in-non-const-trait-impl-method.rs new file mode 100644 index 0000000000000..b538c4b6a32fd --- /dev/null +++ b/tests/ui/traits/const-traits/const-closure-in-non-const-trait-impl-method.rs @@ -0,0 +1,17 @@ +#![feature(const_trait_impl)] +#![feature(const_closures)] + +// Regression test for https://github.com/rust-lang/rust/issues/153891 + +const trait Foo { + fn test() -> impl [const] Fn(); +} + +impl Foo for &mut T { + const fn test() -> impl [const] Fn() { + //~^ ERROR functions in trait impls cannot be declared const + const move || {} + } +} + +fn main() {} diff --git a/tests/ui/traits/const-traits/const-closure-in-non-const-trait-impl-method.stderr b/tests/ui/traits/const-traits/const-closure-in-non-const-trait-impl-method.stderr new file mode 100644 index 0000000000000..3ff5578748d29 --- /dev/null +++ b/tests/ui/traits/const-traits/const-closure-in-non-const-trait-impl-method.stderr @@ -0,0 +1,19 @@ +error[E0379]: functions in trait impls cannot be declared const + --> $DIR/const-closure-in-non-const-trait-impl-method.rs:11:5 + | +LL | const fn test() -> impl [const] Fn() { + | ^^^^^ functions in trait impls cannot be const + | +help: remove the `const` ... + | +LL - const fn test() -> impl [const] Fn() { +LL + fn test() -> impl [const] Fn() { + | +help: ... and declare the impl to be const instead + | +LL | impl const Foo for &mut T { + | +++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0379`. diff --git a/tests/ui/traits/const-traits/const-closure-in-non-const-trait-method.rs b/tests/ui/traits/const-traits/const-closure-in-non-const-trait-method.rs new file mode 100644 index 0000000000000..dfd0793180871 --- /dev/null +++ b/tests/ui/traits/const-traits/const-closure-in-non-const-trait-method.rs @@ -0,0 +1,12 @@ +#![feature(const_closures)] + +// Regression test for https://github.com/rust-lang/rust/issues/153891 + +trait Tr { + const fn test() { + //~^ ERROR functions in traits cannot be declared const + (const || {})() + } +} + +fn main() {} diff --git a/tests/ui/traits/const-traits/const-closure-in-non-const-trait-method.stderr b/tests/ui/traits/const-traits/const-closure-in-non-const-trait-method.stderr new file mode 100644 index 0000000000000..79462f620da37 --- /dev/null +++ b/tests/ui/traits/const-traits/const-closure-in-non-const-trait-method.stderr @@ -0,0 +1,12 @@ +error[E0379]: functions in traits cannot be declared const + --> $DIR/const-closure-in-non-const-trait-method.rs:6:5 + | +LL | const fn test() { + | ^^^^^- + | | + | functions in traits cannot be const + | help: remove the `const` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0379`. From abd8c38a28aa6ccb43426add1e87ac65b53e64fc Mon Sep 17 00:00:00 2001 From: aerooneqq Date: Wed, 22 Apr 2026 15:24:30 +0300 Subject: [PATCH 10/20] Support self ty propagation for functions in free to trait reuse --- compiler/rustc_ast_lowering/src/delegation.rs | 11 +- .../src/delegation/generics.rs | 15 +- compiler/rustc_hir/src/hir.rs | 2 + compiler/rustc_hir_analysis/src/delegation.rs | 106 ++++++++++---- tests/pretty/delegation-inherit-attributes.pp | 4 +- .../generics/free-fn-to-trait-infer.rs | 2 +- .../generics/free-fn-to-trait-infer.stderr | 26 +--- .../generics/free-to-trait-self-reuse.rs | 56 ++++++++ .../generics/free-to-trait-self-reuse.stderr | 123 +++++++++++++++++ .../generics/free-to-trait-static-reuse.rs | 46 +++++++ .../free-to-trait-static-reuse.stderr | 129 ++++++++++++++++++ .../generics/mapping/free-to-trait-pass.rs | 10 +- .../generics/synth-params-ice-154780.rs | 4 +- 13 files changed, 476 insertions(+), 58 deletions(-) create mode 100644 tests/ui/delegation/generics/free-to-trait-self-reuse.rs create mode 100644 tests/ui/delegation/generics/free-to-trait-self-reuse.stderr create mode 100644 tests/ui/delegation/generics/free-to-trait-static-reuse.rs create mode 100644 tests/ui/delegation/generics/free-to-trait-static-reuse.stderr diff --git a/compiler/rustc_ast_lowering/src/delegation.rs b/compiler/rustc_ast_lowering/src/delegation.rs index 01382a69f2ec0..593eac2df4893 100644 --- a/compiler/rustc_ast_lowering/src/delegation.rs +++ b/compiler/rustc_ast_lowering/src/delegation.rs @@ -143,7 +143,8 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> { let (param_count, c_variadic) = self.param_count(sig_id); - let mut generics = self.uplift_delegation_generics(delegation, sig_id, item_id); + let mut generics = + self.uplift_delegation_generics(delegation, sig_id, item_id, is_method); let body_id = self.lower_delegation_body( delegation, @@ -301,6 +302,8 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> { hir::InferDelegationSig::Output(self.arena.alloc(hir::DelegationGenerics { child_args_segment_id: generics.child.args_segment_id, parent_args_segment_id: generics.parent.args_segment_id, + self_ty_id: generics.self_ty_id, + propagate_self_ty: generics.propagate_self_ty, })), )), span, @@ -554,6 +557,12 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> { } }; + generics.self_ty_id = match new_path { + hir::QPath::Resolved(ty, _) => ty, + hir::QPath::TypeRelative(ty, _) => Some(ty), + } + .map(|ty| ty.hir_id); + let callee_path = self.arena.alloc(self.mk_expr(hir::ExprKind::Path(new_path), span)); self.arena.alloc(self.mk_expr(hir::ExprKind::Call(callee_path, args), span)) }; diff --git a/compiler/rustc_ast_lowering/src/delegation/generics.rs b/compiler/rustc_ast_lowering/src/delegation/generics.rs index 01b17438bc7f1..201f6bfb4bd63 100644 --- a/compiler/rustc_ast_lowering/src/delegation/generics.rs +++ b/compiler/rustc_ast_lowering/src/delegation/generics.rs @@ -67,6 +67,8 @@ pub(super) struct GenericsGenerationResult<'hir> { pub(super) struct GenericsGenerationResults<'hir> { pub(super) parent: GenericsGenerationResult<'hir>, pub(super) child: GenericsGenerationResult<'hir>, + pub(super) self_ty_id: Option, + pub(super) propagate_self_ty: bool, } pub(super) struct GenericArgsPropagationDetails { @@ -209,6 +211,7 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> { delegation: &Delegation, sig_id: DefId, item_id: NodeId, + is_method: bool, ) -> GenericsGenerationResults<'hir> { let delegation_parent_kind = self.tcx.def_kind(self.tcx.local_parent(self.local_def_id(item_id))); @@ -230,7 +233,12 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> { let child = DelegationGenerics::trait_impl(sig_params, child_user_specified); let child = GenericsGenerationResult::new(child); - return GenericsGenerationResults { parent, child }; + return GenericsGenerationResults { + parent, + child, + self_ty_id: None, + propagate_self_ty: false, + }; } let delegation_in_free_ctx = @@ -238,13 +246,14 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> { let sig_parent = self.tcx.parent(sig_id); let sig_in_trait = matches!(self.tcx.def_kind(sig_parent), DefKind::Trait); + let free_to_trait_delegation = delegation_in_free_ctx && sig_in_trait; + let generate_self = free_to_trait_delegation && is_method && delegation.qself.is_none(); let can_add_generics_to_parent = len >= 2 && self.get_resolution_id(segments[len - 2].id).is_some_and(|def_id| { matches!(self.tcx.def_kind(def_id), DefKind::Trait | DefKind::TraitAlias) }); - let generate_self = delegation_in_free_ctx && sig_in_trait; let parent_generics = if can_add_generics_to_parent { let sig_parent_params = &self.tcx.generics_of(sig_parent).own_params[..]; @@ -278,6 +287,8 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> { GenericsGenerationResults { parent: GenericsGenerationResult::new(parent_generics), child: GenericsGenerationResult::new(child_generics), + self_ty_id: None, + propagate_self_ty: free_to_trait_delegation && !generate_self, } } diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index d8149b4e30a59..3055682bf04c1 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -3761,6 +3761,8 @@ pub enum OpaqueTyOrigin { pub struct DelegationGenerics { pub parent_args_segment_id: Option, pub child_args_segment_id: Option, + pub self_ty_id: Option, + pub propagate_self_ty: bool, } #[derive(Debug, Clone, Copy, PartialEq, Eq, HashStable_Generic)] diff --git a/compiler/rustc_hir_analysis/src/delegation.rs b/compiler/rustc_hir_analysis/src/delegation.rs index da9d3f2290898..be8a8e228c47a 100644 --- a/compiler/rustc_hir_analysis/src/delegation.rs +++ b/compiler/rustc_hir_analysis/src/delegation.rs @@ -7,7 +7,7 @@ use std::debug_assert_matches; use rustc_data_structures::fx::FxHashMap; use rustc_hir::def::DefKind; use rustc_hir::def_id::{DefId, LocalDefId}; -use rustc_hir::{HirId, PathSegment}; +use rustc_hir::{DelegationGenerics, HirId, PathSegment}; use rustc_middle::ty::{ self, EarlyBinder, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitableExt, }; @@ -65,19 +65,35 @@ impl<'tcx> TypeFolder> for ParamIndexRemapper<'tcx> { } enum SelfPositionKind { - AfterLifetimes, + AfterLifetimes(bool /* Should propagate self ty */), Zero, None, } -fn create_self_position_kind(caller_kind: FnKind, callee_kind: FnKind) -> SelfPositionKind { - match (caller_kind, callee_kind) { +fn get_delegation_generics(tcx: TyCtxt<'_>, delegation_id: LocalDefId) -> &DelegationGenerics { + tcx.hir_node(tcx.local_def_id_to_hir_id(delegation_id)) + .fn_sig() + .expect("processing delegation") + .decl + .opt_delegation_generics() + .expect("processing delegation") +} + +fn create_self_position_kind( + tcx: TyCtxt<'_>, + delegation_id: LocalDefId, + sig_id: DefId, +) -> SelfPositionKind { + match (fn_kind(tcx, delegation_id), fn_kind(tcx, sig_id)) { (FnKind::AssocInherentImpl, FnKind::AssocTrait) | (FnKind::AssocTraitImpl, FnKind::AssocTrait) | (FnKind::AssocTrait, FnKind::AssocTrait) | (FnKind::AssocTrait, FnKind::Free) => SelfPositionKind::Zero, - (FnKind::Free, FnKind::AssocTrait) => SelfPositionKind::AfterLifetimes, + (FnKind::Free, FnKind::AssocTrait) => { + let propagate_self_ty = get_delegation_generics(tcx, delegation_id).propagate_self_ty; + SelfPositionKind::AfterLifetimes(propagate_self_ty) + } _ => SelfPositionKind::None, } @@ -141,8 +157,7 @@ fn create_mapping<'tcx>( ) -> FxHashMap { let mut mapping: FxHashMap = Default::default(); - let (caller_kind, callee_kind) = (fn_kind(tcx, def_id), fn_kind(tcx, sig_id)); - let self_pos_kind = create_self_position_kind(caller_kind, callee_kind); + let self_pos_kind = create_self_position_kind(tcx, def_id, sig_id); let is_self_at_zero = matches!(self_pos_kind, SelfPositionKind::Zero); // Is self at zero? If so insert mapping, self in sig parent is always at 0. @@ -156,7 +171,7 @@ fn create_mapping<'tcx>( args_index += get_delegation_parent_args_count_without_self(tcx, def_id, sig_id); let sig_generics = tcx.generics_of(sig_id); - let process_sig_parent_generics = matches!(callee_kind, FnKind::AssocTrait); + let process_sig_parent_generics = matches!(fn_kind(tcx, sig_id), FnKind::AssocTrait); if process_sig_parent_generics { for i in (sig_generics.has_self as usize)..sig_generics.parent_count { @@ -176,7 +191,9 @@ fn create_mapping<'tcx>( } // If self after lifetimes insert mapping, relying that self is at 0 in sig parent. - if matches!(self_pos_kind, SelfPositionKind::AfterLifetimes) { + // If self ty is propagated (meaning there is no generic param `Self`), the specified + // self ty will be inserted in args in `create_generic_args`. + if matches!(self_pos_kind, SelfPositionKind::AfterLifetimes { .. }) { mapping.insert(0, args_index as u32); args_index += 1; } @@ -259,6 +276,22 @@ fn get_parent_and_inheritance_kind<'tcx>( } } +fn get_delegation_self_ty_or_err(tcx: TyCtxt<'_>, delegation_id: LocalDefId) -> Ty<'_> { + get_delegation_generics(tcx, delegation_id) + .self_ty_id + .map(|id| { + let ctx = ItemCtxt::new(tcx, delegation_id); + ctx.lower_ty(tcx.hir_node(id).expect_ty()) + }) + .unwrap_or_else(|| { + Ty::new_error_with_message( + tcx, + tcx.def_span(delegation_id), + "the self type must be specified", + ) + }) +} + fn get_delegation_self_ty<'tcx>(tcx: TyCtxt<'tcx>, delegation_id: LocalDefId) -> Option> { let sig_id = tcx.hir_opt_delegation_sig_id(delegation_id).expect("Delegation must have sig_id"); let (caller_kind, callee_kind) = (fn_kind(tcx, delegation_id), fn_kind(tcx, sig_id)); @@ -269,15 +302,19 @@ fn get_delegation_self_ty<'tcx>(tcx: TyCtxt<'tcx>, delegation_id: LocalDefId) -> | (FnKind::Free, FnKind::Free) | (FnKind::AssocTrait, FnKind::Free) | (FnKind::AssocTrait, FnKind::AssocTrait) => { - match create_self_position_kind(caller_kind, callee_kind) { + match create_self_position_kind(tcx, delegation_id, sig_id) { SelfPositionKind::None => None, - SelfPositionKind::AfterLifetimes => { - // Both sig parent and child lifetimes are in included in this count. - Some(tcx.generics_of(delegation_id).own_counts().lifetimes) + SelfPositionKind::AfterLifetimes(propagate_self_ty) => { + if propagate_self_ty { + Some(get_delegation_self_ty_or_err(tcx, delegation_id)) + } else { + // Both sig parent and child lifetimes are in included in this count. + let index = tcx.generics_of(delegation_id).own_counts().lifetimes; + Some(Ty::new_param(tcx, index as u32, kw::SelfUpper)) + } } - SelfPositionKind::Zero => Some(0), + SelfPositionKind::Zero => Some(Ty::new_param(tcx, 0, kw::SelfUpper)), } - .map(|self_index| Ty::new_param(tcx, self_index as u32, kw::SelfUpper)) } (FnKind::AssocTraitImpl, FnKind::AssocTrait) @@ -366,7 +403,7 @@ fn create_generic_args<'tcx>( let mut new_args = vec![]; - let self_pos_kind = create_self_position_kind(caller_kind, callee_kind); + let self_pos_kind = create_self_position_kind(tcx, delegation_id, sig_id); let mut lifetimes_end_pos; if !parent_args.is_empty() { @@ -374,7 +411,7 @@ fn create_generic_args<'tcx>( parent_args.iter().filter(|a| a.as_region().is_some()).count(); match self_pos_kind { - SelfPositionKind::AfterLifetimes => { + SelfPositionKind::AfterLifetimes { .. } => { new_args.extend(&parent_args[1..1 + parent_args_lifetimes_count]); lifetimes_end_pos = parent_args_lifetimes_count; @@ -407,6 +444,15 @@ fn create_generic_args<'tcx>( .count(); new_args.extend_from_slice(args); + + // Parent args are empty, then if we should propagate self ty (meaning Self generic + // param was not generated) then we should insert it, as it won't be in `args`. + if matches!(self_pos_kind, SelfPositionKind::AfterLifetimes(true)) { + new_args.insert( + lifetimes_end_pos, + ty::GenericArg::from(get_delegation_self_ty_or_err(tcx, delegation_id)), + ); + } } if !child_args.is_empty() { @@ -427,7 +473,8 @@ fn create_generic_args<'tcx>( new_args.insert(lifetimes_end_pos + i, child_args[i]); } - let skip_self = matches!(self_pos_kind, SelfPositionKind::AfterLifetimes); + // If self_ty is propagated it means that Self generic param was not generated. + let skip_self = matches!(self_pos_kind, SelfPositionKind::AfterLifetimes(false)); new_args.extend(&child_args[child_lifetimes_count + skip_self as usize..]); } @@ -446,6 +493,7 @@ pub(crate) fn inherit_predicates_for_delegation_item<'tcx>( preds: Vec<(ty::Clause<'tcx>, Span)>, args: Vec>, folder: ParamIndexRemapper<'tcx>, + filter_self_preds: bool, } impl<'tcx> PredicatesCollector<'tcx> { @@ -458,6 +506,16 @@ pub(crate) fn inherit_predicates_for_delegation_item<'tcx>( let args = self.args.as_slice(); for pred in preds.predicates { + // If self ty is specified then there will be no generic param `Self`, + // so we do not need its predicates. + if self.filter_self_preds + && let Some(trait_pred) = pred.0.as_trait_clause() + // Rely that `Self` has zero index. + && trait_pred.self_ty().skip_binder().is_param(0) + { + continue; + } + let new_pred = pred.0.fold_with(&mut self.folder); self.preds.push(( EarlyBinder::bind(new_pred).instantiate(self.tcx, args).skip_norm_wip(), @@ -484,8 +542,10 @@ pub(crate) fn inherit_predicates_for_delegation_item<'tcx>( let (parent_args, child_args) = get_delegation_user_specified_args(tcx, def_id); let (folder, args) = create_folder_and_args(tcx, def_id, sig_id, parent_args, child_args); - let collector = PredicatesCollector { tcx, preds: vec![], args, folder }; + let self_pos_kind = create_self_position_kind(tcx, def_id, sig_id); + let filter_self_preds = matches!(self_pos_kind, SelfPositionKind::AfterLifetimes(true)); + let collector = PredicatesCollector { tcx, preds: vec![], args, folder, filter_self_preds }; let (parent, inh_kind) = get_parent_and_inheritance_kind(tcx, def_id, sig_id); // `explicit_predicates_of` is used here to avoid copying `Self: Trait` predicate. @@ -573,13 +633,7 @@ fn get_delegation_user_specified_args<'tcx>( tcx: TyCtxt<'tcx>, delegation_id: LocalDefId, ) -> (&'tcx [ty::GenericArg<'tcx>], &'tcx [ty::GenericArg<'tcx>]) { - let info = tcx - .hir_node(tcx.local_def_id_to_hir_id(delegation_id)) - .fn_sig() - .expect("Lowering delegation") - .decl - .opt_delegation_generics() - .expect("Lowering delegation"); + let info = get_delegation_generics(tcx, delegation_id); let get_segment = |hir_id: HirId| -> Option<(&'tcx PathSegment<'tcx>, DefId)> { let segment = tcx.hir_node(hir_id).expect_path_segment(); diff --git a/tests/pretty/delegation-inherit-attributes.pp b/tests/pretty/delegation-inherit-attributes.pp index 242e7161aa84c..e29f76089256d 100644 --- a/tests/pretty/delegation-inherit-attributes.pp +++ b/tests/pretty/delegation-inherit-attributes.pp @@ -114,10 +114,10 @@ #[attr = MustUse {reason: "some reason"}] #[attr = Inline(Hint)] - fn foo(self: _, arg1: _) -> _ { ::foo(self + 1, arg1) } + fn foo(self: _, arg1: _) -> _ { ::foo(self + 1, arg1) } #[attr = MustUse {reason: "some reason"}] #[attr = Inline(Hint)] - fn bar(arg0: _, arg1: _) -> _ { foo(self + 1, arg1) } + fn bar(arg0: _, arg1: _) -> _ { foo(self + 1, arg1) } } } diff --git a/tests/ui/delegation/generics/free-fn-to-trait-infer.rs b/tests/ui/delegation/generics/free-fn-to-trait-infer.rs index 905fc8cf21d7d..f89c17fe266ca 100644 --- a/tests/ui/delegation/generics/free-fn-to-trait-infer.rs +++ b/tests/ui/delegation/generics/free-fn-to-trait-infer.rs @@ -13,8 +13,8 @@ reuse Trait::<_>::foo:: as generic_arguments1; //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions reuse >::foo as generic_arguments2; //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions -//~| ERROR mismatched types reuse <_ as Trait<_>>::foo as generic_arguments3; //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions +//~| ERROR the placeholder `_` is not allowed within types on item signatures for functions fn main() {} diff --git a/tests/ui/delegation/generics/free-fn-to-trait-infer.stderr b/tests/ui/delegation/generics/free-fn-to-trait-infer.stderr index a20b28c16402d..05956f045a279 100644 --- a/tests/ui/delegation/generics/free-fn-to-trait-infer.stderr +++ b/tests/ui/delegation/generics/free-fn-to-trait-infer.stderr @@ -11,29 +11,17 @@ LL | reuse >::foo as generic_arguments2; | ^ not allowed in type signatures error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions - --> $DIR/free-fn-to-trait-infer.rs:17:19 + --> $DIR/free-fn-to-trait-infer.rs:16:8 | LL | reuse <_ as Trait<_>>::foo as generic_arguments3; - | ^ not allowed in type signatures + | ^ not allowed in type signatures -error[E0308]: mismatched types - --> $DIR/free-fn-to-trait-infer.rs:14:25 - | -LL | reuse >::foo as generic_arguments2; - | ^^^ - | | - | expected `&u8`, found `&Self` - | arguments to this function are incorrect - | - = note: expected reference `&u8` - found reference `&Self` -note: method defined here - --> $DIR/free-fn-to-trait-infer.rs:7:8 +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions + --> $DIR/free-fn-to-trait-infer.rs:16:19 | -LL | fn foo(&self, _: U, _: T) {} - | ^^^ ----- +LL | reuse <_ as Trait<_>>::foo as generic_arguments3; + | ^ not allowed in type signatures error: aborting due to 4 previous errors -Some errors have detailed explanations: E0121, E0308. -For more information about an error, try `rustc --explain E0121`. +For more information about this error, try `rustc --explain E0121`. diff --git a/tests/ui/delegation/generics/free-to-trait-self-reuse.rs b/tests/ui/delegation/generics/free-to-trait-self-reuse.rs new file mode 100644 index 0000000000000..4714fa471432b --- /dev/null +++ b/tests/ui/delegation/generics/free-to-trait-self-reuse.rs @@ -0,0 +1,56 @@ +#![feature(fn_delegation)] +#![allow(incomplete_features)] + +trait Bound {} + +trait Trait<'a, T, const X: usize> +where + Self: Bound + Sized, +{ + fn method(&self, x: U) {} + fn method2(self, x: U) {} + fn method3(&mut self, x: U) {} +} + +impl<'a, T, const X: usize> Trait<'a, T, X> for usize {} +impl Bound for usize {} + +reuse >::method as foo; +reuse >::method:: as foo2; +reuse ::method as bar; +reuse ::method::, false> as bar2; + +reuse Trait::<'static, i32, 123>::method as foo3; +reuse Trait::<'static, i32, 123>::method2:: as foo4; +reuse Trait::method3 as bar3; +reuse Trait::method3::, false> as bar4; + +reuse ::method as error5; +//~^ ERROR: the trait bound `String: Trait<'a, T, X>` is not satisfied + +struct Struct; +impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {} +//~^ ERROR: the trait bound `Struct: Bound` is not satisfied + +reuse ::method as error6; +//~^ ERROR: the trait bound `Struct: Bound` is not satisfied + +fn main() { + foo::<&'static str, true>(&123, ""); + foo2(&123, "".to_string()); + bar::<'static, i32, 123, String, false>(&123, "".to_string()); + bar2::<'static, usize, 321>(&123, vec![213, 123]); + + foo3::(&123, "".to_string()); + //~^ ERROR: function takes 3 generic arguments but 2 generic arguments were supplied + foo4(123, "".to_string()); + bar3::<'static, i32, 123, bool, false>(&mut 123, true); + //~^ ERROR: function takes 5 generic arguments but 4 generic arguments were supplied + bar4::<'static, usize, 321>(&mut 123, vec![123]); + //~^ ERROR: function takes 3 generic arguments but 2 generic arguments were supplied + + foo3::(&123, "".to_string()); + foo4::(123, "".to_string()); + bar3::<'static, usize, i32, 123, String, false>(&mut 123, "".to_string()); + bar4::<'static, usize, usize, 321>(&mut 123, vec![123]); +} diff --git a/tests/ui/delegation/generics/free-to-trait-self-reuse.stderr b/tests/ui/delegation/generics/free-to-trait-self-reuse.stderr new file mode 100644 index 0000000000000..842f4cd4eb395 --- /dev/null +++ b/tests/ui/delegation/generics/free-to-trait-self-reuse.stderr @@ -0,0 +1,123 @@ +error[E0277]: the trait bound `Struct: Bound` is not satisfied + --> $DIR/free-to-trait-self-reuse.rs:32:49 + | +LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {} + | ^^^^^^ unsatisfied trait bound + | +help: the trait `Bound` is not implemented for `Struct` + --> $DIR/free-to-trait-self-reuse.rs:31:1 + | +LL | struct Struct; + | ^^^^^^^^^^^^^ +help: the trait `Bound` is implemented for `usize` + --> $DIR/free-to-trait-self-reuse.rs:16:1 + | +LL | impl Bound for usize {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: required by a bound in `Trait` + --> $DIR/free-to-trait-self-reuse.rs:8:11 + | +LL | trait Trait<'a, T, const X: usize> + | ----- required by a bound in this trait +LL | where +LL | Self: Bound + Sized, + | ^^^^^^^^ required by this bound in `Trait` + +error[E0277]: the trait bound `String: Trait<'a, T, X>` is not satisfied + --> $DIR/free-to-trait-self-reuse.rs:28:8 + | +LL | reuse ::method as error5; + | ^^^^^^ the trait `Trait<'a, T, X>` is not implemented for `String` + | +help: the following other types implement trait `Trait<'a, T, X>` + --> $DIR/free-to-trait-self-reuse.rs:15:1 + | +LL | impl<'a, T, const X: usize> Trait<'a, T, X> for usize {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `usize` +... +LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Struct` + +error[E0277]: the trait bound `Struct: Bound` is not satisfied + --> $DIR/free-to-trait-self-reuse.rs:35:8 + | +LL | reuse ::method as error6; + | ^^^^^^ unsatisfied trait bound + | +help: the trait `Bound` is not implemented for `Struct` + --> $DIR/free-to-trait-self-reuse.rs:31:1 + | +LL | struct Struct; + | ^^^^^^^^^^^^^ +help: the trait `Bound` is implemented for `usize` + --> $DIR/free-to-trait-self-reuse.rs:16:1 + | +LL | impl Bound for usize {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: required by a bound in `Trait::method` + --> $DIR/free-to-trait-self-reuse.rs:8:11 + | +LL | Self: Bound + Sized, + | ^^^^^^^^ required by this bound in `Trait::method` +LL | { +LL | fn method(&self, x: U) {} + | ------ required by a bound in this associated function + +error[E0107]: function takes 3 generic arguments but 2 generic arguments were supplied + --> $DIR/free-to-trait-self-reuse.rs:44:5 + | +LL | foo3::(&123, "".to_string()); + | ^^^^ ------ ---- supplied 2 generic arguments + | | + | expected 3 generic arguments + | +note: function defined here, with 3 generic parameters: `Self`, `U`, `B` + --> $DIR/free-to-trait-self-reuse.rs:23:45 + | +LL | reuse Trait::<'static, i32, 123>::method as foo3; + | ------ ^^^^ +help: add missing generic argument + | +LL | foo3::(&123, "".to_string()); + | +++ + +error[E0107]: function takes 5 generic arguments but 4 generic arguments were supplied + --> $DIR/free-to-trait-self-reuse.rs:47:5 + | +LL | bar3::<'static, i32, 123, bool, false>(&mut 123, true); + | ^^^^ --- --- ---- ----- supplied 4 generic arguments + | | + | expected 5 generic arguments + | +note: function defined here, with 5 generic parameters: `Self`, `T`, `X`, `U`, `B` + --> $DIR/free-to-trait-self-reuse.rs:25:25 + | +LL | reuse Trait::method3 as bar3; + | ------- ^^^^ +help: add missing generic argument + | +LL | bar3::<'static, i32, 123, bool, false, B>(&mut 123, true); + | +++ + +error[E0107]: function takes 3 generic arguments but 2 generic arguments were supplied + --> $DIR/free-to-trait-self-reuse.rs:49:5 + | +LL | bar4::<'static, usize, 321>(&mut 123, vec![123]); + | ^^^^ ----- --- supplied 2 generic arguments + | | + | expected 3 generic arguments + | +note: function defined here, with 3 generic parameters: `Self`, `T`, `X` + --> $DIR/free-to-trait-self-reuse.rs:26:44 + | +LL | reuse Trait::method3::, false> as bar4; + | ------- ^^^^ +help: add missing generic argument + | +LL | bar4::<'static, usize, 321, X>(&mut 123, vec![123]); + | +++ + +error: aborting due to 6 previous errors + +Some errors have detailed explanations: E0107, E0277. +For more information about an error, try `rustc --explain E0107`. diff --git a/tests/ui/delegation/generics/free-to-trait-static-reuse.rs b/tests/ui/delegation/generics/free-to-trait-static-reuse.rs new file mode 100644 index 0000000000000..b82e3fcac1b36 --- /dev/null +++ b/tests/ui/delegation/generics/free-to-trait-static-reuse.rs @@ -0,0 +1,46 @@ +#![feature(fn_delegation)] +#![allow(incomplete_features)] + +trait Bound {} + +trait Trait<'a, T, const X: usize> +where + Self: Bound, +{ + fn static_method<'c: 'c, U, const B: bool>(x: usize) {} +} + +impl<'a, T, const X: usize> Trait<'a, T, X> for usize {} +impl Bound for usize {} + +reuse >::static_method as foo { self + 2 } +reuse >::static_method::<'static, String, false> as foo2; +reuse ::static_method as bar { self + 1 } +reuse ::static_method::<'static, Vec, false> as bar2; + +reuse Trait::static_method as error { self - 123 } +//~^ ERROR: type annotations needed +reuse Trait::<'static, i32, 123>::static_method as error2; +//~^ ERROR: type annotations needed +reuse Trait::<'static, i32, 123>::static_method::<'static, String, false> as error3; +//~^ ERROR: type annotations needed +reuse Trait::static_method::<'static, Vec, false> as error4 { self + 4 } +//~^ ERROR: type annotations needed + +reuse ::static_method as error5; +//~^ ERROR: the trait bound `String: Trait<'a, T, X>` is not satisfied + +struct Struct; +impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {} +//~^ ERROR: the trait bound `Struct: Bound` is not satisfied + +reuse ::static_method as error6; +//~^ ERROR: the trait bound `Struct: Bound` is not satisfied + +fn main() { + foo::<'static, String, true>(123); + foo2(123); + + bar::<'static, 'static, i32, 123, String, false>(123); + bar2::<'static, usize, 321>(123); +} diff --git a/tests/ui/delegation/generics/free-to-trait-static-reuse.stderr b/tests/ui/delegation/generics/free-to-trait-static-reuse.stderr new file mode 100644 index 0000000000000..4ccbd0b072c3b --- /dev/null +++ b/tests/ui/delegation/generics/free-to-trait-static-reuse.stderr @@ -0,0 +1,129 @@ +error[E0277]: the trait bound `Struct: Bound` is not satisfied + --> $DIR/free-to-trait-static-reuse.rs:34:49 + | +LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {} + | ^^^^^^ unsatisfied trait bound + | +help: the trait `Bound` is not implemented for `Struct` + --> $DIR/free-to-trait-static-reuse.rs:33:1 + | +LL | struct Struct; + | ^^^^^^^^^^^^^ +help: the trait `Bound` is implemented for `usize` + --> $DIR/free-to-trait-static-reuse.rs:14:1 + | +LL | impl Bound for usize {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: required by a bound in `Trait` + --> $DIR/free-to-trait-static-reuse.rs:8:11 + | +LL | trait Trait<'a, T, const X: usize> + | ----- required by a bound in this trait +LL | where +LL | Self: Bound, + | ^^^^^^^^ required by this bound in `Trait` + +error[E0283]: type annotations needed + --> $DIR/free-to-trait-static-reuse.rs:21:14 + | +LL | reuse Trait::static_method as error { self - 123 } + | ^^^^^^^^^^^^^ cannot infer type + | +note: multiple `impl`s satisfying `_: Trait<'a, T, X>` found + --> $DIR/free-to-trait-static-reuse.rs:13:1 + | +LL | impl<'a, T, const X: usize> Trait<'a, T, X> for usize {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0283]: type annotations needed + --> $DIR/free-to-trait-static-reuse.rs:23:35 + | +LL | reuse Trait::<'static, i32, 123>::static_method as error2; + | ^^^^^^^^^^^^^ cannot infer type + | +note: multiple `impl`s satisfying `_: Trait<'static, i32, 123>` found + --> $DIR/free-to-trait-static-reuse.rs:13:1 + | +LL | impl<'a, T, const X: usize> Trait<'a, T, X> for usize {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0283]: type annotations needed + --> $DIR/free-to-trait-static-reuse.rs:25:35 + | +LL | reuse Trait::<'static, i32, 123>::static_method::<'static, String, false> as error3; + | ^^^^^^^^^^^^^ cannot infer type + | +note: multiple `impl`s satisfying `_: Trait<'static, i32, 123>` found + --> $DIR/free-to-trait-static-reuse.rs:13:1 + | +LL | impl<'a, T, const X: usize> Trait<'a, T, X> for usize {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0283]: type annotations needed + --> $DIR/free-to-trait-static-reuse.rs:27:14 + | +LL | reuse Trait::static_method::<'static, Vec, false> as error4 { self + 4 } + | ^^^^^^^^^^^^^ cannot infer type + | +note: multiple `impl`s satisfying `_: Trait<'a, T, X>` found + --> $DIR/free-to-trait-static-reuse.rs:13:1 + | +LL | impl<'a, T, const X: usize> Trait<'a, T, X> for usize {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `String: Trait<'a, T, X>` is not satisfied + --> $DIR/free-to-trait-static-reuse.rs:30:8 + | +LL | reuse ::static_method as error5; + | ^^^^^^ the trait `Trait<'a, T, X>` is not implemented for `String` + | +help: the following other types implement trait `Trait<'a, T, X>` + --> $DIR/free-to-trait-static-reuse.rs:13:1 + | +LL | impl<'a, T, const X: usize> Trait<'a, T, X> for usize {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `usize` +... +LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Struct` + +error[E0277]: the trait bound `Struct: Bound` is not satisfied + --> $DIR/free-to-trait-static-reuse.rs:37:8 + | +LL | reuse ::static_method as error6; + | ^^^^^^ unsatisfied trait bound + | +help: the trait `Bound` is not implemented for `Struct` + --> $DIR/free-to-trait-static-reuse.rs:33:1 + | +LL | struct Struct; + | ^^^^^^^^^^^^^ +help: the trait `Bound` is implemented for `usize` + --> $DIR/free-to-trait-static-reuse.rs:14:1 + | +LL | impl Bound for usize {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: required by a bound in `Trait::static_method` + --> $DIR/free-to-trait-static-reuse.rs:8:11 + | +LL | Self: Bound, + | ^^^^^^^^ required by this bound in `Trait::static_method` +LL | { +LL | fn static_method<'c: 'c, U, const B: bool>(x: usize) {} + | ------------- required by a bound in this associated function + +error: aborting due to 7 previous errors + +Some errors have detailed explanations: E0277, E0283. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/delegation/generics/mapping/free-to-trait-pass.rs b/tests/ui/delegation/generics/mapping/free-to-trait-pass.rs index cd779a9887a27..1126881836696 100644 --- a/tests/ui/delegation/generics/mapping/free-to-trait-pass.rs +++ b/tests/ui/delegation/generics/mapping/free-to-trait-pass.rs @@ -171,14 +171,14 @@ mod test_10 { pub fn check() { fn with_ctx<'a, 'b, 'c, A, B, C, const N: usize, const M: bool>() { reuse ::foo as bar; - bar::<'a, 'b, 'c, u8, C, A, M>(); - bar::<'static, 'static, 'static, u8, i32, i32, false>(); + bar::<'a, 'b, 'c, C, A, M>(); + bar::<'static, 'static, 'static, i32, i32, false>(); reuse >::foo as bar1; - bar1::<'static, u8, i32, true>(); + bar1::<'static, i32, true>(); reuse >::foo::<'static, u32, true> as bar2; - bar2::(); + bar2(); } with_ctx::(); @@ -211,7 +211,7 @@ mod test_11 { pub fn check<'b>() { reuse ::foo; - foo::<'static, 'b, usize, u32, Struct, String, false>(); + foo::<'static, 'b, u32, Struct, String, false>(); } } diff --git a/tests/ui/delegation/generics/synth-params-ice-154780.rs b/tests/ui/delegation/generics/synth-params-ice-154780.rs index 96af4ed86b4c2..3ea52818a8f08 100644 --- a/tests/ui/delegation/generics/synth-params-ice-154780.rs +++ b/tests/ui/delegation/generics/synth-params-ice-154780.rs @@ -36,8 +36,8 @@ mod test_2 { reuse ::bar as bar2; pub fn check() { - assert_eq!(foo2::<'static, 'static, X, (), true, false, (), ()>(X, || 123), 123); - assert_eq!(bar2::<'static, X, (), true>(X, || 123), 123); + assert_eq!(foo2::<'static, 'static, (), true, false, (), ()>(X, || 123), 123); + assert_eq!(bar2::<'static, (), true>(X, || 123), 123); } } From 0dca30756db23c9f287a527e4125fcccd600a207 Mon Sep 17 00:00:00 2001 From: Jules Bertholet Date: Fri, 17 Apr 2026 21:22:16 -0400 Subject: [PATCH 11/20] Account for titlecase in casing lints --- compiler/rustc_lint/src/lib.rs | 1 + compiler/rustc_lint/src/nonstandard_style.rs | 80 +++++++++++++------ .../rustc_lint/src/nonstandard_style/tests.rs | 40 +++++++--- .../lint/lint-nonstandard-style-unicode-1.rs | 12 ++- .../lint-nonstandard-style-unicode-1.stderr | 14 +++- .../lint/lint-nonstandard-style-unicode-2.rs | 31 +++++++ .../lint-nonstandard-style-unicode-2.stderr | 61 ++++++++++++++ .../lint/lint-nonstandard-style-unicode-3.rs | 7 ++ .../lint-nonstandard-style-unicode-3.stderr | 23 +++++- tests/ui/lint/special-upper-lower-cases.rs | 18 ++--- .../ui/lint/special-upper-lower-cases.stderr | 27 ++++--- 11 files changed, 252 insertions(+), 62 deletions(-) create mode 100644 tests/ui/lint/lint-nonstandard-style-unicode-2.rs create mode 100644 tests/ui/lint/lint-nonstandard-style-unicode-2.stderr diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index 9fa5501433453..4a5172a237e71 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -24,6 +24,7 @@ #![feature(box_patterns)] #![feature(iter_order_by)] #![feature(rustc_attrs)] +#![feature(titlecase)] #![feature(try_blocks)] // tidy-alphabetical-end diff --git a/compiler/rustc_lint/src/nonstandard_style.rs b/compiler/rustc_lint/src/nonstandard_style.rs index 13429f328565d..6cec7b0efd82f 100644 --- a/compiler/rustc_lint/src/nonstandard_style.rs +++ b/compiler/rustc_lint/src/nonstandard_style.rs @@ -47,34 +47,46 @@ declare_lint! { declare_lint_pass!(NonCamelCaseTypes => [NON_CAMEL_CASE_TYPES]); -/// Some unicode characters *have* case, are considered upper case or lower case, but they *can't* -/// be upper cased or lower cased. For the purposes of the lint suggestion, we care about being able +/// Some unicode characters *have* case, are considered upper, title, or lower case, but they *can't* +/// be title cased or lower cased. For the purposes of the lint suggestion, we care about being able /// to change the char's case. fn char_has_case(c: char) -> bool { - !c.to_lowercase().eq(c.to_uppercase()) + !c.to_lowercase().eq(c.to_titlecase()) } -// contains a capitalisable character followed by, or preceded by, an underscore -fn has_underscore_case(s: &str) -> bool { +/// FIXME: we should add a more efficient version +/// in the stdlib for this +fn changes_when_titlecased(c: char) -> bool { + !c.to_titlecase().eq([c]) +} + +// contains a capitalisable character followed by, or preceded by, an underscore, +// or contains an uppercase character that changes when titlecased, +// or contains `__` +fn not_camel_case(s: &str) -> bool { let mut last = '\0'; - s.chars().any(|c| match (std::mem::replace(&mut last, c), c) { - ('_', cs) | (cs, '_') => char_has_case(cs), - _ => false, + s.chars().any(|snd| { + let fst = std::mem::replace(&mut last, snd); + match (fst, snd) { + ('_', '_') => return true, + ('_', _) if char_has_case(snd) => return true, + (_, '_') if char_has_case(fst) => return true, + _ => snd.is_uppercase() && changes_when_titlecased(snd), + } }) } -fn is_camel_case(name: &str) -> bool { +fn is_upper_camel_case(name: &str) -> bool { let name = name.trim_matches('_'); let Some(first) = name.chars().next() else { return true; }; - // start with a non-lowercase letter rather than uppercase - // ones (some scripts don't have a concept of upper/lowercase) - !(first.is_lowercase() || name.contains("__") || has_underscore_case(name)) + // some scripts don't have a concept of upper/lowercase + !(changes_when_titlecased(first) || not_camel_case(name)) } -fn to_camel_case(s: &str) -> String { +fn to_upper_camel_case(s: &str) -> String { s.trim_matches('_') .split('_') .filter(|component| !component.is_empty()) @@ -83,24 +95,31 @@ fn to_camel_case(s: &str) -> String { let mut new_word = true; let mut prev_is_lower_case = true; + let mut prev_is_lowercased_sigma = false; for c in component.chars() { // Preserve the case if an uppercase letter follows a lowercase letter, so that // `camelCase` is converted to `CamelCase`. - if prev_is_lower_case && c.is_uppercase() { + if prev_is_lower_case && (c.is_uppercase() | c.is_titlecase()) { new_word = true; } if new_word { - camel_cased_component.extend(c.to_uppercase()); + camel_cased_component.extend(c.to_titlecase()); } else { camel_cased_component.extend(c.to_lowercase()); } - prev_is_lower_case = c.is_lowercase(); + prev_is_lower_case = c.is_lowercase() || c.is_titlecase(); + prev_is_lowercased_sigma = !new_word && c == 'Σ'; new_word = false; } + if prev_is_lowercased_sigma { + camel_cased_component.pop(); + camel_cased_component.push('ς'); + } + camel_cased_component }) .fold((String::new(), None), |(acc, prev): (String, Option), next| { @@ -122,8 +141,8 @@ impl NonCamelCaseTypes { fn check_case(&self, cx: &EarlyContext<'_>, sort: &str, ident: &Ident) { let name = ident.name.as_str(); - if !is_camel_case(name) { - let cc = to_camel_case(name); + if !is_upper_camel_case(name) { + let cc = to_upper_camel_case(name); let sub = if *name != cc { NonCamelCaseTypeSub::Suggestion { span: ident.span, replace: cc } } else { @@ -235,14 +254,20 @@ impl NonSnakeCase { continue; } for ch in s.chars() { - if !buf.is_empty() && buf != "'" && ch.is_uppercase() && !last_upper { - words.push(buf); + if !buf.is_empty() + && buf != "'" + && (ch.is_uppercase() || ch.is_titlecase()) + && !last_upper + { + // We lowercase only at the end, to handle final sigma correctly + words.push(buf.to_lowercase()); buf = String::new(); } - last_upper = ch.is_uppercase(); - buf.extend(ch.to_lowercase()); + last_upper = ch.is_uppercase() || ch.is_titlecase(); + buf.push(ch); } - words.push(buf); + // We lowercase only at the end, to handle final sigma correctly + words.push(buf.to_lowercase()); } words.join("_") } @@ -262,7 +287,8 @@ impl NonSnakeCase { // This correctly handles letters in languages with and without // cases, as well as numbers and underscores. - !ident.chars().any(char::is_uppercase) + // FIXME: we should add a standard library impl of `c.to_lowercase().eq([c])` + ident.chars().all(|c| c.to_lowercase().eq([c])) } let name = ident.name.as_str(); @@ -474,10 +500,12 @@ impl<'a, 'b, F: FnOnce() -> NonUpperCaseGlobal<'b>> Diagnostic<'a, ()> impl NonUpperCaseGlobals { fn check_upper_case(cx: &LateContext<'_>, sort: &str, did: Option, ident: &Ident) { let name = ident.name.as_str(); - if name.chars().any(|c| c.is_lowercase()) { + // FIXME: we should add a more efficient version + // in the stdlib for `c.to_uppercase().eq([c])` + if !name.chars().all(|c| c.to_uppercase().eq([c])) { let uc = NonSnakeCase::to_snake_case(name).to_uppercase(); - // If the item is exported, suggesting changing it's name would be breaking-change + // If the item is exported, suggesting changing its name would be a breaking change // and could break users without a "nice" applicable fix, so let's avoid it. let can_change_usages = if let Some(did) = did { !cx.tcx.effective_visibilities(()).is_exported(did) diff --git a/compiler/rustc_lint/src/nonstandard_style/tests.rs b/compiler/rustc_lint/src/nonstandard_style/tests.rs index 39c525b8623d0..773ef99775462 100644 --- a/compiler/rustc_lint/src/nonstandard_style/tests.rs +++ b/compiler/rustc_lint/src/nonstandard_style/tests.rs @@ -1,21 +1,37 @@ -use super::{is_camel_case, to_camel_case}; +use super::{is_upper_camel_case, to_upper_camel_case}; #[test] fn camel_case() { - assert!(!is_camel_case("userData")); - assert_eq!(to_camel_case("userData"), "UserData"); + assert!(!is_upper_camel_case("userData")); + assert_eq!(to_upper_camel_case("userData"), "UserData"); - assert!(is_camel_case("X86_64")); + assert!(is_upper_camel_case("X86_64")); - assert!(!is_camel_case("X86__64")); - assert_eq!(to_camel_case("X86__64"), "X86_64"); + assert!(!is_upper_camel_case("X86__64")); + assert_eq!(to_upper_camel_case("X86__64"), "X86_64"); - assert!(!is_camel_case("Abc_123")); - assert_eq!(to_camel_case("Abc_123"), "Abc123"); + assert!(!is_upper_camel_case("Abc_123")); + assert_eq!(to_upper_camel_case("Abc_123"), "Abc123"); - assert!(!is_camel_case("A1_b2_c3")); - assert_eq!(to_camel_case("A1_b2_c3"), "A1B2C3"); + assert!(!is_upper_camel_case("A1_b2_c3")); + assert_eq!(to_upper_camel_case("A1_b2_c3"), "A1B2C3"); - assert!(!is_camel_case("ONE_TWO_THREE")); - assert_eq!(to_camel_case("ONE_TWO_THREE"), "OneTwoThree"); + assert!(!is_upper_camel_case("ONE_TWO_THREE")); + assert_eq!(to_upper_camel_case("ONE_TWO_THREE"), "OneTwoThree"); + + // FIXME(@Jules-Bertholet): This test doesn't work due to what I believe + // is a Unicode spec bug - uppercase Georgian letters have + // incorrect titlecase mappings. + // I've reported it to Unicode. + // Georgian mtavruli is only used in all-caps + //assert!(!is_upper_camel_case("ᲫალაᲔრთობაშია")); + //assert_eq!(to_upper_camel_case("ᲫალაᲔრთობაშია"), "ძალა_ერთობაშია"); + + assert!(!is_upper_camel_case("LJNJaaaDŽooo")); + assert_eq!(to_upper_camel_case("LJNJaaLjNJaDŽooo"), "LjnjaaLjNjaDžooo"); + + // Final sigma + assert!(!is_upper_camel_case("ΦΙΛΟΣ_ΦΙΛΟΣ")); + assert_eq!(to_upper_camel_case("ΦΙΛΟΣ_ΦΙΛΟΣ"), "ΦιλοςΦιλος"); + assert!(is_upper_camel_case("ΦιλοσΦιλοσ")); } diff --git a/tests/ui/lint/lint-nonstandard-style-unicode-1.rs b/tests/ui/lint/lint-nonstandard-style-unicode-1.rs index 7c45c099304fa..95738b2bec5a4 100644 --- a/tests/ui/lint/lint-nonstandard-style-unicode-1.rs +++ b/tests/ui/lint/lint-nonstandard-style-unicode-1.rs @@ -42,8 +42,18 @@ struct Hello_World; struct 你_ӟ; //~^ ERROR type `你_ӟ` should have an upper camel case name -// and this is ok: +struct ΦΙΛΟΣ_Σ; +//~^ ERROR type `ΦΙΛΟΣ_Σ` should have an upper camel case name + +struct Σ_ΦΙΛΟΣ; +//~^ ERROR type `Σ_ΦΙΛΟΣ` should have an upper camel case name + +// these are ok: struct 你_好; +struct ძალა_ერთობაშია; + +struct Σ; + fn main() {} diff --git a/tests/ui/lint/lint-nonstandard-style-unicode-1.stderr b/tests/ui/lint/lint-nonstandard-style-unicode-1.stderr index 6c2aa225e602e..c319395e6ce31 100644 --- a/tests/ui/lint/lint-nonstandard-style-unicode-1.stderr +++ b/tests/ui/lint/lint-nonstandard-style-unicode-1.stderr @@ -46,5 +46,17 @@ error: type `你_ӟ` should have an upper camel case name LL | struct 你_ӟ; | ^^^^ help: convert the identifier to upper camel case: `你Ӟ` -error: aborting due to 7 previous errors +error: type `ΦΙΛΟΣ_Σ` should have an upper camel case name + --> $DIR/lint-nonstandard-style-unicode-1.rs:45:8 + | +LL | struct ΦΙΛΟΣ_Σ; + | ^^^^^^^ help: convert the identifier to upper camel case: `ΦιλοςΣ` + +error: type `Σ_ΦΙΛΟΣ` should have an upper camel case name + --> $DIR/lint-nonstandard-style-unicode-1.rs:48:8 + | +LL | struct Σ_ΦΙΛΟΣ; + | ^^^^^^^ help: convert the identifier to upper camel case: `ΣΦιλος` + +error: aborting due to 9 previous errors diff --git a/tests/ui/lint/lint-nonstandard-style-unicode-2.rs b/tests/ui/lint/lint-nonstandard-style-unicode-2.rs new file mode 100644 index 0000000000000..43c98c1f26b3e --- /dev/null +++ b/tests/ui/lint/lint-nonstandard-style-unicode-2.rs @@ -0,0 +1,31 @@ +#![allow(dead_code)] +#![forbid(non_snake_case)] + +// 2. non_snake_case + + +fn LJNJaaLjNJaDŽooo() {} +//~^ ERROR function `LJNJaaLjNJaDŽooo` should have a snake case name +//~| WARN identifier contains 5 non normalized (NFKC) characters + +fn LjnjaaLjNjaDžooo() {} +//~^ ERROR function `LjnjaaLjNjaDžooo` should have a snake case name +//~| WARN identifier contains 5 non normalized (NFKC) characters + +// test final sigma casing +fn ΦΙΛΟΣ_ΦΙΛΟΣ() {} +//~^ ERROR function `ΦΙΛΟΣ_ΦΙΛΟΣ` should have a snake case name + +fn Σ() {} +//~^ ERROR function `Σ` should have a snake case name + +fn ΦΙΛΟΣ_Σ() {} +//~^ ERROR function `ΦΙΛΟΣ_Σ` should have a snake case name + +fn Σ_ΦΙΛΟΣ() {} +//~^ ERROR function `Σ_ΦΙΛΟΣ` should have a snake case name + +// this is ok +fn φιλοσ_φιλοσ() {} + +fn main() {} diff --git a/tests/ui/lint/lint-nonstandard-style-unicode-2.stderr b/tests/ui/lint/lint-nonstandard-style-unicode-2.stderr new file mode 100644 index 0000000000000..3e5fffb22ebc4 --- /dev/null +++ b/tests/ui/lint/lint-nonstandard-style-unicode-2.stderr @@ -0,0 +1,61 @@ +warning: identifier contains 5 non normalized (NFKC) characters: 'LJ', 'NJ', 'Lj', 'NJ', and 'DŽ' + --> $DIR/lint-nonstandard-style-unicode-2.rs:7:4 + | +LL | fn LJNJaaLjNJaDŽooo() {} + | ^^^^^^^^^^^ + | + = note: these characters are included in the Not_NFKC Unicode general security profile + = note: `#[warn(uncommon_codepoints)]` on by default + +warning: identifier contains 5 non normalized (NFKC) characters: 'Lj', 'nj', 'Lj', 'Nj', and 'Dž' + --> $DIR/lint-nonstandard-style-unicode-2.rs:11:4 + | +LL | fn LjnjaaLjNjaDžooo() {} + | ^^^^^^^^^^^ + | + = note: these characters are included in the Not_NFKC Unicode general security profile + +error: function `LJNJaaLjNJaDŽooo` should have a snake case name + --> $DIR/lint-nonstandard-style-unicode-2.rs:7:4 + | +LL | fn LJNJaaLjNJaDŽooo() {} + | ^^^^^^^^^^^ help: convert the identifier to snake case: `ljnjaa_ljnja_džooo` + | +note: the lint level is defined here + --> $DIR/lint-nonstandard-style-unicode-2.rs:2:11 + | +LL | #![forbid(non_snake_case)] + | ^^^^^^^^^^^^^^ + +error: function `LjnjaaLjNjaDžooo` should have a snake case name + --> $DIR/lint-nonstandard-style-unicode-2.rs:11:4 + | +LL | fn LjnjaaLjNjaDžooo() {} + | ^^^^^^^^^^^ help: convert the identifier to snake case: `ljnjaa_ljnja_džooo` + +error: function `ΦΙΛΟΣ_ΦΙΛΟΣ` should have a snake case name + --> $DIR/lint-nonstandard-style-unicode-2.rs:16:4 + | +LL | fn ΦΙΛΟΣ_ΦΙΛΟΣ() {} + | ^^^^^^^^^^^ help: convert the identifier to snake case: `φιλος_φιλος` + +error: function `Σ` should have a snake case name + --> $DIR/lint-nonstandard-style-unicode-2.rs:19:4 + | +LL | fn Σ() {} + | ^ help: convert the identifier to snake case: `σ` + +error: function `ΦΙΛΟΣ_Σ` should have a snake case name + --> $DIR/lint-nonstandard-style-unicode-2.rs:22:4 + | +LL | fn ΦΙΛΟΣ_Σ() {} + | ^^^^^^^ help: convert the identifier to snake case: `φιλος_σ` + +error: function `Σ_ΦΙΛΟΣ` should have a snake case name + --> $DIR/lint-nonstandard-style-unicode-2.rs:25:4 + | +LL | fn Σ_ΦΙΛΟΣ() {} + | ^^^^^^^ help: convert the identifier to snake case: `σ_φιλος` + +error: aborting due to 6 previous errors; 2 warnings emitted + diff --git a/tests/ui/lint/lint-nonstandard-style-unicode-3.rs b/tests/ui/lint/lint-nonstandard-style-unicode-3.rs index 9175be7a0f49d..cb835e914704b 100644 --- a/tests/ui/lint/lint-nonstandard-style-unicode-3.rs +++ b/tests/ui/lint/lint-nonstandard-style-unicode-3.rs @@ -21,4 +21,11 @@ static τεχ: f32 = 3.14159265; static __密__封__线__内__禁__止__答__题__: bool = true; +static ძალა_ერთობაშია: () = (); +//~^ ERROR static variable `ძალა_ერთობაშია` should have an upper case name + +static Nj: () = (); +//~^ ERROR static variable `Nj` should have an upper case name +//~| WARN identifier contains a non normalized (NFKC) character + fn main() {} diff --git a/tests/ui/lint/lint-nonstandard-style-unicode-3.stderr b/tests/ui/lint/lint-nonstandard-style-unicode-3.stderr index 3d4337bbc6f92..223620ab22942 100644 --- a/tests/ui/lint/lint-nonstandard-style-unicode-3.stderr +++ b/tests/ui/lint/lint-nonstandard-style-unicode-3.stderr @@ -1,3 +1,12 @@ +warning: identifier contains a non normalized (NFKC) character: 'Nj' + --> $DIR/lint-nonstandard-style-unicode-3.rs:27:8 + | +LL | static Nj: () = (); + | ^ + | + = note: this character is included in the Not_NFKC Unicode general security profile + = note: `#[warn(uncommon_codepoints)]` on by default + error: static variable `τεχ` should have an upper case name --> $DIR/lint-nonstandard-style-unicode-3.rs:17:8 | @@ -10,5 +19,17 @@ note: the lint level is defined here LL | #![forbid(non_upper_case_globals)] | ^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 1 previous error +error: static variable `ძალა_ერთობაშია` should have an upper case name + --> $DIR/lint-nonstandard-style-unicode-3.rs:24:8 + | +LL | static ძალა_ერთობაშია: () = (); + | ^^^^^^^^^^^^^^ help: convert the identifier to upper case: `ᲫᲐᲚᲐ_ᲔᲠᲗᲝᲑᲐᲨᲘᲐ` + +error: static variable `Nj` should have an upper case name + --> $DIR/lint-nonstandard-style-unicode-3.rs:27:8 + | +LL | static Nj: () = (); + | ^ help: convert the identifier to upper case: `NJ` + +error: aborting due to 3 previous errors; 1 warning emitted diff --git a/tests/ui/lint/special-upper-lower-cases.rs b/tests/ui/lint/special-upper-lower-cases.rs index d77ffbcbfa3d1..6384909911a35 100644 --- a/tests/ui/lint/special-upper-lower-cases.rs +++ b/tests/ui/lint/special-upper-lower-cases.rs @@ -1,23 +1,23 @@ // (#77273) These characters are in the general categories of -// "Uppercase/Lowercase Letter". -// The diagnostics don't provide meaningful suggestions for them -// as we cannot convert them properly. +// "Uppercase/Lowercase Letter", +// but casing operations map them to themselves. +// Therefore, we do not warn about casing +// (but do warn about uncommon codepoints). //@ check-pass -#![allow(uncommon_codepoints, unused)] +#![allow(unused)] struct 𝕟𝕠𝕥𝕒𝕔𝕒𝕞𝕖𝕝; -//~^ WARN: type `𝕟𝕠𝕥𝕒𝕔𝕒𝕞𝕖𝕝` should have an upper camel case name +//~^ WARN identifier contains 9 non normalized (NFKC) characters -// FIXME: How we should handle this? struct 𝕟𝕠𝕥_𝕒_𝕔𝕒𝕞𝕖𝕝; -//~^ WARN: type `𝕟𝕠𝕥_𝕒_𝕔𝕒𝕞𝕖𝕝` should have an upper camel case name +//~^ WARN identifier contains 9 non normalized (NFKC) characters static 𝗻𝗼𝗻𝘂𝗽𝗽𝗲𝗿𝗰𝗮𝘀𝗲: i32 = 1; -//~^ WARN: static variable `𝗻𝗼𝗻𝘂𝗽𝗽𝗲𝗿𝗰𝗮𝘀𝗲` should have an upper case name +//~^ WARN identifier contains 12 non normalized (NFKC) characters fn main() { let 𝓢𝓝𝓐𝓐𝓐𝓐𝓚𝓔𝓢 = 1; - //~^ WARN: variable `𝓢𝓝𝓐𝓐𝓐𝓐𝓚𝓔𝓢` should have a snake case name + //~^ WARN identifier contains 9 non normalized (NFKC) characters } diff --git a/tests/ui/lint/special-upper-lower-cases.stderr b/tests/ui/lint/special-upper-lower-cases.stderr index 0f5cf336aec2d..18e366f176fb3 100644 --- a/tests/ui/lint/special-upper-lower-cases.stderr +++ b/tests/ui/lint/special-upper-lower-cases.stderr @@ -1,32 +1,35 @@ -warning: type `𝕟𝕠𝕥𝕒𝕔𝕒𝕞𝕖𝕝` should have an upper camel case name - --> $DIR/special-upper-lower-cases.rs:10:8 +warning: identifier contains 9 non normalized (NFKC) characters: '𝕟', '𝕠', '𝕥', '𝕒', '𝕔', '𝕒', '𝕞', '𝕖', and '𝕝' + --> $DIR/special-upper-lower-cases.rs:11:8 | LL | struct 𝕟𝕠𝕥𝕒𝕔𝕒𝕞𝕖𝕝; - | ^^^^^^^^^ should have an UpperCamelCase name + | ^^^^^^^^^ | - = note: `#[warn(non_camel_case_types)]` (part of `#[warn(nonstandard_style)]`) on by default + = note: these characters are included in the Not_NFKC Unicode general security profile + = note: `#[warn(uncommon_codepoints)]` on by default -warning: type `𝕟𝕠𝕥_𝕒_𝕔𝕒𝕞𝕖𝕝` should have an upper camel case name +warning: identifier contains 9 non normalized (NFKC) characters: '𝕟', '𝕠', '𝕥', '𝕒', '𝕔', '𝕒', '𝕞', '𝕖', and '𝕝' --> $DIR/special-upper-lower-cases.rs:14:8 | LL | struct 𝕟𝕠𝕥_𝕒_𝕔𝕒𝕞𝕖𝕝; - | ^^^^^^^^^^^ should have an UpperCamelCase name + | ^^^^^^^^^^^ + | + = note: these characters are included in the Not_NFKC Unicode general security profile -warning: static variable `𝗻𝗼𝗻𝘂𝗽𝗽𝗲𝗿𝗰𝗮𝘀𝗲` should have an upper case name +warning: identifier contains 12 non normalized (NFKC) characters: '𝗻', '𝗼', '𝗻', '𝘂', '𝗽', '𝗽', '𝗲', '𝗿', '𝗰', '𝗮', '𝘀', and '𝗲' --> $DIR/special-upper-lower-cases.rs:17:8 | LL | static 𝗻𝗼𝗻𝘂𝗽𝗽𝗲𝗿𝗰𝗮𝘀𝗲: i32 = 1; - | ^^^^^^^^^^^^ should have an UPPER_CASE name + | ^^^^^^^^^^^^ | - = note: `#[warn(non_upper_case_globals)]` (part of `#[warn(nonstandard_style)]`) on by default + = note: these characters are included in the Not_NFKC Unicode general security profile -warning: variable `𝓢𝓝𝓐𝓐𝓐𝓐𝓚𝓔𝓢` should have a snake case name +warning: identifier contains 9 non normalized (NFKC) characters: '𝓢', '𝓝', '𝓐', '𝓐', '𝓐', '𝓐', '𝓚', '𝓔', and '𝓢' --> $DIR/special-upper-lower-cases.rs:21:9 | LL | let 𝓢𝓝𝓐𝓐𝓐𝓐𝓚𝓔𝓢 = 1; - | ^^^^^^^^^ should have a snake_case name + | ^^^^^^^^^ | - = note: `#[warn(non_snake_case)]` (part of `#[warn(nonstandard_style)]`) on by default + = note: these characters are included in the Not_NFKC Unicode general security profile warning: 4 warnings emitted From 78435a9ff8adde46e8ab6651272edea3775516f6 Mon Sep 17 00:00:00 2001 From: aerooneqq Date: Thu, 23 Apr 2026 09:37:48 +0300 Subject: [PATCH 12/20] Remove #![allow(incomplete_features)] from delegation tests --- .../auxiliary/recursive-delegation-aux.rs | 1 - tests/ui/delegation/bad-resolve.rs | 1 - tests/ui/delegation/bad-resolve.stderr | 24 +-- tests/ui/delegation/body-identity-glob.rs | 1 - tests/ui/delegation/body-identity-list.rs | 1 - ..._body_owner_parent_found_in_diagnostics.rs | 1 - ...y_owner_parent_found_in_diagnostics.stderr | 26 +-- .../duplicate-definition-inside-trait-impl.rs | 1 - ...licate-definition-inside-trait-impl.stderr | 8 +- tests/ui/delegation/empty-glob.rs | 1 - tests/ui/delegation/empty-glob.stderr | 2 +- tests/ui/delegation/empty-list.rs | 1 - tests/ui/delegation/empty-list.stderr | 2 +- .../explicit-paths-in-traits-pass.rs | 1 - tests/ui/delegation/explicit-paths-pass.rs | 1 - .../explicit-paths-signature-pass.rs | 1 - tests/ui/delegation/explicit-paths.rs | 1 - tests/ui/delegation/explicit-paths.stderr | 34 ++-- tests/ui/delegation/fn-header-variadic.rs | 1 - tests/ui/delegation/fn-header-variadic.stderr | 4 +- tests/ui/delegation/fn-header.rs | 1 - tests/ui/delegation/foreign-fn.rs | 1 - tests/ui/delegation/foreign-fn.stderr | 4 +- .../generics/const-type-ice-153433.rs | 1 - .../generics/const-type-ice-153433.stderr | 2 +- .../generics/const-type-ice-153499.rs | 1 - .../generics/const-type-ice-153499.stderr | 6 +- .../generics/const-type-ice-154334.rs | 1 + .../def-path-hash-collision-ice-153410.rs | 5 +- .../def-path-hash-collision-ice-153410.stderr | 6 +- .../generics/free-fn-to-free-fn-pass.rs | 1 - .../delegation/generics/free-fn-to-free-fn.rs | 1 - .../generics/free-fn-to-free-fn.stderr | 8 +- .../generics/free-fn-to-trait-infer.rs | 1 - .../generics/free-fn-to-trait-infer.stderr | 8 +- .../generics/free-fn-to-trait-method-pass.rs | 1 - .../generics/free-fn-to-trait-method.rs | 1 - .../generics/free-fn-to-trait-method.stderr | 8 +- .../generics/free-to-trait-self-reuse.rs | 1 - .../generics/free-to-trait-self-reuse.stderr | 32 ++-- .../generics/free-to-trait-static-reuse.rs | 1 - .../free-to-trait-static-reuse.stderr | 36 ++-- .../generics/generic-params-defaults.rs | 1 - .../generics/generic-params-defaults.stderr | 4 +- .../generics/generic-params-same-names.rs | 1 - .../generics/generic-params-same-names.stderr | 14 +- .../delegation/generics/generics-aux-pass.rs | 1 - .../generics/generics-gen-args-errors.rs | 1 - .../generics/generics-gen-args-errors.stderr | 176 +++++++++--------- .../generics/impl-to-free-fn-pass.rs | 1 - .../generics/impl-to-trait-method.rs | 1 - .../generics/impl-to-trait-method.stderr | 16 +- .../impl-trait-to-trait-method-pass.rs | 1 - .../inherent-impl-to-trait-method-pass.rs | 1 - .../generics/mapping/free-to-free-pass.rs | 1 - .../generics/mapping/free-to-trait-pass.rs | 1 - .../mapping/impl-trait-to-free-pass.rs | 1 - .../mapping/impl-trait-to-trait-pass.rs | 1 - .../mapping/inherent-impl-to-free-pass.rs | 1 - .../mapping/inherent-impl-to-trait-pass.rs | 1 - .../generics/mapping/trait-to-free-pass.rs | 1 - .../generics/mapping/trait-to-trait-pass.rs | 1 - .../stability-implications-non-local-defid.rs | 1 - .../generics/synth-params-ice-143498.rs | 1 - .../generics/synth-params-ice-143498.stderr | 6 +- .../generics/trait-impl-wrong-args-count.rs | 1 - .../trait-impl-wrong-args-count.stderr | 42 ++--- .../generics/trait-method-to-other-pass.rs | 1 - .../generics/unresolved-segment-ice-153389.rs | 1 - .../unresolved-segment-ice-153389.stderr | 2 +- tests/ui/delegation/glob-bad-path.rs | 1 - tests/ui/delegation/glob-bad-path.stderr | 4 +- tests/ui/delegation/glob-glob-conflict.rs | 1 - tests/ui/delegation/glob-glob-conflict.stderr | 16 +- tests/ui/delegation/glob-glob.rs | 1 - tests/ui/delegation/glob-non-fn.rs | 1 - tests/ui/delegation/glob-non-fn.stderr | 12 +- tests/ui/delegation/glob-non-impl.rs | 1 - tests/ui/delegation/glob-non-impl.stderr | 8 +- tests/ui/delegation/glob-override.rs | 1 - tests/ui/delegation/glob-traitless-qpath.rs | 1 - .../ui/delegation/glob-traitless-qpath.stderr | 4 +- tests/ui/delegation/glob.rs | 1 - ...ems-before-lowering-ices.ice_155125.stderr | 4 +- ...ems-before-lowering-ices.ice_155127.stderr | 2 +- ...ems-before-lowering-ices.ice_155128.stderr | 4 +- ...ems-before-lowering-ices.ice_155164.stderr | 2 +- ...ems-before-lowering-ices.ice_155202.stderr | 4 +- .../hir-crate-items-before-lowering-ices.rs | 1 - tests/ui/delegation/ice-isssue-128190.rs | 1 - tests/ui/delegation/ice-isssue-128190.stderr | 2 +- tests/ui/delegation/ice-issue-122550.rs | 1 - tests/ui/delegation/ice-issue-122550.stderr | 12 +- tests/ui/delegation/ice-issue-124342.rs | 1 - tests/ui/delegation/ice-issue-124342.stderr | 4 +- tests/ui/delegation/ice-issue-124347.rs | 1 - tests/ui/delegation/ice-issue-124347.stderr | 10 +- tests/ui/delegation/ice-issue-138362.rs | 1 - tests/ui/delegation/ice-issue-138362.stderr | 4 +- tests/ui/delegation/ice-issue-150673.rs | 1 - tests/ui/delegation/ice-issue-150673.stderr | 4 +- .../ice-non-fn-target-in-trait-impl.rs | 1 - .../ice-non-fn-target-in-trait-impl.stderr | 4 +- tests/ui/delegation/impl-reuse-bad-path.rs | 1 - .../ui/delegation/impl-reuse-bad-path.stderr | 16 +- tests/ui/delegation/impl-reuse-empty-glob.rs | 1 - .../delegation/impl-reuse-empty-glob.stderr | 2 +- .../delegation/impl-reuse-illegal-places.rs | 1 - .../impl-reuse-illegal-places.stderr | 24 +-- .../delegation/impl-reuse-negative-traits.rs | 1 - .../impl-reuse-negative-traits.stderr | 2 +- .../delegation/impl-reuse-non-reuse-items.rs | 1 - .../impl-reuse-non-reuse-items.stderr | 12 +- .../impl-reuse-non-trait-impl-cfg-false.rs | 1 - ...impl-reuse-non-trait-impl-cfg-false.stderr | 2 +- .../delegation/impl-reuse-non-trait-impl.rs | 1 - .../impl-reuse-non-trait-impl.stderr | 2 +- tests/ui/delegation/impl-reuse-pass.rs | 1 - .../ui/delegation/impl-reuse-self-hygiene.rs | 1 - .../delegation/impl-reuse-self-hygiene.stderr | 12 +- tests/ui/delegation/impl-trait.rs | 1 - tests/ui/delegation/inner-attr.rs | 1 - tests/ui/delegation/inner-attr.stderr | 6 +- tests/ui/delegation/list.rs | 1 - tests/ui/delegation/macro-inside-glob.rs | 1 - tests/ui/delegation/macro-inside-list.rs | 1 - tests/ui/delegation/method-call-choice.rs | 1 - tests/ui/delegation/method-call-choice.stderr | 4 +- tests/ui/delegation/method-call-priority.rs | 1 - tests/ui/delegation/parse.rs | 1 - .../delegation/recursive-delegation-errors.rs | 2 - .../recursive-delegation-errors.stderr | 44 ++--- .../recursive-delegation-ice-150152.rs | 1 - .../recursive-delegation-ice-150152.stderr | 20 +- .../delegation/recursive-delegation-pass.rs | 1 - tests/ui/delegation/rename.rs | 1 - .../reuse-trait-path-with-empty-generics.rs | 1 - ...euse-trait-path-with-empty-generics.stderr | 2 +- tests/ui/delegation/self-coercion.rs | 1 - tests/ui/delegation/self-hygiene.rs | 1 - tests/ui/delegation/self-hygiene.stderr | 4 +- tests/ui/delegation/target-expr-pass.rs | 1 - tests/ui/delegation/target-expr-pass.stderr | 6 +- tests/ui/delegation/target-expr.rs | 1 - tests/ui/delegation/target-expr.stderr | 12 +- .../delegation/unlowered-path-ice-154820.rs | 1 - .../unlowered-path-ice-154820.stderr | 8 +- .../unreachable-label-ice-148889.rs | 1 - .../unreachable-label-ice-148889.stderr | 2 +- .../unresolved-delegation-ice-151356.rs | 1 - .../unresolved-delegation-ice-151356.stderr | 2 +- .../ui/delegation/unsupported.current.stderr | 24 +-- tests/ui/delegation/unsupported.next.stderr | 16 +- tests/ui/delegation/unsupported.rs | 1 - .../ui/delegation/unused-import-ice-144594.rs | 1 - .../unused-import-ice-144594.stderr | 4 +- .../zero-args-delegations-ice-154332.rs | 1 - .../zero-args-delegations-ice-154332.stderr | 8 +- 158 files changed, 405 insertions(+), 499 deletions(-) diff --git a/tests/ui/delegation/auxiliary/recursive-delegation-aux.rs b/tests/ui/delegation/auxiliary/recursive-delegation-aux.rs index 5df644974f3ef..56d99cec880ad 100644 --- a/tests/ui/delegation/auxiliary/recursive-delegation-aux.rs +++ b/tests/ui/delegation/auxiliary/recursive-delegation-aux.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] fn foo() {} diff --git a/tests/ui/delegation/bad-resolve.rs b/tests/ui/delegation/bad-resolve.rs index 79acaec021a66..5744bd1f994c8 100644 --- a/tests/ui/delegation/bad-resolve.rs +++ b/tests/ui/delegation/bad-resolve.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] trait Trait { const C: u32 = 0; diff --git a/tests/ui/delegation/bad-resolve.stderr b/tests/ui/delegation/bad-resolve.stderr index 6fde0bb13877a..f79eaa5bfc28f 100644 --- a/tests/ui/delegation/bad-resolve.stderr +++ b/tests/ui/delegation/bad-resolve.stderr @@ -1,5 +1,5 @@ error[E0324]: item `C` is an associated method, which doesn't match its trait `Trait` - --> $DIR/bad-resolve.rs:24:5 + --> $DIR/bad-resolve.rs:23:5 | LL | const C: u32 = 0; | ----------------- item in trait @@ -8,7 +8,7 @@ LL | reuse ::C; | ^^^^^^^^^^^^^^^^^^^^^^ does not match trait error[E0324]: item `Type` is an associated method, which doesn't match its trait `Trait` - --> $DIR/bad-resolve.rs:27:5 + --> $DIR/bad-resolve.rs:26:5 | LL | type Type; | ---------- item in trait @@ -17,7 +17,7 @@ LL | reuse ::Type; | ^^^^^^^^^^^^^^^^^^^^^^^^^ does not match trait error[E0407]: method `baz` is not a member of trait `Trait` - --> $DIR/bad-resolve.rs:30:5 + --> $DIR/bad-resolve.rs:29:5 | LL | reuse ::baz; | ^^^^^^^^^^^^^^^^^^^^---^ @@ -26,7 +26,7 @@ LL | reuse ::baz; | not a member of trait `Trait` error[E0407]: method `foo2` is not a member of trait `Trait` - --> $DIR/bad-resolve.rs:37:5 + --> $DIR/bad-resolve.rs:36:5 | LL | reuse Trait::foo2 { self.0 } | ^^^^^^^^^^^^^----^^^^^^^^^^^ @@ -35,19 +35,19 @@ LL | reuse Trait::foo2 { self.0 } | not a member of trait `Trait` error[E0423]: expected function, found associated constant `Trait::C` - --> $DIR/bad-resolve.rs:24:11 + --> $DIR/bad-resolve.rs:23:11 | LL | reuse ::C; | ^^^^^^^^^^^^^^^ not a function error[E0575]: expected method or associated constant, found associated type `Trait::Type` - --> $DIR/bad-resolve.rs:27:11 + --> $DIR/bad-resolve.rs:26:11 | LL | reuse ::Type; | ^^^^^^^^^^^^^^^^^^ not a method or associated constant error[E0576]: cannot find method or associated constant `baz` in trait `Trait` - --> $DIR/bad-resolve.rs:30:25 + --> $DIR/bad-resolve.rs:29:25 | LL | fn bar() {} | -------- similarly named associated function `bar` defined here @@ -62,13 +62,13 @@ LL + reuse ::bar; | error[E0425]: cannot find function `foo` in this scope - --> $DIR/bad-resolve.rs:35:11 + --> $DIR/bad-resolve.rs:34:11 | LL | reuse foo { &self.0 } | ^^^ not found in this scope error[E0425]: cannot find function `foo2` in trait `Trait` - --> $DIR/bad-resolve.rs:37:18 + --> $DIR/bad-resolve.rs:36:18 | LL | fn foo(&self, x: i32) -> i32 { x } | ---------------------------- similarly named associated function `foo` defined here @@ -83,7 +83,7 @@ LL + reuse Trait::foo { self.0 } | error[E0046]: not all trait items implemented, missing: `Type` - --> $DIR/bad-resolve.rs:22:1 + --> $DIR/bad-resolve.rs:21:1 | LL | type Type; | --------- `Type` from trait @@ -92,7 +92,7 @@ LL | impl Trait for S { | ^^^^^^^^^^^^^^^^ missing `Type` in implementation error[E0433]: cannot find module or crate `unresolved_prefix` in this scope - --> $DIR/bad-resolve.rs:43:7 + --> $DIR/bad-resolve.rs:42:7 | LL | reuse unresolved_prefix::{a, b, c}; | ^^^^^^^^^^^^^^^^^ use of unresolved module or unlinked crate `unresolved_prefix` @@ -100,7 +100,7 @@ LL | reuse unresolved_prefix::{a, b, c}; = help: you might be missing a crate named `unresolved_prefix` error[E0433]: `crate` in paths can only be used in start position - --> $DIR/bad-resolve.rs:44:29 + --> $DIR/bad-resolve.rs:43:29 | LL | reuse prefix::{self, super, crate}; | ^^^^^ can only be used in path start position diff --git a/tests/ui/delegation/body-identity-glob.rs b/tests/ui/delegation/body-identity-glob.rs index 58b644f46d617..14fbede473a4e 100644 --- a/tests/ui/delegation/body-identity-glob.rs +++ b/tests/ui/delegation/body-identity-glob.rs @@ -1,7 +1,6 @@ //@ check-pass #![feature(fn_delegation)] -#![allow(incomplete_features)] trait Trait { fn foo(&self) {} diff --git a/tests/ui/delegation/body-identity-list.rs b/tests/ui/delegation/body-identity-list.rs index 1f08ab4e1a4c2..3ca725ccc955d 100644 --- a/tests/ui/delegation/body-identity-list.rs +++ b/tests/ui/delegation/body-identity-list.rs @@ -1,7 +1,6 @@ //@ check-pass #![feature(fn_delegation)] -#![allow(incomplete_features)] trait Trait { fn foo(&self) {} diff --git a/tests/ui/delegation/correct_body_owner_parent_found_in_diagnostics.rs b/tests/ui/delegation/correct_body_owner_parent_found_in_diagnostics.rs index 5d801f26de168..68a1a936fcaaa 100644 --- a/tests/ui/delegation/correct_body_owner_parent_found_in_diagnostics.rs +++ b/tests/ui/delegation/correct_body_owner_parent_found_in_diagnostics.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] use std::marker::PhantomData; diff --git a/tests/ui/delegation/correct_body_owner_parent_found_in_diagnostics.stderr b/tests/ui/delegation/correct_body_owner_parent_found_in_diagnostics.stderr index 6cf844f29b06f..ab0c6d66e9c51 100644 --- a/tests/ui/delegation/correct_body_owner_parent_found_in_diagnostics.stderr +++ b/tests/ui/delegation/correct_body_owner_parent_found_in_diagnostics.stderr @@ -1,5 +1,5 @@ error[E0261]: use of undeclared lifetime name `'a` - --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:22:68 + --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:21:68 | LL | reuse ::{foo, bar, meh} { &const { InvariantRef::<'a>::NEW } } | ^^ undeclared lifetime @@ -14,7 +14,7 @@ LL | impl<'a> Trait for Z { | ++++ error[E0261]: use of undeclared lifetime name `'a` - --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:22:68 + --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:21:68 | LL | reuse ::{foo, bar, meh} { &const { InvariantRef::<'a>::NEW } } | ^^ undeclared lifetime @@ -29,7 +29,7 @@ LL | impl<'a> Trait for Z { | ++++ error[E0261]: use of undeclared lifetime name `'a` - --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:22:68 + --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:21:68 | LL | reuse ::{foo, bar, meh} { &const { InvariantRef::<'a>::NEW } } | ^^ undeclared lifetime @@ -44,7 +44,7 @@ LL | impl<'a> Trait for Z { | ++++ error[E0599]: no associated function or constant named `new` found for struct `InvariantRef<'a, T>` in the current scope - --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:9:41 + --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:8:41 | LL | pub struct InvariantRef<'a, T: ?Sized>(&'a T, PhantomData<&'a mut &'a T>); | -------------------------------------- associated function or constant `new` not found for this struct @@ -53,19 +53,19 @@ LL | pub const NEW: Self = InvariantRef::new(&()); | ^^^ associated function or constant not found in `InvariantRef<'_, _>` error[E0277]: the trait bound `u8: Trait` is not satisfied - --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:22:12 + --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:21:12 | LL | reuse ::{foo, bar, meh} { &const { InvariantRef::<'a>::NEW } } | ^^ the trait `Trait` is not implemented for `u8` | help: the trait `Trait` is implemented for `Z` - --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:21:1 + --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:20:1 | LL | impl Trait for Z { | ^^^^^^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:22:53 + --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:21:53 | LL | reuse ::{foo, bar, meh} { &const { InvariantRef::<'a>::NEW } } | ^^^^^^^^^^^^^^^^^^^^^^^ expected `u8`, found `InvariantRef<'_, ()>` @@ -74,20 +74,20 @@ LL | reuse ::{foo, bar, meh} { &const { InvariantRef::<'a>::NEW found struct `InvariantRef<'_, ()>` error[E0277]: the trait bound `u8: Trait` is not satisfied - --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:22:12 + --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:21:12 | LL | reuse ::{foo, bar, meh} { &const { InvariantRef::<'a>::NEW } } | ^^ the trait `Trait` is not implemented for `u8` | help: the trait `Trait` is implemented for `Z` - --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:21:1 + --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:20:1 | LL | impl Trait for Z { | ^^^^^^^^^^^^^^^^ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0308]: mismatched types - --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:22:53 + --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:21:53 | LL | reuse ::{foo, bar, meh} { &const { InvariantRef::<'a>::NEW } } | ^^^^^^^^^^^^^^^^^^^^^^^ expected `u8`, found `InvariantRef<'_, ()>` @@ -97,20 +97,20 @@ LL | reuse ::{foo, bar, meh} { &const { InvariantRef::<'a>::NEW = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: the trait bound `u8: Trait` is not satisfied - --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:22:12 + --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:21:12 | LL | reuse ::{foo, bar, meh} { &const { InvariantRef::<'a>::NEW } } | ^^ the trait `Trait` is not implemented for `u8` | help: the trait `Trait` is implemented for `Z` - --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:21:1 + --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:20:1 | LL | impl Trait for Z { | ^^^^^^^^^^^^^^^^ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0308]: mismatched types - --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:22:53 + --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:21:53 | LL | reuse ::{foo, bar, meh} { &const { InvariantRef::<'a>::NEW } } | ^^^^^^^^^^^^^^^^^^^^^^^ expected `u8`, found `InvariantRef<'_, ()>` diff --git a/tests/ui/delegation/duplicate-definition-inside-trait-impl.rs b/tests/ui/delegation/duplicate-definition-inside-trait-impl.rs index 3c796b91d6fa9..ecd47a7ccaa94 100644 --- a/tests/ui/delegation/duplicate-definition-inside-trait-impl.rs +++ b/tests/ui/delegation/duplicate-definition-inside-trait-impl.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] trait Trait { fn foo(&self) -> u32 { 0 } diff --git a/tests/ui/delegation/duplicate-definition-inside-trait-impl.stderr b/tests/ui/delegation/duplicate-definition-inside-trait-impl.stderr index 83d69d2df6000..9e2dd8ea84ac9 100644 --- a/tests/ui/delegation/duplicate-definition-inside-trait-impl.stderr +++ b/tests/ui/delegation/duplicate-definition-inside-trait-impl.stderr @@ -1,5 +1,5 @@ error[E0201]: duplicate definitions with name `foo`: - --> $DIR/duplicate-definition-inside-trait-impl.rs:19:5 + --> $DIR/duplicate-definition-inside-trait-impl.rs:18:5 | LL | fn foo(&self) -> u32 { 0 } | -------------------------- item in trait @@ -10,13 +10,13 @@ LL | reuse Trait::foo; | ^^^^^^^^^^^^^^^^^ duplicate definition error[E0061]: this function takes 1 argument but 0 arguments were supplied - --> $DIR/duplicate-definition-inside-trait-impl.rs:19:18 + --> $DIR/duplicate-definition-inside-trait-impl.rs:18:18 | LL | reuse Trait::foo; | ^^^ argument #1 of type `&_` is missing | note: method defined here - --> $DIR/duplicate-definition-inside-trait-impl.rs:5:8 + --> $DIR/duplicate-definition-inside-trait-impl.rs:4:8 | LL | fn foo(&self) -> u32 { 0 } | ^^^ ----- @@ -26,7 +26,7 @@ LL | reuse Trait::foo(/* value */); | +++++++++++++ error[E0308]: mismatched types - --> $DIR/duplicate-definition-inside-trait-impl.rs:19:18 + --> $DIR/duplicate-definition-inside-trait-impl.rs:18:18 | LL | reuse Trait::foo; | ^^^- help: consider using a semicolon here: `;` diff --git a/tests/ui/delegation/empty-glob.rs b/tests/ui/delegation/empty-glob.rs index d98579d897257..70c8c6e10d14b 100644 --- a/tests/ui/delegation/empty-glob.rs +++ b/tests/ui/delegation/empty-glob.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] trait Trait {} diff --git a/tests/ui/delegation/empty-glob.stderr b/tests/ui/delegation/empty-glob.stderr index f4d282f6a0f6c..92ba982e22a81 100644 --- a/tests/ui/delegation/empty-glob.stderr +++ b/tests/ui/delegation/empty-glob.stderr @@ -1,5 +1,5 @@ error: empty glob delegation is not supported - --> $DIR/empty-glob.rs:8:5 + --> $DIR/empty-glob.rs:7:5 | LL | reuse Trait::*; | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/delegation/empty-list.rs b/tests/ui/delegation/empty-list.rs index e0697f42283ec..3a1aae6d31e36 100644 --- a/tests/ui/delegation/empty-list.rs +++ b/tests/ui/delegation/empty-list.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] mod m {} diff --git a/tests/ui/delegation/empty-list.stderr b/tests/ui/delegation/empty-list.stderr index 50d3c0eee223c..2c0f0c6ae492e 100644 --- a/tests/ui/delegation/empty-list.stderr +++ b/tests/ui/delegation/empty-list.stderr @@ -1,5 +1,5 @@ error: empty list delegation is not supported - --> $DIR/empty-list.rs:6:1 + --> $DIR/empty-list.rs:5:1 | LL | reuse m::{}; | ^^^^^^^^^^^^ diff --git a/tests/ui/delegation/explicit-paths-in-traits-pass.rs b/tests/ui/delegation/explicit-paths-in-traits-pass.rs index 7d281ad150a03..3837642fcbb32 100644 --- a/tests/ui/delegation/explicit-paths-in-traits-pass.rs +++ b/tests/ui/delegation/explicit-paths-in-traits-pass.rs @@ -1,7 +1,6 @@ //@ run-pass #![feature(fn_delegation)] -#![allow(incomplete_features)] trait ToReuse { fn foo(&self, x: i32) -> i32 { x } diff --git a/tests/ui/delegation/explicit-paths-pass.rs b/tests/ui/delegation/explicit-paths-pass.rs index 7efbb37951856..fd0b9e83689d8 100644 --- a/tests/ui/delegation/explicit-paths-pass.rs +++ b/tests/ui/delegation/explicit-paths-pass.rs @@ -1,7 +1,6 @@ //@ run-pass #![feature(fn_delegation)] -#![allow(incomplete_features)] trait Trait { fn bar(&self, x: i32) -> i32 { x } diff --git a/tests/ui/delegation/explicit-paths-signature-pass.rs b/tests/ui/delegation/explicit-paths-signature-pass.rs index 11bc8a70db0e3..59d14d3becc74 100644 --- a/tests/ui/delegation/explicit-paths-signature-pass.rs +++ b/tests/ui/delegation/explicit-paths-signature-pass.rs @@ -1,7 +1,6 @@ //@ run-pass #![feature(fn_delegation)] -#![allow(incomplete_features)] mod to_reuse { use crate::S; diff --git a/tests/ui/delegation/explicit-paths.rs b/tests/ui/delegation/explicit-paths.rs index 018025041c0bc..2592d3d2698fc 100644 --- a/tests/ui/delegation/explicit-paths.rs +++ b/tests/ui/delegation/explicit-paths.rs @@ -1,6 +1,5 @@ //@ edition:2015 #![feature(fn_delegation)] -#![allow(incomplete_features)] trait Trait { fn foo1(&self, x: i32) -> i32 { x } diff --git a/tests/ui/delegation/explicit-paths.stderr b/tests/ui/delegation/explicit-paths.stderr index 460cfab85f215..30239f3648a53 100644 --- a/tests/ui/delegation/explicit-paths.stderr +++ b/tests/ui/delegation/explicit-paths.stderr @@ -1,5 +1,5 @@ error[E0407]: method `foo3` is not a member of trait `Trait` - --> $DIR/explicit-paths.rs:50:9 + --> $DIR/explicit-paths.rs:49:9 | LL | reuse to_reuse::foo3; | ^^^^^^^^^^^^^^^^----^ @@ -8,7 +8,7 @@ LL | reuse to_reuse::foo3; | not a member of trait `Trait` error[E0407]: method `foo4` is not a member of trait `Trait` - --> $DIR/explicit-paths.rs:52:9 + --> $DIR/explicit-paths.rs:51:9 | LL | reuse F::foo4 { &self.0 } | ^^^^^^^^^----^^^^^^^^^^^^ @@ -17,49 +17,49 @@ LL | reuse F::foo4 { &self.0 } | not a member of trait `Trait` error[E0425]: cannot find function `foo4` in `S` - --> $DIR/explicit-paths.rs:28:14 + --> $DIR/explicit-paths.rs:27:14 | LL | reuse S::foo4; | ^^^^ not found in `S` error[E0425]: cannot find function `foo4` in `F` - --> $DIR/explicit-paths.rs:39:18 + --> $DIR/explicit-paths.rs:38:18 | LL | reuse F::foo4 { &self.0 } | ^^^^ not found in `F` | note: function `fn_to_other::foo4` exists but is inaccessible - --> $DIR/explicit-paths.rs:28:5 + --> $DIR/explicit-paths.rs:27:5 | LL | reuse S::foo4; | ^^^^^^^^^^^^^^ not accessible error[E0425]: cannot find function `foo4` in `F` - --> $DIR/explicit-paths.rs:52:18 + --> $DIR/explicit-paths.rs:51:18 | LL | reuse F::foo4 { &self.0 } | ^^^^ not found in `F` | note: function `fn_to_other::foo4` exists but is inaccessible - --> $DIR/explicit-paths.rs:28:5 + --> $DIR/explicit-paths.rs:27:5 | LL | reuse S::foo4; | ^^^^^^^^^^^^^^ not accessible error[E0425]: cannot find function `foo4` in `F` - --> $DIR/explicit-paths.rs:66:18 + --> $DIR/explicit-paths.rs:65:18 | LL | reuse F::foo4 { &F } | ^^^^ not found in `F` | note: function `fn_to_other::foo4` exists but is inaccessible - --> $DIR/explicit-paths.rs:28:5 + --> $DIR/explicit-paths.rs:27:5 | LL | reuse S::foo4; | ^^^^^^^^^^^^^^ not accessible error[E0119]: conflicting implementations of trait `Trait` for type `S` - --> $DIR/explicit-paths.rs:75:5 + --> $DIR/explicit-paths.rs:74:5 | LL | impl Trait for S { | ---------------- first implementation here @@ -68,7 +68,7 @@ LL | impl Trait for S { | ^^^^^^^^^^^^^^^^ conflicting implementation for `S` error[E0308]: mismatched types - --> $DIR/explicit-paths.rs:62:36 + --> $DIR/explicit-paths.rs:61:36 | LL | trait Trait2 : Trait { | -------------------- found this type parameter @@ -80,24 +80,24 @@ LL | reuse ::foo1 { self } = note: expected reference `&F` found reference `&Self` note: method defined here - --> $DIR/explicit-paths.rs:6:8 + --> $DIR/explicit-paths.rs:5:8 | LL | fn foo1(&self, x: i32) -> i32 { x } | ^^^^ ----- error[E0277]: the trait bound `S2: Trait` is not satisfied - --> $DIR/explicit-paths.rs:77:16 + --> $DIR/explicit-paths.rs:76:16 | LL | reuse ::foo1; | ^^ unsatisfied trait bound | help: the trait `Trait` is not implemented for `S2` - --> $DIR/explicit-paths.rs:74:5 + --> $DIR/explicit-paths.rs:73:5 | LL | struct S2; | ^^^^^^^^^ help: the following other types implement trait `Trait` - --> $DIR/explicit-paths.rs:11:1 + --> $DIR/explicit-paths.rs:10:1 | LL | impl Trait for F {} | ^^^^^^^^^^^^^^^^ `F` @@ -109,7 +109,7 @@ LL | impl Trait for S { | ^^^^^^^^^^^^^^^^ `S` error[E0308]: mismatched types - --> $DIR/explicit-paths.rs:77:30 + --> $DIR/explicit-paths.rs:76:30 | LL | reuse ::foo1; | ^^^^ @@ -120,7 +120,7 @@ LL | reuse ::foo1; = note: expected reference `&S2` found reference `&S` note: method defined here - --> $DIR/explicit-paths.rs:6:8 + --> $DIR/explicit-paths.rs:5:8 | LL | fn foo1(&self, x: i32) -> i32 { x } | ^^^^ ----- diff --git a/tests/ui/delegation/fn-header-variadic.rs b/tests/ui/delegation/fn-header-variadic.rs index 346c49f08e5d3..b5056f48a9be4 100644 --- a/tests/ui/delegation/fn-header-variadic.rs +++ b/tests/ui/delegation/fn-header-variadic.rs @@ -3,7 +3,6 @@ #![feature(c_variadic)] #![feature(fn_delegation)] -#![allow(incomplete_features)] mod to_reuse { pub unsafe extern "C" fn variadic_fn(n: usize, mut args: ...) {} diff --git a/tests/ui/delegation/fn-header-variadic.stderr b/tests/ui/delegation/fn-header-variadic.stderr index c2d7672939fcc..688a965fb4d5c 100644 --- a/tests/ui/delegation/fn-header-variadic.stderr +++ b/tests/ui/delegation/fn-header-variadic.stderr @@ -1,5 +1,5 @@ error: delegation to C-variadic functions is not allowed - --> $DIR/fn-header-variadic.rs:12:17 + --> $DIR/fn-header-variadic.rs:11:17 | LL | pub unsafe extern "C" fn variadic_fn(n: usize, mut args: ...) {} | ------------------------------------------------------------- callee defined here @@ -8,7 +8,7 @@ LL | reuse to_reuse::variadic_fn; | ^^^^^^^^^^^ error: delegation to C-variadic functions is not allowed - --> $DIR/fn-header-variadic.rs:14:22 + --> $DIR/fn-header-variadic.rs:13:22 | LL | reuse fn_header_aux::variadic_fn_extern; | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/delegation/fn-header.rs b/tests/ui/delegation/fn-header.rs index 608aef8d9683b..d3fb6fb88ed59 100644 --- a/tests/ui/delegation/fn-header.rs +++ b/tests/ui/delegation/fn-header.rs @@ -5,7 +5,6 @@ #![feature(c_variadic)] #![feature(fn_delegation)] -#![allow(incomplete_features)] #![deny(unused_unsafe)] mod to_reuse { diff --git a/tests/ui/delegation/foreign-fn.rs b/tests/ui/delegation/foreign-fn.rs index 1d221da29ceb2..6046dab6dfd45 100644 --- a/tests/ui/delegation/foreign-fn.rs +++ b/tests/ui/delegation/foreign-fn.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] #![deny(unsafe_op_in_unsafe_fn)] #![deny(unused_unsafe)] diff --git a/tests/ui/delegation/foreign-fn.stderr b/tests/ui/delegation/foreign-fn.stderr index f7d3dba4bb1c0..2b7f4bf87c5c8 100644 --- a/tests/ui/delegation/foreign-fn.stderr +++ b/tests/ui/delegation/foreign-fn.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/foreign-fn.rs:17:30 + --> $DIR/foreign-fn.rs:16:30 | LL | let _: extern "C" fn() = default_unsafe_foo; | --------------- ^^^^^^^^^^^^^^^^^^ expected safe fn, found unsafe fn @@ -11,7 +11,7 @@ LL | let _: extern "C" fn() = default_unsafe_foo; = note: unsafe functions cannot be coerced into safe function pointers error[E0308]: mismatched types - --> $DIR/foreign-fn.rs:19:30 + --> $DIR/foreign-fn.rs:18:30 | LL | let _: extern "C" fn() = unsafe_foo; | --------------- ^^^^^^^^^^ expected safe fn, found unsafe fn diff --git a/tests/ui/delegation/generics/const-type-ice-153433.rs b/tests/ui/delegation/generics/const-type-ice-153433.rs index edd6d0542a999..d0fa87f4cfb6d 100644 --- a/tests/ui/delegation/generics/const-type-ice-153433.rs +++ b/tests/ui/delegation/generics/const-type-ice-153433.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] fn main() { fn foo Foo>() {} diff --git a/tests/ui/delegation/generics/const-type-ice-153433.stderr b/tests/ui/delegation/generics/const-type-ice-153433.stderr index 3b537e2f8988e..b28bf0242762f 100644 --- a/tests/ui/delegation/generics/const-type-ice-153433.stderr +++ b/tests/ui/delegation/generics/const-type-ice-153433.stderr @@ -1,5 +1,5 @@ error[E0405]: cannot find trait `Foo` in this scope - --> $DIR/const-type-ice-153433.rs:5:33 + --> $DIR/const-type-ice-153433.rs:4:33 | LL | fn foo Foo>() {} | ^^^ not found in this scope diff --git a/tests/ui/delegation/generics/const-type-ice-153499.rs b/tests/ui/delegation/generics/const-type-ice-153499.rs index debda0d04a18c..2c56d55667357 100644 --- a/tests/ui/delegation/generics/const-type-ice-153499.rs +++ b/tests/ui/delegation/generics/const-type-ice-153499.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] trait Trait<'a, T, const F: fn(&CStr) -> usize> { //~^ ERROR: cannot find type `CStr` in this scope diff --git a/tests/ui/delegation/generics/const-type-ice-153499.stderr b/tests/ui/delegation/generics/const-type-ice-153499.stderr index 02fd7197dcdc3..4f60b168c11da 100644 --- a/tests/ui/delegation/generics/const-type-ice-153499.stderr +++ b/tests/ui/delegation/generics/const-type-ice-153499.stderr @@ -1,5 +1,5 @@ error[E0425]: cannot find type `CStr` in this scope - --> $DIR/const-type-ice-153499.rs:4:33 + --> $DIR/const-type-ice-153499.rs:3:33 | LL | trait Trait<'a, T, const F: fn(&CStr) -> usize> { | ^^^^ not found in this scope @@ -10,7 +10,7 @@ LL + use std::ffi::CStr; | error: using function pointers as const generic parameters is forbidden - --> $DIR/const-type-ice-153499.rs:4:29 + --> $DIR/const-type-ice-153499.rs:3:29 | LL | trait Trait<'a, T, const F: fn(&CStr) -> usize> { | ^^^^^^^^^^^^^^^^^^ @@ -18,7 +18,7 @@ LL | trait Trait<'a, T, const F: fn(&CStr) -> usize> { = note: the only supported types are integers, `bool`, and `char` error: using function pointers as const generic parameters is forbidden - --> $DIR/const-type-ice-153499.rs:10:14 + --> $DIR/const-type-ice-153499.rs:9:14 | LL | reuse Trait::foo; | ^^^ diff --git a/tests/ui/delegation/generics/const-type-ice-154334.rs b/tests/ui/delegation/generics/const-type-ice-154334.rs index 91cf1d3a0a639..3d2d8ca3ed7fd 100644 --- a/tests/ui/delegation/generics/const-type-ice-154334.rs +++ b/tests/ui/delegation/generics/const-type-ice-154334.rs @@ -5,6 +5,7 @@ #![feature(fn_delegation)] #![feature(adt_const_params)] #![feature(unsized_const_params)] + trait Trait<'a, T, const N: str> { fn foo<'v, A, B>(&self) {} } diff --git a/tests/ui/delegation/generics/def-path-hash-collision-ice-153410.rs b/tests/ui/delegation/generics/def-path-hash-collision-ice-153410.rs index a7e42ef977f47..9276a0d220ad0 100644 --- a/tests/ui/delegation/generics/def-path-hash-collision-ice-153410.rs +++ b/tests/ui/delegation/generics/def-path-hash-collision-ice-153410.rs @@ -1,8 +1,7 @@ //@ compile-flags: -Z deduplicate-diagnostics=yes //@ edition:2024 -#![feature(fn_delegation)] -#![feature(iter_advance_by)] +#![feature(fn_delegation)]#![feature(iter_advance_by)] #![feature(iter_array_chunks)] #![feature(iterator_try_collect)] #![feature(iterator_try_reduce)] @@ -15,7 +14,7 @@ #![feature(iter_partition_in_place)] #![feature(trusted_random_access)] #![feature(try_find)] -#![allow(incomplete_features)] + impl Iterator { //~^ ERROR: expected a type, found a trait [E0782] diff --git a/tests/ui/delegation/generics/def-path-hash-collision-ice-153410.stderr b/tests/ui/delegation/generics/def-path-hash-collision-ice-153410.stderr index f18634e8a2e19..4b4c1bc006632 100644 --- a/tests/ui/delegation/generics/def-path-hash-collision-ice-153410.stderr +++ b/tests/ui/delegation/generics/def-path-hash-collision-ice-153410.stderr @@ -1,11 +1,11 @@ error[E0575]: expected method or associated constant, found associated type `Iterator::Item` - --> $DIR/def-path-hash-collision-ice-153410.rs:22:10 + --> $DIR/def-path-hash-collision-ice-153410.rs:21:10 | LL | reuse< < fn()>::Output>::Item as Iterator>::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a method or associated constant error[E0782]: expected a type, found a trait - --> $DIR/def-path-hash-collision-ice-153410.rs:20:6 + --> $DIR/def-path-hash-collision-ice-153410.rs:19:6 | LL | impl Iterator { | ^^^^^^^^ @@ -20,7 +20,7 @@ LL | impl Iterator for /* Type */ { | ++++++++++++++ error[E0223]: ambiguous associated type - --> $DIR/def-path-hash-collision-ice-153410.rs:22:14 + --> $DIR/def-path-hash-collision-ice-153410.rs:21:14 | LL | reuse< < fn()>::Output>::Item as Iterator>::*; | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/delegation/generics/free-fn-to-free-fn-pass.rs b/tests/ui/delegation/generics/free-fn-to-free-fn-pass.rs index 625bbdd758c1b..7883b8651e4a3 100644 --- a/tests/ui/delegation/generics/free-fn-to-free-fn-pass.rs +++ b/tests/ui/delegation/generics/free-fn-to-free-fn-pass.rs @@ -1,6 +1,5 @@ //@ run-pass #![feature(fn_delegation)] -#![allow(incomplete_features)] mod to_reuse { pub fn types(x: U, y: T) -> (T, U) { diff --git a/tests/ui/delegation/generics/free-fn-to-free-fn.rs b/tests/ui/delegation/generics/free-fn-to-free-fn.rs index 67f7a12d710d5..7090975f89a17 100644 --- a/tests/ui/delegation/generics/free-fn-to-free-fn.rs +++ b/tests/ui/delegation/generics/free-fn-to-free-fn.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] mod to_reuse { pub fn consts() -> i32 { diff --git a/tests/ui/delegation/generics/free-fn-to-free-fn.stderr b/tests/ui/delegation/generics/free-fn-to-free-fn.stderr index db88b8d4f8b7d..3032dd53a50b7 100644 --- a/tests/ui/delegation/generics/free-fn-to-free-fn.stderr +++ b/tests/ui/delegation/generics/free-fn-to-free-fn.stderr @@ -1,5 +1,5 @@ error[E0107]: function takes 0 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/free-fn-to-free-fn.rs:19:5 + --> $DIR/free-fn-to-free-fn.rs:18:5 | LL | late::<'static>(&0u8); | ^^^^----------- help: remove the unnecessary generics @@ -7,13 +7,13 @@ LL | late::<'static>(&0u8); | expected 0 lifetime arguments | note: function defined here, with 0 lifetime parameters - --> $DIR/free-fn-to-free-fn.rs:15:17 + --> $DIR/free-fn-to-free-fn.rs:14:17 | LL | reuse to_reuse::late; | ^^^^ error[E0277]: the trait bound `S: Clone` is not satisfied - --> $DIR/free-fn-to-free-fn.rs:23:12 + --> $DIR/free-fn-to-free-fn.rs:22:12 | LL | bounds(S); | ------ ^ the trait `Clone` is not implemented for `S` @@ -21,7 +21,7 @@ LL | bounds(S); | required by a bound introduced by this call | note: required by a bound in `bounds` - --> $DIR/free-fn-to-free-fn.rs:11:22 + --> $DIR/free-fn-to-free-fn.rs:10:22 | LL | pub fn bounds(_: T) {} | ^^^^^ required by this bound in `bounds` diff --git a/tests/ui/delegation/generics/free-fn-to-trait-infer.rs b/tests/ui/delegation/generics/free-fn-to-trait-infer.rs index f89c17fe266ca..0a0665b752681 100644 --- a/tests/ui/delegation/generics/free-fn-to-trait-infer.rs +++ b/tests/ui/delegation/generics/free-fn-to-trait-infer.rs @@ -1,7 +1,6 @@ //@ compile-flags: -Z deduplicate-diagnostics=yes #![feature(fn_delegation)] -#![allow(incomplete_features)] trait Trait { fn foo(&self, _: U, _: T) {} diff --git a/tests/ui/delegation/generics/free-fn-to-trait-infer.stderr b/tests/ui/delegation/generics/free-fn-to-trait-infer.stderr index 05956f045a279..f1e9231cc4050 100644 --- a/tests/ui/delegation/generics/free-fn-to-trait-infer.stderr +++ b/tests/ui/delegation/generics/free-fn-to-trait-infer.stderr @@ -1,23 +1,23 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions - --> $DIR/free-fn-to-trait-infer.rs:12:15 + --> $DIR/free-fn-to-trait-infer.rs:11:15 | LL | reuse Trait::<_>::foo:: as generic_arguments1; | ^ not allowed in type signatures error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions - --> $DIR/free-fn-to-trait-infer.rs:14:20 + --> $DIR/free-fn-to-trait-infer.rs:13:20 | LL | reuse >::foo as generic_arguments2; | ^ not allowed in type signatures error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions - --> $DIR/free-fn-to-trait-infer.rs:16:8 + --> $DIR/free-fn-to-trait-infer.rs:15:8 | LL | reuse <_ as Trait<_>>::foo as generic_arguments3; | ^ not allowed in type signatures error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions - --> $DIR/free-fn-to-trait-infer.rs:16:19 + --> $DIR/free-fn-to-trait-infer.rs:15:19 | LL | reuse <_ as Trait<_>>::foo as generic_arguments3; | ^ not allowed in type signatures diff --git a/tests/ui/delegation/generics/free-fn-to-trait-method-pass.rs b/tests/ui/delegation/generics/free-fn-to-trait-method-pass.rs index f7b7c09e2ca42..865a8314d01d3 100644 --- a/tests/ui/delegation/generics/free-fn-to-trait-method-pass.rs +++ b/tests/ui/delegation/generics/free-fn-to-trait-method-pass.rs @@ -1,6 +1,5 @@ //@ run-pass #![feature(fn_delegation)] -#![allow(incomplete_features)] mod types { pub trait Trait { diff --git a/tests/ui/delegation/generics/free-fn-to-trait-method.rs b/tests/ui/delegation/generics/free-fn-to-trait-method.rs index eb3a941c8f484..fba3ddb169589 100644 --- a/tests/ui/delegation/generics/free-fn-to-trait-method.rs +++ b/tests/ui/delegation/generics/free-fn-to-trait-method.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] mod default_param { pub trait Trait { diff --git a/tests/ui/delegation/generics/free-fn-to-trait-method.stderr b/tests/ui/delegation/generics/free-fn-to-trait-method.stderr index b35a3188dd94b..8b2e603b4c9b2 100644 --- a/tests/ui/delegation/generics/free-fn-to-trait-method.stderr +++ b/tests/ui/delegation/generics/free-fn-to-trait-method.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `S: Copy` is not satisfied - --> $DIR/free-fn-to-trait-method.rs:39:18 + --> $DIR/free-fn-to-trait-method.rs:38:18 | LL | bounds(&0u8, S, U); | ------ ^ the trait `Copy` is not implemented for `S` @@ -7,7 +7,7 @@ LL | bounds(&0u8, S, U); | required by a bound introduced by this call | note: required by a bound in `bounds` - --> $DIR/free-fn-to-trait-method.rs:23:54 + --> $DIR/free-fn-to-trait-method.rs:22:54 | LL | fn foo(&self, t: T, u: U) where T: Copy {} | ^^^^ required by this bound in `bounds` @@ -21,7 +21,7 @@ LL | struct S; | error[E0277]: the trait bound `U: Clone` is not satisfied - --> $DIR/free-fn-to-trait-method.rs:39:21 + --> $DIR/free-fn-to-trait-method.rs:38:21 | LL | bounds(&0u8, S, U); | ------ ^ the trait `Clone` is not implemented for `U` @@ -29,7 +29,7 @@ LL | bounds(&0u8, S, U); | required by a bound introduced by this call | note: required by a bound in `bounds` - --> $DIR/free-fn-to-trait-method.rs:23:19 + --> $DIR/free-fn-to-trait-method.rs:22:19 | LL | fn foo(&self, t: T, u: U) where T: Copy {} | ^^^^^ required by this bound in `bounds` diff --git a/tests/ui/delegation/generics/free-to-trait-self-reuse.rs b/tests/ui/delegation/generics/free-to-trait-self-reuse.rs index 4714fa471432b..f8471b53c57d7 100644 --- a/tests/ui/delegation/generics/free-to-trait-self-reuse.rs +++ b/tests/ui/delegation/generics/free-to-trait-self-reuse.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] trait Bound {} diff --git a/tests/ui/delegation/generics/free-to-trait-self-reuse.stderr b/tests/ui/delegation/generics/free-to-trait-self-reuse.stderr index 842f4cd4eb395..a37a1b777d4d1 100644 --- a/tests/ui/delegation/generics/free-to-trait-self-reuse.stderr +++ b/tests/ui/delegation/generics/free-to-trait-self-reuse.stderr @@ -1,21 +1,21 @@ error[E0277]: the trait bound `Struct: Bound` is not satisfied - --> $DIR/free-to-trait-self-reuse.rs:32:49 + --> $DIR/free-to-trait-self-reuse.rs:31:49 | LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {} | ^^^^^^ unsatisfied trait bound | help: the trait `Bound` is not implemented for `Struct` - --> $DIR/free-to-trait-self-reuse.rs:31:1 + --> $DIR/free-to-trait-self-reuse.rs:30:1 | LL | struct Struct; | ^^^^^^^^^^^^^ help: the trait `Bound` is implemented for `usize` - --> $DIR/free-to-trait-self-reuse.rs:16:1 + --> $DIR/free-to-trait-self-reuse.rs:15:1 | LL | impl Bound for usize {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ note: required by a bound in `Trait` - --> $DIR/free-to-trait-self-reuse.rs:8:11 + --> $DIR/free-to-trait-self-reuse.rs:7:11 | LL | trait Trait<'a, T, const X: usize> | ----- required by a bound in this trait @@ -24,13 +24,13 @@ LL | Self: Bound + Sized, | ^^^^^^^^ required by this bound in `Trait` error[E0277]: the trait bound `String: Trait<'a, T, X>` is not satisfied - --> $DIR/free-to-trait-self-reuse.rs:28:8 + --> $DIR/free-to-trait-self-reuse.rs:27:8 | LL | reuse ::method as error5; | ^^^^^^ the trait `Trait<'a, T, X>` is not implemented for `String` | help: the following other types implement trait `Trait<'a, T, X>` - --> $DIR/free-to-trait-self-reuse.rs:15:1 + --> $DIR/free-to-trait-self-reuse.rs:14:1 | LL | impl<'a, T, const X: usize> Trait<'a, T, X> for usize {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `usize` @@ -39,23 +39,23 @@ LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Struct` error[E0277]: the trait bound `Struct: Bound` is not satisfied - --> $DIR/free-to-trait-self-reuse.rs:35:8 + --> $DIR/free-to-trait-self-reuse.rs:34:8 | LL | reuse ::method as error6; | ^^^^^^ unsatisfied trait bound | help: the trait `Bound` is not implemented for `Struct` - --> $DIR/free-to-trait-self-reuse.rs:31:1 + --> $DIR/free-to-trait-self-reuse.rs:30:1 | LL | struct Struct; | ^^^^^^^^^^^^^ help: the trait `Bound` is implemented for `usize` - --> $DIR/free-to-trait-self-reuse.rs:16:1 + --> $DIR/free-to-trait-self-reuse.rs:15:1 | LL | impl Bound for usize {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ note: required by a bound in `Trait::method` - --> $DIR/free-to-trait-self-reuse.rs:8:11 + --> $DIR/free-to-trait-self-reuse.rs:7:11 | LL | Self: Bound + Sized, | ^^^^^^^^ required by this bound in `Trait::method` @@ -64,7 +64,7 @@ LL | fn method(&self, x: U) {} | ------ required by a bound in this associated function error[E0107]: function takes 3 generic arguments but 2 generic arguments were supplied - --> $DIR/free-to-trait-self-reuse.rs:44:5 + --> $DIR/free-to-trait-self-reuse.rs:43:5 | LL | foo3::(&123, "".to_string()); | ^^^^ ------ ---- supplied 2 generic arguments @@ -72,7 +72,7 @@ LL | foo3::(&123, "".to_string()); | expected 3 generic arguments | note: function defined here, with 3 generic parameters: `Self`, `U`, `B` - --> $DIR/free-to-trait-self-reuse.rs:23:45 + --> $DIR/free-to-trait-self-reuse.rs:22:45 | LL | reuse Trait::<'static, i32, 123>::method as foo3; | ------ ^^^^ @@ -82,7 +82,7 @@ LL | foo3::(&123, "".to_string()); | +++ error[E0107]: function takes 5 generic arguments but 4 generic arguments were supplied - --> $DIR/free-to-trait-self-reuse.rs:47:5 + --> $DIR/free-to-trait-self-reuse.rs:46:5 | LL | bar3::<'static, i32, 123, bool, false>(&mut 123, true); | ^^^^ --- --- ---- ----- supplied 4 generic arguments @@ -90,7 +90,7 @@ LL | bar3::<'static, i32, 123, bool, false>(&mut 123, true); | expected 5 generic arguments | note: function defined here, with 5 generic parameters: `Self`, `T`, `X`, `U`, `B` - --> $DIR/free-to-trait-self-reuse.rs:25:25 + --> $DIR/free-to-trait-self-reuse.rs:24:25 | LL | reuse Trait::method3 as bar3; | ------- ^^^^ @@ -100,7 +100,7 @@ LL | bar3::<'static, i32, 123, bool, false, B>(&mut 123, true); | +++ error[E0107]: function takes 3 generic arguments but 2 generic arguments were supplied - --> $DIR/free-to-trait-self-reuse.rs:49:5 + --> $DIR/free-to-trait-self-reuse.rs:48:5 | LL | bar4::<'static, usize, 321>(&mut 123, vec![123]); | ^^^^ ----- --- supplied 2 generic arguments @@ -108,7 +108,7 @@ LL | bar4::<'static, usize, 321>(&mut 123, vec![123]); | expected 3 generic arguments | note: function defined here, with 3 generic parameters: `Self`, `T`, `X` - --> $DIR/free-to-trait-self-reuse.rs:26:44 + --> $DIR/free-to-trait-self-reuse.rs:25:44 | LL | reuse Trait::method3::, false> as bar4; | ------- ^^^^ diff --git a/tests/ui/delegation/generics/free-to-trait-static-reuse.rs b/tests/ui/delegation/generics/free-to-trait-static-reuse.rs index b82e3fcac1b36..abb69e5fc1588 100644 --- a/tests/ui/delegation/generics/free-to-trait-static-reuse.rs +++ b/tests/ui/delegation/generics/free-to-trait-static-reuse.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] trait Bound {} diff --git a/tests/ui/delegation/generics/free-to-trait-static-reuse.stderr b/tests/ui/delegation/generics/free-to-trait-static-reuse.stderr index 4ccbd0b072c3b..398fa2e5db92a 100644 --- a/tests/ui/delegation/generics/free-to-trait-static-reuse.stderr +++ b/tests/ui/delegation/generics/free-to-trait-static-reuse.stderr @@ -1,21 +1,21 @@ error[E0277]: the trait bound `Struct: Bound` is not satisfied - --> $DIR/free-to-trait-static-reuse.rs:34:49 + --> $DIR/free-to-trait-static-reuse.rs:33:49 | LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {} | ^^^^^^ unsatisfied trait bound | help: the trait `Bound` is not implemented for `Struct` - --> $DIR/free-to-trait-static-reuse.rs:33:1 + --> $DIR/free-to-trait-static-reuse.rs:32:1 | LL | struct Struct; | ^^^^^^^^^^^^^ help: the trait `Bound` is implemented for `usize` - --> $DIR/free-to-trait-static-reuse.rs:14:1 + --> $DIR/free-to-trait-static-reuse.rs:13:1 | LL | impl Bound for usize {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ note: required by a bound in `Trait` - --> $DIR/free-to-trait-static-reuse.rs:8:11 + --> $DIR/free-to-trait-static-reuse.rs:7:11 | LL | trait Trait<'a, T, const X: usize> | ----- required by a bound in this trait @@ -24,13 +24,13 @@ LL | Self: Bound, | ^^^^^^^^ required by this bound in `Trait` error[E0283]: type annotations needed - --> $DIR/free-to-trait-static-reuse.rs:21:14 + --> $DIR/free-to-trait-static-reuse.rs:20:14 | LL | reuse Trait::static_method as error { self - 123 } | ^^^^^^^^^^^^^ cannot infer type | note: multiple `impl`s satisfying `_: Trait<'a, T, X>` found - --> $DIR/free-to-trait-static-reuse.rs:13:1 + --> $DIR/free-to-trait-static-reuse.rs:12:1 | LL | impl<'a, T, const X: usize> Trait<'a, T, X> for usize {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -39,13 +39,13 @@ LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0283]: type annotations needed - --> $DIR/free-to-trait-static-reuse.rs:23:35 + --> $DIR/free-to-trait-static-reuse.rs:22:35 | LL | reuse Trait::<'static, i32, 123>::static_method as error2; | ^^^^^^^^^^^^^ cannot infer type | note: multiple `impl`s satisfying `_: Trait<'static, i32, 123>` found - --> $DIR/free-to-trait-static-reuse.rs:13:1 + --> $DIR/free-to-trait-static-reuse.rs:12:1 | LL | impl<'a, T, const X: usize> Trait<'a, T, X> for usize {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -54,13 +54,13 @@ LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0283]: type annotations needed - --> $DIR/free-to-trait-static-reuse.rs:25:35 + --> $DIR/free-to-trait-static-reuse.rs:24:35 | LL | reuse Trait::<'static, i32, 123>::static_method::<'static, String, false> as error3; | ^^^^^^^^^^^^^ cannot infer type | note: multiple `impl`s satisfying `_: Trait<'static, i32, 123>` found - --> $DIR/free-to-trait-static-reuse.rs:13:1 + --> $DIR/free-to-trait-static-reuse.rs:12:1 | LL | impl<'a, T, const X: usize> Trait<'a, T, X> for usize {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -69,13 +69,13 @@ LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0283]: type annotations needed - --> $DIR/free-to-trait-static-reuse.rs:27:14 + --> $DIR/free-to-trait-static-reuse.rs:26:14 | LL | reuse Trait::static_method::<'static, Vec, false> as error4 { self + 4 } | ^^^^^^^^^^^^^ cannot infer type | note: multiple `impl`s satisfying `_: Trait<'a, T, X>` found - --> $DIR/free-to-trait-static-reuse.rs:13:1 + --> $DIR/free-to-trait-static-reuse.rs:12:1 | LL | impl<'a, T, const X: usize> Trait<'a, T, X> for usize {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -84,13 +84,13 @@ LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `String: Trait<'a, T, X>` is not satisfied - --> $DIR/free-to-trait-static-reuse.rs:30:8 + --> $DIR/free-to-trait-static-reuse.rs:29:8 | LL | reuse ::static_method as error5; | ^^^^^^ the trait `Trait<'a, T, X>` is not implemented for `String` | help: the following other types implement trait `Trait<'a, T, X>` - --> $DIR/free-to-trait-static-reuse.rs:13:1 + --> $DIR/free-to-trait-static-reuse.rs:12:1 | LL | impl<'a, T, const X: usize> Trait<'a, T, X> for usize {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `usize` @@ -99,23 +99,23 @@ LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Struct` error[E0277]: the trait bound `Struct: Bound` is not satisfied - --> $DIR/free-to-trait-static-reuse.rs:37:8 + --> $DIR/free-to-trait-static-reuse.rs:36:8 | LL | reuse ::static_method as error6; | ^^^^^^ unsatisfied trait bound | help: the trait `Bound` is not implemented for `Struct` - --> $DIR/free-to-trait-static-reuse.rs:33:1 + --> $DIR/free-to-trait-static-reuse.rs:32:1 | LL | struct Struct; | ^^^^^^^^^^^^^ help: the trait `Bound` is implemented for `usize` - --> $DIR/free-to-trait-static-reuse.rs:14:1 + --> $DIR/free-to-trait-static-reuse.rs:13:1 | LL | impl Bound for usize {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ note: required by a bound in `Trait::static_method` - --> $DIR/free-to-trait-static-reuse.rs:8:11 + --> $DIR/free-to-trait-static-reuse.rs:7:11 | LL | Self: Bound, | ^^^^^^^^ required by this bound in `Trait::static_method` diff --git a/tests/ui/delegation/generics/generic-params-defaults.rs b/tests/ui/delegation/generics/generic-params-defaults.rs index 66a9195551337..96bfd533b7903 100644 --- a/tests/ui/delegation/generics/generic-params-defaults.rs +++ b/tests/ui/delegation/generics/generic-params-defaults.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] trait Trait<'a, 'b, 'c, A = usize, B = u32, C = String, const N: usize = 123> { fn foo(&self) { diff --git a/tests/ui/delegation/generics/generic-params-defaults.stderr b/tests/ui/delegation/generics/generic-params-defaults.stderr index 76fc3fde4753c..58242387b1721 100644 --- a/tests/ui/delegation/generics/generic-params-defaults.stderr +++ b/tests/ui/delegation/generics/generic-params-defaults.stderr @@ -1,5 +1,5 @@ error: defaults for generic parameters are not allowed here - --> $DIR/generic-params-defaults.rs:5:12 + --> $DIR/generic-params-defaults.rs:4:12 | LL | fn foo(&self) { | ^^^^^^^^^ @@ -12,7 +12,7 @@ error: aborting due to 1 previous error Future incompatibility report: Future breakage diagnostic: error: defaults for generic parameters are not allowed here - --> $DIR/generic-params-defaults.rs:5:12 + --> $DIR/generic-params-defaults.rs:4:12 | LL | fn foo(&self) { | ^^^^^^^^^ diff --git a/tests/ui/delegation/generics/generic-params-same-names.rs b/tests/ui/delegation/generics/generic-params-same-names.rs index ff1d5aa2b3f6a..a176930662d4c 100644 --- a/tests/ui/delegation/generics/generic-params-same-names.rs +++ b/tests/ui/delegation/generics/generic-params-same-names.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] trait Trait<'a, 'b, 'c, A, B, C, const N: usize> { fn foo<'a, 'b, 'c, A, B, C, const N: usize>(&self) { diff --git a/tests/ui/delegation/generics/generic-params-same-names.stderr b/tests/ui/delegation/generics/generic-params-same-names.stderr index 71ac05fcada01..6f2f4a0b22657 100644 --- a/tests/ui/delegation/generics/generic-params-same-names.stderr +++ b/tests/ui/delegation/generics/generic-params-same-names.stderr @@ -1,5 +1,5 @@ error[E0496]: lifetime name `'a` shadows a lifetime name that is already in scope - --> $DIR/generic-params-same-names.rs:5:12 + --> $DIR/generic-params-same-names.rs:4:12 | LL | trait Trait<'a, 'b, 'c, A, B, C, const N: usize> { | -- first declared here @@ -7,7 +7,7 @@ LL | fn foo<'a, 'b, 'c, A, B, C, const N: usize>(&self) { | ^^ lifetime `'a` already in scope error[E0496]: lifetime name `'b` shadows a lifetime name that is already in scope - --> $DIR/generic-params-same-names.rs:5:16 + --> $DIR/generic-params-same-names.rs:4:16 | LL | trait Trait<'a, 'b, 'c, A, B, C, const N: usize> { | -- first declared here @@ -15,7 +15,7 @@ LL | fn foo<'a, 'b, 'c, A, B, C, const N: usize>(&self) { | ^^ lifetime `'b` already in scope error[E0496]: lifetime name `'c` shadows a lifetime name that is already in scope - --> $DIR/generic-params-same-names.rs:5:20 + --> $DIR/generic-params-same-names.rs:4:20 | LL | trait Trait<'a, 'b, 'c, A, B, C, const N: usize> { | -- first declared here @@ -23,7 +23,7 @@ LL | fn foo<'a, 'b, 'c, A, B, C, const N: usize>(&self) { | ^^ lifetime `'c` already in scope error[E0403]: the name `A` is already used for a generic parameter in this item's generic parameters - --> $DIR/generic-params-same-names.rs:5:24 + --> $DIR/generic-params-same-names.rs:4:24 | LL | trait Trait<'a, 'b, 'c, A, B, C, const N: usize> { | - first use of `A` @@ -31,7 +31,7 @@ LL | fn foo<'a, 'b, 'c, A, B, C, const N: usize>(&self) { | ^ already used error[E0403]: the name `B` is already used for a generic parameter in this item's generic parameters - --> $DIR/generic-params-same-names.rs:5:27 + --> $DIR/generic-params-same-names.rs:4:27 | LL | trait Trait<'a, 'b, 'c, A, B, C, const N: usize> { | - first use of `B` @@ -39,7 +39,7 @@ LL | fn foo<'a, 'b, 'c, A, B, C, const N: usize>(&self) { | ^ already used error[E0403]: the name `C` is already used for a generic parameter in this item's generic parameters - --> $DIR/generic-params-same-names.rs:5:30 + --> $DIR/generic-params-same-names.rs:4:30 | LL | trait Trait<'a, 'b, 'c, A, B, C, const N: usize> { | - first use of `C` @@ -47,7 +47,7 @@ LL | fn foo<'a, 'b, 'c, A, B, C, const N: usize>(&self) { | ^ already used error[E0403]: the name `N` is already used for a generic parameter in this item's generic parameters - --> $DIR/generic-params-same-names.rs:5:39 + --> $DIR/generic-params-same-names.rs:4:39 | LL | trait Trait<'a, 'b, 'c, A, B, C, const N: usize> { | - first use of `N` diff --git a/tests/ui/delegation/generics/generics-aux-pass.rs b/tests/ui/delegation/generics/generics-aux-pass.rs index a2cfe91dc4033..06f5c6d4d212e 100644 --- a/tests/ui/delegation/generics/generics-aux-pass.rs +++ b/tests/ui/delegation/generics/generics-aux-pass.rs @@ -2,7 +2,6 @@ //@ run-pass #![feature(fn_delegation)] -#![allow(incomplete_features)] reuse generics::foo as bar; reuse generics::Trait::foo as trait_foo; diff --git a/tests/ui/delegation/generics/generics-gen-args-errors.rs b/tests/ui/delegation/generics/generics-gen-args-errors.rs index 68e26e41a5627..70a69ebcc408b 100644 --- a/tests/ui/delegation/generics/generics-gen-args-errors.rs +++ b/tests/ui/delegation/generics/generics-gen-args-errors.rs @@ -1,7 +1,6 @@ //@ compile-flags: -Z deduplicate-diagnostics=yes #![feature(fn_delegation)] -#![allow(incomplete_features)] mod test_1 { fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} diff --git a/tests/ui/delegation/generics/generics-gen-args-errors.stderr b/tests/ui/delegation/generics/generics-gen-args-errors.stderr index cf06d397244a2..7bf130ba5d6a9 100644 --- a/tests/ui/delegation/generics/generics-gen-args-errors.stderr +++ b/tests/ui/delegation/generics/generics-gen-args-errors.stderr @@ -1,5 +1,5 @@ error[E0401]: can't use generic parameters from outer item - --> $DIR/generics-gen-args-errors.rs:34:21 + --> $DIR/generics-gen-args-errors.rs:33:21 | LL | fn check() { | - type parameter from outer item @@ -12,7 +12,7 @@ LL | reuse foo:: as xd; = note: nested items are independent from their parent item for everything except for privacy and name resolution error[E0401]: can't use generic parameters from outer item - --> $DIR/generics-gen-args-errors.rs:34:24 + --> $DIR/generics-gen-args-errors.rs:33:24 | LL | fn check() { | - type parameter from outer item @@ -25,7 +25,7 @@ LL | reuse foo:: as xd; = note: nested items are independent from their parent item for everything except for privacy and name resolution error[E0401]: can't use generic parameters from outer item - --> $DIR/generics-gen-args-errors.rs:34:27 + --> $DIR/generics-gen-args-errors.rs:33:27 | LL | fn check() { | - type parameter from outer item @@ -38,7 +38,7 @@ LL | reuse foo:: as xd; = note: nested items are independent from their parent item for everything except for privacy and name resolution error[E0261]: use of undeclared lifetime name `'asdasd` - --> $DIR/generics-gen-args-errors.rs:53:29 + --> $DIR/generics-gen-args-errors.rs:52:29 | LL | reuse foo::<'static, _, 'asdasd, 'static, 'static, 'static, _> as bar3; | ^^^^^^^ undeclared lifetime @@ -49,7 +49,7 @@ LL | reuse foo'asdasd, ::<'static, _, 'asdasd, 'static, 'static, 'static, _> | ++++++++ error[E0261]: use of undeclared lifetime name `'a` - --> $DIR/generics-gen-args-errors.rs:70:50 + --> $DIR/generics-gen-args-errors.rs:69:50 | LL | reuse foo::<"asdasd", asd, "askdn", 'static, 'a> as bar7; | ^^ undeclared lifetime @@ -60,7 +60,7 @@ LL | reuse foo'a, ::<"asdasd", asd, "askdn", 'static, 'a> as bar7; | +++ error[E0106]: missing lifetime specifiers - --> $DIR/generics-gen-args-errors.rs:117:19 + --> $DIR/generics-gen-args-errors.rs:116:19 | LL | reuse Trait::::foo::<1, 2, 3, _, 6> as bar7; | ^^^^^ expected 3 lifetime parameters @@ -71,7 +71,7 @@ LL | reuse Trait::, Clone, _, 'static, dyn Send, _>::foo'a | ++++++++++++ +++ error[E0423]: expected value, found struct `String` - --> $DIR/generics-gen-args-errors.rs:14:33 + --> $DIR/generics-gen-args-errors.rs:13:33 | LL | bar::(); | ^^^^^^ @@ -81,7 +81,7 @@ LL | bar::(); = note: `String` defined here error[E0425]: cannot find type `asd` in this scope - --> $DIR/generics-gen-args-errors.rs:28:15 + --> $DIR/generics-gen-args-errors.rs:27:15 | LL | bar::(); | ^^^ not found in this scope @@ -92,7 +92,7 @@ LL | fn check() { | +++++ error[E0425]: cannot find type `asd` in this scope - --> $DIR/generics-gen-args-errors.rs:28:20 + --> $DIR/generics-gen-args-errors.rs:27:20 | LL | bar::(); | ^^^ not found in this scope @@ -103,7 +103,7 @@ LL | fn check() { | +++++ error[E0425]: cannot find type `asd` in this scope - --> $DIR/generics-gen-args-errors.rs:28:25 + --> $DIR/generics-gen-args-errors.rs:27:25 | LL | bar::(); | ^^^ not found in this scope @@ -114,73 +114,73 @@ LL | fn check() { | +++++ error[E0425]: cannot find type `asdasd` in this scope - --> $DIR/generics-gen-args-errors.rs:57:39 + --> $DIR/generics-gen-args-errors.rs:56:39 | LL | reuse foo:: as bar4; | ^^^^^^ not found in this scope error[E0425]: cannot find type `asd` in this scope - --> $DIR/generics-gen-args-errors.rs:65:22 + --> $DIR/generics-gen-args-errors.rs:64:22 | LL | reuse foo::<1, 2,asd,String, { let x = 0; }> as bar6; | ^^^ not found in this scope error[E0425]: cannot find type `asd` in this scope - --> $DIR/generics-gen-args-errors.rs:70:27 + --> $DIR/generics-gen-args-errors.rs:69:27 | LL | reuse foo::<"asdasd", asd, "askdn", 'static, 'a> as bar7; | ^^^ not found in this scope error[E0425]: cannot find type `asd` in this scope - --> $DIR/generics-gen-args-errors.rs:85:19 + --> $DIR/generics-gen-args-errors.rs:84:19 | LL | reuse Trait::::foo as bar1; | ^^^ not found in this scope error[E0425]: cannot find type `asd` in this scope - --> $DIR/generics-gen-args-errors.rs:85:24 + --> $DIR/generics-gen-args-errors.rs:84:24 | LL | reuse Trait::::foo as bar1; | ^^^ not found in this scope error[E0425]: cannot find type `asd` in this scope - --> $DIR/generics-gen-args-errors.rs:85:29 + --> $DIR/generics-gen-args-errors.rs:84:29 | LL | reuse Trait::::foo as bar1; | ^^^ not found in this scope error[E0425]: cannot find type `asd` in this scope - --> $DIR/generics-gen-args-errors.rs:85:34 + --> $DIR/generics-gen-args-errors.rs:84:34 | LL | reuse Trait::::foo as bar1; | ^^^ not found in this scope error[E0425]: cannot find type `asd` in this scope - --> $DIR/generics-gen-args-errors.rs:85:39 + --> $DIR/generics-gen-args-errors.rs:84:39 | LL | reuse Trait::::foo as bar1; | ^^^ not found in this scope error[E0425]: cannot find type `asdasa` in this scope - --> $DIR/generics-gen-args-errors.rs:85:44 + --> $DIR/generics-gen-args-errors.rs:84:44 | LL | reuse Trait::::foo as bar1; | ^^^^^^ not found in this scope error[E0425]: cannot find type `DDDD` in this scope - --> $DIR/generics-gen-args-errors.rs:110:34 + --> $DIR/generics-gen-args-errors.rs:109:34 | LL | reuse Trait::<1, 2, 'static, DDDD>::foo::<1, 2, 3, 4, 5, 6> as bar6; | ^^^^ not found in this scope error[E0107]: function takes 2 lifetime arguments but 0 lifetime arguments were supplied - --> $DIR/generics-gen-args-errors.rs:34:15 + --> $DIR/generics-gen-args-errors.rs:33:15 | LL | reuse foo:: as xd; | ^^^ expected 2 lifetime arguments | note: function defined here, with 2 lifetime parameters: `'a`, `'b` - --> $DIR/generics-gen-args-errors.rs:7:8 + --> $DIR/generics-gen-args-errors.rs:6:8 | LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} | ^^^ -- -- @@ -190,19 +190,19 @@ LL | reuse foo::<'a, 'b, A, B, C> as xd; | +++++++ error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions - --> $DIR/generics-gen-args-errors.rs:46:11 + --> $DIR/generics-gen-args-errors.rs:45:11 | LL | reuse foo::<> as bar1; | ^^^ not allowed in type signatures error[E0107]: function takes 2 lifetime arguments but 0 lifetime arguments were supplied - --> $DIR/generics-gen-args-errors.rs:49:11 + --> $DIR/generics-gen-args-errors.rs:48:11 | LL | reuse foo:: as bar2; | ^^^ expected 2 lifetime arguments | note: function defined here, with 2 lifetime parameters: `'a`, `'b` - --> $DIR/generics-gen-args-errors.rs:44:8 + --> $DIR/generics-gen-args-errors.rs:43:8 | LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} | ^^^ -- -- @@ -212,7 +212,7 @@ LL | reuse foo::<'a, 'b, String, String> as bar2; | +++++++ error[E0107]: function takes 3 generic arguments but 2 generic arguments were supplied - --> $DIR/generics-gen-args-errors.rs:49:11 + --> $DIR/generics-gen-args-errors.rs:48:11 | LL | reuse foo:: as bar2; | ^^^ ------ ------ supplied 2 generic arguments @@ -220,7 +220,7 @@ LL | reuse foo:: as bar2; | expected 3 generic arguments | note: function defined here, with 3 generic parameters: `T`, `U`, `N` - --> $DIR/generics-gen-args-errors.rs:44:8 + --> $DIR/generics-gen-args-errors.rs:43:8 | LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} | ^^^ - - -------------- @@ -230,7 +230,7 @@ LL | reuse foo:: as bar2; | +++ error[E0107]: function takes 2 lifetime arguments but 5 lifetime arguments were supplied - --> $DIR/generics-gen-args-errors.rs:53:11 + --> $DIR/generics-gen-args-errors.rs:52:11 | LL | reuse foo::<'static, _, 'asdasd, 'static, 'static, 'static, _> as bar3; | ^^^ --------------------------- help: remove the lifetime arguments @@ -238,19 +238,19 @@ LL | reuse foo::<'static, _, 'asdasd, 'static, 'static, 'static, _> as bar3; | expected 2 lifetime arguments | note: function defined here, with 2 lifetime parameters: `'a`, `'b` - --> $DIR/generics-gen-args-errors.rs:44:8 + --> $DIR/generics-gen-args-errors.rs:43:8 | LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} | ^^^ -- -- error[E0107]: function takes 3 generic arguments but 2 generic arguments were supplied - --> $DIR/generics-gen-args-errors.rs:53:11 + --> $DIR/generics-gen-args-errors.rs:52:11 | LL | reuse foo::<'static, _, 'asdasd, 'static, 'static, 'static, _> as bar3; | ^^^ expected 3 generic arguments ------- - supplied 2 generic arguments | note: function defined here, with 3 generic parameters: `T`, `U`, `N` - --> $DIR/generics-gen-args-errors.rs:44:8 + --> $DIR/generics-gen-args-errors.rs:43:8 | LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} | ^^^ - - -------------- @@ -260,7 +260,7 @@ LL | reuse foo::<'static, _, 'asdasd, 'static, 'static, 'static, _, N> as ba | +++ error[E0107]: function takes 2 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/generics-gen-args-errors.rs:57:11 + --> $DIR/generics-gen-args-errors.rs:56:11 | LL | reuse foo:: as bar4; | ^^^ ------ supplied 1 lifetime argument @@ -268,7 +268,7 @@ LL | reuse foo:: as bar4; | expected 2 lifetime arguments | note: function defined here, with 2 lifetime parameters: `'a`, `'b` - --> $DIR/generics-gen-args-errors.rs:44:8 + --> $DIR/generics-gen-args-errors.rs:43:8 | LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} | ^^^ -- -- @@ -278,13 +278,13 @@ LL | reuse foo:: as bar4; | +++++++++ error[E0107]: function takes 2 lifetime arguments but 0 lifetime arguments were supplied - --> $DIR/generics-gen-args-errors.rs:61:11 + --> $DIR/generics-gen-args-errors.rs:60:11 | LL | reuse foo::<1, 2, _, 4, 5, _> as bar5; | ^^^ expected 2 lifetime arguments | note: function defined here, with 2 lifetime parameters: `'a`, `'b` - --> $DIR/generics-gen-args-errors.rs:44:8 + --> $DIR/generics-gen-args-errors.rs:43:8 | LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} | ^^^ -- -- @@ -294,7 +294,7 @@ LL | reuse foo::<'a, 'b, 1, 2, _, 4, 5, _> as bar5; | +++++++ error[E0107]: function takes 3 generic arguments but 6 generic arguments were supplied - --> $DIR/generics-gen-args-errors.rs:61:11 + --> $DIR/generics-gen-args-errors.rs:60:11 | LL | reuse foo::<1, 2, _, 4, 5, _> as bar5; | ^^^ --------- help: remove the unnecessary generic arguments @@ -302,19 +302,19 @@ LL | reuse foo::<1, 2, _, 4, 5, _> as bar5; | expected 3 generic arguments | note: function defined here, with 3 generic parameters: `T`, `U`, `N` - --> $DIR/generics-gen-args-errors.rs:44:8 + --> $DIR/generics-gen-args-errors.rs:43:8 | LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} | ^^^ - - -------------- error[E0107]: function takes 2 lifetime arguments but 0 lifetime arguments were supplied - --> $DIR/generics-gen-args-errors.rs:65:11 + --> $DIR/generics-gen-args-errors.rs:64:11 | LL | reuse foo::<1, 2,asd,String, { let x = 0; }> as bar6; | ^^^ expected 2 lifetime arguments | note: function defined here, with 2 lifetime parameters: `'a`, `'b` - --> $DIR/generics-gen-args-errors.rs:44:8 + --> $DIR/generics-gen-args-errors.rs:43:8 | LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} | ^^^ -- -- @@ -324,7 +324,7 @@ LL | reuse foo::<'a, 'b, 1, 2,asd,String, { let x = 0; }> as bar6; | +++++++ error[E0107]: function takes 3 generic arguments but 5 generic arguments were supplied - --> $DIR/generics-gen-args-errors.rs:65:11 + --> $DIR/generics-gen-args-errors.rs:64:11 | LL | reuse foo::<1, 2,asd,String, { let x = 0; }> as bar6; | ^^^ ----------------------- help: remove the unnecessary generic arguments @@ -332,25 +332,25 @@ LL | reuse foo::<1, 2,asd,String, { let x = 0; }> as bar6; | expected 3 generic arguments | note: function defined here, with 3 generic parameters: `T`, `U`, `N` - --> $DIR/generics-gen-args-errors.rs:44:8 + --> $DIR/generics-gen-args-errors.rs:43:8 | LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} | ^^^ - - -------------- error[E0747]: constant provided when a type was expected - --> $DIR/generics-gen-args-errors.rs:70:17 + --> $DIR/generics-gen-args-errors.rs:69:17 | LL | reuse foo::<"asdasd", asd, "askdn", 'static, 'a> as bar7; | ^^^^^^^^ error[E0107]: function takes 2 lifetime arguments but 0 lifetime arguments were supplied - --> $DIR/generics-gen-args-errors.rs:75:11 + --> $DIR/generics-gen-args-errors.rs:74:11 | LL | reuse foo::<{}, {}, {}> as bar8; | ^^^ expected 2 lifetime arguments | note: function defined here, with 2 lifetime parameters: `'a`, `'b` - --> $DIR/generics-gen-args-errors.rs:44:8 + --> $DIR/generics-gen-args-errors.rs:43:8 | LL | fn foo<'a: 'a, 'b: 'b, T: Clone, U: Clone, const N: usize>() {} | ^^^ -- -- @@ -360,13 +360,13 @@ LL | reuse foo::<'a, 'b, {}, {}, {}> as bar8; | +++++++ error[E0107]: trait takes 3 lifetime arguments but 0 lifetime arguments were supplied - --> $DIR/generics-gen-args-errors.rs:85:11 + --> $DIR/generics-gen-args-errors.rs:84:11 | LL | reuse Trait::::foo as bar1; | ^^^^^ expected 3 lifetime arguments | note: trait defined here, with 3 lifetime parameters: `'b`, `'c`, `'a` - --> $DIR/generics-gen-args-errors.rs:81:11 + --> $DIR/generics-gen-args-errors.rs:80:11 | LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized { | ^^^^^ -- -- -- @@ -376,7 +376,7 @@ LL | reuse Trait::<'b, 'c, 'a, asd, asd, asd, asd, asd, asdasa>::foo as bar1 | +++++++++++ error[E0107]: trait takes 2 generic arguments but 6 generic arguments were supplied - --> $DIR/generics-gen-args-errors.rs:85:11 + --> $DIR/generics-gen-args-errors.rs:84:11 | LL | reuse Trait::::foo as bar1; | ^^^^^ ----------------------- help: remove the unnecessary generic arguments @@ -384,13 +384,13 @@ LL | reuse Trait::::foo as bar1; | expected 2 generic arguments | note: trait defined here, with 2 generic parameters: `T`, `N` - --> $DIR/generics-gen-args-errors.rs:81:11 + --> $DIR/generics-gen-args-errors.rs:80:11 | LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized { | ^^^^^ - -------------- error[E0107]: trait takes 3 lifetime arguments but 2 lifetime arguments were supplied - --> $DIR/generics-gen-args-errors.rs:95:11 + --> $DIR/generics-gen-args-errors.rs:94:11 | LL | reuse Trait::<'static, 'static>::foo as bar2; | ^^^^^ ------- ------- supplied 2 lifetime arguments @@ -398,7 +398,7 @@ LL | reuse Trait::<'static, 'static>::foo as bar2; | expected 3 lifetime arguments | note: trait defined here, with 3 lifetime parameters: `'b`, `'c`, `'a` - --> $DIR/generics-gen-args-errors.rs:81:11 + --> $DIR/generics-gen-args-errors.rs:80:11 | LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized { | ^^^^^ -- -- -- @@ -408,19 +408,19 @@ LL | reuse Trait::<'static, 'static, 'static>::foo as bar2; | +++++++++ error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions - --> $DIR/generics-gen-args-errors.rs:95:11 + --> $DIR/generics-gen-args-errors.rs:94:11 | LL | reuse Trait::<'static, 'static>::foo as bar2; | ^^^^^ not allowed in type signatures error[E0107]: trait takes 3 lifetime arguments but 0 lifetime arguments were supplied - --> $DIR/generics-gen-args-errors.rs:98:11 + --> $DIR/generics-gen-args-errors.rs:97:11 | LL | reuse Trait::<1, 2, 3, 4, 5>::foo as bar3; | ^^^^^ expected 3 lifetime arguments | note: trait defined here, with 3 lifetime parameters: `'b`, `'c`, `'a` - --> $DIR/generics-gen-args-errors.rs:81:11 + --> $DIR/generics-gen-args-errors.rs:80:11 | LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized { | ^^^^^ -- -- -- @@ -430,7 +430,7 @@ LL | reuse Trait::<'b, 'c, 'a, 1, 2, 3, 4, 5>::foo as bar3; | +++++++++++ error[E0107]: trait takes 2 generic arguments but 5 generic arguments were supplied - --> $DIR/generics-gen-args-errors.rs:98:11 + --> $DIR/generics-gen-args-errors.rs:97:11 | LL | reuse Trait::<1, 2, 3, 4, 5>::foo as bar3; | ^^^^^ --------- help: remove the unnecessary generic arguments @@ -438,19 +438,19 @@ LL | reuse Trait::<1, 2, 3, 4, 5>::foo as bar3; | expected 2 generic arguments | note: trait defined here, with 2 generic parameters: `T`, `N` - --> $DIR/generics-gen-args-errors.rs:81:11 + --> $DIR/generics-gen-args-errors.rs:80:11 | LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized { | ^^^^^ - -------------- error[E0107]: trait takes 3 lifetime arguments but 0 lifetime arguments were supplied - --> $DIR/generics-gen-args-errors.rs:102:11 + --> $DIR/generics-gen-args-errors.rs:101:11 | LL | reuse Trait::<1, 2, true>::foo as bar4; | ^^^^^ expected 3 lifetime arguments | note: trait defined here, with 3 lifetime parameters: `'b`, `'c`, `'a` - --> $DIR/generics-gen-args-errors.rs:81:11 + --> $DIR/generics-gen-args-errors.rs:80:11 | LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized { | ^^^^^ -- -- -- @@ -460,7 +460,7 @@ LL | reuse Trait::<'b, 'c, 'a, 1, 2, true>::foo as bar4; | +++++++++++ error[E0107]: trait takes 2 generic arguments but 3 generic arguments were supplied - --> $DIR/generics-gen-args-errors.rs:102:11 + --> $DIR/generics-gen-args-errors.rs:101:11 | LL | reuse Trait::<1, 2, true>::foo as bar4; | ^^^^^ ------ help: remove the unnecessary generic argument @@ -468,13 +468,13 @@ LL | reuse Trait::<1, 2, true>::foo as bar4; | expected 2 generic arguments | note: trait defined here, with 2 generic parameters: `T`, `N` - --> $DIR/generics-gen-args-errors.rs:81:11 + --> $DIR/generics-gen-args-errors.rs:80:11 | LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized { | ^^^^^ - -------------- error[E0107]: trait takes 3 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/generics-gen-args-errors.rs:106:11 + --> $DIR/generics-gen-args-errors.rs:105:11 | LL | reuse Trait::<'static>::foo as bar5; | ^^^^^ ------- supplied 1 lifetime argument @@ -482,7 +482,7 @@ LL | reuse Trait::<'static>::foo as bar5; | expected 3 lifetime arguments | note: trait defined here, with 3 lifetime parameters: `'b`, `'c`, `'a` - --> $DIR/generics-gen-args-errors.rs:81:11 + --> $DIR/generics-gen-args-errors.rs:80:11 | LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized { | ^^^^^ -- -- -- @@ -492,13 +492,13 @@ LL | reuse Trait::<'static, 'static, 'static>::foo as bar5; | ++++++++++++++++++ error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions - --> $DIR/generics-gen-args-errors.rs:106:11 + --> $DIR/generics-gen-args-errors.rs:105:11 | LL | reuse Trait::<'static>::foo as bar5; | ^^^^^ not allowed in type signatures error[E0107]: trait takes 3 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/generics-gen-args-errors.rs:110:11 + --> $DIR/generics-gen-args-errors.rs:109:11 | LL | reuse Trait::<1, 2, 'static, DDDD>::foo::<1, 2, 3, 4, 5, 6> as bar6; | ^^^^^ - supplied 1 lifetime argument @@ -506,7 +506,7 @@ LL | reuse Trait::<1, 2, 'static, DDDD>::foo::<1, 2, 3, 4, 5, 6> as bar6; | expected 3 lifetime arguments | note: trait defined here, with 3 lifetime parameters: `'b`, `'c`, `'a` - --> $DIR/generics-gen-args-errors.rs:81:11 + --> $DIR/generics-gen-args-errors.rs:80:11 | LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized { | ^^^^^ -- -- -- @@ -516,7 +516,7 @@ LL | reuse Trait::<1, 'static, 'static, 2, 'static, DDDD>::foo::<1, 2, 3, 4, | ++++++++++++++++++ error[E0107]: trait takes 2 generic arguments but 3 generic arguments were supplied - --> $DIR/generics-gen-args-errors.rs:110:11 + --> $DIR/generics-gen-args-errors.rs:109:11 | LL | reuse Trait::<1, 2, 'static, DDDD>::foo::<1, 2, 3, 4, 5, 6> as bar6; | ^^^^^ --------------- help: remove the unnecessary generic argument @@ -524,19 +524,19 @@ LL | reuse Trait::<1, 2, 'static, DDDD>::foo::<1, 2, 3, 4, 5, 6> as bar6; | expected 2 generic arguments | note: trait defined here, with 2 generic parameters: `T`, `N` - --> $DIR/generics-gen-args-errors.rs:81:11 + --> $DIR/generics-gen-args-errors.rs:80:11 | LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized { | ^^^^^ - -------------- error[E0107]: method takes 1 lifetime argument but 0 lifetime arguments were supplied - --> $DIR/generics-gen-args-errors.rs:110:41 + --> $DIR/generics-gen-args-errors.rs:109:41 | LL | reuse Trait::<1, 2, 'static, DDDD>::foo::<1, 2, 3, 4, 5, 6> as bar6; | ^^^ expected 1 lifetime argument | note: method defined here, with 1 lifetime parameter: `'d` - --> $DIR/generics-gen-args-errors.rs:82:12 + --> $DIR/generics-gen-args-errors.rs:81:12 | LL | fn foo<'d: 'd, U, const M: bool>(self) {} | ^^^ -- @@ -546,7 +546,7 @@ LL | reuse Trait::<1, 2, 'static, DDDD>::foo::<'d, 1, 2, 3, 4, 5, 6> as bar6 | +++ error[E0107]: method takes 2 generic arguments but 6 generic arguments were supplied - --> $DIR/generics-gen-args-errors.rs:110:41 + --> $DIR/generics-gen-args-errors.rs:109:41 | LL | reuse Trait::<1, 2, 'static, DDDD>::foo::<1, 2, 3, 4, 5, 6> as bar6; | ^^^ ------------ help: remove the unnecessary generic arguments @@ -554,13 +554,13 @@ LL | reuse Trait::<1, 2, 'static, DDDD>::foo::<1, 2, 3, 4, 5, 6> as bar6; | expected 2 generic arguments | note: method defined here, with 2 generic parameters: `U`, `M` - --> $DIR/generics-gen-args-errors.rs:82:12 + --> $DIR/generics-gen-args-errors.rs:81:12 | LL | fn foo<'d: 'd, U, const M: bool>(self) {} | ^^^ - ------------- error[E0107]: trait takes 3 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/generics-gen-args-errors.rs:117:11 + --> $DIR/generics-gen-args-errors.rs:116:11 | LL | reuse Trait::::foo::<1, 2, 3, _, 6> as bar7; | ^^^^^ ----- supplied 1 lifetime argument @@ -568,7 +568,7 @@ LL | reuse Trait::::foo::<1, 2, 3, _, | expected 3 lifetime arguments | note: trait defined here, with 3 lifetime parameters: `'b`, `'c`, `'a` - --> $DIR/generics-gen-args-errors.rs:81:11 + --> $DIR/generics-gen-args-errors.rs:80:11 | LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized { | ^^^^^ -- -- -- @@ -578,7 +578,7 @@ LL | reuse Trait::: | ++++++++++++++++++ error[E0107]: trait takes 2 generic arguments but 5 generic arguments were supplied - --> $DIR/generics-gen-args-errors.rs:117:11 + --> $DIR/generics-gen-args-errors.rs:116:11 | LL | reuse Trait::::foo::<1, 2, 3, _, 6> as bar7; | ^^^^^ --- help: remove the unnecessary generic argument @@ -586,19 +586,19 @@ LL | reuse Trait::::foo::<1, 2, 3, _, | expected 2 generic arguments | note: trait defined here, with 2 generic parameters: `T`, `N` - --> $DIR/generics-gen-args-errors.rs:81:11 + --> $DIR/generics-gen-args-errors.rs:80:11 | LL | trait Trait<'b, 'c, 'a, T, const N: usize>: Sized { | ^^^^^ - -------------- error[E0107]: method takes 1 lifetime argument but 0 lifetime arguments were supplied - --> $DIR/generics-gen-args-errors.rs:117:59 + --> $DIR/generics-gen-args-errors.rs:116:59 | LL | reuse Trait::::foo::<1, 2, 3, _, 6> as bar7; | ^^^ expected 1 lifetime argument | note: method defined here, with 1 lifetime parameter: `'d` - --> $DIR/generics-gen-args-errors.rs:82:12 + --> $DIR/generics-gen-args-errors.rs:81:12 | LL | fn foo<'d: 'd, U, const M: bool>(self) {} | ^^^ -- @@ -608,7 +608,7 @@ LL | reuse Trait::::foo::<'d, 1, 2, 3 | +++ error[E0107]: method takes 2 generic arguments but 5 generic arguments were supplied - --> $DIR/generics-gen-args-errors.rs:117:59 + --> $DIR/generics-gen-args-errors.rs:116:59 | LL | reuse Trait::::foo::<1, 2, 3, _, 6> as bar7; | ^^^ --------- help: remove the unnecessary generic arguments @@ -616,13 +616,13 @@ LL | reuse Trait::::foo::<1, 2, 3, _, | expected 2 generic arguments | note: method defined here, with 2 generic parameters: `U`, `M` - --> $DIR/generics-gen-args-errors.rs:82:12 + --> $DIR/generics-gen-args-errors.rs:81:12 | LL | fn foo<'d: 'd, U, const M: bool>(self) {} | ^^^ - ------------- error[E0107]: function takes 3 generic arguments but 6 generic arguments were supplied - --> $DIR/generics-gen-args-errors.rs:11:9 + --> $DIR/generics-gen-args-errors.rs:10:9 | LL | bar::<1, 2, 3, 4, 5, 6>(); | ^^^ --------- help: remove the unnecessary generic arguments @@ -630,13 +630,13 @@ LL | bar::<1, 2, 3, 4, 5, 6>(); | expected 3 generic arguments | note: function defined here, with 3 generic parameters: `T`, `U`, `N` - --> $DIR/generics-gen-args-errors.rs:8:18 + --> $DIR/generics-gen-args-errors.rs:7:18 | LL | reuse foo as bar; | --- ^^^ error[E0107]: function takes 2 lifetime arguments but 5 lifetime arguments were supplied - --> $DIR/generics-gen-args-errors.rs:17:9 + --> $DIR/generics-gen-args-errors.rs:16:9 | LL | bar::<'static, 'static, 'static, 'static, 'static>(); | ^^^ --------------------------- help: remove the lifetime arguments @@ -644,19 +644,19 @@ LL | bar::<'static, 'static, 'static, 'static, 'static>(); | expected 2 lifetime arguments | note: function defined here, with 2 lifetime parameters: `'a`, `'b` - --> $DIR/generics-gen-args-errors.rs:8:18 + --> $DIR/generics-gen-args-errors.rs:7:18 | LL | reuse foo as bar; | --- ^^^ error[E0747]: constant provided when a type was expected - --> $DIR/generics-gen-args-errors.rs:20:23 + --> $DIR/generics-gen-args-errors.rs:19:23 | LL | bar::(); | ^ error[E0107]: function takes 3 generic arguments but 5 generic arguments were supplied - --> $DIR/generics-gen-args-errors.rs:25:9 + --> $DIR/generics-gen-args-errors.rs:24:9 | LL | bar::<_, _, _, _, _>(); | ^^^ ------ help: remove the unnecessary generic arguments @@ -664,13 +664,13 @@ LL | bar::<_, _, _, _, _>(); | expected 3 generic arguments | note: function defined here, with 3 generic parameters: `T`, `U`, `N` - --> $DIR/generics-gen-args-errors.rs:8:18 + --> $DIR/generics-gen-args-errors.rs:7:18 | LL | reuse foo as bar; | --- ^^^ error[E0747]: unresolved item provided when a constant was expected - --> $DIR/generics-gen-args-errors.rs:28:25 + --> $DIR/generics-gen-args-errors.rs:27:25 | LL | bar::(); | ^^^ @@ -681,7 +681,7 @@ LL | bar::(); | + + error[E0747]: unresolved item provided when a constant was expected - --> $DIR/generics-gen-args-errors.rs:34:27 + --> $DIR/generics-gen-args-errors.rs:33:27 | LL | reuse foo:: as xd; | ^ @@ -692,7 +692,7 @@ LL | reuse foo:: as xd; | + + error[E0747]: constant provided when a type was expected - --> $DIR/generics-gen-args-errors.rs:75:17 + --> $DIR/generics-gen-args-errors.rs:74:17 | LL | reuse foo::<{}, {}, {}> as bar8; | ^^ diff --git a/tests/ui/delegation/generics/impl-to-free-fn-pass.rs b/tests/ui/delegation/generics/impl-to-free-fn-pass.rs index 3b39a45746758..9ed9d9183fa06 100644 --- a/tests/ui/delegation/generics/impl-to-free-fn-pass.rs +++ b/tests/ui/delegation/generics/impl-to-free-fn-pass.rs @@ -1,6 +1,5 @@ //@ run-pass #![feature(fn_delegation)] -#![allow(incomplete_features)] mod to_reuse { pub fn foo(_: T, y: U) -> U { y } diff --git a/tests/ui/delegation/generics/impl-to-trait-method.rs b/tests/ui/delegation/generics/impl-to-trait-method.rs index 39e32e2ed1500..102e905068e2a 100644 --- a/tests/ui/delegation/generics/impl-to-trait-method.rs +++ b/tests/ui/delegation/generics/impl-to-trait-method.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] mod bounds { trait Trait0 {} diff --git a/tests/ui/delegation/generics/impl-to-trait-method.stderr b/tests/ui/delegation/generics/impl-to-trait-method.stderr index 74ccf61bea703..114ebf48cca06 100644 --- a/tests/ui/delegation/generics/impl-to-trait-method.stderr +++ b/tests/ui/delegation/generics/impl-to-trait-method.stderr @@ -1,16 +1,16 @@ error[E0277]: the trait bound `bounds::S: Trait0` is not satisfied - --> $DIR/impl-to-trait-method.rs:12:19 + --> $DIR/impl-to-trait-method.rs:11:19 | LL | Self: Trait0, | ^^^^^^ unsatisfied trait bound | help: the trait `Trait0` is not implemented for `bounds::S` - --> $DIR/impl-to-trait-method.rs:21:5 + --> $DIR/impl-to-trait-method.rs:20:5 | LL | struct S(F); | ^^^^^^^^ help: this trait has no implementations, consider adding one - --> $DIR/impl-to-trait-method.rs:5:5 + --> $DIR/impl-to-trait-method.rs:4:5 | LL | trait Trait0 {} | ^^^^^^^^^^^^ @@ -20,7 +20,7 @@ LL + #![feature(trivial_bounds)] | error[E0277]: the trait bound `bounds::F: Trait0` is not satisfied - --> $DIR/impl-to-trait-method.rs:24:34 + --> $DIR/impl-to-trait-method.rs:23:34 | LL | reuse Trait1::::foo { &self.0 } | --- ^^^^^^^ unsatisfied trait bound @@ -28,17 +28,17 @@ LL | reuse Trait1::::foo { &self.0 } | required by a bound introduced by this call | help: the trait `Trait0` is not implemented for `bounds::F` - --> $DIR/impl-to-trait-method.rs:18:5 + --> $DIR/impl-to-trait-method.rs:17:5 | LL | struct F; | ^^^^^^^^ help: this trait has no implementations, consider adding one - --> $DIR/impl-to-trait-method.rs:5:5 + --> $DIR/impl-to-trait-method.rs:4:5 | LL | trait Trait0 {} | ^^^^^^^^^^^^ note: required by a bound in `Trait1::foo` - --> $DIR/impl-to-trait-method.rs:12:19 + --> $DIR/impl-to-trait-method.rs:11:19 | LL | fn foo(&self) | --- required by a bound in this associated function @@ -47,7 +47,7 @@ LL | Self: Trait0, | ^^^^^^ required by this bound in `Trait1::foo` error[E0282]: type annotations needed - --> $DIR/impl-to-trait-method.rs:39:22 + --> $DIR/impl-to-trait-method.rs:38:22 | LL | reuse Trait::foo { &self.0 } | ^^^ cannot infer type for type parameter `T` declared on the trait `Trait` diff --git a/tests/ui/delegation/generics/impl-trait-to-trait-method-pass.rs b/tests/ui/delegation/generics/impl-trait-to-trait-method-pass.rs index 72440fe82d44d..00a91bc05cfd6 100644 --- a/tests/ui/delegation/generics/impl-trait-to-trait-method-pass.rs +++ b/tests/ui/delegation/generics/impl-trait-to-trait-method-pass.rs @@ -1,7 +1,6 @@ //@ run-pass #![feature(fn_delegation)] -#![allow(incomplete_features)] use std::iter::{Iterator, Map}; diff --git a/tests/ui/delegation/generics/inherent-impl-to-trait-method-pass.rs b/tests/ui/delegation/generics/inherent-impl-to-trait-method-pass.rs index 6f3bb17897169..8cf0ddbd286d2 100644 --- a/tests/ui/delegation/generics/inherent-impl-to-trait-method-pass.rs +++ b/tests/ui/delegation/generics/inherent-impl-to-trait-method-pass.rs @@ -1,7 +1,6 @@ //@ run-pass #![feature(fn_delegation)] -#![allow(incomplete_features)] trait Trait { fn foo(&self, x: T, y: U) -> (T, U) { diff --git a/tests/ui/delegation/generics/mapping/free-to-free-pass.rs b/tests/ui/delegation/generics/mapping/free-to-free-pass.rs index bfdcb416d6445..c5520350ced60 100644 --- a/tests/ui/delegation/generics/mapping/free-to-free-pass.rs +++ b/tests/ui/delegation/generics/mapping/free-to-free-pass.rs @@ -1,7 +1,6 @@ //@ run-pass #![feature(fn_delegation)] -#![allow(incomplete_features)] //! This is one of the mapping tests, which tests mapping of delegee parent and child //! generic params, whose main goal is to create cases with diff --git a/tests/ui/delegation/generics/mapping/free-to-trait-pass.rs b/tests/ui/delegation/generics/mapping/free-to-trait-pass.rs index 1126881836696..9f4b2b39f5f57 100644 --- a/tests/ui/delegation/generics/mapping/free-to-trait-pass.rs +++ b/tests/ui/delegation/generics/mapping/free-to-trait-pass.rs @@ -1,7 +1,6 @@ //@ run-pass #![feature(fn_delegation)] -#![allow(incomplete_features)] //! This is one of the mapping tests, which tests mapping of delegee parent and child //! generic params, whose main goal is to create cases with diff --git a/tests/ui/delegation/generics/mapping/impl-trait-to-free-pass.rs b/tests/ui/delegation/generics/mapping/impl-trait-to-free-pass.rs index 7abd9e19dde63..b2da7f56b2da7 100644 --- a/tests/ui/delegation/generics/mapping/impl-trait-to-free-pass.rs +++ b/tests/ui/delegation/generics/mapping/impl-trait-to-free-pass.rs @@ -1,7 +1,6 @@ //@ run-pass #![feature(fn_delegation)] -#![allow(incomplete_features)] #![allow(late_bound_lifetime_arguments)] //! This is one of the mapping tests, which tests mapping of delegee parent and child diff --git a/tests/ui/delegation/generics/mapping/impl-trait-to-trait-pass.rs b/tests/ui/delegation/generics/mapping/impl-trait-to-trait-pass.rs index 3dcb359ab2e52..bf7f8655b111e 100644 --- a/tests/ui/delegation/generics/mapping/impl-trait-to-trait-pass.rs +++ b/tests/ui/delegation/generics/mapping/impl-trait-to-trait-pass.rs @@ -1,7 +1,6 @@ //@ run-pass #![feature(fn_delegation)] -#![allow(incomplete_features)] #![allow(late_bound_lifetime_arguments)] //! This is one of the mapping tests, which tests mapping of delegee parent and child diff --git a/tests/ui/delegation/generics/mapping/inherent-impl-to-free-pass.rs b/tests/ui/delegation/generics/mapping/inherent-impl-to-free-pass.rs index 1e08e155c5de8..f7149dd9de037 100644 --- a/tests/ui/delegation/generics/mapping/inherent-impl-to-free-pass.rs +++ b/tests/ui/delegation/generics/mapping/inherent-impl-to-free-pass.rs @@ -1,7 +1,6 @@ //@ run-pass #![feature(fn_delegation)] -#![allow(incomplete_features)] //! This is one of the mapping tests, which tests mapping of delegee parent and child //! generic params, whose main goal is to create cases with diff --git a/tests/ui/delegation/generics/mapping/inherent-impl-to-trait-pass.rs b/tests/ui/delegation/generics/mapping/inherent-impl-to-trait-pass.rs index bf4d1a7ca2cb0..a28ca88c0ce31 100644 --- a/tests/ui/delegation/generics/mapping/inherent-impl-to-trait-pass.rs +++ b/tests/ui/delegation/generics/mapping/inherent-impl-to-trait-pass.rs @@ -1,7 +1,6 @@ //@ run-pass #![feature(fn_delegation)] -#![allow(incomplete_features)] #![allow(late_bound_lifetime_arguments)] //! This is one of the mapping tests, which tests mapping of delegee parent and child diff --git a/tests/ui/delegation/generics/mapping/trait-to-free-pass.rs b/tests/ui/delegation/generics/mapping/trait-to-free-pass.rs index 12edc3b72facd..452e0ee5cfddb 100644 --- a/tests/ui/delegation/generics/mapping/trait-to-free-pass.rs +++ b/tests/ui/delegation/generics/mapping/trait-to-free-pass.rs @@ -1,7 +1,6 @@ //@ run-pass #![feature(fn_delegation)] -#![allow(incomplete_features)] //! This is one of the mapping tests, which tests mapping of delegee parent and child //! generic params, whose main goal is to create cases with diff --git a/tests/ui/delegation/generics/mapping/trait-to-trait-pass.rs b/tests/ui/delegation/generics/mapping/trait-to-trait-pass.rs index bcc1369aa4408..aac835c904637 100644 --- a/tests/ui/delegation/generics/mapping/trait-to-trait-pass.rs +++ b/tests/ui/delegation/generics/mapping/trait-to-trait-pass.rs @@ -1,7 +1,6 @@ //@ run-pass #![feature(fn_delegation)] -#![allow(incomplete_features)] #![allow(late_bound_lifetime_arguments)] //! This is one of the mapping tests, which tests mapping of delegee parent and child diff --git a/tests/ui/delegation/generics/stability-implications-non-local-defid.rs b/tests/ui/delegation/generics/stability-implications-non-local-defid.rs index f8b7874f28068..0fb04acd488e5 100644 --- a/tests/ui/delegation/generics/stability-implications-non-local-defid.rs +++ b/tests/ui/delegation/generics/stability-implications-non-local-defid.rs @@ -1,7 +1,6 @@ //@ check-pass #![feature(fn_delegation)] -#![allow(incomplete_features)] #![feature(staged_api)] #![unstable(feature = "foo", issue = "none")] diff --git a/tests/ui/delegation/generics/synth-params-ice-143498.rs b/tests/ui/delegation/generics/synth-params-ice-143498.rs index 652059b37ec6c..ca6d2d5c193b0 100644 --- a/tests/ui/delegation/generics/synth-params-ice-143498.rs +++ b/tests/ui/delegation/generics/synth-params-ice-143498.rs @@ -15,7 +15,6 @@ #![feature(iter_partition_in_place)] #![feature(trusted_random_access)] #![feature(try_find)] -#![allow(incomplete_features)] impl X { //~^ ERROR: cannot find type `X` in this scope diff --git a/tests/ui/delegation/generics/synth-params-ice-143498.stderr b/tests/ui/delegation/generics/synth-params-ice-143498.stderr index 14b03991d9e62..17154f9779475 100644 --- a/tests/ui/delegation/generics/synth-params-ice-143498.stderr +++ b/tests/ui/delegation/generics/synth-params-ice-143498.stderr @@ -1,17 +1,17 @@ error[E0425]: cannot find type `X` in this scope - --> $DIR/synth-params-ice-143498.rs:20:6 + --> $DIR/synth-params-ice-143498.rs:19:6 | LL | impl X { | ^ not found in this scope error[E0575]: expected method or associated constant, found associated type `Iterator::Item` - --> $DIR/synth-params-ice-143498.rs:22:10 + --> $DIR/synth-params-ice-143498.rs:21:10 | LL | reuse< std::fmt::Debug as Iterator >::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a method or associated constant error[E0782]: expected a type, found a trait - --> $DIR/synth-params-ice-143498.rs:22:12 + --> $DIR/synth-params-ice-143498.rs:21:12 | LL | reuse< std::fmt::Debug as Iterator >::*; | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/delegation/generics/trait-impl-wrong-args-count.rs b/tests/ui/delegation/generics/trait-impl-wrong-args-count.rs index 7cb98ff307fd6..4073e5ce88607 100644 --- a/tests/ui/delegation/generics/trait-impl-wrong-args-count.rs +++ b/tests/ui/delegation/generics/trait-impl-wrong-args-count.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] // Testing delegation from trait impl to free functions. mod test_1 { diff --git a/tests/ui/delegation/generics/trait-impl-wrong-args-count.stderr b/tests/ui/delegation/generics/trait-impl-wrong-args-count.stderr index 9234771ca11f3..09281768bbf73 100644 --- a/tests/ui/delegation/generics/trait-impl-wrong-args-count.stderr +++ b/tests/ui/delegation/generics/trait-impl-wrong-args-count.stderr @@ -1,5 +1,5 @@ error[E0107]: function takes at most 2 generic arguments but 3 generic arguments were supplied - --> $DIR/trait-impl-wrong-args-count.rs:25:25 + --> $DIR/trait-impl-wrong-args-count.rs:24:25 | LL | reuse to_reuse::bar; | ^^^ @@ -8,31 +8,31 @@ LL | reuse to_reuse::bar; | help: remove the unnecessary generic argument | note: function defined here, with at most 2 generic parameters: `A`, `B` - --> $DIR/trait-impl-wrong-args-count.rs:7:16 + --> $DIR/trait-impl-wrong-args-count.rs:6:16 | LL | pub fn bar<'a: 'a, 'b: 'b, A, B>(x: &super::XX) {} | ^^^ - - error[E0107]: function takes 0 generic arguments but 3 generic arguments were supplied - --> $DIR/trait-impl-wrong-args-count.rs:28:25 + --> $DIR/trait-impl-wrong-args-count.rs:27:25 | LL | reuse to_reuse::bar1; | ^^^^ expected 0 generic arguments | note: function defined here, with 0 generic parameters - --> $DIR/trait-impl-wrong-args-count.rs:8:16 + --> $DIR/trait-impl-wrong-args-count.rs:7:16 | LL | pub fn bar1(x: &super::XX) {} | ^^^^ error[E0284]: type annotations needed - --> $DIR/trait-impl-wrong-args-count.rs:31:25 + --> $DIR/trait-impl-wrong-args-count.rs:30:25 | LL | reuse to_reuse::bar2; | ^^^^ cannot infer the value of the const parameter `X` declared on the function `bar2` | note: required by a const generic parameter in `bar2` - --> $DIR/trait-impl-wrong-args-count.rs:9:39 + --> $DIR/trait-impl-wrong-args-count.rs:8:39 | LL | pub fn bar2(x: &super::XX) {} | ^^^^^^^^^^^^^^ required by this const generic parameter in `bar2` @@ -42,13 +42,13 @@ LL | reuse to_reuse::bar2::; | ++++++++++++++++++++++++++ error[E0284]: type annotations needed - --> $DIR/trait-impl-wrong-args-count.rs:31:25 + --> $DIR/trait-impl-wrong-args-count.rs:30:25 | LL | reuse to_reuse::bar2; | ^^^^ cannot infer the value of the const parameter `Y` declared on the function `bar2` | note: required by a const generic parameter in `bar2` - --> $DIR/trait-impl-wrong-args-count.rs:9:55 + --> $DIR/trait-impl-wrong-args-count.rs:8:55 | LL | pub fn bar2(x: &super::XX) {} | ^^^^^^^^^^^^^ required by this const generic parameter in `bar2` @@ -58,13 +58,13 @@ LL | reuse to_reuse::bar2::; | ++++++++++++++++++++++++++ error[E0107]: missing generics for trait `test_2::Trait1` - --> $DIR/trait-impl-wrong-args-count.rs:61:21 + --> $DIR/trait-impl-wrong-args-count.rs:60:21 | LL | reuse ::bar; | ^^^^^^ expected 2 generic arguments | note: trait defined here, with 2 generic parameters: `A`, `B` - --> $DIR/trait-impl-wrong-args-count.rs:52:11 + --> $DIR/trait-impl-wrong-args-count.rs:51:11 | LL | trait Trait1 { | ^^^^^^ - - @@ -74,13 +74,13 @@ LL | reuse >::bar; | ++++++ error[E0107]: missing generics for trait `test_2::Trait1` - --> $DIR/trait-impl-wrong-args-count.rs:68:21 + --> $DIR/trait-impl-wrong-args-count.rs:67:21 | LL | reuse ::bar::<'static, u32, u32, 1> as bar3; | ^^^^^^ expected 2 generic arguments | note: trait defined here, with 2 generic parameters: `A`, `B` - --> $DIR/trait-impl-wrong-args-count.rs:52:11 + --> $DIR/trait-impl-wrong-args-count.rs:51:11 | LL | trait Trait1 { | ^^^^^^ - - @@ -90,13 +90,13 @@ LL | reuse >::bar::<'static, u32, u32, 1> as bar3; | ++++++ error[E0107]: missing generics for trait `test_2::Trait1` - --> $DIR/trait-impl-wrong-args-count.rs:71:21 + --> $DIR/trait-impl-wrong-args-count.rs:70:21 | LL | reuse ::bar as bar4; | ^^^^^^ expected 2 generic arguments | note: trait defined here, with 2 generic parameters: `A`, `B` - --> $DIR/trait-impl-wrong-args-count.rs:52:11 + --> $DIR/trait-impl-wrong-args-count.rs:51:11 | LL | trait Trait1 { | ^^^^^^ - - @@ -106,37 +106,37 @@ LL | reuse >::bar as bar4; | ++++++ error[E0107]: associated function takes 0 generic arguments but 3 generic arguments were supplied - --> $DIR/trait-impl-wrong-args-count.rs:96:40 + --> $DIR/trait-impl-wrong-args-count.rs:95:40 | LL | reuse >::bar; | ^^^ expected 0 generic arguments | note: associated function defined here, with 0 generic parameters - --> $DIR/trait-impl-wrong-args-count.rs:87:12 + --> $DIR/trait-impl-wrong-args-count.rs:86:12 | LL | fn bar() {} | ^^^ error[E0107]: associated function takes 0 generic arguments but 3 generic arguments were supplied - --> $DIR/trait-impl-wrong-args-count.rs:99:40 + --> $DIR/trait-impl-wrong-args-count.rs:98:40 | LL | reuse >::bar as bar1; | ^^^ expected 0 generic arguments | note: associated function defined here, with 0 generic parameters - --> $DIR/trait-impl-wrong-args-count.rs:87:12 + --> $DIR/trait-impl-wrong-args-count.rs:86:12 | LL | fn bar() {} | ^^^ error[E0282]: type annotations needed - --> $DIR/trait-impl-wrong-args-count.rs:102:40 + --> $DIR/trait-impl-wrong-args-count.rs:101:40 | LL | reuse >::foo as bar2; | ^^^ cannot infer type of the type parameter `X` declared on the associated function `foo` error[E0107]: associated function takes at most 2 generic arguments but 3 generic arguments were supplied - --> $DIR/trait-impl-wrong-args-count.rs:105:40 + --> $DIR/trait-impl-wrong-args-count.rs:104:40 | LL | reuse >::foo as bar3; | ^^^ @@ -145,7 +145,7 @@ LL | reuse >::foo as bar3; | help: remove the unnecessary generic argument | note: associated function defined here, with at most 2 generic parameters: `X`, `Y` - --> $DIR/trait-impl-wrong-args-count.rs:88:12 + --> $DIR/trait-impl-wrong-args-count.rs:87:12 | LL | fn foo() {} | ^^^ - - diff --git a/tests/ui/delegation/generics/trait-method-to-other-pass.rs b/tests/ui/delegation/generics/trait-method-to-other-pass.rs index 2094705a05ce6..ac2c78104dc0d 100644 --- a/tests/ui/delegation/generics/trait-method-to-other-pass.rs +++ b/tests/ui/delegation/generics/trait-method-to-other-pass.rs @@ -1,7 +1,6 @@ //@ run-pass #![feature(fn_delegation)] -#![allow(incomplete_features)] mod to_reuse { pub fn foo(x: T) -> T { x } diff --git a/tests/ui/delegation/generics/unresolved-segment-ice-153389.rs b/tests/ui/delegation/generics/unresolved-segment-ice-153389.rs index 431184923887d..6ec229d9635e0 100644 --- a/tests/ui/delegation/generics/unresolved-segment-ice-153389.rs +++ b/tests/ui/delegation/generics/unresolved-segment-ice-153389.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] trait Trait{ fn bar(); diff --git a/tests/ui/delegation/generics/unresolved-segment-ice-153389.stderr b/tests/ui/delegation/generics/unresolved-segment-ice-153389.stderr index b69917117fce9..6c65da87f3468 100644 --- a/tests/ui/delegation/generics/unresolved-segment-ice-153389.stderr +++ b/tests/ui/delegation/generics/unresolved-segment-ice-153389.stderr @@ -1,5 +1,5 @@ error[E0425]: cannot find function `missing` in this scope - --> $DIR/unresolved-segment-ice-153389.rs:9:11 + --> $DIR/unresolved-segment-ice-153389.rs:8:11 | LL | reuse missing::<> as bar; | ^^^^^^^ not found in this scope diff --git a/tests/ui/delegation/glob-bad-path.rs b/tests/ui/delegation/glob-bad-path.rs index 067cb651777e1..71009a51b3cb3 100644 --- a/tests/ui/delegation/glob-bad-path.rs +++ b/tests/ui/delegation/glob-bad-path.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] trait Trait {} struct S; diff --git a/tests/ui/delegation/glob-bad-path.stderr b/tests/ui/delegation/glob-bad-path.stderr index 7e92bc045bbd5..f14f8a54ae4cb 100644 --- a/tests/ui/delegation/glob-bad-path.stderr +++ b/tests/ui/delegation/glob-bad-path.stderr @@ -1,11 +1,11 @@ error: expected trait, found struct `S` - --> $DIR/glob-bad-path.rs:9:11 + --> $DIR/glob-bad-path.rs:8:11 | LL | reuse S::*; | ^ not a trait error[E0433]: cannot find module or crate `unresolved` in this scope - --> $DIR/glob-bad-path.rs:8:11 + --> $DIR/glob-bad-path.rs:7:11 | LL | reuse unresolved::*; | ^^^^^^^^^^ use of unresolved module or unlinked crate `unresolved` diff --git a/tests/ui/delegation/glob-glob-conflict.rs b/tests/ui/delegation/glob-glob-conflict.rs index c1cd3f703e07f..beea96d167c39 100644 --- a/tests/ui/delegation/glob-glob-conflict.rs +++ b/tests/ui/delegation/glob-glob-conflict.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] trait Trait1 { fn method(&self) -> u8; diff --git a/tests/ui/delegation/glob-glob-conflict.stderr b/tests/ui/delegation/glob-glob-conflict.stderr index f55ee333630c6..4ada3eb0efa69 100644 --- a/tests/ui/delegation/glob-glob-conflict.stderr +++ b/tests/ui/delegation/glob-glob-conflict.stderr @@ -1,5 +1,5 @@ error[E0201]: duplicate definitions with name `method`: - --> $DIR/glob-glob-conflict.rs:27:5 + --> $DIR/glob-glob-conflict.rs:26:5 | LL | fn method(&self) -> u8; | ----------------------- item in trait @@ -10,7 +10,7 @@ LL | reuse Trait2::*; | ^^^^^^^^^^^^^^^^ duplicate definition error[E0201]: duplicate definitions with name `method`: - --> $DIR/glob-glob-conflict.rs:33:5 + --> $DIR/glob-glob-conflict.rs:32:5 | LL | fn method(&self) -> u8; | ----------------------- item in trait @@ -21,13 +21,13 @@ LL | reuse Trait1::*; | ^^^^^^^^^^^^^^^^ duplicate definition error[E0061]: this function takes 1 argument but 0 arguments were supplied - --> $DIR/glob-glob-conflict.rs:27:19 + --> $DIR/glob-glob-conflict.rs:26:19 | LL | reuse Trait2::*; | ^ argument #1 of type `&_` is missing | note: method defined here - --> $DIR/glob-glob-conflict.rs:8:8 + --> $DIR/glob-glob-conflict.rs:7:8 | LL | fn method(&self) -> u8; | ^^^^^^ ---- @@ -37,7 +37,7 @@ LL | reuse Trait2::*(/* value */); | +++++++++++++ error[E0308]: mismatched types - --> $DIR/glob-glob-conflict.rs:27:19 + --> $DIR/glob-glob-conflict.rs:26:19 | LL | reuse Trait2::*; | ^- help: consider using a semicolon here: `;` @@ -46,13 +46,13 @@ LL | reuse Trait2::*; | expected `()` because of default return type error[E0061]: this function takes 1 argument but 0 arguments were supplied - --> $DIR/glob-glob-conflict.rs:33:19 + --> $DIR/glob-glob-conflict.rs:32:19 | LL | reuse Trait1::*; | ^ argument #1 of type `&_` is missing | note: method defined here - --> $DIR/glob-glob-conflict.rs:5:8 + --> $DIR/glob-glob-conflict.rs:4:8 | LL | fn method(&self) -> u8; | ^^^^^^ ---- @@ -62,7 +62,7 @@ LL | reuse Trait1::*(/* value */); | +++++++++++++ error[E0308]: mismatched types - --> $DIR/glob-glob-conflict.rs:33:19 + --> $DIR/glob-glob-conflict.rs:32:19 | LL | reuse Trait1::*; | ^- help: consider using a semicolon here: `;` diff --git a/tests/ui/delegation/glob-glob.rs b/tests/ui/delegation/glob-glob.rs index ef7f9a15e1955..d574f8d01e20a 100644 --- a/tests/ui/delegation/glob-glob.rs +++ b/tests/ui/delegation/glob-glob.rs @@ -1,7 +1,6 @@ //@ check-pass #![feature(fn_delegation)] -#![allow(incomplete_features)] mod inner { pub trait TraitFoo { diff --git a/tests/ui/delegation/glob-non-fn.rs b/tests/ui/delegation/glob-non-fn.rs index ab312d51f4981..14a78e7b65e25 100644 --- a/tests/ui/delegation/glob-non-fn.rs +++ b/tests/ui/delegation/glob-non-fn.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] trait Trait { fn method(&self); diff --git a/tests/ui/delegation/glob-non-fn.stderr b/tests/ui/delegation/glob-non-fn.stderr index f63c8e88c6fae..3353290fc5b10 100644 --- a/tests/ui/delegation/glob-non-fn.stderr +++ b/tests/ui/delegation/glob-non-fn.stderr @@ -1,5 +1,5 @@ error[E0324]: item `CONST` is an associated method, which doesn't match its trait `Trait` - --> $DIR/glob-non-fn.rs:30:5 + --> $DIR/glob-non-fn.rs:29:5 | LL | const CONST: u8; | ---------------- item in trait @@ -8,7 +8,7 @@ LL | reuse Trait::* { &self.0 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ does not match trait error[E0324]: item `Type` is an associated method, which doesn't match its trait `Trait` - --> $DIR/glob-non-fn.rs:30:5 + --> $DIR/glob-non-fn.rs:29:5 | LL | type Type; | ---------- item in trait @@ -17,7 +17,7 @@ LL | reuse Trait::* { &self.0 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ does not match trait error[E0201]: duplicate definitions with name `method`: - --> $DIR/glob-non-fn.rs:30:5 + --> $DIR/glob-non-fn.rs:29:5 | LL | fn method(&self); | ----------------- item in trait @@ -29,19 +29,19 @@ LL | reuse Trait::* { &self.0 } | previous definition here error[E0423]: expected function, found associated constant `Trait::CONST` - --> $DIR/glob-non-fn.rs:30:11 + --> $DIR/glob-non-fn.rs:29:11 | LL | reuse Trait::* { &self.0 } | ^^^^^ not a function error[E0423]: expected function, found associated type `Trait::Type` - --> $DIR/glob-non-fn.rs:30:11 + --> $DIR/glob-non-fn.rs:29:11 | LL | reuse Trait::* { &self.0 } | ^^^^^ not a function error[E0046]: not all trait items implemented, missing: `CONST`, `Type`, `method` - --> $DIR/glob-non-fn.rs:29:1 + --> $DIR/glob-non-fn.rs:28:1 | LL | const CONST: u8; | --------------- `CONST` from trait diff --git a/tests/ui/delegation/glob-non-impl.rs b/tests/ui/delegation/glob-non-impl.rs index e3a4061fb15a6..4dec76b680347 100644 --- a/tests/ui/delegation/glob-non-impl.rs +++ b/tests/ui/delegation/glob-non-impl.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] trait Trait { fn method() {} diff --git a/tests/ui/delegation/glob-non-impl.stderr b/tests/ui/delegation/glob-non-impl.stderr index ea458fd5e90fb..8a9a4983f3253 100644 --- a/tests/ui/delegation/glob-non-impl.stderr +++ b/tests/ui/delegation/glob-non-impl.stderr @@ -1,23 +1,23 @@ error: delegation is not supported in `extern` blocks - --> $DIR/glob-non-impl.rs:15:5 + --> $DIR/glob-non-impl.rs:14:5 | LL | reuse Trait::*; | ^^^^^^^^^^^^^^^ error: glob delegation is only supported in impls - --> $DIR/glob-non-impl.rs:8:1 + --> $DIR/glob-non-impl.rs:7:1 | LL | reuse Trait::*; | ^^^^^^^^^^^^^^^ error: glob delegation is only supported in impls - --> $DIR/glob-non-impl.rs:11:5 + --> $DIR/glob-non-impl.rs:10:5 | LL | reuse Trait::*; | ^^^^^^^^^^^^^^^ error: glob delegation is only supported in impls - --> $DIR/glob-non-impl.rs:19:5 + --> $DIR/glob-non-impl.rs:18:5 | LL | reuse Trait::*; | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/delegation/glob-override.rs b/tests/ui/delegation/glob-override.rs index 1d0dcf1df6e60..13c5fbb2d5c5c 100644 --- a/tests/ui/delegation/glob-override.rs +++ b/tests/ui/delegation/glob-override.rs @@ -1,7 +1,6 @@ //@ check-pass #![feature(fn_delegation)] -#![allow(incomplete_features)] trait Trait { fn foo(&self) -> u8; diff --git a/tests/ui/delegation/glob-traitless-qpath.rs b/tests/ui/delegation/glob-traitless-qpath.rs index abf4b3180ed21..90309f7bf55a3 100644 --- a/tests/ui/delegation/glob-traitless-qpath.rs +++ b/tests/ui/delegation/glob-traitless-qpath.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] struct S; diff --git a/tests/ui/delegation/glob-traitless-qpath.stderr b/tests/ui/delegation/glob-traitless-qpath.stderr index e3257de347a76..3c306f145dd79 100644 --- a/tests/ui/delegation/glob-traitless-qpath.stderr +++ b/tests/ui/delegation/glob-traitless-qpath.stderr @@ -1,11 +1,11 @@ error: qualified path without a trait in glob delegation - --> $DIR/glob-traitless-qpath.rs:7:5 + --> $DIR/glob-traitless-qpath.rs:6:5 | LL | reuse ::*; | ^^^^^^^^^^^^^^ error: qualified path without a trait in glob delegation - --> $DIR/glob-traitless-qpath.rs:8:5 + --> $DIR/glob-traitless-qpath.rs:7:5 | LL | reuse <()>::*; | ^^^^^^^^^^^^^^ diff --git a/tests/ui/delegation/glob.rs b/tests/ui/delegation/glob.rs index 5bc80c1664897..dce4abea5b552 100644 --- a/tests/ui/delegation/glob.rs +++ b/tests/ui/delegation/glob.rs @@ -1,7 +1,6 @@ //@ check-pass #![feature(fn_delegation)] -#![allow(incomplete_features)] trait Trait { fn foo(&self) -> u8; diff --git a/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155125.stderr b/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155125.stderr index e8a32e340f3e5..d2f0e87ecb593 100644 --- a/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155125.stderr +++ b/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155125.stderr @@ -1,5 +1,5 @@ error[E0428]: the name `foo` is defined multiple times - --> $DIR/hir-crate-items-before-lowering-ices.rs:13:17 + --> $DIR/hir-crate-items-before-lowering-ices.rs:12:17 | LL | fn foo() {} | -------- previous definition of the value `foo` here @@ -9,7 +9,7 @@ LL | reuse foo; = note: `foo` must be defined only once in the value namespace of this block error: complex const arguments must be placed inside of a `const` block - --> $DIR/hir-crate-items-before-lowering-ices.rs:11:13 + --> $DIR/hir-crate-items-before-lowering-ices.rs:10:13 | LL | / { LL | | fn foo() {} diff --git a/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155127.stderr b/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155127.stderr index 132e4e3034c4e..8c24631c27fb6 100644 --- a/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155127.stderr +++ b/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155127.stderr @@ -1,5 +1,5 @@ error: `#[deprecated]` attribute cannot be used on delegations - --> $DIR/hir-crate-items-before-lowering-ices.rs:27:9 + --> $DIR/hir-crate-items-before-lowering-ices.rs:26:9 | LL | #[deprecated] | ^^^^^^^^^^^^^ diff --git a/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155128.stderr b/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155128.stderr index 0a1b2c5a472c7..833b0869002e2 100644 --- a/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155128.stderr +++ b/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155128.stderr @@ -1,5 +1,5 @@ error[E0061]: this function takes 0 arguments but 1 argument was supplied - --> $DIR/hir-crate-items-before-lowering-ices.rs:37:11 + --> $DIR/hir-crate-items-before-lowering-ices.rs:36:11 | LL | reuse a as b { | ___________^______- @@ -9,7 +9,7 @@ LL | | } | |_____- unexpected argument of type `fn() {foo::<_>}` | note: function defined here - --> $DIR/hir-crate-items-before-lowering-ices.rs:35:8 + --> $DIR/hir-crate-items-before-lowering-ices.rs:34:8 | LL | fn a() {} | ^ diff --git a/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155164.stderr b/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155164.stderr index 34d1a92ccd225..8590881e67836 100644 --- a/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155164.stderr +++ b/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155164.stderr @@ -1,5 +1,5 @@ error: complex const arguments must be placed inside of a `const` block - --> $DIR/hir-crate-items-before-lowering-ices.rs:47:13 + --> $DIR/hir-crate-items-before-lowering-ices.rs:46:13 | LL | / { LL | | diff --git a/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155202.stderr b/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155202.stderr index 28f045ca69442..abe70cb82f3b3 100644 --- a/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155202.stderr +++ b/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155202.stderr @@ -1,11 +1,11 @@ error[E0425]: cannot find value `async` in this scope - --> $DIR/hir-crate-items-before-lowering-ices.rs:66:13 + --> $DIR/hir-crate-items-before-lowering-ices.rs:65:13 | LL | async || {}; | ^^^^^ not found in this scope error[E0308]: mismatched types - --> $DIR/hir-crate-items-before-lowering-ices.rs:66:22 + --> $DIR/hir-crate-items-before-lowering-ices.rs:65:22 | LL | async || {}; | ^^ expected `bool`, found `()` diff --git a/tests/ui/delegation/hir-crate-items-before-lowering-ices.rs b/tests/ui/delegation/hir-crate-items-before-lowering-ices.rs index 6c16a1ae22d38..c223d5d4a5adc 100644 --- a/tests/ui/delegation/hir-crate-items-before-lowering-ices.rs +++ b/tests/ui/delegation/hir-crate-items-before-lowering-ices.rs @@ -1,7 +1,6 @@ //@ revisions: ice_155125 ice_155127 ice_155128 ice_155164 ice_155202 #![feature(min_generic_const_args, fn_delegation)] -#![allow(incomplete_features)] #[cfg(ice_155125)] mod ice_155125 { diff --git a/tests/ui/delegation/ice-isssue-128190.rs b/tests/ui/delegation/ice-isssue-128190.rs index dab3bbee663cb..2917930634d85 100644 --- a/tests/ui/delegation/ice-isssue-128190.rs +++ b/tests/ui/delegation/ice-isssue-128190.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] fn a(&self) {} //~^ ERROR `self` parameter is only allowed in associated functions diff --git a/tests/ui/delegation/ice-isssue-128190.stderr b/tests/ui/delegation/ice-isssue-128190.stderr index 18f676642c2b9..f3e539a8dee3c 100644 --- a/tests/ui/delegation/ice-isssue-128190.stderr +++ b/tests/ui/delegation/ice-isssue-128190.stderr @@ -1,5 +1,5 @@ error: `self` parameter is only allowed in associated functions - --> $DIR/ice-isssue-128190.rs:4:6 + --> $DIR/ice-isssue-128190.rs:3:6 | LL | fn a(&self) {} | ^^^^^ not semantically valid as function parameter diff --git a/tests/ui/delegation/ice-issue-122550.rs b/tests/ui/delegation/ice-issue-122550.rs index 92c0dda960543..54a9a9181676b 100644 --- a/tests/ui/delegation/ice-issue-122550.rs +++ b/tests/ui/delegation/ice-issue-122550.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] trait Trait { fn description(&self) -> &str {} diff --git a/tests/ui/delegation/ice-issue-122550.stderr b/tests/ui/delegation/ice-issue-122550.stderr index 01355c8ad921c..42fc1e29bb190 100644 --- a/tests/ui/delegation/ice-issue-122550.stderr +++ b/tests/ui/delegation/ice-issue-122550.stderr @@ -1,28 +1,28 @@ error[E0308]: mismatched types - --> $DIR/ice-issue-122550.rs:5:35 + --> $DIR/ice-issue-122550.rs:4:35 | LL | fn description(&self) -> &str {} | ^^ expected `&str`, found `()` error[E0277]: the trait bound `S: Trait` is not satisfied - --> $DIR/ice-issue-122550.rs:13:12 + --> $DIR/ice-issue-122550.rs:12:12 | LL | reuse ::description { &self.0 } | ^ unsatisfied trait bound | help: the trait `Trait` is not implemented for `S` - --> $DIR/ice-issue-122550.rs:10:1 + --> $DIR/ice-issue-122550.rs:9:1 | LL | struct S(F); | ^^^^^^^^ help: this trait has no implementations, consider adding one - --> $DIR/ice-issue-122550.rs:4:1 + --> $DIR/ice-issue-122550.rs:3:1 | LL | trait Trait { | ^^^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/ice-issue-122550.rs:13:39 + --> $DIR/ice-issue-122550.rs:12:39 | LL | reuse ::description { &self.0 } | ----------- ^^^^^^^ expected `&S`, found `&F` @@ -32,7 +32,7 @@ LL | reuse ::description { &self.0 } = note: expected reference `&S` found reference `&F` note: method defined here - --> $DIR/ice-issue-122550.rs:5:8 + --> $DIR/ice-issue-122550.rs:4:8 | LL | fn description(&self) -> &str {} | ^^^^^^^^^^^ ----- diff --git a/tests/ui/delegation/ice-issue-124342.rs b/tests/ui/delegation/ice-issue-124342.rs index ad62f6bd54af9..b5e7d9386d33d 100644 --- a/tests/ui/delegation/ice-issue-124342.rs +++ b/tests/ui/delegation/ice-issue-124342.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] mod to_reuse {} diff --git a/tests/ui/delegation/ice-issue-124342.stderr b/tests/ui/delegation/ice-issue-124342.stderr index f9a3684d64932..19d75e494cafe 100644 --- a/tests/ui/delegation/ice-issue-124342.stderr +++ b/tests/ui/delegation/ice-issue-124342.stderr @@ -1,11 +1,11 @@ error[E0425]: cannot find function `foo` in module `to_reuse` - --> $DIR/ice-issue-124342.rs:7:21 + --> $DIR/ice-issue-124342.rs:6:21 | LL | reuse to_reuse::foo { foo } | ^^^ not found in `to_reuse` error[E0425]: cannot find value `foo` in this scope - --> $DIR/ice-issue-124342.rs:7:27 + --> $DIR/ice-issue-124342.rs:6:27 | LL | reuse to_reuse::foo { foo } | ^^^ diff --git a/tests/ui/delegation/ice-issue-124347.rs b/tests/ui/delegation/ice-issue-124347.rs index 2716347118341..56e3a21baf162 100644 --- a/tests/ui/delegation/ice-issue-124347.rs +++ b/tests/ui/delegation/ice-issue-124347.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] trait Trait { reuse Trait::foo { &self.0 } diff --git a/tests/ui/delegation/ice-issue-124347.stderr b/tests/ui/delegation/ice-issue-124347.stderr index 90ad839e662c0..9c0125d3a0852 100644 --- a/tests/ui/delegation/ice-issue-124347.stderr +++ b/tests/ui/delegation/ice-issue-124347.stderr @@ -1,23 +1,23 @@ error: failed to resolve delegation callee - --> $DIR/ice-issue-124347.rs:5:18 + --> $DIR/ice-issue-124347.rs:4:18 | LL | reuse Trait::foo { &self.0 } | ^^^ error: failed to resolve delegation callee - --> $DIR/ice-issue-124347.rs:10:7 + --> $DIR/ice-issue-124347.rs:9:7 | LL | reuse foo; | ^^^ error[E0061]: this function takes 0 arguments but 1 argument was supplied - --> $DIR/ice-issue-124347.rs:5:18 + --> $DIR/ice-issue-124347.rs:4:18 | LL | reuse Trait::foo { &self.0 } | ^^^ ------- unexpected argument | note: associated function defined here - --> $DIR/ice-issue-124347.rs:5:18 + --> $DIR/ice-issue-124347.rs:4:18 | LL | reuse Trait::foo { &self.0 } | ^^^ @@ -28,7 +28,7 @@ LL + reuse Trait::fo&self.0 } | warning: function cannot return without recursing - --> $DIR/ice-issue-124347.rs:10:7 + --> $DIR/ice-issue-124347.rs:9:7 | LL | reuse foo; | ^^^ diff --git a/tests/ui/delegation/ice-issue-138362.rs b/tests/ui/delegation/ice-issue-138362.rs index c30660098555b..9626696530a5d 100644 --- a/tests/ui/delegation/ice-issue-138362.rs +++ b/tests/ui/delegation/ice-issue-138362.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] trait HasSelf { fn method(self); diff --git a/tests/ui/delegation/ice-issue-138362.stderr b/tests/ui/delegation/ice-issue-138362.stderr index 9feddc9feaec3..7acb1f1962129 100644 --- a/tests/ui/delegation/ice-issue-138362.stderr +++ b/tests/ui/delegation/ice-issue-138362.stderr @@ -1,11 +1,11 @@ error[E0061]: this function takes 1 argument but 0 arguments were supplied - --> $DIR/ice-issue-138362.rs:11:20 + --> $DIR/ice-issue-138362.rs:10:20 | LL | reuse HasSelf::method; | ^^^^^^ argument #1 is missing | note: method defined here - --> $DIR/ice-issue-138362.rs:5:8 + --> $DIR/ice-issue-138362.rs:4:8 | LL | fn method(self); | ^^^^^^ ---- diff --git a/tests/ui/delegation/ice-issue-150673.rs b/tests/ui/delegation/ice-issue-150673.rs index 7f041d3ce2570..c0709e9b6e896 100644 --- a/tests/ui/delegation/ice-issue-150673.rs +++ b/tests/ui/delegation/ice-issue-150673.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] mod to_reuse { pub fn foo() -> T { diff --git a/tests/ui/delegation/ice-issue-150673.stderr b/tests/ui/delegation/ice-issue-150673.stderr index fc817b07770e8..808e8e84a61e0 100644 --- a/tests/ui/delegation/ice-issue-150673.stderr +++ b/tests/ui/delegation/ice-issue-150673.stderr @@ -1,11 +1,11 @@ error[E0107]: missing generics for struct `S` - --> $DIR/ice-issue-150673.rs:16:16 + --> $DIR/ice-issue-150673.rs:15:16 | LL | impl Trait for S { | ^ expected 1 generic argument | note: struct defined here, with 1 generic parameter: `T` - --> $DIR/ice-issue-150673.rs:10:8 + --> $DIR/ice-issue-150673.rs:9:8 | LL | struct S(T); | ^ - diff --git a/tests/ui/delegation/ice-non-fn-target-in-trait-impl.rs b/tests/ui/delegation/ice-non-fn-target-in-trait-impl.rs index ebb826f832bc9..a88a2ef0613ad 100644 --- a/tests/ui/delegation/ice-non-fn-target-in-trait-impl.rs +++ b/tests/ui/delegation/ice-non-fn-target-in-trait-impl.rs @@ -3,7 +3,6 @@ // should emit a resolution error, not ICE. #![feature(fn_delegation)] -#![allow(incomplete_features)] trait Trait { fn bar(); diff --git a/tests/ui/delegation/ice-non-fn-target-in-trait-impl.stderr b/tests/ui/delegation/ice-non-fn-target-in-trait-impl.stderr index bed13b0a3a9b1..0bf5846cb782c 100644 --- a/tests/ui/delegation/ice-non-fn-target-in-trait-impl.stderr +++ b/tests/ui/delegation/ice-non-fn-target-in-trait-impl.stderr @@ -1,11 +1,11 @@ error[E0423]: expected function, found module `std::path` - --> $DIR/ice-non-fn-target-in-trait-impl.rs:14:11 + --> $DIR/ice-non-fn-target-in-trait-impl.rs:13:11 | LL | reuse std::path::<> as bar; | ^^^^^^^^^^^^^ not a function error[E0423]: expected function, found crate `core` - --> $DIR/ice-non-fn-target-in-trait-impl.rs:16:11 + --> $DIR/ice-non-fn-target-in-trait-impl.rs:15:11 | LL | reuse core::<> as bar2; | ^^^^^^^^ not a function diff --git a/tests/ui/delegation/impl-reuse-bad-path.rs b/tests/ui/delegation/impl-reuse-bad-path.rs index 656be5d79d9b1..2ac0805ecb96d 100644 --- a/tests/ui/delegation/impl-reuse-bad-path.rs +++ b/tests/ui/delegation/impl-reuse-bad-path.rs @@ -1,4 +1,3 @@ -#![allow(incomplete_features)] #![feature(fn_delegation)] mod unresolved { diff --git a/tests/ui/delegation/impl-reuse-bad-path.stderr b/tests/ui/delegation/impl-reuse-bad-path.stderr index bf486260c6695..31909993af151 100644 --- a/tests/ui/delegation/impl-reuse-bad-path.stderr +++ b/tests/ui/delegation/impl-reuse-bad-path.stderr @@ -1,47 +1,47 @@ error: empty glob delegation is not supported - --> $DIR/impl-reuse-bad-path.rs:11:5 + --> $DIR/impl-reuse-bad-path.rs:10:5 | LL | reuse impl T for unresolved { self.0 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected trait, found struct `Trait` - --> $DIR/impl-reuse-bad-path.rs:21:16 + --> $DIR/impl-reuse-bad-path.rs:20:16 | LL | reuse impl Trait for S { self.0 } | ^^^^^ not a trait error: expected trait, found module `TraitModule` - --> $DIR/impl-reuse-bad-path.rs:26:16 + --> $DIR/impl-reuse-bad-path.rs:25:16 | LL | reuse impl TraitModule for S { self.0 } | ^^^^^^^^^^^ not a trait error[E0433]: cannot find module or crate `unresolved` in this scope - --> $DIR/impl-reuse-bad-path.rs:6:16 + --> $DIR/impl-reuse-bad-path.rs:5:16 | LL | reuse impl unresolved for S { self.0 } | ^^^^^^^^^^ use of unresolved module or unlinked crate `unresolved` error[E0405]: cannot find trait `unresolved` in this scope - --> $DIR/impl-reuse-bad-path.rs:6:16 + --> $DIR/impl-reuse-bad-path.rs:5:16 | LL | reuse impl unresolved for S { self.0 } | ^^^^^^^^^^ not found in this scope error[E0425]: cannot find type `unresolved` in this scope - --> $DIR/impl-reuse-bad-path.rs:11:22 + --> $DIR/impl-reuse-bad-path.rs:10:22 | LL | reuse impl T for unresolved { self.0 } | ^^^^^^^^^^ not found in this scope error[E0404]: expected trait, found struct `Trait` - --> $DIR/impl-reuse-bad-path.rs:21:16 + --> $DIR/impl-reuse-bad-path.rs:20:16 | LL | reuse impl Trait for S { self.0 } | ^^^^^ not a trait error[E0404]: expected trait, found module `TraitModule` - --> $DIR/impl-reuse-bad-path.rs:26:16 + --> $DIR/impl-reuse-bad-path.rs:25:16 | LL | reuse impl TraitModule for S { self.0 } | ^^^^^^^^^^^ not a trait diff --git a/tests/ui/delegation/impl-reuse-empty-glob.rs b/tests/ui/delegation/impl-reuse-empty-glob.rs index 3f1314c47da62..1c2b869262445 100644 --- a/tests/ui/delegation/impl-reuse-empty-glob.rs +++ b/tests/ui/delegation/impl-reuse-empty-glob.rs @@ -1,4 +1,3 @@ -#![allow(incomplete_features)] #![feature(fn_delegation)] mod empty_glob { diff --git a/tests/ui/delegation/impl-reuse-empty-glob.stderr b/tests/ui/delegation/impl-reuse-empty-glob.stderr index bf6bb58763519..1097f3af20736 100644 --- a/tests/ui/delegation/impl-reuse-empty-glob.stderr +++ b/tests/ui/delegation/impl-reuse-empty-glob.stderr @@ -1,5 +1,5 @@ error: empty glob delegation is not supported - --> $DIR/impl-reuse-empty-glob.rs:9:5 + --> $DIR/impl-reuse-empty-glob.rs:8:5 | LL | reuse impl T for S { self.0 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/delegation/impl-reuse-illegal-places.rs b/tests/ui/delegation/impl-reuse-illegal-places.rs index 361331d41315d..e9a1cf2be7bce 100644 --- a/tests/ui/delegation/impl-reuse-illegal-places.rs +++ b/tests/ui/delegation/impl-reuse-illegal-places.rs @@ -1,4 +1,3 @@ -#![allow(incomplete_features)] #![feature(fn_delegation)] trait T { diff --git a/tests/ui/delegation/impl-reuse-illegal-places.stderr b/tests/ui/delegation/impl-reuse-illegal-places.stderr index fb17ebdd6cee1..5aae101b8c324 100644 --- a/tests/ui/delegation/impl-reuse-illegal-places.stderr +++ b/tests/ui/delegation/impl-reuse-illegal-places.stderr @@ -1,5 +1,5 @@ error: expected `:`, found keyword `impl` - --> $DIR/impl-reuse-illegal-places.rs:14:11 + --> $DIR/impl-reuse-illegal-places.rs:13:11 | LL | struct X { | - while parsing this struct @@ -7,7 +7,7 @@ LL | reuse impl T for F { self.0 } | ^^^^ expected `:` error: implementation is not supported in `trait`s or `impl`s - --> $DIR/impl-reuse-illegal-places.rs:19:5 + --> $DIR/impl-reuse-illegal-places.rs:18:5 | LL | reuse impl T for F { self.0 } | ^^^^^^^^^^^^^^^^^^ @@ -15,7 +15,7 @@ LL | reuse impl T for F { self.0 } = help: consider moving the implementation out to a nearby module scope error: implementation is not supported in `trait`s or `impl`s - --> $DIR/impl-reuse-illegal-places.rs:24:5 + --> $DIR/impl-reuse-illegal-places.rs:23:5 | LL | reuse impl T for F { self.0 } | ^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | reuse impl T for F { self.0 } = help: consider moving the implementation out to a nearby module scope error: implementation is not supported in `extern` blocks - --> $DIR/impl-reuse-illegal-places.rs:29:5 + --> $DIR/impl-reuse-illegal-places.rs:28:5 | LL | reuse impl T for F { self.0 } | ^^^^^^^^^^^^^^^^^^ @@ -31,13 +31,13 @@ LL | reuse impl T for F { self.0 } = help: consider moving the implementation out to a nearby module scope error: expected identifier, found keyword `impl` - --> $DIR/impl-reuse-illegal-places.rs:39:15 + --> $DIR/impl-reuse-illegal-places.rs:38:15 | LL | reuse impl T for F { self.0 } | ^^^^ expected identifier, found keyword error: expected one of `,`, `as`, or `}`, found keyword `impl` - --> $DIR/impl-reuse-illegal-places.rs:39:15 + --> $DIR/impl-reuse-illegal-places.rs:38:15 | LL | reuse impl T for F { self.0 } | -^^^^ expected one of `,`, `as`, or `}` @@ -45,7 +45,7 @@ LL | reuse impl T for F { self.0 } | help: missing `,` error: expected one of `,`, `as`, or `}`, found `T` - --> $DIR/impl-reuse-illegal-places.rs:39:20 + --> $DIR/impl-reuse-illegal-places.rs:38:20 | LL | reuse impl T for F { self.0 } | -^ expected one of `,`, `as`, or `}` @@ -53,13 +53,13 @@ LL | reuse impl T for F { self.0 } | help: missing `,` error: expected identifier, found keyword `for` - --> $DIR/impl-reuse-illegal-places.rs:39:22 + --> $DIR/impl-reuse-illegal-places.rs:38:22 | LL | reuse impl T for F { self.0 } | ^^^ expected identifier, found keyword error: expected one of `,`, `as`, or `}`, found keyword `for` - --> $DIR/impl-reuse-illegal-places.rs:39:22 + --> $DIR/impl-reuse-illegal-places.rs:38:22 | LL | reuse impl T for F { self.0 } | -^^^ expected one of `,`, `as`, or `}` @@ -67,7 +67,7 @@ LL | reuse impl T for F { self.0 } | help: missing `,` error: expected one of `,`, `as`, or `}`, found `F` - --> $DIR/impl-reuse-illegal-places.rs:39:26 + --> $DIR/impl-reuse-illegal-places.rs:38:26 | LL | reuse impl T for F { self.0 } | -^ expected one of `,`, `as`, or `}` @@ -75,13 +75,13 @@ LL | reuse impl T for F { self.0 } | help: missing `,` error: expected one of `,`, `as`, or `}`, found `{` - --> $DIR/impl-reuse-illegal-places.rs:39:28 + --> $DIR/impl-reuse-illegal-places.rs:38:28 | LL | reuse impl T for F { self.0 } | ^ expected one of `,`, `as`, or `}` error: expected item, found `}` - --> $DIR/impl-reuse-illegal-places.rs:48:1 + --> $DIR/impl-reuse-illegal-places.rs:47:1 | LL | } | ^ expected item diff --git a/tests/ui/delegation/impl-reuse-negative-traits.rs b/tests/ui/delegation/impl-reuse-negative-traits.rs index 8bc2b72708599..bce331e5c36b9 100644 --- a/tests/ui/delegation/impl-reuse-negative-traits.rs +++ b/tests/ui/delegation/impl-reuse-negative-traits.rs @@ -1,4 +1,3 @@ -#![allow(incomplete_features)] #![feature(fn_delegation)] #![feature(negative_impls)] diff --git a/tests/ui/delegation/impl-reuse-negative-traits.stderr b/tests/ui/delegation/impl-reuse-negative-traits.stderr index 7510fdd89d7c6..1dc4f59e5c97d 100644 --- a/tests/ui/delegation/impl-reuse-negative-traits.stderr +++ b/tests/ui/delegation/impl-reuse-negative-traits.stderr @@ -1,5 +1,5 @@ error[E0749]: negative impls cannot have any items - --> $DIR/impl-reuse-negative-traits.rs:16:1 + --> $DIR/impl-reuse-negative-traits.rs:15:1 | LL | reuse impl !Trait for F { &self.0 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/delegation/impl-reuse-non-reuse-items.rs b/tests/ui/delegation/impl-reuse-non-reuse-items.rs index de7c92279218d..0dbe8016c1e8e 100644 --- a/tests/ui/delegation/impl-reuse-non-reuse-items.rs +++ b/tests/ui/delegation/impl-reuse-non-reuse-items.rs @@ -1,4 +1,3 @@ -#![allow(incomplete_features)] #![feature(fn_delegation)] mod non_delegatable_items { diff --git a/tests/ui/delegation/impl-reuse-non-reuse-items.stderr b/tests/ui/delegation/impl-reuse-non-reuse-items.stderr index 9d6b0f6381367..044c9aa5a7ab9 100644 --- a/tests/ui/delegation/impl-reuse-non-reuse-items.stderr +++ b/tests/ui/delegation/impl-reuse-non-reuse-items.stderr @@ -1,5 +1,5 @@ error[E0324]: item `CONST` is an associated method, which doesn't match its trait `Trait` - --> $DIR/impl-reuse-non-reuse-items.rs:23:5 + --> $DIR/impl-reuse-non-reuse-items.rs:22:5 | LL | const CONST: u8; | ---------------- item in trait @@ -8,7 +8,7 @@ LL | reuse impl Trait for S { &self.0 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ does not match trait error[E0324]: item `Type` is an associated method, which doesn't match its trait `Trait` - --> $DIR/impl-reuse-non-reuse-items.rs:23:5 + --> $DIR/impl-reuse-non-reuse-items.rs:22:5 | LL | type Type; | ---------- item in trait @@ -17,7 +17,7 @@ LL | reuse impl Trait for S { &self.0 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ does not match trait error[E0201]: duplicate definitions with name `method`: - --> $DIR/impl-reuse-non-reuse-items.rs:23:5 + --> $DIR/impl-reuse-non-reuse-items.rs:22:5 | LL | fn method(&self); | ----------------- item in trait @@ -29,19 +29,19 @@ LL | reuse impl Trait for S { &self.0 } | previous definition here error[E0423]: expected function, found associated constant `Trait::CONST` - --> $DIR/impl-reuse-non-reuse-items.rs:23:16 + --> $DIR/impl-reuse-non-reuse-items.rs:22:16 | LL | reuse impl Trait for S { &self.0 } | ^^^^^ not a function error[E0423]: expected function, found associated type `Trait::Type` - --> $DIR/impl-reuse-non-reuse-items.rs:23:16 + --> $DIR/impl-reuse-non-reuse-items.rs:22:16 | LL | reuse impl Trait for S { &self.0 } | ^^^^^ not a function error[E0046]: not all trait items implemented, missing: `CONST`, `Type`, `method` - --> $DIR/impl-reuse-non-reuse-items.rs:23:5 + --> $DIR/impl-reuse-non-reuse-items.rs:22:5 | LL | const CONST: u8; | --------------- `CONST` from trait diff --git a/tests/ui/delegation/impl-reuse-non-trait-impl-cfg-false.rs b/tests/ui/delegation/impl-reuse-non-trait-impl-cfg-false.rs index 51ef1dc14ba86..0480c98945fe1 100644 --- a/tests/ui/delegation/impl-reuse-non-trait-impl-cfg-false.rs +++ b/tests/ui/delegation/impl-reuse-non-trait-impl-cfg-false.rs @@ -1,4 +1,3 @@ -#![allow(incomplete_features)] #![feature(fn_delegation)] struct Trait(usize); diff --git a/tests/ui/delegation/impl-reuse-non-trait-impl-cfg-false.stderr b/tests/ui/delegation/impl-reuse-non-trait-impl-cfg-false.stderr index 24a138016116c..da5bddcfe39b1 100644 --- a/tests/ui/delegation/impl-reuse-non-trait-impl-cfg-false.stderr +++ b/tests/ui/delegation/impl-reuse-non-trait-impl-cfg-false.stderr @@ -1,5 +1,5 @@ error: only trait impls can be reused - --> $DIR/impl-reuse-non-trait-impl-cfg-false.rs:7:1 + --> $DIR/impl-reuse-non-trait-impl-cfg-false.rs:6:1 | LL | reuse impl Trait { self.0 } | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/delegation/impl-reuse-non-trait-impl.rs b/tests/ui/delegation/impl-reuse-non-trait-impl.rs index c7a9813250db9..913a7d5f815a7 100644 --- a/tests/ui/delegation/impl-reuse-non-trait-impl.rs +++ b/tests/ui/delegation/impl-reuse-non-trait-impl.rs @@ -1,4 +1,3 @@ -#![allow(incomplete_features)] #![feature(fn_delegation)] struct Trait(usize); diff --git a/tests/ui/delegation/impl-reuse-non-trait-impl.stderr b/tests/ui/delegation/impl-reuse-non-trait-impl.stderr index 3987042104c38..a0a773f90a98b 100644 --- a/tests/ui/delegation/impl-reuse-non-trait-impl.stderr +++ b/tests/ui/delegation/impl-reuse-non-trait-impl.stderr @@ -1,5 +1,5 @@ error: only trait impls can be reused - --> $DIR/impl-reuse-non-trait-impl.rs:6:1 + --> $DIR/impl-reuse-non-trait-impl.rs:5:1 | LL | reuse impl Trait { self.0 } | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/delegation/impl-reuse-pass.rs b/tests/ui/delegation/impl-reuse-pass.rs index 578e8c08e7038..75fbd468aabff 100644 --- a/tests/ui/delegation/impl-reuse-pass.rs +++ b/tests/ui/delegation/impl-reuse-pass.rs @@ -1,6 +1,5 @@ //@ check-pass -#![allow(incomplete_features)] #![feature(fn_delegation)] #![feature(const_trait_impl)] #![allow(warnings)] diff --git a/tests/ui/delegation/impl-reuse-self-hygiene.rs b/tests/ui/delegation/impl-reuse-self-hygiene.rs index b49e4419703a7..bbb0c4c04498f 100644 --- a/tests/ui/delegation/impl-reuse-self-hygiene.rs +++ b/tests/ui/delegation/impl-reuse-self-hygiene.rs @@ -1,4 +1,3 @@ -#![allow(incomplete_features)] #![feature(fn_delegation)] trait Trait { diff --git a/tests/ui/delegation/impl-reuse-self-hygiene.stderr b/tests/ui/delegation/impl-reuse-self-hygiene.stderr index ae93829809e4f..748e36cf55fd8 100644 --- a/tests/ui/delegation/impl-reuse-self-hygiene.stderr +++ b/tests/ui/delegation/impl-reuse-self-hygiene.stderr @@ -1,5 +1,5 @@ error[E0424]: expected value, found module `self` - --> $DIR/impl-reuse-self-hygiene.rs:10:76 + --> $DIR/impl-reuse-self-hygiene.rs:9:76 | LL | macro_rules! one_line_reuse { ($self:ident) => { reuse impl Trait for S1 { $self.0 } } } | --------------------------^^^^^---- @@ -13,7 +13,7 @@ LL | one_line_reuse!(self); = note: this error originates in the macro `one_line_reuse` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0424]: expected value, found module `self` - --> $DIR/impl-reuse-self-hygiene.rs:10:76 + --> $DIR/impl-reuse-self-hygiene.rs:9:76 | LL | macro_rules! one_line_reuse { ($self:ident) => { reuse impl Trait for S1 { $self.0 } } } | --------------------------^^^^^---- @@ -28,7 +28,7 @@ LL | one_line_reuse!(self); = note: this error originates in the macro `one_line_reuse` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0424]: expected value, found module `self` - --> $DIR/impl-reuse-self-hygiene.rs:17:22 + --> $DIR/impl-reuse-self-hygiene.rs:16:22 | LL | macro_rules! one_line_reuse_expr { ($x:expr) => { reuse impl Trait for S2 { $x } } } | ------------------------------ `self` not allowed in an implementation @@ -36,7 +36,7 @@ LL | one_line_reuse_expr!(self.0); | ^^^^ `self` value is a keyword only available in methods with a `self` parameter error[E0424]: expected value, found module `self` - --> $DIR/impl-reuse-self-hygiene.rs:17:22 + --> $DIR/impl-reuse-self-hygiene.rs:16:22 | LL | macro_rules! one_line_reuse_expr { ($x:expr) => { reuse impl Trait for S2 { $x } } } | ------------------------------ `self` not allowed in an implementation @@ -46,7 +46,7 @@ LL | one_line_reuse_expr!(self.0); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0424]: expected value, found module `self` - --> $DIR/impl-reuse-self-hygiene.rs:24:23 + --> $DIR/impl-reuse-self-hygiene.rs:23:23 | LL | macro_rules! one_line_reuse_expr2 { ($x:expr) => { reuse impl Trait for s3!() { $x } } } | --------------------------------- `self` not allowed in an implementation @@ -54,7 +54,7 @@ LL | one_line_reuse_expr2!(self.0); | ^^^^ `self` value is a keyword only available in methods with a `self` parameter error[E0424]: expected value, found module `self` - --> $DIR/impl-reuse-self-hygiene.rs:24:23 + --> $DIR/impl-reuse-self-hygiene.rs:23:23 | LL | macro_rules! one_line_reuse_expr2 { ($x:expr) => { reuse impl Trait for s3!() { $x } } } | --------------------------------- `self` not allowed in an implementation diff --git a/tests/ui/delegation/impl-trait.rs b/tests/ui/delegation/impl-trait.rs index 13df0155485c9..cb86a048a18e9 100644 --- a/tests/ui/delegation/impl-trait.rs +++ b/tests/ui/delegation/impl-trait.rs @@ -1,7 +1,6 @@ //@ check-pass #![feature(fn_delegation)] -#![allow(incomplete_features)] mod to_reuse { pub fn foo() -> impl Clone { 0 } diff --git a/tests/ui/delegation/inner-attr.rs b/tests/ui/delegation/inner-attr.rs index 501118713d123..6bd2892095fc0 100644 --- a/tests/ui/delegation/inner-attr.rs +++ b/tests/ui/delegation/inner-attr.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] fn a() {} diff --git a/tests/ui/delegation/inner-attr.stderr b/tests/ui/delegation/inner-attr.stderr index 226a48ecf9a4b..307586ccef93d 100644 --- a/tests/ui/delegation/inner-attr.stderr +++ b/tests/ui/delegation/inner-attr.stderr @@ -1,5 +1,5 @@ error: an inner attribute is not permitted in this context - --> $DIR/inner-attr.rs:6:16 + --> $DIR/inner-attr.rs:5:16 | LL | reuse a as b { #![rustc_dummy] self } | ^^^^^^^^^^^^^^^ @@ -10,13 +10,13 @@ LL | fn main() {} = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files error[E0061]: this function takes 0 arguments but 1 argument was supplied - --> $DIR/inner-attr.rs:6:7 + --> $DIR/inner-attr.rs:5:7 | LL | reuse a as b { #![rustc_dummy] self } | ^ ---- unexpected argument | note: function defined here - --> $DIR/inner-attr.rs:4:4 + --> $DIR/inner-attr.rs:3:4 | LL | fn a() {} | ^ diff --git a/tests/ui/delegation/list.rs b/tests/ui/delegation/list.rs index 208b14816797a..fc6eabb4bfd2b 100644 --- a/tests/ui/delegation/list.rs +++ b/tests/ui/delegation/list.rs @@ -1,7 +1,6 @@ //@ check-pass #![feature(fn_delegation)] -#![allow(incomplete_features)] trait Trait { fn foo(&self) -> u8 { 0 } diff --git a/tests/ui/delegation/macro-inside-glob.rs b/tests/ui/delegation/macro-inside-glob.rs index 1d529341c5b4b..dae97b20e5943 100644 --- a/tests/ui/delegation/macro-inside-glob.rs +++ b/tests/ui/delegation/macro-inside-glob.rs @@ -1,7 +1,6 @@ //@ check-pass #![feature(fn_delegation)] -#![allow(incomplete_features)] trait Trait { fn foo(&self) -> u8 { 0 } diff --git a/tests/ui/delegation/macro-inside-list.rs b/tests/ui/delegation/macro-inside-list.rs index d07a4e47dd4cd..390852a7089f1 100644 --- a/tests/ui/delegation/macro-inside-list.rs +++ b/tests/ui/delegation/macro-inside-list.rs @@ -1,7 +1,6 @@ //@ check-pass #![feature(fn_delegation)] -#![allow(incomplete_features)] trait Trait { fn foo(&self) -> u8 { 0 } diff --git a/tests/ui/delegation/method-call-choice.rs b/tests/ui/delegation/method-call-choice.rs index 8d53d8bfdb72d..0131899d8605d 100644 --- a/tests/ui/delegation/method-call-choice.rs +++ b/tests/ui/delegation/method-call-choice.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] trait Trait { fn foo(&self) {} diff --git a/tests/ui/delegation/method-call-choice.stderr b/tests/ui/delegation/method-call-choice.stderr index 6757af20a6b3a..b7ba49953cfd1 100644 --- a/tests/ui/delegation/method-call-choice.stderr +++ b/tests/ui/delegation/method-call-choice.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/method-call-choice.rs:21:27 + --> $DIR/method-call-choice.rs:20:27 | LL | reuse to_reuse::foo { self.0 } | --- ^^^^^^ expected `&F`, found `F` @@ -7,7 +7,7 @@ LL | reuse to_reuse::foo { self.0 } | arguments to this function are incorrect | note: function defined here - --> $DIR/method-call-choice.rs:15:12 + --> $DIR/method-call-choice.rs:14:12 | LL | pub fn foo(_: &F) {} | ^^^ ----- diff --git a/tests/ui/delegation/method-call-priority.rs b/tests/ui/delegation/method-call-priority.rs index 8d68740d181a8..4467cae6013b2 100644 --- a/tests/ui/delegation/method-call-priority.rs +++ b/tests/ui/delegation/method-call-priority.rs @@ -1,7 +1,6 @@ //@ run-pass #![feature(fn_delegation)] -#![allow(incomplete_features)] #![allow(dead_code)] trait Trait1 { diff --git a/tests/ui/delegation/parse.rs b/tests/ui/delegation/parse.rs index 72b00bf6e0d53..109be4eed2829 100644 --- a/tests/ui/delegation/parse.rs +++ b/tests/ui/delegation/parse.rs @@ -2,7 +2,6 @@ #![feature(decl_macro)] #![feature(fn_delegation)] -#![allow(incomplete_features)] macro_rules! reuse { {} => {} } diff --git a/tests/ui/delegation/recursive-delegation-errors.rs b/tests/ui/delegation/recursive-delegation-errors.rs index da295b09caeaa..353a4e76d94ed 100644 --- a/tests/ui/delegation/recursive-delegation-errors.rs +++ b/tests/ui/delegation/recursive-delegation-errors.rs @@ -1,6 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] - mod first_mod { reuse foo; diff --git a/tests/ui/delegation/recursive-delegation-errors.stderr b/tests/ui/delegation/recursive-delegation-errors.stderr index bf446bd872f76..aaa7d8b2d6b49 100644 --- a/tests/ui/delegation/recursive-delegation-errors.stderr +++ b/tests/ui/delegation/recursive-delegation-errors.stderr @@ -1,101 +1,101 @@ error: failed to resolve delegation callee - --> $DIR/recursive-delegation-errors.rs:6:11 + --> $DIR/recursive-delegation-errors.rs:4:11 | LL | reuse foo; | ^^^ error: encountered a cycle during delegation signature resolution - --> $DIR/recursive-delegation-errors.rs:12:11 + --> $DIR/recursive-delegation-errors.rs:10:11 | LL | reuse foo as bar; | ^^^ error: encountered a cycle during delegation signature resolution - --> $DIR/recursive-delegation-errors.rs:14:11 + --> $DIR/recursive-delegation-errors.rs:12:11 | LL | reuse bar as foo; | ^^^ error: encountered a cycle during delegation signature resolution - --> $DIR/recursive-delegation-errors.rs:19:11 + --> $DIR/recursive-delegation-errors.rs:17:11 | LL | reuse foo as foo1; | ^^^ error: encountered a cycle during delegation signature resolution - --> $DIR/recursive-delegation-errors.rs:21:11 + --> $DIR/recursive-delegation-errors.rs:19:11 | LL | reuse foo1 as foo2; | ^^^^ error: encountered a cycle during delegation signature resolution - --> $DIR/recursive-delegation-errors.rs:23:11 + --> $DIR/recursive-delegation-errors.rs:21:11 | LL | reuse foo2 as foo3; | ^^^^ error: encountered a cycle during delegation signature resolution - --> $DIR/recursive-delegation-errors.rs:25:11 + --> $DIR/recursive-delegation-errors.rs:23:11 | LL | reuse foo3 as foo4; | ^^^^ error: encountered a cycle during delegation signature resolution - --> $DIR/recursive-delegation-errors.rs:27:11 + --> $DIR/recursive-delegation-errors.rs:25:11 | LL | reuse foo4 as foo5; | ^^^^ error: encountered a cycle during delegation signature resolution - --> $DIR/recursive-delegation-errors.rs:29:11 + --> $DIR/recursive-delegation-errors.rs:27:11 | LL | reuse foo5 as foo; | ^^^^ error: encountered a cycle during delegation signature resolution - --> $DIR/recursive-delegation-errors.rs:35:22 + --> $DIR/recursive-delegation-errors.rs:33:22 | LL | reuse Trait::foo as bar; | ^^^ error: encountered a cycle during delegation signature resolution - --> $DIR/recursive-delegation-errors.rs:38:22 + --> $DIR/recursive-delegation-errors.rs:36:22 | LL | reuse Trait::bar as foo; | ^^^ error: encountered a cycle during delegation signature resolution - --> $DIR/recursive-delegation-errors.rs:45:30 + --> $DIR/recursive-delegation-errors.rs:43:30 | LL | reuse super::fifth_mod::{bar as foo, foo as bar}; | ^^^ error: encountered a cycle during delegation signature resolution - --> $DIR/recursive-delegation-errors.rs:45:42 + --> $DIR/recursive-delegation-errors.rs:43:42 | LL | reuse super::fifth_mod::{bar as foo, foo as bar}; | ^^^ error: encountered a cycle during delegation signature resolution - --> $DIR/recursive-delegation-errors.rs:50:27 + --> $DIR/recursive-delegation-errors.rs:48:27 | LL | reuse GlobReuse::{foo as bar, bar as goo, goo as foo}; | ^^^ error: encountered a cycle during delegation signature resolution - --> $DIR/recursive-delegation-errors.rs:50:39 + --> $DIR/recursive-delegation-errors.rs:48:39 | LL | reuse GlobReuse::{foo as bar, bar as goo, goo as foo}; | ^^^ error: encountered a cycle during delegation signature resolution - --> $DIR/recursive-delegation-errors.rs:50:51 + --> $DIR/recursive-delegation-errors.rs:48:51 | LL | reuse GlobReuse::{foo as bar, bar as goo, goo as foo}; | ^^^ error[E0283]: type annotations needed - --> $DIR/recursive-delegation-errors.rs:35:22 + --> $DIR/recursive-delegation-errors.rs:33:22 | LL | reuse Trait::foo as bar; | ^^^ cannot infer type @@ -103,7 +103,7 @@ LL | reuse Trait::foo as bar; = note: the type must implement `fourth_mod::Trait` error[E0283]: type annotations needed - --> $DIR/recursive-delegation-errors.rs:38:22 + --> $DIR/recursive-delegation-errors.rs:36:22 | LL | reuse Trait::bar as foo; | ^^^ cannot infer type @@ -111,7 +111,7 @@ LL | reuse Trait::bar as foo; = note: the type must implement `fourth_mod::Trait` error[E0283]: type annotations needed - --> $DIR/recursive-delegation-errors.rs:50:27 + --> $DIR/recursive-delegation-errors.rs:48:27 | LL | reuse GlobReuse::{foo as bar, bar as goo, goo as foo}; | ^^^ cannot infer type @@ -119,7 +119,7 @@ LL | reuse GlobReuse::{foo as bar, bar as goo, goo as foo}; = note: the type must implement `GlobReuse` error[E0283]: type annotations needed - --> $DIR/recursive-delegation-errors.rs:50:39 + --> $DIR/recursive-delegation-errors.rs:48:39 | LL | reuse GlobReuse::{foo as bar, bar as goo, goo as foo}; | ^^^ cannot infer type @@ -127,7 +127,7 @@ LL | reuse GlobReuse::{foo as bar, bar as goo, goo as foo}; = note: the type must implement `GlobReuse` error[E0283]: type annotations needed - --> $DIR/recursive-delegation-errors.rs:50:51 + --> $DIR/recursive-delegation-errors.rs:48:51 | LL | reuse GlobReuse::{foo as bar, bar as goo, goo as foo}; | ^^^ cannot infer type @@ -135,7 +135,7 @@ LL | reuse GlobReuse::{foo as bar, bar as goo, goo as foo}; = note: the type must implement `GlobReuse` warning: function cannot return without recursing - --> $DIR/recursive-delegation-errors.rs:6:11 + --> $DIR/recursive-delegation-errors.rs:4:11 | LL | reuse foo; | ^^^ diff --git a/tests/ui/delegation/recursive-delegation-ice-150152.rs b/tests/ui/delegation/recursive-delegation-ice-150152.rs index 565563c9d03d4..c4aaa7fd2d1f2 100644 --- a/tests/ui/delegation/recursive-delegation-ice-150152.rs +++ b/tests/ui/delegation/recursive-delegation-ice-150152.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] mod first_example { mod to_reuse { pub fn foo() {} } diff --git a/tests/ui/delegation/recursive-delegation-ice-150152.stderr b/tests/ui/delegation/recursive-delegation-ice-150152.stderr index c58f0ff092912..b59b588f4968a 100644 --- a/tests/ui/delegation/recursive-delegation-ice-150152.stderr +++ b/tests/ui/delegation/recursive-delegation-ice-150152.stderr @@ -1,29 +1,29 @@ error[E0405]: cannot find trait `Item` in this scope - --> $DIR/recursive-delegation-ice-150152.rs:9:10 + --> $DIR/recursive-delegation-ice-150152.rs:8:10 | LL | impl Item for S { | ^^^^ not found in this scope error[E0425]: cannot find type `S` in this scope - --> $DIR/recursive-delegation-ice-150152.rs:24:20 + --> $DIR/recursive-delegation-ice-150152.rs:23:20 | LL | impl Trait for S { | ^ not found in this scope | note: struct `first_example::S` exists but is inaccessible - --> $DIR/recursive-delegation-ice-150152.rs:6:5 + --> $DIR/recursive-delegation-ice-150152.rs:5:5 | LL | struct S< S >; | ^^^^^^^^^^^^^^ not accessible error[E0425]: cannot find function `foo` in this scope - --> $DIR/recursive-delegation-ice-150152.rs:26:15 + --> $DIR/recursive-delegation-ice-150152.rs:25:15 | LL | reuse foo; | ^^^ not found in this scope | note: these functions exist but are inaccessible - --> $DIR/recursive-delegation-ice-150152.rs:5:20 + --> $DIR/recursive-delegation-ice-150152.rs:4:20 | LL | mod to_reuse { pub fn foo() {} } | ^^^^^^^^^^^^ `first_example::to_reuse::foo`: not accessible @@ -32,19 +32,19 @@ LL | fn foo() {} | ^^^^^^^^ `second_example::to_reuse::foo`: not accessible error[E0603]: function `foo` is private - --> $DIR/recursive-delegation-ice-150152.rs:18:25 + --> $DIR/recursive-delegation-ice-150152.rs:17:25 | LL | reuse to_reuse::foo; | ^^^ private function | note: the function `foo` is defined here - --> $DIR/recursive-delegation-ice-150152.rs:22:9 + --> $DIR/recursive-delegation-ice-150152.rs:21:9 | LL | fn foo() {} | ^^^^^^^^ error[E0392]: type parameter `S` is never used - --> $DIR/recursive-delegation-ice-150152.rs:6:15 + --> $DIR/recursive-delegation-ice-150152.rs:5:15 | LL | struct S< S >; | ^ unused type parameter @@ -53,13 +53,13 @@ LL | struct S< S >; = help: if you intended `S` to be a const parameter, use `const S: /* Type */` instead error[E0107]: missing generics for struct `S` - --> $DIR/recursive-delegation-ice-150152.rs:9:21 + --> $DIR/recursive-delegation-ice-150152.rs:8:21 | LL | impl Item for S { | ^ expected 1 generic argument | note: struct defined here, with 1 generic parameter: `S` - --> $DIR/recursive-delegation-ice-150152.rs:6:12 + --> $DIR/recursive-delegation-ice-150152.rs:5:12 | LL | struct S< S >; | ^ - diff --git a/tests/ui/delegation/recursive-delegation-pass.rs b/tests/ui/delegation/recursive-delegation-pass.rs index 2a40986d352a6..94c06749d9ec2 100644 --- a/tests/ui/delegation/recursive-delegation-pass.rs +++ b/tests/ui/delegation/recursive-delegation-pass.rs @@ -3,7 +3,6 @@ //@ aux-crate:recursive_delegation_aux=recursive-delegation-aux.rs #![feature(fn_delegation)] -#![allow(incomplete_features)] #![allow(warnings)] mod first_mod { diff --git a/tests/ui/delegation/rename.rs b/tests/ui/delegation/rename.rs index 80b8724a5bf9e..2298785800718 100644 --- a/tests/ui/delegation/rename.rs +++ b/tests/ui/delegation/rename.rs @@ -1,7 +1,6 @@ //@ check-pass #![feature(fn_delegation)] -#![allow(incomplete_features)] mod to_reuse { pub fn a() {} diff --git a/tests/ui/delegation/reuse-trait-path-with-empty-generics.rs b/tests/ui/delegation/reuse-trait-path-with-empty-generics.rs index 08645e1500446..b79f5b7eaf09b 100644 --- a/tests/ui/delegation/reuse-trait-path-with-empty-generics.rs +++ b/tests/ui/delegation/reuse-trait-path-with-empty-generics.rs @@ -1,6 +1,5 @@ //@ needs-rustc-debug-assertions #![feature(fn_delegation)] -#![allow(incomplete_features)] trait Trait { fn bar4(); diff --git a/tests/ui/delegation/reuse-trait-path-with-empty-generics.stderr b/tests/ui/delegation/reuse-trait-path-with-empty-generics.stderr index eaed6cb33c505..5ec13f3703bdc 100644 --- a/tests/ui/delegation/reuse-trait-path-with-empty-generics.stderr +++ b/tests/ui/delegation/reuse-trait-path-with-empty-generics.stderr @@ -1,5 +1,5 @@ error[E0423]: expected function, found trait `Trait` - --> $DIR/reuse-trait-path-with-empty-generics.rs:10:11 + --> $DIR/reuse-trait-path-with-empty-generics.rs:9:11 | LL | reuse Trait::<> as bar4; | ^^^^^^^^^ not a function diff --git a/tests/ui/delegation/self-coercion.rs b/tests/ui/delegation/self-coercion.rs index 96c1f1b140b14..e6c71ec1e257b 100644 --- a/tests/ui/delegation/self-coercion.rs +++ b/tests/ui/delegation/self-coercion.rs @@ -1,7 +1,6 @@ //@ run-pass #![feature(fn_delegation)] -#![allow(incomplete_features)] trait Trait : Sized { fn by_value(self) -> i32 { 1 } diff --git a/tests/ui/delegation/self-hygiene.rs b/tests/ui/delegation/self-hygiene.rs index dac6c319416a3..db0049c33be01 100644 --- a/tests/ui/delegation/self-hygiene.rs +++ b/tests/ui/delegation/self-hygiene.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] macro_rules! emit_self { () => { self } } //~^ ERROR expected value, found module `self` diff --git a/tests/ui/delegation/self-hygiene.stderr b/tests/ui/delegation/self-hygiene.stderr index fa64b7d1d7f7b..1ccb196dbbadc 100644 --- a/tests/ui/delegation/self-hygiene.stderr +++ b/tests/ui/delegation/self-hygiene.stderr @@ -1,5 +1,5 @@ error[E0424]: expected value, found module `self` - --> $DIR/self-hygiene.rs:4:34 + --> $DIR/self-hygiene.rs:3:34 | LL | macro_rules! emit_self { () => { self } } | ^^^^ `self` value is a keyword only available in methods with a `self` parameter @@ -13,7 +13,7 @@ LL | | } = note: this error originates in the macro `emit_self` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0424]: expected value, found module `self` - --> $DIR/self-hygiene.rs:4:34 + --> $DIR/self-hygiene.rs:3:34 | LL | macro_rules! emit_self { () => { self } } | ^^^^ `self` value is a keyword only available in methods with a `self` parameter diff --git a/tests/ui/delegation/target-expr-pass.rs b/tests/ui/delegation/target-expr-pass.rs index 2d5cf7aace2bc..887a1ee5953dd 100644 --- a/tests/ui/delegation/target-expr-pass.rs +++ b/tests/ui/delegation/target-expr-pass.rs @@ -1,7 +1,6 @@ //@ run-pass #![feature(fn_delegation)] -#![allow(incomplete_features)] mod to_reuse { pub fn foo(x: i32) -> i32 { x } diff --git a/tests/ui/delegation/target-expr-pass.stderr b/tests/ui/delegation/target-expr-pass.stderr index 4924d95208a16..d7ca17c9ef86d 100644 --- a/tests/ui/delegation/target-expr-pass.stderr +++ b/tests/ui/delegation/target-expr-pass.stderr @@ -1,5 +1,5 @@ warning: trait `Trait` is never used - --> $DIR/target-expr-pass.rs:17:7 + --> $DIR/target-expr-pass.rs:16:7 | LL | trait Trait { | ^^^^^ @@ -7,13 +7,13 @@ LL | trait Trait { = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default warning: struct `F` is never constructed - --> $DIR/target-expr-pass.rs:21:8 + --> $DIR/target-expr-pass.rs:20:8 | LL | struct F; | ^ warning: struct `S` is never constructed - --> $DIR/target-expr-pass.rs:24:8 + --> $DIR/target-expr-pass.rs:23:8 | LL | struct S(F); | ^ diff --git a/tests/ui/delegation/target-expr.rs b/tests/ui/delegation/target-expr.rs index f766ca7356a4c..253ce1fffff72 100644 --- a/tests/ui/delegation/target-expr.rs +++ b/tests/ui/delegation/target-expr.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] trait Trait { fn static_method(x: i32) -> i32 { x } diff --git a/tests/ui/delegation/target-expr.stderr b/tests/ui/delegation/target-expr.stderr index e26d12ee447d0..7153fa4178374 100644 --- a/tests/ui/delegation/target-expr.stderr +++ b/tests/ui/delegation/target-expr.stderr @@ -1,5 +1,5 @@ error[E0401]: can't use generic parameters from outer item - --> $DIR/target-expr.rs:18:17 + --> $DIR/target-expr.rs:17:17 | LL | fn bar(_: T) { | - type parameter from outer item @@ -12,7 +12,7 @@ LL | let _ = T::Default(); = note: nested items are independent from their parent item for everything except for privacy and name resolution error[E0434]: can't capture dynamic environment in a fn item - --> $DIR/target-expr.rs:26:17 + --> $DIR/target-expr.rs:25:17 | LL | let x = y; | ^ @@ -20,7 +20,7 @@ LL | let x = y; = help: use the `|| { ... }` closure form instead error[E0424]: expected value, found module `self` - --> $DIR/target-expr.rs:33:5 + --> $DIR/target-expr.rs:32:5 | LL | fn main() { | ---- this function can't have a `self` parameter @@ -29,19 +29,19 @@ LL | self.0; | ^^^^ `self` value is a keyword only available in methods with a `self` parameter error[E0425]: cannot find value `x` in this scope - --> $DIR/target-expr.rs:35:13 + --> $DIR/target-expr.rs:34:13 | LL | let z = x; | ^ | help: the binding `x` is available in a different scope in the same function - --> $DIR/target-expr.rs:26:13 + --> $DIR/target-expr.rs:25:13 | LL | let x = y; | ^ error[E0308]: mismatched types - --> $DIR/target-expr.rs:16:32 + --> $DIR/target-expr.rs:15:32 | LL | reuse Trait::static_method { | ________________________________^ diff --git a/tests/ui/delegation/unlowered-path-ice-154820.rs b/tests/ui/delegation/unlowered-path-ice-154820.rs index a527b17cf6c41..b9246313a3f0a 100644 --- a/tests/ui/delegation/unlowered-path-ice-154820.rs +++ b/tests/ui/delegation/unlowered-path-ice-154820.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] reuse foo:: < { //~ ERROR: failed to resolve delegation callee //~^ ERROR: function takes 0 generic arguments but 1 generic argument was supplied diff --git a/tests/ui/delegation/unlowered-path-ice-154820.stderr b/tests/ui/delegation/unlowered-path-ice-154820.stderr index fbcb3ca9c71cf..b690237e3ac9e 100644 --- a/tests/ui/delegation/unlowered-path-ice-154820.stderr +++ b/tests/ui/delegation/unlowered-path-ice-154820.stderr @@ -1,5 +1,5 @@ error[E0428]: the name `foo` is defined multiple times - --> $DIR/unlowered-path-ice-154820.rs:7:5 + --> $DIR/unlowered-path-ice-154820.rs:6:5 | LL | fn foo() {} | -------- previous definition of the value `foo` here @@ -9,13 +9,13 @@ LL | reuse foo; = note: `foo` must be defined only once in the value namespace of this block error: failed to resolve delegation callee - --> $DIR/unlowered-path-ice-154820.rs:4:7 + --> $DIR/unlowered-path-ice-154820.rs:3:7 | LL | reuse foo:: < { | ^^^ error[E0107]: function takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/unlowered-path-ice-154820.rs:4:7 + --> $DIR/unlowered-path-ice-154820.rs:3:7 | LL | reuse foo:: < { | _______^^^- @@ -29,7 +29,7 @@ LL | | >; | |___- help: remove the unnecessary generics | note: function defined here, with 0 generic parameters - --> $DIR/unlowered-path-ice-154820.rs:4:7 + --> $DIR/unlowered-path-ice-154820.rs:3:7 | LL | reuse foo:: < { | ^^^ diff --git a/tests/ui/delegation/unreachable-label-ice-148889.rs b/tests/ui/delegation/unreachable-label-ice-148889.rs index e5f9fa1cf4934..64cbcc3931f1f 100644 --- a/tests/ui/delegation/unreachable-label-ice-148889.rs +++ b/tests/ui/delegation/unreachable-label-ice-148889.rs @@ -1,4 +1,3 @@ -#![allow(incomplete_features)] #![feature(fn_delegation)] trait Trait { diff --git a/tests/ui/delegation/unreachable-label-ice-148889.stderr b/tests/ui/delegation/unreachable-label-ice-148889.stderr index 2141962609183..a6e1c61bb8f54 100644 --- a/tests/ui/delegation/unreachable-label-ice-148889.stderr +++ b/tests/ui/delegation/unreachable-label-ice-148889.stderr @@ -1,5 +1,5 @@ error[E0767]: use of unreachable label `'foo` - --> $DIR/unreachable-label-ice-148889.rs:15:59 + --> $DIR/unreachable-label-ice-148889.rs:14:59 | LL | 'foo: loop { | ---- unreachable label defined here diff --git a/tests/ui/delegation/unresolved-delegation-ice-151356.rs b/tests/ui/delegation/unresolved-delegation-ice-151356.rs index b61e085511833..f51f48c6ef972 100644 --- a/tests/ui/delegation/unresolved-delegation-ice-151356.rs +++ b/tests/ui/delegation/unresolved-delegation-ice-151356.rs @@ -1,4 +1,3 @@ -#![allow(incomplete_features)] #![feature(fn_delegation)] extern "C" { diff --git a/tests/ui/delegation/unresolved-delegation-ice-151356.stderr b/tests/ui/delegation/unresolved-delegation-ice-151356.stderr index 407d22e477c4b..297fe35c9eeba 100644 --- a/tests/ui/delegation/unresolved-delegation-ice-151356.stderr +++ b/tests/ui/delegation/unresolved-delegation-ice-151356.stderr @@ -1,5 +1,5 @@ error: incorrect function inside `extern` block - --> $DIR/unresolved-delegation-ice-151356.rs:5:8 + --> $DIR/unresolved-delegation-ice-151356.rs:4:8 | LL | extern "C" { | ---------- `extern` blocks define existing foreign functions and functions inside of them cannot have a body diff --git a/tests/ui/delegation/unsupported.current.stderr b/tests/ui/delegation/unsupported.current.stderr index 657f990271734..21ea451a2ea5c 100644 --- a/tests/ui/delegation/unsupported.current.stderr +++ b/tests/ui/delegation/unsupported.current.stderr @@ -1,36 +1,36 @@ -error[E0391]: cycle detected when computing type of `opaque::::opaque_ret::{anon_assoc#0}` - --> $DIR/unsupported.rs:30:25 +error[E0391]: cycle detected when computing type of `opaque::::opaque_ret::{anon_assoc#0}` + --> $DIR/unsupported.rs:29:25 | LL | reuse to_reuse::opaque_ret; | ^^^^^^^^^^ | note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process... - --> $DIR/unsupported.rs:30:25 + --> $DIR/unsupported.rs:29:25 | LL | reuse to_reuse::opaque_ret; | ^^^^^^^^^^ - = note: ...which again requires computing type of `opaque::::opaque_ret::{anon_assoc#0}`, completing the cycle -note: cycle used when checking assoc item `opaque::::opaque_ret` is compatible with trait definition - --> $DIR/unsupported.rs:30:25 + = note: ...which again requires computing type of `opaque::::opaque_ret::{anon_assoc#0}`, completing the cycle +note: cycle used when checking assoc item `opaque::::opaque_ret` is compatible with trait definition + --> $DIR/unsupported.rs:29:25 | LL | reuse to_reuse::opaque_ret; | ^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information -error[E0391]: cycle detected when computing type of `opaque::::opaque_ret::{anon_assoc#0}` - --> $DIR/unsupported.rs:33:24 +error[E0391]: cycle detected when computing type of `opaque::::opaque_ret::{anon_assoc#0}` + --> $DIR/unsupported.rs:32:24 | LL | reuse ToReuse::opaque_ret; | ^^^^^^^^^^ | note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process... - --> $DIR/unsupported.rs:33:24 + --> $DIR/unsupported.rs:32:24 | LL | reuse ToReuse::opaque_ret; | ^^^^^^^^^^ - = note: ...which again requires computing type of `opaque::::opaque_ret::{anon_assoc#0}`, completing the cycle -note: cycle used when checking assoc item `opaque::::opaque_ret` is compatible with trait definition - --> $DIR/unsupported.rs:33:24 + = note: ...which again requires computing type of `opaque::::opaque_ret::{anon_assoc#0}`, completing the cycle +note: cycle used when checking assoc item `opaque::::opaque_ret` is compatible with trait definition + --> $DIR/unsupported.rs:32:24 | LL | reuse ToReuse::opaque_ret; | ^^^^^^^^^^ diff --git a/tests/ui/delegation/unsupported.next.stderr b/tests/ui/delegation/unsupported.next.stderr index 90b17752cd8b1..82569be1a7bae 100644 --- a/tests/ui/delegation/unsupported.next.stderr +++ b/tests/ui/delegation/unsupported.next.stderr @@ -1,30 +1,30 @@ -error[E0391]: cycle detected when computing type of `opaque::::opaque_ret::{anon_assoc#0}` - --> $DIR/unsupported.rs:30:25 +error[E0391]: cycle detected when computing type of `opaque::::opaque_ret::{anon_assoc#0}` + --> $DIR/unsupported.rs:29:25 | LL | reuse to_reuse::opaque_ret; | ^^^^^^^^^^ | note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process... - --> $DIR/unsupported.rs:30:25 + --> $DIR/unsupported.rs:29:25 | LL | reuse to_reuse::opaque_ret; | ^^^^^^^^^^ - = note: ...which again requires computing type of `opaque::::opaque_ret::{anon_assoc#0}`, completing the cycle + = note: ...which again requires computing type of `opaque::::opaque_ret::{anon_assoc#0}`, completing the cycle = note: cycle used when computing implied outlives bounds for `::opaque_ret::{anon_assoc#0}` (hack disabled = false) = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information -error[E0391]: cycle detected when computing type of `opaque::::opaque_ret::{anon_assoc#0}` - --> $DIR/unsupported.rs:33:24 +error[E0391]: cycle detected when computing type of `opaque::::opaque_ret::{anon_assoc#0}` + --> $DIR/unsupported.rs:32:24 | LL | reuse ToReuse::opaque_ret; | ^^^^^^^^^^ | note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process... - --> $DIR/unsupported.rs:33:24 + --> $DIR/unsupported.rs:32:24 | LL | reuse ToReuse::opaque_ret; | ^^^^^^^^^^ - = note: ...which again requires computing type of `opaque::::opaque_ret::{anon_assoc#0}`, completing the cycle + = note: ...which again requires computing type of `opaque::::opaque_ret::{anon_assoc#0}`, completing the cycle = note: cycle used when computing implied outlives bounds for `::opaque_ret::{anon_assoc#0}` (hack disabled = false) = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information diff --git a/tests/ui/delegation/unsupported.rs b/tests/ui/delegation/unsupported.rs index af3b87ee7c8c5..678c93dcd53c0 100644 --- a/tests/ui/delegation/unsupported.rs +++ b/tests/ui/delegation/unsupported.rs @@ -9,7 +9,6 @@ #![feature(const_trait_impl)] #![feature(c_variadic)] #![feature(fn_delegation)] -#![allow(incomplete_features)] mod opaque { trait Trait {} diff --git a/tests/ui/delegation/unused-import-ice-144594.rs b/tests/ui/delegation/unused-import-ice-144594.rs index 1d064a4c978f1..fca67c6ee0b81 100644 --- a/tests/ui/delegation/unused-import-ice-144594.rs +++ b/tests/ui/delegation/unused-import-ice-144594.rs @@ -1,4 +1,3 @@ -#![allow(incomplete_features)] #![feature(fn_delegation)] reuse a as b { diff --git a/tests/ui/delegation/unused-import-ice-144594.stderr b/tests/ui/delegation/unused-import-ice-144594.stderr index 1939380235eed..f09313aac21f4 100644 --- a/tests/ui/delegation/unused-import-ice-144594.stderr +++ b/tests/ui/delegation/unused-import-ice-144594.stderr @@ -1,11 +1,11 @@ error[E0425]: cannot find function `a` in this scope - --> $DIR/unused-import-ice-144594.rs:4:7 + --> $DIR/unused-import-ice-144594.rs:3:7 | LL | reuse a as b { | ^ not found in this scope error[E0425]: cannot find value `x` in this scope - --> $DIR/unused-import-ice-144594.rs:8:9 + --> $DIR/unused-import-ice-144594.rs:7:9 | LL | x.add | ^ not found in this scope diff --git a/tests/ui/delegation/zero-args-delegations-ice-154332.rs b/tests/ui/delegation/zero-args-delegations-ice-154332.rs index c684803014ad7..a9d7876db5e87 100644 --- a/tests/ui/delegation/zero-args-delegations-ice-154332.rs +++ b/tests/ui/delegation/zero-args-delegations-ice-154332.rs @@ -1,5 +1,4 @@ #![feature(fn_delegation)] -#![allow(incomplete_features)] mod test_ice { fn a() {} diff --git a/tests/ui/delegation/zero-args-delegations-ice-154332.stderr b/tests/ui/delegation/zero-args-delegations-ice-154332.stderr index dcac56e0b2ba9..517a01dac6f0e 100644 --- a/tests/ui/delegation/zero-args-delegations-ice-154332.stderr +++ b/tests/ui/delegation/zero-args-delegations-ice-154332.stderr @@ -1,5 +1,5 @@ error[E0061]: this function takes 0 arguments but 1 argument was supplied - --> $DIR/zero-args-delegations-ice-154332.rs:7:11 + --> $DIR/zero-args-delegations-ice-154332.rs:6:11 | LL | reuse a as b { | ___________^______- @@ -11,7 +11,7 @@ LL | | } | |_____- unexpected argument of type `()` | note: function defined here - --> $DIR/zero-args-delegations-ice-154332.rs:5:8 + --> $DIR/zero-args-delegations-ice-154332.rs:4:8 | LL | fn a() {} | ^ @@ -22,13 +22,13 @@ LL + reuse { | error[E0061]: this function takes 0 arguments but 1 argument was supplied - --> $DIR/zero-args-delegations-ice-154332.rs:26:21 + --> $DIR/zero-args-delegations-ice-154332.rs:25:21 | LL | reuse to_reuse::zero_args { self } | ^^^^^^^^^ ---- unexpected argument | note: function defined here - --> $DIR/zero-args-delegations-ice-154332.rs:21:16 + --> $DIR/zero-args-delegations-ice-154332.rs:20:16 | LL | pub fn zero_args() -> i32 { | ^^^^^^^^^ From 4d2b607aa8a3ce780c6e14d919ed8b14ce3b5db3 Mon Sep 17 00:00:00 2001 From: Qai Juang <237468078+qaijuang@users.noreply.github.com> Date: Thu, 23 Apr 2026 12:32:33 +0000 Subject: [PATCH 13/20] Fix E0191 suggestion for empty dyn trait args * Fix E0191 suggestion for empty dyn trait args * Fix tidy check * address code nit * fold test into existing E0191 test --- .../src/hir_ty_lowering/errors.rs | 12 ++++++------ ...t-as-dyn-trait-wo-assoc-type-issue-21950.rs | 15 +++++++++++++++ ...-dyn-trait-wo-assoc-type-issue-21950.stderr | 18 ++++++++++++++++-- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs index 784deffce434c..0aa478f99200b 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs @@ -1115,12 +1115,12 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { ) }) .collect(); - // FIXME(fmease): Does not account for `dyn Trait<>` (suggs `dyn Trait<, X = Y>`). - let code = if let Some(snippet) = snippet.strip_suffix('>') { - // The user wrote `Trait<'a>` or similar and we don't have a term we can suggest, - // but at least we can clue them to the correct syntax `Trait<'a, Item = /* ... */>` - // while accounting for the `<'a>` in the suggestion. - format!("{}, {}>", snippet, bindings.join(", ")) + let code = if let Some(snippet) = snippet.strip_suffix("<>") { + // Empty generics + format!("{snippet}<{}>", bindings.join(", ")) + } else if let Some(snippet) = snippet.strip_suffix('>') { + // Non-empty generics + format!("{snippet}, {}>", bindings.join(", ")) } else if in_expr_or_pat { // The user wrote `Trait`, so we don't have a term we can suggest, but at least we // can clue them to the correct syntax `Trait::`. diff --git a/tests/ui/traits/cast-as-dyn-trait-wo-assoc-type-issue-21950.rs b/tests/ui/traits/cast-as-dyn-trait-wo-assoc-type-issue-21950.rs index 3c3815054502f..f677a7fceeeab 100644 --- a/tests/ui/traits/cast-as-dyn-trait-wo-assoc-type-issue-21950.rs +++ b/tests/ui/traits/cast-as-dyn-trait-wo-assoc-type-issue-21950.rs @@ -12,8 +12,23 @@ impl Add for i32 { type Output = i32; } +trait Meow { + type Assoc; +} + +struct Cat; + +impl Meow for Cat { + type Assoc = i32; +} + fn main() { let x = &10 as &dyn Add; //OK let x = &10 as &dyn Add; //~^ ERROR E0191 + + // Regression test for https://github.com/rust-lang/rust/issues/155578. + let cat = Cat; + let _: &dyn Meow<> = &cat; + //~^ ERROR E0191 } diff --git a/tests/ui/traits/cast-as-dyn-trait-wo-assoc-type-issue-21950.stderr b/tests/ui/traits/cast-as-dyn-trait-wo-assoc-type-issue-21950.stderr index 1d9d46489ae10..831dc5431a4d9 100644 --- a/tests/ui/traits/cast-as-dyn-trait-wo-assoc-type-issue-21950.stderr +++ b/tests/ui/traits/cast-as-dyn-trait-wo-assoc-type-issue-21950.stderr @@ -1,5 +1,5 @@ error[E0191]: the value of the associated type `Output` in `Add` must be specified - --> $DIR/cast-as-dyn-trait-wo-assoc-type-issue-21950.rs:17:25 + --> $DIR/cast-as-dyn-trait-wo-assoc-type-issue-21950.rs:27:25 | LL | type Output; | ----------- `Output` defined here @@ -12,6 +12,20 @@ help: specify the associated type LL | let x = &10 as &dyn Add; | +++++++++++++++++++++ -error: aborting due to 1 previous error +error[E0191]: the value of the associated type `Assoc` in `Meow` must be specified + --> $DIR/cast-as-dyn-trait-wo-assoc-type-issue-21950.rs:32:17 + | +LL | type Assoc; + | ---------- `Assoc` defined here +... +LL | let _: &dyn Meow<> = &cat; + | ^^^^^^ + | +help: specify the associated type + | +LL | let _: &dyn Meow = &cat; + | ++++++++++++++++++ + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0191`. From 359910e21ec021b7d9977c4454ee02adec990911 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 22 Apr 2026 23:16:12 +0200 Subject: [PATCH 14/20] Remove `AttributeLintKind::MalformedDoc` variant --- .../rustc_attr_parsing/src/attributes/doc.rs | 17 +++++++++-------- compiler/rustc_attr_parsing/src/errors.rs | 7 +++++++ compiler/rustc_lint/src/early/diagnostics.rs | 2 -- compiler/rustc_lint/src/lints.rs | 7 ------- compiler/rustc_lint_defs/src/lib.rs | 1 - 5 files changed, 16 insertions(+), 18 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/doc.rs b/compiler/rustc_attr_parsing/src/attributes/doc.rs index 2b6d56c411939..aac0adfff5f09 100644 --- a/compiler/rustc_attr_parsing/src/attributes/doc.rs +++ b/compiler/rustc_attr_parsing/src/attributes/doc.rs @@ -18,6 +18,7 @@ use crate::errors::{ DocAutoCfgHideShowExpectsList, DocAutoCfgHideShowUnexpectedItem, DocAutoCfgWrongLiteral, DocTestLiteral, DocTestTakesList, DocTestUnknown, DocUnknownAny, DocUnknownInclude, DocUnknownPasses, DocUnknownPlugins, DocUnknownSpotlight, IllFormedAttributeInput, + MalformedDoc, }; use crate::parser::{ArgParser, MetaItemOrLitParser, MetaItemParser, OwnedPathParser}; use crate::session_diagnostics::{ @@ -107,9 +108,9 @@ fn expected_string_literal( span: Span, _actual_literal: Option<&MetaItemLit>, ) { - cx.emit_lint( + cx.emit_dyn_lint( rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES, - AttributeLintKind::MalformedDoc, + |dcx, level| MalformedDoc.into_diag(dcx, level), span, ); } @@ -203,9 +204,9 @@ impl DocParser { // FIXME: remove this method once merged and uncomment the line below instead. // cx.expected_list(cx.attr_span, args); let span = cx.attr_span; - cx.emit_lint( + cx.emit_dyn_lint( rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES, - AttributeLintKind::MalformedDoc, + |dcx, level| MalformedDoc.into_diag(dcx, level), span, ); return; @@ -399,9 +400,9 @@ impl DocParser { // FIXME: remove this method once merged and uncomment the line // below instead. // cx.expected_identifier(sub_item.path().span()); - cx.emit_lint( + cx.emit_dyn_lint( rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES, - AttributeLintKind::MalformedDoc, + |dcx, level| MalformedDoc.into_diag(dcx, level), sub_item.path().span(), ); continue; @@ -605,9 +606,9 @@ impl DocParser { // FIXME: remove this method once merged and uncomment the line // below instead. // cx.unexpected_literal(lit.span); - cx.emit_lint( + cx.emit_dyn_lint( rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES, - AttributeLintKind::MalformedDoc, + |dcx, level| MalformedDoc.into_diag(dcx, level), lit.span, ); } diff --git a/compiler/rustc_attr_parsing/src/errors.rs b/compiler/rustc_attr_parsing/src/errors.rs index d3e6845799e7f..aca238ead7c10 100644 --- a/compiler/rustc_attr_parsing/src/errors.rs +++ b/compiler/rustc_attr_parsing/src/errors.rs @@ -325,3 +325,10 @@ pub(crate) struct IncorrectDoNotRecommendLocation { #[label("not a trait implementation")] pub target_span: Span, } + +#[derive(Diagnostic)] +#[diag("malformed `doc` attribute input")] +#[warning( + "this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!" +)] +pub(crate) struct MalformedDoc; diff --git a/compiler/rustc_lint/src/early/diagnostics.rs b/compiler/rustc_lint/src/early/diagnostics.rs index 92c4748483278..60d6daf222e63 100644 --- a/compiler/rustc_lint/src/early/diagnostics.rs +++ b/compiler/rustc_lint/src/early/diagnostics.rs @@ -43,8 +43,6 @@ impl<'a> Diagnostic<'a, ()> for DecorateAttrLint<'_, '_, '_> { .into_diag(dcx, level) } - &AttributeLintKind::MalformedDoc => lints::MalformedDoc.into_diag(dcx, level), - &AttributeLintKind::ExpectedNoArgs => lints::ExpectedNoArgs.into_diag(dcx, level), &AttributeLintKind::ExpectedNameValue => lints::ExpectedNameValue.into_diag(dcx, level), diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index ccbc325648e38..5da9f2a9a7467 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -3282,13 +3282,6 @@ impl Subdiagnostic for MismatchedLifetimeSyntaxesSuggestion { } } -#[derive(Diagnostic)] -#[diag("malformed `doc` attribute input")] -#[warning( - "this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!" -)] -pub(crate) struct MalformedDoc; - #[derive(Diagnostic)] #[diag("didn't expect any arguments here")] #[warning( diff --git a/compiler/rustc_lint_defs/src/lib.rs b/compiler/rustc_lint_defs/src/lib.rs index 45ac2c59b04e9..2a34e8b641dd3 100644 --- a/compiler/rustc_lint_defs/src/lib.rs +++ b/compiler/rustc_lint_defs/src/lib.rs @@ -656,7 +656,6 @@ pub enum DeprecatedSinceKind { pub enum AttributeLintKind { UnexpectedCfgName((Symbol, Span), Option<(Symbol, Span)>), UnexpectedCfgValue((Symbol, Span), Option<(Symbol, Span)>), - MalformedDoc, ExpectedNoArgs, ExpectedNameValue, MalFormedDiagnosticAttribute { attribute: &'static str, options: &'static str, span: Span }, From af3652c1dc655456710c24831ad65d48d9a58984 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 22 Apr 2026 23:18:28 +0200 Subject: [PATCH 15/20] Remove `AttributeLintKind::ExpectedNoArgs` variant --- compiler/rustc_attr_parsing/src/attributes/doc.rs | 8 ++++---- compiler/rustc_attr_parsing/src/errors.rs | 7 +++++++ compiler/rustc_lint/src/early/diagnostics.rs | 2 -- compiler/rustc_lint/src/lints.rs | 7 ------- compiler/rustc_lint_defs/src/lib.rs | 1 - 5 files changed, 11 insertions(+), 14 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/doc.rs b/compiler/rustc_attr_parsing/src/attributes/doc.rs index aac0adfff5f09..c6065743d7f79 100644 --- a/compiler/rustc_attr_parsing/src/attributes/doc.rs +++ b/compiler/rustc_attr_parsing/src/attributes/doc.rs @@ -17,8 +17,8 @@ use crate::errors::{ AttrCrateLevelOnly, DocAliasDuplicated, DocAutoCfgExpectsHideOrShow, DocAutoCfgHideShowExpectsList, DocAutoCfgHideShowUnexpectedItem, DocAutoCfgWrongLiteral, DocTestLiteral, DocTestTakesList, DocTestUnknown, DocUnknownAny, DocUnknownInclude, - DocUnknownPasses, DocUnknownPlugins, DocUnknownSpotlight, IllFormedAttributeInput, - MalformedDoc, + DocUnknownPasses, DocUnknownPlugins, DocUnknownSpotlight, ExpectedNoArgs, + IllFormedAttributeInput, MalformedDoc, }; use crate::parser::{ArgParser, MetaItemOrLitParser, MetaItemParser, OwnedPathParser}; use crate::session_diagnostics::{ @@ -94,9 +94,9 @@ fn expected_name_value( // FIXME: remove this method once merged and use `cx.expected_no_args(span)` instead. fn expected_no_args(cx: &mut AcceptContext<'_, '_, S>, span: Span) { - cx.emit_lint( + cx.emit_dyn_lint( rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES, - AttributeLintKind::ExpectedNoArgs, + |dcx, level| ExpectedNoArgs.into_diag(dcx, level), span, ); } diff --git a/compiler/rustc_attr_parsing/src/errors.rs b/compiler/rustc_attr_parsing/src/errors.rs index aca238ead7c10..b3e66abddd411 100644 --- a/compiler/rustc_attr_parsing/src/errors.rs +++ b/compiler/rustc_attr_parsing/src/errors.rs @@ -332,3 +332,10 @@ pub(crate) struct IncorrectDoNotRecommendLocation { "this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!" )] pub(crate) struct MalformedDoc; + +#[derive(Diagnostic)] +#[diag("didn't expect any arguments here")] +#[warning( + "this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!" +)] +pub(crate) struct ExpectedNoArgs; diff --git a/compiler/rustc_lint/src/early/diagnostics.rs b/compiler/rustc_lint/src/early/diagnostics.rs index 60d6daf222e63..fd10e240a726e 100644 --- a/compiler/rustc_lint/src/early/diagnostics.rs +++ b/compiler/rustc_lint/src/early/diagnostics.rs @@ -43,8 +43,6 @@ impl<'a> Diagnostic<'a, ()> for DecorateAttrLint<'_, '_, '_> { .into_diag(dcx, level) } - &AttributeLintKind::ExpectedNoArgs => lints::ExpectedNoArgs.into_diag(dcx, level), - &AttributeLintKind::ExpectedNameValue => lints::ExpectedNameValue.into_diag(dcx, level), &AttributeLintKind::MalFormedDiagnosticAttribute { attribute, options, span } => { lints::MalFormedDiagnosticAttributeLint { attribute, options, span } diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 5da9f2a9a7467..d22e2bebd5aa0 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -3282,13 +3282,6 @@ impl Subdiagnostic for MismatchedLifetimeSyntaxesSuggestion { } } -#[derive(Diagnostic)] -#[diag("didn't expect any arguments here")] -#[warning( - "this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!" -)] -pub(crate) struct ExpectedNoArgs; - #[derive(Diagnostic)] #[diag("expected this to be of the form `... = \"...\"`")] #[warning( diff --git a/compiler/rustc_lint_defs/src/lib.rs b/compiler/rustc_lint_defs/src/lib.rs index 2a34e8b641dd3..57860d5676674 100644 --- a/compiler/rustc_lint_defs/src/lib.rs +++ b/compiler/rustc_lint_defs/src/lib.rs @@ -656,7 +656,6 @@ pub enum DeprecatedSinceKind { pub enum AttributeLintKind { UnexpectedCfgName((Symbol, Span), Option<(Symbol, Span)>), UnexpectedCfgValue((Symbol, Span), Option<(Symbol, Span)>), - ExpectedNoArgs, ExpectedNameValue, MalFormedDiagnosticAttribute { attribute: &'static str, options: &'static str, span: Span }, MalformedDiagnosticFormat { warning: FormatWarning }, From ad11f2efec0c2cd6e52d068a5c0bff1ebd37ac83 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 22 Apr 2026 23:22:06 +0200 Subject: [PATCH 16/20] Remove `AttributeLintKind::ExpectedNameValue` variant --- compiler/rustc_attr_parsing/src/attributes/doc.rs | 7 +++---- compiler/rustc_attr_parsing/src/errors.rs | 7 +++++++ compiler/rustc_lint/src/early/diagnostics.rs | 1 - compiler/rustc_lint/src/lints.rs | 7 ------- compiler/rustc_lint_defs/src/lib.rs | 1 - 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/doc.rs b/compiler/rustc_attr_parsing/src/attributes/doc.rs index c6065743d7f79..321f6e08a733f 100644 --- a/compiler/rustc_attr_parsing/src/attributes/doc.rs +++ b/compiler/rustc_attr_parsing/src/attributes/doc.rs @@ -5,7 +5,6 @@ use rustc_hir::Target; use rustc_hir::attrs::{ AttributeKind, CfgEntry, CfgHideShow, CfgInfo, DocAttribute, DocInline, HideOrShow, }; -use rustc_hir::lints::AttributeLintKind; use rustc_session::parse::feature_err; use rustc_span::{Span, Symbol, edition, sym}; use thin_vec::ThinVec; @@ -17,7 +16,7 @@ use crate::errors::{ AttrCrateLevelOnly, DocAliasDuplicated, DocAutoCfgExpectsHideOrShow, DocAutoCfgHideShowExpectsList, DocAutoCfgHideShowUnexpectedItem, DocAutoCfgWrongLiteral, DocTestLiteral, DocTestTakesList, DocTestUnknown, DocUnknownAny, DocUnknownInclude, - DocUnknownPasses, DocUnknownPlugins, DocUnknownSpotlight, ExpectedNoArgs, + DocUnknownPasses, DocUnknownPlugins, DocUnknownSpotlight, ExpectedNameValue, ExpectedNoArgs, IllFormedAttributeInput, MalformedDoc, }; use crate::parser::{ArgParser, MetaItemOrLitParser, MetaItemParser, OwnedPathParser}; @@ -85,9 +84,9 @@ fn expected_name_value( span: Span, _name: Option, ) { - cx.emit_lint( + cx.emit_dyn_lint( rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES, - AttributeLintKind::ExpectedNameValue, + |dcx, level| ExpectedNameValue.into_diag(dcx, level), span, ); } diff --git a/compiler/rustc_attr_parsing/src/errors.rs b/compiler/rustc_attr_parsing/src/errors.rs index b3e66abddd411..4dc585b55a777 100644 --- a/compiler/rustc_attr_parsing/src/errors.rs +++ b/compiler/rustc_attr_parsing/src/errors.rs @@ -339,3 +339,10 @@ pub(crate) struct MalformedDoc; "this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!" )] pub(crate) struct ExpectedNoArgs; + +#[derive(Diagnostic)] +#[diag("expected this to be of the form `... = \"...\"`")] +#[warning( + "this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!" +)] +pub(crate) struct ExpectedNameValue; diff --git a/compiler/rustc_lint/src/early/diagnostics.rs b/compiler/rustc_lint/src/early/diagnostics.rs index fd10e240a726e..473c7bbc8b9fc 100644 --- a/compiler/rustc_lint/src/early/diagnostics.rs +++ b/compiler/rustc_lint/src/early/diagnostics.rs @@ -43,7 +43,6 @@ impl<'a> Diagnostic<'a, ()> for DecorateAttrLint<'_, '_, '_> { .into_diag(dcx, level) } - &AttributeLintKind::ExpectedNameValue => lints::ExpectedNameValue.into_diag(dcx, level), &AttributeLintKind::MalFormedDiagnosticAttribute { attribute, options, span } => { lints::MalFormedDiagnosticAttributeLint { attribute, options, span } .into_diag(dcx, level) diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index d22e2bebd5aa0..46411eb7df9e1 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -3282,13 +3282,6 @@ impl Subdiagnostic for MismatchedLifetimeSyntaxesSuggestion { } } -#[derive(Diagnostic)] -#[diag("expected this to be of the form `... = \"...\"`")] -#[warning( - "this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!" -)] -pub(crate) struct ExpectedNameValue; - #[derive(Diagnostic)] #[diag("positional format arguments are not allowed here")] #[help( diff --git a/compiler/rustc_lint_defs/src/lib.rs b/compiler/rustc_lint_defs/src/lib.rs index 57860d5676674..e9e1fd75a2d9b 100644 --- a/compiler/rustc_lint_defs/src/lib.rs +++ b/compiler/rustc_lint_defs/src/lib.rs @@ -656,7 +656,6 @@ pub enum DeprecatedSinceKind { pub enum AttributeLintKind { UnexpectedCfgName((Symbol, Span), Option<(Symbol, Span)>), UnexpectedCfgValue((Symbol, Span), Option<(Symbol, Span)>), - ExpectedNameValue, MalFormedDiagnosticAttribute { attribute: &'static str, options: &'static str, span: Span }, MalformedDiagnosticFormat { warning: FormatWarning }, DiagnosticWrappedParserError { description: String, label: String, span: Span }, From 9bf2522cf0156e9f6c2be65f8fbd426672d774a1 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 22 Apr 2026 23:27:22 +0200 Subject: [PATCH 17/20] Remove `AttributeLintKind::MalFormedDiagnosticAttribute` variant --- .../src/attributes/diagnostic/mod.rs | 29 ++++++++++++------- compiler/rustc_attr_parsing/src/errors.rs | 10 +++++++ compiler/rustc_lint/src/early/diagnostics.rs | 4 --- compiler/rustc_lint/src/lints.rs | 10 ------- compiler/rustc_lint_defs/src/lib.rs | 1 - 5 files changed, 28 insertions(+), 26 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs b/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs index 32d73ff32361c..a03b3e5c13467 100644 --- a/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs +++ b/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs @@ -1,6 +1,6 @@ use std::ops::Range; -use rustc_errors::E0232; +use rustc_errors::{Diagnostic, E0232}; use rustc_hir::AttrPath; use rustc_hir::attrs::diagnostic::{ Directive, FilterFormatString, Flag, FormatArg, FormatString, LitOrArg, Name, NameValue, @@ -18,6 +18,7 @@ use rustc_span::{Ident, InnerSpan, Span, Symbol, kw, sym}; use thin_vec::{ThinVec, thin_vec}; use crate::context::{AcceptContext, Stage}; +use crate::errors::MalFormedDiagnosticAttributeLint; use crate::parser::{ArgParser, MetaItemListParser, MetaItemOrLitParser, MetaItemParser}; pub(crate) mod do_not_recommend; @@ -157,12 +158,15 @@ fn parse_list<'p, S: Stage>( ); } ArgParser::NameValue(_) => { - cx.emit_lint( + cx.emit_dyn_lint( MALFORMED_DIAGNOSTIC_ATTRIBUTES, - AttributeLintKind::MalFormedDiagnosticAttribute { - attribute: mode.as_str(), - options: mode.allowed_options(), - span, + move |dcx, level| { + MalFormedDiagnosticAttributeLint { + attribute: mode.as_str(), + options: mode.allowed_options(), + span, + } + .into_diag(dcx, level) }, span, ); @@ -188,12 +192,15 @@ fn parse_directive_items<'p, S: Stage>( let span = item.span(); macro malformed() {{ - cx.emit_lint( + cx.emit_dyn_lint( MALFORMED_DIAGNOSTIC_ATTRIBUTES, - AttributeLintKind::MalFormedDiagnosticAttribute { - attribute: mode.as_str(), - options: mode.allowed_options(), - span, + move |dcx, level| { + MalFormedDiagnosticAttributeLint { + attribute: mode.as_str(), + options: mode.allowed_options(), + span, + } + .into_diag(dcx, level) }, span, ); diff --git a/compiler/rustc_attr_parsing/src/errors.rs b/compiler/rustc_attr_parsing/src/errors.rs index 4dc585b55a777..af2b41bf0ff02 100644 --- a/compiler/rustc_attr_parsing/src/errors.rs +++ b/compiler/rustc_attr_parsing/src/errors.rs @@ -346,3 +346,13 @@ pub(crate) struct ExpectedNoArgs; "this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!" )] pub(crate) struct ExpectedNameValue; + +#[derive(Diagnostic)] +#[diag("malformed `{$attribute}` attribute")] +#[help("{$options}")] +pub(crate) struct MalFormedDiagnosticAttributeLint { + pub attribute: &'static str, + pub options: &'static str, + #[label("invalid option found here")] + pub span: Span, +} diff --git a/compiler/rustc_lint/src/early/diagnostics.rs b/compiler/rustc_lint/src/early/diagnostics.rs index 473c7bbc8b9fc..5bca718ec7b77 100644 --- a/compiler/rustc_lint/src/early/diagnostics.rs +++ b/compiler/rustc_lint/src/early/diagnostics.rs @@ -43,10 +43,6 @@ impl<'a> Diagnostic<'a, ()> for DecorateAttrLint<'_, '_, '_> { .into_diag(dcx, level) } - &AttributeLintKind::MalFormedDiagnosticAttribute { attribute, options, span } => { - lints::MalFormedDiagnosticAttributeLint { attribute, options, span } - .into_diag(dcx, level) - } AttributeLintKind::MalformedDiagnosticFormat { warning } => match warning { FormatWarning::PositionalArgument { .. } => { lints::DisallowedPositionalArgument.into_diag(dcx, level) diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 46411eb7df9e1..891ae0d542f7d 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -3337,13 +3337,3 @@ pub(crate) struct EqInternalMethodImplemented; "only literals are allowed as values for the `message`, `note` and `label` options. These options must be separated by a comma" )] pub(crate) struct NonMetaItemDiagnosticAttribute; - -#[derive(Diagnostic)] -#[diag("malformed `{$attribute}` attribute")] -#[help("{$options}")] -pub(crate) struct MalFormedDiagnosticAttributeLint { - pub attribute: &'static str, - pub options: &'static str, - #[label("invalid option found here")] - pub span: Span, -} diff --git a/compiler/rustc_lint_defs/src/lib.rs b/compiler/rustc_lint_defs/src/lib.rs index e9e1fd75a2d9b..e4b7f74de3a20 100644 --- a/compiler/rustc_lint_defs/src/lib.rs +++ b/compiler/rustc_lint_defs/src/lib.rs @@ -656,7 +656,6 @@ pub enum DeprecatedSinceKind { pub enum AttributeLintKind { UnexpectedCfgName((Symbol, Span), Option<(Symbol, Span)>), UnexpectedCfgValue((Symbol, Span), Option<(Symbol, Span)>), - MalFormedDiagnosticAttribute { attribute: &'static str, options: &'static str, span: Span }, MalformedDiagnosticFormat { warning: FormatWarning }, DiagnosticWrappedParserError { description: String, label: String, span: Span }, IgnoredDiagnosticOption { option_name: Symbol, first_span: Span, later_span: Span }, From eb8be4f99149b66b09f34b9c40689c7a5c73fbc4 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 22 Apr 2026 23:31:49 +0200 Subject: [PATCH 18/20] Remove `AttributeLintKind::MalformedDiagnosticFormat` variant --- .../src/attributes/diagnostic/mod.rs | 19 ++++++++++++++++--- compiler/rustc_attr_parsing/src/errors.rs | 17 +++++++++++++++++ compiler/rustc_lint/src/early/diagnostics.rs | 11 ----------- compiler/rustc_lint/src/lints.rs | 17 ----------------- compiler/rustc_lint_defs/src/lib.rs | 1 - 5 files changed, 33 insertions(+), 32 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs b/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs index a03b3e5c13467..6a0fff1d37f5c 100644 --- a/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs +++ b/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs @@ -18,7 +18,10 @@ use rustc_span::{Ident, InnerSpan, Span, Symbol, kw, sym}; use thin_vec::{ThinVec, thin_vec}; use crate::context::{AcceptContext, Stage}; -use crate::errors::MalFormedDiagnosticAttributeLint; +use crate::errors::{ + DisallowedPlaceholder, DisallowedPositionalArgument, InvalidFormatSpecifier, + MalFormedDiagnosticAttributeLint, +}; use crate::parser::{ArgParser, MetaItemListParser, MetaItemOrLitParser, MetaItemParser}; pub(crate) mod do_not_recommend; @@ -252,9 +255,19 @@ fn parse_directive_items<'p, S: Stage>( let (FormatWarning::InvalidSpecifier { span, .. } | FormatWarning::PositionalArgument { span, .. } | FormatWarning::DisallowedPlaceholder { span }) = warning; - cx.emit_lint( + cx.emit_dyn_lint( MALFORMED_DIAGNOSTIC_FORMAT_LITERALS, - AttributeLintKind::MalformedDiagnosticFormat { warning }, + move |dcx, level| match warning { + FormatWarning::PositionalArgument { .. } => { + DisallowedPositionalArgument.into_diag(dcx, level) + } + FormatWarning::InvalidSpecifier { .. } => { + InvalidFormatSpecifier.into_diag(dcx, level) + } + FormatWarning::DisallowedPlaceholder { .. } => { + DisallowedPlaceholder.into_diag(dcx, level) + } + }, span, ); } diff --git a/compiler/rustc_attr_parsing/src/errors.rs b/compiler/rustc_attr_parsing/src/errors.rs index af2b41bf0ff02..3847f897f85c1 100644 --- a/compiler/rustc_attr_parsing/src/errors.rs +++ b/compiler/rustc_attr_parsing/src/errors.rs @@ -356,3 +356,20 @@ pub(crate) struct MalFormedDiagnosticAttributeLint { #[label("invalid option found here")] pub span: Span, } + +#[derive(Diagnostic)] +#[diag("positional format arguments are not allowed here")] +#[help( + "only named format arguments with the name of one of the generic types are allowed in this context" +)] +pub(crate) struct DisallowedPositionalArgument; + +#[derive(Diagnostic)] +#[diag("format arguments are not allowed here")] +#[help("consider removing this format argument")] +pub(crate) struct DisallowedPlaceholder; + +#[derive(Diagnostic)] +#[diag("invalid format specifier")] +#[help("no format specifier are supported in this position")] +pub(crate) struct InvalidFormatSpecifier; diff --git a/compiler/rustc_lint/src/early/diagnostics.rs b/compiler/rustc_lint/src/early/diagnostics.rs index 5bca718ec7b77..8324043c9809d 100644 --- a/compiler/rustc_lint/src/early/diagnostics.rs +++ b/compiler/rustc_lint/src/early/diagnostics.rs @@ -43,17 +43,6 @@ impl<'a> Diagnostic<'a, ()> for DecorateAttrLint<'_, '_, '_> { .into_diag(dcx, level) } - AttributeLintKind::MalformedDiagnosticFormat { warning } => match warning { - FormatWarning::PositionalArgument { .. } => { - lints::DisallowedPositionalArgument.into_diag(dcx, level) - } - FormatWarning::InvalidSpecifier { .. } => { - lints::InvalidFormatSpecifier.into_diag(dcx, level) - } - FormatWarning::DisallowedPlaceholder { .. } => { - lints::DisallowedPlaceholder.into_diag(dcx, level) - } - }, AttributeLintKind::DiagnosticWrappedParserError { description, label, span } => { lints::WrappedParserError { description, label, span: *span }.into_diag(dcx, level) } diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 891ae0d542f7d..1cfa580b58b8f 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -3282,23 +3282,6 @@ impl Subdiagnostic for MismatchedLifetimeSyntaxesSuggestion { } } -#[derive(Diagnostic)] -#[diag("positional format arguments are not allowed here")] -#[help( - "only named format arguments with the name of one of the generic types are allowed in this context" -)] -pub(crate) struct DisallowedPositionalArgument; - -#[derive(Diagnostic)] -#[diag("format arguments are not allowed here")] -#[help("consider removing this format argument")] -pub(crate) struct DisallowedPlaceholder; - -#[derive(Diagnostic)] -#[diag("invalid format specifier")] -#[help("no format specifier are supported in this position")] -pub(crate) struct InvalidFormatSpecifier; - #[derive(Diagnostic)] #[diag("{$description}")] pub(crate) struct WrappedParserError<'a> { diff --git a/compiler/rustc_lint_defs/src/lib.rs b/compiler/rustc_lint_defs/src/lib.rs index e4b7f74de3a20..5c7fac926a9fc 100644 --- a/compiler/rustc_lint_defs/src/lib.rs +++ b/compiler/rustc_lint_defs/src/lib.rs @@ -656,7 +656,6 @@ pub enum DeprecatedSinceKind { pub enum AttributeLintKind { UnexpectedCfgName((Symbol, Span), Option<(Symbol, Span)>), UnexpectedCfgValue((Symbol, Span), Option<(Symbol, Span)>), - MalformedDiagnosticFormat { warning: FormatWarning }, DiagnosticWrappedParserError { description: String, label: String, span: Span }, IgnoredDiagnosticOption { option_name: Symbol, first_span: Span, later_span: Span }, MissingOptionsForDiagnosticAttribute { attribute: &'static str, options: &'static str }, From f9cb68421555a54569ad36fe039940b5c37a5fa7 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 22 Apr 2026 23:41:43 +0200 Subject: [PATCH 19/20] Remove `AttributeLintKind::DiagnosticWrappedParserError` variant --- .../src/attributes/diagnostic/mod.rs | 15 +++++++++------ compiler/rustc_attr_parsing/src/errors.rs | 9 +++++++++ compiler/rustc_lint/src/early/diagnostics.rs | 5 +---- compiler/rustc_lint/src/lints.rs | 9 --------- compiler/rustc_lint_defs/src/lib.rs | 1 - 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs b/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs index 6a0fff1d37f5c..f6030d6479d1a 100644 --- a/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs +++ b/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs @@ -20,7 +20,7 @@ use thin_vec::{ThinVec, thin_vec}; use crate::context::{AcceptContext, Stage}; use crate::errors::{ DisallowedPlaceholder, DisallowedPositionalArgument, InvalidFormatSpecifier, - MalFormedDiagnosticAttributeLint, + MalFormedDiagnosticAttributeLint, WrappedParserError, }; use crate::parser::{ArgParser, MetaItemListParser, MetaItemOrLitParser, MetaItemParser}; @@ -275,12 +275,15 @@ fn parse_directive_items<'p, S: Stage>( f } Err(e) => { - cx.emit_lint( + cx.emit_dyn_lint( MALFORMED_DIAGNOSTIC_FORMAT_LITERALS, - AttributeLintKind::DiagnosticWrappedParserError { - description: e.description, - label: e.label, - span: slice_span(input.span, e.span, is_snippet), + move |dcx, level| { + WrappedParserError { + description: &e.description, + label: &e.label, + span: slice_span(input.span, e.span.clone(), is_snippet), + } + .into_diag(dcx, level) }, input.span, ); diff --git a/compiler/rustc_attr_parsing/src/errors.rs b/compiler/rustc_attr_parsing/src/errors.rs index 3847f897f85c1..8efb5190d952a 100644 --- a/compiler/rustc_attr_parsing/src/errors.rs +++ b/compiler/rustc_attr_parsing/src/errors.rs @@ -373,3 +373,12 @@ pub(crate) struct DisallowedPlaceholder; #[diag("invalid format specifier")] #[help("no format specifier are supported in this position")] pub(crate) struct InvalidFormatSpecifier; + +#[derive(Diagnostic)] +#[diag("{$description}")] +pub(crate) struct WrappedParserError<'a> { + pub description: &'a str, + #[label("{$label}")] + pub span: Span, + pub label: &'a str, +} diff --git a/compiler/rustc_lint/src/early/diagnostics.rs b/compiler/rustc_lint/src/early/diagnostics.rs index 8324043c9809d..3038a2ed0522f 100644 --- a/compiler/rustc_lint/src/early/diagnostics.rs +++ b/compiler/rustc_lint/src/early/diagnostics.rs @@ -2,7 +2,7 @@ use std::any::Any; use rustc_data_structures::sync::DynSend; use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, Level}; -use rustc_hir::lints::{AttributeLintKind, FormatWarning}; +use rustc_hir::lints::AttributeLintKind; use rustc_middle::ty::TyCtxt; use rustc_session::Session; @@ -43,9 +43,6 @@ impl<'a> Diagnostic<'a, ()> for DecorateAttrLint<'_, '_, '_> { .into_diag(dcx, level) } - AttributeLintKind::DiagnosticWrappedParserError { description, label, span } => { - lints::WrappedParserError { description, label, span: *span }.into_diag(dcx, level) - } &AttributeLintKind::IgnoredDiagnosticOption { option_name, first_span, later_span } => { lints::IgnoredDiagnosticOption { option_name, first_span, later_span } .into_diag(dcx, level) diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 1cfa580b58b8f..6e4c79ecfac90 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -3282,15 +3282,6 @@ impl Subdiagnostic for MismatchedLifetimeSyntaxesSuggestion { } } -#[derive(Diagnostic)] -#[diag("{$description}")] -pub(crate) struct WrappedParserError<'a> { - pub description: &'a str, - #[label("{$label}")] - pub span: Span, - pub label: &'a str, -} - #[derive(Diagnostic)] #[diag("`{$option_name}` is ignored due to previous definition of `{$option_name}`")] pub(crate) struct IgnoredDiagnosticOption { diff --git a/compiler/rustc_lint_defs/src/lib.rs b/compiler/rustc_lint_defs/src/lib.rs index 5c7fac926a9fc..5c45195a41de8 100644 --- a/compiler/rustc_lint_defs/src/lib.rs +++ b/compiler/rustc_lint_defs/src/lib.rs @@ -656,7 +656,6 @@ pub enum DeprecatedSinceKind { pub enum AttributeLintKind { UnexpectedCfgName((Symbol, Span), Option<(Symbol, Span)>), UnexpectedCfgValue((Symbol, Span), Option<(Symbol, Span)>), - DiagnosticWrappedParserError { description: String, label: String, span: Span }, IgnoredDiagnosticOption { option_name: Symbol, first_span: Span, later_span: Span }, MissingOptionsForDiagnosticAttribute { attribute: &'static str, options: &'static str }, NonMetaItemDiagnosticAttribute, From b716ebc7d1cc72bd65f6007c052014f2c631965d Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 22 Apr 2026 23:49:01 +0200 Subject: [PATCH 20/20] Remove `AttributeLintKind::IgnoredDiagnosticOption` variant --- .../src/attributes/diagnostic/mod.rs | 23 ++++++++++--------- compiler/rustc_attr_parsing/src/errors.rs | 10 ++++++++ compiler/rustc_lint/src/early/diagnostics.rs | 4 ---- compiler/rustc_lint/src/lints.rs | 10 -------- compiler/rustc_lint_defs/src/lib.rs | 1 - 5 files changed, 22 insertions(+), 26 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs b/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs index f6030d6479d1a..00e753eea97cd 100644 --- a/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs +++ b/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs @@ -19,8 +19,8 @@ use thin_vec::{ThinVec, thin_vec}; use crate::context::{AcceptContext, Stage}; use crate::errors::{ - DisallowedPlaceholder, DisallowedPositionalArgument, InvalidFormatSpecifier, - MalFormedDiagnosticAttributeLint, WrappedParserError, + DisallowedPlaceholder, DisallowedPositionalArgument, IgnoredDiagnosticOption, + InvalidFormatSpecifier, MalFormedDiagnosticAttributeLint, WrappedParserError, }; use crate::parser::{ArgParser, MetaItemListParser, MetaItemOrLitParser, MetaItemParser}; @@ -116,12 +116,12 @@ fn merge( match (first, later) { (Some(_) | None, None) => {} (Some((first_span, _)), Some((later_span, _))) => { - cx.emit_lint( + let first_span = *first_span; + cx.emit_dyn_lint( MALFORMED_DIAGNOSTIC_ATTRIBUTES, - AttributeLintKind::IgnoredDiagnosticOption { - first_span: *first_span, - later_span, - option_name, + move |dcx, level| { + IgnoredDiagnosticOption { first_span, later_span, option_name } + .into_diag(dcx, level) }, later_span, ); @@ -220,13 +220,14 @@ fn parse_directive_items<'p, S: Stage>( }} macro duplicate($name: ident, $($first_span:tt)*) {{ - cx.emit_lint( + let first_span = $($first_span)*; + cx.emit_dyn_lint( MALFORMED_DIAGNOSTIC_ATTRIBUTES, - AttributeLintKind::IgnoredDiagnosticOption { - first_span: $($first_span)*, + move |dcx, level| IgnoredDiagnosticOption { + first_span, later_span: span, option_name: $name, - }, + }.into_diag(dcx, level), span, ); }} diff --git a/compiler/rustc_attr_parsing/src/errors.rs b/compiler/rustc_attr_parsing/src/errors.rs index 8efb5190d952a..b421e85688958 100644 --- a/compiler/rustc_attr_parsing/src/errors.rs +++ b/compiler/rustc_attr_parsing/src/errors.rs @@ -382,3 +382,13 @@ pub(crate) struct WrappedParserError<'a> { pub span: Span, pub label: &'a str, } + +#[derive(Diagnostic)] +#[diag("`{$option_name}` is ignored due to previous definition of `{$option_name}`")] +pub(crate) struct IgnoredDiagnosticOption { + pub option_name: Symbol, + #[label("`{$option_name}` is first declared here")] + pub first_span: Span, + #[label("`{$option_name}` is later redundantly declared here")] + pub later_span: Span, +} diff --git a/compiler/rustc_lint/src/early/diagnostics.rs b/compiler/rustc_lint/src/early/diagnostics.rs index 3038a2ed0522f..29c302ff2802a 100644 --- a/compiler/rustc_lint/src/early/diagnostics.rs +++ b/compiler/rustc_lint/src/early/diagnostics.rs @@ -43,10 +43,6 @@ impl<'a> Diagnostic<'a, ()> for DecorateAttrLint<'_, '_, '_> { .into_diag(dcx, level) } - &AttributeLintKind::IgnoredDiagnosticOption { option_name, first_span, later_span } => { - lints::IgnoredDiagnosticOption { option_name, first_span, later_span } - .into_diag(dcx, level) - } &AttributeLintKind::MissingOptionsForDiagnosticAttribute { attribute, options } => { lints::MissingOptionsForDiagnosticAttribute { attribute, options } .into_diag(dcx, level) diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 6e4c79ecfac90..c2c140a3c6d92 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -3282,16 +3282,6 @@ impl Subdiagnostic for MismatchedLifetimeSyntaxesSuggestion { } } -#[derive(Diagnostic)] -#[diag("`{$option_name}` is ignored due to previous definition of `{$option_name}`")] -pub(crate) struct IgnoredDiagnosticOption { - pub option_name: Symbol, - #[label("`{$option_name}` is first declared here")] - pub first_span: Span, - #[label("`{$option_name}` is later redundantly declared here")] - pub later_span: Span, -} - #[derive(Diagnostic)] #[diag("missing options for `{$attribute}` attribute")] #[help("{$options}")] diff --git a/compiler/rustc_lint_defs/src/lib.rs b/compiler/rustc_lint_defs/src/lib.rs index 5c45195a41de8..aef62c768337b 100644 --- a/compiler/rustc_lint_defs/src/lib.rs +++ b/compiler/rustc_lint_defs/src/lib.rs @@ -656,7 +656,6 @@ pub enum DeprecatedSinceKind { pub enum AttributeLintKind { UnexpectedCfgName((Symbol, Span), Option<(Symbol, Span)>), UnexpectedCfgValue((Symbol, Span), Option<(Symbol, Span)>), - IgnoredDiagnosticOption { option_name: Symbol, first_span: Span, later_span: Span }, MissingOptionsForDiagnosticAttribute { attribute: &'static str, options: &'static str }, NonMetaItemDiagnosticAttribute, }