diff --git a/compiler/rustc_attr_parsing/src/attributes/allow_unstable.rs b/compiler/rustc_attr_parsing/src/attributes/allow_unstable.rs index c2511ac75d5d2..278b3200a4541 100644 --- a/compiler/rustc_attr_parsing/src/attributes/allow_unstable.rs +++ b/compiler/rustc_attr_parsing/src/attributes/allow_unstable.rs @@ -81,7 +81,7 @@ fn parse_unstable( ) -> impl IntoIterator { let mut res = Vec::new(); - let Some(list) = args.list() else { + let Some(list) = args.as_list() else { cx.emit_err(session_diagnostics::ExpectsFeatureList { span: cx.attr_span, name: symbol.to_ident_string(), diff --git a/compiler/rustc_attr_parsing/src/attributes/cfg.rs b/compiler/rustc_attr_parsing/src/attributes/cfg.rs index 84c83be8b4a5d..c2dda74e9f515 100644 --- a/compiler/rustc_attr_parsing/src/attributes/cfg.rs +++ b/compiler/rustc_attr_parsing/src/attributes/cfg.rs @@ -44,13 +44,9 @@ pub fn parse_cfg( cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser, ) -> Option { - let ArgParser::List(list) = args else { - let attr_span = cx.attr_span; - cx.adcx().expected_list(attr_span, args); - return None; - }; + let list = cx.expect_list(args, cx.attr_span)?; - let Some(single) = list.single() else { + let Some(single) = list.as_single() else { let target = cx.target; let mut adcx = cx.adcx(); if list.is_empty() { @@ -93,7 +89,7 @@ pub fn parse_cfg_entry( MetaItemOrLitParser::MetaItemParser(meta) => match meta.args() { ArgParser::List(list) => match meta.path().word_sym() { Some(sym::not) => { - let Some(single) = list.single() else { + let Some(single) = list.as_single() else { return Err(cx.adcx().expected_single_argument(list.span, list.len())); }; CfgEntry::Not(Box::new(parse_cfg_entry(cx, single)?), list.span) @@ -136,7 +132,7 @@ fn parse_cfg_entry_version( meta_span: Span, ) -> Result { try_gate_cfg(sym::version, meta_span, cx.sess(), cx.features_option()); - let Some(version) = list.single() else { + let Some(version) = list.as_single() else { return Err( cx.emit_err(session_diagnostics::ExpectedSingleVersionLiteral { span: list.span }) ); diff --git a/compiler/rustc_attr_parsing/src/attributes/cfg_select.rs b/compiler/rustc_attr_parsing/src/attributes/cfg_select.rs index 918fd0a4582b7..99d8f557238cb 100644 --- a/compiler/rustc_attr_parsing/src/attributes/cfg_select.rs +++ b/compiler/rustc_attr_parsing/src/attributes/cfg_select.rs @@ -1,15 +1,15 @@ -use rustc_ast::token::Token; +use rustc_ast::token::{CommentKind, Token}; use rustc_ast::tokenstream::TokenStream; use rustc_ast::{AttrStyle, NodeId, token}; use rustc_data_structures::fx::FxHashMap; -use rustc_errors::Diagnostic; +use rustc_errors::{DiagDecorator, Diagnostic}; use rustc_feature::{AttributeTemplate, Features}; use rustc_hir::attrs::CfgEntry; use rustc_hir::{AttrPath, Target}; use rustc_parse::exp; use rustc_parse::parser::{Parser, Recovery}; use rustc_session::Session; -use rustc_session::lint::builtin::UNREACHABLE_CFG_SELECT_PREDICATES; +use rustc_session::lint::builtin::{UNREACHABLE_CFG_SELECT_PREDICATES, UNUSED_DOC_COMMENTS}; use rustc_span::{ErrorGuaranteed, Span, Symbol, sym}; use crate::attributes::AttributeSafety; @@ -78,12 +78,15 @@ pub fn parse_cfg_select( let mut branches = CfgSelectBranches::default(); while p.token != token::Eof { + let doc_comment = eat_outer_doc_comments(p); + if p.eat_keyword(exp!(Underscore)) { let underscore = p.prev_token; p.expect(exp!(FatArrow)).map_err(|e| e.emit())?; let tts = p.parse_delimited_token_tree().map_err(|e| e.emit())?; let span = underscore.span.to(p.token.span); + lint_unused_doc_comment(p, doc_comment, lint_node_id); match branches.wildcard { None => branches.wildcard = Some((underscore, tts, span)), @@ -123,6 +126,7 @@ pub fn parse_cfg_select( let tts = p.parse_delimited_token_tree().map_err(|e| e.emit())?; let span = cfg_span.to(p.token.span); + lint_unused_doc_comment(p, doc_comment, lint_node_id); match branches.wildcard { None => branches.reachable.push((cfg, tts, span)), @@ -143,6 +147,41 @@ pub fn parse_cfg_select( Ok(branches) } +fn eat_outer_doc_comments(p: &mut Parser<'_>) -> Option<(Span, CommentKind)> { + let mut doc_comment: Option<(Span, CommentKind)> = None; + + while let token::DocComment(comment_kind, AttrStyle::Outer, _) = p.token.kind { + let span = p.token.span; + doc_comment = Some(match doc_comment { + Some((prev_span, _)) => (prev_span.with_hi(span.hi()), comment_kind), + None => (span, comment_kind), + }); + p.bump(); + } + + doc_comment +} + +fn lint_unused_doc_comment( + p: &mut Parser<'_>, + doc_comment: Option<(Span, CommentKind)>, + lint_node_id: NodeId, +) { + let Some((span, comment_kind)) = doc_comment else { return }; + let help = match comment_kind { + CommentKind::Line => "use `//` for a plain comment", + CommentKind::Block => "use `/* */` for a plain comment", + }; + p.psess.buffer_lint( + UNUSED_DOC_COMMENTS, + span, + lint_node_id, + DiagDecorator(move |diag| { + diag.primary_message("unused doc comment").help(help); + }), + ); +} + fn lint_unreachable( p: &mut Parser<'_>, predicates: impl Iterator, diff --git a/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs index 357be2f48f85e..ceb4da3df6a22 100644 --- a/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs @@ -24,7 +24,7 @@ impl SingleAttributeParser for OptimizeParser { const TEMPLATE: AttributeTemplate = template!(List: &["size", "speed", "none"]); fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option { - let single = cx.single_element_list(args, cx.attr_span)?; + let single = cx.expect_single_element_list(args, cx.attr_span)?; let res = match single.meta_item().and_then(|i| i.path().word().map(|i| i.name)) { Some(sym::size) => OptimizeAttr::Size, @@ -75,7 +75,7 @@ impl SingleAttributeParser for CoverageParser { const TEMPLATE: AttributeTemplate = template!(OneOf: &[sym::off, sym::on]); fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option { - let arg = cx.single_element_list(args, cx.attr_span)?; + let arg = cx.expect_single_element_list(args, cx.attr_span)?; let mut fail_incorrect_argument = |span| cx.adcx().expected_specific_argument(span, &[sym::on, sym::off]); @@ -371,8 +371,7 @@ impl AttributeParser for UsedParser { let used_by = match args { ArgParser::NoArgs => UsedBy::Default, ArgParser::List(list) => { - let Some(l) = list.single() else { - cx.adcx().expected_single_argument(list.span, list.len()); + let Some(l) = cx.expect_single(list) else { return; }; @@ -463,9 +462,7 @@ fn parse_tf_attribute( args: &ArgParser, ) -> impl IntoIterator { let mut features = Vec::new(); - let ArgParser::List(list) = args else { - let attr_span = cx.attr_span; - cx.adcx().expected_list(attr_span, args); + let Some(list) = cx.expect_list(args, cx.attr_span) else { return features; }; if list.is_empty() { @@ -588,11 +585,7 @@ impl SingleAttributeParser for SanitizeParser { ]); fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option { - let Some(list) = args.list() else { - let attr_span = cx.attr_span; - cx.adcx().expected_list(attr_span, args); - return None; - }; + let list = cx.expect_list(args, cx.attr_span)?; let mut on_set = SanitizerSet::empty(); let mut off_set = SanitizerSet::empty(); @@ -719,11 +712,7 @@ impl SingleAttributeParser for PatchableFunctionEntryParser { const TEMPLATE: AttributeTemplate = template!(List: &["prefix_nops = m, entry_nops = n"]); fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option { - let Some(meta_item_list) = args.list() else { - let attr_span = cx.attr_span; - cx.adcx().expected_list(attr_span, args); - return None; - }; + let meta_item_list = cx.expect_list(args, cx.attr_span)?; let mut prefix = None; let mut entry = None; diff --git a/compiler/rustc_attr_parsing/src/attributes/confusables.rs b/compiler/rustc_attr_parsing/src/attributes/confusables.rs index 4041ce85fa985..4aa6468be889f 100644 --- a/compiler/rustc_attr_parsing/src/attributes/confusables.rs +++ b/compiler/rustc_attr_parsing/src/attributes/confusables.rs @@ -12,11 +12,7 @@ impl AttributeParser for ConfusablesParser { &[sym::rustc_confusables], template!(List: &[r#""name1", "name2", ..."#]), |this, cx, args| { - let Some(list) = args.list() else { - let attr_span = cx.attr_span; - cx.adcx().expected_list(attr_span, args); - return; - }; + let Some(list) = cx.expect_list(args, cx.attr_span) else { return }; if list.is_empty() { cx.emit_err(EmptyConfusables { span: cx.attr_span }); diff --git a/compiler/rustc_attr_parsing/src/attributes/crate_level.rs b/compiler/rustc_attr_parsing/src/attributes/crate_level.rs index 3739461c2004d..451e126dd5c6a 100644 --- a/compiler/rustc_attr_parsing/src/attributes/crate_level.rs +++ b/compiler/rustc_attr_parsing/src/attributes/crate_level.rs @@ -314,9 +314,7 @@ impl CombineAttributeParser for FeatureParser { cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser, ) -> impl IntoIterator { - let ArgParser::List(list) = args else { - let attr_span = cx.attr_span; - cx.adcx().expected_list(attr_span, args); + let Some(list) = cx.expect_list(args, cx.attr_span) else { return Vec::new(); }; @@ -362,9 +360,7 @@ impl CombineAttributeParser for RegisterToolParser { cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser, ) -> impl IntoIterator { - let ArgParser::List(list) = args else { - let attr_span = cx.attr_span; - cx.adcx().expected_list(attr_span, args); + let Some(list) = cx.expect_list(args, cx.attr_span) else { return Vec::new(); }; diff --git a/compiler/rustc_attr_parsing/src/attributes/debugger.rs b/compiler/rustc_attr_parsing/src/attributes/debugger.rs index 65e9b968e946d..f31cf70085442 100644 --- a/compiler/rustc_attr_parsing/src/attributes/debugger.rs +++ b/compiler/rustc_attr_parsing/src/attributes/debugger.rs @@ -20,7 +20,7 @@ impl CombineAttributeParser for DebuggerViualizerParser { cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser, ) -> impl IntoIterator { - let single = cx.single_element_list(args, cx.attr_span)?; + let single = cx.expect_single_element_list(args, cx.attr_span)?; let Some(mi) = single.meta_item() else { cx.adcx().expected_name_value(single.span(), None); return None; diff --git a/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs b/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs index ee99e2904c80d..e56ed166592aa 100644 --- a/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs +++ b/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs @@ -344,7 +344,7 @@ fn parse_directive_items<'p, S: Stage>( } (Mode::RustcOnUnimplemented, sym::on) => { if is_root { - let items = or_malformed!(item.args().list()?); + let items = or_malformed!(item.args().as_list()?); let mut iter = items.mixed(); let condition: &MetaItemOrLitParser = match iter.next() { Some(c) => c, @@ -554,7 +554,7 @@ fn parse_predicate(input: &MetaItemOrLitParser) -> Result Ok(Predicate::Any(parse_predicate_sequence(mis)?)), sym::all => Ok(Predicate::All(parse_predicate_sequence(mis)?)), sym::not => { - if let Some(single) = mis.single() { + if let Some(single) = mis.as_single() { Ok(Predicate::Not(Box::new(parse_predicate(single)?))) } else { Err(InvalidOnClause::ExpectedOnePredInNot { span: mis.span }) diff --git a/compiler/rustc_attr_parsing/src/attributes/doc.rs b/compiler/rustc_attr_parsing/src/attributes/doc.rs index 321f6e08a733f..5d07478b152ee 100644 --- a/compiler/rustc_attr_parsing/src/attributes/doc.rs +++ b/compiler/rustc_attr_parsing/src/attributes/doc.rs @@ -199,7 +199,7 @@ impl DocParser { self.attribute.no_crate_inject = Some(path.span()) } Some(sym::attr) => { - let Some(list) = args.list() else { + let Some(list) = args.as_list() else { // FIXME: remove this method once merged and uncomment the line below instead. // cx.expected_list(cx.attr_span, args); let span = cx.attr_span; @@ -587,7 +587,7 @@ impl DocParser { }), Some(sym::auto_cfg) => self.parse_auto_cfg(cx, path, args), Some(sym::test) => { - let Some(list) = args.list() else { + let Some(list) = args.as_list() else { cx.emit_dyn_lint( rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES, |dcx, level| DocTestTakesList.into_diag(dcx, level), diff --git a/compiler/rustc_attr_parsing/src/attributes/inline.rs b/compiler/rustc_attr_parsing/src/attributes/inline.rs index 32f995753bad3..0fc226add0124 100644 --- a/compiler/rustc_attr_parsing/src/attributes/inline.rs +++ b/compiler/rustc_attr_parsing/src/attributes/inline.rs @@ -37,10 +37,7 @@ impl SingleAttributeParser for InlineParser { match args { ArgParser::NoArgs => Some(AttributeKind::Inline(InlineAttr::Hint, cx.attr_span)), ArgParser::List(list) => { - let Some(l) = list.single() else { - cx.adcx().expected_single_argument(list.span, list.len()); - return None; - }; + let l = cx.expect_single(list)?; match l.meta_item().and_then(|i| i.path().word_sym()) { Some(sym::always) => { @@ -78,10 +75,7 @@ impl SingleAttributeParser for RustcForceInlineParser { let reason = match args { ArgParser::NoArgs => None, ArgParser::List(list) => { - let Some(l) = list.single() else { - cx.adcx().expected_single_argument(list.span, list.len()); - return None; - }; + let l = cx.expect_single(list)?; let Some(reason) = l.lit().and_then(|i| i.kind.str()) else { cx.adcx().expected_string_literal(l.span(), l.lit()); diff --git a/compiler/rustc_attr_parsing/src/attributes/instruction_set.rs b/compiler/rustc_attr_parsing/src/attributes/instruction_set.rs index 36e45a763e172..8a182959f95da 100644 --- a/compiler/rustc_attr_parsing/src/attributes/instruction_set.rs +++ b/compiler/rustc_attr_parsing/src/attributes/instruction_set.rs @@ -19,7 +19,7 @@ impl SingleAttributeParser for InstructionSetParser { fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option { const POSSIBLE_SYMBOLS: &[Symbol] = &[sym::arm_a32, sym::arm_t32]; const POSSIBLE_ARM_SYMBOLS: &[Symbol] = &[sym::a32, sym::t32]; - let maybe_meta_item = cx.single_element_list(args, cx.attr_span)?; + let maybe_meta_item = cx.expect_single_element_list(args, cx.attr_span)?; let Some(meta_item) = maybe_meta_item.meta_item() else { cx.adcx().expected_specific_argument(maybe_meta_item.span(), POSSIBLE_SYMBOLS); diff --git a/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs index 9f48f7f8ab559..ca14e993e5e89 100644 --- a/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs @@ -390,7 +390,7 @@ impl LinkParser { cx.adcx().duplicate_key(item.span(), sym::cfg); return true; } - let Some(link_cfg) = cx.single_element_list(item.args(), item.span()) else { + let Some(link_cfg) = cx.expect_single_element_list(item.args(), item.span()) else { return true; }; if !features.link_cfg() { diff --git a/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs index 7dcf1b3eb0641..f23694a84c4d1 100644 --- a/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs @@ -142,7 +142,7 @@ impl SingleAttributeParser for MacroExportParser { let local_inner_macros = match args { ArgParser::NoArgs => false, ArgParser::List(list) => { - let Some(l) = list.single() else { + let Some(l) = list.as_single() else { cx.adcx().warn_ill_formed_attribute_input(INVALID_MACRO_EXPORT_ARGUMENTS); return None; }; @@ -174,7 +174,7 @@ impl SingleAttributeParser for CollapseDebugInfoParser { const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::MacroDef)]); fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option { - let single = cx.single_element_list(args, cx.attr_span)?; + let single = cx.expect_single_element_list(args, cx.attr_span)?; let Some(mi) = single.meta_item() else { cx.adcx().expected_not_literal(single.span()); return None; diff --git a/compiler/rustc_attr_parsing/src/attributes/proc_macro_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/proc_macro_attrs.rs index 76dc171c6831e..e57a34e7888a7 100644 --- a/compiler/rustc_attr_parsing/src/attributes/proc_macro_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/proc_macro_attrs.rs @@ -57,7 +57,7 @@ fn parse_derive_like( args: &ArgParser, trait_name_mandatory: bool, ) -> Option<(Option, ThinVec)> { - let Some(list) = args.list() else { + let Some(list) = args.as_list() else { // For #[rustc_builtin_macro], it is permitted to leave out the trait name if args.no_args().is_ok() && !trait_name_mandatory { return Some((None, ThinVec::new())); @@ -101,10 +101,7 @@ fn parse_derive_like( cx.adcx().expected_specific_argument(attrs.span(), &[sym::attributes]); return None; } - let Some(attr_list) = attr_list.args().list() else { - cx.adcx().expected_list(attrs.span(), attr_list.args()); - return None; - }; + let attr_list = cx.expect_list(attr_list.args(), attrs.span())?; // Parse item in `attributes(...)` argument for attr in attr_list.mixed() { diff --git a/compiler/rustc_attr_parsing/src/attributes/prototype.rs b/compiler/rustc_attr_parsing/src/attributes/prototype.rs index b6110f627a8cf..1778c68832a3c 100644 --- a/compiler/rustc_attr_parsing/src/attributes/prototype.rs +++ b/compiler/rustc_attr_parsing/src/attributes/prototype.rs @@ -22,11 +22,7 @@ impl SingleAttributeParser for CustomMirParser { const TEMPLATE: AttributeTemplate = template!(List: &[r#"dialect = "...", phase = "...""#]); fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option { - let Some(list) = args.list() else { - let attr_span = cx.attr_span; - cx.adcx().expected_list(attr_span, args); - return None; - }; + let list = cx.expect_list(args, cx.attr_span)?; let mut dialect = None; let mut phase = None; diff --git a/compiler/rustc_attr_parsing/src/attributes/repr.rs b/compiler/rustc_attr_parsing/src/attributes/repr.rs index 71a41384d213c..a90fa7d749f8e 100644 --- a/compiler/rustc_attr_parsing/src/attributes/repr.rs +++ b/compiler/rustc_attr_parsing/src/attributes/repr.rs @@ -32,9 +32,7 @@ impl CombineAttributeParser for ReprParser { ) -> impl IntoIterator { let mut reprs = Vec::new(); - let Some(list) = args.list() else { - let attr_span = cx.attr_span; - cx.adcx().expected_list(attr_span, args); + let Some(list) = cx.expect_list(args, cx.attr_span) else { return reprs; }; @@ -197,7 +195,7 @@ fn parse_repr_align( ) -> Option { use AlignKind::*; - let Some(align) = list.single() else { + let Some(align) = list.as_single() else { match align_kind { Packed => { cx.emit_err(session_diagnostics::IncorrectReprFormatPackedOneOrZeroArg { @@ -296,8 +294,7 @@ impl RustcAlignParser { cx.adcx().expected_list(attr_span, args); } ArgParser::List(list) => { - let Some(align) = list.single() else { - cx.adcx().expected_single_argument(list.span, list.len()); + let Some(align) = cx.expect_single(list) else { return; }; diff --git a/compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs b/compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs index e6f97683c6127..3a9eb71f31362 100644 --- a/compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs +++ b/compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs @@ -96,9 +96,7 @@ impl CombineAttributeParser for RustcDumpLayoutParser { cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser, ) -> impl IntoIterator { - let ArgParser::List(items) = args else { - let attr_span = cx.attr_span; - cx.adcx().expected_list(attr_span, args); + let Some(items) = cx.expect_list(args, cx.attr_span) else { return vec![]; }; diff --git a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs index 3f4049366f405..1d35923339eb7 100644 --- a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs +++ b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs @@ -30,11 +30,7 @@ impl SingleAttributeParser for RustcMustImplementOneOfParser { const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Trait)]); const TEMPLATE: AttributeTemplate = template!(List: &["function1, function2, ..."]); fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option { - let Some(list) = args.list() else { - let span = cx.attr_span; - cx.adcx().expected_list(span, args); - return None; - }; + let list = cx.expect_list(args, cx.attr_span)?; let mut fn_names = ThinVec::new(); @@ -130,11 +126,7 @@ impl SingleAttributeParser for RustcLegacyConstGenericsParser { const TEMPLATE: AttributeTemplate = template!(List: &["N"]); fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option { - let ArgParser::List(meta_items) = args else { - let attr_span = cx.attr_span; - cx.adcx().expected_list(attr_span, args); - return None; - }; + let meta_items = cx.expect_list(args, cx.attr_span)?; let mut parsed_indexes = ThinVec::new(); let mut errored = false; @@ -185,7 +177,7 @@ impl SingleAttributeParser for RustcLintOptDenyFieldAccessParser { const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Field)]); const TEMPLATE: AttributeTemplate = template!(Word); fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option { - let arg = cx.single_element_list(args, cx.attr_span)?; + let arg = cx.expect_single_element_list(args, cx.attr_span)?; let MetaItemOrLitParser::Lit(MetaItemLit { kind: LitKind::Str(lint_message, _), .. }) = arg else { @@ -210,11 +202,7 @@ fn parse_cgu_fields( args: &ArgParser, accepts_kind: bool, ) -> Option<(Symbol, Symbol, Option)> { - let Some(args) = args.list() else { - let attr_span = cx.attr_span; - cx.adcx().expected_list(attr_span, args); - return None; - }; + let args = cx.expect_list(args, cx.attr_span)?; let mut cfg = None::<(Symbol, Span)>; let mut module = None::<(Symbol, Span)>; @@ -359,7 +347,7 @@ impl SingleAttributeParser for RustcDeprecatedSafe2024Parser { const TEMPLATE: AttributeTemplate = template!(List: &[r#"audit_that = "...""#]); fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option { - let single = cx.single_element_list(args, cx.attr_span)?; + let single = cx.expect_single_element_list(args, cx.attr_span)?; let Some(arg) = single.meta_item() else { cx.adcx().expected_name_value(single.span(), None); @@ -418,11 +406,7 @@ impl SingleAttributeParser for RustcNeverTypeOptionsParser { ]); fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option { - let Some(list) = args.list() else { - let attr_span = cx.attr_span; - cx.adcx().expected_list(attr_span, args); - return None; - }; + let list = cx.expect_list(args, cx.attr_span)?; let mut fallback = None::; let mut diverging_block_default = None::; @@ -703,9 +687,7 @@ impl CombineAttributeParser for RustcMirParser { cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser, ) -> impl IntoIterator { - let Some(list) = args.list() else { - let attr_span = cx.attr_span; - cx.adcx().expected_list(attr_span, args); + let Some(list) = cx.expect_list(args, cx.attr_span) else { return ThinVec::new(); }; @@ -825,11 +807,8 @@ impl CombineAttributeParser for RustcCleanParser { if !cx.cx.sess.opts.unstable_opts.query_dep_graph { cx.emit_err(AttributeRequiresOpt { span: cx.attr_span, opt: "-Z query-dep-graph" }); } - let Some(list) = args.list() else { - let attr_span = cx.attr_span; - cx.adcx().expected_list(attr_span, args); - return None; - }; + let list = cx.expect_list(args, cx.attr_span)?; + let mut except = None; let mut loaded_from_disk = None; let mut cfg = None; @@ -926,11 +905,7 @@ impl SingleAttributeParser for RustcIfThisChangedParser { match args { ArgParser::NoArgs => Some(AttributeKind::RustcIfThisChanged(cx.attr_span, None)), ArgParser::List(list) => { - let Some(item) = list.single() else { - let attr_span = cx.attr_span; - cx.adcx().expected_single_argument(attr_span, list.len()); - return None; - }; + let item = cx.expect_single(list)?; let Some(ident) = item.meta_item().and_then(|item| item.ident()) else { cx.adcx().expected_identifier(item.span()); return None; @@ -988,7 +963,7 @@ impl CombineAttributeParser for RustcThenThisWouldNeedParser { if !cx.cx.sess.opts.unstable_opts.query_dep_graph { cx.emit_err(AttributeRequiresOpt { span: cx.attr_span, opt: "-Z query-dep-graph" }); } - let item = cx.single_element_list(args, cx.attr_span)?; + let item = cx.expect_single_element_list(args, cx.attr_span)?; let Some(ident) = item.meta_item().and_then(|item| item.ident()) else { cx.adcx().expected_identifier(item.span()); return None; diff --git a/compiler/rustc_attr_parsing/src/attributes/stability.rs b/compiler/rustc_attr_parsing/src/attributes/stability.rs index 0559469bc3691..f6f964fb4d69e 100644 --- a/compiler/rustc_attr_parsing/src/attributes/stability.rs +++ b/compiler/rustc_attr_parsing/src/attributes/stability.rs @@ -311,11 +311,7 @@ pub(crate) fn parse_stability( let mut feature = None; let mut since = None; - let ArgParser::List(list) = args else { - let attr_span = cx.attr_span; - cx.adcx().expected_list(attr_span, args); - return None; - }; + let list = cx.expect_list(args, cx.attr_span)?; for param in list.mixed() { let param_span = param.span(); @@ -383,11 +379,7 @@ pub(crate) fn parse_unstability( let mut implied_by = None; let mut old_name = None; - let ArgParser::List(list) = args else { - let attr_span = cx.attr_span; - cx.adcx().expected_list(attr_span, args); - return None; - }; + let list = cx.expect_list(args, cx.attr_span)?; for param in list.mixed() { let Some(param) = param.meta_item() else { @@ -503,11 +495,7 @@ impl CombineAttributeParser for UnstableRemovedParser { return None; } - let ArgParser::List(list) = args else { - let attr_span = cx.attr_span; - cx.adcx().expected_list(attr_span, args); - return None; - }; + let list = cx.expect_list(args, cx.attr_span)?; for param in list.mixed() { let Some(param) = param.meta_item() else { diff --git a/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs index 06087c8a4baa1..456b29d0c3aa3 100644 --- a/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs @@ -28,10 +28,11 @@ impl SingleAttributeParser for IgnoreParser { Some(str_value) } ArgParser::List(list) => { - let help = list.single().and_then(|item| item.meta_item()).and_then(|item| { - item.args().no_args().ok()?; - Some(item.path().to_string()) - }); + let help = + list.as_single().and_then(|item| item.meta_item()).and_then(|item| { + item.args().no_args().ok()?; + Some(item.path().to_string()) + }); cx.adcx().warn_ill_formed_attribute_input_with_help( ILL_FORMED_ATTRIBUTE_INPUT, help, @@ -71,10 +72,7 @@ impl SingleAttributeParser for ShouldPanicParser { Some(str_value) } ArgParser::List(list) => { - let Some(single) = list.single() else { - cx.adcx().expected_single_argument(list.span, list.len()); - return None; - }; + let single = cx.expect_single(list)?; let Some(single) = single.meta_item() else { cx.adcx().expected_name_value(single.span(), Some(sym::expected)); return None; @@ -140,17 +138,13 @@ impl SingleAttributeParser for RustcAbiParser { ]); fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option { - let Some(args) = args.list() else { + let Some(args) = args.as_list() else { let attr_span = cx.attr_span; cx.adcx().expected_specific_argument_and_list(attr_span, &[sym::assert_eq, sym::debug]); return None; }; - let Some(arg) = args.single() else { - let attr_span = cx.attr_span; - cx.adcx().expected_single_argument(attr_span, args.len()); - return None; - }; + let arg = cx.expect_single(args)?; let mut fail_incorrect_argument = |span| cx.adcx().expected_specific_argument(span, &[sym::assert_eq, sym::debug]); @@ -203,7 +197,7 @@ impl SingleAttributeParser for TestRunnerParser { const TEMPLATE: AttributeTemplate = template!(List: &["path"]); fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option { - let single = cx.single_element_list(args, cx.attr_span)?; + let single = cx.expect_single_element_list(args, cx.attr_span)?; let Some(meta) = single.meta_item() else { cx.adcx().expected_not_literal(single.span()); diff --git a/compiler/rustc_attr_parsing/src/attributes/traits.rs b/compiler/rustc_attr_parsing/src/attributes/traits.rs index b2a9addfeab3c..d3eb62a4c60d8 100644 --- a/compiler/rustc_attr_parsing/src/attributes/traits.rs +++ b/compiler/rustc_attr_parsing/src/attributes/traits.rs @@ -17,11 +17,7 @@ impl SingleAttributeParser for RustcSkipDuringMethodDispatchParser fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option { let mut array = false; let mut boxed_slice = false; - let Some(args) = args.list() else { - let attr_span = cx.attr_span; - cx.adcx().expected_list(attr_span, args); - return None; - }; + let args = cx.expect_list(args, cx.attr_span)?; if args.is_empty() { cx.adcx().expected_at_least_one_argument(args.span); return None; diff --git a/compiler/rustc_attr_parsing/src/attributes/util.rs b/compiler/rustc_attr_parsing/src/attributes/util.rs index 98f8cc23b5001..1f91b1a583096 100644 --- a/compiler/rustc_attr_parsing/src/attributes/util.rs +++ b/compiler/rustc_attr_parsing/src/attributes/util.rs @@ -41,7 +41,7 @@ pub(crate) fn parse_single_integer( cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser, ) -> Option { - let single = cx.single_element_list(args, cx.attr_span)?; + let single = cx.expect_single_element_list(args, cx.attr_span)?; let Some(lit) = single.lit() else { cx.adcx().expected_integer_literal(single.span()); return None; diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index 5ced5d5f975a0..cebbabfcbf1be 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -61,7 +61,7 @@ use crate::attributes::test_attrs::*; use crate::attributes::traits::*; use crate::attributes::transparency::*; use crate::attributes::{AttributeParser as _, AttributeSafety, Combine, Single, WithoutArgs}; -use crate::parser::{ArgParser, MetaItemOrLitParser, RefPathParser}; +use crate::parser::{ArgParser, MetaItemListParser, MetaItemOrLitParser, RefPathParser}; use crate::session_diagnostics::{ AttributeParseError, AttributeParseErrorReason, AttributeParseErrorSuggestions, ParsedDescription, @@ -554,7 +554,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> { /// /// The provided span is used as a fallback for diagnostic generation in case `arg` does not /// contain any. It should be the span of the node that contains `arg`. - pub(crate) fn single_element_list<'arg>( + pub(crate) fn expect_single_element_list<'arg>( &mut self, arg: &'arg ArgParser, span: Span, @@ -564,13 +564,59 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> { return None; }; - let Some(single) = l.single() else { + let Some(single) = l.as_single() else { self.adcx().expected_single_argument(l.span, l.len()); return None; }; Some(single) } + + /// Asserts that an [`ArgParser`] is a list and returns it, or emits an error and returns + /// `None`. + /// + /// Some examples: + /// + /// - `#[allow(clippy::complexity)]`: `(clippy::complexity)` is a list + /// - `#[rustfmt::skip::macros(target_macro_name)]`: `(target_macro_name)` is a list + /// + /// This is a higher-level (and harder to misuse) wrapper over [`ArgParser::as_list`]. That + /// allows using `?` when the attribute parsing function allows it. You may still want to use + /// [`ArgParser::as_list`] for the following reasons: + /// + /// - You want to emit your own diagnostics (for instance, with [`SharedContext::emit_err`]). + /// - The attribute can be parsed in multiple ways and it does not make sense to emit an error. + pub(crate) fn expect_list<'arg>( + &mut self, + args: &'arg ArgParser, + span: Span, + ) -> Option<&'arg MetaItemListParser> { + let list = args.as_list(); + if list.is_none() { + self.adcx().expected_list(span, args); + } + list + } + + /// Asserts that a [`MetaItemListParser`] contains a single element and returns it, or emits an + /// error and returns `None`. + /// + /// This is a higher-level (and harder to misuse) wrapper over [`MetaItemListParser::as_single`]. + /// That allows using `?` to early return. You may still want to use + /// [`MetaItemListParser::as_single`] for the following reasons: + /// + /// - You want to emit your own diagnostics (for instance, with [`SharedContext::emit_err`]). + /// - The attribute can be parsed in multiple ways and it does not make sense to emit an error. + pub(crate) fn expect_single<'arg>( + &mut self, + list: &'arg MetaItemListParser, + ) -> Option<&'arg MetaItemOrLitParser> { + let single = list.as_single(); + if single.is_none() { + self.adcx().expected_single_argument(list.span, list.len()); + } + single + } } impl<'f, 'sess, S: Stage> Deref for AcceptContext<'f, 'sess, S> { diff --git a/compiler/rustc_attr_parsing/src/parser.rs b/compiler/rustc_attr_parsing/src/parser.rs index a7daec6d6096c..ce2367006128d 100644 --- a/compiler/rustc_attr_parsing/src/parser.rs +++ b/compiler/rustc_attr_parsing/src/parser.rs @@ -176,7 +176,7 @@ impl ArgParser { /// /// - `#[allow(clippy::complexity)]`: `(clippy::complexity)` is a list /// - `#[rustfmt::skip::macros(target_macro_name)]`: `(target_macro_name)` is a list - pub fn list(&self) -> Option<&MetaItemListParser> { + pub fn as_list(&self) -> Option<&MetaItemListParser> { match self { Self::List(l) => Some(l), Self::NameValue(_) | Self::NoArgs => None, @@ -255,6 +255,7 @@ impl MetaItemOrLitParser { } } +// FIXME(scrabsha): once #155696 is merged, update this and mention the higher-level APIs. /// Utility that deconstructs a MetaItem into usable parts. /// /// MetaItems are syntactically extremely flexible, but specific attributes want to parse @@ -263,7 +264,7 @@ impl MetaItemOrLitParser { /// MetaItems consist of some path, and some args. The args could be empty. In other words: /// /// - `name` -> args are empty -/// - `name(...)` -> args are a [`list`](ArgParser::list), which is the bit between the parentheses +/// - `name(...)` -> args are a [`list`](ArgParser::as_list), which is the bit between the parentheses /// - `name = value`-> arg is [`name_value`](ArgParser::name_value), where the argument is the /// `= value` part /// @@ -694,7 +695,7 @@ impl MetaItemListParser { /// Returns Some if the list contains only a single element. /// /// Inside the Some is the parser to parse this single element. - pub fn single(&self) -> Option<&MetaItemOrLitParser> { + pub fn as_single(&self) -> Option<&MetaItemOrLitParser> { let mut iter = self.mixed(); iter.next().filter(|_| iter.next().is_none()) } diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 5608bd82fdacd..dad08e0bc92fd 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -1304,6 +1304,15 @@ impl Attribute { Attribute::Unparsed(_) => false, } } + + pub fn is_prefix_attr_for_suggestions(&self) -> bool { + match self { + Attribute::Unparsed(attr) => attr.span.desugaring_kind().is_none(), + // Other parsed attributes that can appear on expressions originate from source and + // should make suggestions treat the expression like a prefixed form. + Attribute::Parsed(_) => true, + } + } } impl AttributeExt for Attribute { diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index ac77354f2a794..71c02dc32f6b5 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -57,25 +57,7 @@ use crate::{ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub(crate) fn precedence(&self, expr: &hir::Expr<'_>) -> ExprPrecedence { let has_attr = |id: HirId| -> bool { - for attr in self.tcx.hir_attrs(id) { - // For the purpose of rendering suggestions, disregard attributes - // that originate from desugaring of any kind. For example, `x?` - // desugars to `#[allow(unreachable_code)] match ...`. Failing to - // ignore the prefix attribute in the desugaring would cause this - // suggestion: - // - // let y: u32 = x?.try_into().unwrap(); - // ++++++++++++++++++++ - // - // to be rendered as: - // - // let y: u32 = (x?).try_into().unwrap(); - // + +++++++++++++++++++++ - if attr.span().desugaring_kind().is_none() { - return true; - } - } - false + self.tcx.hir_attrs(id).iter().any(hir::Attribute::is_prefix_attr_for_suggestions) }; // Special case: range expressions are desugared to struct literals in HIR, diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index 46aeec65fe2d7..352652413751e 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -845,12 +845,7 @@ impl<'tcx> LateContext<'tcx> { /// be used for pretty-printing HIR by rustc_hir_pretty. pub fn precedence(&self, expr: &hir::Expr<'_>) -> ExprPrecedence { let has_attr = |id: hir::HirId| -> bool { - for attr in self.tcx.hir_attrs(id) { - if attr.span().desugaring_kind().is_none() { - return true; - } - } - false + self.tcx.hir_attrs(id).iter().any(hir::Attribute::is_prefix_attr_for_suggestions) }; expr.precedence(&has_attr) } diff --git a/tests/run-make/remap-path-prefix-edge-cases/rmake.rs b/tests/run-make/remap-path-prefix-edge-cases/rmake.rs new file mode 100644 index 0000000000000..364c5b30f476d --- /dev/null +++ b/tests/run-make/remap-path-prefix-edge-cases/rmake.rs @@ -0,0 +1,51 @@ +//! This test checks multiple edge-case of `--remap-path-prefix`. +//! +//! It tests: +//! - `=` sign in FROM path +//! - multiple path remappings +//! - multiple conflicting path remappings + +//@ ignore-windows (does not support directories with = sign) + +use std::path::Path; + +use run_make_support::{ + CompletedProcess, assert_contains, assert_not_contains, cwd, rfs, run_in_tmpdir, rustc, rustdoc, +}; + +fn main() { + run_in_tmpdir(|| { + let out_dir = cwd(); + + // Create a directory with an `=` sign + let eq_dir = out_dir.join("path=with=equal"); + rfs::create_dir_all(&eq_dir); + + let src_path = eq_dir.join("lib.rs"); + rfs::write(&src_path, "pub fn broken_func() { "); + + // Use multiple remap args and conflicting remappings + let remap_args = [ + format!("--remap-path-prefix={}={}", eq_dir.display(), "REMAPPED_DIR"), + format!("--remap-path-prefix={}={}", eq_dir.display(), "REMAPPED_DIR2"), + ]; + + fn run_test(cmd: impl FnOnce() -> CompletedProcess) { + let output = cmd(); + let stderr = output.stderr_utf8(); + + // Checks the diagnostic output + assert_contains(&stderr, "REMAPPED_DIR2/lib.rs"); + assert_not_contains(&stderr, "REMAPPED_DIR/"); + assert_not_contains(&stderr, "path=with=equal"); + }; + + // Test with rustc + run_test(|| rustc().input(&src_path).args(&remap_args).run_fail()); + + // Test with rustdoc + run_test(|| { + rustdoc().input(&src_path).arg("-Zunstable-options").args(&remap_args).run_fail() + }); + }); +} diff --git a/tests/ui/README.md b/tests/ui/README.md index 008af992f207c..2fe1657e7ecf2 100644 --- a/tests/ui/README.md +++ b/tests/ui/README.md @@ -412,10 +412,6 @@ Tests for quality of diagnostics involving suppression of cascading errors in so Tests for built-in derive macros (`Debug`, `Clone`, etc.) when used in conjunction with built-in `#[derive(..)]` attributes. -## `tests/ui/deriving/`: Derive Macro - -**FIXME**: Coalesce with `tests/ui/derives`. - ## `tests/ui/dest-prop/` Destination Propagation **FIXME**: Contains a single test for the `DestProp` mir-opt, should probably be rehomed. diff --git a/tests/ui/conditional-compilation/cfg-attr-parsed-span-issue-154801.rs b/tests/ui/conditional-compilation/cfg-attr-parsed-span-issue-154801.rs new file mode 100644 index 0000000000000..2264d2ba44a89 --- /dev/null +++ b/tests/ui/conditional-compilation/cfg-attr-parsed-span-issue-154801.rs @@ -0,0 +1,11 @@ +fn main() { + let _x = 30; + #[cfg_attr(, (cc))] //~ ERROR expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `,` + _x //~ ERROR mismatched types +} + +fn inline_case() { + let _x = 30; + #[inline] //~ ERROR `#[inline]` attribute cannot be used on expressions + _x //~ ERROR mismatched types +} diff --git a/tests/ui/conditional-compilation/cfg-attr-parsed-span-issue-154801.stderr b/tests/ui/conditional-compilation/cfg-attr-parsed-span-issue-154801.stderr new file mode 100644 index 0000000000000..ee62d232b12a7 --- /dev/null +++ b/tests/ui/conditional-compilation/cfg-attr-parsed-span-issue-154801.stderr @@ -0,0 +1,42 @@ +error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `,` + --> $DIR/cfg-attr-parsed-span-issue-154801.rs:3:16 + | +LL | #[cfg_attr(, (cc))] + | ^ + | + = note: for more information, visit +help: must be of the form + | +LL - #[cfg_attr(, (cc))] +LL + #[cfg_attr(predicate, attr1, attr2, ...)] + | + +error: `#[inline]` attribute cannot be used on expressions + --> $DIR/cfg-attr-parsed-span-issue-154801.rs:9:5 + | +LL | #[inline] + | ^^^^^^^^^ + | + = help: `#[inline]` can only be applied to functions + +error[E0308]: mismatched types + --> $DIR/cfg-attr-parsed-span-issue-154801.rs:4:5 + | +LL | fn main() { + | - expected `()` because of default return type +... +LL | _x + | ^^ expected `()`, found integer + +error[E0308]: mismatched types + --> $DIR/cfg-attr-parsed-span-issue-154801.rs:10:5 + | +LL | fn inline_case() { + | - help: try adding a return type: `-> i32` +... +LL | _x + | ^^ expected `()`, found integer + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/deriving/auxiliary/derive-no-std.rs b/tests/ui/derives/auxiliary/derive-no-std.rs similarity index 100% rename from tests/ui/deriving/auxiliary/derive-no-std.rs rename to tests/ui/derives/auxiliary/derive-no-std.rs diff --git a/tests/ui/derives/auxiliary/rustc-serialize.rs b/tests/ui/derives/auxiliary/rustc-serialize.rs deleted file mode 100644 index 24177af931c4a..0000000000000 --- a/tests/ui/derives/auxiliary/rustc-serialize.rs +++ /dev/null @@ -1,16 +0,0 @@ -#![crate_type = "lib"] - -pub trait Decoder { - type Error; - - fn read_enum(&mut self, name: &str, f: F) -> Result - where F: FnOnce(&mut Self) -> Result; - fn read_enum_variant(&mut self, names: &[&str], f: F) - -> Result - where F: FnMut(&mut Self, usize) -> Result; - -} - -pub trait Decodable: Sized { - fn decode(d: &mut D) -> Result; -} diff --git a/tests/ui/derives/clone-vector-element-size.rs b/tests/ui/derives/clone-copy/clone-vector-element-size.rs similarity index 100% rename from tests/ui/derives/clone-vector-element-size.rs rename to tests/ui/derives/clone-copy/clone-vector-element-size.rs diff --git a/tests/ui/derives/copy-drop-mutually-exclusive.rs b/tests/ui/derives/clone-copy/copy-drop-mutually-exclusive.rs similarity index 100% rename from tests/ui/derives/copy-drop-mutually-exclusive.rs rename to tests/ui/derives/clone-copy/copy-drop-mutually-exclusive.rs diff --git a/tests/ui/derives/copy-drop-mutually-exclusive.stderr b/tests/ui/derives/clone-copy/copy-drop-mutually-exclusive.stderr similarity index 100% rename from tests/ui/derives/copy-drop-mutually-exclusive.stderr rename to tests/ui/derives/clone-copy/copy-drop-mutually-exclusive.stderr diff --git a/tests/ui/derives/derive-clone-basic.rs b/tests/ui/derives/clone-copy/derive-clone-basic.rs similarity index 100% rename from tests/ui/derives/derive-clone-basic.rs rename to tests/ui/derives/clone-copy/derive-clone-basic.rs diff --git a/tests/ui/derives/derives-span-Clone.rs b/tests/ui/derives/clone-copy/derives-span-Clone.rs similarity index 100% rename from tests/ui/derives/derives-span-Clone.rs rename to tests/ui/derives/clone-copy/derives-span-Clone.rs diff --git a/tests/ui/derives/derives-span-Clone.stderr b/tests/ui/derives/clone-copy/derives-span-Clone.stderr similarity index 100% rename from tests/ui/derives/derives-span-Clone.stderr rename to tests/ui/derives/clone-copy/derives-span-Clone.stderr diff --git a/tests/ui/derives/deriving-copyclone.rs b/tests/ui/derives/clone-copy/deriving-copyclone.rs similarity index 100% rename from tests/ui/derives/deriving-copyclone.rs rename to tests/ui/derives/clone-copy/deriving-copyclone.rs diff --git a/tests/ui/derives/deriving-copyclone.stderr b/tests/ui/derives/clone-copy/deriving-copyclone.stderr similarity index 100% rename from tests/ui/derives/deriving-copyclone.stderr rename to tests/ui/derives/clone-copy/deriving-copyclone.stderr diff --git a/tests/ui/derives/duplicate-derive-copy-clone-diagnostics.rs b/tests/ui/derives/clone-copy/duplicate-derive-copy-clone-diagnostics.rs similarity index 100% rename from tests/ui/derives/duplicate-derive-copy-clone-diagnostics.rs rename to tests/ui/derives/clone-copy/duplicate-derive-copy-clone-diagnostics.rs diff --git a/tests/ui/derives/duplicate-derive-copy-clone-diagnostics.stderr b/tests/ui/derives/clone-copy/duplicate-derive-copy-clone-diagnostics.stderr similarity index 100% rename from tests/ui/derives/duplicate-derive-copy-clone-diagnostics.stderr rename to tests/ui/derives/clone-copy/duplicate-derive-copy-clone-diagnostics.stderr diff --git a/tests/ui/deriving/deriving-copyclone.rs b/tests/ui/derives/clone-copy/misbehaving-clone-impl.rs similarity index 100% rename from tests/ui/deriving/deriving-copyclone.rs rename to tests/ui/derives/clone-copy/misbehaving-clone-impl.rs diff --git a/tests/ui/deriving/auxiliary/another-proc-macro.rs b/tests/ui/derives/coercepointee/auxiliary/another-proc-macro.rs similarity index 100% rename from tests/ui/deriving/auxiliary/another-proc-macro.rs rename to tests/ui/derives/coercepointee/auxiliary/another-proc-macro.rs diff --git a/tests/ui/deriving/auxiliary/malicious-macro.rs b/tests/ui/derives/coercepointee/auxiliary/malicious-macro.rs similarity index 100% rename from tests/ui/deriving/auxiliary/malicious-macro.rs rename to tests/ui/derives/coercepointee/auxiliary/malicious-macro.rs diff --git a/tests/ui/deriving/built-in-proc-macro-scope.rs b/tests/ui/derives/coercepointee/built-in-proc-macro-scope.rs similarity index 100% rename from tests/ui/deriving/built-in-proc-macro-scope.rs rename to tests/ui/derives/coercepointee/built-in-proc-macro-scope.rs diff --git a/tests/ui/deriving/built-in-proc-macro-scope.stdout b/tests/ui/derives/coercepointee/built-in-proc-macro-scope.stdout similarity index 100% rename from tests/ui/deriving/built-in-proc-macro-scope.stdout rename to tests/ui/derives/coercepointee/built-in-proc-macro-scope.stdout diff --git a/tests/ui/deriving/coerce-pointee-bounds-issue-127647.rs b/tests/ui/derives/coercepointee/coerce-pointee-bounds-issue-127647.rs similarity index 100% rename from tests/ui/deriving/coerce-pointee-bounds-issue-127647.rs rename to tests/ui/derives/coercepointee/coerce-pointee-bounds-issue-127647.rs diff --git a/tests/ui/deriving/deriving-coerce-pointee-expanded.rs b/tests/ui/derives/coercepointee/deriving-coerce-pointee-expanded.rs similarity index 100% rename from tests/ui/deriving/deriving-coerce-pointee-expanded.rs rename to tests/ui/derives/coercepointee/deriving-coerce-pointee-expanded.rs diff --git a/tests/ui/deriving/deriving-coerce-pointee-expanded.stdout b/tests/ui/derives/coercepointee/deriving-coerce-pointee-expanded.stdout similarity index 100% rename from tests/ui/deriving/deriving-coerce-pointee-expanded.stdout rename to tests/ui/derives/coercepointee/deriving-coerce-pointee-expanded.stdout diff --git a/tests/ui/deriving/deriving-coerce-pointee-neg.rs b/tests/ui/derives/coercepointee/deriving-coerce-pointee-neg.rs similarity index 100% rename from tests/ui/deriving/deriving-coerce-pointee-neg.rs rename to tests/ui/derives/coercepointee/deriving-coerce-pointee-neg.rs diff --git a/tests/ui/deriving/deriving-coerce-pointee-neg.stderr b/tests/ui/derives/coercepointee/deriving-coerce-pointee-neg.stderr similarity index 100% rename from tests/ui/deriving/deriving-coerce-pointee-neg.stderr rename to tests/ui/derives/coercepointee/deriving-coerce-pointee-neg.stderr diff --git a/tests/ui/deriving/deriving-coerce-pointee.rs b/tests/ui/derives/coercepointee/deriving-coerce-pointee.rs similarity index 100% rename from tests/ui/deriving/deriving-coerce-pointee.rs rename to tests/ui/derives/coercepointee/deriving-coerce-pointee.rs diff --git a/tests/ui/deriving/proc-macro-attribute-mixing.rs b/tests/ui/derives/coercepointee/proc-macro-attribute-mixing.rs similarity index 100% rename from tests/ui/deriving/proc-macro-attribute-mixing.rs rename to tests/ui/derives/coercepointee/proc-macro-attribute-mixing.rs diff --git a/tests/ui/deriving/proc-macro-attribute-mixing.stdout b/tests/ui/derives/coercepointee/proc-macro-attribute-mixing.stdout similarity index 100% rename from tests/ui/deriving/proc-macro-attribute-mixing.stdout rename to tests/ui/derives/coercepointee/proc-macro-attribute-mixing.stdout diff --git a/tests/ui/derives/derive-Debug-enum-variants.rs b/tests/ui/derives/debug/derive-Debug-enum-variants.rs similarity index 100% rename from tests/ui/derives/derive-Debug-enum-variants.rs rename to tests/ui/derives/debug/derive-Debug-enum-variants.rs diff --git a/tests/ui/derives/derive-Debug-use-ufcs-struct.rs b/tests/ui/derives/debug/derive-Debug-use-ufcs-struct.rs similarity index 100% rename from tests/ui/derives/derive-Debug-use-ufcs-struct.rs rename to tests/ui/derives/debug/derive-Debug-use-ufcs-struct.rs diff --git a/tests/ui/derives/derive-Debug-use-ufcs-tuple.rs b/tests/ui/derives/debug/derive-Debug-use-ufcs-tuple.rs similarity index 100% rename from tests/ui/derives/derive-Debug-use-ufcs-tuple.rs rename to tests/ui/derives/debug/derive-Debug-use-ufcs-tuple.rs diff --git a/tests/ui/deriving/deriving-show-2.rs b/tests/ui/derives/debug/derive-debug-2.rs similarity index 100% rename from tests/ui/deriving/deriving-show-2.rs rename to tests/ui/derives/debug/derive-debug-2.rs diff --git a/tests/ui/derives/derive-debug-generic-with-lifetime.rs b/tests/ui/derives/debug/derive-debug-generic-with-lifetime.rs similarity index 100% rename from tests/ui/derives/derive-debug-generic-with-lifetime.rs rename to tests/ui/derives/debug/derive-debug-generic-with-lifetime.rs diff --git a/tests/ui/derives/derive-debug-newtype-unsized-slice.rs b/tests/ui/derives/debug/derive-debug-newtype-unsized-slice.rs similarity index 100% rename from tests/ui/derives/derive-debug-newtype-unsized-slice.rs rename to tests/ui/derives/debug/derive-debug-newtype-unsized-slice.rs diff --git a/tests/ui/derives/derive-debug-uninhabited-enum.rs b/tests/ui/derives/debug/derive-debug-uninhabited-enum.rs similarity index 100% rename from tests/ui/derives/derive-debug-uninhabited-enum.rs rename to tests/ui/derives/debug/derive-debug-uninhabited-enum.rs diff --git a/tests/ui/derives/derive-debug-uninhabited-enum.stderr b/tests/ui/derives/debug/derive-debug-uninhabited-enum.stderr similarity index 100% rename from tests/ui/derives/derive-debug-uninhabited-enum.stderr rename to tests/ui/derives/debug/derive-debug-uninhabited-enum.stderr diff --git a/tests/ui/deriving/deriving-show.rs b/tests/ui/derives/debug/derive-debug.rs similarity index 100% rename from tests/ui/deriving/deriving-show.rs rename to tests/ui/derives/debug/derive-debug.rs diff --git a/tests/ui/derives/derives-span-Debug.rs b/tests/ui/derives/debug/derives-span-Debug.rs similarity index 100% rename from tests/ui/derives/derives-span-Debug.rs rename to tests/ui/derives/debug/derives-span-Debug.rs diff --git a/tests/ui/derives/derives-span-Debug.stderr b/tests/ui/derives/debug/derives-span-Debug.stderr similarity index 100% rename from tests/ui/derives/derives-span-Debug.stderr rename to tests/ui/derives/debug/derives-span-Debug.stderr diff --git a/tests/ui/derives/nonsense-input-to-debug.rs b/tests/ui/derives/debug/nonsense-input-to-debug.rs similarity index 100% rename from tests/ui/derives/nonsense-input-to-debug.rs rename to tests/ui/derives/debug/nonsense-input-to-debug.rs diff --git a/tests/ui/derives/nonsense-input-to-debug.stderr b/tests/ui/derives/debug/nonsense-input-to-debug.stderr similarity index 100% rename from tests/ui/derives/nonsense-input-to-debug.stderr rename to tests/ui/derives/debug/nonsense-input-to-debug.stderr diff --git a/tests/ui/derives/derives-span-Default.rs b/tests/ui/derives/default/derives-span-Default.rs similarity index 100% rename from tests/ui/derives/derives-span-Default.rs rename to tests/ui/derives/default/derives-span-Default.rs diff --git a/tests/ui/derives/derives-span-Default.stderr b/tests/ui/derives/default/derives-span-Default.stderr similarity index 100% rename from tests/ui/derives/derives-span-Default.stderr rename to tests/ui/derives/default/derives-span-Default.stderr diff --git a/tests/ui/deriving/deriving-default-box.rs b/tests/ui/derives/default/deriving-default-box.rs similarity index 100% rename from tests/ui/deriving/deriving-default-box.rs rename to tests/ui/derives/default/deriving-default-box.rs diff --git a/tests/ui/deriving/deriving-default-enum.rs b/tests/ui/derives/default/deriving-default-enum.rs similarity index 100% rename from tests/ui/deriving/deriving-default-enum.rs rename to tests/ui/derives/default/deriving-default-enum.rs diff --git a/tests/ui/deriving/multiple-defaults.rs b/tests/ui/derives/default/multiple-defaults.rs similarity index 100% rename from tests/ui/deriving/multiple-defaults.rs rename to tests/ui/derives/default/multiple-defaults.rs diff --git a/tests/ui/deriving/multiple-defaults.stderr b/tests/ui/derives/default/multiple-defaults.stderr similarity index 100% rename from tests/ui/deriving/multiple-defaults.stderr rename to tests/ui/derives/default/multiple-defaults.stderr diff --git a/tests/ui/deriving/derive-no-std.rs b/tests/ui/derives/derive-no-std.rs similarity index 100% rename from tests/ui/deriving/derive-no-std.rs rename to tests/ui/derives/derive-no-std.rs diff --git a/tests/ui/deriving/deriving-all-codegen.rs b/tests/ui/derives/deriving-all-codegen.rs similarity index 100% rename from tests/ui/deriving/deriving-all-codegen.rs rename to tests/ui/derives/deriving-all-codegen.rs diff --git a/tests/ui/deriving/deriving-all-codegen.stdout b/tests/ui/derives/deriving-all-codegen.stdout similarity index 100% rename from tests/ui/deriving/deriving-all-codegen.stdout rename to tests/ui/derives/deriving-all-codegen.stdout diff --git a/tests/ui/deriving/deriving-associated-types.rs b/tests/ui/derives/deriving-associated-types.rs similarity index 100% rename from tests/ui/deriving/deriving-associated-types.rs rename to tests/ui/derives/deriving-associated-types.rs diff --git a/tests/ui/deriving/deriving-from-wrong-target.rs b/tests/ui/derives/deriving-from-wrong-target.rs similarity index 100% rename from tests/ui/deriving/deriving-from-wrong-target.rs rename to tests/ui/derives/deriving-from-wrong-target.rs diff --git a/tests/ui/deriving/deriving-from-wrong-target.stderr b/tests/ui/derives/deriving-from-wrong-target.stderr similarity index 100% rename from tests/ui/deriving/deriving-from-wrong-target.stderr rename to tests/ui/derives/deriving-from-wrong-target.stderr diff --git a/tests/ui/deriving/deriving-from.rs b/tests/ui/derives/deriving-from.rs similarity index 100% rename from tests/ui/deriving/deriving-from.rs rename to tests/ui/derives/deriving-from.rs diff --git a/tests/ui/deriving/deriving-hash.rs b/tests/ui/derives/deriving-hash.rs similarity index 100% rename from tests/ui/deriving/deriving-hash.rs rename to tests/ui/derives/deriving-hash.rs diff --git a/tests/ui/deriving/deriving-in-fn.rs b/tests/ui/derives/deriving-in-fn.rs similarity index 100% rename from tests/ui/deriving/deriving-in-fn.rs rename to tests/ui/derives/deriving-in-fn.rs diff --git a/tests/ui/deriving/deriving-with-helper.rs b/tests/ui/derives/deriving-with-helper.rs similarity index 100% rename from tests/ui/deriving/deriving-with-helper.rs rename to tests/ui/derives/deriving-with-helper.rs diff --git a/tests/ui/deriving/deriving-with-repr-packed.rs b/tests/ui/derives/deriving-with-repr-packed-3.rs similarity index 100% rename from tests/ui/deriving/deriving-with-repr-packed.rs rename to tests/ui/derives/deriving-with-repr-packed-3.rs diff --git a/tests/ui/derives/derive-eq-check-all-variants.rs b/tests/ui/derives/eq-ord/derive-eq-check-all-variants.rs similarity index 100% rename from tests/ui/derives/derive-eq-check-all-variants.rs rename to tests/ui/derives/eq-ord/derive-eq-check-all-variants.rs diff --git a/tests/ui/derives/derive-eq-check-all-variants.stderr b/tests/ui/derives/eq-ord/derive-eq-check-all-variants.stderr similarity index 100% rename from tests/ui/derives/derive-eq-check-all-variants.stderr rename to tests/ui/derives/eq-ord/derive-eq-check-all-variants.stderr diff --git a/tests/ui/derives/derive-partial-ord-discriminant-64bit.rs b/tests/ui/derives/eq-ord/derive-partial-ord-discriminant-64bit.rs similarity index 100% rename from tests/ui/derives/derive-partial-ord-discriminant-64bit.rs rename to tests/ui/derives/eq-ord/derive-partial-ord-discriminant-64bit.rs diff --git a/tests/ui/derives/derive-partial-ord-discriminant.rs b/tests/ui/derives/eq-ord/derive-partial-ord-discriminant.rs similarity index 100% rename from tests/ui/derives/derive-partial-ord-discriminant.rs rename to tests/ui/derives/eq-ord/derive-partial-ord-discriminant.rs diff --git a/tests/ui/derives/derive-partial-ord.rs b/tests/ui/derives/eq-ord/derive-partial-ord.rs similarity index 100% rename from tests/ui/derives/derive-partial-ord.rs rename to tests/ui/derives/eq-ord/derive-partial-ord.rs diff --git a/tests/ui/deriving/derive-partialord-correctness.rs b/tests/ui/derives/eq-ord/derive-partialord-correctness.rs similarity index 100% rename from tests/ui/deriving/derive-partialord-correctness.rs rename to tests/ui/derives/eq-ord/derive-partialord-correctness.rs diff --git a/tests/ui/derives/derives-span-Eq.rs b/tests/ui/derives/eq-ord/derives-span-Eq.rs similarity index 100% rename from tests/ui/derives/derives-span-Eq.rs rename to tests/ui/derives/eq-ord/derives-span-Eq.rs diff --git a/tests/ui/derives/derives-span-Eq.stderr b/tests/ui/derives/eq-ord/derives-span-Eq.stderr similarity index 100% rename from tests/ui/derives/derives-span-Eq.stderr rename to tests/ui/derives/eq-ord/derives-span-Eq.stderr diff --git a/tests/ui/derives/derives-span-Ord.rs b/tests/ui/derives/eq-ord/derives-span-Ord.rs similarity index 100% rename from tests/ui/derives/derives-span-Ord.rs rename to tests/ui/derives/eq-ord/derives-span-Ord.rs diff --git a/tests/ui/derives/derives-span-Ord.stderr b/tests/ui/derives/eq-ord/derives-span-Ord.stderr similarity index 100% rename from tests/ui/derives/derives-span-Ord.stderr rename to tests/ui/derives/eq-ord/derives-span-Ord.stderr diff --git a/tests/ui/derives/derives-span-PartialEq.rs b/tests/ui/derives/eq-ord/derives-span-PartialEq.rs similarity index 100% rename from tests/ui/derives/derives-span-PartialEq.rs rename to tests/ui/derives/eq-ord/derives-span-PartialEq.rs diff --git a/tests/ui/derives/derives-span-PartialEq.stderr b/tests/ui/derives/eq-ord/derives-span-PartialEq.stderr similarity index 100% rename from tests/ui/derives/derives-span-PartialEq.stderr rename to tests/ui/derives/eq-ord/derives-span-PartialEq.stderr diff --git a/tests/ui/derives/derives-span-PartialOrd.rs b/tests/ui/derives/eq-ord/derives-span-PartialOrd.rs similarity index 100% rename from tests/ui/derives/derives-span-PartialOrd.rs rename to tests/ui/derives/eq-ord/derives-span-PartialOrd.rs diff --git a/tests/ui/derives/derives-span-PartialOrd.stderr b/tests/ui/derives/eq-ord/derives-span-PartialOrd.stderr similarity index 100% rename from tests/ui/derives/derives-span-PartialOrd.stderr rename to tests/ui/derives/eq-ord/derives-span-PartialOrd.stderr diff --git a/tests/ui/deriving/deriving-cmp-generic-enum.rs b/tests/ui/derives/eq-ord/deriving-cmp-generic-enum.rs similarity index 100% rename from tests/ui/deriving/deriving-cmp-generic-enum.rs rename to tests/ui/derives/eq-ord/deriving-cmp-generic-enum.rs diff --git a/tests/ui/deriving/deriving-cmp-generic-struct-enum.rs b/tests/ui/derives/eq-ord/deriving-cmp-generic-struct-enum.rs similarity index 100% rename from tests/ui/deriving/deriving-cmp-generic-struct-enum.rs rename to tests/ui/derives/eq-ord/deriving-cmp-generic-struct-enum.rs diff --git a/tests/ui/deriving/deriving-cmp-generic-struct.rs b/tests/ui/derives/eq-ord/deriving-cmp-generic-struct.rs similarity index 100% rename from tests/ui/deriving/deriving-cmp-generic-struct.rs rename to tests/ui/derives/eq-ord/deriving-cmp-generic-struct.rs diff --git a/tests/ui/deriving/deriving-cmp-generic-tuple-struct.rs b/tests/ui/derives/eq-ord/deriving-cmp-generic-tuple-struct.rs similarity index 100% rename from tests/ui/deriving/deriving-cmp-generic-tuple-struct.rs rename to tests/ui/derives/eq-ord/deriving-cmp-generic-tuple-struct.rs diff --git a/tests/ui/deriving/deriving-cmp-shortcircuit.rs b/tests/ui/derives/eq-ord/deriving-cmp-shortcircuit.rs similarity index 100% rename from tests/ui/deriving/deriving-cmp-shortcircuit.rs rename to tests/ui/derives/eq-ord/deriving-cmp-shortcircuit.rs diff --git a/tests/ui/deriving/deriving-eq-ord-boxed-slice.rs b/tests/ui/derives/eq-ord/deriving-eq-ord-boxed-slice.rs similarity index 100% rename from tests/ui/deriving/deriving-eq-ord-boxed-slice.rs rename to tests/ui/derives/eq-ord/deriving-eq-ord-boxed-slice.rs diff --git a/tests/ui/deriving/deriving-self-lifetime-totalord-totaleq.rs b/tests/ui/derives/eq-ord/deriving-self-lifetime-totalord-totaleq.rs similarity index 100% rename from tests/ui/deriving/deriving-self-lifetime-totalord-totaleq.rs rename to tests/ui/derives/eq-ord/deriving-self-lifetime-totalord-totaleq.rs diff --git a/tests/ui/deriving/do-not-suggest-calling-fn-in-derive-macro.rs b/tests/ui/derives/eq-ord/do-not-suggest-calling-fn-in-derive-macro.rs similarity index 100% rename from tests/ui/deriving/do-not-suggest-calling-fn-in-derive-macro.rs rename to tests/ui/derives/eq-ord/do-not-suggest-calling-fn-in-derive-macro.rs diff --git a/tests/ui/deriving/do-not-suggest-calling-fn-in-derive-macro.stderr b/tests/ui/derives/eq-ord/do-not-suggest-calling-fn-in-derive-macro.stderr similarity index 100% rename from tests/ui/deriving/do-not-suggest-calling-fn-in-derive-macro.stderr rename to tests/ui/derives/eq-ord/do-not-suggest-calling-fn-in-derive-macro.stderr diff --git a/tests/ui/deriving/internal_eq_trait_method_impls.rs b/tests/ui/derives/eq-ord/internal_eq_trait_method_impls.rs similarity index 100% rename from tests/ui/deriving/internal_eq_trait_method_impls.rs rename to tests/ui/derives/eq-ord/internal_eq_trait_method_impls.rs diff --git a/tests/ui/deriving/internal_eq_trait_method_impls.stderr b/tests/ui/derives/eq-ord/internal_eq_trait_method_impls.stderr similarity index 100% rename from tests/ui/deriving/internal_eq_trait_method_impls.stderr rename to tests/ui/derives/eq-ord/internal_eq_trait_method_impls.stderr diff --git a/tests/ui/derives/invalid-derive-comparison-34229.rs b/tests/ui/derives/eq-ord/invalid-derive-comparison-34229.rs similarity index 100% rename from tests/ui/derives/invalid-derive-comparison-34229.rs rename to tests/ui/derives/eq-ord/invalid-derive-comparison-34229.rs diff --git a/tests/ui/derives/invalid-derive-comparison-34229.stderr b/tests/ui/derives/eq-ord/invalid-derive-comparison-34229.stderr similarity index 100% rename from tests/ui/derives/invalid-derive-comparison-34229.stderr rename to tests/ui/derives/eq-ord/invalid-derive-comparison-34229.stderr diff --git a/tests/ui/deriving/deriving-enum-single-variant.rs b/tests/ui/deriving/deriving-enum-single-variant.rs deleted file mode 100644 index 43d229c442c45..0000000000000 --- a/tests/ui/deriving/deriving-enum-single-variant.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ run-pass -#![allow(non_camel_case_types)] - -pub type task_id = isize; - -#[derive(PartialEq)] -pub enum Task { - TaskHandle(task_id) -} - -pub fn main() { } diff --git a/tests/ui/deriving/deriving-in-macro.rs b/tests/ui/deriving/deriving-in-macro.rs deleted file mode 100644 index 739d9b3068226..0000000000000 --- a/tests/ui/deriving/deriving-in-macro.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ check-pass -#![allow(non_camel_case_types)] -#![allow(dead_code)] - -macro_rules! define_vec { - () => ( - mod foo { - #[derive(PartialEq)] - pub struct bar; - } - ) -} - -define_vec![]; - -pub fn main() {} diff --git a/tests/ui/deriving/deriving-meta-multiple.rs b/tests/ui/deriving/deriving-meta-multiple.rs deleted file mode 100644 index 7c2d3566fbf26..0000000000000 --- a/tests/ui/deriving/deriving-meta-multiple.rs +++ /dev/null @@ -1,25 +0,0 @@ -//@ run-pass -#![allow(unused_must_use)] -#![allow(unused_imports)] -#![allow(deprecated)] - -use std::hash::{Hash, SipHasher}; - -// testing multiple separate deriving attributes -#[derive(PartialEq)] -#[derive(Clone)] -#[derive(Hash)] -struct Foo { - bar: usize, - baz: isize -} - -fn hash(_t: &T) {} - -pub fn main() { - let a = Foo {bar: 4, baz: -3}; - - a == a; // check for PartialEq impl w/o testing its correctness - a.clone(); // check for Clone impl w/o testing its correctness - hash(&a); // check for Hash impl w/o testing its correctness -} diff --git a/tests/ui/deriving/deriving-meta.rs b/tests/ui/deriving/deriving-meta.rs deleted file mode 100644 index 70b5821edae14..0000000000000 --- a/tests/ui/deriving/deriving-meta.rs +++ /dev/null @@ -1,22 +0,0 @@ -//@ run-pass -#![allow(unused_must_use)] -#![allow(unused_imports)] -#![allow(deprecated)] - -use std::hash::{Hash, SipHasher}; - -#[derive(PartialEq, Clone, Hash)] -struct Foo { - bar: usize, - baz: isize -} - -fn hash(_t: &T) {} - -pub fn main() { - let a = Foo {bar: 4, baz: -3}; - - a == a; // check for PartialEq impl w/o testing its correctness - a.clone(); // check for Clone impl w/o testing its correctness - hash(&a); // check for Hash impl w/o testing its correctness -} diff --git a/tests/ui/deriving/deriving-via-extension-c-enum.rs b/tests/ui/deriving/deriving-via-extension-c-enum.rs deleted file mode 100644 index 8d15257116f10..0000000000000 --- a/tests/ui/deriving/deriving-via-extension-c-enum.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ run-pass -#![allow(dead_code)] -#[derive(PartialEq, Debug)] -enum Foo { - Bar, - Baz, - Boo -} - -pub fn main() { - let a = Foo::Bar; - let b = Foo::Bar; - assert_eq!(a, b); - assert!(!(a != b)); - assert!(a.eq(&b)); - assert!(!a.ne(&b)); -} diff --git a/tests/ui/deriving/deriving-via-extension-enum.rs b/tests/ui/deriving/deriving-via-extension-enum.rs deleted file mode 100644 index f844c8243d431..0000000000000 --- a/tests/ui/deriving/deriving-via-extension-enum.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ run-pass -#![allow(dead_code)] -#[derive(PartialEq, Debug)] -enum Foo { - Bar(isize, isize), - Baz(f64, f64) -} - -pub fn main() { - let a = Foo::Bar(1, 2); - let b = Foo::Bar(1, 2); - assert_eq!(a, b); - assert!(!(a != b)); - assert!(a.eq(&b)); - assert!(!a.ne(&b)); -} diff --git a/tests/ui/deriving/deriving-via-extension-hash-enum.rs b/tests/ui/deriving/deriving-via-extension-hash-enum.rs deleted file mode 100644 index acd34f7818717..0000000000000 --- a/tests/ui/deriving/deriving-via-extension-hash-enum.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ run-pass -#![allow(dead_code)] -#[derive(Hash)] -enum Foo { - Bar(isize, char), - Baz(char, isize) -} - -#[derive(Hash)] -enum A { - B, - C, - D, - E -} - -pub fn main(){} diff --git a/tests/ui/deriving/deriving-via-extension-hash-struct.rs b/tests/ui/deriving/deriving-via-extension-hash-struct.rs deleted file mode 100644 index 2b1bc9e108b13..0000000000000 --- a/tests/ui/deriving/deriving-via-extension-hash-struct.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ run-pass -#![allow(dead_code)] - -#[derive(Hash)] -struct Foo { - x: isize, - y: isize, - z: isize -} - -pub fn main() {} diff --git a/tests/ui/deriving/deriving-via-extension-struct-empty.rs b/tests/ui/deriving/deriving-via-extension-struct-empty.rs deleted file mode 100644 index 43a60013e79e4..0000000000000 --- a/tests/ui/deriving/deriving-via-extension-struct-empty.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ run-pass -#[derive(PartialEq, Debug)] -struct Foo; - -pub fn main() { - assert_eq!(Foo, Foo); - assert!(!(Foo != Foo)); -} diff --git a/tests/ui/deriving/deriving-via-extension-struct-like-enum-variant.rs b/tests/ui/deriving/deriving-via-extension-struct-like-enum-variant.rs deleted file mode 100644 index fe382c4e4b907..0000000000000 --- a/tests/ui/deriving/deriving-via-extension-struct-like-enum-variant.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ run-pass -#![allow(dead_code)] -#[derive(PartialEq, Debug)] -enum S { - X { x: isize, y: isize }, - Y -} - -pub fn main() { - let x = S::X { x: 1, y: 2 }; - assert_eq!(x, x); - assert!(!(x != x)); -} diff --git a/tests/ui/deriving/deriving-via-extension-struct-tuple.rs b/tests/ui/deriving/deriving-via-extension-struct-tuple.rs deleted file mode 100644 index 3192b85a37be2..0000000000000 --- a/tests/ui/deriving/deriving-via-extension-struct-tuple.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ run-pass -#[derive(PartialEq, Debug)] -struct Foo(isize, isize, String); - -pub fn main() { - let a1 = Foo(5, 6, "abc".to_string()); - let a2 = Foo(5, 6, "abc".to_string()); - let b = Foo(5, 7, "def".to_string()); - - assert_eq!(a1, a1); - assert_eq!(a2, a1); - assert!(!(a1 == b)); - - assert!(a1 != b); - assert!(!(a1 != a1)); - assert!(!(a2 != a1)); -} diff --git a/tests/ui/deriving/deriving-via-extension-struct.rs b/tests/ui/deriving/deriving-via-extension-struct.rs deleted file mode 100644 index 4a5c3453876a3..0000000000000 --- a/tests/ui/deriving/deriving-via-extension-struct.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ run-pass -#[derive(PartialEq, Debug)] -struct Foo { - x: isize, - y: isize, - z: isize, -} - -pub fn main() { - let a = Foo { x: 1, y: 2, z: 3 }; - let b = Foo { x: 1, y: 2, z: 3 }; - assert_eq!(a, b); - assert!(!(a != b)); - assert!(a.eq(&b)); - assert!(!a.ne(&b)); -} diff --git a/tests/ui/deriving/deriving-via-extension-type-params.rs b/tests/ui/deriving/deriving-via-extension-type-params.rs deleted file mode 100644 index 79ac0c316754e..0000000000000 --- a/tests/ui/deriving/deriving-via-extension-type-params.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ run-pass -#[derive(PartialEq, Hash, Debug)] -struct Foo { - x: isize, - y: T, - z: isize -} - -pub fn main() { - let a = Foo { x: 1, y: 2.0f64, z: 3 }; - let b = Foo { x: 1, y: 2.0f64, z: 3 }; - assert_eq!(a, b); - assert!(!(a != b)); - assert!(a.eq(&b)); - assert!(!a.ne(&b)); -} diff --git a/tests/ui/lint/unused/unused-doc-comments-for-macros.rs b/tests/ui/lint/unused/unused-doc-comments-for-macros.rs index 05828ebb2c353..96de81399633d 100644 --- a/tests/ui/lint/unused/unused-doc-comments-for-macros.rs +++ b/tests/ui/lint/unused/unused-doc-comments-for-macros.rs @@ -14,4 +14,16 @@ fn main() { /// line2 /// line3 foo!(); + + // Regression test for https://github.com/rust-lang/rust/issues/155701. + cfg_select! { + /// line1 //~ ERROR: unused doc comment + /// line2 + /// line3 + debug_assertions => (), + /// line1 //~ ERROR: unused doc comment + /// line2 + /// line3 + _ => (), + } } diff --git a/tests/ui/lint/unused/unused-doc-comments-for-macros.stderr b/tests/ui/lint/unused/unused-doc-comments-for-macros.stderr index 26b1c2b058c1f..295e328e67724 100644 --- a/tests/ui/lint/unused/unused-doc-comments-for-macros.stderr +++ b/tests/ui/lint/unused/unused-doc-comments-for-macros.stderr @@ -27,5 +27,25 @@ LL | | /// line3 | = help: to document an item produced by a macro, the macro must produce the documentation as part of its expansion -error: aborting due to 2 previous errors +error: unused doc comment + --> $DIR/unused-doc-comments-for-macros.rs:20:9 + | +LL | / /// line1 +LL | | /// line2 +LL | | /// line3 + | |_________________^ + | + = help: use `//` for a plain comment + +error: unused doc comment + --> $DIR/unused-doc-comments-for-macros.rs:24:9 + | +LL | / /// line1 +LL | | /// line2 +LL | | /// line3 + | |_________________^ + | + = help: use `//` for a plain comment + +error: aborting due to 4 previous errors diff --git a/triagebot.toml b/triagebot.toml index a4155914fb02b..19b6fa9bc5289 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -1283,7 +1283,7 @@ Please ensure that if you've changed the output: """ cc = ["@aDotInTheVoid", "@obi1kenobi"] -[mentions."tests/ui/deriving/deriving-all-codegen.stdout"] +[mentions."tests/ui/derives/deriving-all-codegen.stdout"] message = "Changes to the code generated for builtin derived traits." cc = ["@nnethercote"] @@ -1345,6 +1345,9 @@ cc = ["@rust-lang/project-exploit-mitigations", "@rcvalle"] [mentions."tests/codegen-llvm/stack-protector.rs"] cc = ["@rust-lang/project-exploit-mitigations", "@rcvalle"] +[mentions."tests/debuginfo/basic-stepping.rs"] +cc = ["@Enselic"] + [mentions."tests/ui/sanitizer"] cc = ["@rcvalle"]