diff --git a/Cargo.lock b/Cargo.lock index 696b797e612f9..3d8c246270130 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4026,7 +4026,6 @@ name = "rustc_expand" version = "0.0.0" dependencies = [ "rustc_ast", - "rustc_ast_passes", "rustc_ast_pretty", "rustc_attr_ir", "rustc_attr_parsing", diff --git a/RELEASES.md b/RELEASES.md index 940fa7c6072a9..f2d74f2e7f1f0 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -67,6 +67,8 @@ Stabilized APIs - [`Atomic::get_mut_slice`](https://doc.rust-lang.org/stable/core/sync/atomic/struct.Atomic.html#method.get_mut_slice) - [`Atomic::from_mut_slice`](https://doc.rust-lang.org/stable/core/sync/atomic/struct.Atomic.html#method.from_mut_slice) - [`std::range::legacy`](https://doc.rust-lang.org/stable/std/range/legacy/index.html) +- [`bool::ok_or`](https://doc.rust-lang.org/stable/std/primitive.bool.html#method.ok_or) +- [`bool::ok_or_else`](https://doc.rust-lang.org/stable/std/primitive.bool.html#method.ok_or_else) diff --git a/compiler/rustc_arena/src/lib.rs b/compiler/rustc_arena/src/lib.rs index c33765f03d77d..dfc48b0bd1cd6 100644 --- a/compiler/rustc_arena/src/lib.rs +++ b/compiler/rustc_arena/src/lib.rs @@ -13,7 +13,7 @@ #![cfg_attr(bootstrap, feature(never_type))] #![cfg_attr(test, feature(test))] #![deny(unsafe_op_in_unsafe_fn)] -#![doc(test(no_crate_inject, attr(deny(warnings), allow(internal_features))))] +#![doc(test(no_crate_inject, attr(deny(warnings))))] #![feature(decl_macro)] #![feature(dropck_eyepatch)] #![feature(rustc_attrs)] diff --git a/compiler/rustc_ast/src/lib.rs b/compiler/rustc_ast/src/lib.rs index 3b01eb6eefa7d..46d8e11cc0931 100644 --- a/compiler/rustc_ast/src/lib.rs +++ b/compiler/rustc_ast/src/lib.rs @@ -5,7 +5,7 @@ //! This API is completely unstable and subject to change. // tidy-alphabetical-start -#![doc(test(attr(deny(warnings), allow(internal_features))))] +#![doc(test(attr(deny(warnings))))] #![feature(associated_type_defaults)] #![feature(deref_patterns)] #![feature(iter_order_by)] diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 1265bae778601..def0934214ef2 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -45,7 +45,7 @@ use rustc_ast::mut_visit::{self, MutVisitor}; use rustc_ast::node_id::NodeMap; use rustc_ast::visit::{self, Visitor}; use rustc_ast::{self as ast, *}; -use rustc_attr_parsing::{AttributeParser, OmitDoc, Recovery, ShouldEmit}; +use rustc_attr_parsing::{AttributeParser, Recovery, ShouldEmit}; use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::sorted_map::SortedMap; use rustc_data_structures::stable_hash::{StableHash, StableHasher}; @@ -1231,7 +1231,6 @@ impl<'hir> LoweringContext<'_, 'hir> { attrs, target_span, target, - OmitDoc::Lower, |s| l.lower(s), |lint_id, span, kind| { self.delayed_lints.push(DelayedLint { diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index daa663b8d1b6a..15d94530eecae 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -46,10 +46,6 @@ macro_rules! gate_multi { }}; } -pub fn check_attribute(attr: &ast::Attribute, sess: &Session, features: &Features) { - PostExpansionVisitor { sess, features }.visit_attribute(attr) -} - struct PostExpansionVisitor<'a> { sess: &'a Session, @@ -152,33 +148,9 @@ impl<'a> PostExpansionVisitor<'a> { } impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { - fn visit_attribute(&mut self, attr: &ast::Attribute) { - // Check unstable flavors of the `#[doc]` attribute. - if attr.has_name(sym::doc) { - for meta_item_inner in attr.meta_item_list().unwrap_or_default() { - macro_rules! gate_doc { ($($s:literal { $($name:ident => $feature:ident)* })*) => { - $($(if meta_item_inner.has_name(sym::$name) { - let msg = concat!("`#[doc(", stringify!($name), ")]` is ", $s); - gate!(self, $feature, attr.span, msg); - })*)* - }} - - gate_doc!( - "experimental" { - cfg => doc_cfg - auto_cfg => doc_cfg - masked => doc_masked - notable_trait => doc_notable_trait - } - "meant for internal use only" { - attribute => rustdoc_internals - keyword => rustdoc_internals - fake_variadic => rustdoc_internals - search_unbox => rustdoc_internals - } - ); - } - } + fn visit_attribute(&mut self, attr: &'a ast::Attribute) { + // Checked in attribute parsers, do NOT add checks here + visit::walk_attribute(self, attr) } fn visit_item(&mut self, i: &'a ast::Item) { diff --git a/compiler/rustc_attr_parsing/src/attributes/doc.rs b/compiler/rustc_attr_parsing/src/attributes/doc.rs index 7b0df693debf5..e315d6abea395 100644 --- a/compiler/rustc_attr_parsing/src/attributes/doc.rs +++ b/compiler/rustc_attr_parsing/src/attributes/doc.rs @@ -5,10 +5,9 @@ use rustc_attr_ir::{ DocInline, HideOrShow, }; use rustc_data_structures::fx::{FxHashSet, FxIndexMap, IndexEntry}; -use rustc_errors::{Applicability, msg}; +use rustc_errors::Applicability; use rustc_feature::AttributeStability; use rustc_lint_defs::builtin::{INVALID_DOC_ATTRIBUTES, UNUSED_ATTRIBUTES}; -use rustc_session::diagnostics::feature_err; use rustc_span::{Span, Symbol, edition, sym}; use super::prelude::{ALL_TARGETS, AllowedTargets}; @@ -526,19 +525,15 @@ impl DocParser { } macro_rules! no_args_and_crate_level { ($ident: ident) => {{ - no_args_and_crate_level!($ident, |span| {}); - }}; - ($ident: ident, |$span:ident| $extra_validation:block) => {{ if let Err(span) = args.as_no_args() { expected_no_args(cx, span); return; } - let $span = path.span(); - if !check_attr_crate_level(cx, $span) { + let span = path.span(); + if !check_attr_crate_level(cx, span) { return; } - $extra_validation - self.attribute.$ident = Some($span); + self.attribute.$ident = Some(span); }}; } macro_rules! string_arg_and_crate_level { @@ -569,6 +564,12 @@ impl DocParser { self.attribute.$ident = Some((s, path.span())); }}; } + macro_rules! gated { + ($feature:ident $(,$notes:expr)*) => { + let stability = $crate::unstable!($feature $(, $notes)*); + cx.shared.cx.check_attribute_stability(&cx.attr_path, path.span(), stability); + }; + } match path.word_sym() { Some(sym::alias) => self.parse_alias(cx, path, args), @@ -583,37 +584,60 @@ impl DocParser { } Some(sym::inline) => self.parse_inline(cx, path, args, DocInline::Inline), Some(sym::no_inline) => self.parse_inline(cx, path, args, DocInline::NoInline), - Some(sym::masked) => no_args!(masked), - Some(sym::cfg) => self.parse_cfg(cx, args), - Some(sym::notable_trait) => no_args!(notable_trait), - Some(sym::keyword) => parse_keyword_and_attribute( - cx, - path, - args, - &mut self.attribute.keyword, - sym::keyword, - ), - Some(sym::attribute) => parse_keyword_and_attribute( - cx, - path, - args, - &mut self.attribute.attribute, - sym::attribute, - ), - Some(sym::fake_variadic) => no_args_and_not_crate_level!(fake_variadic), - Some(sym::search_unbox) => no_args_and_not_crate_level!(search_unbox), - Some(sym::rust_logo) => no_args_and_crate_level!(rust_logo, |span| { - if !cx.features().rustdoc_internals() { - feature_err( - cx.sess(), - sym::rustdoc_internals, - span, - msg!("the `#[doc(rust_logo)]` attribute is used for Rust branding"), - ) - .emit(); + Some(sym::masked) => { + gated!(doc_masked); + no_args!(masked) + } + Some(sym::cfg) => { + gated!(doc_cfg); + self.parse_cfg(cx, args) + } + Some(sym::notable_trait) => { + gated!(doc_notable_trait); + no_args!(notable_trait) + } + Some(sym::keyword) => { + gated!(rustdoc_internals); + parse_keyword_and_attribute( + cx, + path, + args, + &mut self.attribute.keyword, + sym::keyword, + ) + } + Some(sym::attribute) => { + gated!(rustdoc_internals); + parse_keyword_and_attribute( + cx, + path, + args, + &mut self.attribute.attribute, + sym::attribute, + ) + } + Some(sym::fake_variadic) => { + gated!(rustdoc_internals); + no_args_and_not_crate_level!(fake_variadic) + } + Some(sym::search_unbox) => { + gated!(rustdoc_internals); + no_args_and_not_crate_level!(search_unbox) + } + Some(sym::rust_logo) => { + // FIXME: Only feature gated at the crate level (!!) + if cx.target == Target::Crate { + gated!( + rustdoc_internals, + "the `#[doc(rust_logo)]` attribute is used for Rust branding" + ); } - }), - Some(sym::auto_cfg) => self.parse_auto_cfg(cx, path, args), + no_args_and_crate_level!(rust_logo) + } + Some(sym::auto_cfg) => { + gated!(doc_cfg); + self.parse_auto_cfg(cx, path, args) + } Some(sym::test) => { let Some(list) = args.as_list() else { cx.emit_lint( diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index dfda3dc722e1b..006219624e4fa 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -864,12 +864,6 @@ impl<'p, 'sess: 'p> DerefMut for SharedContext<'p, 'sess> { } } -#[derive(PartialEq, Clone, Copy, Debug)] -pub enum OmitDoc { - Lower, - Skip, -} - #[derive(Copy, Clone, Debug)] pub enum ShouldEmit { /// The operations will emit errors, and lints, and errors are fatal. diff --git a/compiler/rustc_attr_parsing/src/interface.rs b/compiler/rustc_attr_parsing/src/interface.rs index 602fa6f707055..0686613acb250 100644 --- a/compiler/rustc_attr_parsing/src/interface.rs +++ b/compiler/rustc_attr_parsing/src/interface.rs @@ -23,7 +23,7 @@ use crate::context::{ use crate::diagnostics::ParsedDescription; use crate::parser::{AllowExprMetavar, ArgParser, PathParser, RefPathParser}; use crate::synthetic::SyntheticAttrState; -use crate::{AttributeTemplate, OmitDoc, ShouldEmit}; +use crate::{AttributeTemplate, ShouldEmit}; pub struct EmitAttribute( pub Box< @@ -161,7 +161,6 @@ impl<'sess> AttributeParser<'sess> { attrs, target_span, target, - OmitDoc::Skip, std::convert::identity, |lint_id, span, kind| { sess.psess.dyn_buffer_lint_sess(lint_id.lint, span, target_node_id, kind.0) @@ -310,14 +309,12 @@ impl<'sess> AttributeParser<'sess> { /// Parse a list of attributes. /// - /// `target_span` is the span of the thing this list of attributes is applied to, - /// and when `omit_doc` is set, doc attributes are filtered out. + /// `target_span` is the span of the thing this list of attributes is applied to. pub fn parse_attribute_list( &mut self, attrs: &[ast::Attribute], target_span: Span, target: Target, - omit_doc: OmitDoc, lower_span: impl Copy + Fn(Span) -> Span, mut emit_lint: impl FnMut(LintId, MultiSpan, EmitAttribute), ) -> Vec { @@ -335,23 +332,26 @@ impl<'sess> AttributeParser<'sess> { } } - // Sometimes, for example for `#![doc = include_str!("readme.md")]`, - // doc still contains a non-literal. You might say, when we're lowering attributes - // that's expanded right? But no, sometimes, when parsing attributes on macros, - // we already use the lowering logic and these are still there. So, when `omit_doc` - // is set we *also* want to ignore these. - let is_doc_attribute = attr.has_name(sym::doc); - if omit_doc == OmitDoc::Skip && is_doc_attribute { + fn is_doc_non_lit_expr(attr: &ast::Attribute) -> bool { + if !attr.has_name(sym::doc) { + return false; + } + let ast::AttrKind::Normal(n) = &attr.kind else { return false }; + let ast::AttrArgs::Eq { expr, .. } = &n.item.args else { return false }; + if matches!(expr.kind, ast::ExprKind::Lit(_)) { + return false; + }; + true + } + + // FIXME accidentally allowed on Stable Rust + if target == Target::MacroCall && is_doc_non_lit_expr(attr) { continue; } let attr_span = lower_span(attr.span); match &attr.kind { ast::AttrKind::DocComment(comment_kind, symbol) => { - if omit_doc == OmitDoc::Skip { - continue; - } - attributes.push(Attribute::Parsed(AttributeKind::DocComment { style: attr.style, kind: DocFragmentKind::Sugared(*comment_kind), @@ -407,7 +407,7 @@ impl<'sess> AttributeParser<'sess> { // bla // blob // a - if is_doc_attribute + if attr.has_name(sym::doc) && let ArgParser::NameValue(nv) = &args // If not a string key/value, it should emit an error, but to make // things simpler, it's handled in `DocParser` because it's simpler to diff --git a/compiler/rustc_attr_parsing/src/lib.rs b/compiler/rustc_attr_parsing/src/lib.rs index 4b386f06a005c..3360791cdbc5f 100644 --- a/compiler/rustc_attr_parsing/src/lib.rs +++ b/compiler/rustc_attr_parsing/src/lib.rs @@ -116,7 +116,7 @@ pub use attributes::cfg::{ }; pub use attributes::cfg_select::*; pub use attributes::util::{is_builtin_attr, parse_version}; -pub use context::{OmitDoc, ShouldEmit}; +pub use context::ShouldEmit; pub use diagnostics::ParsedDescription; pub use interface::{AttributeParser, EmitAttribute}; pub use rustc_parse::parser::Recovery; diff --git a/compiler/rustc_attr_parsing/src/stability.rs b/compiler/rustc_attr_parsing/src/stability.rs index b0ab2649c4078..9ae8287812542 100644 --- a/compiler/rustc_attr_parsing/src/stability.rs +++ b/compiler/rustc_attr_parsing/src/stability.rs @@ -53,10 +53,24 @@ impl<'sess> AttributeParser<'sess> { sym::prelude_import => ("the `prelude_import` attribute is for use by rustc only".to_string(), &[]), sym::profiler_runtime => ("the `profiler_runtime` attribute is used to identify the `profiler_builtins` crate which contains the profiler runtime and will never be stable".to_string(), &[]), sym::thread_local => ("the `thread_local` attribute is an experimental feature, and does not currently handle destructors".to_string(), &[]), + sym::rustdoc_internals => ("this subset of the `doc` attribute is meant for internal use only".to_string(), &[]), + sym::doc_notable_trait => ("the `doc(notable_trait)` attribute is experimental".to_string(), &[]), + sym::doc_cfg => ("the `doc(cfg)` and `doc(auto_cfg)` attributes are experimental".to_string(), &[]), + sym::doc_masked => ("the `doc(masked)` attribute is experimental".to_string(), &[]), _ => (format!("the `{attr_path}` attribute is an experimental feature"), &[]), }; - let mut diag = feature_err(self.sess, gate_name, attr_path.span, explain); + // For unstable subsets of an attribute, point at that + let err_span = if matches!( + gate_name, + sym::rustdoc_internals | sym::doc_notable_trait | sym::doc_cfg | sym::doc_masked + ) { + attr_span + } else { + attr_path.span + }; + + let mut diag = feature_err(self.sess, gate_name, err_span, explain); // Remove the suggestion for `#![feature(staged_api)]` as these attributes are currently // not usable outside std. If we do ever expose `#[stable]` etc under a different feature diff --git a/compiler/rustc_builtin_macros/src/contracts.rs b/compiler/rustc_builtin_macros/src/contracts.rs index e47c1b1363df0..20001400857a6 100644 --- a/compiler/rustc_builtin_macros/src/contracts.rs +++ b/compiler/rustc_builtin_macros/src/contracts.rs @@ -137,6 +137,21 @@ fn expand_contract_clause_tts( annotated: TokenStream, clause_keyword: rustc_span::Symbol, ) -> Result { + if annotation.is_empty() { + let (name, example) = if clause_keyword == kw::ContractRequires { + ("requires", "condition") + } else { + ("ensures", "|result: &T| condition") + }; + ecx.sess.dcx().span_err( + attr_span, + format!("`{name}` attribute requires an argument, e.g., `#[{name}({example})]`"), + ); + // Returning `Err` would replace it with a dummy fragment and cause cascading name-resolution errors. + // Instead, we return the original token stream so that there is no later noises. + return Ok(annotated); + } + let feature_span = ecx.with_def_site_ctxt(attr_span); expand_contract_clause(ecx, attr_span, annotated, |new_tts| { new_tts.push(TokenTree::Token( diff --git a/compiler/rustc_expand/Cargo.toml b/compiler/rustc_expand/Cargo.toml index 80353e4c8dba4..0f216aa9f68df 100644 --- a/compiler/rustc_expand/Cargo.toml +++ b/compiler/rustc_expand/Cargo.toml @@ -10,7 +10,6 @@ doctest = false [dependencies] # tidy-alphabetical-start rustc_ast = { path = "../rustc_ast" } -rustc_ast_passes = { path = "../rustc_ast_passes" } rustc_ast_pretty = { path = "../rustc_ast_pretty" } rustc_attr_ir = { path = "../rustc_attr_ir" } rustc_attr_parsing = { path = "../rustc_attr_parsing" } diff --git a/compiler/rustc_expand/src/expand.rs b/compiler/rustc_expand/src/expand.rs index e4d84847db55d..024ee2871b125 100644 --- a/compiler/rustc_expand/src/expand.rs +++ b/compiler/rustc_expand/src/expand.rs @@ -2245,15 +2245,13 @@ impl<'a, 'b> InvocationCollector<'a, 'b> { attr } - // Detect use of feature-gated or invalid attributes on macro invocations + // Run attributes through the attribute parser // since they will not be detected after macro expansion. fn check_attributes(&self, attrs: &[ast::Attribute], call: &ast::MacCall) { use SyntheticAttr::*; - let features = self.cx.ecfg.features; let mut attrs = attrs.iter().peekable(); let mut span: Option = None; while let Some(attr) = attrs.next() { - rustc_ast_passes::feature_gate::check_attribute(attr, self.cx.sess, features); validate_attr::check_attr(&self.cx.sess.psess, attr); AttributeParser::parse_limited_all( self.cx.sess, diff --git a/compiler/rustc_graphviz/src/lib.rs b/compiler/rustc_graphviz/src/lib.rs index cd1e573ea28df..2aaf9cea97e44 100644 --- a/compiler/rustc_graphviz/src/lib.rs +++ b/compiler/rustc_graphviz/src/lib.rs @@ -270,7 +270,7 @@ //! * [DOT language](https://www.graphviz.org/doc/info/lang.html) // tidy-alphabetical-start -#![doc(test(attr(allow(unused_variables), deny(warnings), allow(internal_features))))] +#![doc(test(attr(allow(unused_variables), deny(warnings))))] // tidy-alphabetical-end use std::borrow::Cow; diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 98269a5fd4e44..dbc503f5c7ec4 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -823,7 +823,7 @@ declare_lint! { /// /// ### Example /// - /// ```rust + /// ```rust,compile_fail /// #![deny(dead_code_pub_in_binary)] /// /// pub fn unused_pub_fn() {} @@ -1132,9 +1132,9 @@ declare_lint! { /// /// ### Example /// - /// ```rust + /// ```rust,compile_fail /// #![deny(warnings)] - /// fn foo() {} + /// struct non_standard_name; /// ``` /// /// {{produces}} diff --git a/compiler/rustc_parse_format/src/lib.rs b/compiler/rustc_parse_format/src/lib.rs index 256bc8c3fe30e..90e04fe388ad6 100644 --- a/compiler/rustc_parse_format/src/lib.rs +++ b/compiler/rustc_parse_format/src/lib.rs @@ -8,7 +8,7 @@ // We want to be able to build this crate with a stable compiler, // so no `#![feature]` attributes should be added. #![deny(unstable_features)] -#![doc(test(attr(deny(warnings), allow(internal_features))))] +#![doc(test(attr(deny(warnings))))] // tidy-alphabetical-end use std::ops::Range; diff --git a/compiler/rustc_public/src/lib.rs b/compiler/rustc_public/src/lib.rs index 4adc0e139a68e..ac2d1eb7a7a42 100644 --- a/compiler/rustc_public/src/lib.rs +++ b/compiler/rustc_public/src/lib.rs @@ -43,7 +43,7 @@ //! For more information, see . #![allow(rustc::usage_of_ty_tykind)] -#![doc(test(attr(allow(unused_variables), deny(warnings), allow(internal_features))))] +#![doc(test(attr(allow(unused_variables), deny(warnings))))] #![feature(sized_hierarchy)] use std::fmt::Debug; diff --git a/compiler/rustc_public_bridge/src/lib.rs b/compiler/rustc_public_bridge/src/lib.rs index d598f88a00d27..c8859b0e349ea 100644 --- a/compiler/rustc_public_bridge/src/lib.rs +++ b/compiler/rustc_public_bridge/src/lib.rs @@ -13,7 +13,7 @@ // tidy-alphabetical-start #![allow(rustc::usage_of_ty_tykind)] -#![doc(test(attr(allow(unused_variables), deny(warnings), allow(internal_features))))] +#![doc(test(attr(allow(unused_variables), deny(warnings))))] #![feature(trait_alias)] // tidy-alphabetical-end diff --git a/compiler/rustc_resolve/src/def_collector.rs b/compiler/rustc_resolve/src/def_collector.rs index b45a9d1a6ec54..29b1773ddc5ca 100644 --- a/compiler/rustc_resolve/src/def_collector.rs +++ b/compiler/rustc_resolve/src/def_collector.rs @@ -3,7 +3,7 @@ use std::mem; use rustc_ast::visit::FnKind; use rustc_ast::*; use rustc_attr_parsing as attr; -use rustc_attr_parsing::{AttributeParser, OmitDoc, ShouldEmit}; +use rustc_attr_parsing::{AttributeParser, ShouldEmit}; use rustc_expand::expand::AstFragment; use rustc_hir as hir; use rustc_hir::Target; @@ -187,7 +187,6 @@ impl<'a, 'ra, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'ra, 'tcx> { &i.attrs, i.span, Target::MacroDef, - OmitDoc::Skip, std::convert::identity, |_lint_id, _span, _kind| { // FIXME(jdonszelmann): emit lints here properly diff --git a/compiler/rustc_serialize/src/lib.rs b/compiler/rustc_serialize/src/lib.rs index 39333ab00b57f..ae7c3854d00b4 100644 --- a/compiler/rustc_serialize/src/lib.rs +++ b/compiler/rustc_serialize/src/lib.rs @@ -4,7 +4,7 @@ #![allow(internal_features)] #![allow(rustc::internal)] #![cfg_attr(bootstrap, feature(never_type))] -#![doc(test(attr(allow(unused_variables), deny(warnings), allow(internal_features))))] +#![doc(test(attr(allow(unused_variables), deny(warnings))))] #![feature(core_intrinsics)] #![feature(min_specialization)] #![feature(nonzero_internals)] diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index a5053c408b155..95f6348cfbdbb 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -3647,11 +3647,14 @@ pub enum Polonius { impl Default for Polonius { fn default() -> Self { - if option_env!("CFG_DEFAULT_POLONIUS_NEXT").is_some() { Self::Next } else { Self::Off } + Self::DEFAULT } } impl Polonius { + pub(crate) const DEFAULT: Self = + if option_env!("CFG_DEFAULT_POLONIUS_NEXT").is_some() { Self::Next } else { Self::Off }; + /// Returns whether the legacy version of polonius is enabled pub fn is_legacy_enabled(&self) -> bool { matches!(self, Polonius::Legacy) diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 90459090ced87..bab087249593a 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -510,7 +510,7 @@ macro_rules! options { $( { TARGET_MODIFIER: $tmod_variant:ident } )? $( { MITIGATION: $mitigation_variant:ident } )? , - $desc:literal + $desc:expr $(, removed: $removed:ident )? ), )* @@ -2350,6 +2350,12 @@ options! { // - src/doc/rustc/src/codegen-options/index.md } +const POLONIUS_HELP: &str = match Polonius::DEFAULT { + Polonius::Off => "enable polonius-based borrow-checker (default: no)", + Polonius::Next => "enable polonius-based borrow-checker (default: next)", + Polonius::Legacy => panic!("Polonius::Legacy is not a valid default value"), +}; + options! { UnstableOptions, UnstableOptionsTargetModifiers, Z_OPTIONS, dbopts, "Z", "unstable", @@ -2750,7 +2756,7 @@ options! { `vt-ptr-type-discrimination - incorporate type discrimination in authenticated vtable pointers Example: `-Zpointer-authentication=+calls,-init-fini`."), polonius: Polonius = (Polonius::default(), parse_polonius, [TRACKED], - "enable polonius-based borrow-checker (default: no)"), + POLONIUS_HELP), pre_link_arg: (/* redirected to pre_link_args */) = ((), parse_string_push, [UNTRACKED], "a single extra argument to prepend the linker invocation (can be used several times)"), pre_link_args: Vec = (Vec::new(), parse_list, [UNTRACKED], diff --git a/compiler/rustc_target/src/asm/loongarch.rs b/compiler/rustc_target/src/asm/loongarch.rs index 4aa69dac2d7db..3603d54400536 100644 --- a/compiler/rustc_target/src/asm/loongarch.rs +++ b/compiler/rustc_target/src/asm/loongarch.rs @@ -53,7 +53,7 @@ impl LoongArchInlineAsmRegClass { (Self::vreg, _) => { if allow_experimental_reg { types! { - lsx: F16, F32, F64, + lsx: I128, F16, F32, F64, VecI8(16), VecI16(8), VecI32(4), VecI64(2), VecF32(4), VecF64(2); } } else { @@ -63,7 +63,7 @@ impl LoongArchInlineAsmRegClass { (Self::xreg, _) => { if allow_experimental_reg { types! { - lasx: F16, F32, F64, + lasx: I128, F16, F32, F64, VecI8(16), VecI16(8), VecI32(4), VecI64(2), VecF32(4), VecF64(2), VecI8(32), VecI16(16), VecI32(8), VecI64(4), VecF32(8), VecF64(4); } diff --git a/compiler/rustc_traits/src/normalize_projection_ty.rs b/compiler/rustc_traits/src/normalize_projection_ty.rs index 3710d41dba0d9..03dff745210d6 100644 --- a/compiler/rustc_traits/src/normalize_projection_ty.rs +++ b/compiler/rustc_traits/src/normalize_projection_ty.rs @@ -59,12 +59,6 @@ fn normalize_canonicalized_projection<'tcx>( 0, &mut obligations, ); - obligations.extend(const_arg_has_type_obligation( - tcx, - param_env, - normalized_term, - goal, - )); ocx.register_obligations(obligations); // #112047: With projections and opaques, we are able to create opaques that // are recursive (given some generic parameters of the opaque's type variables). @@ -147,12 +141,6 @@ fn normalize_canonicalized_inherent_projection<'tcx>( 0, &mut obligations, ); - obligations.extend(const_arg_has_type_obligation( - tcx, - param_env, - normalized_term, - goal, - )); ocx.register_obligations(obligations); Ok(NormalizationResult { normalized_term }) diff --git a/library/std/src/sys/fs/uefi.rs b/library/std/src/sys/fs/uefi.rs index 1a0da329ce1a3..08473e245cc8e 100644 --- a/library/std/src/sys/fs/uefi.rs +++ b/library/std/src/sys/fs/uefi.rs @@ -360,12 +360,7 @@ impl File { let off = match pos { SeekFrom::Start(p) => p, SeekFrom::End(p) => { - // Seeking to position 0xFFFFFFFFFFFFFFFF causes the current position to be set to the end of the file. - if p == 0 { - 0xFFFFFFFFFFFFFFFF - } else { - self.file_attr()?.size().checked_add_signed(p).ok_or(NEG_OFF_ERR)? - } + self.file_attr()?.size().checked_add_signed(p).ok_or(NEG_OFF_ERR)? } SeekFrom::Current(p) => self.tell()?.checked_add_signed(p).ok_or(NEG_OFF_ERR)?, }; diff --git a/src/bootstrap/src/bin/rustdoc.rs b/src/bootstrap/src/bin/rustdoc.rs index eba1e9ef1c5cf..da80d7cd8c599 100644 --- a/src/bootstrap/src/bin/rustdoc.rs +++ b/src/bootstrap/src/bin/rustdoc.rs @@ -65,7 +65,10 @@ fn main() { if let Some(crate_name) = parse_value_from_args(&args, "--crate-name") { // Add rust logo and set html root for all rustc crates. if crate_name.starts_with("rustc_") { - cmd.arg("-Ainternal_features") + // We use `-Zcrate-attr=allow` instead of `-A` to force rustdoc to forward this flag to + // the actual doctests. Otherwise those tests all receive the + // `feature(rustdoc_internals)` without receiving the `-A` which leads to errors. + cmd.arg("-Zcrate-attr=allow(internal_features)") .arg("-Zcrate-attr=doc(rust_logo)") .arg("-Zcrate-attr=doc(html_root_url = \"https://doc.rust-lang.org/nightly/nightly-rustc/\")"); diff --git a/src/bootstrap/src/utils/helpers.rs b/src/bootstrap/src/utils/helpers.rs index d41ce974c5009..7fecfe14cc578 100644 --- a/src/bootstrap/src/utils/helpers.rs +++ b/src/bootstrap/src/utils/helpers.rs @@ -141,11 +141,8 @@ pub fn libdir(target: TargetSelection) -> &'static str { /// Adds a list of lookup paths to `cmd`'s dynamic library lookup path. /// If the dylib_path_var is already set for this cmd, the old value will be overwritten! pub fn add_dylib_path(path: Vec, cmd: &mut BootstrapCommand) { - let mut list = dylib_path(); - for path in path { - list.insert(0, path); - } - cmd.env(dylib_path_var(), t!(env::join_paths(list))); + let paths = path.into_iter().chain(dylib_path()); + cmd.env(dylib_path_var(), t!(env::join_paths(paths))); } pub struct TimeIt(bool, Instant); diff --git a/src/doc/unstable-book/src/language-features/asm-experimental-reg.md b/src/doc/unstable-book/src/language-features/asm-experimental-reg.md index db72c44a2dc92..854d66f96756c 100644 --- a/src/doc/unstable-book/src/language-features/asm-experimental-reg.md +++ b/src/doc/unstable-book/src/language-features/asm-experimental-reg.md @@ -19,8 +19,8 @@ This tracks support for additional registers in architectures where inline assem | Architecture | Register class | Target feature | Allowed types | | ------------ | -------------- | -------------- | ------------- | -| LoongArch | `vreg` | `lsx` | `f32`, `f64`,
`i8x16`, `i16x8`, `i32x4`, `i64x2`, `f32x4`, `f64x2` | -| LoongArch | `xreg` | `lasx` | `f32`, `f64`,
`i8x16`, `i16x8`, `i32x4`, `i64x2`, `f32x4`, `f64x2`,
`i8x32`, `i16x16`, `i32x8`, `i64x4`, `f32x8`, `f64x4` | +| LoongArch | `vreg` | `lsx` | `i128`, `f32`, `f64`,
`i8x16`, `i16x8`, `i32x4`, `i64x2`, `f32x4`, `f64x2` | +| LoongArch | `xreg` | `lasx` | `i128`, `f32`, `f64`,
`i8x16`, `i16x8`, `i32x4`, `i64x2`, `f32x4`, `f64x2`,
`i8x32`, `i16x16`, `i32x8`, `i64x4`, `f32x8`, `f64x4` | ## Register aliases diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index cb7ddd0ec58e7..d7fbe64c30771 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -250,17 +250,21 @@ pub(crate) fn get_item_path(tcx: TyCtxt<'_>, def_id: DefId, kind: ItemType) -> V if let ItemType::Macro = kind { // Check to see if it is a macro 2.0 or built-in macro // More information in . - if matches!( - CStore::from_tcx(tcx).load_macro_untracked(tcx, def_id), - LoadedMacro::MacroDef { def, .. } if !def.macro_rules - ) { - once(crate_name).chain(relative).collect() + let is_macro_2_0_or_builtin = if let Some(local_def_id) = def_id.as_local() { + let (_, macro_def, _) = tcx.hir_expect_item(local_def_id).expect_macro(); + !macro_def.macro_rules } else { - vec![crate_name, *relative.last().expect("relative was empty")] + matches!( + CStore::from_tcx(tcx).load_macro_untracked(tcx, def_id), + LoadedMacro::MacroDef { def, .. } if !def.macro_rules + ) + }; + if !is_macro_2_0_or_builtin { + return vec![crate_name, *relative.last().expect("relative was empty")]; } - } else { - once(crate_name).chain(relative).collect() } + + once(crate_name).chain(relative).collect() } /// Record an external fully qualified name in the external_paths cache. diff --git a/tests/run-make/rustc-help/polonius-help.stdout b/tests/run-make/rustc-help/polonius-help.stdout new file mode 100644 index 0000000000000..b1dfd15c09958 --- /dev/null +++ b/tests/run-make/rustc-help/polonius-help.stdout @@ -0,0 +1 @@ + -Z polonius=val -- enable polonius-based borrow-checker (default: next) diff --git a/tests/run-make/rustc-help/rmake.rs b/tests/run-make/rustc-help/rmake.rs index 17811ef18449f..a5e733fb8d9fc 100644 --- a/tests/run-make/rustc-help/rmake.rs +++ b/tests/run-make/rustc-help/rmake.rs @@ -22,6 +22,12 @@ fn main() { // Check that all help options can be invoked at once let codegen_help = bare_rustc().arg("-Chelp").run().stdout_utf8(); let unstable_help = bare_rustc().arg("-Zhelp").run().stdout_utf8(); + let polonius_help = + format!("{}\n", unstable_help.lines().find(|line| line.contains("polonius=val")).unwrap()); + diff() + .expected_file("polonius-help.stdout") + .actual_text("rustc -Zhelp (polonius)", &polonius_help) + .run(); let lints_help = bare_rustc().arg("-Whelp").run().stdout_utf8(); let expected_all = format!("{help}{codegen_help}{unstable_help}{lints_help}"); let all_help = bare_rustc().args(["--help", "-Chelp", "-Zhelp", "-Whelp"]).run().stdout_utf8(); diff --git a/tests/rustdoc-html/auxiliary/generated_macro.rs b/tests/rustdoc-html/auxiliary/generated_macro.rs new file mode 100644 index 0000000000000..47a2eae5b3c2c --- /dev/null +++ b/tests/rustdoc-html/auxiliary/generated_macro.rs @@ -0,0 +1,17 @@ +//@ no-prefer-dynamic + +#![crate_type = "proc-macro"] + +use std::str::FromStr; + +extern crate proc_macro; + +#[proc_macro_derive(MyDeriveMacro)] +pub fn derive_my_derive_macro(item: proc_macro::TokenStream) -> proc_macro::TokenStream { + proc_macro::TokenStream::from_str(" + #[macro_export] + macro_rules! my_generated_macro { + ($my_macro_parameter: expr) => {}; + } + ").unwrap() +} diff --git a/tests/rustdoc-html/generated_macro.rs b/tests/rustdoc-html/generated_macro.rs new file mode 100644 index 0000000000000..3986930f8e631 --- /dev/null +++ b/tests/rustdoc-html/generated_macro.rs @@ -0,0 +1,16 @@ +// This test ensures that the macro generated by the proc macro has the correct +// "item-decl" code block. +// Regression test for . + +//@ aux-build:generated_macro.rs + +#![crate_name = "foo"] + +extern crate generated_macro; + +//@ has 'foo/macro.my_generated_macro.html' +//@ matches - '//*[@class="rust item-decl"]/code' \ +// 'macro_rules! my_generated_macro \{\s+\(\$my_macro_parameter:expr\) => \{ ... \};\s+\}' + +#[derive(generated_macro::MyDeriveMacro)] +struct MyStruct {} diff --git a/tests/rustdoc-ui/feature-gate-doc_cfg.stderr b/tests/rustdoc-ui/feature-gate-doc_cfg.stderr index 68a86c1abb777..db2f3b5737549 100644 --- a/tests/rustdoc-ui/feature-gate-doc_cfg.stderr +++ b/tests/rustdoc-ui/feature-gate-doc_cfg.stderr @@ -1,58 +1,58 @@ -error[E0658]: `#[doc(auto_cfg)]` is experimental - --> $DIR/feature-gate-doc_cfg.rs:1:1 +error[E0658]: the `doc(cfg)` and `doc(auto_cfg)` attributes are experimental + --> $DIR/feature-gate-doc_cfg.rs:1:8 | LL | #![doc(auto_cfg)] - | ^^^^^^^^^^^^^^^^^ + | ^^^^^^^^ | = note: see issue #43781 for more information = help: add `#![feature(doc_cfg)]` 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]: `#[doc(auto_cfg)]` is experimental - --> $DIR/feature-gate-doc_cfg.rs:2:1 +error[E0658]: the `doc(cfg)` and `doc(auto_cfg)` attributes are experimental + --> $DIR/feature-gate-doc_cfg.rs:2:8 | LL | #![doc(auto_cfg(false))] - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^ | = note: see issue #43781 for more information = help: add `#![feature(doc_cfg)]` 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]: `#[doc(auto_cfg)]` is experimental - --> $DIR/feature-gate-doc_cfg.rs:3:1 +error[E0658]: the `doc(cfg)` and `doc(auto_cfg)` attributes are experimental + --> $DIR/feature-gate-doc_cfg.rs:3:8 | LL | #![doc(auto_cfg(true))] - | ^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^ | = note: see issue #43781 for more information = help: add `#![feature(doc_cfg)]` 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]: `#[doc(auto_cfg)]` is experimental - --> $DIR/feature-gate-doc_cfg.rs:4:1 +error[E0658]: the `doc(cfg)` and `doc(auto_cfg)` attributes are experimental + --> $DIR/feature-gate-doc_cfg.rs:4:8 | LL | #![doc(auto_cfg(hide(feature = "solecism")))] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^ | = note: see issue #43781 for more information = help: add `#![feature(doc_cfg)]` 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]: `#[doc(auto_cfg)]` is experimental - --> $DIR/feature-gate-doc_cfg.rs:5:1 +error[E0658]: the `doc(cfg)` and `doc(auto_cfg)` attributes are experimental + --> $DIR/feature-gate-doc_cfg.rs:5:8 | LL | #![doc(auto_cfg(show(feature = "bla")))] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^ | = note: see issue #43781 for more information = help: add `#![feature(doc_cfg)]` 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]: `#[doc(cfg)]` is experimental - --> $DIR/feature-gate-doc_cfg.rs:6:1 +error[E0658]: the `doc(cfg)` and `doc(auto_cfg)` attributes are experimental + --> $DIR/feature-gate-doc_cfg.rs:6:8 | LL | #![doc(cfg(feature = "solecism"))] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^ | = note: see issue #43781 for more information = help: add `#![feature(doc_cfg)]` to the crate attributes to enable diff --git a/tests/rustdoc-ui/lints/redundant-explicit-links-ice.fixed b/tests/rustdoc-ui/lints/redundant-explicit-links-ice.fixed new file mode 100644 index 0000000000000..bfd09e970db06 --- /dev/null +++ b/tests/rustdoc-ui/lints/redundant-explicit-links-ice.fixed @@ -0,0 +1,13 @@ +// Regression test for . + +//@ run-rustfix + +#![deny(rustdoc::redundant_explicit_links)] + +//! [queue] +//~^ ERROR redundant explicit link target + +#[macro_export] +macro_rules! queue { + () => {}; +} diff --git a/tests/rustdoc-ui/lints/redundant-explicit-links-ice.rs b/tests/rustdoc-ui/lints/redundant-explicit-links-ice.rs new file mode 100644 index 0000000000000..a129baecdb79f --- /dev/null +++ b/tests/rustdoc-ui/lints/redundant-explicit-links-ice.rs @@ -0,0 +1,13 @@ +// Regression test for . + +//@ run-rustfix + +#![deny(rustdoc::redundant_explicit_links)] + +//! [queue](macro.queue.html) +//~^ ERROR redundant explicit link target + +#[macro_export] +macro_rules! queue { + () => {}; +} diff --git a/tests/rustdoc-ui/lints/redundant-explicit-links-ice.stderr b/tests/rustdoc-ui/lints/redundant-explicit-links-ice.stderr new file mode 100644 index 0000000000000..2caf08e26936f --- /dev/null +++ b/tests/rustdoc-ui/lints/redundant-explicit-links-ice.stderr @@ -0,0 +1,23 @@ +error: redundant explicit link target + --> $DIR/redundant-explicit-links-ice.rs:7:13 + | +LL | //! [queue](macro.queue.html) + | ----- ^^^^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +note: the lint level is defined here + --> $DIR/redundant-explicit-links-ice.rs:5:9 + | +LL | #![deny(rustdoc::redundant_explicit_links)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: remove explicit link target + | +LL - //! [queue](macro.queue.html) +LL + //! [queue] + | + +error: aborting due to 1 previous error + diff --git a/tests/ui/asm/loongarch/bad-reg.loongarch32_ilp32d.stderr b/tests/ui/asm/loongarch/bad-reg.loongarch32_ilp32d.stderr index 28ac455c06441..dca21ad47ea10 100644 --- a/tests/ui/asm/loongarch/bad-reg.loongarch32_ilp32d.stderr +++ b/tests/ui/asm/loongarch/bad-reg.loongarch32_ilp32d.stderr @@ -1,41 +1,51 @@ error: invalid register `$r0`: constant zero cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:28:18 + --> $DIR/bad-reg.rs:29:18 | LL | asm!("", out("$r0") _); | ^^^^^^^^^^^^ error: invalid register `$tp`: reserved for TLS - --> $DIR/bad-reg.rs:30:18 + --> $DIR/bad-reg.rs:31:18 | LL | asm!("", out("$tp") _); | ^^^^^^^^^^^^ error: invalid register `$sp`: the stack pointer cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:32:18 + --> $DIR/bad-reg.rs:33:18 | LL | asm!("", out("$sp") _); | ^^^^^^^^^^^^ error: invalid register `$r21`: reserved by the ABI - --> $DIR/bad-reg.rs:34:18 + --> $DIR/bad-reg.rs:35:18 | LL | asm!("", out("$r21") _); | ^^^^^^^^^^^^^ error: invalid register `$fp`: the frame pointer cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:36:18 + --> $DIR/bad-reg.rs:37:18 | LL | asm!("", out("$fp") _); | ^^^^^^^^^^^^ error: invalid register `$r31`: $r31 is used internally by LLVM and cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:38:18 + --> $DIR/bad-reg.rs:39:18 | LL | asm!("", out("$r31") _); | ^^^^^^^^^^^^^ error[E0658]: register class `vreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:52:26 + --> $DIR/bad-reg.rs:53:26 + | +LL | asm!("/* {} */", in(vreg) q); + | ^^^^^^^^^^ + | + = note: see issue #133416 for more information + = help: add `#![feature(asm_experimental_reg)]` 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]: register class `vreg` can only be used as a clobber in stable + --> $DIR/bad-reg.rs:56:26 | LL | asm!("/* {} */", in(vreg) f); | ^^^^^^^^^^ @@ -45,7 +55,7 @@ LL | asm!("/* {} */", in(vreg) f); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: register class `vreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:55:26 + --> $DIR/bad-reg.rs:59:26 | LL | asm!("/* {} */", out(vreg) _); | ^^^^^^^^^^^ @@ -55,7 +65,7 @@ LL | asm!("/* {} */", out(vreg) _); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: register class `vreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:57:26 + --> $DIR/bad-reg.rs:61:26 | LL | asm!("/* {} */", in(vreg) d); | ^^^^^^^^^^ @@ -65,7 +75,7 @@ LL | asm!("/* {} */", in(vreg) d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: register class `vreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:60:26 + --> $DIR/bad-reg.rs:64:26 | LL | asm!("/* {} */", out(vreg) d); | ^^^^^^^^^^^ @@ -75,7 +85,17 @@ LL | asm!("/* {} */", out(vreg) d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: register class `xreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:65:26 + --> $DIR/bad-reg.rs:69:26 + | +LL | asm!("/* {} */", in(xreg) q); + | ^^^^^^^^^^ + | + = note: see issue #133416 for more information + = help: add `#![feature(asm_experimental_reg)]` 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]: register class `xreg` can only be used as a clobber in stable + --> $DIR/bad-reg.rs:72:26 | LL | asm!("/* {} */", in(xreg) f); | ^^^^^^^^^^ @@ -85,7 +105,7 @@ LL | asm!("/* {} */", in(xreg) f); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: register class `xreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:68:26 + --> $DIR/bad-reg.rs:75:26 | LL | asm!("/* {} */", out(xreg) _); | ^^^^^^^^^^^ @@ -95,7 +115,7 @@ LL | asm!("/* {} */", out(xreg) _); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: register class `xreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:70:26 + --> $DIR/bad-reg.rs:77:26 | LL | asm!("/* {} */", in(xreg) d); | ^^^^^^^^^^ @@ -105,7 +125,7 @@ LL | asm!("/* {} */", in(xreg) d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: register class `xreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:73:26 + --> $DIR/bad-reg.rs:80:26 | LL | asm!("/* {} */", out(xreg) d); | ^^^^^^^^^^^ @@ -115,7 +135,7 @@ LL | asm!("/* {} */", out(xreg) d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: register class `vreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:77:31 + --> $DIR/bad-reg.rs:84:31 | LL | asm!("", in("$f0") f, in("$vr0") d); | ^^^^^^^^^^^^ @@ -125,7 +145,7 @@ LL | asm!("", in("$f0") f, in("$vr0") d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: register class `xreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:82:31 + --> $DIR/bad-reg.rs:89:31 | LL | asm!("", in("$f0") f, in("$xr0") d); | ^^^^^^^^^^^^ @@ -135,7 +155,7 @@ LL | asm!("", in("$f0") f, in("$xr0") d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: register class `vreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:87:18 + --> $DIR/bad-reg.rs:94:18 | LL | asm!("", in("$vr0") f, in("$xr0") d); | ^^^^^^^^^^^^ @@ -145,7 +165,7 @@ LL | asm!("", in("$vr0") f, in("$xr0") d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: register class `xreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:87:32 + --> $DIR/bad-reg.rs:94:32 | LL | asm!("", in("$vr0") f, in("$xr0") d); | ^^^^^^^^^^^^ @@ -154,8 +174,18 @@ LL | asm!("", in("$vr0") f, in("$xr0") d); = help: add `#![feature(asm_experimental_reg)]` 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]: type `u128` cannot be used with this register class in stable + --> $DIR/bad-reg.rs:53:35 + | +LL | asm!("/* {} */", in(vreg) q); + | ^ + | + = note: see issue #133416 for more information + = help: add `#![feature(asm_experimental_reg)]` 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]: type `f32` cannot be used with this register class in stable - --> $DIR/bad-reg.rs:52:35 + --> $DIR/bad-reg.rs:56:35 | LL | asm!("/* {} */", in(vreg) f); | ^ @@ -165,7 +195,7 @@ LL | asm!("/* {} */", in(vreg) f); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: type `f64` cannot be used with this register class in stable - --> $DIR/bad-reg.rs:57:35 + --> $DIR/bad-reg.rs:61:35 | LL | asm!("/* {} */", in(vreg) d); | ^ @@ -175,7 +205,7 @@ LL | asm!("/* {} */", in(vreg) d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: type `f64` cannot be used with this register class in stable - --> $DIR/bad-reg.rs:60:36 + --> $DIR/bad-reg.rs:64:36 | LL | asm!("/* {} */", out(vreg) d); | ^ @@ -184,8 +214,18 @@ LL | asm!("/* {} */", out(vreg) d); = help: add `#![feature(asm_experimental_reg)]` 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]: type `u128` cannot be used with this register class in stable + --> $DIR/bad-reg.rs:69:35 + | +LL | asm!("/* {} */", in(xreg) q); + | ^ + | + = note: see issue #133416 for more information + = help: add `#![feature(asm_experimental_reg)]` 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]: type `f32` cannot be used with this register class in stable - --> $DIR/bad-reg.rs:65:35 + --> $DIR/bad-reg.rs:72:35 | LL | asm!("/* {} */", in(xreg) f); | ^ @@ -195,7 +235,7 @@ LL | asm!("/* {} */", in(xreg) f); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: type `f64` cannot be used with this register class in stable - --> $DIR/bad-reg.rs:70:35 + --> $DIR/bad-reg.rs:77:35 | LL | asm!("/* {} */", in(xreg) d); | ^ @@ -205,7 +245,7 @@ LL | asm!("/* {} */", in(xreg) d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: type `f64` cannot be used with this register class in stable - --> $DIR/bad-reg.rs:73:36 + --> $DIR/bad-reg.rs:80:36 | LL | asm!("/* {} */", out(xreg) d); | ^ @@ -215,7 +255,7 @@ LL | asm!("/* {} */", out(xreg) d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: type `f64` cannot be used with this register class in stable - --> $DIR/bad-reg.rs:77:42 + --> $DIR/bad-reg.rs:84:42 | LL | asm!("", in("$f0") f, in("$vr0") d); | ^ @@ -225,7 +265,7 @@ LL | asm!("", in("$f0") f, in("$vr0") d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: type `f64` cannot be used with this register class in stable - --> $DIR/bad-reg.rs:82:42 + --> $DIR/bad-reg.rs:89:42 | LL | asm!("", in("$f0") f, in("$xr0") d); | ^ @@ -235,7 +275,7 @@ LL | asm!("", in("$f0") f, in("$xr0") d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: type `f32` cannot be used with this register class in stable - --> $DIR/bad-reg.rs:87:29 + --> $DIR/bad-reg.rs:94:29 | LL | asm!("", in("$vr0") f, in("$xr0") d); | ^ @@ -245,7 +285,7 @@ LL | asm!("", in("$vr0") f, in("$xr0") d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: type `f64` cannot be used with this register class in stable - --> $DIR/bad-reg.rs:87:43 + --> $DIR/bad-reg.rs:94:43 | LL | asm!("", in("$vr0") f, in("$xr0") d); | ^ @@ -254,6 +294,6 @@ LL | asm!("", in("$vr0") f, in("$xr0") d); = help: add `#![feature(asm_experimental_reg)]` 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 28 previous errors +error: aborting due to 32 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/asm/loongarch/bad-reg.loongarch32_ilp32s.stderr b/tests/ui/asm/loongarch/bad-reg.loongarch32_ilp32s.stderr index 1ee1b86989c4d..9ffab83db95cb 100644 --- a/tests/ui/asm/loongarch/bad-reg.loongarch32_ilp32s.stderr +++ b/tests/ui/asm/loongarch/bad-reg.loongarch32_ilp32s.stderr @@ -1,41 +1,51 @@ error: invalid register `$r0`: constant zero cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:28:18 + --> $DIR/bad-reg.rs:29:18 | LL | asm!("", out("$r0") _); | ^^^^^^^^^^^^ error: invalid register `$tp`: reserved for TLS - --> $DIR/bad-reg.rs:30:18 + --> $DIR/bad-reg.rs:31:18 | LL | asm!("", out("$tp") _); | ^^^^^^^^^^^^ error: invalid register `$sp`: the stack pointer cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:32:18 + --> $DIR/bad-reg.rs:33:18 | LL | asm!("", out("$sp") _); | ^^^^^^^^^^^^ error: invalid register `$r21`: reserved by the ABI - --> $DIR/bad-reg.rs:34:18 + --> $DIR/bad-reg.rs:35:18 | LL | asm!("", out("$r21") _); | ^^^^^^^^^^^^^ error: invalid register `$fp`: the frame pointer cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:36:18 + --> $DIR/bad-reg.rs:37:18 | LL | asm!("", out("$fp") _); | ^^^^^^^^^^^^ error: invalid register `$r31`: $r31 is used internally by LLVM and cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:38:18 + --> $DIR/bad-reg.rs:39:18 | LL | asm!("", out("$r31") _); | ^^^^^^^^^^^^^ error[E0658]: register class `vreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:52:26 + --> $DIR/bad-reg.rs:53:26 + | +LL | asm!("/* {} */", in(vreg) q); + | ^^^^^^^^^^ + | + = note: see issue #133416 for more information + = help: add `#![feature(asm_experimental_reg)]` 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]: register class `vreg` can only be used as a clobber in stable + --> $DIR/bad-reg.rs:56:26 | LL | asm!("/* {} */", in(vreg) f); | ^^^^^^^^^^ @@ -45,7 +55,7 @@ LL | asm!("/* {} */", in(vreg) f); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: register class `vreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:55:26 + --> $DIR/bad-reg.rs:59:26 | LL | asm!("/* {} */", out(vreg) _); | ^^^^^^^^^^^ @@ -55,7 +65,7 @@ LL | asm!("/* {} */", out(vreg) _); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: register class `vreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:57:26 + --> $DIR/bad-reg.rs:61:26 | LL | asm!("/* {} */", in(vreg) d); | ^^^^^^^^^^ @@ -65,7 +75,7 @@ LL | asm!("/* {} */", in(vreg) d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: register class `vreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:60:26 + --> $DIR/bad-reg.rs:64:26 | LL | asm!("/* {} */", out(vreg) d); | ^^^^^^^^^^^ @@ -75,7 +85,17 @@ LL | asm!("/* {} */", out(vreg) d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: register class `xreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:65:26 + --> $DIR/bad-reg.rs:69:26 + | +LL | asm!("/* {} */", in(xreg) q); + | ^^^^^^^^^^ + | + = note: see issue #133416 for more information + = help: add `#![feature(asm_experimental_reg)]` 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]: register class `xreg` can only be used as a clobber in stable + --> $DIR/bad-reg.rs:72:26 | LL | asm!("/* {} */", in(xreg) f); | ^^^^^^^^^^ @@ -85,7 +105,7 @@ LL | asm!("/* {} */", in(xreg) f); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: register class `xreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:68:26 + --> $DIR/bad-reg.rs:75:26 | LL | asm!("/* {} */", out(xreg) _); | ^^^^^^^^^^^ @@ -95,7 +115,7 @@ LL | asm!("/* {} */", out(xreg) _); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: register class `xreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:70:26 + --> $DIR/bad-reg.rs:77:26 | LL | asm!("/* {} */", in(xreg) d); | ^^^^^^^^^^ @@ -105,7 +125,7 @@ LL | asm!("/* {} */", in(xreg) d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: register class `xreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:73:26 + --> $DIR/bad-reg.rs:80:26 | LL | asm!("/* {} */", out(xreg) d); | ^^^^^^^^^^^ @@ -115,7 +135,7 @@ LL | asm!("/* {} */", out(xreg) d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: register class `vreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:77:31 + --> $DIR/bad-reg.rs:84:31 | LL | asm!("", in("$f0") f, in("$vr0") d); | ^^^^^^^^^^^^ @@ -125,7 +145,7 @@ LL | asm!("", in("$f0") f, in("$vr0") d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: register class `xreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:82:31 + --> $DIR/bad-reg.rs:89:31 | LL | asm!("", in("$f0") f, in("$xr0") d); | ^^^^^^^^^^^^ @@ -135,7 +155,7 @@ LL | asm!("", in("$f0") f, in("$xr0") d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: register class `vreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:87:18 + --> $DIR/bad-reg.rs:94:18 | LL | asm!("", in("$vr0") f, in("$xr0") d); | ^^^^^^^^^^^^ @@ -145,7 +165,7 @@ LL | asm!("", in("$vr0") f, in("$xr0") d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: register class `xreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:87:32 + --> $DIR/bad-reg.rs:94:32 | LL | asm!("", in("$vr0") f, in("$xr0") d); | ^^^^^^^^^^^^ @@ -155,31 +175,41 @@ LL | asm!("", in("$vr0") f, in("$xr0") d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: register class `freg` requires at least one of the following target features: d, f - --> $DIR/bad-reg.rs:42:26 + --> $DIR/bad-reg.rs:43:26 | LL | asm!("/* {} */", in(freg) f); | ^^^^^^^^^^ error: register class `freg` requires at least one of the following target features: d, f - --> $DIR/bad-reg.rs:44:26 + --> $DIR/bad-reg.rs:45:26 | LL | asm!("/* {} */", out(freg) _); | ^^^^^^^^^^^ error: register class `freg` requires at least one of the following target features: d, f - --> $DIR/bad-reg.rs:46:26 + --> $DIR/bad-reg.rs:47:26 | LL | asm!("/* {} */", in(freg) d); | ^^^^^^^^^^ error: register class `freg` requires at least one of the following target features: d, f - --> $DIR/bad-reg.rs:48:26 + --> $DIR/bad-reg.rs:49:26 | LL | asm!("/* {} */", out(freg) d); | ^^^^^^^^^^^ +error[E0658]: type `u128` cannot be used with this register class in stable + --> $DIR/bad-reg.rs:53:35 + | +LL | asm!("/* {} */", in(vreg) q); + | ^ + | + = note: see issue #133416 for more information + = help: add `#![feature(asm_experimental_reg)]` 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]: type `f32` cannot be used with this register class in stable - --> $DIR/bad-reg.rs:52:35 + --> $DIR/bad-reg.rs:56:35 | LL | asm!("/* {} */", in(vreg) f); | ^ @@ -189,7 +219,7 @@ LL | asm!("/* {} */", in(vreg) f); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: type `f64` cannot be used with this register class in stable - --> $DIR/bad-reg.rs:57:35 + --> $DIR/bad-reg.rs:61:35 | LL | asm!("/* {} */", in(vreg) d); | ^ @@ -199,7 +229,7 @@ LL | asm!("/* {} */", in(vreg) d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: type `f64` cannot be used with this register class in stable - --> $DIR/bad-reg.rs:60:36 + --> $DIR/bad-reg.rs:64:36 | LL | asm!("/* {} */", out(vreg) d); | ^ @@ -208,8 +238,18 @@ LL | asm!("/* {} */", out(vreg) d); = help: add `#![feature(asm_experimental_reg)]` 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]: type `u128` cannot be used with this register class in stable + --> $DIR/bad-reg.rs:69:35 + | +LL | asm!("/* {} */", in(xreg) q); + | ^ + | + = note: see issue #133416 for more information + = help: add `#![feature(asm_experimental_reg)]` 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]: type `f32` cannot be used with this register class in stable - --> $DIR/bad-reg.rs:65:35 + --> $DIR/bad-reg.rs:72:35 | LL | asm!("/* {} */", in(xreg) f); | ^ @@ -219,7 +259,7 @@ LL | asm!("/* {} */", in(xreg) f); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: type `f64` cannot be used with this register class in stable - --> $DIR/bad-reg.rs:70:35 + --> $DIR/bad-reg.rs:77:35 | LL | asm!("/* {} */", in(xreg) d); | ^ @@ -229,7 +269,7 @@ LL | asm!("/* {} */", in(xreg) d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: type `f64` cannot be used with this register class in stable - --> $DIR/bad-reg.rs:73:36 + --> $DIR/bad-reg.rs:80:36 | LL | asm!("/* {} */", out(xreg) d); | ^ @@ -239,13 +279,13 @@ LL | asm!("/* {} */", out(xreg) d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: register class `freg` requires at least one of the following target features: d, f - --> $DIR/bad-reg.rs:77:18 + --> $DIR/bad-reg.rs:84:18 | LL | asm!("", in("$f0") f, in("$vr0") d); | ^^^^^^^^^^^ error[E0658]: type `f64` cannot be used with this register class in stable - --> $DIR/bad-reg.rs:77:42 + --> $DIR/bad-reg.rs:84:42 | LL | asm!("", in("$f0") f, in("$vr0") d); | ^ @@ -255,13 +295,13 @@ LL | asm!("", in("$f0") f, in("$vr0") d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: register class `freg` requires at least one of the following target features: d, f - --> $DIR/bad-reg.rs:82:18 + --> $DIR/bad-reg.rs:89:18 | LL | asm!("", in("$f0") f, in("$xr0") d); | ^^^^^^^^^^^ error[E0658]: type `f64` cannot be used with this register class in stable - --> $DIR/bad-reg.rs:82:42 + --> $DIR/bad-reg.rs:89:42 | LL | asm!("", in("$f0") f, in("$xr0") d); | ^ @@ -271,7 +311,7 @@ LL | asm!("", in("$f0") f, in("$xr0") d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: type `f32` cannot be used with this register class in stable - --> $DIR/bad-reg.rs:87:29 + --> $DIR/bad-reg.rs:94:29 | LL | asm!("", in("$vr0") f, in("$xr0") d); | ^ @@ -281,7 +321,7 @@ LL | asm!("", in("$vr0") f, in("$xr0") d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: type `f64` cannot be used with this register class in stable - --> $DIR/bad-reg.rs:87:43 + --> $DIR/bad-reg.rs:94:43 | LL | asm!("", in("$vr0") f, in("$xr0") d); | ^ @@ -290,6 +330,6 @@ LL | asm!("", in("$vr0") f, in("$xr0") d); = help: add `#![feature(asm_experimental_reg)]` 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 34 previous errors +error: aborting due to 38 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/asm/loongarch/bad-reg.loongarch64_lp64d.stderr b/tests/ui/asm/loongarch/bad-reg.loongarch64_lp64d.stderr index 97462d6dc5f0b..067dd354f3093 100644 --- a/tests/ui/asm/loongarch/bad-reg.loongarch64_lp64d.stderr +++ b/tests/ui/asm/loongarch/bad-reg.loongarch64_lp64d.stderr @@ -1,41 +1,41 @@ error: invalid register `$r0`: constant zero cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:28:18 + --> $DIR/bad-reg.rs:29:18 | LL | asm!("", out("$r0") _); | ^^^^^^^^^^^^ error: invalid register `$tp`: reserved for TLS - --> $DIR/bad-reg.rs:30:18 + --> $DIR/bad-reg.rs:31:18 | LL | asm!("", out("$tp") _); | ^^^^^^^^^^^^ error: invalid register `$sp`: the stack pointer cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:32:18 + --> $DIR/bad-reg.rs:33:18 | LL | asm!("", out("$sp") _); | ^^^^^^^^^^^^ error: invalid register `$r21`: reserved by the ABI - --> $DIR/bad-reg.rs:34:18 + --> $DIR/bad-reg.rs:35:18 | LL | asm!("", out("$r21") _); | ^^^^^^^^^^^^^ error: invalid register `$fp`: the frame pointer cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:36:18 + --> $DIR/bad-reg.rs:37:18 | LL | asm!("", out("$fp") _); | ^^^^^^^^^^^^ error: invalid register `$r31`: $r31 is used internally by LLVM and cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:38:18 + --> $DIR/bad-reg.rs:39:18 | LL | asm!("", out("$r31") _); | ^^^^^^^^^^^^^ error: register `$vr0` conflicts with register `$f0` - --> $DIR/bad-reg.rs:77:31 + --> $DIR/bad-reg.rs:84:31 | LL | asm!("", in("$f0") f, in("$vr0") d); | ----------- ^^^^^^^^^^^^ register `$vr0` @@ -43,7 +43,7 @@ LL | asm!("", in("$f0") f, in("$vr0") d); | register `$f0` error: register `$xr0` conflicts with register `$f0` - --> $DIR/bad-reg.rs:82:31 + --> $DIR/bad-reg.rs:89:31 | LL | asm!("", in("$f0") f, in("$xr0") d); | ----------- ^^^^^^^^^^^^ register `$xr0` @@ -51,7 +51,7 @@ LL | asm!("", in("$f0") f, in("$xr0") d); | register `$f0` error: register `$xr0` conflicts with register `$vr0` - --> $DIR/bad-reg.rs:87:32 + --> $DIR/bad-reg.rs:94:32 | LL | asm!("", in("$vr0") f, in("$xr0") d); | ------------ ^^^^^^^^^^^^ register `$xr0` diff --git a/tests/ui/asm/loongarch/bad-reg.loongarch64_lp64s.stderr b/tests/ui/asm/loongarch/bad-reg.loongarch64_lp64s.stderr index 1ee1b86989c4d..9ffab83db95cb 100644 --- a/tests/ui/asm/loongarch/bad-reg.loongarch64_lp64s.stderr +++ b/tests/ui/asm/loongarch/bad-reg.loongarch64_lp64s.stderr @@ -1,41 +1,51 @@ error: invalid register `$r0`: constant zero cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:28:18 + --> $DIR/bad-reg.rs:29:18 | LL | asm!("", out("$r0") _); | ^^^^^^^^^^^^ error: invalid register `$tp`: reserved for TLS - --> $DIR/bad-reg.rs:30:18 + --> $DIR/bad-reg.rs:31:18 | LL | asm!("", out("$tp") _); | ^^^^^^^^^^^^ error: invalid register `$sp`: the stack pointer cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:32:18 + --> $DIR/bad-reg.rs:33:18 | LL | asm!("", out("$sp") _); | ^^^^^^^^^^^^ error: invalid register `$r21`: reserved by the ABI - --> $DIR/bad-reg.rs:34:18 + --> $DIR/bad-reg.rs:35:18 | LL | asm!("", out("$r21") _); | ^^^^^^^^^^^^^ error: invalid register `$fp`: the frame pointer cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:36:18 + --> $DIR/bad-reg.rs:37:18 | LL | asm!("", out("$fp") _); | ^^^^^^^^^^^^ error: invalid register `$r31`: $r31 is used internally by LLVM and cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:38:18 + --> $DIR/bad-reg.rs:39:18 | LL | asm!("", out("$r31") _); | ^^^^^^^^^^^^^ error[E0658]: register class `vreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:52:26 + --> $DIR/bad-reg.rs:53:26 + | +LL | asm!("/* {} */", in(vreg) q); + | ^^^^^^^^^^ + | + = note: see issue #133416 for more information + = help: add `#![feature(asm_experimental_reg)]` 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]: register class `vreg` can only be used as a clobber in stable + --> $DIR/bad-reg.rs:56:26 | LL | asm!("/* {} */", in(vreg) f); | ^^^^^^^^^^ @@ -45,7 +55,7 @@ LL | asm!("/* {} */", in(vreg) f); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: register class `vreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:55:26 + --> $DIR/bad-reg.rs:59:26 | LL | asm!("/* {} */", out(vreg) _); | ^^^^^^^^^^^ @@ -55,7 +65,7 @@ LL | asm!("/* {} */", out(vreg) _); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: register class `vreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:57:26 + --> $DIR/bad-reg.rs:61:26 | LL | asm!("/* {} */", in(vreg) d); | ^^^^^^^^^^ @@ -65,7 +75,7 @@ LL | asm!("/* {} */", in(vreg) d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: register class `vreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:60:26 + --> $DIR/bad-reg.rs:64:26 | LL | asm!("/* {} */", out(vreg) d); | ^^^^^^^^^^^ @@ -75,7 +85,17 @@ LL | asm!("/* {} */", out(vreg) d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: register class `xreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:65:26 + --> $DIR/bad-reg.rs:69:26 + | +LL | asm!("/* {} */", in(xreg) q); + | ^^^^^^^^^^ + | + = note: see issue #133416 for more information + = help: add `#![feature(asm_experimental_reg)]` 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]: register class `xreg` can only be used as a clobber in stable + --> $DIR/bad-reg.rs:72:26 | LL | asm!("/* {} */", in(xreg) f); | ^^^^^^^^^^ @@ -85,7 +105,7 @@ LL | asm!("/* {} */", in(xreg) f); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: register class `xreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:68:26 + --> $DIR/bad-reg.rs:75:26 | LL | asm!("/* {} */", out(xreg) _); | ^^^^^^^^^^^ @@ -95,7 +115,7 @@ LL | asm!("/* {} */", out(xreg) _); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: register class `xreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:70:26 + --> $DIR/bad-reg.rs:77:26 | LL | asm!("/* {} */", in(xreg) d); | ^^^^^^^^^^ @@ -105,7 +125,7 @@ LL | asm!("/* {} */", in(xreg) d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: register class `xreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:73:26 + --> $DIR/bad-reg.rs:80:26 | LL | asm!("/* {} */", out(xreg) d); | ^^^^^^^^^^^ @@ -115,7 +135,7 @@ LL | asm!("/* {} */", out(xreg) d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: register class `vreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:77:31 + --> $DIR/bad-reg.rs:84:31 | LL | asm!("", in("$f0") f, in("$vr0") d); | ^^^^^^^^^^^^ @@ -125,7 +145,7 @@ LL | asm!("", in("$f0") f, in("$vr0") d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: register class `xreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:82:31 + --> $DIR/bad-reg.rs:89:31 | LL | asm!("", in("$f0") f, in("$xr0") d); | ^^^^^^^^^^^^ @@ -135,7 +155,7 @@ LL | asm!("", in("$f0") f, in("$xr0") d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: register class `vreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:87:18 + --> $DIR/bad-reg.rs:94:18 | LL | asm!("", in("$vr0") f, in("$xr0") d); | ^^^^^^^^^^^^ @@ -145,7 +165,7 @@ LL | asm!("", in("$vr0") f, in("$xr0") d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: register class `xreg` can only be used as a clobber in stable - --> $DIR/bad-reg.rs:87:32 + --> $DIR/bad-reg.rs:94:32 | LL | asm!("", in("$vr0") f, in("$xr0") d); | ^^^^^^^^^^^^ @@ -155,31 +175,41 @@ LL | asm!("", in("$vr0") f, in("$xr0") d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: register class `freg` requires at least one of the following target features: d, f - --> $DIR/bad-reg.rs:42:26 + --> $DIR/bad-reg.rs:43:26 | LL | asm!("/* {} */", in(freg) f); | ^^^^^^^^^^ error: register class `freg` requires at least one of the following target features: d, f - --> $DIR/bad-reg.rs:44:26 + --> $DIR/bad-reg.rs:45:26 | LL | asm!("/* {} */", out(freg) _); | ^^^^^^^^^^^ error: register class `freg` requires at least one of the following target features: d, f - --> $DIR/bad-reg.rs:46:26 + --> $DIR/bad-reg.rs:47:26 | LL | asm!("/* {} */", in(freg) d); | ^^^^^^^^^^ error: register class `freg` requires at least one of the following target features: d, f - --> $DIR/bad-reg.rs:48:26 + --> $DIR/bad-reg.rs:49:26 | LL | asm!("/* {} */", out(freg) d); | ^^^^^^^^^^^ +error[E0658]: type `u128` cannot be used with this register class in stable + --> $DIR/bad-reg.rs:53:35 + | +LL | asm!("/* {} */", in(vreg) q); + | ^ + | + = note: see issue #133416 for more information + = help: add `#![feature(asm_experimental_reg)]` 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]: type `f32` cannot be used with this register class in stable - --> $DIR/bad-reg.rs:52:35 + --> $DIR/bad-reg.rs:56:35 | LL | asm!("/* {} */", in(vreg) f); | ^ @@ -189,7 +219,7 @@ LL | asm!("/* {} */", in(vreg) f); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: type `f64` cannot be used with this register class in stable - --> $DIR/bad-reg.rs:57:35 + --> $DIR/bad-reg.rs:61:35 | LL | asm!("/* {} */", in(vreg) d); | ^ @@ -199,7 +229,7 @@ LL | asm!("/* {} */", in(vreg) d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: type `f64` cannot be used with this register class in stable - --> $DIR/bad-reg.rs:60:36 + --> $DIR/bad-reg.rs:64:36 | LL | asm!("/* {} */", out(vreg) d); | ^ @@ -208,8 +238,18 @@ LL | asm!("/* {} */", out(vreg) d); = help: add `#![feature(asm_experimental_reg)]` 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]: type `u128` cannot be used with this register class in stable + --> $DIR/bad-reg.rs:69:35 + | +LL | asm!("/* {} */", in(xreg) q); + | ^ + | + = note: see issue #133416 for more information + = help: add `#![feature(asm_experimental_reg)]` 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]: type `f32` cannot be used with this register class in stable - --> $DIR/bad-reg.rs:65:35 + --> $DIR/bad-reg.rs:72:35 | LL | asm!("/* {} */", in(xreg) f); | ^ @@ -219,7 +259,7 @@ LL | asm!("/* {} */", in(xreg) f); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: type `f64` cannot be used with this register class in stable - --> $DIR/bad-reg.rs:70:35 + --> $DIR/bad-reg.rs:77:35 | LL | asm!("/* {} */", in(xreg) d); | ^ @@ -229,7 +269,7 @@ LL | asm!("/* {} */", in(xreg) d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: type `f64` cannot be used with this register class in stable - --> $DIR/bad-reg.rs:73:36 + --> $DIR/bad-reg.rs:80:36 | LL | asm!("/* {} */", out(xreg) d); | ^ @@ -239,13 +279,13 @@ LL | asm!("/* {} */", out(xreg) d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: register class `freg` requires at least one of the following target features: d, f - --> $DIR/bad-reg.rs:77:18 + --> $DIR/bad-reg.rs:84:18 | LL | asm!("", in("$f0") f, in("$vr0") d); | ^^^^^^^^^^^ error[E0658]: type `f64` cannot be used with this register class in stable - --> $DIR/bad-reg.rs:77:42 + --> $DIR/bad-reg.rs:84:42 | LL | asm!("", in("$f0") f, in("$vr0") d); | ^ @@ -255,13 +295,13 @@ LL | asm!("", in("$f0") f, in("$vr0") d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: register class `freg` requires at least one of the following target features: d, f - --> $DIR/bad-reg.rs:82:18 + --> $DIR/bad-reg.rs:89:18 | LL | asm!("", in("$f0") f, in("$xr0") d); | ^^^^^^^^^^^ error[E0658]: type `f64` cannot be used with this register class in stable - --> $DIR/bad-reg.rs:82:42 + --> $DIR/bad-reg.rs:89:42 | LL | asm!("", in("$f0") f, in("$xr0") d); | ^ @@ -271,7 +311,7 @@ LL | asm!("", in("$f0") f, in("$xr0") d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: type `f32` cannot be used with this register class in stable - --> $DIR/bad-reg.rs:87:29 + --> $DIR/bad-reg.rs:94:29 | LL | asm!("", in("$vr0") f, in("$xr0") d); | ^ @@ -281,7 +321,7 @@ LL | asm!("", in("$vr0") f, in("$xr0") d); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: type `f64` cannot be used with this register class in stable - --> $DIR/bad-reg.rs:87:43 + --> $DIR/bad-reg.rs:94:43 | LL | asm!("", in("$vr0") f, in("$xr0") d); | ^ @@ -290,6 +330,6 @@ LL | asm!("", in("$vr0") f, in("$xr0") d); = help: add `#![feature(asm_experimental_reg)]` 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 34 previous errors +error: aborting due to 38 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/asm/loongarch/bad-reg.rs b/tests/ui/asm/loongarch/bad-reg.rs index 6bda28eb10fde..ac2eeb7d78a70 100644 --- a/tests/ui/asm/loongarch/bad-reg.rs +++ b/tests/ui/asm/loongarch/bad-reg.rs @@ -8,6 +8,7 @@ //@[loongarch64_lp64d] needs-llvm-components: loongarch //@[loongarch64_lp64s] compile-flags: --target loongarch64-unknown-none-softfloat //@[loongarch64_lp64s] needs-llvm-components: loongarch +//@ min-llvm-version: 23 //@ ignore-backends: gcc #![cfg_attr(loongarch64_lp64d, feature(asm_experimental_reg))] @@ -20,7 +21,7 @@ extern crate minicore; use minicore::*; fn f() { - let mut x = 0; + let mut q = 0_u128; let mut f = 0.0_f32; let mut d = 0.0_f64; unsafe { @@ -49,6 +50,9 @@ fn f() { //[loongarch32_ilp32s,loongarch64_lp64s]~^ ERROR register class `freg` requires at least one of the following target features: d, f asm!("", out("$vr0") _); // ok + asm!("/* {} */", in(vreg) q); + //[loongarch32_ilp32s,loongarch32_ilp32d,loongarch64_lp64s]~^ ERROR register class `vreg` can only be used as a clobber in stable + //[loongarch32_ilp32s,loongarch32_ilp32d,loongarch64_lp64s]~| ERROR type `u128` cannot be used with this register class in stable asm!("/* {} */", in(vreg) f); //[loongarch32_ilp32s,loongarch32_ilp32d,loongarch64_lp64s]~^ ERROR register class `vreg` can only be used as a clobber in stable //[loongarch32_ilp32s,loongarch32_ilp32d,loongarch64_lp64s]~| ERROR type `f32` cannot be used with this register class in stable @@ -62,6 +66,9 @@ fn f() { //[loongarch32_ilp32s,loongarch32_ilp32d,loongarch64_lp64s]~| ERROR type `f64` cannot be used with this register class in stable asm!("", out("$xr0") _); // ok + asm!("/* {} */", in(xreg) q); + //[loongarch32_ilp32s,loongarch32_ilp32d,loongarch64_lp64s]~^ ERROR register class `xreg` can only be used as a clobber in stable + //[loongarch32_ilp32s,loongarch32_ilp32d,loongarch64_lp64s]~| ERROR type `u128` cannot be used with this register class in stable asm!("/* {} */", in(xreg) f); //[loongarch32_ilp32s,loongarch32_ilp32d,loongarch64_lp64s]~^ ERROR register class `xreg` can only be used as a clobber in stable //[loongarch32_ilp32s,loongarch32_ilp32d,loongarch64_lp64s]~| ERROR type `f32` cannot be used with this register class in stable diff --git a/tests/ui/attributes/attr-on-mac-call.rs b/tests/ui/attributes/attr-on-mac-call.rs index 7b30ec810ff81..618e583d0af5e 100644 --- a/tests/ui/attributes/attr-on-mac-call.rs +++ b/tests/ui/attributes/attr-on-mac-call.rs @@ -110,4 +110,15 @@ fn main() { #[register_tool(xyz)] //~^ ERROR crate-level attribute should be an inner attribute unreachable!(); + #[deprecated = concat!("woah", "dude")] + //~^ ERROR attribute value must be a literal + #[doc = concat!("woah", "dude")] + unreachable!(); + #[doc = { + let a = 1; + let b = 1; + let sum = a + b; + assert_eq!(sum, 2); + }] + unreachable!(); } diff --git a/tests/ui/attributes/attr-on-mac-call.stderr b/tests/ui/attributes/attr-on-mac-call.stderr index 3454998af2922..aa158bee22768 100644 --- a/tests/ui/attributes/attr-on-mac-call.stderr +++ b/tests/ui/attributes/attr-on-mac-call.stderr @@ -38,6 +38,12 @@ note: this attribute does not have an `!`, which means it is applied to this mac LL | unreachable!(); | ^^^^^^^^^^^^^^ +error: attribute value must be a literal + --> $DIR/attr-on-mac-call.rs:113:20 + | +LL | #[deprecated = concat!("woah", "dude")] + | ^^^^^^^^^^^^^^^^^^^^^^^ + warning: the `export_name` attribute cannot be used on macro calls --> $DIR/attr-on-mac-call.rs:8:7 | @@ -341,6 +347,6 @@ LL | #[repr(Rust)] = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute -error: aborting due to 4 previous errors; 30 warnings emitted +error: aborting due to 5 previous errors; 30 warnings emitted For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/const-generics/generic_const_parameter_types/inherent-type-const.rs b/tests/ui/const-generics/generic_const_parameter_types/inherent-type-const.rs new file mode 100644 index 0000000000000..86eab5ec70eb2 --- /dev/null +++ b/tests/ui/const-generics/generic_const_parameter_types/inherent-type-const.rs @@ -0,0 +1,22 @@ +//@ check-pass +#![feature( + min_generic_const_args, + generic_const_parameter_types, + inherent_associated_types, + min_adt_const_params, + const_param_ty_trait +)] + +struct ThreeTypes(T1, T2, T3); + +impl ThreeTypes { + type const INHERENT: [T3; 0] = []; +} + +struct Struct; + +fn f() -> Struct<{ core::direct_const_arg!(ThreeTypes::::INHERENT) }> { + Struct +} + +fn main() {} diff --git a/tests/ui/contracts/empty-ensures.rs b/tests/ui/contracts/empty-ensures.rs index 79e57df6eb984..242e903b7cc96 100644 --- a/tests/ui/contracts/empty-ensures.rs +++ b/tests/ui/contracts/empty-ensures.rs @@ -6,7 +6,7 @@ extern crate core; use core::contracts::ensures; #[ensures()] -//~^ ERROR expected an `Fn(&_)` closure, found `()` [E0277] +//~^ ERROR `ensures` attribute requires an argument fn foo(x: u32) -> u32 { x * 2 } diff --git a/tests/ui/contracts/empty-ensures.stderr b/tests/ui/contracts/empty-ensures.stderr index b87f709eeb7a4..369ba431b62ce 100644 --- a/tests/ui/contracts/empty-ensures.stderr +++ b/tests/ui/contracts/empty-ensures.stderr @@ -1,16 +1,8 @@ -error[E0277]: expected an `Fn(&_)` closure, found `()` +error: `ensures` attribute requires an argument, e.g., `#[ensures(|result: &T| condition)]` --> $DIR/empty-ensures.rs:8:1 | LL | #[ensures()] | ^^^^^^^^^^^^ - | | - | expected an `Fn(&_)` closure, found `()` - | required by a bound introduced by this call - | - = help: the trait `for<'a> Fn(&'a _)` is not implemented for `()` -note: required by a bound in `build_check_ensures` - --> $SRC_DIR/core/src/contracts.rs:LL:COL error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/contracts/empty-requires.rs b/tests/ui/contracts/empty-requires.rs index dedcc10d52cb0..eae86607acf31 100644 --- a/tests/ui/contracts/empty-requires.rs +++ b/tests/ui/contracts/empty-requires.rs @@ -1,4 +1,3 @@ -//@ dont-require-annotations: NOTE //@ compile-flags: -Zcontract-checks=yes #![expect(incomplete_features)] #![feature(contracts)] @@ -7,8 +6,7 @@ extern crate core; use core::contracts::requires; #[requires()] -//~^ ERROR mismatched types [E0308] -//~| NOTE expected `bool`, found `()` +//~^ ERROR `requires` attribute requires an argument fn foo(x: u32) -> u32 { x * 2 } diff --git a/tests/ui/contracts/empty-requires.stderr b/tests/ui/contracts/empty-requires.stderr index 702b8a23c55e3..c8fa644702259 100644 --- a/tests/ui/contracts/empty-requires.stderr +++ b/tests/ui/contracts/empty-requires.stderr @@ -1,9 +1,8 @@ -error[E0308]: mismatched types - --> $DIR/empty-requires.rs:9:1 +error: `requires` attribute requires an argument, e.g., `#[requires(condition)]` + --> $DIR/empty-requires.rs:8:1 | LL | #[requires()] - | ^^^^^^^^^^^^^ expected `bool`, found `()` + | ^^^^^^^^^^^^^ error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/feature-gates/doc-rust-logo.rs b/tests/ui/feature-gates/doc-rust-logo.rs index e6a58512944bb..08857cc778f5b 100644 --- a/tests/ui/feature-gates/doc-rust-logo.rs +++ b/tests/ui/feature-gates/doc-rust-logo.rs @@ -1,5 +1,7 @@ #![doc(rust_logo)] -//~^ ERROR the `#[doc(rust_logo)]` attribute is used for Rust branding +//~^ ERROR this subset of the `doc` attribute is meant for internal use only //! This is not an official rust crate +#[doc(rust_logo)] +//~^ WARN this attribute can only be applied at the crate level fn main() {} diff --git a/tests/ui/feature-gates/doc-rust-logo.stderr b/tests/ui/feature-gates/doc-rust-logo.stderr index 5c64652667ed8..f31837be284d1 100644 --- a/tests/ui/feature-gates/doc-rust-logo.stderr +++ b/tests/ui/feature-gates/doc-rust-logo.stderr @@ -1,4 +1,4 @@ -error[E0658]: the `#[doc(rust_logo)]` attribute is used for Rust branding +error[E0658]: this subset of the `doc` attribute is meant for internal use only --> $DIR/doc-rust-logo.rs:1:8 | LL | #![doc(rust_logo)] @@ -7,7 +7,17 @@ LL | #![doc(rust_logo)] = note: see issue #90418 for more information = help: add `#![feature(rustdoc_internals)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = note: the `#[doc(rust_logo)]` attribute is used for Rust branding -error: aborting due to 1 previous error +warning: this attribute can only be applied at the crate level + --> $DIR/doc-rust-logo.rs:5:7 + | +LL | #[doc(rust_logo)] + | ^^^^^^^^^ + | + = note: read for more information + = note: `#[warn(invalid_doc_attributes)]` on by default + +error: aborting due to 1 previous error; 1 warning emitted For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-doc_cfg.stderr b/tests/ui/feature-gates/feature-gate-doc_cfg.stderr index 5315aaeeb3edb..cb2898960472a 100644 --- a/tests/ui/feature-gates/feature-gate-doc_cfg.stderr +++ b/tests/ui/feature-gates/feature-gate-doc_cfg.stderr @@ -1,8 +1,8 @@ -error[E0658]: `#[doc(cfg)]` is experimental - --> $DIR/feature-gate-doc_cfg.rs:1:1 +error[E0658]: the `doc(cfg)` and `doc(auto_cfg)` attributes are experimental + --> $DIR/feature-gate-doc_cfg.rs:1:7 | LL | #[doc(cfg(unix))] - | ^^^^^^^^^^^^^^^^^ + | ^^^ | = note: see issue #43781 for more information = help: add `#![feature(doc_cfg)]` to the crate attributes to enable diff --git a/tests/ui/feature-gates/feature-gate-doc_masked.rs b/tests/ui/feature-gates/feature-gate-doc_masked.rs index bde3af6b594c2..a2776cb696c49 100644 --- a/tests/ui/feature-gates/feature-gate-doc_masked.rs +++ b/tests/ui/feature-gates/feature-gate-doc_masked.rs @@ -1,4 +1,8 @@ -#[doc(masked)] //~ ERROR: `#[doc(masked)]` is experimental +#[doc(masked)] //~ ERROR the `doc(masked)` attribute is experimental extern crate std as realstd; -fn main() {} +fn main() { + #[doc(masked)] + //~^ ERROR the `doc(masked)` attribute is experimental [E0658] + println!(); +} diff --git a/tests/ui/feature-gates/feature-gate-doc_masked.stderr b/tests/ui/feature-gates/feature-gate-doc_masked.stderr index 10607a19757cb..8f1b03e50325c 100644 --- a/tests/ui/feature-gates/feature-gate-doc_masked.stderr +++ b/tests/ui/feature-gates/feature-gate-doc_masked.stderr @@ -1,13 +1,23 @@ -error[E0658]: `#[doc(masked)]` is experimental - --> $DIR/feature-gate-doc_masked.rs:1:1 +error[E0658]: the `doc(masked)` attribute is experimental + --> $DIR/feature-gate-doc_masked.rs:5:11 + | +LL | #[doc(masked)] + | ^^^^^^ + | + = note: see issue #44027 for more information + = help: add `#![feature(doc_masked)]` 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]: the `doc(masked)` attribute is experimental + --> $DIR/feature-gate-doc_masked.rs:1:7 | LL | #[doc(masked)] - | ^^^^^^^^^^^^^^ + | ^^^^^^ | = note: see issue #44027 for more information = help: add `#![feature(doc_masked)]` 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 1 previous error +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-doc_notable_trait.rs b/tests/ui/feature-gates/feature-gate-doc_notable_trait.rs index 7f3392eadadb3..1bc1028b9e0ef 100644 --- a/tests/ui/feature-gates/feature-gate-doc_notable_trait.rs +++ b/tests/ui/feature-gates/feature-gate-doc_notable_trait.rs @@ -1,4 +1,8 @@ -#[doc(notable_trait)] //~ ERROR: `#[doc(notable_trait)]` is experimental +#[doc(notable_trait)] //~ ERROR the `doc(notable_trait)` attribute is experimental trait SomeTrait {} -fn main() {} +fn main() { + #[doc(notable_trait)] + //~^ ERROR the `doc(notable_trait)` attribute is experimental [E0658] + println!(); +} diff --git a/tests/ui/feature-gates/feature-gate-doc_notable_trait.stderr b/tests/ui/feature-gates/feature-gate-doc_notable_trait.stderr index 1b40b9ac18a8f..632c91b929185 100644 --- a/tests/ui/feature-gates/feature-gate-doc_notable_trait.stderr +++ b/tests/ui/feature-gates/feature-gate-doc_notable_trait.stderr @@ -1,13 +1,23 @@ -error[E0658]: `#[doc(notable_trait)]` is experimental - --> $DIR/feature-gate-doc_notable_trait.rs:1:1 +error[E0658]: the `doc(notable_trait)` attribute is experimental + --> $DIR/feature-gate-doc_notable_trait.rs:5:11 + | +LL | #[doc(notable_trait)] + | ^^^^^^^^^^^^^ + | + = note: see issue #45040 for more information + = help: add `#![feature(doc_notable_trait)]` 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]: the `doc(notable_trait)` attribute is experimental + --> $DIR/feature-gate-doc_notable_trait.rs:1:7 | LL | #[doc(notable_trait)] - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^ | = note: see issue #45040 for more information = help: add `#![feature(doc_notable_trait)]` 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 1 previous error +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-rustdoc_internals.rs b/tests/ui/feature-gates/feature-gate-rustdoc_internals.rs index 7aa6dcbd5daac..e39221a204ca8 100644 --- a/tests/ui/feature-gates/feature-gate-rustdoc_internals.rs +++ b/tests/ui/feature-gates/feature-gate-rustdoc_internals.rs @@ -1,17 +1,29 @@ -#[doc(keyword = "match")] //~ ERROR: `#[doc(keyword)]` is meant for internal use only +#[doc(keyword = "match")] //~ ERROR: this subset of the `doc` attribute is meant for internal use only /// wonderful const _: () = (); -#[doc(attribute = "repr")] //~ ERROR: `#[doc(attribute)]` is meant for internal use only +#[doc(attribute = "repr")] //~ ERROR this subset of the `doc` attribute is meant for internal use only /// wonderful const _: () = (); trait Mine {} -#[doc(fake_variadic)] //~ ERROR: `#[doc(fake_variadic)]` is meant for internal use only +#[doc(fake_variadic)] //~ ERROR this subset of the `doc` attribute is meant for internal use only impl Mine for (T,) {} -#[doc(search_unbox)] //~ ERROR: `#[doc(search_unbox)]` is meant for internal use only +#[doc(search_unbox)] //~ ERROR this subset of the `doc` attribute is meant for internal use only struct Wrap (T); -fn main() {} +fn main() { + #[doc(search_unbox)] + //~^ ERROR this subset of the `doc` attribute is meant for internal use only [E0658] + println!(); + + #[doc(fake_variadic)] + //~^ ERROR this subset of the `doc` attribute is meant for internal use only [E0658] + println!(); + + #[doc(attribute = "repr")] + //~^ ERROR this subset of the `doc` attribute is meant for internal use only [E0658] + println!(); +} diff --git a/tests/ui/feature-gates/feature-gate-rustdoc_internals.stderr b/tests/ui/feature-gates/feature-gate-rustdoc_internals.stderr index 5a6d4d3b45e0f..ab542eb85bacf 100644 --- a/tests/ui/feature-gates/feature-gate-rustdoc_internals.stderr +++ b/tests/ui/feature-gates/feature-gate-rustdoc_internals.stderr @@ -1,43 +1,73 @@ -error[E0658]: `#[doc(keyword)]` is meant for internal use only - --> $DIR/feature-gate-rustdoc_internals.rs:1:1 +error[E0658]: this subset of the `doc` attribute is meant for internal use only + --> $DIR/feature-gate-rustdoc_internals.rs:18:11 + | +LL | #[doc(search_unbox)] + | ^^^^^^^^^^^^ + | + = note: see issue #90418 for more information + = help: add `#![feature(rustdoc_internals)]` 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]: this subset of the `doc` attribute is meant for internal use only + --> $DIR/feature-gate-rustdoc_internals.rs:22:11 + | +LL | #[doc(fake_variadic)] + | ^^^^^^^^^^^^^ + | + = note: see issue #90418 for more information + = help: add `#![feature(rustdoc_internals)]` 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]: this subset of the `doc` attribute is meant for internal use only + --> $DIR/feature-gate-rustdoc_internals.rs:26:11 + | +LL | #[doc(attribute = "repr")] + | ^^^^^^^^^ + | + = note: see issue #90418 for more information + = help: add `#![feature(rustdoc_internals)]` 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]: this subset of the `doc` attribute is meant for internal use only + --> $DIR/feature-gate-rustdoc_internals.rs:1:7 | LL | #[doc(keyword = "match")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^ | = note: see issue #90418 for more information = help: add `#![feature(rustdoc_internals)]` 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]: `#[doc(attribute)]` is meant for internal use only - --> $DIR/feature-gate-rustdoc_internals.rs:5:1 +error[E0658]: this subset of the `doc` attribute is meant for internal use only + --> $DIR/feature-gate-rustdoc_internals.rs:5:7 | LL | #[doc(attribute = "repr")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = note: see issue #90418 for more information = help: add `#![feature(rustdoc_internals)]` 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]: `#[doc(fake_variadic)]` is meant for internal use only - --> $DIR/feature-gate-rustdoc_internals.rs:11:1 +error[E0658]: this subset of the `doc` attribute is meant for internal use only + --> $DIR/feature-gate-rustdoc_internals.rs:11:7 | LL | #[doc(fake_variadic)] - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^ | = note: see issue #90418 for more information = help: add `#![feature(rustdoc_internals)]` 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]: `#[doc(search_unbox)]` is meant for internal use only - --> $DIR/feature-gate-rustdoc_internals.rs:14:1 +error[E0658]: this subset of the `doc` attribute is meant for internal use only + --> $DIR/feature-gate-rustdoc_internals.rs:14:7 | LL | #[doc(search_unbox)] - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ | = note: see issue #90418 for more information = help: add `#![feature(rustdoc_internals)]` 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 4 previous errors +error: aborting due to 7 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/lint/single-use-lifetimes-issue-146834.rs b/tests/ui/lint/single-use-lifetimes-issue-146834.rs new file mode 100644 index 0000000000000..8c03e40fa8070 --- /dev/null +++ b/tests/ui/lint/single-use-lifetimes-issue-146834.rs @@ -0,0 +1,18 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/146834. + +//@ compile-flags: -Wsingle-use-lifetimes +//@ edition: 2024 + +#![expect(incomplete_features)] +#![feature(contracts)] + +#[core::contracts::ensures] +//~^ ERROR `ensures` attribute requires an argument +fn f<'a, 'b>(a: &'a i32, b: &'b i32) -> (&i32, &i32) { + //~^ ERROR missing lifetime specifiers + //~| WARN lifetime parameter `'a` only used once + //~| WARN lifetime parameter `'b` only used once + loop {} +} + +fn main() {} diff --git a/tests/ui/lint/single-use-lifetimes-issue-146834.stderr b/tests/ui/lint/single-use-lifetimes-issue-146834.stderr new file mode 100644 index 0000000000000..d7b84680fd081 --- /dev/null +++ b/tests/ui/lint/single-use-lifetimes-issue-146834.stderr @@ -0,0 +1,55 @@ +error: `ensures` attribute requires an argument, e.g., `#[ensures(|result: &T| condition)]` + --> $DIR/single-use-lifetimes-issue-146834.rs:9:1 + | +LL | #[core::contracts::ensures] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0106]: missing lifetime specifiers + --> $DIR/single-use-lifetimes-issue-146834.rs:11:42 + | +LL | fn f<'a, 'b>(a: &'a i32, b: &'b i32) -> (&i32, &i32) { + | ------- ------- ^ ^ expected named lifetime parameter + | | + | expected named lifetime parameter + | + = help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments +note: these named lifetimes are available to use + --> $DIR/single-use-lifetimes-issue-146834.rs:11:6 + | +LL | fn f<'a, 'b>(a: &'a i32, b: &'b i32) -> (&i32, &i32) { + | ^^ ^^ +help: consider using one of the available lifetimes here + | +LL | fn f<'a, 'b>(a: &'a i32, b: &'b i32) -> (&'lifetime i32, &'lifetime i32) { + | +++++++++ +++++++++ + +warning: lifetime parameter `'a` only used once + --> $DIR/single-use-lifetimes-issue-146834.rs:11:6 + | +LL | fn f<'a, 'b>(a: &'a i32, b: &'b i32) -> (&i32, &i32) { + | ^^ -- ...is used only here + | | + | this lifetime... + | + = note: requested on the command line with `-W single-use-lifetimes` +help: elide the single-use lifetime + | +LL - fn f<'a, 'b>(a: &'a i32, b: &'b i32) -> (&i32, &i32) { +LL + fn f<'b>(a: &i32, b: &'b i32) -> (&i32, &i32) { + | + +warning: lifetime parameter `'b` only used once + --> $DIR/single-use-lifetimes-issue-146834.rs:11:10 + | +LL | fn f<'a, 'b>(a: &'a i32, b: &'b i32) -> (&i32, &i32) { + | ^^ this lifetime... -- ...is used only here + | +help: elide the single-use lifetime + | +LL - fn f<'a, 'b>(a: &'a i32, b: &'b i32) -> (&i32, &i32) { +LL + fn f<'a>(a: &'a i32, b: &i32) -> (&i32, &i32) { + | + +error: aborting due to 2 previous errors; 2 warnings emitted + +For more information about this error, try `rustc --explain E0106`. 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 0a95b79988894..62c4fe82348cc 100644 --- a/tests/ui/lint/unused/unused-doc-comments-for-macros.rs +++ b/tests/ui/lint/unused/unused-doc-comments-for-macros.rs @@ -16,11 +16,12 @@ fn main() { foo!(); // Even invalid doc attributes should emit the warning. - #[doc = { //~ ERROR: unused doc comment + #[doc = { let a = 1; let b = 1; let sum = a + b; assert_eq!(sum, 2); }] + //~^^^^^^ ERROR: unused doc comment foo!(); } diff --git a/tests/ui/macros/ice-in-tokenstream-for-contracts-issue-140683.rs b/tests/ui/macros/ice-in-tokenstream-for-contracts-issue-140683.rs index 2b1bacf7e0c31..db85d496991f7 100644 --- a/tests/ui/macros/ice-in-tokenstream-for-contracts-issue-140683.rs +++ b/tests/ui/macros/ice-in-tokenstream-for-contracts-issue-140683.rs @@ -4,7 +4,7 @@ struct T; impl T { - #[core::contracts::ensures] //~ ERROR expected an `Fn(&_)` closure, found `()` + #[core::contracts::ensures] //~ ERROR `ensures` attribute requires an argument fn b() {(loop)} //~^ ERROR expected `{`, found `)` //~| ERROR expected `{`, found `)` diff --git a/tests/ui/macros/ice-in-tokenstream-for-contracts-issue-140683.stderr b/tests/ui/macros/ice-in-tokenstream-for-contracts-issue-140683.stderr index 56dbdae14189b..ab6459bdc919a 100644 --- a/tests/ui/macros/ice-in-tokenstream-for-contracts-issue-140683.stderr +++ b/tests/ui/macros/ice-in-tokenstream-for-contracts-issue-140683.stderr @@ -6,6 +6,12 @@ LL | fn b() {(loop)} | | | while parsing this `loop` expression +error: `ensures` attribute requires an argument, e.g., `#[ensures(|result: &T| condition)]` + --> $DIR/ice-in-tokenstream-for-contracts-issue-140683.rs:7:5 + | +LL | #[core::contracts::ensures] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error: expected `{`, found `)` --> $DIR/ice-in-tokenstream-for-contracts-issue-140683.rs:8:18 | @@ -16,19 +22,5 @@ LL | fn b() {(loop)} | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0277]: expected an `Fn(&_)` closure, found `()` - --> $DIR/ice-in-tokenstream-for-contracts-issue-140683.rs:7:5 - | -LL | #[core::contracts::ensures] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | expected an `Fn(&_)` closure, found `()` - | required by a bound introduced by this call - | - = help: the trait `for<'a> Fn(&'a _)` is not implemented for `()` -note: required by a bound in `build_check_ensures` - --> $SRC_DIR/core/src/contracts.rs:LL:COL - error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0277`.