diff --git a/Cargo.lock b/Cargo.lock index 5eeb855aacb87..a736a9118322f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4275,7 +4275,6 @@ dependencies = [ "rustc_fluent_macro", "rustc_hir", "rustc_index", - "rustc_lexer", "rustc_macros", "rustc_middle", "rustc_privacy", diff --git a/compiler/rustc_lint/messages.ftl b/compiler/rustc_lint/messages.ftl index 48d6d6bbf6788..e744655a67332 100644 --- a/compiler/rustc_lint/messages.ftl +++ b/compiler/rustc_lint/messages.ftl @@ -536,9 +536,6 @@ lint_non_camel_case_type = {$sort} `{$name}` should have an upper camel case nam .suggestion = convert the identifier to upper camel case .label = should have an UpperCamelCase name -lint_non_existent_doc_keyword = found non-existing keyword `{$keyword}` used in `#[doc(keyword = "...")]` - .help = only existing keywords are allowed in core/std - lint_non_fmt_panic = panic message is not a string literal .note = this usage of `{$name}!()` is deprecated; it will be a hard error in Rust 2021 .more_info_note = for more information, see diff --git a/compiler/rustc_lint/src/internal.rs b/compiler/rustc_lint/src/internal.rs index 482650e04e85c..4dff512f9d6dd 100644 --- a/compiler/rustc_lint/src/internal.rs +++ b/compiler/rustc_lint/src/internal.rs @@ -12,11 +12,11 @@ use rustc_middle::ty::{self, GenericArgsRef, Ty as MiddleTy}; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::Span; use rustc_span::hygiene::{ExpnKind, MacroKind}; -use rustc_span::symbol::{Symbol, kw, sym}; +use rustc_span::symbol::sym; use tracing::debug; use crate::lints::{ - BadOptAccessDiag, DefaultHashTypesDiag, DiagOutOfImpl, LintPassByHand, NonExistentDocKeyword, + BadOptAccessDiag, DefaultHashTypesDiag, DiagOutOfImpl, LintPassByHand, NonGlobImportTypeIrInherent, QueryInstability, QueryUntracked, SpanUseEqCtxtDiag, SymbolInternStringLiteralDiag, TyQualified, TykindDiag, TykindKind, TypeIrInherentUsage, UntranslatableDiag, @@ -375,46 +375,6 @@ impl EarlyLintPass for LintPassImpl { } } -declare_tool_lint! { - /// The `existing_doc_keyword` lint detects use `#[doc()]` keywords - /// that don't exist, e.g. `#[doc(keyword = "..")]`. - pub rustc::EXISTING_DOC_KEYWORD, - Allow, - "Check that documented keywords in std and core actually exist", - report_in_external_macro: true -} - -declare_lint_pass!(ExistingDocKeyword => [EXISTING_DOC_KEYWORD]); - -fn is_doc_keyword(s: Symbol) -> bool { - s <= kw::Union -} - -impl<'tcx> LateLintPass<'tcx> for ExistingDocKeyword { - fn check_item(&mut self, cx: &LateContext<'_>, item: &rustc_hir::Item<'_>) { - for attr in cx.tcx.hir().attrs(item.hir_id()) { - if !attr.has_name(sym::doc) { - continue; - } - if let Some(list) = attr.meta_item_list() { - for nested in list { - if nested.has_name(sym::keyword) { - let keyword = nested - .value_str() - .expect("#[doc(keyword = \"...\")] expected a value!"); - if is_doc_keyword(keyword) { - return; - } - cx.emit_span_lint(EXISTING_DOC_KEYWORD, attr.span, NonExistentDocKeyword { - keyword, - }); - } - } - } - } - } -} - declare_tool_lint! { /// The `untranslatable_diagnostic` lint detects messages passed to functions with `impl /// Into<{D,Subd}iagMessage` parameters without using translatable Fluent strings. diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index a99c94592b302..d7f0d2a6941fb 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -600,8 +600,6 @@ fn register_internals(store: &mut LintStore) { store.register_late_mod_pass(|_| Box::new(DefaultHashTypes)); store.register_lints(&QueryStability::lint_vec()); store.register_late_mod_pass(|_| Box::new(QueryStability)); - store.register_lints(&ExistingDocKeyword::lint_vec()); - store.register_late_mod_pass(|_| Box::new(ExistingDocKeyword)); store.register_lints(&TyTyKind::lint_vec()); store.register_late_mod_pass(|_| Box::new(TyTyKind)); store.register_lints(&TypeIr::lint_vec()); @@ -629,7 +627,6 @@ fn register_internals(store: &mut LintStore) { LintId::of(LINT_PASS_IMPL_WITHOUT_MACRO), LintId::of(USAGE_OF_QUALIFIED_TY), LintId::of(NON_GLOB_IMPORT_OF_TYPE_IR_INHERENT), - LintId::of(EXISTING_DOC_KEYWORD), LintId::of(BAD_OPT_ACCESS), LintId::of(SPAN_USE_EQ_CTXT), ]); diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 4977b3971bd10..be4b03081e902 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -950,13 +950,6 @@ pub(crate) struct NonGlobImportTypeIrInherent { #[help] pub(crate) struct LintPassByHand; -#[derive(LintDiagnostic)] -#[diag(lint_non_existent_doc_keyword)] -#[help] -pub(crate) struct NonExistentDocKeyword { - pub keyword: Symbol, -} - #[derive(LintDiagnostic)] #[diag(lint_diag_out_of_impl)] pub(crate) struct DiagOutOfImpl; diff --git a/compiler/rustc_mir_build/src/build/expr/into.rs b/compiler/rustc_mir_build/src/build/expr/into.rs index a3d5376dcd405..0ac1ae56d59bb 100644 --- a/compiler/rustc_mir_build/src/build/expr/into.rs +++ b/compiler/rustc_mir_build/src/build/expr/into.rs @@ -367,14 +367,20 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { .collect() } AdtExprBase::DefaultFields(field_types) => { - itertools::zip_eq(field_names, &**field_types) - .map(|(n, ty)| match fields_map.get(&n) { + itertools::zip_eq(field_names, field_types) + .map(|(n, &ty)| match fields_map.get(&n) { Some(v) => v.clone(), None => match variant.fields[n].value { Some(def) => { - let value = Const::from_unevaluated(this.tcx, def) - .instantiate(this.tcx, args); - this.literal_operand(expr_span, value) + let value = Const::Unevaluated( + UnevaluatedConst::new(def, args), + ty, + ); + Operand::Constant(Box::new(ConstOperand { + span: expr_span, + user_ty: None, + const_: value, + })) } None => { let name = variant.fields[n].name; diff --git a/compiler/rustc_passes/Cargo.toml b/compiler/rustc_passes/Cargo.toml index ed5991459ac1b..e1cb6903839af 100644 --- a/compiler/rustc_passes/Cargo.toml +++ b/compiler/rustc_passes/Cargo.toml @@ -16,7 +16,6 @@ rustc_feature = { path = "../rustc_feature" } rustc_fluent_macro = { path = "../rustc_fluent_macro" } rustc_hir = { path = "../rustc_hir" } rustc_index = { path = "../rustc_index" } -rustc_lexer = { path = "../rustc_lexer" } rustc_macros = { path = "../rustc_macros" } rustc_middle = { path = "../rustc_middle" } rustc_privacy = { path = "../rustc_privacy" } diff --git a/compiler/rustc_passes/messages.ftl b/compiler/rustc_passes/messages.ftl index 7a0a518bb513a..fd133ba878e10 100644 --- a/compiler/rustc_passes/messages.ftl +++ b/compiler/rustc_passes/messages.ftl @@ -211,8 +211,9 @@ passes_doc_invalid = passes_doc_keyword_empty_mod = `#[doc(keyword = "...")]` should be used on empty modules -passes_doc_keyword_invalid_ident = - `{$doc_keyword}` is not a valid identifier +passes_doc_keyword_not_keyword = + nonexistent keyword `{$keyword}` used in `#[doc(keyword = "...")]` + .help = only existing keywords are allowed in core/std passes_doc_keyword_not_mod = `#[doc(keyword = "...")]` should be used on modules diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index ee197ce07ca71..4d66f5a538709 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -912,6 +912,13 @@ impl<'tcx> CheckAttrVisitor<'tcx> { } fn check_doc_keyword(&self, meta: &MetaItemInner, hir_id: HirId) { + fn is_doc_keyword(s: Symbol) -> bool { + // FIXME: Once rustdoc can handle URL conflicts on case insensitive file systems, we + // can remove the `SelfTy` case here, remove `sym::SelfTy`, and update the + // `#[doc(keyword = "SelfTy")` attribute in `library/std/src/keyword_docs.rs`. + s <= kw::Union || s == sym::SelfTy + } + let doc_keyword = meta.value_str().unwrap_or(kw::Empty); if doc_keyword == kw::Empty { self.doc_attr_str_error(meta, "keyword"); @@ -933,10 +940,10 @@ impl<'tcx> CheckAttrVisitor<'tcx> { return; } } - if !rustc_lexer::is_ident(doc_keyword.as_str()) { - self.dcx().emit_err(errors::DocKeywordInvalidIdent { + if !is_doc_keyword(doc_keyword) { + self.dcx().emit_err(errors::DocKeywordNotKeyword { span: meta.name_value_literal_span().unwrap_or_else(|| meta.span()), - doc_keyword, + keyword: doc_keyword, }); } } diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs index fdc7e1bba2f0e..f71d528405267 100644 --- a/compiler/rustc_passes/src/errors.rs +++ b/compiler/rustc_passes/src/errors.rs @@ -216,18 +216,19 @@ pub(crate) struct DocKeywordEmptyMod { } #[derive(Diagnostic)] -#[diag(passes_doc_keyword_not_mod)] -pub(crate) struct DocKeywordNotMod { +#[diag(passes_doc_keyword_not_keyword)] +#[help] +pub(crate) struct DocKeywordNotKeyword { #[primary_span] pub span: Span, + pub keyword: Symbol, } #[derive(Diagnostic)] -#[diag(passes_doc_keyword_invalid_ident)] -pub(crate) struct DocKeywordInvalidIdent { +#[diag(passes_doc_keyword_not_mod)] +pub(crate) struct DocKeywordNotMod { #[primary_span] pub span: Span, - pub doc_keyword: Symbol, } #[derive(Diagnostic)] diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index c62e609c8a999..7d99ca5a31e2d 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -306,6 +306,7 @@ symbols! { RwLockWriteGuard, Saturating, SeekFrom, + SelfTy, Send, SeqCst, Sized, diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs index 5a62a4c3bd5fe..ee5ce19cb4df6 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs @@ -824,7 +824,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { fn cmp_fn_sig( &self, sig1: &ty::PolyFnSig<'tcx>, + fn_def1: Option<(DefId, &'tcx [ty::GenericArg<'tcx>])>, sig2: &ty::PolyFnSig<'tcx>, + fn_def2: Option<(DefId, &'tcx [ty::GenericArg<'tcx>])>, ) -> (DiagStyledString, DiagStyledString) { let sig1 = &(self.normalize_fn_sig)(*sig1); let sig2 = &(self.normalize_fn_sig)(*sig2); @@ -930,6 +932,25 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { (values.1).0.extend(x2.0); } + let fmt = |(did, args)| format!(" {{{}}}", self.tcx.def_path_str_with_args(did, args)); + + match (fn_def1, fn_def2) { + (None, None) => {} + (Some(fn_def1), Some(fn_def2)) => { + let path1 = fmt(fn_def1); + let path2 = fmt(fn_def2); + let same_path = path1 == path2; + values.0.push(path1, !same_path); + values.1.push(path2, !same_path); + } + (Some(fn_def1), None) => { + values.0.push_highlighted(fmt(fn_def1)); + } + (None, Some(fn_def2)) => { + values.1.push_highlighted(fmt(fn_def2)); + } + } + values } @@ -1318,36 +1339,21 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { (ty::FnDef(did1, args1), ty::FnDef(did2, args2)) => { let sig1 = self.tcx.fn_sig(*did1).instantiate(self.tcx, args1); let sig2 = self.tcx.fn_sig(*did2).instantiate(self.tcx, args2); - let mut values = self.cmp_fn_sig(&sig1, &sig2); - let path1 = format!(" {{{}}}", self.tcx.def_path_str_with_args(*did1, args1)); - let path2 = format!(" {{{}}}", self.tcx.def_path_str_with_args(*did2, args2)); - let same_path = path1 == path2; - values.0.push(path1, !same_path); - values.1.push(path2, !same_path); - values + self.cmp_fn_sig(&sig1, Some((*did1, args1)), &sig2, Some((*did2, args2))) } (ty::FnDef(did1, args1), ty::FnPtr(sig_tys2, hdr2)) => { let sig1 = self.tcx.fn_sig(*did1).instantiate(self.tcx, args1); - let mut values = self.cmp_fn_sig(&sig1, &sig_tys2.with(*hdr2)); - values.0.push_highlighted(format!( - " {{{}}}", - self.tcx.def_path_str_with_args(*did1, args1) - )); - values + self.cmp_fn_sig(&sig1, Some((*did1, args1)), &sig_tys2.with(*hdr2), None) } (ty::FnPtr(sig_tys1, hdr1), ty::FnDef(did2, args2)) => { let sig2 = self.tcx.fn_sig(*did2).instantiate(self.tcx, args2); - let mut values = self.cmp_fn_sig(&sig_tys1.with(*hdr1), &sig2); - values - .1 - .push_normal(format!(" {{{}}}", self.tcx.def_path_str_with_args(*did2, args2))); - values + self.cmp_fn_sig(&sig_tys1.with(*hdr1), None, &sig2, Some((*did2, args2))) } (ty::FnPtr(sig_tys1, hdr1), ty::FnPtr(sig_tys2, hdr2)) => { - self.cmp_fn_sig(&sig_tys1.with(*hdr1), &sig_tys2.with(*hdr2)) + self.cmp_fn_sig(&sig_tys1.with(*hdr1), None, &sig_tys2.with(*hdr2), None) } _ => { @@ -2102,7 +2108,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { if exp_found.references_error() { return None; } - let (exp, fnd) = self.cmp_fn_sig(&exp_found.expected, &exp_found.found); + let (exp, fnd) = self.cmp_fn_sig(&exp_found.expected, None, &exp_found.found, None); Some((exp, fnd, None)) } } diff --git a/library/std/src/keyword_docs.rs b/library/std/src/keyword_docs.rs index 4302e24781ee8..0c526eafdf36f 100644 --- a/library/std/src/keyword_docs.rs +++ b/library/std/src/keyword_docs.rs @@ -807,64 +807,6 @@ mod in_keyword {} /// [Reference]: ../reference/statements.html#let-statements mod let_keyword {} -#[doc(keyword = "while")] -// -/// Loop while a condition is upheld. -/// -/// A `while` expression is used for predicate loops. The `while` expression runs the conditional -/// expression before running the loop body, then runs the loop body if the conditional -/// expression evaluates to `true`, or exits the loop otherwise. -/// -/// ```rust -/// let mut counter = 0; -/// -/// while counter < 10 { -/// println!("{counter}"); -/// counter += 1; -/// } -/// ``` -/// -/// Like the [`for`] expression, we can use `break` and `continue`. A `while` expression -/// cannot break with a value and always evaluates to `()` unlike [`loop`]. -/// -/// ```rust -/// let mut i = 1; -/// -/// while i < 100 { -/// i *= 2; -/// if i == 64 { -/// break; // Exit when `i` is 64. -/// } -/// } -/// ``` -/// -/// As `if` expressions have their pattern matching variant in `if let`, so too do `while` -/// expressions with `while let`. The `while let` expression matches the pattern against the -/// expression, then runs the loop body if pattern matching succeeds, or exits the loop otherwise. -/// We can use `break` and `continue` in `while let` expressions just like in `while`. -/// -/// ```rust -/// let mut counter = Some(0); -/// -/// while let Some(i) = counter { -/// if i == 10 { -/// counter = None; -/// } else { -/// println!("{i}"); -/// counter = Some (i + 1); -/// } -/// } -/// ``` -/// -/// For more information on `while` and loops in general, see the [reference]. -/// -/// See also, [`for`], [`loop`]. -/// -/// [`for`]: keyword.for.html -/// [`loop`]: keyword.loop.html -/// [reference]: ../reference/expressions/loop-expr.html#predicate-loops -mod while_keyword {} - #[doc(keyword = "loop")] // /// Loop indefinitely. @@ -1321,10 +1263,10 @@ mod return_keyword {} /// [Reference]: ../reference/items/associated-items.html#methods mod self_keyword {} -// FIXME: Once rustdoc can handle URL conflicts on case insensitive file systems, we can remove the -// three next lines and put back: `#[doc(keyword = "Self")]`. +// FIXME: Once rustdoc can handle URL conflicts on case insensitive file systems, we can replace +// these two lines with `#[doc(keyword = "Self")]` and update `is_doc_keyword` in +// `CheckAttrVisitor`. #[doc(alias = "Self")] -#[allow(rustc::existing_doc_keyword)] #[doc(keyword = "SelfTy")] // /// The implementing type within a [`trait`] or [`impl`] block, or the current type within a type @@ -2343,6 +2285,64 @@ mod use_keyword {} /// [RFC]: https://github.com/rust-lang/rfcs/blob/master/text/0135-where.md mod where_keyword {} +#[doc(keyword = "while")] +// +/// Loop while a condition is upheld. +/// +/// A `while` expression is used for predicate loops. The `while` expression runs the conditional +/// expression before running the loop body, then runs the loop body if the conditional +/// expression evaluates to `true`, or exits the loop otherwise. +/// +/// ```rust +/// let mut counter = 0; +/// +/// while counter < 10 { +/// println!("{counter}"); +/// counter += 1; +/// } +/// ``` +/// +/// Like the [`for`] expression, we can use `break` and `continue`. A `while` expression +/// cannot break with a value and always evaluates to `()` unlike [`loop`]. +/// +/// ```rust +/// let mut i = 1; +/// +/// while i < 100 { +/// i *= 2; +/// if i == 64 { +/// break; // Exit when `i` is 64. +/// } +/// } +/// ``` +/// +/// As `if` expressions have their pattern matching variant in `if let`, so too do `while` +/// expressions with `while let`. The `while let` expression matches the pattern against the +/// expression, then runs the loop body if pattern matching succeeds, or exits the loop otherwise. +/// We can use `break` and `continue` in `while let` expressions just like in `while`. +/// +/// ```rust +/// let mut counter = Some(0); +/// +/// while let Some(i) = counter { +/// if i == 10 { +/// counter = None; +/// } else { +/// println!("{i}"); +/// counter = Some (i + 1); +/// } +/// } +/// ``` +/// +/// For more information on `while` and loops in general, see the [reference]. +/// +/// See also, [`for`], [`loop`]. +/// +/// [`for`]: keyword.for.html +/// [`loop`]: keyword.loop.html +/// [reference]: ../reference/expressions/loop-expr.html#predicate-loops +mod while_keyword {} + // 2018 Edition keywords #[doc(alias = "promise")] diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 2b97f73f79aa9..1c80694ca8f24 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -251,7 +251,6 @@ #![allow(explicit_outlives_requirements)] #![allow(unused_lifetimes)] #![allow(internal_features)] -#![deny(rustc::existing_doc_keyword)] #![deny(fuzzy_provenance_casts)] #![deny(unsafe_op_in_unsafe_fn)] #![allow(rustdoc::redundant_explicit_links)] diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index db8426492eec0..f19c3a51f619b 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -207,7 +207,7 @@ To do so, the `#[doc(keyword = "...")]` attribute is used. Example: #![allow(internal_features)] /// Some documentation about the keyword. -#[doc(keyword = "keyword")] +#[doc(keyword = "break")] mod empty_mod {} ``` diff --git a/tests/crashes/130797.rs b/tests/crashes/130797.rs new file mode 100644 index 0000000000000..e9c877d92a6e9 --- /dev/null +++ b/tests/crashes/130797.rs @@ -0,0 +1,23 @@ +//@ known-bug: #130797 + +trait Transform { + type Output<'a>; +} +trait Propagate {} +trait AddChild { + fn add_child(&self) {} +} + +pub struct Node(T); +impl AddChild Propagate>>> for Node where T: Transform {} + +fn make_graph_root() { + Node(Dummy).add_child() +} + +struct Dummy; +impl Transform for Dummy { + type Output<'a> = (); +} + +pub fn main() {} diff --git a/tests/crashes/132103.rs b/tests/crashes/132103.rs new file mode 100644 index 0000000000000..5bf4792c44c9f --- /dev/null +++ b/tests/crashes/132103.rs @@ -0,0 +1,21 @@ +//@ known-bug: #132103 +//@compile-flags: -Zvalidate-mir --edition=2018 -Zinline-mir=yes +use core::future::{async_drop_in_place, Future}; +use core::mem::{self}; +use core::pin::pin; +use core::task::{Context, Waker}; + +async fn test_async_drop(x: T) { + let mut x = mem::MaybeUninit::new(x); + pin!(unsafe { async_drop_in_place(x.as_mut_ptr()) }); +} + +fn main() { + let waker = Waker::noop(); + let mut cx = Context::from_waker(&waker); + + let fut = pin!(async { + test_async_drop(test_async_drop(0)).await; + }); + fut.poll(&mut cx); +} diff --git a/tests/crashes/132960.rs b/tests/crashes/132960.rs new file mode 100644 index 0000000000000..87d0ee7dedebd --- /dev/null +++ b/tests/crashes/132960.rs @@ -0,0 +1,36 @@ +//@ known-bug: #132960 + +#![feature(adt_const_params, const_ptr_read, generic_const_exprs)] + +const fn concat_strs() -> &'static str +where + [(); A.len()]:, + [(); B.len()]:, + [(); A.len() + B.len()]:, +{ + #[repr(C)] + #[repr(C)] + + const fn concat_arr(a: [u8; M], b: [u8; N]) -> [u8; M + N] {} + + struct Inner; + impl Inner + where + [(); A.len()]:, + [(); B.len()]:, + [(); A.len() + B.len()]:, + { + const ABSTR: &'static str = unsafe { + std::str::from_utf8_unchecked(&concat_arr( + A.as_ptr().cast().read(), + B.as_ptr().cast().read(), + )) + }; + } + + Inner::::ABSTR +} + +const FOO: &str = "foo"; +const BAR: &str = "bar"; +const FOOBAR: &str = concat_strs::(); diff --git a/tests/crashes/133117.rs b/tests/crashes/133117.rs new file mode 100644 index 0000000000000..751c82626d574 --- /dev/null +++ b/tests/crashes/133117.rs @@ -0,0 +1,8 @@ +//@ known-bug: #133117 + +fn main() { + match () { + (!|!) if true => {} + (!|!) if true => {} + } +} diff --git a/tests/crashes/133252.rs b/tests/crashes/133252.rs new file mode 100644 index 0000000000000..3cecf448287bf --- /dev/null +++ b/tests/crashes/133252.rs @@ -0,0 +1,43 @@ +//@ known-bug: #133252 +//@ edition:2021 +use std::future::Future; + +trait Owned: 'static {} +fn ice() -> impl Future { + async { + let not_static = 0; + force_send(async_load(¬_static)); + loop {} + } +} + +fn force_send(_: T) {} + +fn async_load<'a, T: LoadQuery<'a>>(this: T) -> impl Future { + async { + this.get_future().await; + } +} + +trait LoadQuery<'a>: Sized { + type LoadFuture: Future; + + fn get_future(self) -> Self::LoadFuture { + loop {} + } +} + +impl<'a> LoadQuery<'a> for &'a u8 { + type LoadFuture = SimpleFuture; +} + +struct SimpleFuture; +impl Future for SimpleFuture { + type Output = (); + fn poll( + self: std::pin::Pin<&mut Self>, + _: &mut std::task::Context<'_>, + ) -> std::task::Poll { + loop {} + } +} diff --git a/tests/crashes/133613.rs b/tests/crashes/133613.rs new file mode 100644 index 0000000000000..f01780d7cf425 --- /dev/null +++ b/tests/crashes/133613.rs @@ -0,0 +1,7 @@ +//@ known-bug: #133613 + +struct Wrapper<'a>(); + +trait IntFactory { + fn stream(&self) -> impl IntFactory>; +} diff --git a/tests/crashes/134174.rs b/tests/crashes/134174.rs new file mode 100644 index 0000000000000..899cdc6faf358 --- /dev/null +++ b/tests/crashes/134174.rs @@ -0,0 +1,17 @@ +//@ known-bug: #134175 +//@compile-flags: -Zvalidate-mir -Zinline-mir=yes +use std::vec::IntoIter; + +pub(crate) trait Foo: Iterator::Key> { + type Key; +} + +impl Foo for IntoIter {} + +fn sum_foo>(f: F) -> i32 { + f.fold(0, |a, b| a + b) +} + +fn main() { + let x = sum_foo(vec![11, 10, 1].into_iter()); +} diff --git a/tests/crashes/134334.rs b/tests/crashes/134334.rs new file mode 100644 index 0000000000000..d99df7bdc1eda --- /dev/null +++ b/tests/crashes/134334.rs @@ -0,0 +1,9 @@ +//@ known-bug: #134334 +//@ only-x86_64 + +#[repr(simd)] +struct A(); + +fn main() { + std::arch::asm!("{}", in(xmm_reg) A()); +} diff --git a/tests/crashes/134335.rs b/tests/crashes/134335.rs new file mode 100644 index 0000000000000..bee6686ff3fa8 --- /dev/null +++ b/tests/crashes/134335.rs @@ -0,0 +1,12 @@ +//@ known-bug: #134335 +//@compile-flags: -Zunstable-options --edition=2024 --crate-type=lib +pub async fn async_closure(x: &mut i32) { + let c = async move || { + *x += 1; + }; + call_once(c).await; +} + +fn call_once(f: impl FnOnce() -> T) -> T { + f() +} diff --git a/tests/rustdoc-gui/search-result-color.goml b/tests/rustdoc-gui/search-result-color.goml index e8da43eb896bc..bd9463a096813 100644 --- a/tests/rustdoc-gui/search-result-color.goml +++ b/tests/rustdoc-gui/search-result-color.goml @@ -140,7 +140,7 @@ define-function: ( }, ) -go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=coo" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=fo" // This is needed so that the text color is computed. show-text: true diff --git a/tests/rustdoc-gui/search-result-keyword.goml b/tests/rustdoc-gui/search-result-keyword.goml index 370edce2ddd04..02305f2587c9c 100644 --- a/tests/rustdoc-gui/search-result-keyword.goml +++ b/tests/rustdoc-gui/search-result-keyword.goml @@ -1,8 +1,8 @@ // Checks that the "keyword" results have the expected text alongside them. go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" -write-into: (".search-input", "CookieMonster") +write-into: (".search-input", "for") // To be SURE that the search will be run. press-key: 'Enter' // Waiting for the search results to appear... wait-for: "#search-tabs" -assert-text: (".result-keyword .result-name", "keyword CookieMonster") +assert-text: (".result-keyword .result-name", "keyword for") diff --git a/tests/rustdoc-gui/search-tab.goml b/tests/rustdoc-gui/search-tab.goml index 4329726398c10..3879c127fd0f8 100644 --- a/tests/rustdoc-gui/search-tab.goml +++ b/tests/rustdoc-gui/search-tab.goml @@ -78,7 +78,7 @@ call-function: ("check-colors", { set-window-size: (851, 600) // Check the size and count in tabs -assert-text: ("#search-tabs > button:nth-child(1) > .count", " (25) ") +assert-text: ("#search-tabs > button:nth-child(1) > .count", " (26) ") assert-text: ("#search-tabs > button:nth-child(2) > .count", " (6)  ") assert-text: ("#search-tabs > button:nth-child(3) > .count", " (0)  ") store-property: ("#search-tabs > button:nth-child(1)", {"offsetWidth": buttonWidth}) diff --git a/tests/rustdoc-gui/src/test_docs/lib.rs b/tests/rustdoc-gui/src/test_docs/lib.rs index 91aa2c3fae54a..dae13d9ac1808 100644 --- a/tests/rustdoc-gui/src/test_docs/lib.rs +++ b/tests/rustdoc-gui/src/test_docs/lib.rs @@ -156,7 +156,7 @@ pub enum AnEnum { WithVariants { and: usize, sub: usize, variants: usize }, } -#[doc(keyword = "CookieMonster")] +#[doc(keyword = "for")] /// Some keyword. pub mod keyword {} diff --git a/tests/rustdoc-json/keyword.rs b/tests/rustdoc-json/keyword.rs index 7a820cd1487ca..5338c36e6fbfa 100644 --- a/tests/rustdoc-json/keyword.rs +++ b/tests/rustdoc-json/keyword.rs @@ -15,6 +15,6 @@ pub mod foo {} //@ !has "$.index[*][?(@.name=='hello')]" //@ !has "$.index[*][?(@.name=='bar')]" -#[doc(keyword = "hello")] +#[doc(keyword = "break")] /// hello mod bar {} diff --git a/tests/rustdoc-json/keyword_private.rs b/tests/rustdoc-json/keyword_private.rs index 7a030041f7ca0..2a13bf10d5d62 100644 --- a/tests/rustdoc-json/keyword_private.rs +++ b/tests/rustdoc-json/keyword_private.rs @@ -11,10 +11,10 @@ /// this is a test! pub mod foo {} -//@ !has "$.index[*][?(@.name=='hello')]" +//@ !has "$.index[*][?(@.name=='break')]" //@ has "$.index[*][?(@.name=='bar')]" -//@ is "$.index[*][?(@.name=='bar')].attrs" '["#[doc(keyword = \"hello\")]"]' +//@ is "$.index[*][?(@.name=='bar')].attrs" '["#[doc(keyword = \"break\")]"]' //@ is "$.index[*][?(@.name=='bar')].docs" '"hello"' -#[doc(keyword = "hello")] +#[doc(keyword = "break")] /// hello mod bar {} diff --git a/tests/rustdoc-ui/invalid-keyword.stderr b/tests/rustdoc-ui/invalid-keyword.stderr index 82faaaab47f30..c1e41d3b0b35c 100644 --- a/tests/rustdoc-ui/invalid-keyword.stderr +++ b/tests/rustdoc-ui/invalid-keyword.stderr @@ -1,8 +1,10 @@ -error: `foo df` is not a valid identifier +error: nonexistent keyword `foo df` used in `#[doc(keyword = "...")]` --> $DIR/invalid-keyword.rs:3:17 | LL | #[doc(keyword = "foo df")] | ^^^^^^^^ + | + = help: only existing keywords are allowed in core/std error: aborting due to 1 previous error diff --git a/tests/rustdoc/keyword.rs b/tests/rustdoc/keyword.rs index 519e1944bc78a..8f86c8ffd380b 100644 --- a/tests/rustdoc/keyword.rs +++ b/tests/rustdoc/keyword.rs @@ -16,7 +16,7 @@ /// this is a test! mod foo{} -//@ has foo/keyword.foo.html '//section[@id="main-content"]//div[@class="docblock"]//p' 'hello' -#[doc(keyword = "foo")] +//@ has foo/keyword.break.html '//section[@id="main-content"]//div[@class="docblock"]//p' 'hello' +#[doc(keyword = "break")] /// hello mod bar {} diff --git a/tests/ui/error-emitter/highlighting.svg b/tests/ui/error-emitter/highlighting.svg index a4019c78f4841..68fc118f1a6e4 100644 --- a/tests/ui/error-emitter/highlighting.svg +++ b/tests/ui/error-emitter/highlighting.svg @@ -39,7 +39,7 @@ = note: expected fn pointer `for<'a> fn(Box<(dyn Any + Send + 'a)>) -> Pin<_>` - found fn item `fn(Box<(dyn Any + Send + 'static)>) -> Pin<_> {wrapped_fn}` + found fn item `fn(Box<(dyn Any + Send + 'static)>) -> Pin<_> {wrapped_fn}` note: function defined here diff --git a/tests/ui/error-emitter/unicode-output.svg b/tests/ui/error-emitter/unicode-output.svg index f98fd8b74032b..b253fff643b0f 100644 --- a/tests/ui/error-emitter/unicode-output.svg +++ b/tests/ui/error-emitter/unicode-output.svg @@ -39,7 +39,7 @@ note: expected fn pointer `for<'a> fn(Box<(dyn Any + Send + 'a)>) -> Pin<_>` - found fn item `fn(Box<(dyn Any + Send + 'static)>) -> Pin<_> {wrapped_fn}` + found fn item `fn(Box<(dyn Any + Send + 'static)>) -> Pin<_> {wrapped_fn}` note: function defined here diff --git a/tests/ui/internal-lints/existing_doc_keyword.rs b/tests/ui/internal-lints/existing_doc_keyword.rs deleted file mode 100644 index 8f60b931591e2..0000000000000 --- a/tests/ui/internal-lints/existing_doc_keyword.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ compile-flags: -Z unstable-options - -#![feature(rustdoc_internals)] - -#![crate_type = "lib"] - -#![deny(rustc::existing_doc_keyword)] - -#[doc(keyword = "tadam")] //~ ERROR -mod tadam {} diff --git a/tests/ui/internal-lints/existing_doc_keyword.stderr b/tests/ui/internal-lints/existing_doc_keyword.stderr deleted file mode 100644 index 5573e7ce4d02d..0000000000000 --- a/tests/ui/internal-lints/existing_doc_keyword.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: found non-existing keyword `tadam` used in `#[doc(keyword = "...")]` - --> $DIR/existing_doc_keyword.rs:9:1 - | -LL | #[doc(keyword = "tadam")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: only existing keywords are allowed in core/std -note: the lint level is defined here - --> $DIR/existing_doc_keyword.rs:7:9 - | -LL | #![deny(rustc::existing_doc_keyword)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/rustdoc/doc_keyword.rs b/tests/ui/rustdoc/doc_keyword.rs index 68a8802b2f645..e0995f336da3b 100644 --- a/tests/ui/rustdoc/doc_keyword.rs +++ b/tests/ui/rustdoc/doc_keyword.rs @@ -1,14 +1,14 @@ #![crate_type = "lib"] #![feature(rustdoc_internals)] -#![doc(keyword = "hello")] //~ ERROR - -#[doc(keyword = "hell")] //~ ERROR +#![doc(keyword = "hello")] +//~^ ERROR `#![doc(keyword = "...")]` isn't allowed as a crate-level attribute +#[doc(keyword = "hell")] //~ ERROR `#[doc(keyword = "...")]` should be used on empty modules mod foo { fn hell() {} } -#[doc(keyword = "hall")] //~ ERROR +#[doc(keyword = "hall")] //~ ERROR `#[doc(keyword = "...")]` should be used on modules fn foo() {} @@ -18,3 +18,6 @@ trait Foo { //~^ ERROR: `#[doc(keyword = "...")]` should be used on modules fn quux() {} } + +#[doc(keyword = "tadam")] //~ ERROR nonexistent keyword `tadam` +mod tadam {} diff --git a/tests/ui/rustdoc/doc_keyword.stderr b/tests/ui/rustdoc/doc_keyword.stderr index a1d0e4ffc0938..584daae2f1aa5 100644 --- a/tests/ui/rustdoc/doc_keyword.stderr +++ b/tests/ui/rustdoc/doc_keyword.stderr @@ -10,6 +10,14 @@ error: `#[doc(keyword = "...")]` should be used on modules LL | #[doc(keyword = "hall")] | ^^^^^^^^^^^^^^^^ +error: nonexistent keyword `tadam` used in `#[doc(keyword = "...")]` + --> $DIR/doc_keyword.rs:22:17 + | +LL | #[doc(keyword = "tadam")] + | ^^^^^^^ + | + = help: only existing keywords are allowed in core/std + error: `#[doc(keyword = "...")]` should be used on modules --> $DIR/doc_keyword.rs:17:11 | @@ -22,5 +30,5 @@ error: `#![doc(keyword = "...")]` isn't allowed as a crate-level attribute LL | #![doc(keyword = "hello")] | ^^^^^^^^^^^^^^^^^ -error: aborting due to 4 previous errors +error: aborting due to 5 previous errors diff --git a/tests/ui/structs/auxiliary/struct_field_default.rs b/tests/ui/structs/default-field-values/auxiliary/struct_field_default.rs similarity index 100% rename from tests/ui/structs/auxiliary/struct_field_default.rs rename to tests/ui/structs/default-field-values/auxiliary/struct_field_default.rs diff --git a/tests/ui/structs/default-field-values-failures.rs b/tests/ui/structs/default-field-values/failures.rs similarity index 100% rename from tests/ui/structs/default-field-values-failures.rs rename to tests/ui/structs/default-field-values/failures.rs diff --git a/tests/ui/structs/default-field-values-failures.stderr b/tests/ui/structs/default-field-values/failures.stderr similarity index 82% rename from tests/ui/structs/default-field-values-failures.stderr rename to tests/ui/structs/default-field-values/failures.stderr index 5b9d2df5a5d73..65ec100fe2ea3 100644 --- a/tests/ui/structs/default-field-values-failures.stderr +++ b/tests/ui/structs/default-field-values/failures.stderr @@ -1,5 +1,5 @@ error: the `#[default]` attribute may only be used on unit enum variants or variants where every field has a default value - --> $DIR/default-field-values-failures.rs:47:5 + --> $DIR/failures.rs:47:5 | LL | Variant {} | ^^^^^^^ @@ -7,7 +7,7 @@ LL | Variant {} = help: consider a manual implementation of `Default` error: generic parameters may not be used in const operations - --> $DIR/default-field-values-failures.rs:22:23 + --> $DIR/failures.rs:22:23 | LL | bat: i32 = as T>::K, | ^ cannot perform const operation using `C` @@ -16,19 +16,19 @@ LL | bat: i32 = as T>::K, = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions error: default fields are not supported in tuple structs - --> $DIR/default-field-values-failures.rs:26:22 + --> $DIR/failures.rs:26:22 | LL | pub struct Rak(i32 = 42); | ^^ default fields are only supported on structs error: generic `Self` types are currently not permitted in anonymous constants - --> $DIR/default-field-values-failures.rs:20:14 + --> $DIR/failures.rs:20:14 | LL | bar: S = Self::S, | ^^^^ error[E0277]: the trait bound `S: Default` is not satisfied - --> $DIR/default-field-values-failures.rs:14:5 + --> $DIR/failures.rs:14:5 | LL | #[derive(Debug, Default)] | ------- in this derive macro expansion @@ -44,13 +44,13 @@ LL | pub struct S; | error: missing mandatory field `bar` - --> $DIR/default-field-values-failures.rs:53:21 + --> $DIR/failures.rs:53:21 | LL | let _ = Bar { .. }; | ^ error[E0308]: mismatched types - --> $DIR/default-field-values-failures.rs:57:17 + --> $DIR/failures.rs:57:17 | LL | let _ = Rak(..); | --- ^^ expected `i32`, found `RangeFull` @@ -58,29 +58,29 @@ LL | let _ = Rak(..); | arguments to this struct are incorrect | note: tuple struct defined here - --> $DIR/default-field-values-failures.rs:26:12 + --> $DIR/failures.rs:26:12 | LL | pub struct Rak(i32 = 42); | ^^^ help: you might have meant to use `..` to skip providing a value for expected fields, but this is only supported on non-tuple struct literals; it is instead interpreted as a `std::ops::RangeFull` literal - --> $DIR/default-field-values-failures.rs:57:17 + --> $DIR/failures.rs:57:17 | LL | let _ = Rak(..); | ^^ error[E0061]: this struct takes 1 argument but 2 arguments were supplied - --> $DIR/default-field-values-failures.rs:59:13 + --> $DIR/failures.rs:59:13 | LL | let _ = Rak(0, ..); | ^^^ -- unexpected argument #2 of type `RangeFull` | help: you might have meant to use `..` to skip providing a value for expected fields, but this is only supported on non-tuple struct literals; it is instead interpreted as a `std::ops::RangeFull` literal - --> $DIR/default-field-values-failures.rs:59:20 + --> $DIR/failures.rs:59:20 | LL | let _ = Rak(0, ..); | ^^ note: tuple struct defined here - --> $DIR/default-field-values-failures.rs:26:12 + --> $DIR/failures.rs:26:12 | LL | pub struct Rak(i32 = 42); | ^^^ @@ -91,18 +91,18 @@ LL + let _ = Rak(0); | error[E0061]: this struct takes 1 argument but 2 arguments were supplied - --> $DIR/default-field-values-failures.rs:61:13 + --> $DIR/failures.rs:61:13 | LL | let _ = Rak(.., 0); | ^^^ -- unexpected argument #1 of type `RangeFull` | help: you might have meant to use `..` to skip providing a value for expected fields, but this is only supported on non-tuple struct literals; it is instead interpreted as a `std::ops::RangeFull` literal - --> $DIR/default-field-values-failures.rs:61:17 + --> $DIR/failures.rs:61:17 | LL | let _ = Rak(.., 0); | ^^ note: tuple struct defined here - --> $DIR/default-field-values-failures.rs:26:12 + --> $DIR/failures.rs:26:12 | LL | pub struct Rak(i32 = 42); | ^^^ diff --git a/tests/ui/structs/default-field-values-invalid-const.rs b/tests/ui/structs/default-field-values/invalid-const.rs similarity index 100% rename from tests/ui/structs/default-field-values-invalid-const.rs rename to tests/ui/structs/default-field-values/invalid-const.rs diff --git a/tests/ui/structs/default-field-values-invalid-const.stderr b/tests/ui/structs/default-field-values/invalid-const.stderr similarity index 79% rename from tests/ui/structs/default-field-values-invalid-const.stderr rename to tests/ui/structs/default-field-values/invalid-const.stderr index 47f25a1f38e3f..f4a3437031bdd 100644 --- a/tests/ui/structs/default-field-values-invalid-const.stderr +++ b/tests/ui/structs/default-field-values/invalid-const.stderr @@ -1,13 +1,13 @@ error[E0080]: evaluation of constant value failed - --> $DIR/default-field-values-invalid-const.rs:5:19 + --> $DIR/invalid-const.rs:5:19 | LL | pub bax: u8 = panic!("asdf"), - | ^^^^^^^^^^^^^^ the evaluated program panicked at 'asdf', $DIR/default-field-values-invalid-const.rs:5:19 + | ^^^^^^^^^^^^^^ the evaluated program panicked at 'asdf', $DIR/invalid-const.rs:5:19 | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation of `Baz::::bat::{constant#0}` failed - --> $DIR/default-field-values-invalid-const.rs:11:19 + --> $DIR/invalid-const.rs:11:19 | LL | pub bat: u8 = 130 + 130, | ^^^^^^^^^ attempt to compute `130_u8 + 130_u8`, which would overflow diff --git a/tests/ui/structs/default-field-values-support.rs b/tests/ui/structs/default-field-values/support.rs similarity index 100% rename from tests/ui/structs/default-field-values-support.rs rename to tests/ui/structs/default-field-values/support.rs diff --git a/tests/ui/structs/default-field-values/use-normalized-ty-for-default-struct-value.rs b/tests/ui/structs/default-field-values/use-normalized-ty-for-default-struct-value.rs new file mode 100644 index 0000000000000..bb14524608d02 --- /dev/null +++ b/tests/ui/structs/default-field-values/use-normalized-ty-for-default-struct-value.rs @@ -0,0 +1,17 @@ +//@ check-pass + +#![feature(default_field_values)] + +struct Value; + +impl Value { + pub const VALUE: Self = Self; +} + +pub struct WithUse { + _use: Value<{ 0 + 0 }> = Value::VALUE +} + +const _: WithUse = WithUse { .. }; + +fn main() {}