diff options
189 files changed, 1405 insertions, 835 deletions
diff --git a/compiler/rustc_attr/src/builtin.rs b/compiler/rustc_attr/src/builtin.rs index 762ebc47ca9..28d73fbe9f3 100644 --- a/compiler/rustc_attr/src/builtin.rs +++ b/compiler/rustc_attr/src/builtin.rs @@ -80,6 +80,10 @@ impl Stability { pub fn is_stable(&self) -> bool { self.level.is_stable() } + + pub fn stable_since(&self) -> Option<StableSince> { + self.level.stable_since() + } } /// Represents the `#[rustc_const_unstable]` and `#[rustc_const_stable]` attributes. @@ -170,6 +174,12 @@ impl StabilityLevel { pub fn is_stable(&self) -> bool { matches!(self, StabilityLevel::Stable { .. }) } + pub fn stable_since(&self) -> Option<StableSince> { + match *self { + StabilityLevel::Stable { since, .. } => Some(since), + StabilityLevel::Unstable { .. } => None, + } + } } #[derive(Encodable, Decodable, PartialEq, Copy, Clone, Debug, Eq, Hash)] diff --git a/compiler/rustc_builtin_macros/src/cfg.rs b/compiler/rustc_builtin_macros/src/cfg.rs index de198115fa0..cf1d5c68ead 100644 --- a/compiler/rustc_builtin_macros/src/cfg.rs +++ b/compiler/rustc_builtin_macros/src/cfg.rs @@ -43,7 +43,7 @@ fn parse_cfg<'a>(cx: &ExtCtxt<'a>, span: Span, tts: TokenStream) -> PResult<'a, return Err(cx.dcx().create_err(errors::RequiresCfgPattern { span })); } - let cfg = p.parse_meta_item(AllowLeadingUnsafe::Yes)?; + let cfg = p.parse_meta_item(AllowLeadingUnsafe::No)?; let _ = p.eat(&token::Comma); diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index 201cfbb1918..bd847cd0068 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -264,6 +264,10 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFea ("riscv32" | "riscv64", "unaligned-scalar-mem") if get_version().0 == 18 => { Some(LLVMFeature::new("fast-unaligned-access")) } + // Filter out features that are not supported by the current LLVM version + ("riscv32" | "riscv64", "zaamo") if get_version().0 < 19 => None, + ("riscv32" | "riscv64", "zabha") if get_version().0 < 19 => None, + ("riscv32" | "riscv64", "zalrsc") if get_version().0 < 19 => None, // Enable the evex512 target feature if an avx512 target feature is enabled. ("x86", s) if s.starts_with("avx512") => { Some(LLVMFeature::with_dependency(s, TargetFeatureFoldStrength::EnableOnly("evex512"))) diff --git a/compiler/rustc_expand/src/mbe/macro_check.rs b/compiler/rustc_expand/src/mbe/macro_check.rs index b1d898b6949..1498b9cbd5d 100644 --- a/compiler/rustc_expand/src/mbe/macro_check.rs +++ b/compiler/rustc_expand/src/mbe/macro_check.rs @@ -119,7 +119,7 @@ use rustc_span::symbol::{MacroRulesNormalizedIdent, kw}; use rustc_span::{ErrorGuaranteed, Span}; use smallvec::SmallVec; -use super::quoted::VALID_FRAGMENT_NAMES_MSG_2021; +use super::quoted::VALID_FRAGMENT_NAMES_MSG; use crate::errors; use crate::mbe::{KleeneToken, TokenTree}; @@ -274,7 +274,7 @@ fn check_binders( psess.dcx().emit_err(errors::MissingFragmentSpecifier { span, add_span: span.shrink_to_hi(), - valid: VALID_FRAGMENT_NAMES_MSG_2021, + valid: VALID_FRAGMENT_NAMES_MSG, }); } else { psess.buffer_lint( diff --git a/compiler/rustc_expand/src/mbe/quoted.rs b/compiler/rustc_expand/src/mbe/quoted.rs index f0a6c841f31..2edd289625e 100644 --- a/compiler/rustc_expand/src/mbe/quoted.rs +++ b/compiler/rustc_expand/src/mbe/quoted.rs @@ -1,4 +1,3 @@ -use rustc_ast::token::NtExprKind::*; use rustc_ast::token::{self, Delimiter, IdentIsRaw, NonterminalKind, Token}; use rustc_ast::{NodeId, tokenstream}; use rustc_ast_pretty::pprust; @@ -13,12 +12,9 @@ use crate::errors; use crate::mbe::macro_parser::count_metavar_decls; use crate::mbe::{Delimited, KleeneOp, KleeneToken, MetaVarExpr, SequenceRepetition, TokenTree}; -const VALID_FRAGMENT_NAMES_MSG: &str = "valid fragment specifiers are \ - `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, \ - `item` and `vis`"; -pub(crate) const VALID_FRAGMENT_NAMES_MSG_2021: &str = "valid fragment specifiers are \ - `ident`, `block`, `stmt`, `expr`, `expr_2021`, `pat`, `ty`, `lifetime`, `literal`, `path`, \ - `meta`, `tt`, `item` and `vis`"; +pub(crate) const VALID_FRAGMENT_NAMES_MSG: &str = "valid fragment specifiers are \ + `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, \ + `meta`, `tt`, `item` and `vis`, along with `expr_2021` and `pat_param` for edition compatibility"; /// Takes a `tokenstream::TokenStream` and returns a `Vec<self::TokenTree>`. Specifically, this /// takes a generic `TokenStream`, such as is used in the rest of the compiler, and returns a @@ -92,39 +88,13 @@ pub(super) fn parse( }; let kind = NonterminalKind::from_symbol(fragment.name, edition) .unwrap_or_else(|| { - let help = match fragment.name { - sym::expr_2021 => { - format!( - "fragment specifier `expr_2021` \ - requires Rust 2021 or later\n\ - {VALID_FRAGMENT_NAMES_MSG}" - ) - } - _ if edition().at_least_rust_2021() - && features.expr_fragment_specifier_2024 => - { - VALID_FRAGMENT_NAMES_MSG_2021.into() - } - _ => VALID_FRAGMENT_NAMES_MSG.into(), - }; sess.dcx().emit_err(errors::InvalidFragmentSpecifier { span, fragment, - help, + help: VALID_FRAGMENT_NAMES_MSG.into(), }); NonterminalKind::Ident }); - if kind == NonterminalKind::Expr(Expr2021 { inferred: false }) - && !features.expr_fragment_specifier_2024 - { - rustc_session::parse::feature_err( - sess, - sym::expr_fragment_specifier_2024, - span, - "fragment specifier `expr_2021` is unstable", - ) - .emit(); - } result.push(TokenTree::MetaVarDecl(span, ident, Some(kind))); continue; } diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs index 5ff002dd7d2..a850eb95620 100644 --- a/compiler/rustc_feature/src/accepted.rs +++ b/compiler/rustc_feature/src/accepted.rs @@ -189,6 +189,8 @@ declare_features! ( (accepted, exhaustive_integer_patterns, "1.33.0", Some(50907)), /// Allows explicit generic arguments specification with `impl Trait` present. (accepted, explicit_generic_args_with_impl_trait, "1.63.0", Some(83701)), + /// Uses 2024 rules for matching `expr` fragments in macros. Also enables `expr_2021` fragment. + (accepted, expr_fragment_specifier_2024, "CURRENT_RUSTC_VERSION", Some(123742)), /// Allows arbitrary expressions in key-value attributes at parse time. (accepted, extended_key_value_attributes, "1.54.0", Some(78835)), /// Allows resolving absolute paths as paths from other crates. diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 1ffd35dbf91..c5530097e96 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -450,8 +450,6 @@ declare_features! ( (unstable, exhaustive_patterns, "1.13.0", Some(51085)), /// Allows explicit tail calls via `become` expression. (incomplete, explicit_tail_calls, "1.72.0", Some(112788)), - /// Uses 2024 rules for matching `expr` fragments in macros. Also enables `expr_2021` fragment. - (incomplete, expr_fragment_specifier_2024, "1.80.0", Some(123742)), /// Allows using `efiapi`, `sysv64` and `win64` as calling convention /// for functions with varargs. (unstable, extended_varargs_abi_support, "1.65.0", Some(100189)), diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index a71e14ce463..70b0b3f5788 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -961,13 +961,20 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) -> Result<(), hir_ty.span, "using raw pointers as const generic parameters is forbidden", ), - _ => tcx.dcx().struct_span_err( - hir_ty.span, - format!("`{}` is forbidden as the type of a const generic parameter", ty), - ), + _ => { + // Avoid showing "{type error}" to users. See #118179. + ty.error_reported()?; + + tcx.dcx().struct_span_err( + hir_ty.span, + format!( + "`{ty}` is forbidden as the type of a const generic parameter", + ), + ) + } }; - diag.note("the only supported types are integers, `bool` and `char`"); + diag.note("the only supported types are integers, `bool`, and `char`"); let cause = ObligationCause::misc(hir_ty.span, param.def_id); let adt_const_params_feature_string = diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index 3b8077bb3fc..bd38b3c109a 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -174,7 +174,7 @@ pub(crate) fn parse_check_cfg(dcx: DiagCtxtHandle<'_>, specs: Vec<String>) -> Ch } }; - let meta_item = match parser.parse_meta_item(AllowLeadingUnsafe::Yes) { + let meta_item = match parser.parse_meta_item(AllowLeadingUnsafe::No) { Ok(meta_item) if parser.token == token::Eof => meta_item, Ok(..) => expected_error(), Err(err) => { diff --git a/compiler/rustc_lint/src/if_let_rescope.rs b/compiler/rustc_lint/src/if_let_rescope.rs index c6218fe1e74..cdd0e80c458 100644 --- a/compiler/rustc_lint/src/if_let_rescope.rs +++ b/compiler/rustc_lint/src/if_let_rescope.rs @@ -122,7 +122,11 @@ impl IfLetRescope { } let tcx = cx.tcx; let source_map = tcx.sess.source_map(); - let expr_end = expr.span.shrink_to_hi(); + let expr_end = match expr.kind { + hir::ExprKind::If(_cond, conseq, None) => conseq.span.shrink_to_hi(), + hir::ExprKind::If(_cond, _conseq, Some(alt)) => alt.span.shrink_to_hi(), + _ => return, + }; let mut add_bracket_to_match_head = match_head_needs_bracket(tcx, expr); let mut significant_droppers = vec![]; let mut lifetime_ends = vec![]; @@ -145,7 +149,10 @@ impl IfLetRescope { recovered: Recovered::No, }) = cond.kind { - let if_let_pat = expr.span.shrink_to_lo().between(init.span); + // Peel off round braces + let if_let_pat = source_map + .span_take_while(expr.span, |&ch| ch == '(' || ch.is_whitespace()) + .between(init.span); // The consequent fragment is always a block. let before_conseq = conseq.span.shrink_to_lo(); let lifetime_end = source_map.end_point(conseq.span); @@ -159,6 +166,8 @@ impl IfLetRescope { if ty_ascription.is_some() || !expr.span.can_be_used_for_suggestions() || !pat.span.can_be_used_for_suggestions() + || !if_let_pat.can_be_used_for_suggestions() + || !before_conseq.can_be_used_for_suggestions() { // Our `match` rewrites does not support type ascription, // so we just bail. @@ -240,6 +249,23 @@ impl<'tcx> LateLintPass<'tcx> for IfLetRescope { if let (Level::Allow, _) = cx.tcx.lint_level_at_node(IF_LET_RESCOPE, expr.hir_id) { return; } + if let hir::ExprKind::Loop(block, _label, hir::LoopSource::While, _span) = expr.kind + && let Some(value) = block.expr + && let hir::ExprKind::If(cond, _conseq, _alt) = value.kind + && let hir::ExprKind::Let(..) = cond.kind + { + // Recall that `while let` is lowered into this: + // ``` + // loop { + // if let .. { body } else { break; } + // } + // ``` + // There is no observable change in drop order on the overall `if let` expression + // given that the `{ break; }` block is trivial so the edition change + // means nothing substantial to this `while` statement. + self.skip.insert(value.hir_id); + return; + } if expr_parent_is_stmt(cx.tcx, expr.hir_id) && matches!(expr.kind, hir::ExprKind::If(_cond, _conseq, None)) { diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index be14107baa9..0a98b363b1a 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -373,7 +373,7 @@ const MIPS_ALLOWED_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[ const RISCV_ALLOWED_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[ // tidy-alphabetical-start - ("a", Stable, &[]), + ("a", Stable, &["zaamo", "zalrsc"]), ("c", Stable, &[]), ("d", Unstable(sym::riscv_target_feature), &["f"]), ("e", Unstable(sym::riscv_target_feature), &[]), @@ -382,6 +382,9 @@ const RISCV_ALLOWED_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[ ("relax", Unstable(sym::riscv_target_feature), &[]), ("unaligned-scalar-mem", Unstable(sym::riscv_target_feature), &[]), ("v", Unstable(sym::riscv_target_feature), &[]), + ("zaamo", Unstable(sym::riscv_target_feature), &[]), + ("zabha", Unstable(sym::riscv_target_feature), &["zaamo"]), + ("zalrsc", Unstable(sym::riscv_target_feature), &[]), ("zba", Stable, &[]), ("zbb", Stable, &[]), ("zbc", Stable, &[]), diff --git a/library/alloc/src/boxed.rs b/library/alloc/src/boxed.rs index 6421504b896..5f207295683 100644 --- a/library/alloc/src/boxed.rs +++ b/library/alloc/src/boxed.rs @@ -228,6 +228,7 @@ mod thin; #[lang = "owned_box"] #[fundamental] #[stable(feature = "rust1", since = "1.0.0")] +#[rustc_insignificant_dtor] // The declaration of the `Box` struct must be kept in sync with the // compiler or ICEs will happen. pub struct Box< diff --git a/library/alloc/src/ffi/c_str.rs b/library/alloc/src/ffi/c_str.rs index 797d591a8b5..d496899e72b 100644 --- a/library/alloc/src/ffi/c_str.rs +++ b/library/alloc/src/ffi/c_str.rs @@ -696,6 +696,7 @@ impl CString { // memory-unsafe code from working by accident. Inline // to prevent LLVM from optimizing it away in debug builds. #[stable(feature = "cstring_drop", since = "1.13.0")] +#[rustc_insignificant_dtor] impl Drop for CString { #[inline] fn drop(&mut self) { diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index ced789c4f92..5d099a49854 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -237,6 +237,7 @@ macro_rules! acquire { /// [rc_examples]: crate::rc#examples #[cfg_attr(not(test), rustc_diagnostic_item = "Arc")] #[stable(feature = "rust1", since = "1.0.0")] +#[rustc_insignificant_dtor] pub struct Arc< T: ?Sized, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global, diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index dec67f9fe51..44cba5aad86 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -3165,7 +3165,7 @@ pub const fn type_id<T: ?Sized + 'static>() -> u128 { /// change the possible layouts of pointers. #[rustc_nounwind] #[unstable(feature = "core_intrinsics", issue = "none")] -#[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")] +#[rustc_const_stable(feature = "ptr_metadata_const", since = "CURRENT_RUSTC_VERSION")] #[rustc_intrinsic] #[rustc_intrinsic_must_be_overridden] pub const fn aggregate_raw_ptr<P: AggregateRawPtr<D, Metadata = M>, D, M>(_data: D, _meta: M) -> P { @@ -3190,7 +3190,7 @@ impl<P: ?Sized, T: ptr::Thin> AggregateRawPtr<*mut T> for *mut P { /// This is used to implement functions like `ptr::metadata`. #[rustc_nounwind] #[unstable(feature = "core_intrinsics", issue = "none")] -#[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")] +#[rustc_const_stable(feature = "ptr_metadata_const", since = "CURRENT_RUSTC_VERSION")] #[rustc_intrinsic] #[rustc_intrinsic_must_be_overridden] pub const fn ptr_metadata<P: ptr::Pointee<Metadata = M> + ?Sized, M>(_ptr: *const P) -> M { diff --git a/library/core/src/ptr/const_ptr.rs b/library/core/src/ptr/const_ptr.rs index 1146ca6ef43..73f0538a49d 100644 --- a/library/core/src/ptr/const_ptr.rs +++ b/library/core/src/ptr/const_ptr.rs @@ -92,7 +92,7 @@ impl<T: ?Sized> *const T { /// } /// ``` #[unstable(feature = "set_ptr_value", issue = "75091")] - #[rustc_const_unstable(feature = "set_ptr_value", issue = "75091")] + #[rustc_const_stable(feature = "ptr_metadata_const", since = "CURRENT_RUSTC_VERSION")] #[must_use = "returns a new pointer rather than modifying its argument"] #[inline] pub const fn with_metadata_of<U>(self, meta: *const U) -> *const U @@ -412,7 +412,6 @@ impl<T: ?Sized> *const T { #[inline(always)] #[stable(feature = "pointer_byte_offsets", since = "1.75.0")] #[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")] - #[rustc_allow_const_fn_unstable(set_ptr_value)] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub const unsafe fn byte_offset(self, count: isize) -> Self { // SAFETY: the caller must uphold the safety contract for `offset`. @@ -495,7 +494,6 @@ impl<T: ?Sized> *const T { #[inline(always)] #[stable(feature = "pointer_byte_offsets", since = "1.75.0")] #[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")] - #[rustc_allow_const_fn_unstable(set_ptr_value)] pub const fn wrapping_byte_offset(self, count: isize) -> Self { self.cast::<u8>().wrapping_offset(count).with_metadata_of(self) } @@ -645,7 +643,6 @@ impl<T: ?Sized> *const T { #[inline(always)] #[stable(feature = "pointer_byte_offsets", since = "1.75.0")] #[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")] - #[rustc_allow_const_fn_unstable(set_ptr_value)] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub const unsafe fn byte_offset_from<U: ?Sized>(self, origin: *const U) -> isize { // SAFETY: the caller must uphold the safety contract for `offset_from`. @@ -873,7 +870,6 @@ impl<T: ?Sized> *const T { #[inline(always)] #[stable(feature = "pointer_byte_offsets", since = "1.75.0")] #[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")] - #[rustc_allow_const_fn_unstable(set_ptr_value)] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub const unsafe fn byte_add(self, count: usize) -> Self { // SAFETY: the caller must uphold the safety contract for `add`. @@ -956,7 +952,6 @@ impl<T: ?Sized> *const T { #[inline(always)] #[stable(feature = "pointer_byte_offsets", since = "1.75.0")] #[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")] - #[rustc_allow_const_fn_unstable(set_ptr_value)] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub const unsafe fn byte_sub(self, count: usize) -> Self { // SAFETY: the caller must uphold the safety contract for `sub`. @@ -1039,7 +1034,6 @@ impl<T: ?Sized> *const T { #[inline(always)] #[stable(feature = "pointer_byte_offsets", since = "1.75.0")] #[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")] - #[rustc_allow_const_fn_unstable(set_ptr_value)] pub const fn wrapping_byte_add(self, count: usize) -> Self { self.cast::<u8>().wrapping_add(count).with_metadata_of(self) } @@ -1120,7 +1114,6 @@ impl<T: ?Sized> *const T { #[inline(always)] #[stable(feature = "pointer_byte_offsets", since = "1.75.0")] #[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")] - #[rustc_allow_const_fn_unstable(set_ptr_value)] pub const fn wrapping_byte_sub(self, count: usize) -> Self { self.cast::<u8>().wrapping_sub(count).with_metadata_of(self) } @@ -1554,7 +1547,6 @@ impl<T> *const [T] { #[inline] #[stable(feature = "slice_ptr_len", since = "1.79.0")] #[rustc_const_stable(feature = "const_slice_ptr_len", since = "1.79.0")] - #[rustc_allow_const_fn_unstable(ptr_metadata)] pub const fn len(self) -> usize { metadata(self) } diff --git a/library/core/src/ptr/metadata.rs b/library/core/src/ptr/metadata.rs index 76a0e2ba774..feeaf78d3e7 100644 --- a/library/core/src/ptr/metadata.rs +++ b/library/core/src/ptr/metadata.rs @@ -92,7 +92,7 @@ pub trait Thin = Pointee<Metadata = ()>; /// /// assert_eq!(std::ptr::metadata("foo"), 3_usize); /// ``` -#[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")] +#[rustc_const_stable(feature = "ptr_metadata_const", since = "CURRENT_RUSTC_VERSION")] #[inline] pub const fn metadata<T: ?Sized>(ptr: *const T) -> <T as Pointee>::Metadata { ptr_metadata(ptr) @@ -106,7 +106,7 @@ pub const fn metadata<T: ?Sized>(ptr: *const T) -> <T as Pointee>::Metadata { /// /// [`slice::from_raw_parts`]: crate::slice::from_raw_parts #[unstable(feature = "ptr_metadata", issue = "81513")] -#[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")] +#[rustc_const_stable(feature = "ptr_metadata_const", since = "CURRENT_RUSTC_VERSION")] #[inline] pub const fn from_raw_parts<T: ?Sized>( data_pointer: *const impl Thin, @@ -120,7 +120,7 @@ pub const fn from_raw_parts<T: ?Sized>( /// /// See the documentation of [`from_raw_parts`] for more details. #[unstable(feature = "ptr_metadata", issue = "81513")] -#[rustc_const_unstable(feature = "ptr_metadata", issue = "81513")] +#[rustc_const_stable(feature = "ptr_metadata_const", since = "CURRENT_RUSTC_VERSION")] #[inline] pub const fn from_raw_parts_mut<T: ?Sized>( data_pointer: *mut impl Thin, diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs index 4f97048eab1..b6df780fe2f 100644 --- a/library/core/src/ptr/mod.rs +++ b/library/core/src/ptr/mod.rs @@ -599,7 +599,6 @@ pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_promotable] #[rustc_const_stable(feature = "const_ptr_null", since = "1.24.0")] -#[rustc_allow_const_fn_unstable(ptr_metadata)] #[rustc_diagnostic_item = "ptr_null"] pub const fn null<T: ?Sized + Thin>() -> *const T { from_raw_parts(without_provenance::<()>(0), ()) @@ -625,7 +624,6 @@ pub const fn null<T: ?Sized + Thin>() -> *const T { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_promotable] #[rustc_const_stable(feature = "const_ptr_null", since = "1.24.0")] -#[rustc_allow_const_fn_unstable(ptr_metadata)] #[rustc_diagnostic_item = "ptr_null_mut"] pub const fn null_mut<T: ?Sized + Thin>() -> *mut T { from_raw_parts_mut(without_provenance_mut::<()>(0), ()) @@ -949,7 +947,6 @@ pub const fn from_mut<T: ?Sized>(r: &mut T) -> *mut T { #[inline] #[stable(feature = "slice_from_raw_parts", since = "1.42.0")] #[rustc_const_stable(feature = "const_slice_from_raw_parts", since = "1.64.0")] -#[rustc_allow_const_fn_unstable(ptr_metadata)] #[rustc_diagnostic_item = "ptr_slice_from_raw_parts"] pub const fn slice_from_raw_parts<T>(data: *const T, len: usize) -> *const [T] { from_raw_parts(data, len) diff --git a/library/core/src/ptr/mut_ptr.rs b/library/core/src/ptr/mut_ptr.rs index 8e33cf081ba..b737c5fdc40 100644 --- a/library/core/src/ptr/mut_ptr.rs +++ b/library/core/src/ptr/mut_ptr.rs @@ -74,7 +74,7 @@ impl<T: ?Sized> *mut T { /// } /// ``` #[unstable(feature = "set_ptr_value", issue = "75091")] - #[rustc_const_unstable(feature = "set_ptr_value", issue = "75091")] + #[rustc_const_stable(feature = "ptr_metadata_const", since = "CURRENT_RUSTC_VERSION")] #[must_use = "returns a new pointer rather than modifying its argument"] #[inline] pub const fn with_metadata_of<U>(self, meta: *const U) -> *mut U @@ -412,7 +412,6 @@ impl<T: ?Sized> *mut T { #[inline(always)] #[stable(feature = "pointer_byte_offsets", since = "1.75.0")] #[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")] - #[rustc_allow_const_fn_unstable(set_ptr_value)] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub const unsafe fn byte_offset(self, count: isize) -> Self { // SAFETY: the caller must uphold the safety contract for `offset`. @@ -492,7 +491,6 @@ impl<T: ?Sized> *mut T { #[inline(always)] #[stable(feature = "pointer_byte_offsets", since = "1.75.0")] #[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")] - #[rustc_allow_const_fn_unstable(set_ptr_value)] pub const fn wrapping_byte_offset(self, count: isize) -> Self { self.cast::<u8>().wrapping_offset(count).with_metadata_of(self) } @@ -808,7 +806,6 @@ impl<T: ?Sized> *mut T { #[inline(always)] #[stable(feature = "pointer_byte_offsets", since = "1.75.0")] #[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")] - #[rustc_allow_const_fn_unstable(set_ptr_value)] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub const unsafe fn byte_offset_from<U: ?Sized>(self, origin: *const U) -> isize { // SAFETY: the caller must uphold the safety contract for `offset_from`. @@ -954,7 +951,6 @@ impl<T: ?Sized> *mut T { #[inline(always)] #[stable(feature = "pointer_byte_offsets", since = "1.75.0")] #[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")] - #[rustc_allow_const_fn_unstable(set_ptr_value)] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub const unsafe fn byte_add(self, count: usize) -> Self { // SAFETY: the caller must uphold the safety contract for `add`. @@ -1037,7 +1033,6 @@ impl<T: ?Sized> *mut T { #[inline(always)] #[stable(feature = "pointer_byte_offsets", since = "1.75.0")] #[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")] - #[rustc_allow_const_fn_unstable(set_ptr_value)] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces pub const unsafe fn byte_sub(self, count: usize) -> Self { // SAFETY: the caller must uphold the safety contract for `sub`. @@ -1118,7 +1113,6 @@ impl<T: ?Sized> *mut T { #[inline(always)] #[stable(feature = "pointer_byte_offsets", since = "1.75.0")] #[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")] - #[rustc_allow_const_fn_unstable(set_ptr_value)] pub const fn wrapping_byte_add(self, count: usize) -> Self { self.cast::<u8>().wrapping_add(count).with_metadata_of(self) } @@ -1197,7 +1191,6 @@ impl<T: ?Sized> *mut T { #[inline(always)] #[stable(feature = "pointer_byte_offsets", since = "1.75.0")] #[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")] - #[rustc_allow_const_fn_unstable(set_ptr_value)] pub const fn wrapping_byte_sub(self, count: usize) -> Self { self.cast::<u8>().wrapping_sub(count).with_metadata_of(self) } @@ -1804,7 +1797,6 @@ impl<T> *mut [T] { #[inline(always)] #[stable(feature = "slice_ptr_len", since = "1.79.0")] #[rustc_const_stable(feature = "const_slice_ptr_len", since = "1.79.0")] - #[rustc_allow_const_fn_unstable(ptr_metadata)] pub const fn len(self) -> usize { metadata(self) } diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs index daa40b3c9d2..e7a265f7e2b 100644 --- a/library/core/src/ptr/non_null.rs +++ b/library/core/src/ptr/non_null.rs @@ -567,7 +567,6 @@ impl<T: ?Sized> NonNull<T> { #[must_use] #[inline(always)] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces - #[rustc_allow_const_fn_unstable(set_ptr_value)] #[stable(feature = "non_null_convenience", since = "1.80.0")] #[rustc_const_stable(feature = "non_null_convenience", since = "1.80.0")] pub const unsafe fn byte_add(self, count: usize) -> Self { @@ -651,7 +650,6 @@ impl<T: ?Sized> NonNull<T> { #[must_use] #[inline(always)] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces - #[rustc_allow_const_fn_unstable(set_ptr_value)] #[stable(feature = "non_null_convenience", since = "1.80.0")] #[rustc_const_stable(feature = "non_null_convenience", since = "1.80.0")] pub const unsafe fn byte_sub(self, count: usize) -> Self { diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index dd8fa1ae343..922168b9e8e 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -111,7 +111,6 @@ impl<T> [T] { #[lang = "slice_len_fn"] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_slice_len", since = "1.39.0")] - #[rustc_allow_const_fn_unstable(ptr_metadata)] #[inline] #[must_use] pub const fn len(&self) -> usize { diff --git a/library/std/build.rs b/library/std/build.rs index c5d0af469a8..7d37d4e9d7d 100644 --- a/library/std/build.rs +++ b/library/std/build.rs @@ -101,10 +101,7 @@ fn main() { // Unsupported <https://github.com/llvm/llvm-project/issues/94434> ("arm64ec", _) => false, // MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054> - ("x86_64", "windows") => false, - // Apple has a special ABI for `f16` that we do not yet support - // FIXME(builtins): fixed by <https://github.com/rust-lang/compiler-builtins/pull/675> - ("x86" | "x86_64", _) if target_vendor == "apple" => false, + ("x86_64", "windows") if target_env == "gnu" => false, // Infinite recursion <https://github.com/llvm/llvm-project/issues/97981> ("csky", _) => false, ("hexagon", _) => false, @@ -132,10 +129,10 @@ fn main() { // ABI unsupported <https://github.com/llvm/llvm-project/issues/41838> ("sparc", _) => false, // MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054> - ("x86_64", "windows") => false, + ("x86_64", "windows") if target_env == "gnu" => false, // 64-bit Linux is about the only platform to have f128 symbols by default (_, "linux") if target_pointer_width == 64 => true, - // Same as for f16, except MacOS is also missing f128 symbols. + // Almost all OSs are missing symbol. compiler-builtins will have to add them. _ => false, }; diff --git a/library/std/src/collections/hash/map/tests.rs b/library/std/src/collections/hash/map/tests.rs index c28dd7b6b50..2599060ef62 100644 --- a/library/std/src/collections/hash/map/tests.rs +++ b/library/std/src/collections/hash/map/tests.rs @@ -1018,6 +1018,7 @@ mod test_extract_if { } #[test] + #[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")] fn drop_panic_leak() { static PREDS: AtomicUsize = AtomicUsize::new(0); static DROPS: AtomicUsize = AtomicUsize::new(0); @@ -1047,6 +1048,7 @@ mod test_extract_if { } #[test] + #[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")] fn pred_panic_leak() { static PREDS: AtomicUsize = AtomicUsize::new(0); static DROPS: AtomicUsize = AtomicUsize::new(0); @@ -1076,6 +1078,7 @@ mod test_extract_if { // Same as above, but attempt to use the iterator again after the panic in the predicate #[test] + #[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")] fn pred_panic_reuse() { static PREDS: AtomicUsize = AtomicUsize::new(0); static DROPS: AtomicUsize = AtomicUsize::new(0); diff --git a/library/std/src/collections/hash/set/tests.rs b/library/std/src/collections/hash/set/tests.rs index 7aa2167e213..8ee8a3e8bf6 100644 --- a/library/std/src/collections/hash/set/tests.rs +++ b/library/std/src/collections/hash/set/tests.rs @@ -429,6 +429,7 @@ fn test_extract_if() { } #[test] +#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")] fn test_extract_if_drop_panic_leak() { static PREDS: AtomicU32 = AtomicU32::new(0); static DROPS: AtomicU32 = AtomicU32::new(0); @@ -459,6 +460,7 @@ fn test_extract_if_drop_panic_leak() { } #[test] +#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")] fn test_extract_if_pred_panic_leak() { static PREDS: AtomicU32 = AtomicU32::new(0); static DROPS: AtomicU32 = AtomicU32::new(0); diff --git a/library/std/src/env/tests.rs b/library/std/src/env/tests.rs index fc7aee29733..d0217261068 100644 --- a/library/std/src/env/tests.rs +++ b/library/std/src/env/tests.rs @@ -1,7 +1,7 @@ use super::*; #[test] -#[cfg_attr(any(target_os = "emscripten", target_env = "sgx"), ignore)] +#[cfg_attr(any(target_os = "emscripten", target_os = "wasi", target_env = "sgx"), ignore)] fn test_self_exe_path() { let path = current_exe(); assert!(path.is_ok()); diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index db7867337dd..124ef121b18 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -8,7 +8,15 @@ #![stable(feature = "rust1", since = "1.0.0")] #![deny(unsafe_op_in_unsafe_fn)] -#[cfg(all(test, not(any(target_os = "emscripten", target_env = "sgx", target_os = "xous"))))] +#[cfg(all( + test, + not(any( + target_os = "emscripten", + target_os = "wasi", + target_env = "sgx", + target_os = "xous" + )) +))] mod tests; use crate::ffi::OsString; diff --git a/library/std/src/io/buffered/tests.rs b/library/std/src/io/buffered/tests.rs index d89ecd317d6..bff0f823c4b 100644 --- a/library/std/src/io/buffered/tests.rs +++ b/library/std/src/io/buffered/tests.rs @@ -164,6 +164,7 @@ fn test_buffered_reader_stream_position() { } #[test] +#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")] fn test_buffered_reader_stream_position_panic() { let inner: &[u8] = &[5, 6, 7, 0, 1, 2, 3, 4]; let mut reader = BufReader::with_capacity(4, io::Cursor::new(inner)); @@ -487,7 +488,7 @@ fn dont_panic_in_drop_on_panicked_flush() { } #[test] -#[cfg_attr(target_os = "emscripten", ignore)] +#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads fn panic_in_write_doesnt_flush_in_drop() { static WRITES: AtomicUsize = AtomicUsize::new(0); diff --git a/library/std/src/io/error/repr_bitpacked.rs b/library/std/src/io/error/repr_bitpacked.rs index 80ba8455df3..a839a2fbac1 100644 --- a/library/std/src/io/error/repr_bitpacked.rs +++ b/library/std/src/io/error/repr_bitpacked.rs @@ -124,6 +124,7 @@ const TAG_SIMPLE: usize = 0b11; /// is_unwind_safe::<std::io::Error>(); /// ``` #[repr(transparent)] +#[rustc_insignificant_dtor] pub(super) struct Repr(NonNull<()>, PhantomData<ErrorData<Box<Custom>>>); // All the types `Repr` stores internally are Send + Sync, and so is it. diff --git a/library/std/src/io/stdio/tests.rs b/library/std/src/io/stdio/tests.rs index ea76a271d12..bf8f3a5adfb 100644 --- a/library/std/src/io/stdio/tests.rs +++ b/library/std/src/io/stdio/tests.rs @@ -25,7 +25,7 @@ fn stderrlock_unwind_safe() { fn assert_unwind_safe<T: UnwindSafe + RefUnwindSafe>() {} #[test] -#[cfg_attr(target_os = "emscripten", ignore)] +#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads fn panic_doesnt_poison() { thread::spawn(|| { let _a = stdin(); @@ -48,17 +48,17 @@ fn panic_doesnt_poison() { } #[test] -#[cfg_attr(target_os = "emscripten", ignore)] +#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads fn test_lock_stderr() { test_lock(stderr, || stderr().lock()); } #[test] -#[cfg_attr(target_os = "emscripten", ignore)] +#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads fn test_lock_stdin() { test_lock(stdin, || stdin().lock()); } #[test] -#[cfg_attr(target_os = "emscripten", ignore)] +#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads fn test_lock_stdout() { test_lock(stdout, || stdout().lock()); } diff --git a/library/std/src/net/ip_addr.rs b/library/std/src/net/ip_addr.rs index 8a9426b61f9..4d673a1d66d 100644 --- a/library/std/src/net/ip_addr.rs +++ b/library/std/src/net/ip_addr.rs @@ -1,5 +1,5 @@ // Tests for this module -#[cfg(all(test, not(target_os = "emscripten")))] +#[cfg(all(test, not(any(target_os = "emscripten", all(target_os = "wasi", target_env = "p1")))))] mod tests; #[stable(feature = "ip_addr", since = "1.7.0")] diff --git a/library/std/src/net/socket_addr.rs b/library/std/src/net/socket_addr.rs index 84922aabdb5..ba9c948a2e9 100644 --- a/library/std/src/net/socket_addr.rs +++ b/library/std/src/net/socket_addr.rs @@ -1,5 +1,5 @@ // Tests for this module -#[cfg(all(test, not(target_os = "emscripten")))] +#[cfg(all(test, not(any(target_os = "emscripten", all(target_os = "wasi", target_env = "p1")))))] mod tests; #[stable(feature = "rust1", since = "1.0.0")] diff --git a/library/std/src/net/tcp.rs b/library/std/src/net/tcp.rs index f81a13d4c44..67a0f7e439d 100644 --- a/library/std/src/net/tcp.rs +++ b/library/std/src/net/tcp.rs @@ -1,6 +1,13 @@ #![deny(unsafe_op_in_unsafe_fn)] -#[cfg(all(test, not(any(target_os = "emscripten", target_os = "xous"))))] +#[cfg(all( + test, + not(any( + target_os = "emscripten", + all(target_os = "wasi", target_env = "p1"), + target_os = "xous" + )) +))] mod tests; use crate::fmt; diff --git a/library/std/src/net/tcp/tests.rs b/library/std/src/net/tcp/tests.rs index d26517d74e4..a7b5cdf4ec0 100644 --- a/library/std/src/net/tcp/tests.rs +++ b/library/std/src/net/tcp/tests.rs @@ -57,6 +57,7 @@ fn connect_timeout_error() { } #[test] +#[cfg_attr(target_os = "wasi", ignore)] // no threads fn listen_localhost() { let socket_addr = next_test_ip4(); let listener = t!(TcpListener::bind(&socket_addr)); @@ -73,6 +74,7 @@ fn listen_localhost() { } #[test] +#[cfg_attr(target_os = "wasi", ignore)] // no threads fn connect_loopback() { each_ip(&mut |addr| { let acceptor = t!(TcpListener::bind(&addr)); @@ -94,6 +96,7 @@ fn connect_loopback() { } #[test] +#[cfg_attr(target_os = "wasi", ignore)] // no threads fn smoke_test() { each_ip(&mut |addr| { let acceptor = t!(TcpListener::bind(&addr)); @@ -114,6 +117,7 @@ fn smoke_test() { } #[test] +#[cfg_attr(target_os = "wasi", ignore)] // no threads fn read_eof() { each_ip(&mut |addr| { let acceptor = t!(TcpListener::bind(&addr)); @@ -133,6 +137,7 @@ fn read_eof() { } #[test] +#[cfg_attr(target_os = "wasi", ignore)] // no threads fn write_close() { each_ip(&mut |addr| { let acceptor = t!(TcpListener::bind(&addr)); @@ -161,6 +166,7 @@ fn write_close() { } #[test] +#[cfg_attr(target_os = "wasi", ignore)] // no threads fn multiple_connect_serial() { each_ip(&mut |addr| { let max = 10; @@ -183,6 +189,7 @@ fn multiple_connect_serial() { } #[test] +#[cfg_attr(target_os = "wasi", ignore)] // no threads fn multiple_connect_interleaved_greedy_schedule() { const MAX: usize = 10; each_ip(&mut |addr| { @@ -220,6 +227,7 @@ fn multiple_connect_interleaved_greedy_schedule() { } #[test] +#[cfg_attr(target_os = "wasi", ignore)] // no threads fn multiple_connect_interleaved_lazy_schedule() { const MAX: usize = 10; each_ip(&mut |addr| { @@ -255,6 +263,7 @@ fn multiple_connect_interleaved_lazy_schedule() { } #[test] +#[cfg_attr(target_os = "wasi", ignore)] // no threads fn socket_and_peer_name() { each_ip(&mut |addr| { let listener = t!(TcpListener::bind(&addr)); @@ -270,6 +279,7 @@ fn socket_and_peer_name() { } #[test] +#[cfg_attr(target_os = "wasi", ignore)] // no threads fn partial_read() { each_ip(&mut |addr| { let (tx, rx) = channel(); @@ -291,6 +301,7 @@ fn partial_read() { } #[test] +#[cfg_attr(target_os = "wasi", ignore)] // no threads fn read_buf() { each_ip(&mut |addr| { let srv = t!(TcpListener::bind(&addr)); @@ -389,6 +400,7 @@ fn double_bind() { } #[test] +#[cfg_attr(target_os = "wasi", ignore)] // no threads fn tcp_clone_smoke() { each_ip(&mut |addr| { let acceptor = t!(TcpListener::bind(&addr)); @@ -420,6 +432,7 @@ fn tcp_clone_smoke() { } #[test] +#[cfg_attr(target_os = "wasi", ignore)] // no threads fn tcp_clone_two_read() { each_ip(&mut |addr| { let acceptor = t!(TcpListener::bind(&addr)); @@ -454,6 +467,7 @@ fn tcp_clone_two_read() { } #[test] +#[cfg_attr(target_os = "wasi", ignore)] // no threads fn tcp_clone_two_write() { each_ip(&mut |addr| { let acceptor = t!(TcpListener::bind(&addr)); @@ -483,6 +497,7 @@ fn tcp_clone_two_write() { #[test] // FIXME: https://github.com/fortanix/rust-sgx/issues/110 #[cfg_attr(target_env = "sgx", ignore)] +#[cfg_attr(target_os = "wasi", ignore)] // no threads fn shutdown_smoke() { each_ip(&mut |addr| { let a = t!(TcpListener::bind(&addr)); @@ -505,6 +520,7 @@ fn shutdown_smoke() { #[test] // FIXME: https://github.com/fortanix/rust-sgx/issues/110 #[cfg_attr(target_env = "sgx", ignore)] +#[cfg_attr(target_os = "wasi", ignore)] // no threads fn close_readwrite_smoke() { each_ip(&mut |addr| { let a = t!(TcpListener::bind(&addr)); @@ -547,6 +563,7 @@ fn close_readwrite_smoke() { #[cfg_attr(target_env = "sgx", ignore)] // On windows, shutdown will not wake up blocking I/O operations. #[cfg_attr(windows, ignore)] +#[cfg_attr(target_os = "wasi", ignore)] // no threads fn close_read_wakes_up() { each_ip(&mut |addr| { let listener = t!(TcpListener::bind(&addr)); @@ -574,6 +591,7 @@ fn close_read_wakes_up() { } #[test] +#[cfg_attr(target_os = "wasi", ignore)] // no threads fn clone_while_reading() { each_ip(&mut |addr| { let accept = t!(TcpListener::bind(&addr)); @@ -614,6 +632,7 @@ fn clone_while_reading() { } #[test] +#[cfg_attr(target_os = "wasi", ignore)] // no threads fn clone_accept_smoke() { each_ip(&mut |addr| { let a = t!(TcpListener::bind(&addr)); @@ -632,6 +651,7 @@ fn clone_accept_smoke() { } #[test] +#[cfg_attr(target_os = "wasi", ignore)] // no threads fn clone_accept_concurrent() { each_ip(&mut |addr| { let a = t!(TcpListener::bind(&addr)); @@ -670,10 +690,10 @@ fn debug() { addr.to_string() } + #[cfg(any(unix, target_os = "wasi"))] + use crate::os::fd::AsRawFd; #[cfg(target_env = "sgx")] use crate::os::fortanix_sgx::io::AsRawFd; - #[cfg(unix)] - use crate::os::unix::io::AsRawFd; #[cfg(not(windows))] fn render_inner(addr: &dyn AsRawFd) -> impl fmt::Debug { addr.as_raw_fd() @@ -714,6 +734,7 @@ fn debug() { ignore )] #[cfg_attr(target_env = "sgx", ignore)] // FIXME: https://github.com/fortanix/rust-sgx/issues/31 +#[cfg_attr(target_os = "wasi", ignore)] // timeout not supported #[test] fn timeouts() { let addr = next_test_ip4(); @@ -742,6 +763,7 @@ fn timeouts() { #[test] #[cfg_attr(target_env = "sgx", ignore)] // FIXME: https://github.com/fortanix/rust-sgx/issues/31 +#[cfg_attr(target_os = "wasi", ignore)] // timeout not supported fn test_read_timeout() { let addr = next_test_ip4(); let listener = t!(TcpListener::bind(&addr)); @@ -763,6 +785,7 @@ fn test_read_timeout() { #[test] #[cfg_attr(target_env = "sgx", ignore)] // FIXME: https://github.com/fortanix/rust-sgx/issues/31 +#[cfg_attr(target_os = "wasi", ignore)] // timeout not supported fn test_read_with_timeout() { let addr = next_test_ip4(); let listener = t!(TcpListener::bind(&addr)); @@ -810,6 +833,7 @@ fn test_timeout_zero_duration() { #[test] #[cfg_attr(target_env = "sgx", ignore)] +#[cfg_attr(target_os = "wasi", ignore)] // linger not supported fn linger() { let addr = next_test_ip4(); let _listener = t!(TcpListener::bind(&addr)); @@ -879,6 +903,7 @@ fn set_nonblocking() { #[test] #[cfg_attr(target_env = "sgx", ignore)] // FIXME: https://github.com/fortanix/rust-sgx/issues/31 +#[cfg_attr(target_os = "wasi", ignore)] // no threads fn peek() { each_ip(&mut |addr| { let (txdone, rxdone) = channel(); diff --git a/library/std/src/net/udp.rs b/library/std/src/net/udp.rs index b78e52023b3..6df47d7b0e0 100644 --- a/library/std/src/net/udp.rs +++ b/library/std/src/net/udp.rs @@ -1,4 +1,12 @@ -#[cfg(all(test, not(any(target_os = "emscripten", target_env = "sgx", target_os = "xous"))))] +#[cfg(all( + test, + not(any( + target_os = "emscripten", + all(target_os = "wasi", target_env = "p1"), + target_env = "sgx", + target_os = "xous" + )) +))] mod tests; use crate::fmt; diff --git a/library/std/src/net/udp/tests.rs b/library/std/src/net/udp/tests.rs index 0cf99366452..1c8c58d1879 100644 --- a/library/std/src/net/udp/tests.rs +++ b/library/std/src/net/udp/tests.rs @@ -27,6 +27,7 @@ fn bind_error() { } #[test] +#[cfg_attr(target_os = "wasi", ignore)] // no threads fn socket_smoke_test_ip4() { each_ip(&mut |server_ip, client_ip| { let (tx1, rx1) = channel(); @@ -69,6 +70,7 @@ fn socket_peer() { } #[test] +#[cfg_attr(target_os = "wasi", ignore)] // no threads fn udp_clone_smoke() { each_ip(&mut |addr1, addr2| { let sock1 = t!(UdpSocket::bind(&addr1)); @@ -98,6 +100,7 @@ fn udp_clone_smoke() { } #[test] +#[cfg_attr(target_os = "wasi", ignore)] // no threads fn udp_clone_two_read() { each_ip(&mut |addr1, addr2| { let sock1 = t!(UdpSocket::bind(&addr1)); @@ -130,6 +133,7 @@ fn udp_clone_two_read() { } #[test] +#[cfg_attr(target_os = "wasi", ignore)] // no threads fn udp_clone_two_write() { each_ip(&mut |addr1, addr2| { let sock1 = t!(UdpSocket::bind(&addr1)); @@ -183,6 +187,7 @@ fn debug() { any(target_os = "netbsd", target_os = "openbsd", target_os = "vxworks", target_os = "nto"), ignore )] +#[cfg_attr(target_os = "wasi", ignore)] // timeout not supported #[test] fn timeouts() { let addr = next_test_ip4(); @@ -208,6 +213,7 @@ fn timeouts() { } #[test] +#[cfg_attr(target_os = "wasi", ignore)] // timeout not supported fn test_read_timeout() { let addr = next_test_ip4(); @@ -232,6 +238,7 @@ fn test_read_timeout() { } #[test] +#[cfg_attr(target_os = "wasi", ignore)] // timeout not supported fn test_read_with_timeout() { let addr = next_test_ip4(); @@ -291,6 +298,7 @@ fn connect_send_recv() { } #[test] +#[cfg_attr(target_os = "wasi", ignore)] // peek not supported fn connect_send_peek_recv() { each_ip(&mut |addr, _| { let socket = t!(UdpSocket::bind(&addr)); @@ -313,6 +321,7 @@ fn connect_send_peek_recv() { } #[test] +#[cfg_attr(target_os = "wasi", ignore)] // peek_from not supported fn peek_from() { each_ip(&mut |addr, _| { let socket = t!(UdpSocket::bind(&addr)); diff --git a/library/std/src/path/tests.rs b/library/std/src/path/tests.rs index 6436872087d..b75793d2bc9 100644 --- a/library/std/src/path/tests.rs +++ b/library/std/src/path/tests.rs @@ -139,7 +139,7 @@ fn test_pathbuf_leak() { } #[test] -#[cfg(unix)] +#[cfg(any(unix, target_os = "wasi"))] pub fn test_decompositions_unix() { t!("", iter: [], @@ -1201,7 +1201,10 @@ pub fn test_push() { }); ); - if cfg!(unix) || cfg!(all(target_env = "sgx", target_vendor = "fortanix")) { + if cfg!(unix) + || cfg!(target_os = "wasi") + || cfg!(all(target_env = "sgx", target_vendor = "fortanix")) + { tp!("", "foo", "foo"); tp!("foo", "bar", "foo/bar"); tp!("foo/", "bar", "foo/bar"); @@ -1358,7 +1361,10 @@ pub fn test_set_file_name() { tfn!("foo", "bar", "bar"); tfn!("foo", "", ""); tfn!("", "foo", "foo"); - if cfg!(unix) || cfg!(all(target_env = "sgx", target_vendor = "fortanix")) { + if cfg!(unix) + || cfg!(target_os = "wasi") + || cfg!(all(target_env = "sgx", target_vendor = "fortanix")) + { tfn!(".", "foo", "./foo"); tfn!("foo/", "bar", "bar"); tfn!("foo/.", "bar", "bar"); @@ -1758,7 +1764,7 @@ fn test_components_debug() { assert_eq!(expected, actual); } -#[cfg(unix)] +#[cfg(any(unix, target_os = "wasi"))] #[test] fn test_iter_debug() { let path = Path::new("/tmp"); @@ -1859,7 +1865,7 @@ fn test_ord() { } #[test] -#[cfg(unix)] +#[cfg(any(unix, target_os = "wasi"))] fn test_unix_absolute() { use crate::path::absolute; diff --git a/library/std/src/process.rs b/library/std/src/process.rs index c84a5c65263..f24fe353e55 100644 --- a/library/std/src/process.rs +++ b/library/std/src/process.rs @@ -148,7 +148,15 @@ #![stable(feature = "process", since = "1.0.0")] #![deny(unsafe_op_in_unsafe_fn)] -#[cfg(all(test, not(any(target_os = "emscripten", target_env = "sgx", target_os = "xous"))))] +#[cfg(all( + test, + not(any( + target_os = "emscripten", + target_os = "wasi", + target_env = "sgx", + target_os = "xous" + )) +))] mod tests; use crate::convert::Infallible; diff --git a/library/std/src/sync/barrier/tests.rs b/library/std/src/sync/barrier/tests.rs index c5620cd91d8..0fbcd998812 100644 --- a/library/std/src/sync/barrier/tests.rs +++ b/library/std/src/sync/barrier/tests.rs @@ -3,7 +3,7 @@ use crate::sync::{Arc, Barrier}; use crate::thread; #[test] -#[cfg_attr(target_os = "emscripten", ignore)] +#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads fn test_barrier() { const N: usize = 10; diff --git a/library/std/src/sync/condvar/tests.rs b/library/std/src/sync/condvar/tests.rs index 12d13a6b20b..f9e9066bc92 100644 --- a/library/std/src/sync/condvar/tests.rs +++ b/library/std/src/sync/condvar/tests.rs @@ -12,7 +12,7 @@ fn smoke() { } #[test] -#[cfg_attr(target_os = "emscripten", ignore)] +#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads fn notify_one() { let m = Arc::new(Mutex::new(())); let m2 = m.clone(); @@ -29,7 +29,7 @@ fn notify_one() { } #[test] -#[cfg_attr(target_os = "emscripten", ignore)] +#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads fn notify_all() { const N: usize = 10; @@ -66,7 +66,7 @@ fn notify_all() { } #[test] -#[cfg_attr(target_os = "emscripten", ignore)] +#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads fn wait_while() { let pair = Arc::new((Mutex::new(false), Condvar::new())); let pair2 = pair.clone(); @@ -87,7 +87,7 @@ fn wait_while() { } #[test] -#[cfg_attr(target_os = "emscripten", ignore)] +#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // condvar wait not supported fn wait_timeout_wait() { let m = Arc::new(Mutex::new(())); let c = Arc::new(Condvar::new()); @@ -106,7 +106,7 @@ fn wait_timeout_wait() { } #[test] -#[cfg_attr(target_os = "emscripten", ignore)] +#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // condvar wait not supported fn wait_timeout_while_wait() { let m = Arc::new(Mutex::new(())); let c = Arc::new(Condvar::new()); @@ -118,7 +118,7 @@ fn wait_timeout_while_wait() { } #[test] -#[cfg_attr(target_os = "emscripten", ignore)] +#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // condvar wait not supported fn wait_timeout_while_instant_satisfy() { let m = Arc::new(Mutex::new(())); let c = Arc::new(Condvar::new()); @@ -130,7 +130,7 @@ fn wait_timeout_while_instant_satisfy() { } #[test] -#[cfg_attr(target_os = "emscripten", ignore)] +#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads fn wait_timeout_while_wake() { let pair = Arc::new((Mutex::new(false), Condvar::new())); let pair_copy = pair.clone(); @@ -153,7 +153,7 @@ fn wait_timeout_while_wake() { } #[test] -#[cfg_attr(target_os = "emscripten", ignore)] +#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads fn wait_timeout_wake() { let m = Arc::new(Mutex::new(())); let c = Arc::new(Condvar::new()); diff --git a/library/std/src/sync/lazy_lock/tests.rs b/library/std/src/sync/lazy_lock/tests.rs index 94044368305..7d7dde54349 100644 --- a/library/std/src/sync/lazy_lock/tests.rs +++ b/library/std/src/sync/lazy_lock/tests.rs @@ -34,6 +34,7 @@ fn lazy_default() { } #[test] +#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")] fn lazy_poisoning() { let x: LazyCell<String> = LazyCell::new(|| panic!("kaboom")); for _ in 0..2 { @@ -43,7 +44,7 @@ fn lazy_poisoning() { } #[test] -#[cfg_attr(target_os = "emscripten", ignore)] +#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads fn sync_lazy_new() { static CALLED: AtomicUsize = AtomicUsize::new(0); static SYNC_LAZY: LazyLock<i32> = LazyLock::new(|| { @@ -90,7 +91,7 @@ fn sync_lazy_default() { } #[test] -#[cfg_attr(target_os = "emscripten", ignore)] +#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads fn static_sync_lazy() { static XS: LazyLock<Vec<i32>> = LazyLock::new(|| { let mut xs = Vec::new(); @@ -123,6 +124,7 @@ fn static_sync_lazy_via_fn() { } #[test] +#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")] fn sync_lazy_poisoning() { let x: LazyLock<String> = LazyLock::new(|| panic!("kaboom")); for _ in 0..2 { diff --git a/library/std/src/sync/mpsc/mod.rs b/library/std/src/sync/mpsc/mod.rs index 26d5b9515a2..83a93a06369 100644 --- a/library/std/src/sync/mpsc/mod.rs +++ b/library/std/src/sync/mpsc/mod.rs @@ -137,10 +137,10 @@ #![stable(feature = "rust1", since = "1.0.0")] -#[cfg(all(test, not(target_os = "emscripten")))] +#[cfg(all(test, not(any(target_os = "emscripten", target_os = "wasi"))))] mod tests; -#[cfg(all(test, not(target_os = "emscripten")))] +#[cfg(all(test, not(any(target_os = "emscripten", target_os = "wasi"))))] mod sync_tests; // MPSC channels are built as a wrapper around MPMC channels, which diff --git a/library/std/src/sync/mutex.rs b/library/std/src/sync/mutex.rs index f3de1f7bf49..fe2aca031a2 100644 --- a/library/std/src/sync/mutex.rs +++ b/library/std/src/sync/mutex.rs @@ -1,4 +1,4 @@ -#[cfg(all(test, not(target_os = "emscripten")))] +#[cfg(all(test, not(any(target_os = "emscripten", target_os = "wasi"))))] mod tests; use crate::cell::UnsafeCell; diff --git a/library/std/src/sync/once.rs b/library/std/src/sync/once.rs index 5a1cd7d0b8b..993df9314fc 100644 --- a/library/std/src/sync/once.rs +++ b/library/std/src/sync/once.rs @@ -3,7 +3,7 @@ //! This primitive is meant to be used to run one-time initialization. An //! example use case would be for initializing an FFI library. -#[cfg(all(test, not(target_os = "emscripten")))] +#[cfg(all(test, not(any(target_os = "emscripten", target_os = "wasi"))))] mod tests; use crate::fmt; diff --git a/library/std/src/sync/once_lock/tests.rs b/library/std/src/sync/once_lock/tests.rs index 1fff3273d20..5113d436c3c 100644 --- a/library/std/src/sync/once_lock/tests.rs +++ b/library/std/src/sync/once_lock/tests.rs @@ -9,7 +9,7 @@ fn spawn_and_wait<R: Send + 'static>(f: impl FnOnce() -> R + Send + 'static) -> } #[test] -#[cfg_attr(target_os = "emscripten", ignore)] +#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads fn sync_once_cell() { static ONCE_CELL: OnceLock<i32> = OnceLock::new(); @@ -43,7 +43,7 @@ fn sync_once_cell_get_unchecked() { } #[test] -#[cfg_attr(target_os = "emscripten", ignore)] +#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads fn sync_once_cell_drop() { static DROP_CNT: AtomicUsize = AtomicUsize::new(0); struct Dropper; @@ -81,6 +81,7 @@ fn clone() { } #[test] +#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")] fn get_or_try_init() { let cell: OnceLock<String> = OnceLock::new(); assert!(cell.get().is_none()); @@ -154,7 +155,7 @@ fn eval_once_macro() { } #[test] -#[cfg_attr(target_os = "emscripten", ignore)] +#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads fn sync_once_cell_does_not_leak_partially_constructed_boxes() { static ONCE_CELL: OnceLock<String> = OnceLock::new(); diff --git a/library/std/src/sync/reentrant_lock.rs b/library/std/src/sync/reentrant_lock.rs index 39f23a14441..0140e0d2129 100644 --- a/library/std/src/sync/reentrant_lock.rs +++ b/library/std/src/sync/reentrant_lock.rs @@ -1,4 +1,4 @@ -#[cfg(all(test, not(target_os = "emscripten")))] +#[cfg(all(test, not(any(target_os = "emscripten", target_os = "wasi"))))] mod tests; use cfg_if::cfg_if; diff --git a/library/std/src/sync/rwlock.rs b/library/std/src/sync/rwlock.rs index 143bdef736d..da2da6f9dfc 100644 --- a/library/std/src/sync/rwlock.rs +++ b/library/std/src/sync/rwlock.rs @@ -1,4 +1,4 @@ -#[cfg(all(test, not(target_os = "emscripten")))] +#[cfg(all(test, not(any(target_os = "emscripten", target_os = "wasi"))))] mod tests; use crate::cell::UnsafeCell; diff --git a/library/std/src/sys/pal/wasip2/mod.rs b/library/std/src/sys/pal/wasip2/mod.rs index 17b26543bd7..320712fdcc9 100644 --- a/library/std/src/sys/pal/wasip2/mod.rs +++ b/library/std/src/sys/pal/wasip2/mod.rs @@ -20,7 +20,6 @@ pub mod futex; #[path = "../wasi/io.rs"] pub mod io; -#[path = "../wasi/net.rs"] pub mod net; #[path = "../wasi/os.rs"] pub mod os; diff --git a/library/std/src/sys/pal/wasip2/net.rs b/library/std/src/sys/pal/wasip2/net.rs new file mode 100644 index 00000000000..c40eb229ba9 --- /dev/null +++ b/library/std/src/sys/pal/wasip2/net.rs @@ -0,0 +1,379 @@ +#![deny(unsafe_op_in_unsafe_fn)] + +use libc::{c_int, c_void, size_t}; + +use super::fd::WasiFd; +use crate::ffi::CStr; +use crate::io::{self, BorrowedBuf, BorrowedCursor, IoSlice, IoSliceMut}; +use crate::net::{Shutdown, SocketAddr}; +use crate::os::wasi::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd}; +use crate::sys::unsupported; +use crate::sys_common::net::{TcpListener, getsockopt, setsockopt, sockaddr_to_addr}; +use crate::sys_common::{AsInner, FromInner, IntoInner}; +use crate::time::{Duration, Instant}; +use crate::{cmp, mem, str}; + +pub extern crate libc as netc; + +#[allow(non_camel_case_types)] +pub type wrlen_t = size_t; + +#[doc(hidden)] +pub trait IsMinusOne { + fn is_minus_one(&self) -> bool; +} + +macro_rules! impl_is_minus_one { + ($($t:ident)*) => ($(impl IsMinusOne for $t { + fn is_minus_one(&self) -> bool { + *self == -1 + } + })*) +} + +impl_is_minus_one! { i8 i16 i32 i64 isize } + +pub fn cvt<T: IsMinusOne>(t: T) -> crate::io::Result<T> { + if t.is_minus_one() { Err(crate::io::Error::last_os_error()) } else { Ok(t) } +} + +pub fn cvt_r<T, F>(mut f: F) -> crate::io::Result<T> +where + T: IsMinusOne, + F: FnMut() -> T, +{ + loop { + match cvt(f()) { + Err(ref e) if e.is_interrupted() => {} + other => return other, + } + } +} + +pub fn cvt_gai(err: c_int) -> io::Result<()> { + if err == 0 { + return Ok(()); + } + + if err == netc::EAI_SYSTEM { + return Err(io::Error::last_os_error()); + } + + let detail = unsafe { + str::from_utf8(CStr::from_ptr(netc::gai_strerror(err)).to_bytes()).unwrap().to_owned() + }; + + Err(io::Error::new( + io::ErrorKind::Uncategorized, + &format!("failed to lookup address information: {detail}")[..], + )) +} + +pub fn init() {} + +pub struct Socket(WasiFd); + +impl Socket { + pub fn new(addr: &SocketAddr, ty: c_int) -> io::Result<Socket> { + let fam = match *addr { + SocketAddr::V4(..) => netc::AF_INET, + SocketAddr::V6(..) => netc::AF_INET6, + }; + Socket::new_raw(fam, ty) + } + + pub fn new_raw(fam: c_int, ty: c_int) -> io::Result<Socket> { + let fd = cvt(unsafe { netc::socket(fam, ty, 0) })?; + Ok(unsafe { Self::from_raw_fd(fd) }) + } + + pub fn connect(&self, addr: &SocketAddr) -> io::Result<()> { + let (addr, len) = addr.into_inner(); + cvt_r(|| unsafe { netc::connect(self.as_raw_fd(), addr.as_ptr(), len) })?; + Ok(()) + } + + pub fn connect_timeout(&self, addr: &SocketAddr, timeout: Duration) -> io::Result<()> { + self.set_nonblocking(true)?; + let r = self.connect(addr); + self.set_nonblocking(false)?; + + match r { + Ok(_) => return Ok(()), + // there's no ErrorKind for EINPROGRESS + Err(ref e) if e.raw_os_error() == Some(netc::EINPROGRESS) => {} + Err(e) => return Err(e), + } + + let mut pollfd = netc::pollfd { fd: self.as_raw_fd(), events: netc::POLLOUT, revents: 0 }; + + if timeout.as_secs() == 0 && timeout.subsec_nanos() == 0 { + return Err(io::Error::ZERO_TIMEOUT); + } + + let start = Instant::now(); + + loop { + let elapsed = start.elapsed(); + if elapsed >= timeout { + return Err(io::const_io_error!(io::ErrorKind::TimedOut, "connection timed out")); + } + + let timeout = timeout - elapsed; + let mut timeout = timeout + .as_secs() + .saturating_mul(1_000) + .saturating_add(timeout.subsec_nanos() as u64 / 1_000_000); + if timeout == 0 { + timeout = 1; + } + + let timeout = cmp::min(timeout, c_int::MAX as u64) as c_int; + + match unsafe { netc::poll(&mut pollfd, 1, timeout) } { + -1 => { + let err = io::Error::last_os_error(); + if !err.is_interrupted() { + return Err(err); + } + } + 0 => {} + _ => { + // WASI poll does not return POLLHUP or POLLERR in revents. Check if the + // connnection actually succeeded and return ok only when the socket is + // ready and no errors were found. + if let Some(e) = self.take_error()? { + return Err(e); + } + + return Ok(()); + } + } + } + } + + pub fn accept( + &self, + storage: *mut netc::sockaddr, + len: *mut netc::socklen_t, + ) -> io::Result<Socket> { + let fd = cvt_r(|| unsafe { netc::accept(self.as_raw_fd(), storage, len) })?; + Ok(unsafe { Self::from_raw_fd(fd) }) + } + + pub fn duplicate(&self) -> io::Result<Socket> { + unsupported() + } + + fn recv_with_flags(&self, mut buf: BorrowedCursor<'_>, flags: c_int) -> io::Result<()> { + let ret = cvt(unsafe { + netc::recv( + self.as_raw_fd(), + buf.as_mut().as_mut_ptr() as *mut c_void, + buf.capacity(), + flags, + ) + })?; + unsafe { + buf.advance_unchecked(ret as usize); + } + Ok(()) + } + + pub fn read(&self, buf: &mut [u8]) -> io::Result<usize> { + let mut buf = BorrowedBuf::from(buf); + self.recv_with_flags(buf.unfilled(), 0)?; + Ok(buf.len()) + } + + pub fn peek(&self, buf: &mut [u8]) -> io::Result<usize> { + let mut buf = BorrowedBuf::from(buf); + self.recv_with_flags(buf.unfilled(), netc::MSG_PEEK)?; + Ok(buf.len()) + } + + pub fn read_buf(&self, buf: BorrowedCursor<'_>) -> io::Result<()> { + self.recv_with_flags(buf, 0) + } + + pub fn read_vectored(&self, bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> { + io::default_read_vectored(|b| self.read(b), bufs) + } + + #[inline] + pub fn is_read_vectored(&self) -> bool { + false + } + + fn recv_from_with_flags( + &self, + buf: &mut [u8], + flags: c_int, + ) -> io::Result<(usize, SocketAddr)> { + let mut storage: netc::sockaddr_storage = unsafe { mem::zeroed() }; + let mut addrlen = mem::size_of_val(&storage) as netc::socklen_t; + + let n = cvt(unsafe { + netc::recvfrom( + self.as_raw_fd(), + buf.as_mut_ptr() as *mut c_void, + buf.len(), + flags, + core::ptr::addr_of_mut!(storage) as *mut _, + &mut addrlen, + ) + })?; + Ok((n as usize, sockaddr_to_addr(&storage, addrlen as usize)?)) + } + + pub fn recv_from(&self, buf: &mut [u8]) -> io::Result<(usize, SocketAddr)> { + self.recv_from_with_flags(buf, 0) + } + + pub fn peek_from(&self, buf: &mut [u8]) -> io::Result<(usize, SocketAddr)> { + self.recv_from_with_flags(buf, netc::MSG_PEEK) + } + + fn write(&self, buf: &[u8]) -> io::Result<usize> { + let len = cmp::min(buf.len(), <wrlen_t>::MAX as usize) as wrlen_t; + let ret = cvt(unsafe { + netc::send(self.as_raw(), buf.as_ptr() as *const c_void, len, netc::MSG_NOSIGNAL) + })?; + Ok(ret as usize) + } + + pub fn write_vectored(&self, bufs: &[IoSlice<'_>]) -> io::Result<usize> { + io::default_write_vectored(|b| self.write(b), bufs) + } + + #[inline] + pub fn is_write_vectored(&self) -> bool { + false + } + + pub fn set_timeout(&self, dur: Option<Duration>, kind: c_int) -> io::Result<()> { + let timeout = match dur { + Some(dur) => { + if dur.as_secs() == 0 && dur.subsec_nanos() == 0 { + return Err(io::Error::ZERO_TIMEOUT); + } + + let secs = dur.as_secs().try_into().unwrap_or(netc::time_t::MAX); + let mut timeout = netc::timeval { + tv_sec: secs, + tv_usec: dur.subsec_micros() as netc::suseconds_t, + }; + if timeout.tv_sec == 0 && timeout.tv_usec == 0 { + timeout.tv_usec = 1; + } + timeout + } + None => netc::timeval { tv_sec: 0, tv_usec: 0 }, + }; + setsockopt(self, netc::SOL_SOCKET, kind, timeout) + } + + pub fn timeout(&self, kind: c_int) -> io::Result<Option<Duration>> { + let raw: netc::timeval = getsockopt(self, netc::SOL_SOCKET, kind)?; + if raw.tv_sec == 0 && raw.tv_usec == 0 { + Ok(None) + } else { + let sec = raw.tv_sec as u64; + let nsec = (raw.tv_usec as u32) * 1000; + Ok(Some(Duration::new(sec, nsec))) + } + } + + pub fn shutdown(&self, how: Shutdown) -> io::Result<()> { + let how = match how { + Shutdown::Write => netc::SHUT_WR, + Shutdown::Read => netc::SHUT_RD, + Shutdown::Both => netc::SHUT_RDWR, + }; + cvt(unsafe { netc::shutdown(self.as_raw_fd(), how) })?; + Ok(()) + } + + pub fn set_linger(&self, _linger: Option<Duration>) -> io::Result<()> { + unsupported() + } + + pub fn linger(&self) -> io::Result<Option<Duration>> { + unsupported() + } + + pub fn set_nodelay(&self, nodelay: bool) -> io::Result<()> { + setsockopt(self, netc::IPPROTO_TCP, netc::TCP_NODELAY, nodelay as c_int) + } + + pub fn nodelay(&self) -> io::Result<bool> { + let raw: c_int = getsockopt(self, netc::IPPROTO_TCP, netc::TCP_NODELAY)?; + Ok(raw != 0) + } + + pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> { + let mut nonblocking = nonblocking as c_int; + cvt(unsafe { netc::ioctl(self.as_raw_fd(), netc::FIONBIO, &mut nonblocking) }).map(drop) + } + + pub fn take_error(&self) -> io::Result<Option<io::Error>> { + let raw: c_int = getsockopt(self, netc::SOL_SOCKET, netc::SO_ERROR)?; + if raw == 0 { Ok(None) } else { Ok(Some(io::Error::from_raw_os_error(raw as i32))) } + } + + // This is used by sys_common code to abstract over Windows and Unix. + pub fn as_raw(&self) -> RawFd { + self.as_raw_fd() + } +} + +impl AsInner<WasiFd> for Socket { + #[inline] + fn as_inner(&self) -> &WasiFd { + &self.0 + } +} + +impl IntoInner<WasiFd> for Socket { + fn into_inner(self) -> WasiFd { + self.0 + } +} + +impl FromInner<WasiFd> for Socket { + fn from_inner(inner: WasiFd) -> Socket { + Socket(inner) + } +} + +impl AsFd for Socket { + fn as_fd(&self) -> BorrowedFd<'_> { + self.0.as_fd() + } +} + +impl AsRawFd for Socket { + #[inline] + fn as_raw_fd(&self) -> RawFd { + self.0.as_raw_fd() + } +} + +impl IntoRawFd for Socket { + fn into_raw_fd(self) -> RawFd { + self.0.into_raw_fd() + } +} + +impl FromRawFd for Socket { + unsafe fn from_raw_fd(raw_fd: RawFd) -> Self { + unsafe { Self(FromRawFd::from_raw_fd(raw_fd)) } + } +} + +impl AsInner<Socket> for TcpListener { + #[inline] + fn as_inner(&self) -> &Socket { + &self.socket() + } +} diff --git a/library/std/src/sys_common/io.rs b/library/std/src/sys_common/io.rs index e386c955f37..6f6f282d432 100644 --- a/library/std/src/sys_common/io.rs +++ b/library/std/src/sys_common/io.rs @@ -3,7 +3,7 @@ pub const DEFAULT_BUF_SIZE: usize = if cfg!(target_os = "espidf") { 512 } else { 8 * 1024 }; #[cfg(test)] -#[allow(dead_code)] // not used on emscripten +#[allow(dead_code)] // not used on emscripten and wasi pub mod test { use rand::RngCore; diff --git a/library/std/src/sys_common/mod.rs b/library/std/src/sys_common/mod.rs index 1c884f107be..aa27886ff6f 100644 --- a/library/std/src/sys_common/mod.rs +++ b/library/std/src/sys_common/mod.rs @@ -32,7 +32,8 @@ cfg_if::cfg_if! { all(unix, not(target_os = "l4re")), windows, target_os = "hermit", - target_os = "solid_asp3" + target_os = "solid_asp3", + all(target_os = "wasi", target_env = "p2") ))] { pub mod net; } else { diff --git a/library/std/src/thread/local.rs b/library/std/src/thread/local.rs index f147c5fdcd1..88bf186700f 100644 --- a/library/std/src/thread/local.rs +++ b/library/std/src/thread/local.rs @@ -2,7 +2,7 @@ #![unstable(feature = "thread_local_internals", issue = "none")] -#[cfg(all(test, not(target_os = "emscripten")))] +#[cfg(all(test, not(any(target_os = "emscripten", target_os = "wasi"))))] mod tests; #[cfg(test)] diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs index 686f5055ac1..22d65583365 100644 --- a/library/std/src/thread/mod.rs +++ b/library/std/src/thread/mod.rs @@ -155,7 +155,7 @@ // Under `test`, `__FastLocalKeyInner` seems unused. #![cfg_attr(test, allow(dead_code))] -#[cfg(all(test, not(target_os = "emscripten")))] +#[cfg(all(test, not(any(target_os = "emscripten", target_os = "wasi"))))] mod tests; use crate::any::Any; diff --git a/library/std/tests/create_dir_all_bare.rs b/library/std/tests/create_dir_all_bare.rs index 8becf713205..30f800c5aa2 100644 --- a/library/std/tests/create_dir_all_bare.rs +++ b/library/std/tests/create_dir_all_bare.rs @@ -1,4 +1,4 @@ -#![cfg(all(test, not(any(target_os = "emscripten", target_env = "sgx"))))] +#![cfg(all(test, not(any(target_os = "emscripten", target_os = "wasi", target_env = "sgx"))))] //! Note that this test changes the current directory so //! should not be in the same process as other tests. diff --git a/library/std/tests/process_spawning.rs b/library/std/tests/process_spawning.rs index d249eb7d50a..3e72e371ade 100644 --- a/library/std/tests/process_spawning.rs +++ b/library/std/tests/process_spawning.rs @@ -5,7 +5,7 @@ use std::{env, fs, process, str}; mod common; #[test] -#[cfg_attr(miri, ignore)] // Process spawning not supported by Miri +#[cfg_attr(any(miri, target_os = "wasi"), ignore)] // Process spawning not supported by Miri and wasi fn issue_15149() { // If we're the parent, copy our own binary to a new directory. let my_path = env::current_exe().unwrap(); diff --git a/library/std/tests/thread.rs b/library/std/tests/thread.rs index fc9917178b2..83574176186 100644 --- a/library/std/tests/thread.rs +++ b/library/std/tests/thread.rs @@ -4,7 +4,7 @@ use std::thread; use std::time::Duration; #[test] -#[cfg_attr(target_os = "emscripten", ignore)] +#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads #[cfg_attr(miri, ignore)] // Miri does not like the thread leak fn sleep_very_long() { let finished = Arc::new(Mutex::new(false)); diff --git a/src/bootstrap/Cargo.lock b/src/bootstrap/Cargo.lock index 952db063636..efcac4f0953 100644 --- a/src/bootstrap/Cargo.lock +++ b/src/bootstrap/Cargo.lock @@ -84,9 +84,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.19" +version = "1.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d74707dde2ba56f86ae90effb3b43ddd369504387e718014de010cec7959800" +checksum = "9540e661f81799159abee814118cc139a2004b3a3aa3ea37724a1b66530b90e0" dependencies = [ "shlex", ] @@ -99,9 +99,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.5.16" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed6719fffa43d0d87e5fd8caeab59be1554fb028cd30edc88fc4369b17971019" +checksum = "b0956a43b323ac1afaffc053ed5c4b7c1f1800bacd1683c353aabbb752515dd3" dependencies = [ "clap_builder", "clap_derive", @@ -109,9 +109,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.15" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216aec2b177652e3846684cbfe25c9964d18ec45234f0f5da5157b207ed1aab6" +checksum = "4d72166dd41634086d5803a47eb71ae740e61d84709c36f3c34110173db3961b" dependencies = [ "anstyle", "clap_lex", @@ -119,18 +119,18 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.18" +version = "4.5.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ee158892bd7ce77aa15c208abbdb73e155d191c287a659b57abd5adb92feb03" +checksum = "8937760c3f4c60871870b8c3ee5f9b30771f792a7045c48bcbba999d7d6b3b8e" dependencies = [ "clap", ] [[package]] name = "clap_derive" -version = "4.5.13" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" dependencies = [ "heck", "proc-macro2", @@ -161,9 +161,9 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51e852e6dc9a5bed1fae92dd2375037bf2b768725bf3be87811edee3249d09ad" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" dependencies = [ "libc", ] @@ -242,9 +242,9 @@ dependencies = [ [[package]] name = "filetime" -version = "0.2.24" +version = "0.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf401df4a4e3872c4fe8151134cf483738e74b67fc934d6532c882b3d24a4550" +checksum = "35c0522e981e68cbfa8c3f978441a5f34b30b96e146b33cd3359176b50fe8586" dependencies = [ "cfg-if", "libc", @@ -264,9 +264,9 @@ dependencies = [ [[package]] name = "globset" -version = "0.4.14" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1" +checksum = "15f1ce686646e7f1e19bf7d5533fe443a45dbfb990e00629110797578b42fb19" dependencies = [ "aho-corasick", "bstr", @@ -292,9 +292,9 @@ dependencies = [ [[package]] name = "ignore" -version = "0.4.22" +version = "0.4.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b46810df39e66e925525d6e38ce1e7f6e1d208f72dc39757880fcb66e2c58af1" +checksum = "6d89fd380afde86567dfba715db065673989d6253f42b88179abd3eae47bda4b" dependencies = [ "crossbeam-deque", "globset", @@ -314,9 +314,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "junction" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c9c415a9b7b1e86cd5738f39d34c9e78c765da7fb1756dbd7d31b3b0d2e7afa" +checksum = "72bbdfd737a243da3dfc1f99ee8d6e166480f17ab4ac84d7c34aacd73fc7bd16" dependencies = [ "scopeguard", "windows-sys 0.52.0", @@ -324,9 +324,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.157" +version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374af5f94e54fa97cf75e945cce8a6b201e88a1a07e688b47dfd2a59c66dbd86" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" [[package]] name = "libredox" @@ -379,9 +379,9 @@ dependencies = [ [[package]] name = "object" -version = "0.36.3" +version = "0.36.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27b64972346851a39438c60b341ebc01bba47464ae329e55cf343eb93964efd9" +checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" dependencies = [ "memchr", ] @@ -398,15 +398,15 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "pretty_assertions" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af7cee1a6c8a5b9208b3cb1061f10c0cb689087b3d8ce85fb9d2dd7a29b6ba66" +checksum = "3ae130e2f271fbc2ac3a40fb1d07180839cdbbe443c7a27e1e3c13c5cac0116d" dependencies = [ "diff", "yansi", @@ -423,18 +423,18 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] [[package]] name = "redox_syscall" -version = "0.5.3" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" +checksum = "355ae415ccd3a04315d3f8246e86d67689ea74d88d915576e1589a351062a13b" dependencies = [ "bitflags", ] @@ -458,9 +458,9 @@ checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "rustix" -version = "0.38.34" +version = "0.38.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" dependencies = [ "bitflags", "errno", @@ -498,18 +498,18 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.208" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff085d2cb684faa248efb494c39b68e522822ac0de72ccf08109abde717cfb2" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.208" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24008e81ff7613ed8e5ba0cfaf24e2c2f1e5b8a0495711e44fcd4882fca62bcf" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", @@ -518,9 +518,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.125" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83c8e735a073ccf5be70aa8066aa984eaf2fa000db6c8d0100ae605b366d31ed" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ "itoa", "memchr", @@ -547,9 +547,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "syn" -version = "2.0.75" +version = "2.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6af063034fc1935ede7be0122941bafa9bacb949334d090b77ca98b5817c7d9" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" dependencies = [ "proc-macro2", "quote", @@ -558,9 +558,9 @@ dependencies = [ [[package]] name = "sysinfo" -version = "0.31.2" +version = "0.31.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4115055da5f572fff541dd0c4e61b0262977f453cc9fe04be83aba25a89bdab" +checksum = "355dbe4f8799b304b05e1b0f05fc59b2a18d36645cf169607da45bde2f69a1be" dependencies = [ "core-foundation-sys", "libc", @@ -571,9 +571,9 @@ dependencies = [ [[package]] name = "tar" -version = "0.4.41" +version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb797dad5fb5b76fcf519e702f4a589483b5ef06567f160c392832c1f5e44909" +checksum = "4ff6c40d3aedb5e06b57c6f669ad17ab063dd1e63d977c6a88e7f4dfa4f04020" dependencies = [ "filetime", "libc", @@ -606,9 +606,9 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "version_check" @@ -833,6 +833,6 @@ dependencies = [ [[package]] name = "yansi" -version = "0.5.1" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" +checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" diff --git a/src/bootstrap/Cargo.toml b/src/bootstrap/Cargo.toml index 1959d0a9662..ba505089a00 100644 --- a/src/bootstrap/Cargo.toml +++ b/src/bootstrap/Cargo.toml @@ -37,7 +37,7 @@ test = false # Most of the time updating these dependencies requires modifications to the # bootstrap codebase(e.g., https://github.com/rust-lang/rust/issues/124565); # otherwise, some targets will fail. That's why these dependencies are explicitly pinned. -cc = "=1.1.19" +cc = "=1.1.22" cmake = "=0.1.48" build_helper = { path = "../tools/build_helper" } diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index eaa982d4e2b..bb1d8d27928 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -1053,10 +1053,6 @@ pub fn rustc_cargo( cargo.rustdocflag("-Zcrate-attr=warn(rust_2018_idioms)"); - // If the rustc output is piped to e.g. `head -n1` we want the process to be - // killed, rather than having an error bubble up and cause a panic. - cargo.rustflag("-Zon-broken-pipe=kill"); - if builder.config.llvm_enzyme { cargo.rustflag("-l").rustflag("Enzyme-19"); } diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 870fe6a9f16..7283b0e9574 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -1792,6 +1792,10 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the cmd.arg("--host").arg(&*compiler.host.triple); cmd.arg("--llvm-filecheck").arg(builder.llvm_filecheck(builder.config.build)); + if builder.build.config.llvm_enzyme { + cmd.arg("--has-enzyme"); + } + if builder.config.cmd.bless() { cmd.arg("--bless"); } diff --git a/src/bootstrap/src/core/build_steps/tool.rs b/src/bootstrap/src/core/build_steps/tool.rs index 64dfe054d9c..fa2c1b8360f 100644 --- a/src/bootstrap/src/core/build_steps/tool.rs +++ b/src/bootstrap/src/core/build_steps/tool.rs @@ -200,6 +200,10 @@ pub fn prepare_tool_cargo( cargo.arg("--features").arg(features.join(", ")); } + // Warning: be very careful with RUSTFLAGS or command-line options, as conditionally applied + // RUSTFLAGS or cli flags can lead to hard-to-diagnose rebuilds due to flag differences, causing + // previous tool build artifacts to get invalidated. + // Enable internal lints for clippy and rustdoc // NOTE: this doesn't enable lints for any other tools unless they explicitly add `#![warn(rustc::internal)]` // See https://github.com/rust-lang/rust/pull/80573#issuecomment-754010776 @@ -209,13 +213,6 @@ pub fn prepare_tool_cargo( // See https://github.com/rust-lang/rust/issues/116538 cargo.rustflag("-Zunstable-options"); - // `-Zon-broken-pipe=kill` breaks cargo tests - if !path.ends_with("cargo") { - // If the output is piped to e.g. `head -n1` we want the process to be killed, - // rather than having an error bubble up and cause a panic. - cargo.rustflag("-Zon-broken-pipe=kill"); - } - cargo } diff --git a/src/bootstrap/src/core/builder.rs b/src/bootstrap/src/core/builder.rs index 6ba669f3b10..c35384ce3c0 100644 --- a/src/bootstrap/src/core/builder.rs +++ b/src/bootstrap/src/core/builder.rs @@ -1564,8 +1564,8 @@ impl<'a> Builder<'a> { let libdir = self.rustc_libdir(compiler); let sysroot_str = sysroot.as_os_str().to_str().expect("sysroot should be UTF-8"); - if !matches!(self.config.dry_run, DryRun::SelfCheck) { - self.verbose_than(0, || println!("using sysroot {sysroot_str}")); + if self.is_verbose() && !matches!(self.config.dry_run, DryRun::SelfCheck) { + println!("using sysroot {sysroot_str}"); } let mut rustflags = Rustflags::new(target); @@ -2014,6 +2014,11 @@ impl<'a> Builder<'a> { cargo.env("RUSTC_BACKTRACE_ON_ICE", "1"); } + if self.is_verbose() { + // This provides very useful logs especially when debugging build cache-related stuff. + cargo.env("CARGO_LOG", "cargo::core::compiler::fingerprint=info"); + } + cargo.env("RUSTC_VERBOSE", self.verbosity.to_string()); // Downstream forks of the Rust compiler might want to use a custom libc to add support for diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 3c0afb858f8..07460b81412 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -2450,7 +2450,7 @@ impl Config { /// Runs a function if verbosity is greater than 0 pub fn verbose(&self, f: impl Fn()) { - if self.verbose > 0 { + if self.is_verbose() { f() } } @@ -2735,7 +2735,7 @@ impl Config { .success(); if has_changes { if if_unchanged { - if self.verbose > 0 { + if self.is_verbose() { println!( "WARNING: saw changes to compiler/ or library/ since {commit}; \ ignoring `download-rustc`" @@ -2832,7 +2832,7 @@ impl Config { let has_changes = !t!(git.as_command_mut().status()).success(); if has_changes { if if_unchanged { - if self.verbose > 0 { + if self.is_verbose() { println!( "warning: saw changes to one of {modified_paths:?} since {commit}; \ ignoring `{option_name}`" diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index 4805e598ce2..75659f46431 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -1370,7 +1370,7 @@ Executed at: {executed_at}"#, } if target.starts_with("wasm") && target.contains("wasi") { - self.default_wasi_runner() + self.default_wasi_runner(target) } else { None } @@ -1379,7 +1379,7 @@ Executed at: {executed_at}"#, /// When a `runner` configuration is not provided and a WASI-looking target /// is being tested this is consulted to prove the environment to see if /// there's a runtime already lying around that seems reasonable to use. - fn default_wasi_runner(&self) -> Option<String> { + fn default_wasi_runner(&self, target: TargetSelection) -> Option<String> { let mut finder = crate::core::sanity::Finder::new(); // Look for Wasmtime, and for its default options be sure to disable @@ -1395,6 +1395,11 @@ Executed at: {executed_at}"#, // inherit the entire environment rather than just this single // environment variable. path.push_str(" --env RUSTC_BOOTSTRAP"); + + if target.contains("wasip2") { + path.push_str(" --wasi inherit-network --wasi allow-ip-name-lookup"); + } + return Some(path); } } diff --git a/src/doc/rustdoc/src/write-documentation/linking-to-items-by-name.md b/src/doc/rustdoc/src/write-documentation/linking-to-items-by-name.md index 1a367b8274b..5e785483402 100644 --- a/src/doc/rustdoc/src/write-documentation/linking-to-items-by-name.md +++ b/src/doc/rustdoc/src/write-documentation/linking-to-items-by-name.md @@ -89,8 +89,8 @@ fn Foo() {} These prefixes will be stripped when displayed in the documentation, so `[struct@Foo]` will be rendered as `Foo`. The following prefixes are available: `struct`, `enum`, `trait`, `union`, -`mod`, `module`, `const`, `constant`, `fn`, `function`, `method`, `derive`, `type`, `value`, -`macro`, `prim` or `primitive`. +`mod`, `module`, `const`, `constant`, `fn`, `function`, `field`, `variant`, `method`, `derive`, +`type`, `value`, `macro`, `prim` or `primitive`. You can also disambiguate for functions by adding `()` after the function name, or for macros by adding `!` after the macro name. The macro `!` can be followed by `()`, `{}`, diff --git a/src/doc/unstable-book/src/compiler-flags/print-check-cfg.md b/src/doc/unstable-book/src/compiler-flags/print-check-cfg.md index ab63c986e85..8d314aa62d4 100644 --- a/src/doc/unstable-book/src/compiler-flags/print-check-cfg.md +++ b/src/doc/unstable-book/src/compiler-flags/print-check-cfg.md @@ -4,23 +4,28 @@ The tracking issue for this feature is: [#125704](https://github.com/rust-lang/r ------------------------ -This option of the `--print` flag print the list of expected cfgs. +This option of the `--print` flag print the list of all the expected cfgs. -This is related to the `--check-cfg` flag which allows specifying arbitrary expected +This is related to the [`--check-cfg` flag][check-cfg] which allows specifying arbitrary expected names and values. -This print option works similarly to `--print=cfg` (modulo check-cfg specifics): - - *check_cfg syntax*: *output of --print=check-cfg* - - `cfg(windows)`: `windows` - - `cfg(feature, values("foo", "bar"))`: `feature="foo"` and `feature="bar"` - - `cfg(feature, values(none(), ""))`: `feature` and `feature=""` - - `cfg(feature, values(any()))`: `feature=any()` - - `cfg(feature, values())`: `feature=` - - `cfg(any())`: `any()` - - *nothing*: `any()=any()` +This print option works similarly to `--print=cfg` (modulo check-cfg specifics). + +| `--check-cfg` | `--print=check-cfg` | +|-----------------------------------|-----------------------------| +| `cfg(foo)` | `foo` | +| `cfg(foo, values("bar"))` | `foo="bar"` | +| `cfg(foo, values(none(), "bar"))` | `foo` & `foo="bar"` | +| | *check-cfg specific syntax* | +| `cfg(foo, values(any())` | `foo=any()` | +| `cfg(foo, values())` | `foo=` | +| `cfg(any())` | `any()` | +| *none* | `any()=any()` | To be used like this: ```bash rustc --print=check-cfg -Zunstable-options lib.rs ``` + +[check-cfg]: https://doc.rust-lang.org/nightly/rustc/check-cfg.html diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index 08c88fc950d..d966f993104 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -117,6 +117,7 @@ fn synthesize_auto_trait_impl<'tcx>( name: None, inner: Box::new(clean::ItemInner { attrs: Default::default(), + stability: None, kind: clean::ImplItem(Box::new(clean::Impl { safety: hir::Safety::Safe, generics, diff --git a/src/librustdoc/clean/blanket_impl.rs b/src/librustdoc/clean/blanket_impl.rs index 36821294885..1f3cb4a61b8 100644 --- a/src/librustdoc/clean/blanket_impl.rs +++ b/src/librustdoc/clean/blanket_impl.rs @@ -87,6 +87,7 @@ pub(crate) fn synthesize_blanket_impls( item_id: clean::ItemId::Blanket { impl_id: impl_def_id, for_: item_def_id }, inner: Box::new(clean::ItemInner { attrs: Default::default(), + stability: None, kind: clean::ImplItem(Box::new(clean::Impl { safety: hir::Safety::Safe, generics: clean_ty_generics( diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index d3c4ef4dc90..e7f921eef7f 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -672,6 +672,7 @@ fn build_module_items( item_id: ItemId::DefId(did), inner: Box::new(clean::ItemInner { attrs: Default::default(), + stability: None, kind: clean::ImportItem(clean::Import::new_simple( item.ident.name, clean::ImportSource { diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index b9c5e8e787b..a3277e8ca92 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -6,7 +6,7 @@ use std::{fmt, iter}; use arrayvec::ArrayVec; use rustc_ast_pretty::pprust; -use rustc_attr::{ConstStability, Deprecation, Stability, StabilityLevel, StableSince}; +use rustc_attr::{ConstStability, Deprecation, Stability, StableSince}; use rustc_const_eval::const_eval::is_unstable_const_fn; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir::def::{CtorKind, DefKind, Res}; @@ -333,6 +333,8 @@ pub(crate) struct ItemInner { /// E.g., struct vs enum vs function. pub(crate) kind: ItemKind, pub(crate) attrs: Attributes, + /// The effective stability, filled out by the `propagate-stability` pass. + pub(crate) stability: Option<Stability>, } impl std::ops::Deref for Item { @@ -381,46 +383,17 @@ fn is_field_vis_inherited(tcx: TyCtxt<'_>, def_id: DefId) -> bool { } impl Item { + /// Returns the effective stability of the item. + /// + /// This method should only be called after the `propagate-stability` pass has been run. pub(crate) fn stability(&self, tcx: TyCtxt<'_>) -> Option<Stability> { - let (mut def_id, mut stability) = if let Some(inlined) = self.inline_stmt_id { - let inlined_def_id = inlined.to_def_id(); - if let Some(stability) = tcx.lookup_stability(inlined_def_id) { - (inlined_def_id, stability) - } else { - // For re-exports into crates without `staged_api`, reuse the original stability. - // This is necessary, because we always want to mark unstable items. - let def_id = self.def_id()?; - return tcx.lookup_stability(def_id); - } - } else { - let def_id = self.def_id()?; - let stability = tcx.lookup_stability(def_id)?; - (def_id, stability) - }; - - let StabilityLevel::Stable { mut since, allowed_through_unstable_modules: false } = - stability.level - else { - return Some(stability); - }; - - // If any of the item's ancestors was stabilized later or is still unstable, - // then report the ancestor's stability instead. - while let Some(parent_def_id) = tcx.opt_parent(def_id) { - if let Some(parent_stability) = tcx.lookup_stability(parent_def_id) { - match parent_stability.level { - StabilityLevel::Unstable { .. } => return Some(parent_stability), - StabilityLevel::Stable { since: parent_since, .. } => { - if parent_since > since { - stability = parent_stability; - since = parent_since; - } - } - } - } - def_id = parent_def_id; - } - Some(stability) + let stability = self.inner.stability; + debug_assert!( + stability.is_some() + || self.def_id().is_none_or(|did| tcx.lookup_stability(did).is_none()), + "missing stability for cleaned item: {self:?}", + ); + stability } pub(crate) fn const_stability(&self, tcx: TyCtxt<'_>) -> Option<ConstStability> { @@ -502,7 +475,7 @@ impl Item { Item { item_id: def_id.into(), - inner: Box::new(ItemInner { kind, attrs }), + inner: Box::new(ItemInner { kind, attrs, stability: None }), name, cfg, inline_stmt_id: None, @@ -638,10 +611,7 @@ impl Item { } pub(crate) fn stable_since(&self, tcx: TyCtxt<'_>) -> Option<StableSince> { - match self.stability(tcx)?.level { - StabilityLevel::Stable { since, .. } => Some(since), - StabilityLevel::Unstable { .. } => None, - } + self.stability(tcx).and_then(|stability| stability.stable_since()) } pub(crate) fn is_non_exhaustive(&self) -> bool { diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index d120e7f36eb..38276e4d20c 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -436,16 +436,9 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items: } clean::ImportItem(ref import) => { - let stab_tags = if let Some(import_def_id) = import.source.did { - // Just need an item with the correct def_id and attrs - let import_item = - clean::Item { item_id: import_def_id.into(), ..(*myitem).clone() }; - - let stab_tags = Some(extra_info_tags(&import_item, item, tcx).to_string()); - stab_tags - } else { - None - }; + let stab_tags = import.source.did.map_or_else(String::new, |import_def_id| { + extra_info_tags(tcx, myitem, item, Some(import_def_id)).to_string() + }); w.write_str(ITEM_TABLE_ROW_OPEN); let id = match import.kind { @@ -454,7 +447,6 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items: } clean::ImportKind::Glob => String::new(), }; - let stab_tags = stab_tags.unwrap_or_default(); let (stab_tags_before, stab_tags_after) = if stab_tags.is_empty() { ("", "") } else { @@ -521,7 +513,7 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items: {docs_before}{docs}{docs_after}", name = EscapeBodyTextWithWbr(myitem.name.unwrap().as_str()), visibility_and_hidden = visibility_and_hidden, - stab_tags = extra_info_tags(myitem, item, tcx), + stab_tags = extra_info_tags(tcx, myitem, item, None), class = myitem.type_(), unsafety_flag = unsafety_flag, href = item_path(myitem.type_(), myitem.name.unwrap().as_str()), @@ -544,9 +536,10 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items: /// Render the stability, deprecation and portability tags that are displayed in the item's summary /// at the module level. fn extra_info_tags<'a, 'tcx: 'a>( + tcx: TyCtxt<'tcx>, item: &'a clean::Item, parent: &'a clean::Item, - tcx: TyCtxt<'tcx>, + import_def_id: Option<DefId>, ) -> impl fmt::Display + 'a + Captures<'tcx> { display_fn(move |f| { fn tag_html<'a>( @@ -564,18 +557,18 @@ fn extra_info_tags<'a, 'tcx: 'a>( } // The trailing space after each tag is to space it properly against the rest of the docs. - if let Some(depr) = &item.deprecation(tcx) { + let deprecation = import_def_id + .map_or_else(|| item.deprecation(tcx), |import_did| tcx.lookup_deprecation(import_did)); + if let Some(depr) = deprecation { let message = if depr.is_in_effect() { "Deprecated" } else { "Deprecation planned" }; write!(f, "{}", tag_html("deprecated", "", message))?; } // The "rustc_private" crates are permanently unstable so it makes no sense // to render "unstable" everywhere. - if item - .stability(tcx) - .as_ref() - .is_some_and(|s| s.is_unstable() && s.feature != sym::rustc_private) - { + let stability = import_def_id + .map_or_else(|| item.stability(tcx), |import_did| tcx.lookup_stability(import_did)); + if stability.is_some_and(|s| s.is_unstable() && s.feature != sym::rustc_private) { write!(f, "{}", tag_html("unstable", "", "Experimental"))?; } diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index 0d556e0a682..984b0877d8d 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -1828,11 +1828,15 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.htm return; } but.onclick = () => { - const path = []; - onEachLazy(document.querySelectorAll(".rustdoc-breadcrumbs a"), a => { - path.push(a.textContent); - }); - path.push(document.querySelector("title").textContent.split(" ")[0]); + // Most page titles are '<Item> in <path::to::module> - Rust', except + // modules (which don't have the first part) and keywords/primitives + // (which don't have a module path) + const title = document.querySelector("title").textContent.replace(" - Rust", ""); + const [item, module] = title.split(" in "); + const path = [item]; + if (module !== undefined) { + path.unshift(module); + } copyContentToClipboard(path.join("::")); copyButtonAnimation(but); diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index e95e8762b1d..0dba16cbaf3 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -110,7 +110,6 @@ impl Res { let prefix = match kind { DefKind::Fn | DefKind::AssocFn => return Suggestion::Function, - DefKind::Field => return Suggestion::RemoveDisambiguator, DefKind::Macro(MacroKind::Bang) => return Suggestion::Macro, DefKind::Macro(MacroKind::Derive) => "derive", @@ -123,6 +122,8 @@ impl Res { "const" } DefKind::Static { .. } => "static", + DefKind::Field => "field", + DefKind::Variant | DefKind::Ctor(..) => "variant", // Now handle things that don't have a specific disambiguator _ => match kind .ns() @@ -415,6 +416,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { &mut self, path_str: &'path str, ns: Namespace, + disambiguator: Option<Disambiguator>, item_id: DefId, module_id: DefId, ) -> Result<Vec<(Res, Option<DefId>)>, UnresolvedPath<'path>> { @@ -454,7 +456,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { match resolve_primitive(path_root, TypeNS) .or_else(|| self.resolve_path(path_root, TypeNS, item_id, module_id)) .map(|ty_res| { - self.resolve_associated_item(ty_res, item_name, ns, module_id) + self.resolve_associated_item(ty_res, item_name, ns, disambiguator, module_id) .into_iter() .map(|(res, def_id)| (res, Some(def_id))) .collect::<Vec<_>>() @@ -557,6 +559,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { root_res: Res, item_name: Symbol, ns: Namespace, + disambiguator: Option<Disambiguator>, module_id: DefId, ) -> Vec<(Res, DefId)> { let tcx = self.cx.tcx; @@ -583,7 +586,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { // FIXME: if the associated item is defined directly on the type alias, // it will show up on its documentation page, we should link there instead. let Some(res) = self.def_id_to_res(did) else { return Vec::new() }; - self.resolve_associated_item(res, item_name, ns, module_id) + self.resolve_associated_item(res, item_name, ns, disambiguator, module_id) } Res::Def( def_kind @ (DefKind::Struct | DefKind::Union | DefKind::Enum | DefKind::ForeignTy), @@ -604,6 +607,39 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { } } + let search_for_field = || { + let (DefKind::Struct | DefKind::Union) = def_kind else { return vec![] }; + debug!("looking for fields named {item_name} for {did:?}"); + // FIXME: this doesn't really belong in `associated_item` (maybe `variant_field` is better?) + // NOTE: it's different from variant_field because it only resolves struct fields, + // not variant fields (2 path segments, not 3). + // + // We need to handle struct (and union) fields in this code because + // syntactically their paths are identical to associated item paths: + // `module::Type::field` and `module::Type::Assoc`. + // + // On the other hand, variant fields can't be mistaken for associated + // items because they look like this: `module::Type::Variant::field`. + // + // Variants themselves don't need to be handled here, even though + // they also look like associated items (`module::Type::Variant`), + // because they are real Rust syntax (unlike the intra-doc links + // field syntax) and are handled by the compiler's resolver. + let ty::Adt(def, _) = tcx.type_of(did).instantiate_identity().kind() else { + unreachable!() + }; + def.non_enum_variant() + .fields + .iter() + .filter(|field| field.name == item_name) + .map(|field| (root_res, field.did)) + .collect::<Vec<_>>() + }; + + if let Some(Disambiguator::Kind(DefKind::Field)) = disambiguator { + return search_for_field(); + } + // Checks if item_name belongs to `impl SomeItem` let mut assoc_items: Vec<_> = tcx .inherent_impls(did) @@ -646,32 +682,8 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { if ns != Namespace::ValueNS { return Vec::new(); } - debug!("looking for fields named {item_name} for {did:?}"); - // FIXME: this doesn't really belong in `associated_item` (maybe `variant_field` is better?) - // NOTE: it's different from variant_field because it only resolves struct fields, - // not variant fields (2 path segments, not 3). - // - // We need to handle struct (and union) fields in this code because - // syntactically their paths are identical to associated item paths: - // `module::Type::field` and `module::Type::Assoc`. - // - // On the other hand, variant fields can't be mistaken for associated - // items because they look like this: `module::Type::Variant::field`. - // - // Variants themselves don't need to be handled here, even though - // they also look like associated items (`module::Type::Variant`), - // because they are real Rust syntax (unlike the intra-doc links - // field syntax) and are handled by the compiler's resolver. - let def = match tcx.type_of(did).instantiate_identity().kind() { - ty::Adt(def, _) if !def.is_enum() => def, - _ => return Vec::new(), - }; - def.non_enum_variant() - .fields - .iter() - .filter(|field| field.name == item_name) - .map(|field| (root_res, field.did)) - .collect::<Vec<_>>() + + search_for_field() } Res::Def(DefKind::Trait, did) => filter_assoc_items_by_name_and_namespace( tcx, @@ -1297,7 +1309,7 @@ impl LinkCollector<'_, '_> { match disambiguator.map(Disambiguator::ns) { Some(expected_ns) => { - match self.resolve(path_str, expected_ns, item_id, module_id) { + match self.resolve(path_str, expected_ns, disambiguator, item_id, module_id) { Ok(candidates) => candidates, Err(err) => { // We only looked in one namespace. Try to give a better error if possible. @@ -1306,8 +1318,9 @@ impl LinkCollector<'_, '_> { let mut err = ResolutionFailure::NotResolved(err); for other_ns in [TypeNS, ValueNS, MacroNS] { if other_ns != expected_ns { - if let Ok(&[res, ..]) = - self.resolve(path_str, other_ns, item_id, module_id).as_deref() + if let Ok(&[res, ..]) = self + .resolve(path_str, other_ns, None, item_id, module_id) + .as_deref() { err = ResolutionFailure::WrongNamespace { res: full_res(self.cx.tcx, res), @@ -1327,7 +1340,7 @@ impl LinkCollector<'_, '_> { None => { // Try everything! let mut candidate = |ns| { - self.resolve(path_str, ns, item_id, module_id) + self.resolve(path_str, ns, None, item_id, module_id) .map_err(ResolutionFailure::NotResolved) }; @@ -1531,6 +1544,8 @@ impl Disambiguator { }), "function" | "fn" | "method" => Kind(DefKind::Fn), "derive" => Kind(DefKind::Macro(MacroKind::Derive)), + "field" => Kind(DefKind::Field), + "variant" => Kind(DefKind::Variant), "type" => NS(Namespace::TypeNS), "value" => NS(Namespace::ValueNS), "macro" => NS(Namespace::MacroNS), @@ -1569,6 +1584,8 @@ impl Disambiguator { fn ns(self) -> Namespace { match self { Self::Namespace(n) => n, + // for purposes of link resolution, fields are in the value namespace. + Self::Kind(DefKind::Field) => ValueNS, Self::Kind(k) => { k.ns().expect("only DefKinds with a valid namespace can be disambiguators") } @@ -1603,8 +1620,6 @@ enum Suggestion { Function, /// `m!` Macro, - /// `foo` without any disambiguator - RemoveDisambiguator, } impl Suggestion { @@ -1613,7 +1628,6 @@ impl Suggestion { Self::Prefix(x) => format!("prefix with `{x}@`").into(), Self::Function => "add parentheses".into(), Self::Macro => "add an exclamation mark".into(), - Self::RemoveDisambiguator => "remove the disambiguator".into(), } } @@ -1623,13 +1637,11 @@ impl Suggestion { Self::Prefix(prefix) => format!("{prefix}@{path_str}"), Self::Function => format!("{path_str}()"), Self::Macro => format!("{path_str}!"), - Self::RemoveDisambiguator => path_str.into(), } } fn as_help_span( &self, - path_str: &str, ori_link: &str, sp: rustc_span::Span, ) -> Vec<(rustc_span::Span, String)> { @@ -1677,7 +1689,6 @@ impl Suggestion { } sugg } - Self::RemoveDisambiguator => vec![(sp, path_str.into())], } } } @@ -1826,7 +1837,9 @@ fn resolution_failure( }; name = start; for ns in [TypeNS, ValueNS, MacroNS] { - if let Ok(v_res) = collector.resolve(start, ns, item_id, module_id) { + if let Ok(v_res) = + collector.resolve(start, ns, None, item_id, module_id) + { debug!("found partial_res={v_res:?}"); if let Some(&res) = v_res.first() { *partial_res = Some(full_res(tcx, res)); @@ -2164,7 +2177,7 @@ fn suggest_disambiguator( }; if let (Some(sp), Some(ori_link)) = (sp, ori_link) { - let mut spans = suggestion.as_help_span(path_str, ori_link, sp); + let mut spans = suggestion.as_help_span(ori_link, sp); if spans.len() > 1 { diag.multipart_suggestion(help, spans, Applicability::MaybeIncorrect); } else { diff --git a/src/librustdoc/passes/mod.rs b/src/librustdoc/passes/mod.rs index b1dc766049d..f5b78023721 100644 --- a/src/librustdoc/passes/mod.rs +++ b/src/librustdoc/passes/mod.rs @@ -23,6 +23,9 @@ pub(crate) use self::strip_priv_imports::STRIP_PRIV_IMPORTS; mod propagate_doc_cfg; pub(crate) use self::propagate_doc_cfg::PROPAGATE_DOC_CFG; +mod propagate_stability; +pub(crate) use self::propagate_stability::PROPAGATE_STABILITY; + pub(crate) mod collect_intra_doc_links; pub(crate) use self::collect_intra_doc_links::COLLECT_INTRA_DOC_LINKS; @@ -75,6 +78,7 @@ pub(crate) const PASSES: &[Pass] = &[ STRIP_PRIVATE, STRIP_PRIV_IMPORTS, PROPAGATE_DOC_CFG, + PROPAGATE_STABILITY, COLLECT_INTRA_DOC_LINKS, COLLECT_TRAIT_IMPLS, CALCULATE_DOC_COVERAGE, @@ -91,6 +95,7 @@ pub(crate) const DEFAULT_PASSES: &[ConditionalPass] = &[ ConditionalPass::new(STRIP_PRIV_IMPORTS, WhenDocumentPrivate), ConditionalPass::always(COLLECT_INTRA_DOC_LINKS), ConditionalPass::always(PROPAGATE_DOC_CFG), + ConditionalPass::always(PROPAGATE_STABILITY), ConditionalPass::always(RUN_LINTS), ]; diff --git a/src/librustdoc/passes/propagate_stability.rs b/src/librustdoc/passes/propagate_stability.rs new file mode 100644 index 00000000000..f51e993bfa5 --- /dev/null +++ b/src/librustdoc/passes/propagate_stability.rs @@ -0,0 +1,72 @@ +//! Propagates stability to child items. +//! +//! The purpose of this pass is to make items whose parents are "more unstable" +//! than the item itself inherit the parent's stability. +//! For example, [`core::error::Error`] is marked as stable since 1.0.0, but the +//! [`core::error`] module is marked as stable since 1.81.0, so we want to show +//! [`core::error::Error`] as stable since 1.81.0 as well. + +use rustc_attr::{Stability, StabilityLevel}; +use rustc_hir::def_id::CRATE_DEF_ID; + +use crate::clean::{Crate, Item, ItemId}; +use crate::core::DocContext; +use crate::fold::DocFolder; +use crate::passes::Pass; + +pub(crate) const PROPAGATE_STABILITY: Pass = Pass { + name: "propagate-stability", + run: propagate_stability, + description: "propagates stability to child items", +}; + +pub(crate) fn propagate_stability(cr: Crate, cx: &mut DocContext<'_>) -> Crate { + let crate_stability = cx.tcx.lookup_stability(CRATE_DEF_ID); + StabilityPropagator { parent_stability: crate_stability, cx }.fold_crate(cr) +} + +struct StabilityPropagator<'a, 'tcx> { + parent_stability: Option<Stability>, + cx: &'a mut DocContext<'tcx>, +} + +impl<'a, 'tcx> DocFolder for StabilityPropagator<'a, 'tcx> { + fn fold_item(&mut self, mut item: Item) -> Option<Item> { + let parent_stability = self.parent_stability; + + let stability = match item.item_id { + ItemId::DefId(def_id) => { + let own_stability = self.cx.tcx.lookup_stability(def_id); + + // If any of the item's parents was stabilized later or is still unstable, + // then use the parent's stability instead. + if let Some(own_stab) = own_stability + && let StabilityLevel::Stable { + since: own_since, + allowed_through_unstable_modules: false, + } = own_stab.level + && let Some(parent_stab) = parent_stability + && (parent_stab.is_unstable() + || parent_stab + .stable_since() + .is_some_and(|parent_since| parent_since > own_since)) + { + parent_stability + } else { + own_stability + } + } + ItemId::Auto { .. } | ItemId::Blanket { .. } => { + // For now, we do now show stability for synthesized impls. + None + } + }; + + item.inner.stability = stability; + self.parent_stability = stability; + let item = self.fold_item_recur(item); + self.parent_stability = parent_stability; + + Some(item) + } +} diff --git a/src/tools/compiletest/src/command-list.rs b/src/tools/compiletest/src/command-list.rs index 865aa76ddb0..a4cedbf66e2 100644 --- a/src/tools/compiletest/src/command-list.rs +++ b/src/tools/compiletest/src/command-list.rs @@ -139,6 +139,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[ "needs-deterministic-layouts", "needs-dlltool", "needs-dynamic-linking", + "needs-enzyme", "needs-force-clang-based-tests", "needs-git-hash", "needs-llvm-components", diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 2d8c0c3fa5e..adc89cad72f 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -349,6 +349,9 @@ pub struct Config { /// whether to run `tidy` when a rustdoc test fails pub has_tidy: bool, + /// whether to run `enzyme` autodiff tests + pub has_enzyme: bool, + /// The current Rust channel pub channel: String, diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 6a889d27793..83a10c56208 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -218,6 +218,8 @@ pub struct TestProps { pub filecheck_flags: Vec<String>, /// Don't automatically insert any `--check-cfg` args pub no_auto_check_cfg: bool, + /// Run tests which require enzyme being build + pub has_enzyme: bool, } mod directives { @@ -322,6 +324,7 @@ impl TestProps { llvm_cov_flags: vec![], filecheck_flags: vec![], no_auto_check_cfg: false, + has_enzyme: false, } } diff --git a/src/tools/compiletest/src/header/needs.rs b/src/tools/compiletest/src/header/needs.rs index 99c0e850f1a..f5dd722ed37 100644 --- a/src/tools/compiletest/src/header/needs.rs +++ b/src/tools/compiletest/src/header/needs.rs @@ -80,6 +80,11 @@ pub(super) fn handle_needs( ignore_reason: "ignored on targets without SafeStack support", }, Need { + name: "needs-enzyme", + condition: config.has_enzyme, + ignore_reason: "ignored when LLVM Enzyme is disabled", + }, + Need { name: "needs-run-enabled", condition: config.run_enabled(), ignore_reason: "ignored when running the resulting test binaries is disabled", diff --git a/src/tools/compiletest/src/lib.rs b/src/tools/compiletest/src/lib.rs index cfc619f9342..a8355ee9590 100644 --- a/src/tools/compiletest/src/lib.rs +++ b/src/tools/compiletest/src/lib.rs @@ -83,6 +83,7 @@ pub fn parse_config(args: Vec<String>) -> Config { ) .optopt("", "run", "whether to execute run-* tests", "auto | always | never") .optflag("", "ignored", "run tests marked as ignored") + .optflag("", "has-enzyme", "run tests that require enzyme") .optflag("", "with-debug-assertions", "whether to run tests with `ignore-debug` header") .optmulti( "", @@ -233,6 +234,7 @@ pub fn parse_config(args: Vec<String>) -> Config { // Avoid spawning an external command when we know tidy won't be used. false }; + let has_enzyme = matches.opt_present("has-enzyme"); let filters = if mode == Mode::RunMake { matches .free @@ -331,6 +333,7 @@ pub fn parse_config(args: Vec<String>) -> Config { .map(|s| s.parse().expect("invalid --compare-mode provided")), rustfix_coverage: matches.opt_present("rustfix-coverage"), has_tidy, + has_enzyme, channel: matches.opt_str("channel").unwrap(), git_hash: matches.opt_present("git-hash"), edition: matches.opt_str("edition"), diff --git a/tests/rustdoc-ui/intra-doc/disambiguator-mismatch.rs b/tests/rustdoc-ui/intra-doc/disambiguator-mismatch.rs index 2d66566119b..8142bd83877 100644 --- a/tests/rustdoc-ui/intra-doc/disambiguator-mismatch.rs +++ b/tests/rustdoc-ui/intra-doc/disambiguator-mismatch.rs @@ -1,6 +1,8 @@ #![deny(rustdoc::broken_intra_doc_links)] //~^ NOTE lint level is defined -pub enum S {} +pub enum S { + A, +} fn S() {} #[macro_export] @@ -13,6 +15,10 @@ const c: usize = 0; trait T {} +struct X { + y: usize, +} + /// Link to [struct@S] //~^ ERROR incompatible link kind for `S` //~| NOTE this link resolved @@ -78,4 +84,14 @@ trait T {} //~^ ERROR unresolved link to `std` //~| NOTE this link resolves to the crate `std` //~| HELP to link to the crate, prefix with `mod@` + +/// Link to [method@X::y] +//~^ ERROR incompatible link kind for `X::y` +//~| NOTE this link resolved +//~| HELP prefix with `field@` + +/// Link to [field@S::A] +//~^ ERROR incompatible link kind for `S::A` +//~| NOTE this link resolved +//~| HELP prefix with `variant@` pub fn f() {} diff --git a/tests/rustdoc-ui/intra-doc/disambiguator-mismatch.stderr b/tests/rustdoc-ui/intra-doc/disambiguator-mismatch.stderr index ee35749ce7f..488120304fd 100644 --- a/tests/rustdoc-ui/intra-doc/disambiguator-mismatch.stderr +++ b/tests/rustdoc-ui/intra-doc/disambiguator-mismatch.stderr @@ -1,5 +1,5 @@ error: incompatible link kind for `S` - --> $DIR/disambiguator-mismatch.rs:16:14 + --> $DIR/disambiguator-mismatch.rs:22:14 | LL | /// Link to [struct@S] | ^^^^^^^^ this link resolved to an enum, which is not a struct @@ -15,7 +15,7 @@ LL | /// Link to [enum@S] | ~~~~~ error: incompatible link kind for `S` - --> $DIR/disambiguator-mismatch.rs:21:14 + --> $DIR/disambiguator-mismatch.rs:27:14 | LL | /// Link to [mod@S] | ^^^^^ this link resolved to an enum, which is not a module @@ -26,7 +26,7 @@ LL | /// Link to [enum@S] | ~~~~~ error: incompatible link kind for `S` - --> $DIR/disambiguator-mismatch.rs:26:14 + --> $DIR/disambiguator-mismatch.rs:32:14 | LL | /// Link to [union@S] | ^^^^^^^ this link resolved to an enum, which is not a union @@ -37,7 +37,7 @@ LL | /// Link to [enum@S] | ~~~~~ error: incompatible link kind for `S` - --> $DIR/disambiguator-mismatch.rs:31:14 + --> $DIR/disambiguator-mismatch.rs:37:14 | LL | /// Link to [trait@S] | ^^^^^^^ this link resolved to an enum, which is not a trait @@ -48,7 +48,7 @@ LL | /// Link to [enum@S] | ~~~~~ error: incompatible link kind for `T` - --> $DIR/disambiguator-mismatch.rs:36:14 + --> $DIR/disambiguator-mismatch.rs:42:14 | LL | /// Link to [struct@T] | ^^^^^^^^ this link resolved to a trait, which is not a struct @@ -59,7 +59,7 @@ LL | /// Link to [trait@T] | ~~~~~~ error: incompatible link kind for `m` - --> $DIR/disambiguator-mismatch.rs:41:14 + --> $DIR/disambiguator-mismatch.rs:47:14 | LL | /// Link to [derive@m] | ^^^^^^^^ this link resolved to a macro, which is not a derive macro @@ -71,7 +71,7 @@ LL + /// Link to [m!] | error: unresolved link to `m` - --> $DIR/disambiguator-mismatch.rs:46:14 + --> $DIR/disambiguator-mismatch.rs:52:14 | LL | /// Link to [m()] | ^^^ this link resolves to the macro `m`, which is not in the value namespace @@ -82,7 +82,7 @@ LL | /// Link to [m!()] | + error: incompatible link kind for `s` - --> $DIR/disambiguator-mismatch.rs:52:14 + --> $DIR/disambiguator-mismatch.rs:58:14 | LL | /// Link to [const@s] | ^^^^^^^ this link resolved to a static, which is not a constant @@ -93,7 +93,7 @@ LL | /// Link to [static@s] | ~~~~~~~ error: incompatible link kind for `c` - --> $DIR/disambiguator-mismatch.rs:57:14 + --> $DIR/disambiguator-mismatch.rs:63:14 | LL | /// Link to [static@c] | ^^^^^^^^ this link resolved to a constant, which is not a static @@ -104,7 +104,7 @@ LL | /// Link to [const@c] | ~~~~~~ error: incompatible link kind for `c` - --> $DIR/disambiguator-mismatch.rs:62:14 + --> $DIR/disambiguator-mismatch.rs:68:14 | LL | /// Link to [fn@c] | ^^^^ this link resolved to a constant, which is not a function @@ -115,7 +115,7 @@ LL | /// Link to [const@c] | ~~~~~~ error: incompatible link kind for `c` - --> $DIR/disambiguator-mismatch.rs:67:14 + --> $DIR/disambiguator-mismatch.rs:73:14 | LL | /// Link to [c()] | ^^^ this link resolved to a constant, which is not a function @@ -127,7 +127,7 @@ LL + /// Link to [const@c] | error: incompatible link kind for `f` - --> $DIR/disambiguator-mismatch.rs:72:14 + --> $DIR/disambiguator-mismatch.rs:78:14 | LL | /// Link to [const@f] | ^^^^^^^ this link resolved to a function, which is not a constant @@ -139,7 +139,7 @@ LL + /// Link to [f()] | error: unresolved link to `std` - --> $DIR/disambiguator-mismatch.rs:77:14 + --> $DIR/disambiguator-mismatch.rs:83:14 | LL | /// Link to [fn@std] | ^^^^^^ this link resolves to the crate `std`, which is not in the value namespace @@ -149,5 +149,27 @@ help: to link to the crate, prefix with `mod@` LL | /// Link to [mod@std] | ~~~~ -error: aborting due to 13 previous errors +error: incompatible link kind for `X::y` + --> $DIR/disambiguator-mismatch.rs:88:14 + | +LL | /// Link to [method@X::y] + | ^^^^^^^^^^^ this link resolved to a field, which is not a function + | +help: to link to the field, prefix with `field@` + | +LL | /// Link to [field@X::y] + | ~~~~~~ + +error: incompatible link kind for `S::A` + --> $DIR/disambiguator-mismatch.rs:93:14 + | +LL | /// Link to [field@S::A] + | ^^^^^^^^^^ this link resolved to a unit variant, which is not a field + | +help: to link to the unit variant, prefix with `variant@` + | +LL | /// Link to [variant@S::A] + | ~~~~~~~~ + +error: aborting due to 15 previous errors diff --git a/tests/rustdoc-ui/intra-doc/field-ice.rs b/tests/rustdoc-ui/intra-doc/field-ice.rs index c5d501e38da..1ba865b53c2 100644 --- a/tests/rustdoc-ui/intra-doc/field-ice.rs +++ b/tests/rustdoc-ui/intra-doc/field-ice.rs @@ -4,8 +4,8 @@ /// [`Foo::bar`] /// [`Foo::bar()`] //~^ERROR incompatible link kind for `Foo::bar` -//~|HELP to link to the field, remove the disambiguator +//~|HELP to link to the field, prefix with `field@` //~|NOTE this link resolved to a field, which is not a function pub struct Foo { - pub bar: u8 + pub bar: u8, } diff --git a/tests/rustdoc-ui/intra-doc/field-ice.stderr b/tests/rustdoc-ui/intra-doc/field-ice.stderr index cc0ada873af..7321c87b790 100644 --- a/tests/rustdoc-ui/intra-doc/field-ice.stderr +++ b/tests/rustdoc-ui/intra-doc/field-ice.stderr @@ -9,10 +9,11 @@ note: the lint level is defined here | LL | #![deny(rustdoc::broken_intra_doc_links)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: to link to the field, remove the disambiguator +help: to link to the field, prefix with `field@` + | +LL - /// [`Foo::bar()`] +LL + /// [`field@Foo::bar`] | -LL | /// [`Foo::bar`] - | ~~~~~~~~ error: aborting due to 1 previous error diff --git a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items.stderr b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items.stderr index ed89fa8391d..9cd855b69ff 100644 --- a/tests/rustdoc-ui/intra-doc/issue-108653-associated-items.stderr +++ b/tests/rustdoc-ui/intra-doc/issue-108653-associated-items.stderr @@ -43,10 +43,10 @@ help: to link to the associated function, add parentheses | LL | /// [`Self::IDENT()`] | ++ -help: to link to the variant, prefix with `type@` +help: to link to the variant, prefix with `variant@` | -LL | /// [`type@Self::IDENT`] - | +++++ +LL | /// [`variant@Self::IDENT`] + | ++++++++ error: `Self::IDENT2` is both an associated constant and an associated type --> $DIR/issue-108653-associated-items.rs:30:7 diff --git a/tests/rustdoc-ui/issues/issue-91713.stdout b/tests/rustdoc-ui/issues/issue-91713.stdout index 1ea3dbfb59f..790e58b0df9 100644 --- a/tests/rustdoc-ui/issues/issue-91713.stdout +++ b/tests/rustdoc-ui/issues/issue-91713.stdout @@ -5,6 +5,7 @@ strip-aliased-non-local - strips all non-local private aliased items from the ou strip-private - strips all private items from a crate which cannot be seen externally, implies strip-priv-imports strip-priv-imports - strips all private import statements (`use`, `extern crate`) from a crate propagate-doc-cfg - propagates `#[doc(cfg(...))]` to child items + propagate-stability - propagates stability to child items collect-intra-doc-links - resolves intra-doc links collect-trait-impls - retrieves trait impls for items in the crate calculate-doc-coverage - counts the number of items with and without documentation @@ -19,6 +20,7 @@ strip-aliased-non-local strip-priv-imports (when --document-private-items) collect-intra-doc-links propagate-doc-cfg + propagate-stability run-lints Passes run with `--show-coverage`: diff --git a/tests/rustdoc/intra-doc/field.rs b/tests/rustdoc/intra-doc/field.rs index ba6b320e560..e98419618e2 100644 --- a/tests/rustdoc/intra-doc/field.rs +++ b/tests/rustdoc/intra-doc/field.rs @@ -1,4 +1,24 @@ //@ has field/index.html '//a[@href="{{channel}}/core/ops/range/struct.Range.html#structfield.start"]' 'start' //@ has field/index.html '//a[@href="{{channel}}/std/io/error/enum.ErrorKind.html#variant.NotFound"]' 'not_found' +//@ has field/index.html '//a[@href="struct.FieldAndMethod.html#structfield.x"]' 'x' +//@ has field/index.html '//a[@href="enum.VariantAndMethod.html#variant.X"]' 'X' //! [start][std::ops::Range::start] //! [not_found][std::io::ErrorKind::NotFound] +//! [x][field@crate::FieldAndMethod::x] +//! [X][variant@crate::VariantAndMethod::X] + +pub struct FieldAndMethod { + pub x: i32, +} + +impl FieldAndMethod { + pub fn x(&self) {} +} + +pub enum VariantAndMethod { + X {}, +} + +impl VariantAndMethod { + fn X() {} +} diff --git a/tests/rustdoc/stability.rs b/tests/rustdoc/stability.rs index de855b43ba5..fc72154cad8 100644 --- a/tests/rustdoc/stability.rs +++ b/tests/rustdoc/stability.rs @@ -25,28 +25,61 @@ pub struct ZzStable; #[unstable(feature = "unstable", issue = "none")] pub mod unstable { - //@ !hasraw stability/unstable/struct.Foo.html '//span[@class="since"]' + //@ !hasraw stability/unstable/struct.StableInUnstable.html \ + // '//span[@class="since"]' //@ has - '//div[@class="stab unstable"]' 'experimental' #[stable(feature = "rust1", since = "1.0.0")] - pub struct Foo; + pub struct StableInUnstable; + + #[stable(feature = "rust1", since = "1.0.0")] + pub mod stable_in_unstable { + //@ !hasraw stability/unstable/stable_in_unstable/struct.Inner.html \ + // '//span[@class="since"]' + //@ has - '//div[@class="stab unstable"]' 'experimental' + #[stable(feature = "rust1", since = "1.0.0")] + pub struct Inner; + } } #[stable(feature = "rust2", since = "2.2.2")] pub mod stable_later { - //@ has stability/stable_later/struct.Bar.html '//span[@class="since"]' '2.2.2' + //@ has stability/stable_later/struct.StableInLater.html \ + // '//span[@class="since"]' '2.2.2' #[stable(feature = "rust1", since = "1.0.0")] - pub struct Bar; + pub struct StableInLater; + + #[stable(feature = "rust1", since = "1.0.0")] + pub mod stable_in_later { + //@ has stability/stable_later/stable_in_later/struct.Inner.html \ + // '//span[@class="since"]' '2.2.2' + #[stable(feature = "rust1", since = "1.0.0")] + pub struct Inner; + } } #[stable(feature = "rust1", since = "1.0.0")] pub mod stable_earlier { - //@ has stability/stable_earlier/struct.Foo.html '//span[@class="since"]' '1.0.0' + //@ has stability/stable_earlier/struct.StableInUnstable.html \ + // '//span[@class="since"]' '1.0.0' + #[doc(inline)] + #[stable(feature = "rust1", since = "1.0.0")] + pub use crate::unstable::StableInUnstable; + + //@ has stability/stable_earlier/stable_in_unstable/struct.Inner.html \ + // '//span[@class="since"]' '1.0.0' + #[doc(inline)] + #[stable(feature = "rust1", since = "1.0.0")] + pub use crate::unstable::stable_in_unstable; + + //@ has stability/stable_earlier/struct.StableInLater.html \ + // '//span[@class="since"]' '1.0.0' #[doc(inline)] #[stable(feature = "rust1", since = "1.0.0")] - pub use crate::unstable::Foo; + pub use crate::stable_later::StableInLater; - //@ has stability/stable_earlier/struct.Bar.html '//span[@class="since"]' '1.0.0' + //@ has stability/stable_earlier/stable_in_later/struct.Inner.html \ + // '//span[@class="since"]' '1.0.0' #[doc(inline)] #[stable(feature = "rust1", since = "1.0.0")] - pub use crate::stable_later::Bar; + pub use crate::stable_later::stable_in_later; } diff --git a/tests/ui/asm/aarch64/type-check-4.rs b/tests/ui/asm/aarch64/type-check-4.rs deleted file mode 100644 index c24567bd5b0..00000000000 --- a/tests/ui/asm/aarch64/type-check-4.rs +++ /dev/null @@ -1,27 +0,0 @@ -//@ only-aarch64 -//@ build-fail - -use std::arch::global_asm; - -fn main() {} - -// Constants must be... constant - -static mut S: i32 = 1; -const fn const_foo(x: i32) -> i32 { - x -} -const fn const_bar<T>(x: T) -> T { - x -} -global_asm!("{}", const unsafe { S }); -//~^ ERROR: evaluation of constant value failed -//~| mutable global memory -global_asm!("{}", const const_foo(0)); -global_asm!("{}", const const_foo(unsafe { S })); -//~^ ERROR: evaluation of constant value failed -//~| mutable global memory -global_asm!("{}", const const_bar(0)); -global_asm!("{}", const const_bar(unsafe { S })); -//~^ ERROR: evaluation of constant value failed -//~| mutable global memory diff --git a/tests/ui/asm/aarch64/type-check-4.stderr b/tests/ui/asm/aarch64/type-check-4.stderr deleted file mode 100644 index 8c22dfcdb5e..00000000000 --- a/tests/ui/asm/aarch64/type-check-4.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/type-check-4.rs:17:34 - | -LL | global_asm!("{}", const unsafe { S }); - | ^ constant accesses mutable global memory - -error[E0080]: evaluation of constant value failed - --> $DIR/type-check-4.rs:21:44 - | -LL | global_asm!("{}", const const_foo(unsafe { S })); - | ^ constant accesses mutable global memory - -error[E0080]: evaluation of constant value failed - --> $DIR/type-check-4.rs:25:44 - | -LL | global_asm!("{}", const const_bar(unsafe { S })); - | ^ constant accesses mutable global memory - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/asm/non-const.rs b/tests/ui/asm/non-const.rs new file mode 100644 index 00000000000..63c46563226 --- /dev/null +++ b/tests/ui/asm/non-const.rs @@ -0,0 +1,11 @@ +//@ needs-asm-support + +use std::arch::global_asm; + +fn main() {} + +// Constants must be... constant +fn non_const_fn(x: i32) -> i32 { x } + +global_asm!("/* {} */", const non_const_fn(0)); +//~^ERROR: cannot call non-const fn diff --git a/tests/ui/asm/non-const.stderr b/tests/ui/asm/non-const.stderr new file mode 100644 index 00000000000..5fae2ac9843 --- /dev/null +++ b/tests/ui/asm/non-const.stderr @@ -0,0 +1,11 @@ +error[E0015]: cannot call non-const fn `non_const_fn` in constants + --> $DIR/non-const.rs:10:31 + | +LL | global_asm!("/* {} */", const non_const_fn(0)); + | ^^^^^^^^^^^^^^^ + | + = note: calls in constants are limited to constant functions, tuple structs and tuple variants + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/asm/x86_64/type-check-4.rs b/tests/ui/asm/x86_64/type-check-4.rs deleted file mode 100644 index ebc6edc07e4..00000000000 --- a/tests/ui/asm/x86_64/type-check-4.rs +++ /dev/null @@ -1,27 +0,0 @@ -//@ only-x86_64 -//@ build-fail - -use std::arch::global_asm; - -fn main() {} - -// Constants must be... constant - -static mut S: i32 = 1; -const fn const_foo(x: i32) -> i32 { - x -} -const fn const_bar<T>(x: T) -> T { - x -} -global_asm!("{}", const unsafe { S }); -//~^ ERROR evaluation of constant value failed -//~| mutable global memory -global_asm!("{}", const const_foo(0)); -global_asm!("{}", const const_foo(unsafe { S })); -//~^ ERROR evaluation of constant value failed -//~| mutable global memory -global_asm!("{}", const const_bar(0)); -global_asm!("{}", const const_bar(unsafe { S })); -//~^ ERROR evaluation of constant value failed -//~| mutable global memory diff --git a/tests/ui/asm/x86_64/type-check-4.stderr b/tests/ui/asm/x86_64/type-check-4.stderr deleted file mode 100644 index 8c22dfcdb5e..00000000000 --- a/tests/ui/asm/x86_64/type-check-4.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/type-check-4.rs:17:34 - | -LL | global_asm!("{}", const unsafe { S }); - | ^ constant accesses mutable global memory - -error[E0080]: evaluation of constant value failed - --> $DIR/type-check-4.rs:21:44 - | -LL | global_asm!("{}", const const_foo(unsafe { S })); - | ^ constant accesses mutable global memory - -error[E0080]: evaluation of constant value failed - --> $DIR/type-check-4.rs:25:44 - | -LL | global_asm!("{}", const const_bar(unsafe { S })); - | ^ constant accesses mutable global memory - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/attributes/unsafe/extraneous-unsafe-attributes.rs b/tests/ui/attributes/unsafe/extraneous-unsafe-attributes.rs index b561550c198..273b127bf9c 100644 --- a/tests/ui/attributes/unsafe/extraneous-unsafe-attributes.rs +++ b/tests/ui/attributes/unsafe/extraneous-unsafe-attributes.rs @@ -27,4 +27,8 @@ mod inner { #[unsafe(used)] //~ ERROR: is not an unsafe attribute static FOO: usize = 0; -fn main() {} +fn main() { + let _a = cfg!(unsafe(foo)); + //~^ ERROR: expected identifier, found keyword `unsafe` + //~^^ ERROR: invalid predicate `r#unsafe` +} diff --git a/tests/ui/attributes/unsafe/extraneous-unsafe-attributes.stderr b/tests/ui/attributes/unsafe/extraneous-unsafe-attributes.stderr index 9fb7f062b91..445d239d867 100644 --- a/tests/ui/attributes/unsafe/extraneous-unsafe-attributes.stderr +++ b/tests/ui/attributes/unsafe/extraneous-unsafe-attributes.stderr @@ -22,6 +22,23 @@ LL | #[unsafe(test)] | = note: extraneous unsafe is not allowed in attributes +error: expected identifier, found keyword `unsafe` + --> $DIR/extraneous-unsafe-attributes.rs:31:19 + | +LL | let _a = cfg!(unsafe(foo)); + | ^^^^^^ expected identifier, found keyword + | +help: escape `unsafe` to use it as an identifier + | +LL | let _a = cfg!(r#unsafe(foo)); + | ++ + +error[E0537]: invalid predicate `r#unsafe` + --> $DIR/extraneous-unsafe-attributes.rs:31:19 + | +LL | let _a = cfg!(unsafe(foo)); + | ^^^^^^^^^^^ + error: `ignore` is not an unsafe attribute --> $DIR/extraneous-unsafe-attributes.rs:13:3 | @@ -62,5 +79,6 @@ LL | #[unsafe(used)] | = note: extraneous unsafe is not allowed in attributes -error: aborting due to 8 previous errors +error: aborting due to 10 previous errors +For more information about this error, try `rustc --explain E0537`. diff --git a/tests/ui/check-cfg/invalid-arguments.rs b/tests/ui/check-cfg/invalid-arguments.rs index b8588ecb4ff..c6b1218ce27 100644 --- a/tests/ui/check-cfg/invalid-arguments.rs +++ b/tests/ui/check-cfg/invalid-arguments.rs @@ -8,7 +8,7 @@ //@ revisions: values_any_missing_values values_any_before_ident ident_in_values_1 //@ revisions: ident_in_values_2 unknown_meta_item_1 unknown_meta_item_2 unknown_meta_item_3 //@ revisions: mixed_values_any mixed_any any_values giberich unterminated -//@ revisions: none_not_empty cfg_none +//@ revisions: none_not_empty cfg_none unsafe_attr // //@ [anything_else]compile-flags: --check-cfg=anything_else(...) //@ [boolean]compile-flags: --check-cfg=cfg(true) @@ -33,5 +33,6 @@ //@ [cfg_none]compile-flags: --check-cfg=cfg(none()) //@ [giberich]compile-flags: --check-cfg=cfg(...) //@ [unterminated]compile-flags: --check-cfg=cfg( +//@ [unsafe_attr]compile-flags: --check-cfg=unsafe(cfg(foo)) fn main() {} diff --git a/tests/ui/check-cfg/invalid-arguments.unsafe_attr.stderr b/tests/ui/check-cfg/invalid-arguments.unsafe_attr.stderr new file mode 100644 index 00000000000..5236ed6f605 --- /dev/null +++ b/tests/ui/check-cfg/invalid-arguments.unsafe_attr.stderr @@ -0,0 +1,5 @@ +error: invalid `--check-cfg` argument: `unsafe(cfg(foo))` + | + = note: expected `cfg(name, values("value1", "value2", ... "valueN"))` + = note: visit <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more details + diff --git a/tests/ui/check-cfg/mix.stderr b/tests/ui/check-cfg/mix.stderr index 653c1c983e2..7726c2d52f5 100644 --- a/tests/ui/check-cfg/mix.stderr +++ b/tests/ui/check-cfg/mix.stderr @@ -251,7 +251,7 @@ warning: unexpected `cfg` condition value: `zebra` LL | cfg!(target_feature = "zebra"); | ^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `amx-bf16`, `amx-complex`, `amx-fp16`, `amx-int8`, `amx-tile`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, and `avx512vpopcntdq` and 241 more + = note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `amx-bf16`, `amx-complex`, `amx-fp16`, `amx-int8`, `amx-tile`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, and `avx512vpopcntdq` and 244 more = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration warning: 27 warnings emitted diff --git a/tests/ui/check-cfg/well-known-values.stderr b/tests/ui/check-cfg/well-known-values.stderr index 14832e7ff43..3c99fdd3821 100644 --- a/tests/ui/check-cfg/well-known-values.stderr +++ b/tests/ui/check-cfg/well-known-values.stderr @@ -174,7 +174,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` LL | target_feature = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `amx-bf16`, `amx-complex`, `amx-fp16`, `amx-int8`, `amx-tile`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, `avx512vpopcntdq`, `avxifma`, `avxneconvert`, `avxvnni`, `avxvnniint16`, `avxvnniint8`, `backchain`, `bf16`, `bmi1`, `bmi2`, `bti`, `bulk-memory`, `c`, `cache`, `cmpxchg16b`, `crc`, `crt-static`, `cssc`, `d`, `d32`, `dit`, `doloop`, `dotprod`, `dpb`, `dpb2`, `dsp`, `dsp1e2`, `dspe60`, `e`, `e1`, `e2`, `ecv`, `edsp`, `elrw`, `ermsb`, `exception-handling`, `extended-const`, `f`, `f16c`, `f32mm`, `f64mm`, `faminmax`, `fcma`, `fdivdu`, `fhm`, `flagm`, `flagm2`, `float1e2`, `float1e3`, `float3e4`, `float7e60`, `floate1`, `fma`, `fp-armv8`, `fp16`, `fp64`, `fp8`, `fp8dot2`, `fp8dot4`, `fp8fma`, `fpuv2_df`, `fpuv2_sf`, `fpuv3_df`, `fpuv3_hf`, `fpuv3_hi`, `fpuv3_sf`, `frecipe`, `frintts`, `fxsr`, `gfni`, `hard-float`, `hard-float-abi`, `hard-tp`, `hbc`, `high-registers`, `hvx`, `hvx-length128b`, `hwdiv`, `i8mm`, `jsconv`, `lahfsahf`, `lasx`, `lbt`, `lor`, `lse`, `lse128`, `lse2`, `lsx`, `lut`, `lvz`, `lzcnt`, `m`, `mclass`, `mops`, `movbe`, `mp`, `mp1e2`, `msa`, `mte`, `multivalue`, `mutable-globals`, `neon`, `nontrapping-fptoint`, `nvic`, `paca`, `pacg`, `pan`, `partword-atomics`, `pclmulqdq`, `pmuv3`, `popcnt`, `power10-vector`, `power8-altivec`, `power8-vector`, `power9-altivec`, `power9-vector`, `prfchw`, `quadword-atomics`, `rand`, `ras`, `rclass`, `rcpc`, `rcpc2`, `rcpc3`, `rdm`, `rdrand`, `rdseed`, `reference-types`, `relax`, `relaxed-simd`, `rtm`, `sb`, `sha`, `sha2`, `sha3`, `sha512`, `sign-ext`, `simd128`, `sm3`, `sm4`, `sme`, `sme-f16f16`, `sme-f64f64`, `sme-f8f16`, `sme-f8f32`, `sme-fa64`, `sme-i16i64`, `sme-lutv2`, `sme2`, `sme2p1`, `spe`, `ssbs`, `sse`, `sse2`, `sse3`, `sse4.1`, `sse4.2`, `sse4a`, `ssse3`, `ssve-fp8dot2`, `ssve-fp8dot4`, `ssve-fp8fma`, `sve`, `sve-b16b16`, `sve2`, `sve2-aes`, `sve2-bitperm`, `sve2-sha3`, `sve2-sm4`, `sve2p1`, `tbm`, `thumb-mode`, `thumb2`, `tme`, `trust`, `trustzone`, `ual`, `unaligned-scalar-mem`, `v`, `v5te`, `v6`, `v6k`, `v6t2`, `v7`, `v8`, `v8.1a`, `v8.2a`, `v8.3a`, `v8.4a`, `v8.5a`, `v8.6a`, `v8.7a`, `v8.8a`, `v8.9a`, `v9.1a`, `v9.2a`, `v9.3a`, `v9.4a`, `v9.5a`, `v9a`, `vaes`, `vdsp2e60f`, `vdspv1`, `vdspv2`, `vector`, `vfp2`, `vfp3`, `vfp4`, `vh`, `virt`, `virtualization`, `vpclmulqdq`, `vsx`, `wfxt`, `xop`, `xsave`, `xsavec`, `xsaveopt`, `xsaves`, `zba`, `zbb`, `zbc`, `zbkb`, `zbkc`, `zbkx`, `zbs`, `zdinx`, `zfh`, `zfhmin`, `zfinx`, `zhinx`, `zhinxmin`, `zk`, `zkn`, `zknd`, `zkne`, `zknh`, `zkr`, `zks`, `zksed`, `zksh`, and `zkt` + = note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `amx-bf16`, `amx-complex`, `amx-fp16`, `amx-int8`, `amx-tile`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, `avx512vpopcntdq`, `avxifma`, `avxneconvert`, `avxvnni`, `avxvnniint16`, `avxvnniint8`, `backchain`, `bf16`, `bmi1`, `bmi2`, `bti`, `bulk-memory`, `c`, `cache`, `cmpxchg16b`, `crc`, `crt-static`, `cssc`, `d`, `d32`, `dit`, `doloop`, `dotprod`, `dpb`, `dpb2`, `dsp`, `dsp1e2`, `dspe60`, `e`, `e1`, `e2`, `ecv`, `edsp`, `elrw`, `ermsb`, `exception-handling`, `extended-const`, `f`, `f16c`, `f32mm`, `f64mm`, `faminmax`, `fcma`, `fdivdu`, `fhm`, `flagm`, `flagm2`, `float1e2`, `float1e3`, `float3e4`, `float7e60`, `floate1`, `fma`, `fp-armv8`, `fp16`, `fp64`, `fp8`, `fp8dot2`, `fp8dot4`, `fp8fma`, `fpuv2_df`, `fpuv2_sf`, `fpuv3_df`, `fpuv3_hf`, `fpuv3_hi`, `fpuv3_sf`, `frecipe`, `frintts`, `fxsr`, `gfni`, `hard-float`, `hard-float-abi`, `hard-tp`, `hbc`, `high-registers`, `hvx`, `hvx-length128b`, `hwdiv`, `i8mm`, `jsconv`, `lahfsahf`, `lasx`, `lbt`, `lor`, `lse`, `lse128`, `lse2`, `lsx`, `lut`, `lvz`, `lzcnt`, `m`, `mclass`, `mops`, `movbe`, `mp`, `mp1e2`, `msa`, `mte`, `multivalue`, `mutable-globals`, `neon`, `nontrapping-fptoint`, `nvic`, `paca`, `pacg`, `pan`, `partword-atomics`, `pclmulqdq`, `pmuv3`, `popcnt`, `power10-vector`, `power8-altivec`, `power8-vector`, `power9-altivec`, `power9-vector`, `prfchw`, `quadword-atomics`, `rand`, `ras`, `rclass`, `rcpc`, `rcpc2`, `rcpc3`, `rdm`, `rdrand`, `rdseed`, `reference-types`, `relax`, `relaxed-simd`, `rtm`, `sb`, `sha`, `sha2`, `sha3`, `sha512`, `sign-ext`, `simd128`, `sm3`, `sm4`, `sme`, `sme-f16f16`, `sme-f64f64`, `sme-f8f16`, `sme-f8f32`, `sme-fa64`, `sme-i16i64`, `sme-lutv2`, `sme2`, `sme2p1`, `spe`, `ssbs`, `sse`, `sse2`, `sse3`, `sse4.1`, `sse4.2`, `sse4a`, `ssse3`, `ssve-fp8dot2`, `ssve-fp8dot4`, `ssve-fp8fma`, `sve`, `sve-b16b16`, `sve2`, `sve2-aes`, `sve2-bitperm`, `sve2-sha3`, `sve2-sm4`, `sve2p1`, `tbm`, `thumb-mode`, `thumb2`, `tme`, `trust`, `trustzone`, `ual`, `unaligned-scalar-mem`, `v`, `v5te`, `v6`, `v6k`, `v6t2`, `v7`, `v8`, `v8.1a`, `v8.2a`, `v8.3a`, `v8.4a`, `v8.5a`, `v8.6a`, `v8.7a`, `v8.8a`, `v8.9a`, `v9.1a`, `v9.2a`, `v9.3a`, `v9.4a`, `v9.5a`, `v9a`, `vaes`, `vdsp2e60f`, `vdspv1`, `vdspv2`, `vector`, `vfp2`, `vfp3`, `vfp4`, `vh`, `virt`, `virtualization`, `vpclmulqdq`, `vsx`, `wfxt`, `xop`, `xsave`, `xsavec`, `xsaveopt`, `xsaves`, `zaamo`, `zabha`, `zalrsc`, `zba`, `zbb`, `zbc`, `zbkb`, `zbkc`, `zbkx`, `zbs`, `zdinx`, `zfh`, `zfhmin`, `zfinx`, `zhinx`, `zhinxmin`, `zk`, `zkn`, `zknd`, `zkne`, `zknh`, `zkr`, `zks`, `zksed`, `zksh`, and `zkt` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` diff --git a/tests/ui/const-generics/adt_const_params/suggest_feature_only_when_possible.stderr b/tests/ui/const-generics/adt_const_params/suggest_feature_only_when_possible.stderr index aafc0640dd2..8c54aef36ca 100644 --- a/tests/ui/const-generics/adt_const_params/suggest_feature_only_when_possible.stderr +++ b/tests/ui/const-generics/adt_const_params/suggest_feature_only_when_possible.stderr @@ -4,7 +4,7 @@ error: `&'static mut ()` is forbidden as the type of a const generic parameter LL | fn uwu_0<const N: &'static mut ()>() {} | ^^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: `&'static u32` is forbidden as the type of a const generic parameter --> $DIR/suggest_feature_only_when_possible.rs:15:19 @@ -12,7 +12,7 @@ error: `&'static u32` is forbidden as the type of a const generic parameter LL | fn owo_0<const N: &'static u32>() {} | ^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -28,7 +28,7 @@ error: `Meow` is forbidden as the type of a const generic parameter LL | fn meow_0<const N: Meow>() {} | ^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -40,7 +40,7 @@ error: `&'static Meow` is forbidden as the type of a const generic parameter LL | fn meow_1<const N: &'static Meow>() {} | ^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -56,7 +56,7 @@ error: `[Meow; 100]` is forbidden as the type of a const generic parameter LL | fn meow_2<const N: [Meow; 100]>() {} | ^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: `(Meow, u8)` is forbidden as the type of a const generic parameter --> $DIR/suggest_feature_only_when_possible.rs:29:20 @@ -64,7 +64,7 @@ error: `(Meow, u8)` is forbidden as the type of a const generic parameter LL | fn meow_3<const N: (Meow, u8)>() {} | ^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: `(Meow, String)` is forbidden as the type of a const generic parameter --> $DIR/suggest_feature_only_when_possible.rs:34:20 @@ -72,7 +72,7 @@ error: `(Meow, String)` is forbidden as the type of a const generic parameter LL | fn meow_4<const N: (Meow, String)>() {} | ^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: `String` is forbidden as the type of a const generic parameter --> $DIR/suggest_feature_only_when_possible.rs:38:19 @@ -80,7 +80,7 @@ error: `String` is forbidden as the type of a const generic parameter LL | fn nya_0<const N: String>() {} | ^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: `Vec<u32>` is forbidden as the type of a const generic parameter --> $DIR/suggest_feature_only_when_possible.rs:40:19 @@ -88,7 +88,7 @@ error: `Vec<u32>` is forbidden as the type of a const generic parameter LL | fn nya_1<const N: Vec<u32>>() {} | ^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: aborting due to 9 previous errors diff --git a/tests/ui/const-generics/const-param-elided-lifetime.full.stderr b/tests/ui/const-generics/const-param-elided-lifetime.full.stderr index d6753a74f85..34510f546c8 100644 --- a/tests/ui/const-generics/const-param-elided-lifetime.full.stderr +++ b/tests/ui/const-generics/const-param-elided-lifetime.full.stderr @@ -5,25 +5,25 @@ LL | struct A<const N: &u8>; | ^ explicit lifetime name needed here error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/const-param-elided-lifetime.rs:14:15 + --> $DIR/const-param-elided-lifetime.rs:13:15 | LL | impl<const N: &u8> A<N> { | ^ explicit lifetime name needed here error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/const-param-elided-lifetime.rs:17:21 + --> $DIR/const-param-elided-lifetime.rs:15:21 | LL | fn foo<const M: &u8>(&self) {} | ^ explicit lifetime name needed here error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/const-param-elided-lifetime.rs:22:15 + --> $DIR/const-param-elided-lifetime.rs:19:15 | LL | impl<const N: &u8> B for A<N> {} | ^ explicit lifetime name needed here error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/const-param-elided-lifetime.rs:26:17 + --> $DIR/const-param-elided-lifetime.rs:22:17 | LL | fn bar<const N: &u8>() {} | ^ explicit lifetime name needed here diff --git a/tests/ui/const-generics/const-param-elided-lifetime.min.stderr b/tests/ui/const-generics/const-param-elided-lifetime.min.stderr index 62267224738..34510f546c8 100644 --- a/tests/ui/const-generics/const-param-elided-lifetime.min.stderr +++ b/tests/ui/const-generics/const-param-elided-lifetime.min.stderr @@ -5,109 +5,29 @@ LL | struct A<const N: &u8>; | ^ explicit lifetime name needed here error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/const-param-elided-lifetime.rs:14:15 + --> $DIR/const-param-elided-lifetime.rs:13:15 | LL | impl<const N: &u8> A<N> { | ^ explicit lifetime name needed here error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/const-param-elided-lifetime.rs:17:21 + --> $DIR/const-param-elided-lifetime.rs:15:21 | LL | fn foo<const M: &u8>(&self) {} | ^ explicit lifetime name needed here error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/const-param-elided-lifetime.rs:22:15 + --> $DIR/const-param-elided-lifetime.rs:19:15 | LL | impl<const N: &u8> B for A<N> {} | ^ explicit lifetime name needed here error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/const-param-elided-lifetime.rs:26:17 + --> $DIR/const-param-elided-lifetime.rs:22:17 | LL | fn bar<const N: &u8>() {} | ^ explicit lifetime name needed here -error: `&u8` is forbidden as the type of a const generic parameter - --> $DIR/const-param-elided-lifetime.rs:9:19 - | -LL | struct A<const N: &u8>; - | ^^^ - | - = note: the only supported types are integers, `bool` and `char` -help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types - | -LL + #![feature(adt_const_params)] - | -help: add `#![feature(unsized_const_params)]` to the crate attributes to enable references to implement the `ConstParamTy` trait - | -LL + #![feature(unsized_const_params)] - | - -error: `&u8` is forbidden as the type of a const generic parameter - --> $DIR/const-param-elided-lifetime.rs:14:15 - | -LL | impl<const N: &u8> A<N> { - | ^^^ - | - = note: the only supported types are integers, `bool` and `char` -help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types - | -LL + #![feature(adt_const_params)] - | -help: add `#![feature(unsized_const_params)]` to the crate attributes to enable references to implement the `ConstParamTy` trait - | -LL + #![feature(unsized_const_params)] - | - -error: `&u8` is forbidden as the type of a const generic parameter - --> $DIR/const-param-elided-lifetime.rs:22:15 - | -LL | impl<const N: &u8> B for A<N> {} - | ^^^ - | - = note: the only supported types are integers, `bool` and `char` -help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types - | -LL + #![feature(adt_const_params)] - | -help: add `#![feature(unsized_const_params)]` to the crate attributes to enable references to implement the `ConstParamTy` trait - | -LL + #![feature(unsized_const_params)] - | - -error: `&u8` is forbidden as the type of a const generic parameter - --> $DIR/const-param-elided-lifetime.rs:26:17 - | -LL | fn bar<const N: &u8>() {} - | ^^^ - | - = note: the only supported types are integers, `bool` and `char` -help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types - | -LL + #![feature(adt_const_params)] - | -help: add `#![feature(unsized_const_params)]` to the crate attributes to enable references to implement the `ConstParamTy` trait - | -LL + #![feature(unsized_const_params)] - | - -error: `&u8` is forbidden as the type of a const generic parameter - --> $DIR/const-param-elided-lifetime.rs:17:21 - | -LL | fn foo<const M: &u8>(&self) {} - | ^^^ - | - = note: the only supported types are integers, `bool` and `char` -help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types - | -LL + #![feature(adt_const_params)] - | -help: add `#![feature(unsized_const_params)]` to the crate attributes to enable references to implement the `ConstParamTy` trait - | -LL + #![feature(unsized_const_params)] - | - -error: aborting due to 10 previous errors +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0637`. diff --git a/tests/ui/const-generics/const-param-elided-lifetime.rs b/tests/ui/const-generics/const-param-elided-lifetime.rs index e75073de98d..b1cdb6a46c5 100644 --- a/tests/ui/const-generics/const-param-elided-lifetime.rs +++ b/tests/ui/const-generics/const-param-elided-lifetime.rs @@ -8,23 +8,18 @@ struct A<const N: &u8>; //~^ ERROR `&` without an explicit lifetime name cannot be used here -//[min]~^^ ERROR `&u8` is forbidden trait B {} impl<const N: &u8> A<N> { //~^ ERROR `&` without an explicit lifetime name cannot be used here - //[min]~^^ ERROR `&u8` is forbidden fn foo<const M: &u8>(&self) {} //~^ ERROR `&` without an explicit lifetime name cannot be used here - //[min]~^^ ERROR `&u8` is forbidden } impl<const N: &u8> B for A<N> {} //~^ ERROR `&` without an explicit lifetime name cannot be used here -//[min]~^^ ERROR `&u8` is forbidden fn bar<const N: &u8>() {} //~^ ERROR `&` without an explicit lifetime name cannot be used here -//[min]~^^ ERROR `&u8` is forbidden fn main() {} diff --git a/tests/ui/const-generics/const-param-type-depends-on-const-param.min.stderr b/tests/ui/const-generics/const-param-type-depends-on-const-param.min.stderr index fcc86b9ac33..18b89963267 100644 --- a/tests/ui/const-generics/const-param-type-depends-on-const-param.min.stderr +++ b/tests/ui/const-generics/const-param-type-depends-on-const-param.min.stderr @@ -20,7 +20,7 @@ error: `[u8; N]` is forbidden as the type of a const generic parameter LL | pub struct Dependent<const N: usize, const X: [u8; N]>([(); N]); | ^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -32,7 +32,7 @@ error: `[u8; N]` is forbidden as the type of a const generic parameter LL | pub struct SelfDependent<const N: [u8; N]>; | ^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/default-ty-closure.stderr b/tests/ui/const-generics/default-ty-closure.stderr index 9c737c1a19d..3f6ca9aea4e 100644 --- a/tests/ui/const-generics/default-ty-closure.stderr +++ b/tests/ui/const-generics/default-ty-closure.stderr @@ -4,7 +4,7 @@ error: using function pointers as const generic parameters is forbidden LL | struct X<const FN: fn() = { || {} }>; | ^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/float-generic.simple.stderr b/tests/ui/const-generics/float-generic.simple.stderr index 2999bce32d6..abc5e7c5a99 100644 --- a/tests/ui/const-generics/float-generic.simple.stderr +++ b/tests/ui/const-generics/float-generic.simple.stderr @@ -4,7 +4,7 @@ error: `f32` is forbidden as the type of a const generic parameter LL | fn foo<const F: f32>() {} | ^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/fn-const-param-call.min.stderr b/tests/ui/const-generics/fn-const-param-call.min.stderr index d37766b28c9..b5b809d2787 100644 --- a/tests/ui/const-generics/fn-const-param-call.min.stderr +++ b/tests/ui/const-generics/fn-const-param-call.min.stderr @@ -4,7 +4,7 @@ error: using function pointers as const generic parameters is forbidden LL | struct Wrapper<const F: fn() -> u32>; | ^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: using function pointers as const generic parameters is forbidden --> $DIR/fn-const-param-call.rs:15:15 @@ -12,7 +12,7 @@ error: using function pointers as const generic parameters is forbidden LL | impl<const F: fn() -> u32> Wrapper<F> { | ^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/fn-const-param-infer.min.stderr b/tests/ui/const-generics/fn-const-param-infer.min.stderr index 4da503d344a..5e08f71a267 100644 --- a/tests/ui/const-generics/fn-const-param-infer.min.stderr +++ b/tests/ui/const-generics/fn-const-param-infer.min.stderr @@ -4,7 +4,7 @@ error: using function pointers as const generic parameters is forbidden LL | struct Checked<const F: fn(usize) -> bool>; | ^^^^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error[E0308]: mismatched types --> $DIR/fn-const-param-infer.rs:33:25 diff --git a/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.min.stderr b/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.min.stderr index 1f67a5c09f1..a8b6f06ab1c 100644 --- a/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.min.stderr +++ b/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.min.stderr @@ -22,7 +22,7 @@ error: `Config` is forbidden as the type of a const generic parameter LL | struct B<const CFG: Config> { | ^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/generic_const_exprs/error_in_ty.stderr b/tests/ui/const-generics/generic_const_exprs/error_in_ty.stderr index 0e40255bcf5..d822fa5894a 100644 --- a/tests/ui/const-generics/generic_const_exprs/error_in_ty.stderr +++ b/tests/ui/const-generics/generic_const_exprs/error_in_ty.stderr @@ -12,7 +12,7 @@ error: `[usize; x]` is forbidden as the type of a const generic parameter LL | pub struct A<const z: [usize; x]> {} | ^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr b/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr index 15d3c472585..45be31c7ba3 100644 --- a/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr +++ b/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr @@ -66,7 +66,7 @@ error: `[[usize; v4]; v4]` is forbidden as the type of a const generic parameter LL | pub struct v17<const v10: usize, const v7: v11> { | ^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/ice-118285-fn-ptr-value.stderr b/tests/ui/const-generics/ice-118285-fn-ptr-value.stderr index 46a8a975d50..4ff386c8163 100644 --- a/tests/ui/const-generics/ice-118285-fn-ptr-value.stderr +++ b/tests/ui/const-generics/ice-118285-fn-ptr-value.stderr @@ -4,7 +4,7 @@ error: using function pointers as const generic parameters is forbidden LL | struct Checked<const F: fn(usize) -> bool>; | ^^^^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/intrinsics-type_name-as-const-argument.min.stderr b/tests/ui/const-generics/intrinsics-type_name-as-const-argument.min.stderr index 2a6d9f53317..506f7d05fa6 100644 --- a/tests/ui/const-generics/intrinsics-type_name-as-const-argument.min.stderr +++ b/tests/ui/const-generics/intrinsics-type_name-as-const-argument.min.stderr @@ -13,7 +13,7 @@ error: `&'static str` is forbidden as the type of a const generic parameter LL | trait Trait<const S: &'static str> {} | ^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/issues/issue-56445-1.min.stderr b/tests/ui/const-generics/issues/issue-56445-1.min.stderr index ff0a1bfc0b5..86eb57355bd 100644 --- a/tests/ui/const-generics/issues/issue-56445-1.min.stderr +++ b/tests/ui/const-generics/issues/issue-56445-1.min.stderr @@ -6,22 +6,6 @@ LL | struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>); | = note: lifetime parameters may not be used in the type of const parameters -error: `&str` is forbidden as the type of a const generic parameter - --> $DIR/issue-56445-1.rs:9:25 - | -LL | struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>); - | ^^^^^^^ - | - = note: the only supported types are integers, `bool` and `char` -help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types - | -LL + #![feature(adt_const_params)] - | -help: add `#![feature(unsized_const_params)]` to the crate attributes to enable references to implement the `ConstParamTy` trait - | -LL + #![feature(unsized_const_params)] - | - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0770`. diff --git a/tests/ui/const-generics/issues/issue-56445-1.rs b/tests/ui/const-generics/issues/issue-56445-1.rs index 53aab40b0ad..681e0e147cf 100644 --- a/tests/ui/const-generics/issues/issue-56445-1.rs +++ b/tests/ui/const-generics/issues/issue-56445-1.rs @@ -8,6 +8,5 @@ use std::marker::PhantomData; struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>); //~^ ERROR: the type of const parameters must not depend on other generic parameters -//[min]~| ERROR: `&str` is forbidden as the type of a const generic parameter impl Bug<'_, ""> {} diff --git a/tests/ui/const-generics/issues/issue-62878.min.stderr b/tests/ui/const-generics/issues/issue-62878.min.stderr index 5205726d738..bd17d70a50b 100644 --- a/tests/ui/const-generics/issues/issue-62878.min.stderr +++ b/tests/ui/const-generics/issues/issue-62878.min.stderr @@ -12,7 +12,7 @@ error: `[u8; N]` is forbidden as the type of a const generic parameter LL | fn foo<const N: usize, const A: [u8; N]>() {} | ^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/issues/issue-63322-forbid-dyn.min.stderr b/tests/ui/const-generics/issues/issue-63322-forbid-dyn.min.stderr index 101ca456cd9..f14485a4976 100644 --- a/tests/ui/const-generics/issues/issue-63322-forbid-dyn.min.stderr +++ b/tests/ui/const-generics/issues/issue-63322-forbid-dyn.min.stderr @@ -4,7 +4,7 @@ error: `&'static (dyn A + 'static)` is forbidden as the type of a const generic LL | fn test<const T: &'static dyn A>() { | ^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/issues/issue-68366.full.stderr b/tests/ui/const-generics/issues/issue-68366.full.stderr index 3363a895e47..caed3c1bf3f 100644 --- a/tests/ui/const-generics/issues/issue-68366.full.stderr +++ b/tests/ui/const-generics/issues/issue-68366.full.stderr @@ -4,7 +4,7 @@ error: `Option<usize>` is forbidden as the type of a const generic parameter LL | struct Collatz<const N: Option<usize>>; | ^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/issues/issue-68366.min.stderr b/tests/ui/const-generics/issues/issue-68366.min.stderr index 276f91e76dd..10b5a06682f 100644 --- a/tests/ui/const-generics/issues/issue-68366.min.stderr +++ b/tests/ui/const-generics/issues/issue-68366.min.stderr @@ -13,7 +13,7 @@ error: `Option<usize>` is forbidden as the type of a const generic parameter LL | struct Collatz<const N: Option<usize>>; | ^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/issues/issue-68615-adt.min.stderr b/tests/ui/const-generics/issues/issue-68615-adt.min.stderr index 2f95eef98c0..d25b34435ed 100644 --- a/tests/ui/const-generics/issues/issue-68615-adt.min.stderr +++ b/tests/ui/const-generics/issues/issue-68615-adt.min.stderr @@ -4,7 +4,7 @@ error: `[usize; 0]` is forbidden as the type of a const generic parameter LL | struct Const<const V: [usize; 0]> {} | ^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/issues/issue-68615-array.min.stderr b/tests/ui/const-generics/issues/issue-68615-array.min.stderr index 6d18f8195d2..60cbc9b4eab 100644 --- a/tests/ui/const-generics/issues/issue-68615-array.min.stderr +++ b/tests/ui/const-generics/issues/issue-68615-array.min.stderr @@ -4,7 +4,7 @@ error: `[usize; 0]` is forbidden as the type of a const generic parameter LL | struct Foo<const V: [usize; 0] > {} | ^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/issues/issue-71169.min.stderr b/tests/ui/const-generics/issues/issue-71169.min.stderr index 94d11f969ff..2ecbc337951 100644 --- a/tests/ui/const-generics/issues/issue-71169.min.stderr +++ b/tests/ui/const-generics/issues/issue-71169.min.stderr @@ -12,7 +12,7 @@ error: `[u8; LEN]` is forbidden as the type of a const generic parameter LL | fn foo<const LEN: usize, const DATA: [u8; LEN]>() {} | ^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/issues/issue-71381.min.stderr b/tests/ui/const-generics/issues/issue-71381.min.stderr index e16d3b7a8a4..38d2cbe6368 100644 --- a/tests/ui/const-generics/issues/issue-71381.min.stderr +++ b/tests/ui/const-generics/issues/issue-71381.min.stderr @@ -20,7 +20,7 @@ error: using function pointers as const generic parameters is forbidden LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&self) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: using function pointers as const generic parameters is forbidden --> $DIR/issue-71381.rs:23:19 @@ -28,7 +28,7 @@ error: using function pointers as const generic parameters is forbidden LL | const FN: unsafe extern "C" fn(Args), | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: aborting due to 4 previous errors diff --git a/tests/ui/const-generics/issues/issue-71382.min.stderr b/tests/ui/const-generics/issues/issue-71382.min.stderr index 0c58b10c0b7..f70e1733a97 100644 --- a/tests/ui/const-generics/issues/issue-71382.min.stderr +++ b/tests/ui/const-generics/issues/issue-71382.min.stderr @@ -4,7 +4,7 @@ error: using function pointers as const generic parameters is forbidden LL | fn test<const FN: fn()>(&self) { | ^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/issues/issue-71611.min.stderr b/tests/ui/const-generics/issues/issue-71611.min.stderr index b01936f4d25..7252bfd1d6a 100644 --- a/tests/ui/const-generics/issues/issue-71611.min.stderr +++ b/tests/ui/const-generics/issues/issue-71611.min.stderr @@ -12,7 +12,7 @@ error: using function pointers as const generic parameters is forbidden LL | fn func<A, const F: fn(inner: A)>(outer: A) { | ^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/issues/issue-72352.min.stderr b/tests/ui/const-generics/issues/issue-72352.min.stderr index ede0faec7c6..17ccfa8a0da 100644 --- a/tests/ui/const-generics/issues/issue-72352.min.stderr +++ b/tests/ui/const-generics/issues/issue-72352.min.stderr @@ -4,7 +4,7 @@ error: using function pointers as const generic parameters is forbidden LL | unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const c_char) -> usize { | ^^^^^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/issues/issue-73491.min.stderr b/tests/ui/const-generics/issues/issue-73491.min.stderr index 8fdd65894ef..2cdbeea2fd6 100644 --- a/tests/ui/const-generics/issues/issue-73491.min.stderr +++ b/tests/ui/const-generics/issues/issue-73491.min.stderr @@ -4,7 +4,7 @@ error: `[u32; LEN]` is forbidden as the type of a const generic parameter LL | fn hoge<const IN: [u32; LEN]>() {} | ^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/issues/issue-73727-static-reference-array-const-param.min.stderr b/tests/ui/const-generics/issues/issue-73727-static-reference-array-const-param.min.stderr index cba03b1cb1f..256636c0628 100644 --- a/tests/ui/const-generics/issues/issue-73727-static-reference-array-const-param.min.stderr +++ b/tests/ui/const-generics/issues/issue-73727-static-reference-array-const-param.min.stderr @@ -4,7 +4,7 @@ error: `&'static [u32]` is forbidden as the type of a const generic parameter LL | fn a<const X: &'static [u32]>() {} | ^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/issues/issue-74101.min.stderr b/tests/ui/const-generics/issues/issue-74101.min.stderr index 236556addce..65fb51d7df9 100644 --- a/tests/ui/const-generics/issues/issue-74101.min.stderr +++ b/tests/ui/const-generics/issues/issue-74101.min.stderr @@ -4,7 +4,7 @@ error: `[u8; 1 + 2]` is forbidden as the type of a const generic parameter LL | fn test<const N: [u8; 1 + 2]>() {} | ^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -16,7 +16,7 @@ error: `[u8; 1 + 2]` is forbidden as the type of a const generic parameter LL | struct Foo<const N: [u8; 1 + 2]>; | ^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/issues/issue-74255.min.stderr b/tests/ui/const-generics/issues/issue-74255.min.stderr index 800902860a7..3b30227a9a6 100644 --- a/tests/ui/const-generics/issues/issue-74255.min.stderr +++ b/tests/ui/const-generics/issues/issue-74255.min.stderr @@ -4,7 +4,7 @@ error: `IceEnum` is forbidden as the type of a const generic parameter LL | fn ice_struct_fn<const I: IceEnum>() {} | ^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/issues/issue-74950.min.stderr b/tests/ui/const-generics/issues/issue-74950.min.stderr index 086176d9959..22537af786b 100644 --- a/tests/ui/const-generics/issues/issue-74950.min.stderr +++ b/tests/ui/const-generics/issues/issue-74950.min.stderr @@ -4,7 +4,7 @@ error: `Inner` is forbidden as the type of a const generic parameter LL | struct Outer<const I: Inner>; | ^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -16,7 +16,7 @@ error: `Inner` is forbidden as the type of a const generic parameter LL | struct Outer<const I: Inner>; | ^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | @@ -29,7 +29,7 @@ error: `Inner` is forbidden as the type of a const generic parameter LL | struct Outer<const I: Inner>; | ^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | @@ -42,7 +42,7 @@ error: `Inner` is forbidden as the type of a const generic parameter LL | struct Outer<const I: Inner>; | ^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | diff --git a/tests/ui/const-generics/issues/issue-75047.min.stderr b/tests/ui/const-generics/issues/issue-75047.min.stderr index f2cc76b9bed..d78ab671820 100644 --- a/tests/ui/const-generics/issues/issue-75047.min.stderr +++ b/tests/ui/const-generics/issues/issue-75047.min.stderr @@ -4,7 +4,7 @@ error: `[u8; Bar::<u32>::value()]` is forbidden as the type of a const generic p LL | struct Foo<const N: [u8; Bar::<u32>::value()]>; | ^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/lifetime-in-const-param.rs b/tests/ui/const-generics/lifetime-in-const-param.rs index be90dbb213e..ce6b52b229f 100644 --- a/tests/ui/const-generics/lifetime-in-const-param.rs +++ b/tests/ui/const-generics/lifetime-in-const-param.rs @@ -4,6 +4,5 @@ struct S2<'b>(&'b ()); struct S<'a, const N: S2>(&'a ()); //~^ ERROR missing lifetime specifier [E0106] -//~| ERROR `S2<'_>` is forbidden as the type of a const generic parameter fn main() {} diff --git a/tests/ui/const-generics/lifetime-in-const-param.stderr b/tests/ui/const-generics/lifetime-in-const-param.stderr index 4096725c52a..7c9d27c1e28 100644 --- a/tests/ui/const-generics/lifetime-in-const-param.stderr +++ b/tests/ui/const-generics/lifetime-in-const-param.stderr @@ -4,18 +4,6 @@ error[E0106]: missing lifetime specifier LL | struct S<'a, const N: S2>(&'a ()); | ^^ expected named lifetime parameter -error: `S2<'_>` is forbidden as the type of a const generic parameter - --> $DIR/lifetime-in-const-param.rs:5:23 - | -LL | struct S<'a, const N: S2>(&'a ()); - | ^^ - | - = note: the only supported types are integers, `bool` and `char` -help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types - | -LL + #![feature(adt_const_params)] - | - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0106`. diff --git a/tests/ui/const-generics/min_const_generics/complex-types.stderr b/tests/ui/const-generics/min_const_generics/complex-types.stderr index 0211770f9e5..bca68982c39 100644 --- a/tests/ui/const-generics/min_const_generics/complex-types.stderr +++ b/tests/ui/const-generics/min_const_generics/complex-types.stderr @@ -4,7 +4,7 @@ error: `[u8; 0]` is forbidden as the type of a const generic parameter LL | struct Foo<const N: [u8; 0]>; | ^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -16,7 +16,7 @@ error: `()` is forbidden as the type of a const generic parameter LL | struct Bar<const N: ()>; | ^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -28,7 +28,7 @@ error: `No` is forbidden as the type of a const generic parameter LL | struct Fez<const N: No>; | ^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -40,7 +40,7 @@ error: `&'static u8` is forbidden as the type of a const generic parameter LL | struct Faz<const N: &'static u8>; | ^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -56,7 +56,7 @@ error: `!` is forbidden as the type of a const generic parameter LL | struct Fiz<const N: !>; | ^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: `()` is forbidden as the type of a const generic parameter --> $DIR/complex-types.rs:20:19 @@ -64,7 +64,7 @@ error: `()` is forbidden as the type of a const generic parameter LL | enum Goo<const N: ()> { A, B } | ^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -76,7 +76,7 @@ error: `()` is forbidden as the type of a const generic parameter LL | union Boo<const N: ()> { a: () } | ^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/nested-type.min.stderr b/tests/ui/const-generics/nested-type.min.stderr index 0da2b30e3f1..8696be3faf3 100644 --- a/tests/ui/const-generics/nested-type.min.stderr +++ b/tests/ui/const-generics/nested-type.min.stderr @@ -29,7 +29,7 @@ LL | | LL | | }]>; | |__^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/not_wf_param_in_rpitit.rs b/tests/ui/const-generics/not_wf_param_in_rpitit.rs index 5471dc9022f..eb672194340 100644 --- a/tests/ui/const-generics/not_wf_param_in_rpitit.rs +++ b/tests/ui/const-generics/not_wf_param_in_rpitit.rs @@ -6,7 +6,6 @@ trait Trait<const N: Trait = bar> { //~| ERROR: the trait `Trait` cannot be made into an object //~| ERROR: the trait `Trait` cannot be made into an object //~| ERROR: the trait `Trait` cannot be made into an object - //~| ERROR: `(dyn Trait<{const error}> + 'static)` is forbidden as the type of a const generic parameter //~| ERROR: trait objects must include the `dyn` keyword async fn a() {} } diff --git a/tests/ui/const-generics/not_wf_param_in_rpitit.stderr b/tests/ui/const-generics/not_wf_param_in_rpitit.stderr index 82e251f1306..ade40550c73 100644 --- a/tests/ui/const-generics/not_wf_param_in_rpitit.stderr +++ b/tests/ui/const-generics/not_wf_param_in_rpitit.stderr @@ -25,7 +25,7 @@ LL | trait Trait<const N: Trait = bar> { | ^^^^^ `Trait` cannot be made into an object | note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> - --> $DIR/not_wf_param_in_rpitit.rs:11:14 + --> $DIR/not_wf_param_in_rpitit.rs:10:14 | LL | trait Trait<const N: Trait = bar> { | ----- this trait cannot be made into an object... @@ -48,7 +48,7 @@ LL | trait Trait<const N: Trait = bar> { | ^^^^^^^^^^^^^^^^^^^^ `Trait` cannot be made into an object | note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> - --> $DIR/not_wf_param_in_rpitit.rs:11:14 + --> $DIR/not_wf_param_in_rpitit.rs:10:14 | LL | trait Trait<const N: Trait = bar> { | ----- this trait cannot be made into an object... @@ -64,14 +64,6 @@ help: alternatively, consider constraining `a` so it does not apply to trait obj LL | async fn a() where Self: Sized {} | +++++++++++++++++ -error: `(dyn Trait<{const error}> + 'static)` is forbidden as the type of a const generic parameter - --> $DIR/not_wf_param_in_rpitit.rs:3:22 - | -LL | trait Trait<const N: Trait = bar> { - | ^^^^^ - | - = note: the only supported types are integers, `bool` and `char` - error[E0038]: the trait `Trait` cannot be made into an object --> $DIR/not_wf_param_in_rpitit.rs:3:13 | @@ -79,7 +71,7 @@ LL | trait Trait<const N: Trait = bar> { | ^^^^^^^^^^^^^^^^^^^^ `Trait` cannot be made into an object | note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> - --> $DIR/not_wf_param_in_rpitit.rs:11:14 + --> $DIR/not_wf_param_in_rpitit.rs:10:14 | LL | trait Trait<const N: Trait = bar> { | ----- this trait cannot be made into an object... @@ -107,7 +99,7 @@ help: add `dyn` keyword before this trait LL | trait Trait<const N: dyn Trait = bar> { | +++ -error: aborting due to 7 previous errors +error: aborting due to 6 previous errors Some errors have detailed explanations: E0038, E0391, E0425, E0782. For more information about an error, try `rustc --explain E0038`. diff --git a/tests/ui/const-generics/opaque_types.stderr b/tests/ui/const-generics/opaque_types.stderr index 3947d645fcb..847f1da16f6 100644 --- a/tests/ui/const-generics/opaque_types.stderr +++ b/tests/ui/const-generics/opaque_types.stderr @@ -74,7 +74,7 @@ error: `Foo` is forbidden as the type of a const generic parameter LL | fn foo<const C: Foo>() {} | ^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error[E0391]: cycle detected when computing type of opaque `Foo::{opaque#0}` --> $DIR/opaque_types.rs:3:12 diff --git a/tests/ui/const-generics/projection-as-arg-const.stderr b/tests/ui/const-generics/projection-as-arg-const.stderr index 88672bce0a7..f6e7620db7d 100644 --- a/tests/ui/const-generics/projection-as-arg-const.stderr +++ b/tests/ui/const-generics/projection-as-arg-const.stderr @@ -4,7 +4,7 @@ error: `<i32 as Identity>::Identity` is forbidden as the type of a const generic LL | pub fn foo<const X: <i32 as Identity>::Identity>() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/raw-ptr-const-param-deref.min.stderr b/tests/ui/const-generics/raw-ptr-const-param-deref.min.stderr index 6027dbb01cd..fca2966e3a3 100644 --- a/tests/ui/const-generics/raw-ptr-const-param-deref.min.stderr +++ b/tests/ui/const-generics/raw-ptr-const-param-deref.min.stderr @@ -4,7 +4,7 @@ error: using raw pointers as const generic parameters is forbidden LL | struct Const<const P: *const u32>; | ^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: using raw pointers as const generic parameters is forbidden --> $DIR/raw-ptr-const-param-deref.rs:13:15 @@ -12,7 +12,7 @@ error: using raw pointers as const generic parameters is forbidden LL | impl<const P: *const u32> Const<P> { | ^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/raw-ptr-const-param.min.stderr b/tests/ui/const-generics/raw-ptr-const-param.min.stderr index c48eea069e0..5694b12f2d5 100644 --- a/tests/ui/const-generics/raw-ptr-const-param.min.stderr +++ b/tests/ui/const-generics/raw-ptr-const-param.min.stderr @@ -4,7 +4,7 @@ error: using raw pointers as const generic parameters is forbidden LL | struct Const<const P: *const u32>; | ^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error[E0308]: mismatched types --> $DIR/raw-ptr-const-param.rs:11:40 diff --git a/tests/ui/const-generics/slice-const-param-mismatch.min.stderr b/tests/ui/const-generics/slice-const-param-mismatch.min.stderr index 3b2410c9894..594f8b9b79a 100644 --- a/tests/ui/const-generics/slice-const-param-mismatch.min.stderr +++ b/tests/ui/const-generics/slice-const-param-mismatch.min.stderr @@ -4,7 +4,7 @@ error: `&'static str` is forbidden as the type of a const generic parameter LL | struct ConstString<const T: &'static str>; | ^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -20,7 +20,7 @@ error: `&'static [u8]` is forbidden as the type of a const generic parameter LL | struct ConstBytes<const T: &'static [u8]>; | ^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/std/const-generics-range.min.stderr b/tests/ui/const-generics/std/const-generics-range.min.stderr index 67f137cf1a0..fd23b9b248a 100644 --- a/tests/ui/const-generics/std/const-generics-range.min.stderr +++ b/tests/ui/const-generics/std/const-generics-range.min.stderr @@ -4,7 +4,7 @@ error: `std::ops::Range<usize>` is forbidden as the type of a const generic para LL | struct _Range<const R: std::ops::Range<usize>>; | ^^^^^^^^^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -16,7 +16,7 @@ error: `RangeFrom<usize>` is forbidden as the type of a const generic parameter LL | struct _RangeFrom<const R: std::ops::RangeFrom<usize>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -28,7 +28,7 @@ error: `RangeFull` is forbidden as the type of a const generic parameter LL | struct _RangeFull<const R: std::ops::RangeFull>; | ^^^^^^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -40,7 +40,7 @@ error: `RangeInclusive<usize>` is forbidden as the type of a const generic param LL | struct _RangeInclusive<const R: std::ops::RangeInclusive<usize>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -52,7 +52,7 @@ error: `RangeTo<usize>` is forbidden as the type of a const generic parameter LL | struct _RangeTo<const R: std::ops::RangeTo<usize>>; | ^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -64,7 +64,7 @@ error: `RangeToInclusive<usize>` is forbidden as the type of a const generic par LL | struct _RangeToInclusive<const R: std::ops::RangeToInclusive<usize>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/transmute-const-param-static-reference.min.stderr b/tests/ui/const-generics/transmute-const-param-static-reference.min.stderr index cf236487cf0..911afa3391d 100644 --- a/tests/ui/const-generics/transmute-const-param-static-reference.min.stderr +++ b/tests/ui/const-generics/transmute-const-param-static-reference.min.stderr @@ -4,7 +4,7 @@ error: `&'static ()` is forbidden as the type of a const generic parameter LL | struct Const<const P: &'static ()>; | ^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/type-dependent/issue-71348.min.stderr b/tests/ui/const-generics/type-dependent/issue-71348.min.stderr index 5aee282952a..8995c415863 100644 --- a/tests/ui/const-generics/type-dependent/issue-71348.min.stderr +++ b/tests/ui/const-generics/type-dependent/issue-71348.min.stderr @@ -12,7 +12,7 @@ error: `&'static str` is forbidden as the type of a const generic parameter LL | trait Get<'a, const N: &'static str> { | ^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -28,7 +28,7 @@ error: `&'static str` is forbidden as the type of a const generic parameter LL | fn ask<'a, const N: &'static str>(&'a self) -> &'a <Self as Get<N>>::Target | ^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/const-generics/type-dependent/issue-71382.stderr b/tests/ui/const-generics/type-dependent/issue-71382.stderr index 69fd6f1c7d5..3830b1527c3 100644 --- a/tests/ui/const-generics/type-dependent/issue-71382.stderr +++ b/tests/ui/const-generics/type-dependent/issue-71382.stderr @@ -4,7 +4,7 @@ error: using function pointers as const generic parameters is forbidden LL | fn test<const FN: fn() -> u8>(&self) -> u8 { | ^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: aborting due to 1 previous error diff --git a/tests/ui/consts/auxiliary/unstable_but_const_stable.rs b/tests/ui/consts/auxiliary/unstable_but_const_stable.rs new file mode 100644 index 00000000000..88044b0272c --- /dev/null +++ b/tests/ui/consts/auxiliary/unstable_but_const_stable.rs @@ -0,0 +1,13 @@ +#![feature(staged_api, rustc_attrs, intrinsics)] +#![stable(since="1.0.0", feature = "stable")] + +extern "rust-intrinsic" { + #[unstable(feature = "unstable", issue = "42")] + #[rustc_const_stable(feature = "stable", since = "1.0.0")] + #[rustc_nounwind] + pub fn write_bytes<T>(dst: *mut T, val: u8, count: usize); +} + +#[unstable(feature = "unstable", issue = "42")] +#[rustc_const_stable(feature = "stable", since = "1.0.0")] +pub const fn some_unstable_fn() {} diff --git a/tests/ui/consts/issue-103790.rs b/tests/ui/consts/issue-103790.rs index d19115ede74..869a43e4018 100644 --- a/tests/ui/consts/issue-103790.rs +++ b/tests/ui/consts/issue-103790.rs @@ -6,6 +6,5 @@ struct S<const S: (), const S: S = { S }>; //~| ERROR missing generics for struct `S` //~| ERROR cycle detected when computing type of `S::S` //~| ERROR `()` is forbidden as the type of a const generic parameter -//~| ERROR `S<{const error}, {const error}>` is forbidden as the type of a const generic parameter fn main() {} diff --git a/tests/ui/consts/issue-103790.stderr b/tests/ui/consts/issue-103790.stderr index c671f078cb5..1515fa60a5c 100644 --- a/tests/ui/consts/issue-103790.stderr +++ b/tests/ui/consts/issue-103790.stderr @@ -42,25 +42,13 @@ error: `()` is forbidden as the type of a const generic parameter LL | struct S<const S: (), const S: S = { S }>; | ^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] | -error: `S<{const error}, {const error}>` is forbidden as the type of a const generic parameter - --> $DIR/issue-103790.rs:4:32 - | -LL | struct S<const S: (), const S: S = { S }>; - | ^ - | - = note: the only supported types are integers, `bool` and `char` -help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types - | -LL + #![feature(adt_const_params)] - | - -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors Some errors have detailed explanations: E0107, E0391, E0403. For more information about an error, try `rustc --explain E0107`. diff --git a/tests/ui/consts/unstable-const-stable.rs b/tests/ui/consts/unstable-const-stable.rs new file mode 100644 index 00000000000..f69e8d0efe5 --- /dev/null +++ b/tests/ui/consts/unstable-const-stable.rs @@ -0,0 +1,14 @@ +//@ aux-build:unstable_but_const_stable.rs + +extern crate unstable_but_const_stable; +use unstable_but_const_stable::*; + +fn main() { + some_unstable_fn(); //~ERROR use of unstable library feature + unsafe { write_bytes(4 as *mut u8, 0, 0) }; //~ERROR use of unstable library feature +} + +const fn const_main() { + some_unstable_fn(); //~ERROR use of unstable library feature + unsafe { write_bytes(4 as *mut u8, 0, 0) }; //~ERROR use of unstable library feature +} diff --git a/tests/ui/consts/unstable-const-stable.stderr b/tests/ui/consts/unstable-const-stable.stderr new file mode 100644 index 00000000000..c4ffbbb60db --- /dev/null +++ b/tests/ui/consts/unstable-const-stable.stderr @@ -0,0 +1,43 @@ +error[E0658]: use of unstable library feature 'unstable' + --> $DIR/unstable-const-stable.rs:7:5 + | +LL | some_unstable_fn(); + | ^^^^^^^^^^^^^^^^ + | + = note: see issue #42 <https://github.com/rust-lang/rust/issues/42> for more information + = help: add `#![feature(unstable)]` 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]: use of unstable library feature 'unstable' + --> $DIR/unstable-const-stable.rs:8:14 + | +LL | unsafe { write_bytes(4 as *mut u8, 0, 0) }; + | ^^^^^^^^^^^ + | + = note: see issue #42 <https://github.com/rust-lang/rust/issues/42> for more information + = help: add `#![feature(unstable)]` 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]: use of unstable library feature 'unstable' + --> $DIR/unstable-const-stable.rs:12:5 + | +LL | some_unstable_fn(); + | ^^^^^^^^^^^^^^^^ + | + = note: see issue #42 <https://github.com/rust-lang/rust/issues/42> for more information + = help: add `#![feature(unstable)]` 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]: use of unstable library feature 'unstable' + --> $DIR/unstable-const-stable.rs:13:14 + | +LL | unsafe { write_bytes(4 as *mut u8, 0, 0) }; + | ^^^^^^^^^^^ + | + = note: see issue #42 <https://github.com/rust-lang/rust/issues/42> for more information + = help: add `#![feature(unstable)]` 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 + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/drop/lint-if-let-rescope.fixed b/tests/ui/drop/lint-if-let-rescope.fixed index f228783f88b..199068d0fd2 100644 --- a/tests/ui/drop/lint-if-let-rescope.fixed +++ b/tests/ui/drop/lint-if-let-rescope.fixed @@ -1,8 +1,8 @@ //@ run-rustfix #![deny(if_let_rescope)] -#![feature(if_let_rescope)] -#![allow(irrefutable_let_patterns)] +#![feature(if_let_rescope, stmt_expr_attributes)] +#![allow(irrefutable_let_patterns, unused_parens)] fn droppy() -> Droppy { Droppy @@ -68,4 +68,30 @@ fn main() { //~| HELP: the value is now dropped here in Edition 2024 //~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021 } + + #[rustfmt::skip] + if (match droppy().get() { Some(_value) => { true } _ => { false }}) { + //~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024 + //~| WARN: this changes meaning in Rust 2024 + //~| HELP: the value is now dropped here in Edition 2024 + //~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021 + // do something + } else if (((match droppy().get() { Some(_value) => { true } _ => { false }}))) { + //~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024 + //~| WARN: this changes meaning in Rust 2024 + //~| HELP: the value is now dropped here in Edition 2024 + //~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021 + } + + while let Some(_value) = droppy().get() { + // Should not lint + break; + } + + while (match droppy().get() { Some(_value) => { false } _ => { true }}) { + //~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024 + //~| WARN: this changes meaning in Rust 2024 + //~| HELP: the value is now dropped here in Edition 2024 + //~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021 + } } diff --git a/tests/ui/drop/lint-if-let-rescope.rs b/tests/ui/drop/lint-if-let-rescope.rs index 241fb897fce..4c043c0266c 100644 --- a/tests/ui/drop/lint-if-let-rescope.rs +++ b/tests/ui/drop/lint-if-let-rescope.rs @@ -1,8 +1,8 @@ //@ run-rustfix #![deny(if_let_rescope)] -#![feature(if_let_rescope)] -#![allow(irrefutable_let_patterns)] +#![feature(if_let_rescope, stmt_expr_attributes)] +#![allow(irrefutable_let_patterns, unused_parens)] fn droppy() -> Droppy { Droppy @@ -68,4 +68,30 @@ fn main() { //~| HELP: the value is now dropped here in Edition 2024 //~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021 } + + #[rustfmt::skip] + if (if let Some(_value) = droppy().get() { true } else { false }) { + //~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024 + //~| WARN: this changes meaning in Rust 2024 + //~| HELP: the value is now dropped here in Edition 2024 + //~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021 + // do something + } else if (((if let Some(_value) = droppy().get() { true } else { false }))) { + //~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024 + //~| WARN: this changes meaning in Rust 2024 + //~| HELP: the value is now dropped here in Edition 2024 + //~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021 + } + + while let Some(_value) = droppy().get() { + // Should not lint + break; + } + + while (if let Some(_value) = droppy().get() { false } else { true }) { + //~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024 + //~| WARN: this changes meaning in Rust 2024 + //~| HELP: the value is now dropped here in Edition 2024 + //~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021 + } } diff --git a/tests/ui/drop/lint-if-let-rescope.stderr b/tests/ui/drop/lint-if-let-rescope.stderr index 25ca3cf1ca8..ef60d141b79 100644 --- a/tests/ui/drop/lint-if-let-rescope.stderr +++ b/tests/ui/drop/lint-if-let-rescope.stderr @@ -131,5 +131,65 @@ help: a `match` with a single arm can preserve the drop order up to Edition 2021 LL | if let () = { match Droppy.get() { Some(_value) => {} _ => {}} } { | ~~~~~ +++++++++++++++++ ++++++++ -error: aborting due to 5 previous errors +error: `if let` assigns a shorter lifetime since Edition 2024 + --> $DIR/lint-if-let-rescope.rs:73:12 + | +LL | if (if let Some(_value) = droppy().get() { true } else { false }) { + | ^^^^^^^^^^^^^^^^^^^--------^^^^^^ + | | + | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion + | + = warning: this changes meaning in Rust 2024 + = note: for more information, see issue #124085 <https://github.com/rust-lang/rust/issues/124085> +help: the value is now dropped here in Edition 2024 + --> $DIR/lint-if-let-rescope.rs:73:53 + | +LL | if (if let Some(_value) = droppy().get() { true } else { false }) { + | ^ +help: a `match` with a single arm can preserve the drop order up to Edition 2021 + | +LL | if (match droppy().get() { Some(_value) => { true } _ => { false }}) { + | ~~~~~ +++++++++++++++++ ~~~~ + + +error: `if let` assigns a shorter lifetime since Edition 2024 + --> $DIR/lint-if-let-rescope.rs:79:21 + | +LL | } else if (((if let Some(_value) = droppy().get() { true } else { false }))) { + | ^^^^^^^^^^^^^^^^^^^--------^^^^^^ + | | + | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion + | + = warning: this changes meaning in Rust 2024 + = note: for more information, see issue #124085 <https://github.com/rust-lang/rust/issues/124085> +help: the value is now dropped here in Edition 2024 + --> $DIR/lint-if-let-rescope.rs:79:62 + | +LL | } else if (((if let Some(_value) = droppy().get() { true } else { false }))) { + | ^ +help: a `match` with a single arm can preserve the drop order up to Edition 2021 + | +LL | } else if (((match droppy().get() { Some(_value) => { true } _ => { false }}))) { + | ~~~~~ +++++++++++++++++ ~~~~ + + +error: `if let` assigns a shorter lifetime since Edition 2024 + --> $DIR/lint-if-let-rescope.rs:91:15 + | +LL | while (if let Some(_value) = droppy().get() { false } else { true }) { + | ^^^^^^^^^^^^^^^^^^^--------^^^^^^ + | | + | this value has a significant drop implementation which may observe a major change in drop order and requires your discretion + | + = warning: this changes meaning in Rust 2024 + = note: for more information, see issue #124085 <https://github.com/rust-lang/rust/issues/124085> +help: the value is now dropped here in Edition 2024 + --> $DIR/lint-if-let-rescope.rs:91:57 + | +LL | while (if let Some(_value) = droppy().get() { false } else { true }) { + | ^ +help: a `match` with a single arm can preserve the drop order up to Edition 2021 + | +LL | while (match droppy().get() { Some(_value) => { false } _ => { true }}) { + | ~~~~~ +++++++++++++++++ ~~~~ + + +error: aborting due to 8 previous errors diff --git a/tests/ui/feature-gates/feature-gate-adt_const_params.stderr b/tests/ui/feature-gates/feature-gate-adt_const_params.stderr index 649e936888b..18d514f8cb5 100644 --- a/tests/ui/feature-gates/feature-gate-adt_const_params.stderr +++ b/tests/ui/feature-gates/feature-gate-adt_const_params.stderr @@ -4,7 +4,7 @@ error: `&'static str` is forbidden as the type of a const generic parameter LL | struct Foo<const NAME: &'static str>; | ^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/feature-gates/feature-gate-unsized-const-params.stderr b/tests/ui/feature-gates/feature-gate-unsized-const-params.stderr index 0a87f34f4f5..85ca2f59cb6 100644 --- a/tests/ui/feature-gates/feature-gate-unsized-const-params.stderr +++ b/tests/ui/feature-gates/feature-gate-unsized-const-params.stderr @@ -4,7 +4,7 @@ error: `[u8]` is forbidden as the type of a const generic parameter LL | struct Foo<const N: [u8]>; | ^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/generic-const-items/elided-lifetimes.rs b/tests/ui/generic-const-items/elided-lifetimes.rs index cca73e2e81e..90899de5af6 100644 --- a/tests/ui/generic-const-items/elided-lifetimes.rs +++ b/tests/ui/generic-const-items/elided-lifetimes.rs @@ -9,7 +9,6 @@ where const I<const S: &str>: &str = ""; //~^ ERROR `&` without an explicit lifetime name cannot be used here -//~| ERROR `&str` is forbidden as the type of a const generic parameter const B<T: Trait<'_>>: () = (); //~ ERROR `'_` cannot be used here diff --git a/tests/ui/generic-const-items/elided-lifetimes.stderr b/tests/ui/generic-const-items/elided-lifetimes.stderr index 85807a1b631..2b543d02b5d 100644 --- a/tests/ui/generic-const-items/elided-lifetimes.stderr +++ b/tests/ui/generic-const-items/elided-lifetimes.stderr @@ -16,27 +16,11 @@ LL | const I<const S: &str>: &str = ""; | ^ explicit lifetime name needed here error[E0637]: `'_` cannot be used here - --> $DIR/elided-lifetimes.rs:14:18 + --> $DIR/elided-lifetimes.rs:13:18 | LL | const B<T: Trait<'_>>: () = (); | ^^ `'_` is a reserved lifetime name -error: `&str` is forbidden as the type of a const generic parameter - --> $DIR/elided-lifetimes.rs:10:18 - | -LL | const I<const S: &str>: &str = ""; - | ^^^^ - | - = note: the only supported types are integers, `bool` and `char` -help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types - | -LL + #![feature(adt_const_params)] - | -help: add `#![feature(unsized_const_params)]` to the crate attributes to enable references to implement the `ConstParamTy` trait - | -LL + #![feature(unsized_const_params)] - | - -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0637`. diff --git a/tests/ui/generic-const-items/wfcheck_err_leak_issue_118179.rs b/tests/ui/generic-const-items/wfcheck_err_leak_issue_118179.rs new file mode 100644 index 00000000000..856f7b622d7 --- /dev/null +++ b/tests/ui/generic-const-items/wfcheck_err_leak_issue_118179.rs @@ -0,0 +1,7 @@ +//! Regression test for #118179: `adt_const_params` feature shouldn't leak +//! `{type error}` in error messages. + +struct G<T, const N: Vec<T>>(T); +//~^ ERROR the type of const parameters must not depend on other generic parameters + +fn main() {} diff --git a/tests/ui/generic-const-items/wfcheck_err_leak_issue_118179.stderr b/tests/ui/generic-const-items/wfcheck_err_leak_issue_118179.stderr new file mode 100644 index 00000000000..654004571db --- /dev/null +++ b/tests/ui/generic-const-items/wfcheck_err_leak_issue_118179.stderr @@ -0,0 +1,11 @@ +error[E0770]: the type of const parameters must not depend on other generic parameters + --> $DIR/wfcheck_err_leak_issue_118179.rs:4:26 + | +LL | struct G<T, const N: Vec<T>>(T); + | ^ the type must not depend on the parameter `T` + | + = note: type parameters may not be used in the type of const parameters + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0770`. diff --git a/tests/ui/lifetimes/unusual-rib-combinations.rs b/tests/ui/lifetimes/unusual-rib-combinations.rs index 0708a00d371..0e92b41ae1e 100644 --- a/tests/ui/lifetimes/unusual-rib-combinations.rs +++ b/tests/ui/lifetimes/unusual-rib-combinations.rs @@ -20,11 +20,9 @@ fn c<T = u8()>() {} // Elided lifetime in path in ConstGeneric fn d<const C: S>() {} //~^ ERROR missing lifetime specifier -//~| ERROR `S<'_>` is forbidden as the type of a const generic parameter trait Foo<'a> {} struct Bar<const N: &'a (dyn for<'a> Foo<'a>)>; //~^ ERROR the type of const parameters must not depend on other generic parameters -//~| ERROR `&dyn for<'a> Foo<'a>` is forbidden as the type of a const generic parameter fn main() {} diff --git a/tests/ui/lifetimes/unusual-rib-combinations.stderr b/tests/ui/lifetimes/unusual-rib-combinations.stderr index ebf6f6ca403..b7effdc8d61 100644 --- a/tests/ui/lifetimes/unusual-rib-combinations.stderr +++ b/tests/ui/lifetimes/unusual-rib-combinations.stderr @@ -5,7 +5,7 @@ LL | fn d<const C: S>() {} | ^ expected named lifetime parameter error[E0770]: the type of const parameters must not depend on other generic parameters - --> $DIR/unusual-rib-combinations.rs:26:22 + --> $DIR/unusual-rib-combinations.rs:25:22 | LL | struct Bar<const N: &'a (dyn for<'a> Foo<'a>)>; | ^^ the type must not depend on the parameter `'a` @@ -40,35 +40,7 @@ error[E0308]: mismatched types LL | fn a() -> [u8; foo()] { | ^^^^^ expected `usize`, found `()` -error: `S<'_>` is forbidden as the type of a const generic parameter - --> $DIR/unusual-rib-combinations.rs:21:15 - | -LL | fn d<const C: S>() {} - | ^ - | - = note: the only supported types are integers, `bool` and `char` -help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types - | -LL + #![feature(adt_const_params)] - | - -error: `&dyn for<'a> Foo<'a>` is forbidden as the type of a const generic parameter - --> $DIR/unusual-rib-combinations.rs:26:21 - | -LL | struct Bar<const N: &'a (dyn for<'a> Foo<'a>)>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the only supported types are integers, `bool` and `char` -help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types - | -LL + #![feature(adt_const_params)] - | -help: add `#![feature(unsized_const_params)]` to the crate attributes to enable references to implement the `ConstParamTy` trait - | -LL + #![feature(unsized_const_params)] - | - -error: aborting due to 8 previous errors +error: aborting due to 6 previous errors Some errors have detailed explanations: E0106, E0214, E0308, E0770. For more information about an error, try `rustc --explain E0106`. diff --git a/tests/ui/lint/unused/unused-macro-with-bad-frag-spec.stderr b/tests/ui/lint/unused/unused-macro-with-bad-frag-spec.stderr index f027e169b42..003c6975c95 100644 --- a/tests/ui/lint/unused/unused-macro-with-bad-frag-spec.stderr +++ b/tests/ui/lint/unused/unused-macro-with-bad-frag-spec.stderr @@ -4,7 +4,7 @@ error: invalid fragment specifier `t_ty` LL | ($wrong:t_ty) => () | ^^^^^^^^^^^ | - = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis` + = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`, along with `expr_2021` and `pat_param` for edition compatibility error: aborting due to 1 previous error diff --git a/tests/ui/macros/expr_2021.rs b/tests/ui/macros/expr_2021.rs new file mode 100644 index 00000000000..8a274e77533 --- /dev/null +++ b/tests/ui/macros/expr_2021.rs @@ -0,0 +1,14 @@ +//@ check-pass +//@ edition: 2015 + +// Ensures expr_2021 fragment specifier is accepted in old editions + +macro_rules! my_macro { + ($x:expr_2021) => { + println!("Hello, {}!", $x); + }; +} + +fn main() { + my_macro!("world"); +} diff --git a/tests/ui/macros/expr_2021_cargo_fix_edition.fixed b/tests/ui/macros/expr_2021_cargo_fix_edition.fixed index 1becd8a92d6..061a4b98033 100644 --- a/tests/ui/macros/expr_2021_cargo_fix_edition.fixed +++ b/tests/ui/macros/expr_2021_cargo_fix_edition.fixed @@ -1,8 +1,6 @@ //@ run-rustfix //@ check-pass //@ compile-flags: --edition=2021 -#![allow(incomplete_features)] -#![feature(expr_fragment_specifier_2024)] #![warn(edition_2024_expr_fragment_specifier)] macro_rules! m { diff --git a/tests/ui/macros/expr_2021_cargo_fix_edition.rs b/tests/ui/macros/expr_2021_cargo_fix_edition.rs index ec0b86d2c23..cd9cd965fad 100644 --- a/tests/ui/macros/expr_2021_cargo_fix_edition.rs +++ b/tests/ui/macros/expr_2021_cargo_fix_edition.rs @@ -1,8 +1,6 @@ //@ run-rustfix //@ check-pass //@ compile-flags: --edition=2021 -#![allow(incomplete_features)] -#![feature(expr_fragment_specifier_2024)] #![warn(edition_2024_expr_fragment_specifier)] macro_rules! m { diff --git a/tests/ui/macros/expr_2021_cargo_fix_edition.stderr b/tests/ui/macros/expr_2021_cargo_fix_edition.stderr index e8a44fed322..fe1fd4a26a0 100644 --- a/tests/ui/macros/expr_2021_cargo_fix_edition.stderr +++ b/tests/ui/macros/expr_2021_cargo_fix_edition.stderr @@ -1,5 +1,5 @@ warning: the `expr` fragment specifier will accept more expressions in the 2024 edition - --> $DIR/expr_2021_cargo_fix_edition.rs:9:9 + --> $DIR/expr_2021_cargo_fix_edition.rs:7:9 | LL | ($e:expr) => { | ^^^^ @@ -7,7 +7,7 @@ LL | ($e:expr) => { = warning: this changes meaning in Rust 2024 = note: for more information, see Migration Guide <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/macro-fragment-specifiers.html> note: the lint level is defined here - --> $DIR/expr_2021_cargo_fix_edition.rs:6:9 + --> $DIR/expr_2021_cargo_fix_edition.rs:4:9 | LL | #![warn(edition_2024_expr_fragment_specifier)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | ($e:expr_2021) => { | ~~~~~~~~~ warning: the `expr` fragment specifier will accept more expressions in the 2024 edition - --> $DIR/expr_2021_cargo_fix_edition.rs:13:11 + --> $DIR/expr_2021_cargo_fix_edition.rs:11:11 | LL | ($($i:expr)*) => { }; | ^^^^ diff --git a/tests/ui/macros/expr_2021_inline_const.edi2021.stderr b/tests/ui/macros/expr_2021_inline_const.edi2021.stderr index b55ae62030c..22d662aaaf2 100644 --- a/tests/ui/macros/expr_2021_inline_const.edi2021.stderr +++ b/tests/ui/macros/expr_2021_inline_const.edi2021.stderr @@ -1,5 +1,5 @@ error: no rules expected the token `const` - --> $DIR/expr_2021_inline_const.rs:26:12 + --> $DIR/expr_2021_inline_const.rs:23:12 | LL | macro_rules! m2021 { | ------------------ when calling this macro @@ -8,13 +8,13 @@ LL | m2021!(const { 1 }); | ^^^^^ no rules expected this token in macro call | note: while trying to match meta-variable `$e:expr_2021` - --> $DIR/expr_2021_inline_const.rs:10:6 + --> $DIR/expr_2021_inline_const.rs:7:6 | LL | ($e:expr_2021) => { | ^^^^^^^^^^^^ error: no rules expected the token `const` - --> $DIR/expr_2021_inline_const.rs:27:12 + --> $DIR/expr_2021_inline_const.rs:24:12 | LL | macro_rules! m2024 { | ------------------ when calling this macro @@ -23,7 +23,7 @@ LL | m2024!(const { 1 }); | ^^^^^ no rules expected this token in macro call | note: while trying to match meta-variable `$e:expr` - --> $DIR/expr_2021_inline_const.rs:16:6 + --> $DIR/expr_2021_inline_const.rs:13:6 | LL | ($e:expr) => { | ^^^^^^^ diff --git a/tests/ui/macros/expr_2021_inline_const.edi2024.stderr b/tests/ui/macros/expr_2021_inline_const.edi2024.stderr index 285db53d6c8..2555e4f757a 100644 --- a/tests/ui/macros/expr_2021_inline_const.edi2024.stderr +++ b/tests/ui/macros/expr_2021_inline_const.edi2024.stderr @@ -1,5 +1,5 @@ error: no rules expected the token `const` - --> $DIR/expr_2021_inline_const.rs:26:12 + --> $DIR/expr_2021_inline_const.rs:23:12 | LL | macro_rules! m2021 { | ------------------ when calling this macro @@ -8,7 +8,7 @@ LL | m2021!(const { 1 }); | ^^^^^ no rules expected this token in macro call | note: while trying to match meta-variable `$e:expr_2021` - --> $DIR/expr_2021_inline_const.rs:10:6 + --> $DIR/expr_2021_inline_const.rs:7:6 | LL | ($e:expr_2021) => { | ^^^^^^^^^^^^ diff --git a/tests/ui/macros/expr_2021_inline_const.rs b/tests/ui/macros/expr_2021_inline_const.rs index 06b74a466d6..39a542fe4d9 100644 --- a/tests/ui/macros/expr_2021_inline_const.rs +++ b/tests/ui/macros/expr_2021_inline_const.rs @@ -3,9 +3,6 @@ //@[edi2021]compile-flags: --edition=2021 // This test ensures that the inline const match only on edition 2024 -#![feature(expr_fragment_specifier_2024)] -#![allow(incomplete_features)] - macro_rules! m2021 { ($e:expr_2021) => { $e diff --git a/tests/ui/macros/expr_2024_underscore_expr.edi2021.stderr b/tests/ui/macros/expr_2024_underscore_expr.edi2021.stderr index 335b3f61343..34df20a69ef 100644 --- a/tests/ui/macros/expr_2024_underscore_expr.edi2021.stderr +++ b/tests/ui/macros/expr_2024_underscore_expr.edi2021.stderr @@ -1,5 +1,5 @@ error: no rules expected the token `_` - --> $DIR/expr_2024_underscore_expr.rs:22:12 + --> $DIR/expr_2024_underscore_expr.rs:19:12 | LL | macro_rules! m2021 { | ------------------ when calling this macro @@ -8,13 +8,13 @@ LL | m2021!(_); | ^ no rules expected this token in macro call | note: while trying to match meta-variable `$e:expr_2021` - --> $DIR/expr_2024_underscore_expr.rs:10:6 + --> $DIR/expr_2024_underscore_expr.rs:7:6 | LL | ($e:expr_2021) => { | ^^^^^^^^^^^^ error: no rules expected the token `_` - --> $DIR/expr_2024_underscore_expr.rs:23:12 + --> $DIR/expr_2024_underscore_expr.rs:20:12 | LL | macro_rules! m2024 { | ------------------ when calling this macro @@ -23,7 +23,7 @@ LL | m2024!(_); | ^ no rules expected this token in macro call | note: while trying to match meta-variable `$e:expr` - --> $DIR/expr_2024_underscore_expr.rs:16:6 + --> $DIR/expr_2024_underscore_expr.rs:13:6 | LL | ($e:expr) => { | ^^^^^^^ diff --git a/tests/ui/macros/expr_2024_underscore_expr.edi2024.stderr b/tests/ui/macros/expr_2024_underscore_expr.edi2024.stderr index 9e49f66a89a..372c5d8637c 100644 --- a/tests/ui/macros/expr_2024_underscore_expr.edi2024.stderr +++ b/tests/ui/macros/expr_2024_underscore_expr.edi2024.stderr @@ -1,5 +1,5 @@ error: no rules expected the token `_` - --> $DIR/expr_2024_underscore_expr.rs:22:12 + --> $DIR/expr_2024_underscore_expr.rs:19:12 | LL | macro_rules! m2021 { | ------------------ when calling this macro @@ -8,7 +8,7 @@ LL | m2021!(_); | ^ no rules expected this token in macro call | note: while trying to match meta-variable `$e:expr_2021` - --> $DIR/expr_2024_underscore_expr.rs:10:6 + --> $DIR/expr_2024_underscore_expr.rs:7:6 | LL | ($e:expr_2021) => { | ^^^^^^^^^^^^ diff --git a/tests/ui/macros/expr_2024_underscore_expr.rs b/tests/ui/macros/expr_2024_underscore_expr.rs index b2129bf154f..86e31374506 100644 --- a/tests/ui/macros/expr_2024_underscore_expr.rs +++ b/tests/ui/macros/expr_2024_underscore_expr.rs @@ -3,9 +3,6 @@ //@[edi2021]compile-flags: --edition=2021 // This test ensures that the `_` tok is considered an // expression on edition 2024. -#![feature(expr_fragment_specifier_2024)] -#![allow(incomplete_features)] - macro_rules! m2021 { ($e:expr_2021) => { $e = 1; diff --git a/tests/ui/macros/feature-gate-expr_fragment_specifier_2024.rs b/tests/ui/macros/feature-gate-expr_fragment_specifier_2024.rs deleted file mode 100644 index 5a737b29821..00000000000 --- a/tests/ui/macros/feature-gate-expr_fragment_specifier_2024.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ compile-flags: --edition=2024 -Z unstable-options - -macro_rules! m { - ($e:expr_2021) => { //~ ERROR: fragment specifier `expr_2021` is unstable - $e - }; -} - -fn main() { - m!(()); -} diff --git a/tests/ui/macros/feature-gate-expr_fragment_specifier_2024.stderr b/tests/ui/macros/feature-gate-expr_fragment_specifier_2024.stderr deleted file mode 100644 index 273a93877ce..00000000000 --- a/tests/ui/macros/feature-gate-expr_fragment_specifier_2024.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0658]: fragment specifier `expr_2021` is unstable - --> $DIR/feature-gate-expr_fragment_specifier_2024.rs:4:6 - | -LL | ($e:expr_2021) => { - | ^^^^^^^^^^^^ - | - = note: see issue #123742 <https://github.com/rust-lang/rust/issues/123742> for more information - = help: add `#![feature(expr_fragment_specifier_2024)]` 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 - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/macros/invalid-fragment-specifier.stderr b/tests/ui/macros/invalid-fragment-specifier.stderr index 7516dbc3a08..a51ea619b36 100644 --- a/tests/ui/macros/invalid-fragment-specifier.stderr +++ b/tests/ui/macros/invalid-fragment-specifier.stderr @@ -4,7 +4,7 @@ error: invalid fragment specifier `id` LL | ($wrong:id) => {}; | ^^^^^^^^^ | - = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis` + = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`, along with `expr_2021` and `pat_param` for edition compatibility error: invalid fragment specifier `r#if` --> $DIR/invalid-fragment-specifier.rs:7:6 @@ -12,7 +12,7 @@ error: invalid fragment specifier `r#if` LL | ($wrong:r#if) => {}; | ^^^^^^^^^^^ | - = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis` + = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`, along with `expr_2021` and `pat_param` for edition compatibility error: aborting due to 2 previous errors diff --git a/tests/ui/macros/issue-21356.stderr b/tests/ui/macros/issue-21356.stderr index dd09da6df4f..5ff92642514 100644 --- a/tests/ui/macros/issue-21356.stderr +++ b/tests/ui/macros/issue-21356.stderr @@ -4,7 +4,7 @@ error: invalid fragment specifier `t_ty` LL | macro_rules! test { ($wrong:t_ty ..) => () } | ^^^^^^^^^^^ | - = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis` + = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`, along with `expr_2021` and `pat_param` for edition compatibility error: aborting due to 1 previous error diff --git a/tests/ui/macros/macro-missing-fragment.e2024.stderr b/tests/ui/macros/macro-missing-fragment.e2024.stderr index 3afa069c170..0dc48e0c7b2 100644 --- a/tests/ui/macros/macro-missing-fragment.e2024.stderr +++ b/tests/ui/macros/macro-missing-fragment.e2024.stderr @@ -5,7 +5,7 @@ LL | ( $( any_token $field_rust_type )* ) => {}; | ^^^^^^^^^^^^^^^^ | = note: fragment specifiers must be specified in the 2024 edition - = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `expr_2021`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis` + = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`, along with `expr_2021` and `pat_param` for edition compatibility help: try adding a specifier here | LL | ( $( any_token $field_rust_type:spec )* ) => {}; @@ -18,7 +18,7 @@ LL | ( $name ) => {}; | ^^^^^ | = note: fragment specifiers must be specified in the 2024 edition - = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `expr_2021`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis` + = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`, along with `expr_2021` and `pat_param` for edition compatibility help: try adding a specifier here | LL | ( $name:spec ) => {}; @@ -31,7 +31,7 @@ LL | ( $name ) => {}; | ^^^^^ | = note: fragment specifiers must be specified in the 2024 edition - = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `expr_2021`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis` + = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`, along with `expr_2021` and `pat_param` for edition compatibility help: try adding a specifier here | LL | ( $name:spec ) => {}; diff --git a/tests/ui/macros/metavar_cross_edition_recursive_macros.rs b/tests/ui/macros/metavar_cross_edition_recursive_macros.rs index 3eec1208b89..9a5b92f5032 100644 --- a/tests/ui/macros/metavar_cross_edition_recursive_macros.rs +++ b/tests/ui/macros/metavar_cross_edition_recursive_macros.rs @@ -6,7 +6,6 @@ // This test captures the behavior of macro-generating-macros with fragment // specifiers across edition boundaries. -#![feature(expr_fragment_specifier_2024)] #![feature(macro_metavar_expr)] #![allow(incomplete_features)] diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/mismatched_generic_args.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/mismatched_generic_args.stderr index 8c814295de4..8e12b40381f 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/mismatched_generic_args.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/mismatched_generic_args.stderr @@ -22,7 +22,7 @@ error: `Dimension` is forbidden as the type of a const generic parameter LL | pub struct Quantity<S, const D: Dimension>(S); | ^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -40,7 +40,7 @@ error: `Dimension` is forbidden as the type of a const generic parameter LL | impl<const D: Dimension, LHS, RHS> Add<LHS, D> for Quantity<LHS, { Dimension }> {} | ^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -52,7 +52,7 @@ error: `Dimension` is forbidden as the type of a const generic parameter LL | pub fn add<const U: Dimension>(x: Quantity<f32, U>) -> Quantity<f32, U> { | ^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/specialization/default-proj-ty-as-type-of-const-issue-125757.stderr b/tests/ui/specialization/default-proj-ty-as-type-of-const-issue-125757.stderr index 7094ee8c67c..8df76b296ac 100644 --- a/tests/ui/specialization/default-proj-ty-as-type-of-const-issue-125757.stderr +++ b/tests/ui/specialization/default-proj-ty-as-type-of-const-issue-125757.stderr @@ -4,7 +4,7 @@ error: `<i32 as Trait>::Type` is forbidden as the type of a const generic parame LL | struct Wrapper<const C: <i32 as Trait>::Type> {} | ^^^^^^^^^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: the constant `C` is not of type `<i32 as Trait>::Type` --> $DIR/default-proj-ty-as-type-of-const-issue-125757.rs:15:22 diff --git a/tests/ui/traits/next-solver/canonical/const-region-infer-to-static-in-binder.stderr b/tests/ui/traits/next-solver/canonical/const-region-infer-to-static-in-binder.stderr index e0cbee88aa1..377dfc8b529 100644 --- a/tests/ui/traits/next-solver/canonical/const-region-infer-to-static-in-binder.stderr +++ b/tests/ui/traits/next-solver/canonical/const-region-infer-to-static-in-binder.stderr @@ -10,7 +10,7 @@ error: using function pointers as const generic parameters is forbidden LL | struct X<const FN: fn() = { || {} }>; | ^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: using function pointers as const generic parameters is forbidden --> $DIR/const-region-infer-to-static-in-binder.rs:4:20 @@ -18,7 +18,7 @@ error: using function pointers as const generic parameters is forbidden LL | struct X<const FN: fn() = { || {} }>; | ^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: aborting due to 3 previous errors diff --git a/tests/ui/type-alias-impl-trait/const_generic_type.infer.stderr b/tests/ui/type-alias-impl-trait/const_generic_type.infer.stderr index 3b6999cabc4..b7999a695e7 100644 --- a/tests/ui/type-alias-impl-trait/const_generic_type.infer.stderr +++ b/tests/ui/type-alias-impl-trait/const_generic_type.infer.stderr @@ -4,7 +4,7 @@ error: `Bar` is forbidden as the type of a const generic parameter LL | async fn test<const N: crate::Bar>() { | ^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: aborting due to 1 previous error diff --git a/tests/ui/type-alias-impl-trait/const_generic_type.no_infer.stderr b/tests/ui/type-alias-impl-trait/const_generic_type.no_infer.stderr index 55a5a3d2000..b526ab49d8d 100644 --- a/tests/ui/type-alias-impl-trait/const_generic_type.no_infer.stderr +++ b/tests/ui/type-alias-impl-trait/const_generic_type.no_infer.stderr @@ -45,7 +45,7 @@ error: `Bar` is forbidden as the type of a const generic parameter LL | async fn test<const N: crate::Bar>() { | ^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: aborting due to 4 previous errors diff --git a/tests/ui/typeck/ice-unexpected-region-123863.stderr b/tests/ui/typeck/ice-unexpected-region-123863.stderr index 0479f134a38..742096f3861 100644 --- a/tests/ui/typeck/ice-unexpected-region-123863.stderr +++ b/tests/ui/typeck/ice-unexpected-region-123863.stderr @@ -4,7 +4,7 @@ error: `&'static str` is forbidden as the type of a const generic parameter LL | const fn concat_strs<const A: &'static str>() -> &'static str { | ^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] @@ -20,7 +20,7 @@ error: `&'static str` is forbidden as the type of a const generic parameter LL | struct Inner<const A: &'static str>; | ^^^^^^^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] diff --git a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.rs b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.rs index 3f43fbfc0cf..53363319ba0 100644 --- a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.rs +++ b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.rs @@ -4,7 +4,6 @@ trait Trait<const N: Trait = bar> { //~| ERROR the trait `Trait` cannot be made into an object //~| ERROR the trait `Trait` cannot be made into an object //~| ERROR the trait `Trait` cannot be made into an object - //~| ERROR `(dyn Trait<{const error}> + 'static)` is forbidden as the type of a const generic parameter //~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects] //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! //~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects] @@ -15,7 +14,6 @@ trait Trait<const N: Trait = bar> { //~| ERROR defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions //~| ERROR associated item referring to unboxed trait object for its own trait //~| ERROR the trait `Trait` cannot be made into an object - //~| ERROR `(dyn Trait<{const error}> + 'static)` is forbidden as the type of a const generic parameter //~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects] //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! //~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects] diff --git a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.stderr b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.stderr index 6b309c223af..fefb788fac7 100644 --- a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.stderr +++ b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.stderr @@ -1,5 +1,5 @@ error[E0403]: the name `N` is already used for a generic parameter in this item's generic parameters - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:18 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:11:18 | LL | trait Trait<const N: Trait = bar> { | - first use of `N` @@ -14,13 +14,13 @@ LL | trait Trait<const N: Trait = bar> { | ^^^ not found in this scope error[E0423]: expected value, found builtin type `u32` - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:29 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:11:29 | LL | fn fnc<const N: Trait = u32>(&self) -> Trait { | ^^^ not a value error[E0425]: cannot find value `bar` in this scope - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:25:9 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:23:9 | LL | bar | ^^^ not found in this scope @@ -54,13 +54,13 @@ LL | trait Trait<const N: Trait = bar> { = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:12 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:11:12 | LL | fn fnc<const N: Trait = u32>(&self) -> Trait { | ^^^^^^^^^^^^^^^^^^^^ warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:21 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:11:21 | LL | fn fnc<const N: Trait = u32>(&self) -> Trait { | ^^^^^ @@ -73,7 +73,7 @@ LL | fn fnc<const N: dyn Trait = u32>(&self) -> Trait { | +++ warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:44 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:11:44 | LL | fn fnc<const N: Trait = u32>(&self) -> Trait { | ^^^^^ @@ -106,7 +106,7 @@ LL | trait Trait<const N: Trait = bar> { | ^^^^^ `Trait` cannot be made into an object | note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:8 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:11:8 | LL | trait Trait<const N: Trait = bar> { | ----- this trait cannot be made into an object... @@ -122,7 +122,7 @@ LL | trait Trait<const N: Trait = bar> { | ^^^^^^^^^^^^^^^^^^^^ `Trait` cannot be made into an object | note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:8 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:11:8 | LL | trait Trait<const N: Trait = bar> { | ----- this trait cannot be made into an object... @@ -131,16 +131,8 @@ LL | fn fnc<const N: Trait = u32>(&self) -> Trait { | ^^^ ...because method `fnc` has generic type parameters = help: consider moving `fnc` to another trait -error: `(dyn Trait<{const error}> + 'static)` is forbidden as the type of a const generic parameter - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:1:22 - | -LL | trait Trait<const N: Trait = bar> { - | ^^^^^ - | - = note: the only supported types are integers, `bool` and `char` - error: associated item referring to unboxed trait object for its own trait - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:44 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:11:44 | LL | trait Trait<const N: Trait = bar> { | ----- in this trait @@ -154,7 +146,7 @@ LL | fn fnc<const N: Trait = u32>(&self) -> Self { | ~~~~ warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:21 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:11:21 | LL | fn fnc<const N: Trait = u32>(&self) -> Trait { | ^^^^^ @@ -168,13 +160,13 @@ LL | fn fnc<const N: dyn Trait = u32>(&self) -> Trait { | +++ error[E0038]: the trait `Trait` cannot be made into an object - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:21 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:11:21 | LL | fn fnc<const N: Trait = u32>(&self) -> Trait { | ^^^^^ `Trait` cannot be made into an object | note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:8 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:11:8 | LL | trait Trait<const N: Trait = bar> { | ----- this trait cannot be made into an object... @@ -190,7 +182,7 @@ LL | trait Trait<const N: Trait = bar> { | ^^^^^^^^^^^^^^^^^^^^ `Trait` cannot be made into an object | note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:8 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:11:8 | LL | trait Trait<const N: Trait = bar> { | ----- this trait cannot be made into an object... @@ -200,15 +192,7 @@ LL | fn fnc<const N: Trait = u32>(&self) -> Trait { = help: consider moving `fnc` to another trait = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: `(dyn Trait<{const error}> + 'static)` is forbidden as the type of a const generic parameter - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:12:21 - | -LL | fn fnc<const N: Trait = u32>(&self) -> Trait { - | ^^^^^ - | - = note: the only supported types are integers, `bool` and `char` - -error: aborting due to 13 previous errors; 5 warnings emitted +error: aborting due to 11 previous errors; 5 warnings emitted Some errors have detailed explanations: E0038, E0391, E0403, E0423, E0425. For more information about an error, try `rustc --explain E0038`. diff --git a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr index d2b0e2d92e0..f8905437c6e 100644 --- a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr +++ b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr @@ -73,7 +73,7 @@ error: `(dyn Bar<2> + 'static)` is forbidden as the type of a const generic para LL | trait Foo<const N: Bar<2>> { | ^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error[E0038]: the trait `Foo` cannot be made into an object --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:11:11 @@ -104,7 +104,7 @@ error: `(dyn Foo<2> + 'static)` is forbidden as the type of a const generic para LL | trait Bar<const M: Foo<2>> {} | ^^^^^^ | - = note: the only supported types are integers, `bool` and `char` + = note: the only supported types are integers, `bool`, and `char` error: aborting due to 5 previous errors; 2 warnings emitted |