diff --git a/compiler/rustc_ast/src/tokenstream.rs b/compiler/rustc_ast/src/tokenstream.rs index 39be8ce5c089d..428f37b8af450 100644 --- a/compiler/rustc_ast/src/tokenstream.rs +++ b/compiler/rustc_ast/src/tokenstream.rs @@ -622,7 +622,7 @@ pub enum Spacing { /// A `TokenStream` is an abstract sequence of tokens, organized into [`TokenTree`]s. #[derive(Clone, Debug, Default, PartialEq, Eq, Hash, Encodable, Decodable)] -pub struct TokenStream(pub(crate) Arc>); +pub struct TokenStream(Arc>); impl TokenStream { pub fn new(tts: Vec) -> TokenStream { @@ -881,7 +881,7 @@ impl<'t> Iterator for TokenStreamIter<'t> { } #[derive(Clone, Debug)] -pub struct TokenTreeCursor { +struct TokenTreeCursor { stream: TokenStream, /// Points to the current token tree in the stream. In `TokenCursor::curr`, /// this can be any token tree. In `TokenCursor::stack`, this is always a @@ -891,27 +891,27 @@ pub struct TokenTreeCursor { impl TokenTreeCursor { #[inline] - pub fn new(stream: TokenStream) -> Self { + fn new(stream: TokenStream) -> Self { TokenTreeCursor { stream, index: 0 } } #[inline] - pub fn curr(&self) -> Option<&TokenTree> { + fn curr(&self) -> Option<&TokenTree> { self.stream.get(self.index) } - pub fn look_ahead(&self, n: usize) -> Option<&TokenTree> { + fn look_ahead(&self, n: usize) -> Option<&TokenTree> { self.stream.get(self.index + n) } #[inline] - pub fn bump(&mut self) { + fn bump(&mut self) { self.index += 1; } // For skipping ahead in rare circumstances. #[inline] - pub fn bump_to_end(&mut self) { + fn bump_to_end(&mut self) { self.index = self.stream.len(); } } @@ -927,18 +927,68 @@ pub struct TokenCursor { // The delimiters for this token stream are found in `self.stack.last()`; // if that is `None` we are in the outermost token stream which never has // delimiters. - pub curr: TokenTreeCursor, + curr: TokenTreeCursor, // Token streams surrounding the current one. The index within each cursor // always points to a `TokenTree::Delimited`. - pub stack: Vec, + stack: Vec, } impl TokenCursor { + #[inline] + pub fn new(stream: TokenStream) -> Self { + TokenCursor { curr: TokenTreeCursor::new(stream), stack: vec![] } + } + pub fn next(&mut self) -> (Token, Spacing) { self.inlined_next() } + /// An `n` of zero is the next token tree in the current token stream; won't look outside the + /// current token stream. + #[inline] + pub fn look_ahead(&self, n: usize) -> Option<&TokenTree> { + self.curr.look_ahead(n) + } + + /// Returns the first token tree (if there is one) past the close delimiter of the enclosing + /// delimited sequence. Panics if we are not within a delimited sequence. + #[inline] + pub fn look_ahead_past_close_delim(&self) -> Option<&TokenTree> { + self.stack.last().unwrap().look_ahead(1) + } + + /// Clones the `TokenTree::Delimited` that we are currently within. Panics if we are not within + /// a delimited sequence. + #[inline] + pub fn clone_enclosing_delim(&self) -> TokenTree { + self.stack.last().unwrap().curr().unwrap().clone() + } + + /// For skipping to the end of the current sequence, in rare circumstances. + #[inline] + pub fn bump_to_end(&mut self) { + self.curr.bump_to_end() + } + + /// Note: the outermost stream has depth of 0. + #[inline] + pub fn depth(&self) -> usize { + self.stack.len() + } + + /// Returns details about the parent delimited sequence, if there is one. + #[inline] + pub fn parent_delim_and_span(&self) -> Option<(Delimiter, DelimSpan)> { + if let Some(last) = self.stack.last() + && let Some(TokenTree::Delimited(span, _, delim, _)) = last.curr() + { + Some((*delim, *span)) + } else { + None + } + } + /// This always-inlined version should only be used on hot code paths. #[inline(always)] pub fn inlined_next(&mut self) -> (Token, Spacing) { diff --git a/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs index 1de0bba71ffd2..15c4714624a63 100644 --- a/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs @@ -541,7 +541,7 @@ impl CombineAttributeParser for TargetFeatureParser { parse_tf_attribute(cx, args) } - fn finalize_check(cx: &FinalizeContext<'_, '_>, attr_span: Span) { + fn finalize_check(cx: &FinalizeCheckContext<'_, '_>, attr_span: Span) { // `#[target_feature]` is incompatible with lang item functions, // except on WASM where calling target-feature functions is safe (see #84988). if !cx.sess().target.is_like_wasm && !cx.sess().opts.actually_rustdoc { diff --git a/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs index c76661b80e11d..07713590ff2e9 100644 --- a/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs @@ -576,7 +576,7 @@ impl NoArgsAttributeParser for FfiPureParser { const STABILITY: AttributeStability = unstable!(ffi_pure); const CREATE: fn(Span) -> AttributeKind = AttributeKind::FfiPure; - fn finalize_check(cx: &FinalizeContext<'_, '_>, attr_span: Span) { + fn finalize_check(cx: &FinalizeCheckContext<'_, '_>, attr_span: Span) { // `#[ffi_const]` functions cannot be `#[ffi_pure]`. if cx.all_attrs.iter().any(|a| a.word_is(sym::ffi_const)) { cx.emit_err(BothFfiConstAndPure { attr_span }); diff --git a/compiler/rustc_attr_parsing/src/attributes/lint_helpers.rs b/compiler/rustc_attr_parsing/src/attributes/lint_helpers.rs index 38afeea07794a..8011beb05546f 100644 --- a/compiler/rustc_attr_parsing/src/attributes/lint_helpers.rs +++ b/compiler/rustc_attr_parsing/src/attributes/lint_helpers.rs @@ -1,6 +1,9 @@ use rustc_feature::AttributeStability; +use rustc_hir::attrs::ReprAttr; +use rustc_hir::find_attr; use super::prelude::*; +use crate::session_diagnostics::RustcPubTransparent; pub(crate) struct RustcAsPtrParser; impl NoArgsAttributeParser for RustcAsPtrParser { @@ -26,6 +29,17 @@ impl NoArgsAttributeParser for RustcPubTransparentParser { ]); const STABILITY: AttributeStability = unstable!(rustc_attrs); const CREATE: fn(Span) -> AttributeKind = AttributeKind::RustcPubTransparent; + + fn finalize_check(cx: &FinalizeCheckContext<'_, '_>, attr_span: Span) { + // `#[rustc_pub_transparent]` may only be applied to `#[repr(transparent)]` types. + let is_transparent = find_attr!( + cx.parsed_attrs, + Repr { reprs, .. } if reprs.iter().any(|(r, _)| r == &ReprAttr::ReprTransparent) + ); + if !is_transparent { + cx.emit_err(RustcPubTransparent { span: cx.target_span, attr_span }); + } + } } pub(crate) struct RustcPassByValueParser; diff --git a/compiler/rustc_attr_parsing/src/attributes/mod.rs b/compiler/rustc_attr_parsing/src/attributes/mod.rs index d3ddd79a97619..0adae406df5c6 100644 --- a/compiler/rustc_attr_parsing/src/attributes/mod.rs +++ b/compiler/rustc_attr_parsing/src/attributes/mod.rs @@ -26,7 +26,7 @@ use rustc_span::edition::Edition; use rustc_span::{Span, Symbol}; use thin_vec::ThinVec; -use crate::context::{AcceptContext, FinalizeContext}; +use crate::context::{AcceptContext, FinalizeCheckContext, FinalizeCheckFn, FinalizeContext}; use crate::parser::ArgParser; use crate::session_diagnostics::UnusedMultiple; use crate::target_checking::AllowedTargets; @@ -117,6 +117,20 @@ pub(crate) trait AttributeParser: Default + 'static { /// every single syntax item that could have attributes applied to it. /// Your accept mappings should determine whether this returns something. fn finalize(self, cx: &FinalizeContext<'_, '_>) -> Option; + + /// If this parser produced an attribute, optionally returns a cross-attribute check + /// to run once *all* attributes on the item have been finalized, together with the + /// span it should be reported at. + /// + /// Running after finalization means the check can inspect the fully parsed attributes + /// via [`FinalizeCheckContext::parsed_attrs`], which are not yet all available during + /// [`finalize`](Self::finalize). This is queried right before `finalize` consumes the + /// parser state. + /// + /// Defaults to no check. + fn deferred_finalize_check(&self) -> Option<(FinalizeCheckFn, Span)> { + None + } } /// Alternative to [`AttributeParser`] that automatically handles state management. @@ -148,13 +162,14 @@ pub(crate) trait SingleAttributeParser: 'static { /// Converts a single syntactical attribute to a single semantic attribute, or [`AttributeKind`] fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option; - /// Optional cross-attribute validation, run once during finalization after all - /// attributes on the item have been parsed. Unlike [`convert`](Self::convert), this - /// has access to the sibling attributes via [`FinalizeContext::all_attrs`], so it can - /// reject incompatible combinations. `attr_span` is the span of this attribute. + /// Optional cross-attribute validation, run once *after* all attributes on the item + /// have been finalized. Unlike [`convert`](Self::convert), this has access to the + /// sibling attributes via [`FinalizeCheckContext::all_attrs`] and the fully parsed + /// attributes via [`FinalizeCheckContext::parsed_attrs`], so it can reject incompatible + /// combinations. `attr_span` is the span of this attribute. /// /// Defaults to a no-op. - fn finalize_check(_cx: &FinalizeContext<'_, '_>, _attr_span: Span) {} + fn finalize_check(_cx: &FinalizeCheckContext<'_, '_>, _attr_span: Span) {} } /// Use in combination with [`SingleAttributeParser`]. @@ -185,11 +200,15 @@ impl AttributeParser for Single { const ALLOWED_TARGETS: AllowedTargets<'_> = T::ALLOWED_TARGETS; const SAFETY: AttributeSafety = T::SAFETY; - fn finalize(self, cx: &FinalizeContext<'_, '_>) -> Option { - let (kind, span) = self.1?; - T::finalize_check(cx, span); + fn finalize(self, _cx: &FinalizeContext<'_, '_>) -> Option { + let (kind, _span) = self.1?; Some(kind) } + + fn deferred_finalize_check(&self) -> Option<(FinalizeCheckFn, Span)> { + let (_, span) = self.1.as_ref()?; + Some((::finalize_check, *span)) + } } pub(crate) enum OnDuplicate { @@ -269,13 +288,14 @@ pub(crate) trait NoArgsAttributeParser: 'static { /// Create the [`AttributeKind`] given attribute's [`Span`]. const CREATE: fn(Span) -> AttributeKind; - /// Optional cross-attribute validation, run once during finalization after all - /// attributes on the item have been parsed. Has access to the sibling attributes via - /// [`FinalizeContext::all_attrs`], so it can reject incompatible combinations. + /// Optional cross-attribute validation, run once *after* all attributes on the item + /// have been finalized. Has access to the sibling attributes via + /// [`FinalizeCheckContext::all_attrs`] and the fully parsed attributes via + /// [`FinalizeCheckContext::parsed_attrs`], so it can reject incompatible combinations. /// `attr_span` is the span of this attribute. /// /// Defaults to a no-op. - fn finalize_check(_cx: &FinalizeContext<'_, '_>, _attr_span: Span) {} + fn finalize_check(_cx: &FinalizeCheckContext<'_, '_>, _attr_span: Span) {} } pub(crate) struct WithoutArgs(PhantomData); @@ -299,7 +319,7 @@ impl SingleAttributeParser for WithoutArgs { Some(T::CREATE(cx.attr_span)) } - fn finalize_check(cx: &FinalizeContext<'_, '_>, attr_span: Span) { + fn finalize_check(cx: &FinalizeCheckContext<'_, '_>, attr_span: Span) { T::finalize_check(cx, attr_span) } } @@ -336,13 +356,14 @@ pub(crate) trait CombineAttributeParser: 'static { args: &ArgParser, ) -> impl IntoIterator; - /// Optional cross-attribute validation, run once during finalization after all - /// attributes on the item have been parsed. Has access to the sibling attributes via - /// [`FinalizeContext::all_attrs`], so it can reject incompatible combinations. + /// Optional cross-attribute validation, run once *after* all attributes on the item + /// have been finalized. Has access to the sibling attributes via + /// [`FinalizeCheckContext::all_attrs`] and the fully parsed attributes via + /// [`FinalizeCheckContext::parsed_attrs`], so it can reject incompatible combinations. /// `attr_span` is the span of the first attribute that was encountered. /// /// Defaults to a no-op. - fn finalize_check(_cx: &FinalizeContext<'_, '_>, _attr_span: Span) {} + fn finalize_check(_cx: &FinalizeCheckContext<'_, '_>, _attr_span: Span) {} } /// Use in combination with [`CombineAttributeParser`]. @@ -375,12 +396,12 @@ impl AttributeParser for Combine { const ALLOWED_TARGETS: AllowedTargets<'_> = T::ALLOWED_TARGETS; const SAFETY: AttributeSafety = T::SAFETY; - fn finalize(self, cx: &FinalizeContext<'_, '_>) -> Option { - if let Some(first_span) = self.first_span { - T::finalize_check(cx, first_span); - Some(T::CONVERT(self.items, first_span)) - } else { - None - } + fn finalize(self, _cx: &FinalizeContext<'_, '_>) -> Option { + let first_span = self.first_span?; + Some(T::CONVERT(self.items, first_span)) + } + + fn deferred_finalize_check(&self) -> Option<(FinalizeCheckFn, Span)> { + Some((::finalize_check, self.first_span?)) } } diff --git a/compiler/rustc_attr_parsing/src/attributes/prelude.rs b/compiler/rustc_attr_parsing/src/attributes/prelude.rs index 4dd8f715f4387..744d5368580d8 100644 --- a/compiler/rustc_attr_parsing/src/attributes/prelude.rs +++ b/compiler/rustc_attr_parsing/src/attributes/prelude.rs @@ -15,7 +15,7 @@ pub(super) use crate::attributes::{ }; // contexts #[doc(hidden)] -pub(super) use crate::context::{AcceptContext, FinalizeContext}; +pub(super) use crate::context::{AcceptContext, FinalizeCheckContext, FinalizeContext}; #[doc(hidden)] pub(super) use crate::parser::*; // target checking diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index 83d5439efd4f0..5f329eec290fc 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -12,8 +12,8 @@ use rustc_ast::{AttrStyle, MetaItemLit, Safety}; use rustc_data_structures::sync::{DynSend, DynSync}; use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, Level, MultiSpan}; use rustc_feature::AttributeStability; -use rustc_hir::AttrPath; use rustc_hir::attrs::AttributeKind; +use rustc_hir::{AttrPath, Attribute}; use rustc_parse::parser::Recovery; use rustc_session::Session; use rustc_session::lint::{Lint, LintId}; @@ -94,7 +94,24 @@ pub(super) struct GroupTypeInnerAccept { pub(crate) type AcceptFn = Box Fn(&mut AcceptContext<'_, 'sess>, &ArgParser) + Send + Sync>; -pub(crate) type FinalizeFn = fn(&mut FinalizeContext<'_, '_>) -> Option; + +pub(crate) type FinalizeFn = fn(&mut FinalizeContext<'_, '_>) -> FinalizeOutput; + +/// A cross-attribute check that runs *after* all attributes on an item have been +/// finalized, so it can inspect the fully parsed attributes via +/// [`FinalizeCheckContext::parsed_attrs`]. The [`Span`] is the span of the attribute the +/// check is associated with, used for diagnostics. +pub(crate) type FinalizeCheckFn = fn(&FinalizeCheckContext<'_, '_>, Span); + +/// The result of finalizing a single attribute parser. +pub(crate) struct FinalizeOutput { + /// The attribute the parser produced, if any. + pub(crate) attr: Option, + /// A check to run once *all* attributes on the item have been finalized, together + /// with the span it should be reported at. Deferred so that it can inspect the fully + /// parsed attributes via [`FinalizeCheckContext::parsed_attrs`]. + pub(crate) deferred_check: Option<(FinalizeCheckFn, Span)>, +} macro_rules! attribute_parsers { ( @@ -123,7 +140,11 @@ macro_rules! attribute_parsers { allowed_targets: <$names as crate::attributes::AttributeParser>::ALLOWED_TARGETS, finalizer: |cx| { let state = STATE_OBJECT.take(); - state.finalize(cx) + // Compute the deferred check (if any) before consuming + // the state in `finalize`. + let deferred_check = state.deferred_finalize_check(); + let attr = state.finalize(cx); + FinalizeOutput { attr, deferred_check } } }); } @@ -793,6 +814,42 @@ impl<'p, 'sess: 'p> DerefMut for FinalizeContext<'p, 'sess> { } } +/// Context given to deferred cross-attribute checks (`finalize_check`). +/// +/// These checks run *after* every attribute on an item has been finalized, so unlike +/// [`FinalizeContext`] this context can also inspect the fully parsed attributes via +/// [`parsed_attrs`](Self::parsed_attrs). +pub(crate) struct FinalizeCheckContext<'p, 'sess> { + pub(crate) shared: SharedContext<'p, 'sess>, + + /// A list of all attribute on this syntax node. + /// + /// Useful for compatibility checks with other attributes. + /// + /// Unlike [`parsed_attrs`](Self::parsed_attrs), this only contains the *paths* of the + /// attributes. + pub(crate) all_attrs: &'p [RefPathParser<'p>], + + /// All attributes that have been parsed on this syntax node. + /// + /// Unlike [`all_attrs`](Self::all_attrs), this contains the fully parsed attributes. + pub(crate) parsed_attrs: &'p [Attribute], +} + +impl<'p, 'sess: 'p> Deref for FinalizeCheckContext<'p, 'sess> { + type Target = SharedContext<'p, 'sess>; + + fn deref(&self) -> &Self::Target { + &self.shared + } +} + +impl<'p, 'sess: 'p> DerefMut for FinalizeCheckContext<'p, 'sess> { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.shared + } +} + impl<'p, 'sess: 'p> Deref for SharedContext<'p, 'sess> { type Target = AttributeParser<'sess>; diff --git a/compiler/rustc_attr_parsing/src/interface.rs b/compiler/rustc_attr_parsing/src/interface.rs index a15d5bfa175a7..30ff962c8bded 100644 --- a/compiler/rustc_attr_parsing/src/interface.rs +++ b/compiler/rustc_attr_parsing/src/interface.rs @@ -18,7 +18,8 @@ use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span, Symbol, sym}; use crate::attributes::AttributeSafety; use crate::context::{ - ATTRIBUTE_PARSERS, AcceptContext, FinalizeContext, FinalizeFn, SharedContext, + ATTRIBUTE_PARSERS, AcceptContext, FinalizeCheckContext, FinalizeCheckFn, FinalizeContext, + FinalizeFn, FinalizeOutput, SharedContext, }; use crate::parser::{AllowExprMetavar, ArgParser, PathParser, RefPathParser}; use crate::session_diagnostics::ParsedDescription; @@ -448,8 +449,14 @@ impl<'sess> AttributeParser<'sess> { } synthetic_attr_state.finalize_synthetic_attrs(&mut attributes); + + // First, run all finalizers to produce the parsed attributes. Cross-attribute + // checks that need to inspect the fully parsed attributes are deferred until all + // finalizers have run (see below), since the parsed attributes are not yet all + // available here. + let mut deferred_checks: Vec<(FinalizeCheckFn, Span)> = Vec::new(); for f in &finalizers { - if let Some(attr) = f(&mut FinalizeContext { + let FinalizeOutput { attr, deferred_check } = f(&mut FinalizeContext { shared: SharedContext { cx: self, target_span, @@ -459,9 +466,33 @@ impl<'sess> AttributeParser<'sess> { has_lint_been_emitted: AtomicBool::new(false), }, all_attrs: &attr_paths, - }) { + }); + if let Some(attr) = attr { attributes.push(Attribute::Parsed(attr)); } + if let Some(deferred_check) = deferred_check { + deferred_checks.push(deferred_check); + } + } + + // Now that all attributes have been parsed, run the deferred checks. These can + // inspect the fully parsed attributes via `FinalizeCheckContext::parsed_attrs`. + for (check, attr_span) in deferred_checks { + check( + &FinalizeCheckContext { + shared: SharedContext { + cx: self, + target_span, + target, + emit_lint: &mut emit_lint, + #[cfg(debug_assertions)] + has_lint_been_emitted: AtomicBool::new(false), + }, + all_attrs: &attr_paths, + parsed_attrs: &attributes, + }, + attr_span, + ); } if !matches!(self.should_emit, ShouldEmit::Nothing) && target == Target::WherePredicate { diff --git a/compiler/rustc_attr_parsing/src/session_diagnostics.rs b/compiler/rustc_attr_parsing/src/session_diagnostics.rs index cbcec3ac22231..a5f6e7afc3dcc 100644 --- a/compiler/rustc_attr_parsing/src/session_diagnostics.rs +++ b/compiler/rustc_attr_parsing/src/session_diagnostics.rs @@ -20,6 +20,15 @@ pub(crate) struct BothFfiConstAndPure { pub attr_span: Span, } +#[derive(Diagnostic)] +#[diag("attribute should be applied to `#[repr(transparent)]` types")] +pub(crate) struct RustcPubTransparent { + #[primary_span] + pub attr_span: Span, + #[label("not a `#[repr(transparent)]` type")] + pub span: Span, +} + #[derive(Diagnostic)] #[diag("{$attr_str} attribute cannot have empty value")] pub(crate) struct DocAliasEmpty<'a> { diff --git a/compiler/rustc_hir_typeck/src/upvar.rs b/compiler/rustc_hir_typeck/src/upvar.rs index 4a92a3ed62e0e..d75d346e712e0 100644 --- a/compiler/rustc_hir_typeck/src/upvar.rs +++ b/compiler/rustc_hir_typeck/src/upvar.rs @@ -2344,12 +2344,22 @@ fn adjust_for_non_move_closure( place.projections.iter().position(|proj| proj.kind == ProjectionKind::Deref); match kind { - ty::UpvarCapture::ByValue | ty::UpvarCapture::ByUse => { + ty::UpvarCapture::ByValue => { if let Some(idx) = contains_deref { truncate_place_to_len_and_update_capture_kind(&mut place, &mut kind, idx); } } + // A non-`move`/`use` closure that only `.use`s an upvar does not need to + // own (and thus clone-on-capture) the value. The `ByUse` kind here can only + // come from a `x.use` in the body (a `use ||` capture clause goes through + // `adjust_for_use_closure` instead). Capturing such a place by immutable + // borrow lets the `.use` expression clone per evaluation, rather than also + // cloning the value into the closure at construction time. See #157141. + ty::UpvarCapture::ByUse => { + kind = ty::UpvarCapture::ByRef(ty::BorrowKind::Immutable); + } + ty::UpvarCapture::ByRef(..) => {} } diff --git a/compiler/rustc_llvm/build.rs b/compiler/rustc_llvm/build.rs index 5be8bd466f854..ef262a5b19b08 100644 --- a/compiler/rustc_llvm/build.rs +++ b/compiler/rustc_llvm/build.rs @@ -160,6 +160,12 @@ impl<'a> IntoIterator for &'a LlvmConfigOutput { } } +fn is_libstdcxx_cxx11_abi_flag(flag: &str) -> bool { + flag == "-D_GLIBCXX_USE_CXX11_ABI" + || flag.starts_with("-D_GLIBCXX_USE_CXX11_ABI=") + || flag == "-U_GLIBCXX_USE_CXX11_ABI" +} + fn main() { if cfg!(feature = "check_only") { return; @@ -255,6 +261,14 @@ fn main() { continue; } + // This is a libstdc++ implementation detail for the C++ library that + // built the runnable llvm-config. When cross-compiling, target LLVM may + // have been built against a target libstdc++ with a different default. + // Let the target compiler/toolchain select its ABI instead. + if is_crossed && is_libstdcxx_cxx11_abi_flag(flag.as_ref()) { + continue; + } + if flag.starts_with("-flto") { continue; } diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 858a2f21c6b75..5c939cbe773cb 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -713,6 +713,40 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { }) } + fn pretty_print_closure_inner( + &mut self, + did: DefId, + args: ty::GenericArgsRef<'tcx>, + ) -> Result<(), PrintError> { + if self.should_truncate() { + write!(self, "@...") + } else if self.tcx().sess.opts.unstable_opts.span_free_formats { + write!(self, "@")?; + self.print_def_path(did, args) + } else if let Some(did) = did.as_local() { + let span = self.tcx().def_span(did); + let loc = if with_forced_trimmed_paths() { + self.tcx() + .sess + .source_map() + .span_to_short_string(span, RemapPathScopeComponents::DIAGNOSTICS) + } else { + self.tcx().sess.source_map().span_to_diagnostic_string(span) + }; + write!( + self, + "@{}", + // This may end up in stderr diagnostics but it may also be + // emitted into MIR. Hence we use the remapped path if + // available + loc + ) + } else { + write!(self, "@")?; + self.print_def_path(did, args) + } + } + fn pretty_print_type(&mut self, ty: Ty<'tcx>) -> Result<(), PrintError> { match *ty.kind() { ty::Bool => write!(self, "bool")?, @@ -904,22 +938,12 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { // // This will look like: // {async fn body of some_fn()} - let did_of_the_fn_item = self.tcx().parent(did); write!(self, " of ")?; + let did_of_the_fn_item = self.tcx().parent(did); self.print_def_path(did_of_the_fn_item, args)?; write!(self, "()")?; - } else if let Some(local_did) = did.as_local() { - let span = self.tcx().def_span(local_did); - write!( - self, - "@{}", - // This may end up in stderr diagnostics but it may also be emitted - // into MIR. Hence we use the remapped path if available - self.tcx().sess.source_map().span_to_diagnostic_string(span) - )?; } else { - write!(self, "@")?; - self.print_def_path(did, args)?; + self.pretty_print_closure_inner(did, args)?; } } else { self.print_def_path(did, args)?; @@ -937,63 +961,19 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { } ty::CoroutineWitness(did, args) => { write!(self, "{{")?; - if !self.tcx().sess.verbose_internals() { + if !self.should_print_verbose() { write!(self, "coroutine witness")?; - if let Some(did) = did.as_local() { - let span = self.tcx().def_span(did); - write!( - self, - "@{}", - // This may end up in stderr diagnostics but it may also be emitted - // into MIR. Hence we use the remapped path if available - self.tcx().sess.source_map().span_to_diagnostic_string(span) - )?; - } else { - write!(self, "@")?; - self.print_def_path(did, args)?; - } + self.pretty_print_closure_inner(did, args)?; } else { self.print_def_path(did, args)?; } - write!(self, "}}")? } ty::Closure(did, args) => { write!(self, "{{")?; if !self.should_print_verbose() { write!(self, "closure")?; - if self.should_truncate() { - write!(self, "@...}}")?; - return Ok(()); - } else { - if let Some(did) = did.as_local() { - if self.tcx().sess.opts.unstable_opts.span_free_formats { - write!(self, "@")?; - self.print_def_path(did.to_def_id(), args)?; - } else { - let span = self.tcx().def_span(did); - let loc = if with_forced_trimmed_paths() { - self.tcx().sess.source_map().span_to_short_string( - span, - RemapPathScopeComponents::DIAGNOSTICS, - ) - } else { - self.tcx().sess.source_map().span_to_diagnostic_string(span) - }; - write!( - self, - "@{}", - // This may end up in stderr diagnostics but it may also be - // emitted into MIR. Hence we use the remapped path if - // available - loc - )?; - } - } else { - write!(self, "@")?; - self.print_def_path(did, args)?; - } - } + self.pretty_print_closure_inner(did, args)?; } else { self.print_def_path(did, args)?; write!(self, " closure_kind_ty=")?; @@ -1011,43 +991,14 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { match self.tcx().coroutine_kind(self.tcx().coroutine_for_closure(did)).unwrap() { hir::CoroutineKind::Desugared( - hir::CoroutineDesugaring::Async, - hir::CoroutineSource::Closure, - ) => write!(self, "async closure")?, - hir::CoroutineKind::Desugared( - hir::CoroutineDesugaring::AsyncGen, + desugaring, hir::CoroutineSource::Closure, - ) => write!(self, "async gen closure")?, - hir::CoroutineKind::Desugared( - hir::CoroutineDesugaring::Gen, - hir::CoroutineSource::Closure, - ) => write!(self, "gen closure")?, + ) => write!(self, "{desugaring}closure")?, _ => unreachable!( "coroutine from coroutine-closure should have CoroutineSource::Closure" ), - } - if let Some(did) = did.as_local() { - if self.tcx().sess.opts.unstable_opts.span_free_formats { - write!(self, "@")?; - self.print_def_path(did.to_def_id(), args)?; - } else { - let span = self.tcx().def_span(did); - // This may end up in stderr diagnostics but it may also be emitted - // into MIR. Hence we use the remapped path if available - let loc = if with_forced_trimmed_paths() { - self.tcx().sess.source_map().span_to_short_string( - span, - RemapPathScopeComponents::DIAGNOSTICS, - ) - } else { - self.tcx().sess.source_map().span_to_diagnostic_string(span) - }; - write!(self, "@{loc}")?; - } - } else { - write!(self, "@")?; - self.print_def_path(did, args)?; - } + }; + self.pretty_print_closure_inner(did, args)?; } else { self.print_def_path(did, args)?; write!(self, " closure_kind_ty=")?; diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 92e8f5eefadb2..c5757f36b2e6a 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -7,7 +7,6 @@ use ast::mut_visit::{self, MutVisitor}; use ast::token::IdentIsRaw; use ast::{CoroutineKind, ForLoopKind, GenBlockKind, MatchKind, Pat, Path, PathSegment, Recovered}; use rustc_ast::token::{self, Delimiter, InvisibleOrigin, MetaVarKind, Token, TokenKind}; -use rustc_ast::tokenstream::TokenTree; use rustc_ast::util::case::Case; use rustc_ast::util::classify; use rustc_ast::util::parser::{AssocOp, ExprPrecedence, Fixity, prec_let_scrutinee_needs_par}; @@ -1276,13 +1275,12 @@ impl<'a> Parser<'a> { None }; let open_paren = self.token.span; - let call_depth = self.token_cursor.stack.len(); + let call_depth = self.token_cursor.depth(); let seq = match self.parse_expr_paren_seq() { Ok(args) => Ok(self.mk_expr(lo.to(self.prev_token.span), self.mk_call(fun, args))), Err(err) - if self.is_expected_raw_ref_mut() - && self.token_cursor.stack.len() == call_depth => + if self.is_expected_raw_ref_mut() && self.token_cursor.depth() == call_depth => { let guar = err.emit(); // Preserve the call expression so later passes can still diagnose the callee, @@ -2510,8 +2508,7 @@ impl<'a> Parser<'a> { } if self.token == TokenKind::Semi - && let Some(last) = self.token_cursor.stack.last() - && let Some(TokenTree::Delimited(_, _, Delimiter::Parenthesis, _)) = last.curr() + && let Some((Delimiter::Parenthesis, _)) = self.token_cursor.parent_delim_and_span() && self.may_recover() { // It is likely that the closure body is a block but where the diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 192cd7668f518..49e786d7d0683 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -962,7 +962,9 @@ impl<'a> Parser<'a> { self.recover_vcs_conflict_marker(); match parse_item(self) { Ok(None) => { - let mut is_unnecessary_semicolon = !items.is_empty() + let mut is_unnecessary_semicolon = (self.token == token::Semi + && self.prev_token == token::Semi) + || !items.is_empty() // When the close delim is `)` in a case like the following, `token.kind` // is expected to be `token::CloseParen`, but the actual `token.kind` is // `token::CloseBrace`. This is because the `token.kind` of the close delim @@ -1011,7 +1013,7 @@ impl<'a> Parser<'a> { .span_label(self.prev_token.span, "item list ends here"); } if is_unnecessary_semicolon { - err.span_suggestion( + err.span_suggestion_verbose( semicolon_span, "consider removing this semicolon", "", diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 09ac1acb74f51..5ef0fb04cd81f 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -29,8 +29,7 @@ use rustc_ast::token::{ self, IdentIsRaw, InvisibleOrigin, MetaVarKind, NtExprKind, NtPatKind, Token, TokenKind, }; use rustc_ast::tokenstream::{ - ParserRange, ParserReplacement, Spacing, TokenCursor, TokenStream, TokenTree, TokenTreeCursor, - WithTokens, + ParserRange, ParserReplacement, Spacing, TokenCursor, TokenStream, TokenTree, WithTokens, }; use rustc_ast::util::case::Case; use rustc_ast::util::classify; @@ -346,7 +345,7 @@ impl<'a> Parser<'a> { ) -> Self { let mut parser = Parser { psess, - token_cursor: TokenCursor { curr: TokenTreeCursor::new(stream), stack: Vec::new() }, + token_cursor: TokenCursor::new(stream), subparser_name, capture_state: CaptureState { capturing: Capturing::No, @@ -502,10 +501,8 @@ impl<'a> Parser<'a> { // Primarily used when `self.token` matches `OpenInvisible(_))`, to look // ahead through the current metavar expansion. fn check_noexpect_past_close_delim(&self, tok: &TokenKind) -> bool { - let mut tree_cursor = self.token_cursor.stack.last().unwrap().clone(); - tree_cursor.bump(); matches!( - tree_cursor.curr(), + self.token_cursor.look_ahead_past_close_delim(), Some(TokenTree::Token(token::Token { kind, .. }, _)) if kind == tok ) } @@ -1157,9 +1154,8 @@ impl<'a> Parser<'a> { // Typically around 98% of the `dist > 0` cases have `dist == 1`, so we // have a fast special case for that. if dist == 1 { - // The index is zero because the tree cursor's index always points - // to the next token to be gotten. - match self.token_cursor.curr.curr() { + // `look_ahead(0)` returns the *next* token. + match self.token_cursor.look_ahead(0) { Some(tree) => { // Indexing stayed within the current token tree. match tree { @@ -1174,8 +1170,7 @@ impl<'a> Parser<'a> { None => { // The tree cursor lookahead went (one) past the end of the // current token tree. Try to return a close delimiter. - if let Some(last) = self.token_cursor.stack.last() - && let Some(&TokenTree::Delimited(span, _, delim, _)) = last.curr() + if let Some((delim, span)) = self.token_cursor.parent_delim_and_span() && !delim.skip() { // We are not in the outermost token stream, so we have @@ -1203,7 +1198,7 @@ impl<'a> Parser<'a> { looker(&token) } - /// Like `lookahead`, but skips over token trees rather than tokens. Useful + /// Like `look_ahead`, but skips over token trees rather than tokens. Useful /// when looking past possible metavariable pasting sites. pub fn tree_look_ahead( &self, @@ -1211,7 +1206,7 @@ impl<'a> Parser<'a> { looker: impl FnOnce(&TokenTree) -> R, ) -> Option { assert_ne!(dist, 0); - self.token_cursor.curr.look_ahead(dist - 1).map(looker) + self.token_cursor.look_ahead(dist - 1).map(looker) } /// Returns whether any of the given keywords are `dist` tokens ahead of the current one. @@ -1408,7 +1403,7 @@ impl<'a> Parser<'a> { if self.token.kind.open_delim().is_some() { // Clone the `TokenTree::Delimited` that we are currently // within. That's what we are going to return. - let tree = self.token_cursor.stack.last().unwrap().curr().unwrap().clone(); + let tree = self.token_cursor.clone_enclosing_delim(); debug_assert_matches!(tree, TokenTree::Delimited(..)); // Advance the token cursor through the entire delimited @@ -1416,22 +1411,22 @@ impl<'a> Parser<'a> { // delimited sequence, i.e. at depth `d`. After getting the // matching `CloseDelim` we are *after* the delimited sequence, // i.e. at depth `d - 1`. - let target_depth = self.token_cursor.stack.len() - 1; + let target_depth = self.token_cursor.depth() - 1; if let Capturing::No = self.capture_state.capturing { // We are not capturing tokens, so skip to the end of the // delimited sequence. This is a perf win when dealing with // declarative macros that pass large `tt` fragments through // multiple rules, as seen in the uom-0.37.0 crate. - self.token_cursor.curr.bump_to_end(); + self.token_cursor.bump_to_end(); self.bump(); - debug_assert_eq!(self.token_cursor.stack.len(), target_depth); + debug_assert_eq!(self.token_cursor.depth(), target_depth); } else { loop { // Advance one token at a time, so `TokenCursor::next()` // can capture these tokens if necessary. self.bump(); - if self.token_cursor.stack.len() == target_depth { + if self.token_cursor.depth() == target_depth { break; } } diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 502c39255e284..032cbcbc1e794 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -201,9 +201,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { AttributeKind::RustcDumpObjectLifetimeDefaults => { self.check_dump_object_lifetime_defaults(hir_id); } - &AttributeKind::RustcPubTransparent(attr_span) => { - self.check_rustc_pub_transparent(attr_span, span, attrs) - } AttributeKind::Naked(..) => self.check_naked(hir_id, target), AttributeKind::TrackCaller(attr_span) => { self.check_track_caller(hir_id, *attr_span, attrs, target) @@ -381,6 +378,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { AttributeKind::RustcPassIndirectlyInNonRusticAbis(..) => (), AttributeKind::RustcPreserveUbChecks => (), AttributeKind::RustcProcMacroDecls => (), + AttributeKind::RustcPubTransparent(..) => (), AttributeKind::RustcReallocator => (), AttributeKind::RustcRegions => (), AttributeKind::RustcReservationImpl(..) => (), @@ -1577,14 +1575,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { } } - fn check_rustc_pub_transparent(&self, attr_span: Span, span: Span, attrs: &[Attribute]) { - if !find_attr!(attrs, Repr { reprs, .. } => reprs.iter().any(|(r, _)| r == &ReprAttr::ReprTransparent)) - .unwrap_or(false) - { - self.dcx().emit_err(diagnostics::RustcPubTransparent { span, attr_span }); - } - } - fn check_rustc_force_inline(&self, hir_id: HirId, attrs: &[Attribute], target: Target) { if let (Target::Closure, None) = ( target, diff --git a/compiler/rustc_passes/src/diagnostics.rs b/compiler/rustc_passes/src/diagnostics.rs index b692c6d5a6826..bd58ea7142e5b 100644 --- a/compiler/rustc_passes/src/diagnostics.rs +++ b/compiler/rustc_passes/src/diagnostics.rs @@ -242,15 +242,6 @@ pub(crate) struct RustcAllowConstFnUnstable { pub span: Span, } -#[derive(Diagnostic)] -#[diag("attribute should be applied to `#[repr(transparent)]` types")] -pub(crate) struct RustcPubTransparent { - #[primary_span] - pub attr_span: Span, - #[label("not a `#[repr(transparent)]` type")] - pub span: Span, -} - #[derive(Diagnostic)] #[diag("attribute cannot be applied to a `async`, `gen` or `async gen` function")] pub(crate) struct RustcForceInlineCoro { diff --git a/compiler/rustc_public/src/compiler_interface.rs b/compiler/rustc_public/src/compiler_interface.rs index b4d4205e6fa01..89ef152e70f51 100644 --- a/compiler/rustc_public/src/compiler_interface.rs +++ b/compiler/rustc_public/src/compiler_interface.rs @@ -18,7 +18,7 @@ use crate::mir::{BinOp, Body, Place, UnOp}; use crate::target::{MachineInfo, MachineSize}; use crate::ty::{ AdtDef, AdtKind, Allocation, AssocItem, Asyncness, ClosureDef, ClosureKind, Constness, - CoroutineDef, Discr, FieldDef, FnDef, ForeignDef, ForeignItemKind, ForeignModule, + CoroutineDef, Discr, FieldDef, FloatTy, FnDef, ForeignDef, ForeignItemKind, ForeignModule, ForeignModuleDef, GenericArgs, GenericPredicates, Generics, ImplDef, ImplTrait, IntrinsicDef, LineInfo, MirConst, PolyFnSig, RigidTy, Span, TraitDecl, TraitDef, TraitRef, Ty, TyConst, TyConstId, TyKind, UintTy, VariantDef, VariantIdx, VtblEntry, @@ -514,7 +514,7 @@ impl<'tcx> CompilerInterface<'tcx> { self.with_cx(|tables, cx| cx.new_const_bool(value).stable(tables, cx)) } - /// Create a new constant that represents the given value. + /// Create a new integer constant that represents the given value. pub(crate) fn try_new_const_uint( &self, value: u128, @@ -526,6 +526,22 @@ impl<'tcx> CompilerInterface<'tcx> { }) } + /// Create a new float constant that represents the given value. + /// The value is the binary representation of the float constant. + /// Example: `try_new_const_float(2.5_f32.to_bits() as u128, FloatTy::F32)`. + pub(crate) fn try_new_const_float( + &self, + value: u128, + float_ty: FloatTy, + ) -> Result { + let mut tables = self.tables.borrow_mut(); + let cx = &*self.cx.borrow(); + let ty = cx.new_rigid_ty(RigidTy::Float(float_ty).internal(&mut *tables, cx.tcx)); + // We use `try_new_const_uint` here since it is capable of constructing all scalars in the mir + // that are not pointer. + cx.try_new_const_uint(value, ty).map(|cnst| cnst.stable(&mut *tables, cx)) + } + pub(crate) fn try_new_ty_const_uint( &self, value: u128, diff --git a/compiler/rustc_public/src/ty.rs b/compiler/rustc_public/src/ty.rs index aae1bdece2fea..ece87c4e1c929 100644 --- a/compiler/rustc_public/src/ty.rs +++ b/compiler/rustc_public/src/ty.rs @@ -212,6 +212,13 @@ impl MirConst { pub fn try_from_uint(value: u128, uint_ty: UintTy) -> Result { with(|cx| cx.try_new_const_uint(value, uint_ty)) } + + /// Build a new constant that represents the given floating point number. + /// The value is the binary representation of the float constant. + /// Example: `try_from_float(2.5_f32.to_bits() as u128, FloatTy::F32)`. + pub fn try_from_float(value: u128, float_ty: FloatTy) -> Result { + with(|cx| cx.try_new_const_float(value, float_ty)) + } } #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index ae8e9e83f5187..5260f724385f8 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -383,6 +383,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { span: Span, source: PathSource<'_, 'ast, 'ra>, res: Option, + could_be_expr: bool, ) -> BaseError { // Make the base error. let mut expected = source.descr_expected(); @@ -400,28 +401,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { } _ => None, }, - could_be_expr: match res { - Res::Def(DefKind::Fn, _) => { - // Verify whether this is a fn call or an Fn used as a type. - self.r - .tcx - .sess - .source_map() - .span_to_snippet(span) - .is_ok_and(|snippet| snippet.ends_with(')')) - } - Res::Def( - DefKind::Ctor(..) - | DefKind::AssocFn - | DefKind::Const { .. } - | DefKind::AssocConst { .. }, - _, - ) - | Res::SelfCtor(_) - | Res::PrimTy(_) - | Res::Local(_) => true, - _ => false, - }, + could_be_expr, suggestion: None, module: None, } @@ -571,13 +551,37 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { fallback_label, span: item_span, span_label, - could_be_expr: false, + could_be_expr, suggestion, module, } } } + fn could_be_expr(&self, res: Res, span: Span) -> bool { + match res { + // Verify whether this is a fn call or an Fn used as a type. + Res::Def(DefKind::Fn, _) => self + .r + .tcx + .sess + .source_map() + .span_to_snippet(span) + .is_ok_and(|snippet| snippet.ends_with(')')), + Res::Def( + DefKind::Ctor(..) + | DefKind::AssocFn + | DefKind::Const { .. } + | DefKind::AssocConst { .. }, + _, + ) + | Res::SelfCtor(_) + | Res::PrimTy(_) + | Res::Local(_) => true, + _ => false, + } + } + /// Try to suggest for a module path that cannot be resolved. /// Such as `fmt::Debug` where `fmt` is not resolved without importing, /// here we search with `lookup_import_candidates` for a module named `fmt` @@ -636,12 +640,29 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { qself: Option<&QSelf>, ) -> (Diag<'tcx>, Vec) { debug!(?res, ?source); - let base_error = self.make_base_error(path, span, source, res); + let cross_namespace_res = res.filter(|res| !res.matches_ns(source.namespace())); + let could_be_expr = res.is_some_and(|res| self.could_be_expr(res, span)); + let base_error = self.make_base_error( + path, + span, + source, + if cross_namespace_res.is_some() { None } else { res }, + could_be_expr, + ); let code = source.error_code(res.is_some()); let mut err = self.r.dcx().struct_span_err(base_error.span, base_error.msg.clone()); err.code(code); + if let Some(res) = cross_namespace_res { + err.note(format!( + "{} {} named `{}` exists in another namespace", + res.article(), + res.descr(), + Segment::names_to_string(path), + )); + } + // Try to get the span of the identifier within the path's syntax context // (if that's different). if let Some(within_macro_span) = diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 7ea7274cafd8b..5b71c0435185a 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -13,6 +13,7 @@ use rustc_feature::UnstableFeatures; use rustc_hashes::Hash64; use rustc_hir::attrs::CollapseMacroDebuginfo; use rustc_macros::{BlobDecodable, Encodable}; +use rustc_span::edit_distance::edit_distance; use rustc_span::edition::Edition; use rustc_span::{RealFileName, RemapPathScopeComponents, SourceFileHashAlgorithm}; use rustc_target::spec::{ @@ -777,7 +778,27 @@ fn build_options( collected_options.mitigations.reset_mitigation(*mitigation, index); } } - None => early_dcx.early_fatal(format!("unknown {outputname} option: `{key}`")), + None => { + let mut error = + early_dcx.early_struct_fatal(format!("unknown {outputname} option: `{key}`")); + let max_dist = option_to_lookup.chars().count().max(3) / 3; + if let Some(option) = descrs + .iter() + .filter(|option| option.removed.is_none()) + .filter_map(|option| { + edit_distance(&option_to_lookup, option.name, max_dist) + .map(|dist| (dist, option)) + }) + .min_by_key(|(dist, _)| *dist) + .map(|(_, option)| option) + { + let name = option.name.replace('_', "-"); + let value = + if option.type_desc == desc::parse_no_value { "" } else { "=" }; + error.help(format!("you might have meant to use `-{prefix} {name}{value}`")); + } + error.emit() + } } } op diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index 7a681a0b64e9d..e0edc76682a3b 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -1651,49 +1651,15 @@ fn confirm_closure_candidate<'cx, 'tcx>( // I didn't see a good way to unify those. ty::CoroutineClosure(def_id, args) => { let args = args.as_coroutine_closure(); - let kind_ty = args.kind_ty(); Unnormalized::new_wip(args.coroutine_closure_sig().map_bound(|sig| { - // If we know the kind and upvars, use that directly. - // Otherwise, defer to `AsyncFnKindHelper::Upvars` to delay - // the projection, like the `AsyncFn*` traits do. - let output_ty = if let Some(_) = kind_ty.to_opt_closure_kind() - // Fall back to projection if upvars aren't constrained - && !args.tupled_upvars_ty().is_ty_var() - { - sig.to_coroutine_given_kind_and_upvars( - tcx, - args.parent_args(), - tcx.coroutine_for_closure(def_id), - ty::ClosureKind::FnOnce, - tcx.lifetimes.re_static, - args.tupled_upvars_ty(), - args.coroutine_captures_by_ref_ty(), - ) - } else { - let upvars_projection_def_id = - tcx.require_lang_item(LangItem::AsyncFnKindUpvars, obligation.cause.span); - let tupled_upvars_ty = Ty::new_projection( - tcx, - ty::IsRigid::No, - upvars_projection_def_id, - [ - ty::GenericArg::from(kind_ty), - Ty::from_closure_kind(tcx, ty::ClosureKind::FnOnce).into(), - tcx.lifetimes.re_static.into(), - sig.tupled_inputs_ty.into(), - args.tupled_upvars_ty().into(), - args.coroutine_captures_by_ref_ty().into(), - ], - ); - sig.to_coroutine( - tcx, - args.parent_args(), - Ty::from_closure_kind(tcx, ty::ClosureKind::FnOnce), - tcx.coroutine_for_closure(def_id), - tupled_upvars_ty, - ) - }; - + let output_ty = coroutine_closure_output_coroutine( + tcx, + obligation, + ty::ClosureKind::FnOnce, + tcx.lifetimes.re_static, + def_id, + args, + ); tcx.mk_fn_sig([sig.tupled_inputs_ty], output_ty, sig.fn_sig_kind) })) } @@ -1770,60 +1736,12 @@ fn confirm_async_closure_candidate<'cx, 'tcx>( let poly_cache_entry = match *self_ty.kind() { ty::CoroutineClosure(def_id, args) => { let args = args.as_coroutine_closure(); - let kind_ty = args.kind_ty(); let sig = args.coroutine_closure_sig().skip_binder(); let term = match item_name { - sym::CallOnceFuture | sym::CallRefFuture => { - if let Some(closure_kind) = kind_ty.to_opt_closure_kind() - // Fall back to projection if upvars aren't constrained - && !args.tupled_upvars_ty().is_ty_var() - { - if !closure_kind.extends(goal_kind) { - bug!("we should not be confirming if the closure kind is not met"); - } - sig.to_coroutine_given_kind_and_upvars( - tcx, - args.parent_args(), - tcx.coroutine_for_closure(def_id), - goal_kind, - env_region, - args.tupled_upvars_ty(), - args.coroutine_captures_by_ref_ty(), - ) - } else { - let upvars_projection_def_id = tcx - .require_lang_item(LangItem::AsyncFnKindUpvars, obligation.cause.span); - // When we don't know the closure kind (and therefore also the closure's upvars, - // which are computed at the same time), we must delay the computation of the - // generator's upvars. We do this using the `AsyncFnKindHelper`, which as a trait - // goal functions similarly to the old `ClosureKind` predicate, and ensures that - // the goal kind <= the closure kind. As a projection `AsyncFnKindHelper::Upvars` - // will project to the right upvars for the generator, appending the inputs and - // coroutine upvars respecting the closure kind. - // N.B. No need to register a `AsyncFnKindHelper` goal here, it's already in `nested`. - let tupled_upvars_ty = Ty::new_projection( - tcx, - ty::IsRigid::No, - upvars_projection_def_id, - [ - ty::GenericArg::from(kind_ty), - Ty::from_closure_kind(tcx, goal_kind).into(), - env_region.into(), - sig.tupled_inputs_ty.into(), - args.tupled_upvars_ty().into(), - args.coroutine_captures_by_ref_ty().into(), - ], - ); - sig.to_coroutine( - tcx, - args.parent_args(), - Ty::from_closure_kind(tcx, goal_kind), - tcx.coroutine_for_closure(def_id), - tupled_upvars_ty, - ) - } - } + sym::CallOnceFuture | sym::CallRefFuture => coroutine_closure_output_coroutine( + tcx, obligation, goal_kind, env_region, def_id, args, + ), sym::Output => sig.return_ty, name => bug!("no such associated type: {name}"), }; @@ -1912,6 +1830,72 @@ fn confirm_async_closure_candidate<'cx, 'tcx>( .with_addl_obligations(nested) } +/// Given a `CoroutineClosure(def_id, args)`, interpret it as a closure, +/// and return its output type for the given `goal_kind` and `env_region`. +fn coroutine_closure_output_coroutine<'tcx>( + tcx: TyCtxt<'tcx>, + obligation: &ProjectionTermObligation<'tcx>, + goal_kind: ty::ClosureKind, + env_region: ty::Region<'tcx>, + def_id: DefId, + args: ty::CoroutineClosureArgs>, +) -> Ty<'tcx> { + let kind_ty = args.kind_ty(); + let sig = args.coroutine_closure_sig().skip_binder(); + + // If we know the kind and upvars, use that directly. + // Otherwise, defer to `AsyncFnKindHelper::Upvars` to delay + // the projection, like the `AsyncFn*` traits do. + if let Some(closure_kind) = kind_ty.to_opt_closure_kind() + // Fall back to projection if upvars aren't constrained + && !args.tupled_upvars_ty().is_ty_var() + { + if !closure_kind.extends(goal_kind) { + bug!("we should not be confirming if the closure kind is not met"); + } + sig.to_coroutine_given_kind_and_upvars( + tcx, + args.parent_args(), + tcx.coroutine_for_closure(def_id), + goal_kind, + env_region, + args.tupled_upvars_ty(), + args.coroutine_captures_by_ref_ty(), + ) + } else { + let upvars_projection_def_id = + tcx.require_lang_item(LangItem::AsyncFnKindUpvars, obligation.cause.span); + // When we don't know the closure kind (and therefore also the closure's upvars, + // which are computed at the same time), we must delay the computation of the + // generator's upvars. We do this using the `AsyncFnKindHelper`, which as a trait + // goal functions similarly to the old `ClosureKind` predicate, and ensures that + // the goal kind <= the closure kind. As a projection `AsyncFnKindHelper::Upvars` + // will project to the right upvars for the generator, appending the inputs and + // coroutine upvars respecting the closure kind. + // N.B. No need to register a `AsyncFnKindHelper` goal here, it's already in `nested`. + let tupled_upvars_ty = Ty::new_projection( + tcx, + ty::IsRigid::No, + upvars_projection_def_id, + [ + ty::GenericArg::from(kind_ty), + Ty::from_closure_kind(tcx, goal_kind).into(), + env_region.into(), + sig.tupled_inputs_ty.into(), + args.tupled_upvars_ty().into(), + args.coroutine_captures_by_ref_ty().into(), + ], + ); + sig.to_coroutine( + tcx, + args.parent_args(), + Ty::from_closure_kind(tcx, goal_kind), + tcx.coroutine_for_closure(def_id), + tupled_upvars_ty, + ) + } +} + fn confirm_async_fn_kind_helper_candidate<'cx, 'tcx>( selcx: &mut SelectionContext<'cx, 'tcx>, obligation: &ProjectionTermObligation<'tcx>, diff --git a/library/std/src/io/buffered/bufreader.rs b/library/alloc/src/io/buffered/bufreader.rs similarity index 93% rename from library/std/src/io/buffered/bufreader.rs rename to library/alloc/src/io/buffered/bufreader.rs index 8d122c8e76e5f..e8b3302e29b98 100644 --- a/library/std/src/io/buffered/bufreader.rs +++ b/library/alloc/src/io/buffered/bufreader.rs @@ -7,6 +7,8 @@ use crate::io::{ self, BorrowedCursor, BufRead, DEFAULT_BUF_SIZE, IoSliceMut, Read, Seek, SeekFrom, SizeHint, SpecReadByte, uninlined_slow_read_byte, }; +use crate::string::String; +use crate::vec::Vec; /// The `BufReader` struct adds buffering to any reader. /// @@ -27,8 +29,9 @@ use crate::io::{ /// unwrapping the `BufReader` with [`BufReader::into_inner`] can also cause /// data loss. /// -/// [`TcpStream::read`]: crate::net::TcpStream::read -/// [`TcpStream`]: crate::net::TcpStream +// FIXME(#74481): Hard-links required to link from `alloc` to `std` +/// [`TcpStream::read`]: ../../std/net/struct.TcpStream.html#method.read +/// [`TcpStream`]: ../../std/net/struct.TcpStream.html /// /// # Examples /// @@ -70,17 +73,21 @@ impl BufReader { /// Ok(()) /// } /// ``` + #[cfg(not(no_global_oom_handling))] #[stable(feature = "rust1", since = "1.0.0")] pub fn new(inner: R) -> BufReader { BufReader::with_capacity(DEFAULT_BUF_SIZE, inner) } - pub(crate) fn try_new_buffer() -> io::Result { - Buffer::try_with_capacity(DEFAULT_BUF_SIZE) - } - - pub(crate) fn with_buffer(inner: R, buf: Buffer) -> Self { - Self { inner, buf } + /// Attempts to allocate an internal buffer, _then_ calls the provided function + /// to retrieve the inner reader `R`. + #[doc(hidden)] + #[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")] + #[inline] + pub fn try_new_with(f: impl FnOnce() -> io::Result) -> io::Result { + let buf = Buffer::try_with_capacity(DEFAULT_BUF_SIZE)?; + let inner = f()?; + Ok(Self { inner, buf }) } /// Creates a new `BufReader` with the specified buffer capacity. @@ -99,6 +106,7 @@ impl BufReader { /// Ok(()) /// } /// ``` + #[cfg(not(no_global_oom_handling))] #[stable(feature = "rust1", since = "1.0.0")] pub fn with_capacity(capacity: usize, inner: R) -> BufReader { BufReader { inner, buf: Buffer::with_capacity(capacity) } @@ -280,14 +288,17 @@ impl BufReader { /// Invalidates all data in the internal buffer. #[inline] - pub(in crate::io) fn discard_buffer(&mut self) { + #[doc(hidden)] + #[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")] + pub fn discard_buffer(&mut self) { self.buf.discard_buffer() } } // This is only used by a test which asserts that the initialization-tracking is correct. -#[cfg(test)] impl BufReader { + #[doc(hidden)] + #[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")] #[allow(missing_docs)] pub fn initialized(&self) -> bool { self.buf.initialized() @@ -413,7 +424,16 @@ impl Read for BufReader { fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { let inner_buf = self.buffer(); buf.try_reserve(inner_buf.len())?; - buf.extend_from_slice(inner_buf); + + cfg_select! { + no_global_oom_handling => { + buf.try_extend_from_slice_of_bytes(inner_buf)?; + } + _ => { + buf.extend_from_slice(inner_buf); + } + } + let nread = inner_buf.len(); self.discard_buffer(); Ok(nread + self.inner.read_to_end(buf)?) @@ -445,7 +465,16 @@ impl Read for BufReader { let mut bytes = Vec::new(); self.read_to_end(&mut bytes)?; let string = crate::str::from_utf8(&bytes).map_err(|_| io::Error::INVALID_UTF8)?; - *buf += string; + + cfg_select! { + no_global_oom_handling => { + buf.try_push_str(string)?; + } + _ => { + buf.push_str(string); + } + } + Ok(string.len()) } } diff --git a/library/std/src/io/buffered/bufreader/buffer.rs b/library/alloc/src/io/buffered/bufreader/buffer.rs similarity index 83% rename from library/std/src/io/buffered/bufreader/buffer.rs rename to library/alloc/src/io/buffered/bufreader/buffer.rs index f2efcc5ab8601..316889d93f576 100644 --- a/library/std/src/io/buffered/bufreader/buffer.rs +++ b/library/alloc/src/io/buffered/bufreader/buffer.rs @@ -9,11 +9,13 @@ //! that user code which wants to do reads from a `BufReader` via `buffer` + `consume` can do so //! without encountering any runtime bounds checks. -use crate::cmp; +use core::cmp; +use core::mem::MaybeUninit; + +use crate::boxed::Box; use crate::io::{self, BorrowedBuf, ErrorKind, Read}; -use crate::mem::MaybeUninit; -pub struct Buffer { +pub(super) struct Buffer { // The buffer. buf: Box<[MaybeUninit]>, // The current seek offset into `buf`, must always be <= `filled`. @@ -29,14 +31,15 @@ pub struct Buffer { } impl Buffer { + #[cfg(not(no_global_oom_handling))] #[inline] - pub fn with_capacity(capacity: usize) -> Self { + pub(super) fn with_capacity(capacity: usize) -> Self { let buf = Box::new_uninit_slice(capacity); Self { buf, pos: 0, filled: 0, initialized: false } } #[inline] - pub fn try_with_capacity(capacity: usize) -> io::Result { + pub(super) fn try_with_capacity(capacity: usize) -> io::Result { match Box::try_new_uninit_slice(capacity) { Ok(buf) => Ok(Self { buf, pos: 0, filled: 0, initialized: false }), Err(_) => { @@ -46,48 +49,47 @@ impl Buffer { } #[inline] - pub fn buffer(&self) -> &[u8] { + pub(super) fn buffer(&self) -> &[u8] { // SAFETY: self.pos and self.filled are valid, and self.filled >= self.pos, and // that region is initialized because those are all invariants of this type. unsafe { self.buf.get_unchecked(self.pos..self.filled).assume_init_ref() } } #[inline] - pub fn capacity(&self) -> usize { + pub(super) fn capacity(&self) -> usize { self.buf.len() } #[inline] - pub fn filled(&self) -> usize { + pub(super) fn filled(&self) -> usize { self.filled } #[inline] - pub fn pos(&self) -> usize { + pub(super) fn pos(&self) -> usize { self.pos } // This is only used by a test which asserts that the initialization-tracking is correct. - #[cfg(test)] - pub fn initialized(&self) -> bool { + pub(super) fn initialized(&self) -> bool { self.initialized } #[inline] - pub fn discard_buffer(&mut self) { + pub(super) fn discard_buffer(&mut self) { self.pos = 0; self.filled = 0; } #[inline] - pub fn consume(&mut self, amt: usize) { + pub(super) fn consume(&mut self, amt: usize) { self.pos = cmp::min(self.pos + amt, self.filled); } /// If there are `amt` bytes available in the buffer, pass a slice containing those bytes to /// `visitor` and return true. If there are not enough bytes available, return false. #[inline] - pub fn consume_with(&mut self, amt: usize, mut visitor: V) -> bool + pub(super) fn consume_with(&mut self, amt: usize, mut visitor: V) -> bool where V: FnMut(&[u8]), { @@ -102,12 +104,12 @@ impl Buffer { } #[inline] - pub fn unconsume(&mut self, amt: usize) { + pub(super) fn unconsume(&mut self, amt: usize) { self.pos = self.pos.saturating_sub(amt); } /// Read more bytes into the buffer without discarding any of its contents - pub fn read_more(&mut self, mut reader: impl Read) -> io::Result { + pub(super) fn read_more(&mut self, mut reader: impl Read) -> io::Result { let mut buf = BorrowedBuf::from(&mut self.buf[self.filled..]); if self.initialized { @@ -124,14 +126,14 @@ impl Buffer { } /// Remove bytes that have already been read from the buffer. - pub fn backshift(&mut self) { + pub(super) fn backshift(&mut self) { self.buf.copy_within(self.pos..self.filled, 0); self.filled -= self.pos; self.pos = 0; } #[inline] - pub fn fill_buf(&mut self, mut reader: impl Read) -> io::Result<&[u8]> { + pub(super) fn fill_buf(&mut self, mut reader: impl Read) -> io::Result<&[u8]> { // If we've reached the end of our internal buffer then we need to fetch // some more data from the reader. // Branch using `>=` instead of the more correct `==` diff --git a/library/std/src/io/buffered/bufwriter.rs b/library/alloc/src/io/buffered/bufwriter.rs similarity index 95% rename from library/std/src/io/buffered/bufwriter.rs rename to library/alloc/src/io/buffered/bufwriter.rs index 1a5cc911c0e43..4847c1605ac79 100644 --- a/library/std/src/io/buffered/bufwriter.rs +++ b/library/alloc/src/io/buffered/bufwriter.rs @@ -1,8 +1,10 @@ +use core::mem::{self, ManuallyDrop}; +use core::{error, fmt, ptr}; + use crate::io::{ self, DEFAULT_BUF_SIZE, ErrorKind, IntoInnerError, IoSlice, Seek, SeekFrom, Write, }; -use crate::mem::{self, ManuallyDrop}; -use crate::{error, fmt, ptr}; +use crate::vec::Vec; /// Wraps a writer and buffers its output. /// @@ -60,8 +62,9 @@ use crate::{error, fmt, ptr}; /// together by the buffer and will all be written out in one system call when /// the `stream` is flushed. /// -/// [`TcpStream::write`]: crate::net::TcpStream::write -/// [`TcpStream`]: crate::net::TcpStream +// FIXME(#74481): Hard-links required to link from `alloc` to `std` +/// [`TcpStream::write`]: ../../std/net/struct.TcpStream.html#method.write +/// [`TcpStream`]: ../../std/net/struct.TcpStream.html /// [`flush`]: BufWriter::flush #[stable(feature = "rust1", since = "1.0.0")] pub struct BufWriter { @@ -87,21 +90,26 @@ impl BufWriter { /// use std::io::BufWriter; /// use std::net::TcpStream; /// + /// # #[expect(unused_mut)] /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); /// ``` + #[cfg(not(no_global_oom_handling))] #[stable(feature = "rust1", since = "1.0.0")] pub fn new(inner: W) -> BufWriter { BufWriter::with_capacity(DEFAULT_BUF_SIZE, inner) } - pub(crate) fn try_new_buffer() -> io::Result> { - Vec::try_with_capacity(DEFAULT_BUF_SIZE).map_err(|_| { + /// Attempts to allocate an internal buffer, _then_ calls the provided function + /// to retrieve the inner writer `W`. + #[doc(hidden)] + #[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")] + #[inline] + pub fn try_new_with(f: impl FnOnce() -> io::Result) -> io::Result { + let buf = Vec::try_with_capacity(DEFAULT_BUF_SIZE).map_err(|_| { io::const_error!(ErrorKind::OutOfMemory, "failed to allocate write buffer") - }) - } - - pub(crate) fn with_buffer(inner: W, buf: Vec) -> Self { - Self { inner, buf, panicked: false } + })?; + let inner = f()?; + Ok(Self { inner, buf, panicked: false }) } /// Creates a new `BufWriter` with at least the specified buffer capacity. @@ -115,8 +123,10 @@ impl BufWriter { /// use std::net::TcpStream; /// /// let stream = TcpStream::connect("127.0.0.1:34254").unwrap(); + /// # #[expect(unused_mut)] /// let mut buffer = BufWriter::with_capacity(100, stream); /// ``` + #[cfg(not(no_global_oom_handling))] #[stable(feature = "rust1", since = "1.0.0")] pub fn with_capacity(capacity: usize, inner: W) -> BufWriter { BufWriter { inner, buf: Vec::with_capacity(capacity), panicked: false } @@ -136,6 +146,7 @@ impl BufWriter { /// use std::io::BufWriter; /// use std::net::TcpStream; /// + /// # #[expect(unused_mut)] /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); /// /// // unwrap the TcpStream and flush the buffer @@ -192,7 +203,9 @@ impl BufWriter { /// "successfully written" (by returning nonzero success values from /// `write`), any 0-length writes from `inner` must be reported as i/o /// errors from this method. - pub(in crate::io) fn flush_buf(&mut self) -> io::Result<()> { + #[doc(hidden)] + #[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")] + pub fn flush_buf(&mut self) -> io::Result<()> { // SAFETY: `::copy_from` assumes that // this will not de-initialize any elements of `self.buf`'s spare // capacity. @@ -287,6 +300,7 @@ impl BufWriter { /// use std::io::BufWriter; /// use std::net::TcpStream; /// + /// # #[expect(unused_mut)] /// let mut buffer = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); /// /// // we can use reference just like buffer @@ -343,7 +357,9 @@ impl BufWriter { /// That the buffer is a `Vec` is an implementation detail. /// Callers should not modify the capacity as there currently is no public API to do so /// and thus any capacity changes would be unexpected by the user. - pub(in crate::io) fn buffer_mut(&mut self) -> &mut Vec { + #[doc(hidden)] + #[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")] + pub fn buffer_mut(&mut self) -> &mut Vec { &mut self.buf } diff --git a/library/std/src/io/buffered/linewriter.rs b/library/alloc/src/io/buffered/linewriter.rs similarity index 98% rename from library/std/src/io/buffered/linewriter.rs rename to library/alloc/src/io/buffered/linewriter.rs index cc6921b86dd0b..bdb979e931f2e 100644 --- a/library/std/src/io/buffered/linewriter.rs +++ b/library/alloc/src/io/buffered/linewriter.rs @@ -84,6 +84,7 @@ impl LineWriter { /// Ok(()) /// } /// ``` + #[cfg(not(no_global_oom_handling))] #[stable(feature = "rust1", since = "1.0.0")] pub fn new(inner: W) -> LineWriter { // Lines typically aren't that long, don't use a giant buffer @@ -105,6 +106,7 @@ impl LineWriter { /// Ok(()) /// } /// ``` + #[cfg(not(no_global_oom_handling))] #[stable(feature = "rust1", since = "1.0.0")] pub fn with_capacity(capacity: usize, inner: W) -> LineWriter { LineWriter { inner: BufWriter::with_capacity(capacity, inner) } diff --git a/library/std/src/io/buffered/linewritershim.rs b/library/alloc/src/io/buffered/linewritershim.rs similarity index 99% rename from library/std/src/io/buffered/linewritershim.rs rename to library/alloc/src/io/buffered/linewritershim.rs index fc250e6ab7de9..35f448fc3aa8a 100644 --- a/library/std/src/io/buffered/linewritershim.rs +++ b/library/alloc/src/io/buffered/linewritershim.rs @@ -13,12 +13,12 @@ use crate::io::{self, BufWriter, IoSlice, Write}; /// `BufWriters` to be temporarily given line-buffering logic; this is what /// enables Stdout to be alternately in line-buffered or block-buffered mode. #[derive(Debug)] -pub struct LineWriterShim<'a, W: ?Sized + Write> { +pub(super) struct LineWriterShim<'a, W: ?Sized + Write> { buffer: &'a mut BufWriter, } impl<'a, W: ?Sized + Write> LineWriterShim<'a, W> { - pub fn new(buffer: &'a mut BufWriter) -> Self { + pub(super) fn new(buffer: &'a mut BufWriter) -> Self { Self { buffer } } diff --git a/library/alloc/src/io/buffered/mod.rs b/library/alloc/src/io/buffered/mod.rs new file mode 100644 index 0000000000000..1bddcfb801932 --- /dev/null +++ b/library/alloc/src/io/buffered/mod.rs @@ -0,0 +1,189 @@ +//! Buffering wrappers for I/O traits + +mod bufreader; +mod bufwriter; +mod linewriter; +mod linewritershim; + +use core::{error, fmt}; + +#[stable(feature = "bufwriter_into_parts", since = "1.56.0")] +pub use self::bufwriter::WriterPanicked; +use self::linewritershim::LineWriterShim; +#[stable(feature = "rust1", since = "1.0.0")] +pub use self::{bufreader::BufReader, bufwriter::BufWriter, linewriter::LineWriter}; +use crate::io::Error; + +/// An error returned by [`BufWriter::into_inner`] which combines an error that +/// happened while writing out the buffer, and the buffered writer object +/// which may be used to recover from the condition. +/// +/// # Examples +/// +/// ```no_run +/// use std::io::BufWriter; +/// use std::net::TcpStream; +/// +/// # #[expect(unused_mut)] +/// let mut stream = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); +/// +/// // do stuff with the stream +/// +/// // we want to get our `TcpStream` back, so let's try: +/// +/// let stream = match stream.into_inner() { +/// Ok(s) => s, +/// Err(e) => { +/// // Here, e is an IntoInnerError +/// panic!("An error occurred"); +/// } +/// }; +/// ``` +#[derive(Debug)] +#[stable(feature = "rust1", since = "1.0.0")] +pub struct IntoInnerError(W, Error); + +impl IntoInnerError { + /// Constructs a new IntoInnerError + fn new(writer: W, error: Error) -> Self { + Self(writer, error) + } + + /// Helper to construct a new IntoInnerError; intended to help with + /// adapters that wrap other adapters + fn new_wrapped(self, f: impl FnOnce(W) -> W2) -> IntoInnerError { + let Self(writer, error) = self; + IntoInnerError::new(f(writer), error) + } + + /// Returns the error which caused the call to [`BufWriter::into_inner()`] + /// to fail. + /// + /// This error was returned when attempting to write the internal buffer. + /// + /// # Examples + /// + /// ```no_run + /// use std::io::BufWriter; + /// use std::net::TcpStream; + /// + /// # #[expect(unused_mut)] + /// let mut stream = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// + /// // do stuff with the stream + /// + /// // we want to get our `TcpStream` back, so let's try: + /// + /// let stream = match stream.into_inner() { + /// Ok(s) => s, + /// Err(e) => { + /// // Here, e is an IntoInnerError, let's log the inner error. + /// // + /// // We'll just 'log' to stdout for this example. + /// println!("{}", e.error()); + /// + /// panic!("An unexpected error occurred."); + /// } + /// }; + /// ``` + #[stable(feature = "rust1", since = "1.0.0")] + pub fn error(&self) -> &Error { + &self.1 + } + + /// Returns the buffered writer instance which generated the error. + /// + /// The returned object can be used for error recovery, such as + /// re-inspecting the buffer. + /// + /// # Examples + /// + /// ```no_run + /// use std::io::BufWriter; + /// use std::net::TcpStream; + /// + /// # #[expect(unused_mut)] + /// let mut stream = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); + /// + /// // do stuff with the stream + /// + /// // we want to get our `TcpStream` back, so let's try: + /// + /// let stream = match stream.into_inner() { + /// Ok(s) => s, + /// Err(e) => { + /// // Here, e is an IntoInnerError, let's re-examine the buffer: + /// let buffer = e.into_inner(); + /// + /// // do stuff to try to recover + /// + /// // afterwards, let's just return the stream + /// buffer.into_inner().unwrap() + /// } + /// }; + /// ``` + #[stable(feature = "rust1", since = "1.0.0")] + pub fn into_inner(self) -> W { + self.0 + } + + /// Consumes the [`IntoInnerError`] and returns the error which caused the call to + /// [`BufWriter::into_inner()`] to fail. Unlike `error`, this can be used to + /// obtain ownership of the underlying error. + /// + /// # Example + /// ``` + /// use std::io::{BufWriter, ErrorKind, Write}; + /// + /// let mut not_enough_space = [0u8; 10]; + /// let mut stream = BufWriter::new(not_enough_space.as_mut()); + /// write!(stream, "this cannot be actually written").unwrap(); + /// let into_inner_err = stream.into_inner().expect_err("now we discover it's too small"); + /// let err = into_inner_err.into_error(); + /// assert_eq!(err.kind(), ErrorKind::WriteZero); + /// ``` + #[stable(feature = "io_into_inner_error_parts", since = "1.55.0")] + pub fn into_error(self) -> Error { + self.1 + } + + /// Consumes the [`IntoInnerError`] and returns the error which caused the call to + /// [`BufWriter::into_inner()`] to fail, and the underlying writer. + /// + /// This can be used to simply obtain ownership of the underlying error; it can also be used for + /// advanced error recovery. + /// + /// # Example + /// ``` + /// use std::io::{BufWriter, ErrorKind, Write}; + /// + /// let mut not_enough_space = [0u8; 10]; + /// let mut stream = BufWriter::new(not_enough_space.as_mut()); + /// write!(stream, "this cannot be actually written").unwrap(); + /// let into_inner_err = stream.into_inner().expect_err("now we discover it's too small"); + /// let (err, recovered_writer) = into_inner_err.into_parts(); + /// assert_eq!(err.kind(), ErrorKind::WriteZero); + /// assert_eq!(recovered_writer.buffer(), b"t be actually written"); + /// ``` + #[stable(feature = "io_into_inner_error_parts", since = "1.55.0")] + pub fn into_parts(self) -> (Error, W) { + (self.1, self.0) + } +} + +#[stable(feature = "rust1", since = "1.0.0")] +impl From> for Error { + fn from(iie: IntoInnerError) -> Error { + iie.1 + } +} + +#[stable(feature = "rust1", since = "1.0.0")] +impl error::Error for IntoInnerError {} + +#[stable(feature = "rust1", since = "1.0.0")] +impl fmt::Display for IntoInnerError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + self.error().fmt(f) + } +} diff --git a/library/alloc/src/io/mod.rs b/library/alloc/src/io/mod.rs index ff39cb145a929..ef09d13cc6247 100644 --- a/library/alloc/src/io/mod.rs +++ b/library/alloc/src/io/mod.rs @@ -1,6 +1,7 @@ //! Traits, helpers, and type definitions for core I/O functionality. mod buf_read; +mod buffered; mod cursor; mod error; mod impls; @@ -22,15 +23,18 @@ pub use core::io::{ }; #[doc(hidden)] #[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")] -pub use core::io::{ - IoHandle, OsFunctions, SizeHint, WriteThroughCursor, chain, default_write_vectored, - slice_write, slice_write_all, slice_write_all_vectored, slice_write_vectored, - stream_len_default, take, +pub use core::io::{IoHandle, OsFunctions, default_write_vectored, stream_len_default}; +use core::io::{ + SizeHint, WriteThroughCursor, chain, slice_write, slice_write_all, slice_write_all_vectored, + slice_write_vectored, take, }; +use self::read::{append_to_string, default_read_buf_exact, default_read_exact}; +use self::util::{bytes, lines, split, uninlined_slow_read_byte}; #[unstable(feature = "alloc_io", issue = "154046")] pub use self::{ buf_read::BufRead, + buffered::{BufReader, BufWriter, IntoInnerError, LineWriter, WriterPanicked}, read::{Read, read_to_string}, util::{Bytes, Lines, Split}, }; @@ -38,8 +42,8 @@ pub use self::{ #[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")] pub use self::{ read::{ - DEFAULT_BUF_SIZE, append_to_string, default_read_buf, default_read_buf_exact, - default_read_exact, default_read_to_end, default_read_to_string, default_read_vectored, + DEFAULT_BUF_SIZE, default_read_buf, default_read_to_end, default_read_to_string, + default_read_vectored, }, - util::{SpecReadByte, bytes, lines, split, uninlined_slow_read_byte}, + util::SpecReadByte, }; diff --git a/library/alloc/src/io/read.rs b/library/alloc/src/io/read.rs index c1356811cc58a..c0123c860b453 100644 --- a/library/alloc/src/io/read.rs +++ b/library/alloc/src/io/read.rs @@ -795,9 +795,7 @@ pub const DEFAULT_BUF_SIZE: usize = cfg_select! { /// 2. We're passing a raw buffer to the function `f`, and it is expected that /// the function only *appends* bytes to the buffer. We'll get undefined /// behavior if existing bytes are overwritten to have non-UTF-8 data. -#[doc(hidden)] -#[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")] -pub unsafe fn append_to_string(buf: &mut String, f: F) -> Result +pub(super) unsafe fn append_to_string(buf: &mut String, f: F) -> Result where F: FnOnce(&mut Vec) -> Result, { @@ -988,9 +986,7 @@ where read(buf) } -#[doc(hidden)] -#[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")] -pub fn default_read_exact(this: &mut R, mut buf: &mut [u8]) -> Result<()> { +pub(super) fn default_read_exact(this: &mut R, mut buf: &mut [u8]) -> Result<()> { while !buf.is_empty() { match this.read(buf) { Ok(0) => break, @@ -1015,9 +1011,7 @@ where Ok(()) } -#[doc(hidden)] -#[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")] -pub fn default_read_buf_exact( +pub(super) fn default_read_buf_exact( this: &mut R, mut cursor: BorrowedCursor<'_, u8>, ) -> Result<()> { diff --git a/library/alloc/src/io/util.rs b/library/alloc/src/io/util.rs index 050e018e8568f..9bf5a56dd7157 100644 --- a/library/alloc/src/io/util.rs +++ b/library/alloc/src/io/util.rs @@ -388,15 +388,11 @@ fn inlined_slow_read_byte(reader: &mut R) -> Option> { // Used by `BufReader::spec_read_byte`, for which the `inline(never)` is // important. #[inline(never)] -#[doc(hidden)] -#[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")] -pub fn uninlined_slow_read_byte(reader: &mut R) -> Option> { +pub(super) fn uninlined_slow_read_byte(reader: &mut R) -> Option> { inlined_slow_read_byte(reader) } -#[doc(hidden)] -#[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")] -pub const fn bytes(inner: R) -> Bytes { +pub(super) const fn bytes(inner: R) -> Bytes { Bytes { inner } } @@ -434,9 +430,7 @@ impl Iterator for Split { } } -#[doc(hidden)] -#[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")] -pub const fn split(buf: B, delim: u8) -> Split { +pub(super) const fn split(buf: B, delim: u8) -> Split { Split { buf, delim } } @@ -475,8 +469,6 @@ impl Iterator for Lines { } } -#[doc(hidden)] -#[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")] -pub const fn lines(buf: B) -> Lines { +pub(super) const fn lines(buf: B) -> Lines { Lines { buf } } diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index 3574855e04dc9..388bf4a55e11f 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -604,9 +604,7 @@ impl File { #[unstable(feature = "file_buffered", issue = "130804")] pub fn open_buffered>(path: P) -> io::Result> { // Allocate the buffer *first* so we don't affect the filesystem otherwise. - let buffer = io::BufReader::::try_new_buffer()?; - let file = File::open(path)?; - Ok(io::BufReader::with_buffer(file, buffer)) + io::BufReader::try_new_with(|| File::open(path)) } /// Opens a file in write-only mode. @@ -672,9 +670,7 @@ impl File { #[unstable(feature = "file_buffered", issue = "130804")] pub fn create_buffered>(path: P) -> io::Result> { // Allocate the buffer *first* so we don't affect the filesystem otherwise. - let buffer = io::BufWriter::::try_new_buffer()?; - let file = File::create(path)?; - Ok(io::BufWriter::with_buffer(file, buffer)) + io::BufWriter::try_new_with(|| File::create(path)) } /// Creates a new file in read-write mode; error if the file exists. diff --git a/library/std/src/io/buffered/mod.rs b/library/std/src/io/buffered/mod.rs index e36f2d92108d0..1d09ff7d8dc1c 100644 --- a/library/std/src/io/buffered/mod.rs +++ b/library/std/src/io/buffered/mod.rs @@ -1,189 +1,4 @@ //! Buffering wrappers for I/O traits -mod bufreader; -mod bufwriter; -mod linewriter; -mod linewritershim; - #[cfg(test)] mod tests; - -#[stable(feature = "bufwriter_into_parts", since = "1.56.0")] -pub use bufwriter::WriterPanicked; -use linewritershim::LineWriterShim; - -#[stable(feature = "rust1", since = "1.0.0")] -pub use self::{bufreader::BufReader, bufwriter::BufWriter, linewriter::LineWriter}; -use crate::io::Error; -use crate::{error, fmt}; - -/// An error returned by [`BufWriter::into_inner`] which combines an error that -/// happened while writing out the buffer, and the buffered writer object -/// which may be used to recover from the condition. -/// -/// # Examples -/// -/// ```no_run -/// use std::io::BufWriter; -/// use std::net::TcpStream; -/// -/// let mut stream = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); -/// -/// // do stuff with the stream -/// -/// // we want to get our `TcpStream` back, so let's try: -/// -/// let stream = match stream.into_inner() { -/// Ok(s) => s, -/// Err(e) => { -/// // Here, e is an IntoInnerError -/// panic!("An error occurred"); -/// } -/// }; -/// ``` -#[derive(Debug)] -#[stable(feature = "rust1", since = "1.0.0")] -pub struct IntoInnerError(W, Error); - -impl IntoInnerError { - /// Constructs a new IntoInnerError - fn new(writer: W, error: Error) -> Self { - Self(writer, error) - } - - /// Helper to construct a new IntoInnerError; intended to help with - /// adapters that wrap other adapters - fn new_wrapped(self, f: impl FnOnce(W) -> W2) -> IntoInnerError { - let Self(writer, error) = self; - IntoInnerError::new(f(writer), error) - } - - /// Returns the error which caused the call to [`BufWriter::into_inner()`] - /// to fail. - /// - /// This error was returned when attempting to write the internal buffer. - /// - /// # Examples - /// - /// ```no_run - /// use std::io::BufWriter; - /// use std::net::TcpStream; - /// - /// let mut stream = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); - /// - /// // do stuff with the stream - /// - /// // we want to get our `TcpStream` back, so let's try: - /// - /// let stream = match stream.into_inner() { - /// Ok(s) => s, - /// Err(e) => { - /// // Here, e is an IntoInnerError, let's log the inner error. - /// // - /// // We'll just 'log' to stdout for this example. - /// println!("{}", e.error()); - /// - /// panic!("An unexpected error occurred."); - /// } - /// }; - /// ``` - #[stable(feature = "rust1", since = "1.0.0")] - pub fn error(&self) -> &Error { - &self.1 - } - - /// Returns the buffered writer instance which generated the error. - /// - /// The returned object can be used for error recovery, such as - /// re-inspecting the buffer. - /// - /// # Examples - /// - /// ```no_run - /// use std::io::BufWriter; - /// use std::net::TcpStream; - /// - /// let mut stream = BufWriter::new(TcpStream::connect("127.0.0.1:34254").unwrap()); - /// - /// // do stuff with the stream - /// - /// // we want to get our `TcpStream` back, so let's try: - /// - /// let stream = match stream.into_inner() { - /// Ok(s) => s, - /// Err(e) => { - /// // Here, e is an IntoInnerError, let's re-examine the buffer: - /// let buffer = e.into_inner(); - /// - /// // do stuff to try to recover - /// - /// // afterwards, let's just return the stream - /// buffer.into_inner().unwrap() - /// } - /// }; - /// ``` - #[stable(feature = "rust1", since = "1.0.0")] - pub fn into_inner(self) -> W { - self.0 - } - - /// Consumes the [`IntoInnerError`] and returns the error which caused the call to - /// [`BufWriter::into_inner()`] to fail. Unlike `error`, this can be used to - /// obtain ownership of the underlying error. - /// - /// # Example - /// ``` - /// use std::io::{BufWriter, ErrorKind, Write}; - /// - /// let mut not_enough_space = [0u8; 10]; - /// let mut stream = BufWriter::new(not_enough_space.as_mut()); - /// write!(stream, "this cannot be actually written").unwrap(); - /// let into_inner_err = stream.into_inner().expect_err("now we discover it's too small"); - /// let err = into_inner_err.into_error(); - /// assert_eq!(err.kind(), ErrorKind::WriteZero); - /// ``` - #[stable(feature = "io_into_inner_error_parts", since = "1.55.0")] - pub fn into_error(self) -> Error { - self.1 - } - - /// Consumes the [`IntoInnerError`] and returns the error which caused the call to - /// [`BufWriter::into_inner()`] to fail, and the underlying writer. - /// - /// This can be used to simply obtain ownership of the underlying error; it can also be used for - /// advanced error recovery. - /// - /// # Example - /// ``` - /// use std::io::{BufWriter, ErrorKind, Write}; - /// - /// let mut not_enough_space = [0u8; 10]; - /// let mut stream = BufWriter::new(not_enough_space.as_mut()); - /// write!(stream, "this cannot be actually written").unwrap(); - /// let into_inner_err = stream.into_inner().expect_err("now we discover it's too small"); - /// let (err, recovered_writer) = into_inner_err.into_parts(); - /// assert_eq!(err.kind(), ErrorKind::WriteZero); - /// assert_eq!(recovered_writer.buffer(), b"t be actually written"); - /// ``` - #[stable(feature = "io_into_inner_error_parts", since = "1.55.0")] - pub fn into_parts(self) -> (Error, W) { - (self.1, self.0) - } -} - -#[stable(feature = "rust1", since = "1.0.0")] -impl From> for Error { - fn from(iie: IntoInnerError) -> Error { - iie.1 - } -} - -#[stable(feature = "rust1", since = "1.0.0")] -impl error::Error for IntoInnerError {} - -#[stable(feature = "rust1", since = "1.0.0")] -impl fmt::Display for IntoInnerError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - self.error().fmt(f) - } -} diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index dbc92d7b45d7c..572f0fb3e4611 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -297,11 +297,14 @@ #[cfg(test)] mod tests; +use alloc_crate::io::OsFunctions; #[unstable(feature = "raw_os_error_ty", issue = "107792")] pub use alloc_crate::io::RawOsError; #[doc(hidden)] #[unstable(feature = "io_const_error_internals", issue = "none")] pub use alloc_crate::io::SimpleMessage; +#[stable(feature = "bufwriter_into_parts", since = "1.56.0")] +pub use alloc_crate::io::WriterPanicked; #[unstable(feature = "io_const_error", issue = "133448")] pub use alloc_crate::io::const_error; #[stable(feature = "io_read_to_string", since = "1.65.0")] @@ -310,23 +313,20 @@ pub use alloc_crate::io::read_to_string; pub use alloc_crate::io::{BorrowedBuf, BorrowedCursor}; #[stable(feature = "rust1", since = "1.0.0")] pub use alloc_crate::io::{ - BufRead, Bytes, Chain, Cursor, Empty, Error, ErrorKind, Lines, Read, Repeat, Result, Seek, - SeekFrom, Sink, Split, Take, Write, empty, repeat, sink, + BufRead, BufReader, BufWriter, Bytes, Chain, Cursor, Empty, Error, ErrorKind, IntoInnerError, + LineWriter, Lines, Read, Repeat, Result, Seek, SeekFrom, Sink, Split, Take, Write, empty, + repeat, sink, }; #[allow(unused_imports, reason = "only used by certain platforms")] pub(crate) use alloc_crate::io::{ DEFAULT_BUF_SIZE, default_read_buf, default_read_vectored, default_write_vectored, }; pub(crate) use alloc_crate::io::{ - IoHandle, SpecReadByte, append_to_string, default_read_buf_exact, default_read_exact, - default_read_to_end, default_read_to_string, stream_len_default, uninlined_slow_read_byte, + IoHandle, SpecReadByte, default_read_to_end, default_read_to_string, stream_len_default, }; #[stable(feature = "iovec", since = "1.36.0")] pub use alloc_crate::io::{IoSlice, IoSliceMut}; -use alloc_crate::io::{OsFunctions, SizeHint}; -#[stable(feature = "bufwriter_into_parts", since = "1.56.0")] -pub use self::buffered::WriterPanicked; #[stable(feature = "anonymous_pipe", since = "1.87.0")] pub use self::pipe::{PipeReader, PipeWriter, pipe}; #[stable(feature = "is_terminal", since = "1.70.0")] @@ -340,7 +340,6 @@ pub use self::stdio::{_eprint, _print}; pub use self::stdio::{set_output_capture, try_set_output_capture}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::{ - buffered::{BufReader, BufWriter, IntoInnerError, LineWriter}, copy::copy, stdio::{Stderr, StderrLock, Stdin, StdinLock, Stdout, StdoutLock, stderr, stdin, stdout}, }; diff --git a/src/bootstrap/src/core/build_steps/doc.rs b/src/bootstrap/src/core/build_steps/doc.rs index 4787578e19db0..9299a47c70c57 100644 --- a/src/bootstrap/src/core/build_steps/doc.rs +++ b/src/bootstrap/src/core/build_steps/doc.rs @@ -1319,6 +1319,10 @@ impl Step for UnstableBookGen { cmd.arg(rustc_path); cmd.arg(out); + // Running rustc requires the library path if rust.rpath = false + // or any other libraries are in a custom location. + builder.add_rustc_lib_path(self.build_compiler, &mut cmd); + cmd.run(builder); } } diff --git a/src/librustdoc/passes/lint/bare_urls.rs b/src/librustdoc/passes/lint/bare_urls.rs index 44fff58eb2618..0928980e390a8 100644 --- a/src/librustdoc/passes/lint/bare_urls.rs +++ b/src/librustdoc/passes/lint/bare_urls.rs @@ -111,6 +111,14 @@ fn find_raw_urls( url_range.start -= 1; url_range.end += 1; without_brackets = Some(match_.as_str()); + } else { + // Periods are valid in URLs, but very uncommon as the last character of one, while + // being very common as sentence punctuation right after one. Leave any trailing + // period out of the link, so that `Visit https://example.com/docs.` is linkified as + // `Visit .`. + let trailing_periods = + match_.as_str().len() - match_.as_str().trim_end_matches('.').len(); + url_range.end -= trailing_periods; } f(cx, "this URL is not a hyperlink", url_range, without_brackets); } diff --git a/src/tools/miri/tests/fail/rustc-error.rs b/src/tools/miri/tests/fail/rustc-error.rs index 7fc73bf365d5e..b554af9c25d69 100644 --- a/src/tools/miri/tests/fail/rustc-error.rs +++ b/src/tools/miri/tests/fail/rustc-error.rs @@ -1,4 +1,4 @@ // Make sure we exit with non-0 status code when the program fails to build. fn main() { - println("Hello, world!"); //~ ERROR: expected function, found macro + println("Hello, world!"); //~ ERROR: cannot find function `println` in this scope } diff --git a/src/tools/miri/tests/fail/rustc-error.stderr b/src/tools/miri/tests/fail/rustc-error.stderr index 31d9946c411f5..4b553ec48037f 100644 --- a/src/tools/miri/tests/fail/rustc-error.stderr +++ b/src/tools/miri/tests/fail/rustc-error.stderr @@ -1,9 +1,10 @@ -error[E0423]: expected function, found macro `println` +error[E0423]: cannot find function `println` in this scope --> tests/fail/rustc-error.rs:LL:CC | LL | println("Hello, world!"); - | ^^^^^^^ not a function + | ^^^^^^^ not found in this scope | + = note: a macro named `println` exists in another namespace help: use `!` to invoke the macro | LL | println!("Hello, world!"); diff --git a/src/tools/unstable-book-gen/src/main.rs b/src/tools/unstable-book-gen/src/main.rs index 923ca65b25501..e95d00f96c15e 100644 --- a/src/tools/unstable-book-gen/src/main.rs +++ b/src/tools/unstable-book-gen/src/main.rs @@ -128,6 +128,7 @@ fn collect_compiler_flags(rustc_path: impl AsRef) -> Features { rustc.env("RUSTC_BOOTSTRAP", "1"); rustc.arg("-Zhelp"); let output = t!(rustc.output()); + assert!(output.status.success(), "`rustc -Zhelp` failed: {output:?}"); let help_str = t!(String::from_utf8(output.stdout)); let parts = help_str.split("\n -Z").collect::>(); assert!(!parts[1..].is_empty(), "no -Z options were found"); diff --git a/tests/rustdoc-ui/lints/bare-urls.fixed b/tests/rustdoc-ui/lints/bare-urls.fixed index ac63e291c5b04..996214b5ff14f 100644 --- a/tests/rustdoc-ui/lints/bare-urls.fixed +++ b/tests/rustdoc-ui/lints/bare-urls.fixed @@ -69,6 +69,16 @@ pub mod foo { pub fn bar() {} } +/// Visit . +//~^ ERROR this URL is not a hyperlink +/// Two sentences. . And more text. +//~^ ERROR this URL is not a hyperlink +/// Trailing ellipsis ... +//~^ ERROR this URL is not a hyperlink +/// A period in the middle of is part of the URL. +//~^ ERROR this URL is not a hyperlink +pub fn trailing_period() {} + /// //~^ ERROR this URL is not a hyperlink /// [ ] diff --git a/tests/rustdoc-ui/lints/bare-urls.rs b/tests/rustdoc-ui/lints/bare-urls.rs index a70a3ec822e4a..9b4fe68e00322 100644 --- a/tests/rustdoc-ui/lints/bare-urls.rs +++ b/tests/rustdoc-ui/lints/bare-urls.rs @@ -69,6 +69,16 @@ pub mod foo { pub fn bar() {} } +/// Visit https://example.com/docs. +//~^ ERROR this URL is not a hyperlink +/// Two sentences. https://example.com. And more text. +//~^ ERROR this URL is not a hyperlink +/// Trailing ellipsis https://example.com/docs... +//~^ ERROR this URL is not a hyperlink +/// A period in the middle of https://example.com/a.b is part of the URL. +//~^ ERROR this URL is not a hyperlink +pub fn trailing_period() {} + /// [https://bloob.blob] //~^ ERROR this URL is not a hyperlink /// [ https://bloob.blob ] diff --git a/tests/rustdoc-ui/lints/bare-urls.stderr b/tests/rustdoc-ui/lints/bare-urls.stderr index 16c2f33fdfb1a..05ddd2ed42ab1 100644 --- a/tests/rustdoc-ui/lints/bare-urls.stderr +++ b/tests/rustdoc-ui/lints/bare-urls.stderr @@ -244,7 +244,55 @@ LL | #[doc = ""] | + + error: this URL is not a hyperlink - --> $DIR/bare-urls.rs:72:5 + --> $DIR/bare-urls.rs:72:11 + | +LL | /// Visit https://example.com/docs. + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: bare URLs are not automatically turned into clickable links +help: use an automatic link instead + | +LL | /// Visit . + | + + + +error: this URL is not a hyperlink + --> $DIR/bare-urls.rs:74:20 + | +LL | /// Two sentences. https://example.com. And more text. + | ^^^^^^^^^^^^^^^^^^^ + | + = note: bare URLs are not automatically turned into clickable links +help: use an automatic link instead + | +LL | /// Two sentences. . And more text. + | + + + +error: this URL is not a hyperlink + --> $DIR/bare-urls.rs:76:23 + | +LL | /// Trailing ellipsis https://example.com/docs... + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: bare URLs are not automatically turned into clickable links +help: use an automatic link instead + | +LL | /// Trailing ellipsis ... + | + + + +error: this URL is not a hyperlink + --> $DIR/bare-urls.rs:78:31 + | +LL | /// A period in the middle of https://example.com/a.b is part of the URL. + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: bare URLs are not automatically turned into clickable links +help: use an automatic link instead + | +LL | /// A period in the middle of is part of the URL. + | + + + +error: this URL is not a hyperlink + --> $DIR/bare-urls.rs:82:5 | LL | /// [https://bloob.blob] | ^^^^^^^^^^^^^^^^^^^^ @@ -257,7 +305,7 @@ LL + /// | error: this URL is not a hyperlink - --> $DIR/bare-urls.rs:74:7 + --> $DIR/bare-urls.rs:84:7 | LL | /// [ https://bloob.blob ] | ^^^^^^^^^^^^^^^^^^ @@ -269,7 +317,7 @@ LL | /// [ ] | + + error: this URL is not a hyperlink - --> $DIR/bare-urls.rs:76:7 + --> $DIR/bare-urls.rs:86:7 | LL | /// [ https://bloob.blob] | ^^^^^^^^^^^^^^^^^^ @@ -281,7 +329,7 @@ LL | /// [ ] | + + error: this URL is not a hyperlink - --> $DIR/bare-urls.rs:78:6 + --> $DIR/bare-urls.rs:88:6 | LL | /// [https://bloob.blob ] | ^^^^^^^^^^^^^^^^^^ @@ -293,7 +341,7 @@ LL | /// [ ] | + + error: this URL is not a hyperlink - --> $DIR/bare-urls.rs:80:6 + --> $DIR/bare-urls.rs:90:6 | LL | /// [https://bloob.blob | ^^^^^^^^^^^^^^^^^^ @@ -305,7 +353,7 @@ LL | /// [ | + + error: this URL is not a hyperlink - --> $DIR/bare-urls.rs:82:5 + --> $DIR/bare-urls.rs:92:5 | LL | /// https://bloob.blob] | ^^^^^^^^^^^^^^^^^^ @@ -316,5 +364,5 @@ help: use an automatic link instead LL | /// ] | + + -error: aborting due to 26 previous errors +error: aborting due to 30 previous errors diff --git a/tests/ui/associated-consts/issue-58022.rs b/tests/ui/associated-consts/issue-58022.rs index 8e2a441f2390d..54f4275f15f7b 100644 --- a/tests/ui/associated-consts/issue-58022.rs +++ b/tests/ui/associated-consts/issue-58022.rs @@ -13,7 +13,7 @@ impl Bar<[u8]> { fn new(slice: &[u8; Self::SIZE]) -> Self { //~^ ERROR: the size for values of type `[u8]` cannot be known at compilation time Foo(Box::new(*slice)) - //~^ ERROR: expected function, tuple struct or tuple variant, found trait `Foo` + //~^ ERROR: cannot find function, tuple struct or tuple variant `Foo` in this scope } } diff --git a/tests/ui/associated-consts/issue-58022.stderr b/tests/ui/associated-consts/issue-58022.stderr index 5d57e01d6f59c..24cec6e141bea 100644 --- a/tests/ui/associated-consts/issue-58022.stderr +++ b/tests/ui/associated-consts/issue-58022.stderr @@ -21,11 +21,13 @@ LL | LL | fn new(slice: &[u8; Foo::SIZE]) -> Self; | ^^^^^^^^^ cannot refer to the associated constant of trait -error[E0423]: expected function, tuple struct or tuple variant, found trait `Foo` +error[E0423]: cannot find function, tuple struct or tuple variant `Foo` in this scope --> $DIR/issue-58022.rs:15:9 | LL | Foo(Box::new(*slice)) - | ^^^ not a function, tuple struct or tuple variant + | ^^^ not found in this scope + | + = note: a trait named `Foo` exists in another namespace error: aborting due to 3 previous errors diff --git a/tests/ui/associated-item/missing-associated_item_or_field_def_ids.rs b/tests/ui/associated-item/missing-associated_item_or_field_def_ids.rs index 029ce7d0e7e49..f4b05749db97f 100644 --- a/tests/ui/associated-item/missing-associated_item_or_field_def_ids.rs +++ b/tests/ui/associated-item/missing-associated_item_or_field_def_ids.rs @@ -1,7 +1,7 @@ // Regression test for . fn main() -> dyn Iterator + ?Iterator::advance_by(usize) { - //~^ ERROR expected trait, found associated function `Iterator::advance_by` + //~^ ERROR cannot find trait `advance_by` in trait `Iterator` //~| ERROR relaxed bounds are not permitted in trait object types todo!() } diff --git a/tests/ui/associated-item/missing-associated_item_or_field_def_ids.stderr b/tests/ui/associated-item/missing-associated_item_or_field_def_ids.stderr index ffe0b14a030d3..ab9db8cfb5438 100644 --- a/tests/ui/associated-item/missing-associated_item_or_field_def_ids.stderr +++ b/tests/ui/associated-item/missing-associated_item_or_field_def_ids.stderr @@ -1,8 +1,10 @@ -error[E0404]: expected trait, found associated function `Iterator::advance_by` - --> $DIR/missing-associated_item_or_field_def_ids.rs:3:30 +error[E0404]: cannot find trait `advance_by` in trait `Iterator` + --> $DIR/missing-associated_item_or_field_def_ids.rs:3:40 | LL | fn main() -> dyn Iterator + ?Iterator::advance_by(usize) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a trait + | ^^^^^^^^^^ not found in `Iterator` + | + = note: an associated function named `Iterator::advance_by` exists in another namespace error: relaxed bounds are not permitted in trait object types --> $DIR/missing-associated_item_or_field_def_ids.rs:3:29 diff --git a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.fixed b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.fixed index 7af986267aa67..46d632cfb5ded 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.fixed +++ b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.fixed @@ -29,12 +29,12 @@ fn baz_path() where T::method(..): Send {} //~^ ERROR return type notation arguments must be elided with `..` fn foo_qualified() where T::method(..): Send {} -//~^ ERROR expected associated type +//~^ ERROR cannot find associated type `method` in trait `Trait` fn bar_qualified() where T::method(..): Send {} -//~^ ERROR expected associated type +//~^ ERROR cannot find associated type `method` in trait `Trait` fn baz_qualified() where T::method(..): Send {} -//~^ ERROR expected associated type +//~^ ERROR cannot find associated type `method` in trait `Trait` fn main() {} diff --git a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs index 983836e6433f0..27ad9f17e33ed 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs @@ -29,12 +29,12 @@ fn baz_path() where T::method(): Send {} //~^ ERROR return type notation arguments must be elided with `..` fn foo_qualified() where ::method(i32): Send {} -//~^ ERROR expected associated type +//~^ ERROR cannot find associated type `method` in trait `Trait` fn bar_qualified() where ::method() -> (): Send {} -//~^ ERROR expected associated type +//~^ ERROR cannot find associated type `method` in trait `Trait` fn baz_qualified() where ::method(): Send {} -//~^ ERROR expected associated type +//~^ ERROR cannot find associated type `method` in trait `Trait` fn main() {} diff --git a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr index e1245a04c7f7d..3222a0be13589 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr @@ -10,36 +10,39 @@ LL - fn bay_path() where T::method(..) -> (): Send {} LL + fn bay_path() where T::method(..): Send {} | -error[E0575]: expected associated type, found associated function `Trait::method` - --> $DIR/bad-inputs-and-output.rs:31:36 +error[E0575]: cannot find associated type `method` in trait `Trait` + --> $DIR/bad-inputs-and-output.rs:31:50 | LL | fn foo_qualified() where ::method(i32): Send {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ not a associated type + | ^^^^^^ not found in `Trait` | + = note: an associated function named `Trait::method` exists in another namespace help: you might have meant to use the return type notation syntax | LL - fn foo_qualified() where ::method(i32): Send {} LL + fn foo_qualified() where T::method(..): Send {} | -error[E0575]: expected associated type, found associated function `Trait::method` - --> $DIR/bad-inputs-and-output.rs:34:36 +error[E0575]: cannot find associated type `method` in trait `Trait` + --> $DIR/bad-inputs-and-output.rs:34:50 | LL | fn bar_qualified() where ::method() -> (): Send {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a associated type + | ^^^^^^ not found in `Trait` | + = note: an associated function named `Trait::method` exists in another namespace help: you might have meant to use the return type notation syntax | LL - fn bar_qualified() where ::method() -> (): Send {} LL + fn bar_qualified() where T::method(..): Send {} | -error[E0575]: expected associated type, found associated function `Trait::method` - --> $DIR/bad-inputs-and-output.rs:37:36 +error[E0575]: cannot find associated type `method` in trait `Trait` + --> $DIR/bad-inputs-and-output.rs:37:50 | LL | fn baz_qualified() where ::method(): Send {} - | ^^^^^^^^^^^^^^^^^^^^^^ not a associated type + | ^^^^^^ not found in `Trait` | + = note: an associated function named `Trait::method` exists in another namespace help: you might have meant to use the return type notation syntax | LL - fn baz_qualified() where ::method(): Send {} diff --git a/tests/ui/associated-type-bounds/return-type-notation/not-a-method.rs b/tests/ui/associated-type-bounds/return-type-notation/not-a-method.rs index 89a414a3bc863..9215b9c6527ea 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/not-a-method.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/not-a-method.rs @@ -13,7 +13,7 @@ where fn not_a_method_and_typoed() where function(): Send, - //~^ ERROR expected type, found function `function` + //~^ ERROR cannot find type `function` in this scope { } diff --git a/tests/ui/associated-type-bounds/return-type-notation/not-a-method.stderr b/tests/ui/associated-type-bounds/return-type-notation/not-a-method.stderr index bf5b432e74f1c..45caec31ab760 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/not-a-method.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/not-a-method.stderr @@ -4,11 +4,13 @@ error[E0575]: expected function, found function `function` LL | function(..): Send, | ^^^^^^^^^^^^ not a function -error[E0573]: expected type, found function `function` +error[E0573]: cannot find type `function` in this scope --> $DIR/not-a-method.rs:15:5 | LL | function(): Send, - | ^^^^^^^^^^ not a type + | ^^^^^^^^ not found in this scope + | + = note: a function named `function` exists in another namespace error[E0576]: cannot find function `method` in this scope --> $DIR/not-a-method.rs:27:5 diff --git a/tests/ui/associated-type-bounds/return-type-notation/path-missing.rs b/tests/ui/associated-type-bounds/return-type-notation/path-missing.rs index 1ad02f754db53..950b61661177f 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/path-missing.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/path-missing.rs @@ -10,7 +10,7 @@ where ::method(..): Send, //~^ ERROR cannot find method or associated constant `method` in trait `A` ::bad(..): Send, - //~^ ERROR expected method or associated constant, found associated type `A::bad` + //~^ ERROR cannot find method or associated constant `bad` in trait `A` { } diff --git a/tests/ui/associated-type-bounds/return-type-notation/path-missing.stderr b/tests/ui/associated-type-bounds/return-type-notation/path-missing.stderr index 677fc0e10bbda..184b6f1adba93 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/path-missing.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/path-missing.stderr @@ -4,11 +4,13 @@ error[E0576]: cannot find method or associated constant `method` in trait `A` LL | ::method(..): Send, | ^^^^^^ not found in `A` -error[E0575]: expected method or associated constant, found associated type `A::bad` - --> $DIR/path-missing.rs:12:5 +error[E0575]: cannot find method or associated constant `bad` in trait `A` + --> $DIR/path-missing.rs:12:15 | LL | ::bad(..): Send, - | ^^^^^^^^^^^^^^^^^ not a method or associated constant + | ^^^ not found in `A` + | + = note: an associated type named `A::bad` exists in another namespace error[E0220]: associated function `method` not found for `T` --> $DIR/path-missing.rs:19:8 diff --git a/tests/ui/associated-types/tuple-struct-expr-pat.fixed b/tests/ui/associated-types/tuple-struct-expr-pat.fixed index d6e2385f82103..2875b3c3e1c3f 100644 --- a/tests/ui/associated-types/tuple-struct-expr-pat.fixed +++ b/tests/ui/associated-types/tuple-struct-expr-pat.fixed @@ -8,17 +8,17 @@ fn main() { let as Trait>::Assoc {} = as Trait>::Assoc {}; - //~^ error: expected method or associated constant, found associated type - //~| error: expected tuple struct or tuple variant, found associated type + //~^ error: cannot find method or associated constant `Assoc` in trait `Trait` + //~| error: cannot find tuple struct or tuple variant `Assoc` in trait `Trait` let as Trait>::Assoc { 0: _a } = as Trait>::Assoc { 0: 0 }; - //~^ error: expected method or associated constant, found associated type - //~| error: expected tuple struct or tuple variant, found associated type + //~^ error: cannot find method or associated constant `Assoc` in trait `Trait` + //~| error: cannot find tuple struct or tuple variant `Assoc` in trait `Trait` let as Trait>::Assoc { 0: _a, 1: _b } = as Trait>::Assoc { 0: 0, 1: 1 }; - //~^ error: expected method or associated constant, found associated type - //~| error: expected tuple struct or tuple variant, found associated type + //~^ error: cannot find method or associated constant `Assoc` in trait `Trait` + //~| error: cannot find tuple struct or tuple variant `Assoc` in trait `Trait` let as Trait>::Assoc { 0: ref _a, 1: ref mut _b, 2: mut _c } = as Trait>::Assoc { 0: 0, 1: 1, 2: 2 }; - //~^ error: expected method or associated constant, found associated type - //~| error: expected tuple struct or tuple variant, found associated type + //~^ error: cannot find method or associated constant `Assoc` in trait `Trait` + //~| error: cannot find tuple struct or tuple variant `Assoc` in trait `Trait` } diff --git a/tests/ui/associated-types/tuple-struct-expr-pat.rs b/tests/ui/associated-types/tuple-struct-expr-pat.rs index f27a5fe175390..33138e063c1f0 100644 --- a/tests/ui/associated-types/tuple-struct-expr-pat.rs +++ b/tests/ui/associated-types/tuple-struct-expr-pat.rs @@ -8,17 +8,17 @@ fn main() { let as Trait>::Assoc() = as Trait>::Assoc(); - //~^ error: expected method or associated constant, found associated type - //~| error: expected tuple struct or tuple variant, found associated type + //~^ error: cannot find method or associated constant `Assoc` in trait `Trait` + //~| error: cannot find tuple struct or tuple variant `Assoc` in trait `Trait` let as Trait>::Assoc(_a) = as Trait>::Assoc(0); - //~^ error: expected method or associated constant, found associated type - //~| error: expected tuple struct or tuple variant, found associated type + //~^ error: cannot find method or associated constant `Assoc` in trait `Trait` + //~| error: cannot find tuple struct or tuple variant `Assoc` in trait `Trait` let as Trait>::Assoc(_a, _b) = as Trait>::Assoc(0, 1); - //~^ error: expected method or associated constant, found associated type - //~| error: expected tuple struct or tuple variant, found associated type + //~^ error: cannot find method or associated constant `Assoc` in trait `Trait` + //~| error: cannot find tuple struct or tuple variant `Assoc` in trait `Trait` let as Trait>::Assoc(ref _a, ref mut _b, mut _c) = as Trait>::Assoc(0, 1, 2); - //~^ error: expected method or associated constant, found associated type - //~| error: expected tuple struct or tuple variant, found associated type + //~^ error: cannot find method or associated constant `Assoc` in trait `Trait` + //~| error: cannot find tuple struct or tuple variant `Assoc` in trait `Trait` } diff --git a/tests/ui/associated-types/tuple-struct-expr-pat.stderr b/tests/ui/associated-types/tuple-struct-expr-pat.stderr index b6ceaae362654..821c06823231d 100644 --- a/tests/ui/associated-types/tuple-struct-expr-pat.stderr +++ b/tests/ui/associated-types/tuple-struct-expr-pat.stderr @@ -1,9 +1,10 @@ -error[E0575]: expected method or associated constant, found associated type `Trait::Assoc` - --> $DIR/tuple-struct-expr-pat.rs:10:36 +error[E0575]: cannot find method or associated constant `Assoc` in trait `Trait` + --> $DIR/tuple-struct-expr-pat.rs:10:53 | LL | let as Trait>::Assoc() = as Trait>::Assoc(); - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^ | + = note: an associated type named `Trait::Assoc` exists in another namespace = note: can't use a type alias as a constructor help: use struct expression instead | @@ -11,12 +12,13 @@ LL - let as Trait>::Assoc() = as Trait>::Assoc(); LL + let as Trait>::Assoc() = as Trait>::Assoc {}; | -error[E0575]: expected tuple struct or tuple variant, found associated type `Trait::Assoc` - --> $DIR/tuple-struct-expr-pat.rs:10:9 +error[E0575]: cannot find tuple struct or tuple variant `Assoc` in trait `Trait` + --> $DIR/tuple-struct-expr-pat.rs:10:26 | LL | let as Trait>::Assoc() = as Trait>::Assoc(); - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^ | + = note: an associated type named `Trait::Assoc` exists in another namespace = note: can't use a type alias as tuple pattern help: use struct pattern instead | @@ -24,12 +26,13 @@ LL - let as Trait>::Assoc() = as Trait>::Assoc(); LL + let as Trait>::Assoc {} = as Trait>::Assoc(); | -error[E0575]: expected method or associated constant, found associated type `Trait::Assoc` - --> $DIR/tuple-struct-expr-pat.rs:13:38 +error[E0575]: cannot find method or associated constant `Assoc` in trait `Trait` + --> $DIR/tuple-struct-expr-pat.rs:13:55 | LL | let as Trait>::Assoc(_a) = as Trait>::Assoc(0); - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^ | + = note: an associated type named `Trait::Assoc` exists in another namespace = note: can't use a type alias as a constructor help: use struct expression instead | @@ -37,12 +40,13 @@ LL - let as Trait>::Assoc(_a) = as Trait>::Assoc(0); LL + let as Trait>::Assoc(_a) = as Trait>::Assoc { 0: 0 }; | -error[E0575]: expected tuple struct or tuple variant, found associated type `Trait::Assoc` - --> $DIR/tuple-struct-expr-pat.rs:13:9 +error[E0575]: cannot find tuple struct or tuple variant `Assoc` in trait `Trait` + --> $DIR/tuple-struct-expr-pat.rs:13:26 | LL | let as Trait>::Assoc(_a) = as Trait>::Assoc(0); - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^ | + = note: an associated type named `Trait::Assoc` exists in another namespace = note: can't use a type alias as tuple pattern help: use struct pattern instead | @@ -50,12 +54,13 @@ LL - let as Trait>::Assoc(_a) = as Trait>::Assoc(0); LL + let as Trait>::Assoc { 0: _a } = as Trait>::Assoc(0); | -error[E0575]: expected method or associated constant, found associated type `Trait::Assoc` - --> $DIR/tuple-struct-expr-pat.rs:16:42 +error[E0575]: cannot find method or associated constant `Assoc` in trait `Trait` + --> $DIR/tuple-struct-expr-pat.rs:16:59 | LL | let as Trait>::Assoc(_a, _b) = as Trait>::Assoc(0, 1); - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^ | + = note: an associated type named `Trait::Assoc` exists in another namespace = note: can't use a type alias as a constructor help: use struct expression instead | @@ -63,12 +68,13 @@ LL - let as Trait>::Assoc(_a, _b) = as Trait>::Assoc(0, 1); LL + let as Trait>::Assoc(_a, _b) = as Trait>::Assoc { 0: 0, 1: 1 }; | -error[E0575]: expected tuple struct or tuple variant, found associated type `Trait::Assoc` - --> $DIR/tuple-struct-expr-pat.rs:16:9 +error[E0575]: cannot find tuple struct or tuple variant `Assoc` in trait `Trait` + --> $DIR/tuple-struct-expr-pat.rs:16:26 | LL | let as Trait>::Assoc(_a, _b) = as Trait>::Assoc(0, 1); - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^ | + = note: an associated type named `Trait::Assoc` exists in another namespace = note: can't use a type alias as tuple pattern help: use struct pattern instead | @@ -76,12 +82,13 @@ LL - let as Trait>::Assoc(_a, _b) = as Trait>::Assoc(0, 1); LL + let as Trait>::Assoc { 0: _a, 1: _b } = as Trait>::Assoc(0, 1); | -error[E0575]: expected method or associated constant, found associated type `Trait::Assoc` - --> $DIR/tuple-struct-expr-pat.rs:19:62 +error[E0575]: cannot find method or associated constant `Assoc` in trait `Trait` + --> $DIR/tuple-struct-expr-pat.rs:19:79 | LL | let as Trait>::Assoc(ref _a, ref mut _b, mut _c) = as Trait>::Assoc(0, 1, 2); - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^ | + = note: an associated type named `Trait::Assoc` exists in another namespace = note: can't use a type alias as a constructor help: use struct expression instead | @@ -89,12 +96,13 @@ LL - let as Trait>::Assoc(ref _a, ref mut _b, mut _c) = as Trait LL + let as Trait>::Assoc(ref _a, ref mut _b, mut _c) = as Trait>::Assoc { 0: 0, 1: 1, 2: 2 }; | -error[E0575]: expected tuple struct or tuple variant, found associated type `Trait::Assoc` - --> $DIR/tuple-struct-expr-pat.rs:19:9 +error[E0575]: cannot find tuple struct or tuple variant `Assoc` in trait `Trait` + --> $DIR/tuple-struct-expr-pat.rs:19:26 | LL | let as Trait>::Assoc(ref _a, ref mut _b, mut _c) = as Trait>::Assoc(0, 1, 2); - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^ | + = note: an associated type named `Trait::Assoc` exists in another namespace = note: can't use a type alias as tuple pattern help: use struct pattern instead | diff --git a/tests/ui/async-await/async-block-control-flow-static-semantics.stderr b/tests/ui/async-await/async-block-control-flow-static-semantics.stderr index b64690bae6cde..5a379cc83447c 100644 --- a/tests/ui/async-await/async-block-control-flow-static-semantics.stderr +++ b/tests/ui/async-await/async-block-control-flow-static-semantics.stderr @@ -10,7 +10,7 @@ LL | | return 0u8; LL | | } | |_^ expected `u8`, found `()` -error[E0271]: expected `{async block@$DIR/async-block-control-flow-static-semantics.rs:23:17: 23:22}` to be a future that resolves to `()`, but it resolves to `u8` +error[E0271]: expected `{async block@async-block-control-flow-static-semantics.rs:23:17}` to be a future that resolves to `()`, but it resolves to `u8` --> $DIR/async-block-control-flow-static-semantics.rs:26:39 | LL | let _: &dyn Future = █ @@ -26,7 +26,7 @@ LL | fn return_targets_async_block_not_fn() -> u8 { | | | implicitly returns `()` as its body has no tail or `return` expression -error[E0271]: expected `{async block@$DIR/async-block-control-flow-static-semantics.rs:14:17: 14:22}` to be a future that resolves to `()`, but it resolves to `u8` +error[E0271]: expected `{async block@async-block-control-flow-static-semantics.rs:14:17}` to be a future that resolves to `()`, but it resolves to `u8` --> $DIR/async-block-control-flow-static-semantics.rs:17:39 | LL | let _: &dyn Future = █ diff --git a/tests/ui/async-await/async-closures/is-not-fn.current.stderr b/tests/ui/async-await/async-closures/is-not-fn.current.stderr index 0fab1c15f27df..19d5f9966ffdc 100644 --- a/tests/ui/async-await/async-closures/is-not-fn.current.stderr +++ b/tests/ui/async-await/async-closures/is-not-fn.current.stderr @@ -1,4 +1,4 @@ -error[E0271]: expected `{async closure@is-not-fn.rs:8:14}` to return `()`, but it returns `{async closure body@$DIR/is-not-fn.rs:8:23: 8:25}` +error[E0271]: expected `{async closure@is-not-fn.rs:8:14}` to return `()`, but it returns `{async closure body@is-not-fn.rs:8:23}` --> $DIR/is-not-fn.rs:8:14 | LL | needs_fn(async || {}); diff --git a/tests/ui/async-await/async-closures/is-not-fn.next.stderr b/tests/ui/async-await/async-closures/is-not-fn.next.stderr index 0fab1c15f27df..19d5f9966ffdc 100644 --- a/tests/ui/async-await/async-closures/is-not-fn.next.stderr +++ b/tests/ui/async-await/async-closures/is-not-fn.next.stderr @@ -1,4 +1,4 @@ -error[E0271]: expected `{async closure@is-not-fn.rs:8:14}` to return `()`, but it returns `{async closure body@$DIR/is-not-fn.rs:8:23: 8:25}` +error[E0271]: expected `{async closure@is-not-fn.rs:8:14}` to return `()`, but it returns `{async closure body@is-not-fn.rs:8:23}` --> $DIR/is-not-fn.rs:8:14 | LL | needs_fn(async || {}); diff --git a/tests/ui/async-await/async-drop/ex-ice1.rs b/tests/ui/async-await/async-drop/ex-ice1.rs index f514c57097a3a..1256c9e299846 100644 --- a/tests/ui/async-await/async-drop/ex-ice1.rs +++ b/tests/ui/async-await/async-drop/ex-ice1.rs @@ -6,7 +6,7 @@ use core::pin::{pin, Pin}; fn main() { let fut = pin!(async { - let async_drop_fut = pin!(core::future::async_drop(async {})); //~ ERROR: expected function, found module `core::future::async_drop` + let async_drop_fut = pin!(core::future::async_drop(async {})); //~ ERROR: cannot find function `async_drop` in module `core::future` //~^ ERROR: module `async_drop` is private (async_drop_fut).await; }); diff --git a/tests/ui/async-await/async-drop/ex-ice1.stderr b/tests/ui/async-await/async-drop/ex-ice1.stderr index a1fa89f2c4001..55e11a538561f 100644 --- a/tests/ui/async-await/async-drop/ex-ice1.stderr +++ b/tests/ui/async-await/async-drop/ex-ice1.stderr @@ -1,8 +1,10 @@ -error[E0423]: expected function, found module `core::future::async_drop` - --> $DIR/ex-ice1.rs:9:35 +error[E0423]: cannot find function `async_drop` in module `core::future` + --> $DIR/ex-ice1.rs:9:49 | LL | ... let async_drop_fut = pin!(core::future::async_drop(async {})); - | ^^^^^^^^^^^^^^^^^^^^^^^^ not a function + | ^^^^^^^^^^ not found in `core::future` + | + = note: a module named `core::future::async_drop` exists in another namespace error[E0603]: module `async_drop` is private --> $DIR/ex-ice1.rs:9:49 diff --git a/tests/ui/async-await/higher-ranked-auto-trait-16.assumptions.stderr b/tests/ui/async-await/higher-ranked-auto-trait-16.assumptions.stderr index 412c31b1bd843..dc6183a45cef5 100644 --- a/tests/ui/async-await/higher-ranked-auto-trait-16.assumptions.stderr +++ b/tests/ui/async-await/higher-ranked-auto-trait-16.assumptions.stderr @@ -6,7 +6,7 @@ LL | | commit_if_ok(&mut ctxt, async |_| todo!()).await; LL | | }); | |______^ implementation of `AsyncFnOnce` is not general enough | - = note: `{async closure@$DIR/higher-ranked-auto-trait-16.rs:19:33: 19:42}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... + = note: `{async closure@...}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `AsyncFnOnce<(&mut Ctxt<'_>,)>` error: implementation of `AsyncFnOnce` is not general enough @@ -17,7 +17,7 @@ LL | | commit_if_ok(&mut ctxt, async |_| todo!()).await; LL | | }); | |______^ implementation of `AsyncFnOnce` is not general enough | - = note: `{async closure@$DIR/higher-ranked-auto-trait-16.rs:19:33: 19:42}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... + = note: `{async closure@...}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `AsyncFnOnce<(&mut Ctxt<'_>,)>` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` diff --git a/tests/ui/async-await/higher-ranked-auto-trait-16.no_assumptions.stderr b/tests/ui/async-await/higher-ranked-auto-trait-16.no_assumptions.stderr index 412c31b1bd843..dc6183a45cef5 100644 --- a/tests/ui/async-await/higher-ranked-auto-trait-16.no_assumptions.stderr +++ b/tests/ui/async-await/higher-ranked-auto-trait-16.no_assumptions.stderr @@ -6,7 +6,7 @@ LL | | commit_if_ok(&mut ctxt, async |_| todo!()).await; LL | | }); | |______^ implementation of `AsyncFnOnce` is not general enough | - = note: `{async closure@$DIR/higher-ranked-auto-trait-16.rs:19:33: 19:42}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... + = note: `{async closure@...}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `AsyncFnOnce<(&mut Ctxt<'_>,)>` error: implementation of `AsyncFnOnce` is not general enough @@ -17,7 +17,7 @@ LL | | commit_if_ok(&mut ctxt, async |_| todo!()).await; LL | | }); | |______^ implementation of `AsyncFnOnce` is not general enough | - = note: `{async closure@$DIR/higher-ranked-auto-trait-16.rs:19:33: 19:42}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... + = note: `{async closure@...}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `AsyncFnOnce<(&mut Ctxt<'_>,)>` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` diff --git a/tests/ui/async-await/issues/issue-78654.full.stderr b/tests/ui/async-await/issues/issue-78654.full.stderr index e1f9aa9ce81e7..4af72ff4e2e98 100644 --- a/tests/ui/async-await/issues/issue-78654.full.stderr +++ b/tests/ui/async-await/issues/issue-78654.full.stderr @@ -1,8 +1,10 @@ -error[E0573]: expected type, found built-in attribute `feature` +error[E0573]: cannot find type `feature` in this scope --> $DIR/issue-78654.rs:9:15 | LL | impl Foo { - | ^^^^^^^ not a type + | ^^^^^^^ not found in this scope + | + = note: a built-in attribute named `feature` exists in another namespace error[E0207]: the const parameter `H` is not constrained by the impl trait, self type, or predicates --> $DIR/issue-78654.rs:9:6 diff --git a/tests/ui/async-await/issues/issue-78654.min.stderr b/tests/ui/async-await/issues/issue-78654.min.stderr index e1f9aa9ce81e7..4af72ff4e2e98 100644 --- a/tests/ui/async-await/issues/issue-78654.min.stderr +++ b/tests/ui/async-await/issues/issue-78654.min.stderr @@ -1,8 +1,10 @@ -error[E0573]: expected type, found built-in attribute `feature` +error[E0573]: cannot find type `feature` in this scope --> $DIR/issue-78654.rs:9:15 | LL | impl Foo { - | ^^^^^^^ not a type + | ^^^^^^^ not found in this scope + | + = note: a built-in attribute named `feature` exists in another namespace error[E0207]: the const parameter `H` is not constrained by the impl trait, self type, or predicates --> $DIR/issue-78654.rs:9:6 diff --git a/tests/ui/async-await/issues/issue-78654.rs b/tests/ui/async-await/issues/issue-78654.rs index eb8bf27ff837d..ecf064faaf6b3 100644 --- a/tests/ui/async-await/issues/issue-78654.rs +++ b/tests/ui/async-await/issues/issue-78654.rs @@ -7,7 +7,7 @@ struct Foo; impl Foo { -//~^ ERROR: expected type, found built-in attribute `feature` +//~^ ERROR: cannot find type `feature` in this scope //~^^ ERROR: the const parameter `H` is not constrained by the impl trait, self type, or predicates async fn biz() {} } diff --git a/tests/ui/closures/local-type-mix.rs b/tests/ui/closures/local-type-mix.rs index edcdac2a61117..2f4043775e5b8 100644 --- a/tests/ui/closures/local-type-mix.rs +++ b/tests/ui/closures/local-type-mix.rs @@ -2,14 +2,14 @@ //@ edition:2018 fn main() { - let _ = |x: x| x; //~ ERROR expected type - let _ = |x: bool| -> x { x }; //~ ERROR expected type - let _ = async move |x: x| x; //~ ERROR expected type - let _ = async move |x: bool| -> x { x }; //~ ERROR expected type + let _ = |x: x| x; //~ ERROR cannot find type `x` in this scope + let _ = |x: bool| -> x { x }; //~ ERROR cannot find type `x` in this scope + let _ = async move |x: x| x; //~ ERROR cannot find type `x` in this scope + let _ = async move |x: bool| -> x { x }; //~ ERROR cannot find type `x` in this scope } -fn foo(x: x) {} //~ ERROR expected type -fn foo_ret(x: bool) -> x {} //~ ERROR expected type +fn foo(x: x) {} //~ ERROR cannot find type `x` in this scope +fn foo_ret(x: bool) -> x {} //~ ERROR cannot find type `x` in this scope -async fn async_foo(x: x) {} //~ ERROR expected type -async fn async_foo_ret(x: bool) -> x {} //~ ERROR expected type +async fn async_foo(x: x) {} //~ ERROR cannot find type `x` in this scope +async fn async_foo_ret(x: bool) -> x {} //~ ERROR cannot find type `x` in this scope diff --git a/tests/ui/closures/local-type-mix.stderr b/tests/ui/closures/local-type-mix.stderr index f3b6a73afd5ca..a88f2be85dfaa 100644 --- a/tests/ui/closures/local-type-mix.stderr +++ b/tests/ui/closures/local-type-mix.stderr @@ -1,50 +1,66 @@ -error[E0573]: expected type, found local variable `x` +error[E0573]: cannot find type `x` in this scope --> $DIR/local-type-mix.rs:5:17 | LL | let _ = |x: x| x; - | ^ not a type + | ^ not found in this scope + | + = note: a local variable named `x` exists in another namespace -error[E0573]: expected type, found local variable `x` +error[E0573]: cannot find type `x` in this scope --> $DIR/local-type-mix.rs:6:26 | LL | let _ = |x: bool| -> x { x }; - | ^ not a type + | ^ not found in this scope + | + = note: a local variable named `x` exists in another namespace -error[E0573]: expected type, found local variable `x` +error[E0573]: cannot find type `x` in this scope --> $DIR/local-type-mix.rs:7:28 | LL | let _ = async move |x: x| x; - | ^ not a type + | ^ not found in this scope + | + = note: a local variable named `x` exists in another namespace -error[E0573]: expected type, found local variable `x` +error[E0573]: cannot find type `x` in this scope --> $DIR/local-type-mix.rs:8:37 | LL | let _ = async move |x: bool| -> x { x }; - | ^ not a type + | ^ not found in this scope + | + = note: a local variable named `x` exists in another namespace -error[E0573]: expected type, found local variable `x` +error[E0573]: cannot find type `x` in this scope --> $DIR/local-type-mix.rs:11:11 | LL | fn foo(x: x) {} - | ^ not a type + | ^ not found in this scope + | + = note: a local variable named `x` exists in another namespace -error[E0573]: expected type, found local variable `x` +error[E0573]: cannot find type `x` in this scope --> $DIR/local-type-mix.rs:12:24 | LL | fn foo_ret(x: bool) -> x {} - | ^ not a type + | ^ not found in this scope + | + = note: a local variable named `x` exists in another namespace -error[E0573]: expected type, found local variable `x` +error[E0573]: cannot find type `x` in this scope --> $DIR/local-type-mix.rs:14:23 | LL | async fn async_foo(x: x) {} - | ^ not a type + | ^ not found in this scope + | + = note: a local variable named `x` exists in another namespace -error[E0573]: expected type, found local variable `x` +error[E0573]: cannot find type `x` in this scope --> $DIR/local-type-mix.rs:15:36 | LL | async fn async_foo_ret(x: bool) -> x {} - | ^ not a type + | ^ not found in this scope + | + = note: a local variable named `x` exists in another namespace error: aborting due to 8 previous errors diff --git a/tests/ui/compile-flags/invalid/codegen-option-typo-suggestion-issue-159482.codegen.stderr b/tests/ui/compile-flags/invalid/codegen-option-typo-suggestion-issue-159482.codegen.stderr new file mode 100644 index 0000000000000..613e8a999a692 --- /dev/null +++ b/tests/ui/compile-flags/invalid/codegen-option-typo-suggestion-issue-159482.codegen.stderr @@ -0,0 +1,4 @@ +error: unknown codegen option: `opt-leve` + | + = help: you might have meant to use `-C opt-level=` + diff --git a/tests/ui/compile-flags/invalid/codegen-option-typo-suggestion-issue-159482.rs b/tests/ui/compile-flags/invalid/codegen-option-typo-suggestion-issue-159482.rs new file mode 100644 index 0000000000000..b796e3dd6e71d --- /dev/null +++ b/tests/ui/compile-flags/invalid/codegen-option-typo-suggestion-issue-159482.rs @@ -0,0 +1,11 @@ +// Regression test for issue #159482 +// Misspelled compiler options should suggest the closest valid command-line spelling. + +//@ revisions: codegen unstable +//@[codegen] compile-flags: -Copt-leve=2 +//@[unstable] compile-flags: -Zno-analysi + +fn main() {} + +//[codegen]~? ERROR unknown codegen option: `opt-leve` +//[unstable]~? ERROR unknown unstable option: `no-analysi` diff --git a/tests/ui/compile-flags/invalid/codegen-option-typo-suggestion-issue-159482.unstable.stderr b/tests/ui/compile-flags/invalid/codegen-option-typo-suggestion-issue-159482.unstable.stderr new file mode 100644 index 0000000000000..49f505aca18ed --- /dev/null +++ b/tests/ui/compile-flags/invalid/codegen-option-typo-suggestion-issue-159482.unstable.stderr @@ -0,0 +1,4 @@ +error: unknown unstable option: `no-analysi` + | + = help: you might have meant to use `-Z no-analysis` + diff --git a/tests/ui/const-generics/assoc_const_as_type_argument.rs b/tests/ui/const-generics/assoc_const_as_type_argument.rs index ffc7f116a94ef..44a43fdbbfb94 100644 --- a/tests/ui/const-generics/assoc_const_as_type_argument.rs +++ b/tests/ui/const-generics/assoc_const_as_type_argument.rs @@ -6,7 +6,7 @@ fn bar() {} fn foo() { bar::<::ASSOC>(); - //~^ ERROR: expected associated type, found associated constant `Trait::ASSOC` + //~^ ERROR: cannot find associated type `ASSOC` in trait `Trait` //~| ERROR: unresolved item provided when a constant was expected } diff --git a/tests/ui/const-generics/assoc_const_as_type_argument.stderr b/tests/ui/const-generics/assoc_const_as_type_argument.stderr index ac00954613506..6060031b78eb1 100644 --- a/tests/ui/const-generics/assoc_const_as_type_argument.stderr +++ b/tests/ui/const-generics/assoc_const_as_type_argument.stderr @@ -1,8 +1,10 @@ -error[E0575]: expected associated type, found associated constant `Trait::ASSOC` - --> $DIR/assoc_const_as_type_argument.rs:8:11 +error[E0575]: cannot find associated type `ASSOC` in trait `Trait` + --> $DIR/assoc_const_as_type_argument.rs:8:25 | LL | bar::<::ASSOC>(); - | ^^^^^^^^^^^^^^^^^^^ not a associated type + | ^^^^^ not found in `Trait` + | + = note: an associated constant named `Trait::ASSOC` exists in another namespace error[E0747]: unresolved item provided when a constant was expected --> $DIR/assoc_const_as_type_argument.rs:8:11 diff --git a/tests/ui/const-generics/const-generic-function.rs b/tests/ui/const-generics/const-generic-function.rs index 03c94d90d105d..dcd16b4b722ea 100644 --- a/tests/ui/const-generics/const-generic-function.rs +++ b/tests/ui/const-generics/const-generic-function.rs @@ -13,7 +13,7 @@ const fn baz() -> i32 { const FOO: i32 = 3; fn main() { - foo::(); //~ ERROR expected type, found function `baz` + foo::(); //~ ERROR cannot find type `baz` in this scope //~^ ERROR unresolved item provided when a constant was expected foo::(); //~ ERROR expected type, found `1` foo::(); //~ ERROR expected type, found `1` diff --git a/tests/ui/const-generics/const-generic-function.stderr b/tests/ui/const-generics/const-generic-function.stderr index 5ad3f1006c17d..57f0af450a0f8 100644 --- a/tests/ui/const-generics/const-generic-function.stderr +++ b/tests/ui/const-generics/const-generic-function.stderr @@ -31,11 +31,13 @@ help: expressions must be enclosed in braces to be used as const generic argumen LL | foo::<{ bar(FOO, 2) }>(); | + + -error[E0573]: expected type, found function `baz` +error[E0573]: cannot find type `baz` in this scope --> $DIR/const-generic-function.rs:16:11 | LL | foo::(); - | ^^^^^ not a type + | ^^^ not found in this scope + | + = note: a function named `baz` exists in another namespace error[E0747]: unresolved item provided when a constant was expected --> $DIR/const-generic-function.rs:16:11 diff --git a/tests/ui/const-generics/generic_const_exprs/issue-69654.rs b/tests/ui/const-generics/generic_const_exprs/issue-69654.rs index 058f404df5783..6f3f7388076a1 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-69654.rs +++ b/tests/ui/const-generics/generic_const_exprs/issue-69654.rs @@ -3,7 +3,7 @@ trait Bar {} impl Bar for [u8; T] {} -//~^ ERROR expected value, found type parameter `T` +//~^ ERROR cannot find value `T` in this scope struct Foo {} impl Foo diff --git a/tests/ui/const-generics/generic_const_exprs/issue-69654.stderr b/tests/ui/const-generics/generic_const_exprs/issue-69654.stderr index 9b5e556b94ee9..a21a11a24c1b2 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-69654.stderr +++ b/tests/ui/const-generics/generic_const_exprs/issue-69654.stderr @@ -1,11 +1,10 @@ -error[E0423]: expected value, found type parameter `T` +error[E0423]: cannot find value `T` in this scope --> $DIR/issue-69654.rs:5:25 | LL | impl Bar for [u8; T] {} - | - ^ not a value - | | - | found this type parameter + | ^ not found in this scope | + = note: a type parameter named `T` exists in another namespace help: you might have meant to write a const parameter here | LL | impl Bar for [u8; T] {} diff --git a/tests/ui/const-generics/generic_const_exprs/unknown-alias-defkind-anonconst-ice-116710.rs b/tests/ui/const-generics/generic_const_exprs/unknown-alias-defkind-anonconst-ice-116710.rs index 81ac9979bd8c7..3685e71a4808d 100644 --- a/tests/ui/const-generics/generic_const_exprs/unknown-alias-defkind-anonconst-ice-116710.rs +++ b/tests/ui/const-generics/generic_const_exprs/unknown-alias-defkind-anonconst-ice-116710.rs @@ -4,7 +4,7 @@ #![allow(incomplete_features)] struct A; -//~^ ERROR expected value, found builtin type `u8` +//~^ ERROR cannot find value `u8` in this scope trait Trait {} impl Trait for A {} diff --git a/tests/ui/const-generics/generic_const_exprs/unknown-alias-defkind-anonconst-ice-116710.stderr b/tests/ui/const-generics/generic_const_exprs/unknown-alias-defkind-anonconst-ice-116710.stderr index e29c49ff0422c..a3b33fcbe6246 100644 --- a/tests/ui/const-generics/generic_const_exprs/unknown-alias-defkind-anonconst-ice-116710.stderr +++ b/tests/ui/const-generics/generic_const_exprs/unknown-alias-defkind-anonconst-ice-116710.stderr @@ -1,8 +1,10 @@ -error[E0423]: expected value, found builtin type `u8` +error[E0423]: cannot find value `u8` in this scope --> $DIR/unknown-alias-defkind-anonconst-ice-116710.rs:6:43 | LL | struct A; - | ^^ not a value + | ^^ not found in this scope + | + = note: a builtin type named `u8` exists in another namespace error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/incorrect-const-param.rs b/tests/ui/const-generics/incorrect-const-param.rs index 5f1d8ca2ae990..951a3c5ed6e53 100644 --- a/tests/ui/const-generics/incorrect-const-param.rs +++ b/tests/ui/const-generics/incorrect-const-param.rs @@ -13,11 +13,11 @@ where } // Forgot const -impl From<[T; N]> for VecWrapper //~ ERROR expected value, found type parameter `N` +impl From<[T; N]> for VecWrapper //~ ERROR cannot find value `N` in this scope where //~^ ERROR expected trait, found builtin type `usize` T: Clone, { - fn from(slice: [T; N]) -> Self { //~ ERROR expected value, found type parameter `N` + fn from(slice: [T; N]) -> Self { //~ ERROR cannot find value `N` in this scope VecWrapper(slice.to_vec()) } } @@ -33,11 +33,11 @@ where } // Forgot const and type -impl From<[T; N]> for VecWrapper //~ ERROR expected value, found type parameter `N` +impl From<[T; N]> for VecWrapper //~ ERROR cannot find value `N` in this scope where T: Clone, { - fn from(slice: [T; N]) -> Self { //~ ERROR expected value, found type parameter `N` + fn from(slice: [T; N]) -> Self { //~ ERROR cannot find value `N` in this scope VecWrapper(slice.to_vec()) } } diff --git a/tests/ui/const-generics/incorrect-const-param.stderr b/tests/ui/const-generics/incorrect-const-param.stderr index c5cf54500ee01..559b007cbd659 100644 --- a/tests/ui/const-generics/incorrect-const-param.stderr +++ b/tests/ui/const-generics/incorrect-const-param.stderr @@ -9,13 +9,13 @@ help: you likely meant to write the type of the const parameter here LL | impl From<[T; N]> for VecWrapper | ++++++++++++ -error[E0423]: expected value, found type parameter `N` +error[E0423]: cannot find value `N` in this scope --> $DIR/incorrect-const-param.rs:16:28 | LL | impl From<[T; N]> for VecWrapper - | - ^ not a value - | | - | found this type parameter + | ^ not found in this scope + | + = note: a type parameter named `N` exists in another namespace error[E0404]: expected trait, found builtin type `usize` --> $DIR/incorrect-const-param.rs:16:12 @@ -28,37 +28,33 @@ help: you might have meant to write a const parameter here LL | impl From<[T; N]> for VecWrapper | +++++ -error[E0423]: expected value, found type parameter `N` +error[E0423]: cannot find value `N` in this scope --> $DIR/incorrect-const-param.rs:20:24 | -LL | impl From<[T; N]> for VecWrapper - | - found this type parameter -... LL | fn from(slice: [T; N]) -> Self { - | ^ not a value + | ^ not found in this scope + | + = note: a type parameter named `N` exists in another namespace -error[E0423]: expected value, found type parameter `N` +error[E0423]: cannot find value `N` in this scope --> $DIR/incorrect-const-param.rs:36:21 | LL | impl From<[T; N]> for VecWrapper - | - ^ not a value - | | - | found this type parameter + | ^ not found in this scope | + = note: a type parameter named `N` exists in another namespace help: you might have meant to write a const parameter here | LL | impl From<[T; N]> for VecWrapper | +++++ ++++++++++++ -error[E0423]: expected value, found type parameter `N` +error[E0423]: cannot find value `N` in this scope --> $DIR/incorrect-const-param.rs:40:24 | -LL | impl From<[T; N]> for VecWrapper - | - found this type parameter -... LL | fn from(slice: [T; N]) -> Self { - | ^ not a value + | ^ not found in this scope | + = note: a type parameter named `N` exists in another namespace help: you might have meant to write a const parameter here | LL | impl From<[T; N]> for VecWrapper diff --git a/tests/ui/const-generics/mgca/adt_expr_erroneuous_inits.rs b/tests/ui/const-generics/mgca/adt_expr_erroneuous_inits.rs index 752844e4328f6..13016d02e4aee 100644 --- a/tests/ui/const-generics/mgca/adt_expr_erroneuous_inits.rs +++ b/tests/ui/const-generics/mgca/adt_expr_erroneuous_inits.rs @@ -21,6 +21,6 @@ fn bar() { //~^ ERROR: cannot find struct, variant or union type `Fooo` in this scope //~| ERROR: struct expression with invalid base path accepts::<{ NonStruct { }}>(); - //~^ ERROR: expected struct, variant or union type, found function `NonStruct` + //~^ ERROR: cannot find struct, variant or union type `NonStruct` in this scope //~| ERROR: struct expression with invalid base path } diff --git a/tests/ui/const-generics/mgca/adt_expr_erroneuous_inits.stderr b/tests/ui/const-generics/mgca/adt_expr_erroneuous_inits.stderr index 72e0e94ff625b..328a57bd0eed8 100644 --- a/tests/ui/const-generics/mgca/adt_expr_erroneuous_inits.stderr +++ b/tests/ui/const-generics/mgca/adt_expr_erroneuous_inits.stderr @@ -13,11 +13,13 @@ LL - accepts::<{ Fooo:: { field: const { 1 } }}>(); LL + accepts::<{ Foo:: { field: const { 1 } }}>(); | -error[E0574]: expected struct, variant or union type, found function `NonStruct` +error[E0574]: cannot find struct, variant or union type `NonStruct` in this scope --> $DIR/adt_expr_erroneuous_inits.rs:23:17 | LL | accepts::<{ NonStruct { }}>(); - | ^^^^^^^^^ not a struct, variant or union type + | ^^^^^^^^^ not found in this scope + | + = note: a function named `NonStruct` exists in another namespace error: struct expression with missing field initialiser for `field` --> $DIR/adt_expr_erroneuous_inits.rs:16:17 diff --git a/tests/ui/const-generics/min_const_generics/const-expression-suggest-missing-braces.rs b/tests/ui/const-generics/min_const_generics/const-expression-suggest-missing-braces.rs index e12e07a28e763..1867c3369006e 100644 --- a/tests/ui/const-generics/min_const_generics/const-expression-suggest-missing-braces.rs +++ b/tests/ui/const-generics/min_const_generics/const-expression-suggest-missing-braces.rs @@ -9,8 +9,8 @@ fn b() { // FIXME(const_generics): these diagnostics are awful, because trait objects without `dyn` were // a terrible mistake. foo::(); - //~^ ERROR expected trait, found constant `BAR` - //~| ERROR expected trait, found constant `BAR` + //~^ ERROR cannot find trait `BAR` in this scope + //~| ERROR cannot find trait `BAR` in this scope //~| ERROR type provided when a constant was expected } fn c() { diff --git a/tests/ui/const-generics/min_const_generics/const-expression-suggest-missing-braces.stderr b/tests/ui/const-generics/min_const_generics/const-expression-suggest-missing-braces.stderr index d9bcc523b1fc4..0deca42e3aade 100644 --- a/tests/ui/const-generics/min_const_generics/const-expression-suggest-missing-braces.stderr +++ b/tests/ui/const-generics/min_const_generics/const-expression-suggest-missing-braces.stderr @@ -119,17 +119,21 @@ help: expressions must be enclosed in braces to be used as const generic argumen LL | foo::<{ BAR - bar::() }>(); | + + -error[E0404]: expected trait, found constant `BAR` +error[E0404]: cannot find trait `BAR` in this scope --> $DIR/const-expression-suggest-missing-braces.rs:11:11 | LL | foo::(); - | ^^^ not a trait + | ^^^ not found in this scope + | + = note: a constant named `BAR` exists in another namespace -error[E0404]: expected trait, found constant `BAR` +error[E0404]: cannot find trait `BAR` in this scope --> $DIR/const-expression-suggest-missing-braces.rs:11:17 | LL | foo::(); - | ^^^ not a trait + | ^^^ not found in this scope + | + = note: a constant named `BAR` exists in another namespace error[E0747]: type provided when a constant was expected --> $DIR/const-expression-suggest-missing-braces.rs:11:11 diff --git a/tests/ui/const-generics/struct-with-invalid-const-param.rs b/tests/ui/const-generics/struct-with-invalid-const-param.rs index be1c4b0e8e80e..89f4c83454d89 100644 --- a/tests/ui/const-generics/struct-with-invalid-const-param.rs +++ b/tests/ui/const-generics/struct-with-invalid-const-param.rs @@ -1,5 +1,5 @@ // Checks that a const param cannot be stored in a struct. -struct S(C); //~ ERROR expected type, found const parameter +struct S(C); //~ ERROR cannot find type `C` in this scope fn main() {} diff --git a/tests/ui/const-generics/struct-with-invalid-const-param.stderr b/tests/ui/const-generics/struct-with-invalid-const-param.stderr index 734a42fe5266c..8b6766a8ad927 100644 --- a/tests/ui/const-generics/struct-with-invalid-const-param.stderr +++ b/tests/ui/const-generics/struct-with-invalid-const-param.stderr @@ -1,8 +1,10 @@ -error[E0573]: expected type, found const parameter `C` +error[E0573]: cannot find type `C` in this scope --> $DIR/struct-with-invalid-const-param.rs:3:23 | LL | struct S(C); - | ^ not a type + | ^ not found in this scope + | + = note: a const parameter named `C` exists in another namespace error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/type_not_in_scope.rs b/tests/ui/const-generics/type_not_in_scope.rs index 1eb265d74d1c7..13801414b2ee1 100644 --- a/tests/ui/const-generics/type_not_in_scope.rs +++ b/tests/ui/const-generics/type_not_in_scope.rs @@ -5,7 +5,7 @@ impl X { } } fn getn() -> [u8; N] {} -//~^ ERROR: expected type, found built-in attribute `cfg_attr` +//~^ ERROR: cannot find type `cfg_attr` in this scope //~| ERROR: mismatched types fn main() {} diff --git a/tests/ui/const-generics/type_not_in_scope.stderr b/tests/ui/const-generics/type_not_in_scope.stderr index f676108d37d0d..0ce0416e4a0cb 100644 --- a/tests/ui/const-generics/type_not_in_scope.stderr +++ b/tests/ui/const-generics/type_not_in_scope.stderr @@ -4,11 +4,13 @@ error[E0425]: cannot find type `X` in this scope LL | impl X { | ^ not found in this scope -error[E0573]: expected type, found built-in attribute `cfg_attr` +error[E0573]: cannot find type `cfg_attr` in this scope --> $DIR/type_not_in_scope.rs:7:18 | LL | fn getn() -> [u8; N] {} - | ^^^^^^^^ not a type + | ^^^^^^^^ not found in this scope + | + = note: a built-in attribute named `cfg_attr` exists in another namespace error[E0308]: mismatched types --> $DIR/type_not_in_scope.rs:7:33 diff --git a/tests/ui/coroutine/coroutine-yielding-or-returning-itself.stderr b/tests/ui/coroutine/coroutine-yielding-or-returning-itself.stderr index 0c153e2d0af36..1b640ebe2b894 100644 --- a/tests/ui/coroutine/coroutine-yielding-or-returning-itself.stderr +++ b/tests/ui/coroutine/coroutine-yielding-or-returning-itself.stderr @@ -1,4 +1,4 @@ -error[E0271]: type mismatch resolving `<{coroutine@$DIR/coroutine-yielding-or-returning-itself.rs:15:47: 15:49} as Coroutine>::Return == {coroutine@$DIR/coroutine-yielding-or-returning-itself.rs:15:47: 15:49}` +error[E0271]: type mismatch resolving `<{coroutine@coroutine-yielding-or-returning-itself.rs:15:47} as Coroutine>::Return == {coroutine@coroutine-yielding-or-returning-itself.rs:15:47}` --> $DIR/coroutine-yielding-or-returning-itself.rs:15:47 | LL | want_cyclic_coroutine_return(#[coroutine] || { @@ -23,7 +23,7 @@ LL | pub fn want_cyclic_coroutine_return(_: T) LL | where T: Coroutine | ^^^^^^^^^^ required by this bound in `want_cyclic_coroutine_return` -error[E0271]: type mismatch resolving `<{coroutine@$DIR/coroutine-yielding-or-returning-itself.rs:28:46: 28:48} as Coroutine>::Yield == {coroutine@$DIR/coroutine-yielding-or-returning-itself.rs:28:46: 28:48}` +error[E0271]: type mismatch resolving `<{coroutine@coroutine-yielding-or-returning-itself.rs:28:46} as Coroutine>::Yield == {coroutine@coroutine-yielding-or-returning-itself.rs:28:46}` --> $DIR/coroutine-yielding-or-returning-itself.rs:28:46 | LL | want_cyclic_coroutine_yield(#[coroutine] || { diff --git a/tests/ui/coroutine/resume-arg-late-bound.stderr b/tests/ui/coroutine/resume-arg-late-bound.stderr index 646abaf4f7bde..0a6fb8dfcbb6c 100644 --- a/tests/ui/coroutine/resume-arg-late-bound.stderr +++ b/tests/ui/coroutine/resume-arg-late-bound.stderr @@ -4,7 +4,7 @@ error: implementation of `Coroutine` is not general enough LL | test(gen); | ^^^^^^^^^ implementation of `Coroutine` is not general enough | - = note: `{coroutine@$DIR/resume-arg-late-bound.rs:11:28: 11:44}` must implement `Coroutine<&'1 mut bool>`, for any lifetime `'1`... + = note: `{coroutine@...}` must implement `Coroutine<&'1 mut bool>`, for any lifetime `'1`... = note: ...but it actually implements `Coroutine<&'2 mut bool>`, for some specific lifetime `'2` error: aborting due to 1 previous error diff --git a/tests/ui/coroutine/type-mismatch-signature-deduction.stderr b/tests/ui/coroutine/type-mismatch-signature-deduction.stderr index 64dc3a8b1f80c..9391325901ec6 100644 --- a/tests/ui/coroutine/type-mismatch-signature-deduction.stderr +++ b/tests/ui/coroutine/type-mismatch-signature-deduction.stderr @@ -18,7 +18,7 @@ LL | Ok(5) LL | Err(5) | ++++ + -error[E0271]: type mismatch resolving `<{coroutine@$DIR/type-mismatch-signature-deduction.rs:8:5: 8:7} as Coroutine>::Return == i32` +error[E0271]: type mismatch resolving `<{coroutine@type-mismatch-signature-deduction.rs:8:5} as Coroutine>::Return == i32` --> $DIR/type-mismatch-signature-deduction.rs:5:13 | LL | fn foo() -> impl Coroutine { diff --git a/tests/ui/cross-crate/unit-struct.rs b/tests/ui/cross-crate/unit-struct.rs index 1517f843eff31..34e412ba3105b 100644 --- a/tests/ui/cross-crate/unit-struct.rs +++ b/tests/ui/cross-crate/unit-struct.rs @@ -7,8 +7,8 @@ extern crate xcrate_unit_struct; fn main() { let _ = xcrate_unit_struct::StructWithFields; - //~^ ERROR expected value, found struct `xcrate_unit_struct::StructWithFields` + //~^ ERROR cannot find value `StructWithFields` in crate `xcrate_unit_struct` let _ = xcrate_unit_struct::StructWithPrivFields; - //~^ ERROR expected value, found struct `xcrate_unit_struct::StructWithPrivFields` + //~^ ERROR cannot find value `StructWithPrivFields` in crate `xcrate_unit_struct` let _ = xcrate_unit_struct::Struct; } diff --git a/tests/ui/cross-crate/unit-struct.stderr b/tests/ui/cross-crate/unit-struct.stderr index a7e3e4685a997..f158602456cea 100644 --- a/tests/ui/cross-crate/unit-struct.stderr +++ b/tests/ui/cross-crate/unit-struct.stderr @@ -1,24 +1,30 @@ -error[E0423]: expected value, found struct `xcrate_unit_struct::StructWithFields` - --> $DIR/unit-struct.rs:9:13 +error[E0423]: cannot find value `StructWithFields` in crate `xcrate_unit_struct` + --> $DIR/unit-struct.rs:9:33 | LL | let _ = xcrate_unit_struct::StructWithFields; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use struct literal syntax instead: `xcrate_unit_struct::StructWithFields { foo: val }` + | --------------------^^^^^^^^^^^^^^^^ + | | + | help: use struct literal syntax instead: `xcrate_unit_struct::StructWithFields { foo: val }` | ::: $DIR/auxiliary/xcrate_unit_struct.rs:20:1 | LL | pub struct StructWithFields { | --------------------------- `xcrate_unit_struct::StructWithFields` defined here + | + = note: a struct named `xcrate_unit_struct::StructWithFields` exists in another namespace -error[E0423]: expected value, found struct `xcrate_unit_struct::StructWithPrivFields` - --> $DIR/unit-struct.rs:11:13 +error[E0423]: cannot find value `StructWithPrivFields` in crate `xcrate_unit_struct` + --> $DIR/unit-struct.rs:11:33 | LL | let _ = xcrate_unit_struct::StructWithPrivFields; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^ | ::: $DIR/auxiliary/xcrate_unit_struct.rs:25:1 | LL | pub struct StructWithPrivFields { | ------------------------------- `xcrate_unit_struct::StructWithPrivFields` defined here + | + = note: a struct named `xcrate_unit_struct::StructWithPrivFields` exists in another namespace error: aborting due to 2 previous errors diff --git a/tests/ui/delegation/bad-resolve.rs b/tests/ui/delegation/bad-resolve.rs index 3700b04160292..eb31c20081461 100644 --- a/tests/ui/delegation/bad-resolve.rs +++ b/tests/ui/delegation/bad-resolve.rs @@ -25,7 +25,7 @@ impl Trait for S { //~| ERROR expected function, found associated constant `Trait::C` reuse ::Type; //~^ ERROR item `Type` is an associated method, which doesn't match its trait `Trait` - //~| ERROR expected method or associated constant, found associated type `Trait::Type` + //~| ERROR cannot find method or associated constant `Type` in trait `Trait` reuse ::baz; //~^ ERROR method `baz` is not a member of trait `Trait` //~| ERROR cannot find method or associated constant `baz` in trait `Trait` @@ -42,6 +42,6 @@ impl Trait for S { mod prefix {} reuse unresolved_prefix::{a, b, c}; //~ ERROR cannot find module or crate `unresolved_prefix` reuse prefix::{self, super, crate}; //~ ERROR `crate` in paths can only be used in start position -//~^ ERROR expected function, found module `prefix::self` +//~^ ERROR cannot find function `self` in module `prefix` fn main() {} diff --git a/tests/ui/delegation/bad-resolve.stderr b/tests/ui/delegation/bad-resolve.stderr index 29460e0ce982f..1e787c224e8b3 100644 --- a/tests/ui/delegation/bad-resolve.stderr +++ b/tests/ui/delegation/bad-resolve.stderr @@ -40,11 +40,13 @@ error[E0423]: expected function, found associated constant `Trait::C` LL | reuse ::C; | ^^^^^^^^^^^^^^^ not a function -error[E0575]: expected method or associated constant, found associated type `Trait::Type` - --> $DIR/bad-resolve.rs:26:11 +error[E0575]: cannot find method or associated constant `Type` in trait `Trait` + --> $DIR/bad-resolve.rs:26:25 | LL | reuse ::Type; - | ^^^^^^^^^^^^^^^^^^ not a method or associated constant + | ^^^^ not found in `Trait` + | + = note: an associated type named `Trait::Type` exists in another namespace error[E0576]: cannot find method or associated constant `baz` in trait `Trait` --> $DIR/bad-resolve.rs:29:25 @@ -82,11 +84,13 @@ LL - reuse Trait::foo2 { self.0 } LL + reuse Trait::foo { self.0 } | -error[E0423]: expected function, found module `prefix::self` - --> $DIR/bad-resolve.rs:44:7 +error[E0423]: cannot find function `self` in module `prefix` + --> $DIR/bad-resolve.rs:44:16 | LL | reuse prefix::{self, super, crate}; - | ^^^^^^ not a function + | ^^^^ not found in `prefix` + | + = note: a module named `prefix::self` exists in another namespace error[E0186]: method `foo` has a `&self` declaration in the trait, but not in the impl --> $DIR/bad-resolve.rs:34:11 diff --git a/tests/ui/delegation/generics/def-path-hash-collision-ice-153410.rs b/tests/ui/delegation/generics/def-path-hash-collision-ice-153410.rs index 9276a0d220ad0..a35386fa3720e 100644 --- a/tests/ui/delegation/generics/def-path-hash-collision-ice-153410.rs +++ b/tests/ui/delegation/generics/def-path-hash-collision-ice-153410.rs @@ -19,7 +19,7 @@ impl Iterator { //~^ ERROR: expected a type, found a trait [E0782] reuse< < fn()>::Output>::Item as Iterator>::*; - //~^ ERROR: expected method or associated constant, found associated type `Iterator::Item` + //~^ ERROR: cannot find method or associated constant `Item` in trait `Iterator` //~| ERROR: ambiguous associated type } diff --git a/tests/ui/delegation/generics/def-path-hash-collision-ice-153410.stderr b/tests/ui/delegation/generics/def-path-hash-collision-ice-153410.stderr index 4b4c1bc006632..99bb6ac7e66be 100644 --- a/tests/ui/delegation/generics/def-path-hash-collision-ice-153410.stderr +++ b/tests/ui/delegation/generics/def-path-hash-collision-ice-153410.stderr @@ -1,8 +1,10 @@ -error[E0575]: expected method or associated constant, found associated type `Iterator::Item` - --> $DIR/def-path-hash-collision-ice-153410.rs:21:10 +error[E0575]: cannot find method or associated constant `Item` in trait `Iterator` + --> $DIR/def-path-hash-collision-ice-153410.rs:21:58 | LL | reuse< < fn()>::Output>::Item as Iterator>::*; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a method or associated constant + | ^ not found in `Iterator` + | + = note: an associated type named `Iterator::Item` exists in another namespace error[E0782]: expected a type, found a trait --> $DIR/def-path-hash-collision-ice-153410.rs:19:6 diff --git a/tests/ui/delegation/generics/generics-gen-args-errors.rs b/tests/ui/delegation/generics/generics-gen-args-errors.rs index 6a8d1674fe184..e71f6df3c11c4 100644 --- a/tests/ui/delegation/generics/generics-gen-args-errors.rs +++ b/tests/ui/delegation/generics/generics-gen-args-errors.rs @@ -11,7 +11,7 @@ mod test_1 { //~^ ERROR: function takes 3 generic arguments but 6 generic arguments were supplied bar::(); - //~^ ERROR: expected value, found struct `String` [E0423] + //~^ ERROR: cannot find value `String` in this scope [E0423] bar::<'static, 'static, 'static, 'static, 'static>(); //~^ ERROR: function takes 2 lifetime arguments but 5 lifetime arguments were supplied diff --git a/tests/ui/delegation/generics/generics-gen-args-errors.stderr b/tests/ui/delegation/generics/generics-gen-args-errors.stderr index c08e23e6c016a..600b30f19ba6f 100644 --- a/tests/ui/delegation/generics/generics-gen-args-errors.stderr +++ b/tests/ui/delegation/generics/generics-gen-args-errors.stderr @@ -59,7 +59,7 @@ help: consider introducing lifetime `'a` here LL | reuse foo'a, ::<"asdasd", asd, "askdn", 'static, 'a> as bar7; | +++ -error[E0423]: expected value, found struct `String` +error[E0423]: cannot find value `String` in this scope --> $DIR/generics-gen-args-errors.rs:13:33 | LL | bar::(); @@ -68,6 +68,8 @@ LL | bar::(); --> $SRC_DIR/alloc/src/string.rs:LL:COL | = note: `String` defined here + | + = note: a struct named `String` exists in another namespace error[E0425]: cannot find type `asd` in this scope --> $DIR/generics-gen-args-errors.rs:27:15 diff --git a/tests/ui/delegation/generics/synth-params-ice-143498.rs b/tests/ui/delegation/generics/synth-params-ice-143498.rs index ca6d2d5c193b0..366451ccdc012 100644 --- a/tests/ui/delegation/generics/synth-params-ice-143498.rs +++ b/tests/ui/delegation/generics/synth-params-ice-143498.rs @@ -19,7 +19,7 @@ impl X { //~^ ERROR: cannot find type `X` in this scope reuse< std::fmt::Debug as Iterator >::*; - //~^ ERROR: expected method or associated constant, found associated type `Iterator::Item` + //~^ ERROR: cannot find method or associated constant `Item` in trait `Iterator` //~| ERROR: expected a type, found a trait } diff --git a/tests/ui/delegation/generics/synth-params-ice-143498.stderr b/tests/ui/delegation/generics/synth-params-ice-143498.stderr index 17154f9779475..8db4a84d76c53 100644 --- a/tests/ui/delegation/generics/synth-params-ice-143498.stderr +++ b/tests/ui/delegation/generics/synth-params-ice-143498.stderr @@ -4,11 +4,13 @@ error[E0425]: cannot find type `X` in this scope LL | impl X { | ^ not found in this scope -error[E0575]: expected method or associated constant, found associated type `Iterator::Item` - --> $DIR/synth-params-ice-143498.rs:21:10 +error[E0575]: cannot find method or associated constant `Item` in trait `Iterator` + --> $DIR/synth-params-ice-143498.rs:21:43 | LL | reuse< std::fmt::Debug as Iterator >::*; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a method or associated constant + | ^ not found in `Iterator` + | + = note: an associated type named `Iterator::Item` exists in another namespace error[E0782]: expected a type, found a trait --> $DIR/synth-params-ice-143498.rs:21:12 diff --git a/tests/ui/delegation/glob-non-fn.rs b/tests/ui/delegation/glob-non-fn.rs index 14a78e7b65e25..939c5db6a0e8f 100644 --- a/tests/ui/delegation/glob-non-fn.rs +++ b/tests/ui/delegation/glob-non-fn.rs @@ -31,7 +31,7 @@ impl Trait for Bad { //~ ERROR not all trait items implemented, missing: `CONST` //~| ERROR item `Type` is an associated method, which doesn't match its trait `Trait` //~| ERROR duplicate definitions with name `method` //~| ERROR expected function, found associated constant `Trait::CONST` - //~| ERROR expected function, found associated type `Trait::Type` + //~| ERROR cannot find function `Type` in trait `Trait` } fn main() {} diff --git a/tests/ui/delegation/glob-non-fn.stderr b/tests/ui/delegation/glob-non-fn.stderr index 3353290fc5b10..6f7010d43d8ae 100644 --- a/tests/ui/delegation/glob-non-fn.stderr +++ b/tests/ui/delegation/glob-non-fn.stderr @@ -34,11 +34,13 @@ error[E0423]: expected function, found associated constant `Trait::CONST` LL | reuse Trait::* { &self.0 } | ^^^^^ not a function -error[E0423]: expected function, found associated type `Trait::Type` - --> $DIR/glob-non-fn.rs:29:11 +error[E0423]: cannot find function `Type` in trait `Trait` + --> $DIR/glob-non-fn.rs:29:18 | LL | reuse Trait::* { &self.0 } - | ^^^^^ not a function + | ^ not found in `Trait` + | + = note: an associated type named `Trait::Type` exists in another namespace error[E0046]: not all trait items implemented, missing: `CONST`, `Type`, `method` --> $DIR/glob-non-fn.rs:28:1 diff --git a/tests/ui/delegation/ice-non-fn-target-in-trait-impl.rs b/tests/ui/delegation/ice-non-fn-target-in-trait-impl.rs index a88a2ef0613ad..7a61da79f3c8f 100644 --- a/tests/ui/delegation/ice-non-fn-target-in-trait-impl.rs +++ b/tests/ui/delegation/ice-non-fn-target-in-trait-impl.rs @@ -11,9 +11,9 @@ trait Trait { impl Trait for () { reuse std::path::<> as bar; - //~^ ERROR expected function, found module `std::path` + //~^ ERROR cannot find function `path` in crate `std` reuse core::<> as bar2; - //~^ ERROR expected function, found crate `core` + //~^ ERROR cannot find function `core` in this scope } fn main() {} diff --git a/tests/ui/delegation/ice-non-fn-target-in-trait-impl.stderr b/tests/ui/delegation/ice-non-fn-target-in-trait-impl.stderr index 0bf5846cb782c..e9eca6b35bb51 100644 --- a/tests/ui/delegation/ice-non-fn-target-in-trait-impl.stderr +++ b/tests/ui/delegation/ice-non-fn-target-in-trait-impl.stderr @@ -1,14 +1,18 @@ -error[E0423]: expected function, found module `std::path` - --> $DIR/ice-non-fn-target-in-trait-impl.rs:13:11 +error[E0423]: cannot find function `path` in crate `std` + --> $DIR/ice-non-fn-target-in-trait-impl.rs:13:16 | LL | reuse std::path::<> as bar; - | ^^^^^^^^^^^^^ not a function + | ^^^^ not found in `std` + | + = note: a module named `std::path` exists in another namespace -error[E0423]: expected function, found crate `core` +error[E0423]: cannot find function `core` in this scope --> $DIR/ice-non-fn-target-in-trait-impl.rs:15:11 | LL | reuse core::<> as bar2; - | ^^^^^^^^ not a function + | ^^^^ not found in this scope + | + = note: a crate named `core` exists in another namespace error: aborting due to 2 previous errors diff --git a/tests/ui/delegation/impl-reuse-non-reuse-items.rs b/tests/ui/delegation/impl-reuse-non-reuse-items.rs index 0dbe8016c1e8e..23c22a61cbb0a 100644 --- a/tests/ui/delegation/impl-reuse-non-reuse-items.rs +++ b/tests/ui/delegation/impl-reuse-non-reuse-items.rs @@ -24,7 +24,7 @@ mod non_delegatable_items { //~| ERROR item `Type` is an associated method, which doesn't match its trait `Trait` //~| ERROR duplicate definitions with name `method` //~| ERROR expected function, found associated constant `Trait::CONST` - //~| ERROR expected function, found associated type `Trait::Type` + //~| ERROR cannot find function `Type` in trait `Trait` //~| ERROR not all trait items implemented, missing: `CONST`, `Type`, `method` } diff --git a/tests/ui/delegation/impl-reuse-non-reuse-items.stderr b/tests/ui/delegation/impl-reuse-non-reuse-items.stderr index 044c9aa5a7ab9..2bd488e9fb3d8 100644 --- a/tests/ui/delegation/impl-reuse-non-reuse-items.stderr +++ b/tests/ui/delegation/impl-reuse-non-reuse-items.stderr @@ -34,11 +34,13 @@ error[E0423]: expected function, found associated constant `Trait::CONST` LL | reuse impl Trait for S { &self.0 } | ^^^^^ not a function -error[E0423]: expected function, found associated type `Trait::Type` - --> $DIR/impl-reuse-non-reuse-items.rs:22:16 +error[E0423]: cannot find function `Type` in trait `Trait` + --> $DIR/impl-reuse-non-reuse-items.rs:22:5 | LL | reuse impl Trait for S { &self.0 } - | ^^^^^ not a function + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in `Trait` + | + = note: an associated type named `Trait::Type` exists in another namespace error[E0046]: not all trait items implemented, missing: `CONST`, `Type`, `method` --> $DIR/impl-reuse-non-reuse-items.rs:22:5 diff --git a/tests/ui/delegation/impl-reuse-self-hygiene.rs b/tests/ui/delegation/impl-reuse-self-hygiene.rs index bbb0c4c04498f..6d58100dc88ee 100644 --- a/tests/ui/delegation/impl-reuse-self-hygiene.rs +++ b/tests/ui/delegation/impl-reuse-self-hygiene.rs @@ -7,21 +7,21 @@ trait Trait { struct S1(u8); macro_rules! one_line_reuse { ($self:ident) => { reuse impl Trait for S1 { $self.0 } } } -//~^ ERROR expected value, found module `self` -//~| ERROR expected value, found module `self` one_line_reuse!(self); +//~^ ERROR cannot find value `self` in this scope +//~| ERROR cannot find value `self` in this scope struct S2(u8); macro_rules! one_line_reuse_expr { ($x:expr) => { reuse impl Trait for S2 { $x } } } one_line_reuse_expr!(self.0); -//~^ ERROR expected value, found module `self` -//~| ERROR expected value, found module `self` +//~^ ERROR cannot find value `self` in this scope +//~| ERROR cannot find value `self` in this scope struct S3(u8); macro_rules! s3 { () => { S3 } } macro_rules! one_line_reuse_expr2 { ($x:expr) => { reuse impl Trait for s3!() { $x } } } one_line_reuse_expr2!(self.0); -//~^ ERROR expected value, found module `self` -//~| ERROR expected value, found module `self` +//~^ ERROR cannot find value `self` in this scope +//~| ERROR cannot find value `self` in this scope fn main() {} diff --git a/tests/ui/delegation/impl-reuse-self-hygiene.stderr b/tests/ui/delegation/impl-reuse-self-hygiene.stderr index 748e36cf55fd8..18e6f0e0f436e 100644 --- a/tests/ui/delegation/impl-reuse-self-hygiene.stderr +++ b/tests/ui/delegation/impl-reuse-self-hygiene.stderr @@ -1,41 +1,43 @@ -error[E0424]: expected value, found module `self` - --> $DIR/impl-reuse-self-hygiene.rs:9:76 +error[E0424]: cannot find value `self` in this scope + --> $DIR/impl-reuse-self-hygiene.rs:10:17 | LL | macro_rules! one_line_reuse { ($self:ident) => { reuse impl Trait for S1 { $self.0 } } } - | --------------------------^^^^^---- + | ----------------------------------- | | | + | | due to this macro variable | | `self` value is a keyword only available in methods with a `self` parameter | `self` not allowed in an implementation -... LL | one_line_reuse!(self); - | --------------------- in this macro invocation + | ^^^^ | - = note: this error originates in the macro `one_line_reuse` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: a module named `self` exists in another namespace -error[E0424]: expected value, found module `self` - --> $DIR/impl-reuse-self-hygiene.rs:9:76 +error[E0424]: cannot find value `self` in this scope + --> $DIR/impl-reuse-self-hygiene.rs:10:17 | LL | macro_rules! one_line_reuse { ($self:ident) => { reuse impl Trait for S1 { $self.0 } } } - | --------------------------^^^^^---- + | ----------------------------------- | | | + | | due to this macro variable | | `self` value is a keyword only available in methods with a `self` parameter | `self` not allowed in an implementation -... LL | one_line_reuse!(self); - | --------------------- in this macro invocation + | ^^^^ | + = note: a module named `self` exists in another namespace = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - = note: this error originates in the macro `one_line_reuse` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0424]: expected value, found module `self` +error[E0424]: cannot find value `self` in this scope --> $DIR/impl-reuse-self-hygiene.rs:16:22 | LL | macro_rules! one_line_reuse_expr { ($x:expr) => { reuse impl Trait for S2 { $x } } } | ------------------------------ `self` not allowed in an implementation LL | one_line_reuse_expr!(self.0); | ^^^^ `self` value is a keyword only available in methods with a `self` parameter + | + = note: a module named `self` exists in another namespace -error[E0424]: expected value, found module `self` +error[E0424]: cannot find value `self` in this scope --> $DIR/impl-reuse-self-hygiene.rs:16:22 | LL | macro_rules! one_line_reuse_expr { ($x:expr) => { reuse impl Trait for S2 { $x } } } @@ -43,17 +45,20 @@ LL | macro_rules! one_line_reuse_expr { ($x:expr) => { reuse impl Trait for S2 { LL | one_line_reuse_expr!(self.0); | ^^^^ `self` value is a keyword only available in methods with a `self` parameter | + = note: a module named `self` exists in another namespace = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0424]: expected value, found module `self` +error[E0424]: cannot find value `self` in this scope --> $DIR/impl-reuse-self-hygiene.rs:23:23 | LL | macro_rules! one_line_reuse_expr2 { ($x:expr) => { reuse impl Trait for s3!() { $x } } } | --------------------------------- `self` not allowed in an implementation LL | one_line_reuse_expr2!(self.0); | ^^^^ `self` value is a keyword only available in methods with a `self` parameter + | + = note: a module named `self` exists in another namespace -error[E0424]: expected value, found module `self` +error[E0424]: cannot find value `self` in this scope --> $DIR/impl-reuse-self-hygiene.rs:23:23 | LL | macro_rules! one_line_reuse_expr2 { ($x:expr) => { reuse impl Trait for s3!() { $x } } } @@ -61,6 +66,7 @@ LL | macro_rules! one_line_reuse_expr2 { ($x:expr) => { reuse impl Trait for s3! LL | one_line_reuse_expr2!(self.0); | ^^^^ `self` value is a keyword only available in methods with a `self` parameter | + = note: a module named `self` exists in another namespace = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: aborting due to 6 previous errors diff --git a/tests/ui/delegation/reuse-trait-path-with-empty-generics.rs b/tests/ui/delegation/reuse-trait-path-with-empty-generics.rs index b79f5b7eaf09b..a3e4fd8f9e9af 100644 --- a/tests/ui/delegation/reuse-trait-path-with-empty-generics.rs +++ b/tests/ui/delegation/reuse-trait-path-with-empty-generics.rs @@ -7,7 +7,7 @@ trait Trait { impl Trait for () { reuse Trait::<> as bar4; - //~^ ERROR expected function, found trait `Trait` + //~^ ERROR cannot find function `Trait` in this scope } fn main() {} diff --git a/tests/ui/delegation/reuse-trait-path-with-empty-generics.stderr b/tests/ui/delegation/reuse-trait-path-with-empty-generics.stderr index 5ec13f3703bdc..665ecb0005747 100644 --- a/tests/ui/delegation/reuse-trait-path-with-empty-generics.stderr +++ b/tests/ui/delegation/reuse-trait-path-with-empty-generics.stderr @@ -1,8 +1,10 @@ -error[E0423]: expected function, found trait `Trait` +error[E0423]: cannot find function `Trait` in this scope --> $DIR/reuse-trait-path-with-empty-generics.rs:9:11 | LL | reuse Trait::<> as bar4; - | ^^^^^^^^^ not a function + | ^^^^^ not found in this scope + | + = note: a trait named `Trait` exists in another namespace error: aborting due to 1 previous error diff --git a/tests/ui/delegation/self-hygiene.rs b/tests/ui/delegation/self-hygiene.rs index db0049c33be01..611ab007abeea 100644 --- a/tests/ui/delegation/self-hygiene.rs +++ b/tests/ui/delegation/self-hygiene.rs @@ -1,8 +1,8 @@ #![feature(fn_delegation)] macro_rules! emit_self { () => { self } } -//~^ ERROR expected value, found module `self` -//~| ERROR expected value, found module `self` +//~^ ERROR cannot find value `self` in this scope +//~| ERROR cannot find value `self` in this scope struct S; impl S { diff --git a/tests/ui/delegation/self-hygiene.stderr b/tests/ui/delegation/self-hygiene.stderr index 1ccb196dbbadc..a0e14ed3cc259 100644 --- a/tests/ui/delegation/self-hygiene.stderr +++ b/tests/ui/delegation/self-hygiene.stderr @@ -1,4 +1,4 @@ -error[E0424]: expected value, found module `self` +error[E0424]: cannot find value `self` in this scope --> $DIR/self-hygiene.rs:3:34 | LL | macro_rules! emit_self { () => { self } } @@ -10,9 +10,10 @@ LL | | emit_self!(); LL | | } | |_____- this function has a `self` parameter, but a macro invocation can only access identifiers it receives from parameters | + = note: a module named `self` exists in another namespace = note: this error originates in the macro `emit_self` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0424]: expected value, found module `self` +error[E0424]: cannot find value `self` in this scope --> $DIR/self-hygiene.rs:3:34 | LL | macro_rules! emit_self { () => { self } } @@ -24,6 +25,7 @@ LL | | emit_self!() LL | | } | |_- delegation supports a `self` parameter, but a macro invocation can only access identifiers it receives from parameters | + = note: a module named `self` exists in another namespace = note: this error originates in the macro `emit_self` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors diff --git a/tests/ui/delegation/target-expr.rs b/tests/ui/delegation/target-expr.rs index b4b3a31f437fc..e9d93c0a01002 100644 --- a/tests/ui/delegation/target-expr.rs +++ b/tests/ui/delegation/target-expr.rs @@ -31,7 +31,7 @@ fn main() { reuse_ptr(0) } self.0; - //~^ ERROR expected value, found module `self` + //~^ ERROR cannot find value `self` in this scope let z = x; //~^ ERROR cannot find value `x` in this scope } diff --git a/tests/ui/delegation/target-expr.stderr b/tests/ui/delegation/target-expr.stderr index 2ceefbf929b9f..2f724f9bdd073 100644 --- a/tests/ui/delegation/target-expr.stderr +++ b/tests/ui/delegation/target-expr.stderr @@ -18,7 +18,7 @@ LL | let x = y; | = help: use the `|| { ... }` closure form instead -error[E0424]: expected value, found module `self` +error[E0424]: cannot find value `self` in this scope --> $DIR/target-expr.rs:33:5 | LL | fn main() { @@ -26,6 +26,8 @@ LL | fn main() { ... LL | self.0; | ^^^^ `self` value is a keyword only available in methods with a `self` parameter + | + = note: a module named `self` exists in another namespace error[E0425]: cannot find value `x` in this scope --> $DIR/target-expr.rs:35:13 diff --git a/tests/ui/did_you_mean/issue-43871-enum-instead-of-variant.rs b/tests/ui/did_you_mean/issue-43871-enum-instead-of-variant.rs index 9602d27469427..764869f973bd3 100644 --- a/tests/ui/did_you_mean/issue-43871-enum-instead-of-variant.rs +++ b/tests/ui/did_you_mean/issue-43871-enum-instead-of-variant.rs @@ -16,21 +16,21 @@ enum ManyVariants { } fn result_test() { - let x = Option(1); //~ ERROR expected function, tuple struct or tuple variant, found enum + let x = Option(1); //~ ERROR cannot find function, tuple struct or tuple variant `Option` in this scope - if let Option(_) = x { //~ ERROR expected tuple struct or tuple variant, found enum + if let Option(_) = x { //~ ERROR cannot find tuple struct or tuple variant `Option` in this scope println!("It is OK."); } let y = Example::Ex(String::from("test")); - if let Example(_) = y { //~ ERROR expected tuple struct or tuple variant, found enum + if let Example(_) = y { //~ ERROR cannot find tuple struct or tuple variant `Example` in this scope println!("It is OK."); } - let y = Void(); //~ ERROR expected function, tuple struct or tuple variant, found enum + let y = Void(); //~ ERROR cannot find function, tuple struct or tuple variant `Void` in this scope - let z = ManyVariants(); //~ ERROR expected function, tuple struct or tuple variant, found enum + let z = ManyVariants(); //~ ERROR cannot find function, tuple struct or tuple variant `ManyVariants` in this scope } fn main() {} diff --git a/tests/ui/did_you_mean/issue-43871-enum-instead-of-variant.stderr b/tests/ui/did_you_mean/issue-43871-enum-instead-of-variant.stderr index 6df485851e04b..9685c3451208a 100644 --- a/tests/ui/did_you_mean/issue-43871-enum-instead-of-variant.stderr +++ b/tests/ui/did_you_mean/issue-43871-enum-instead-of-variant.stderr @@ -1,9 +1,10 @@ -error[E0532]: expected tuple struct or tuple variant, found enum `Option` +error[E0532]: cannot find tuple struct or tuple variant `Option` in this scope --> $DIR/issue-43871-enum-instead-of-variant.rs:21:12 | LL | if let Option(_) = x { | ^^^^^^ | + = note: an enum named `Option` exists in another namespace = help: you might have meant to match against the enum's non-tuple variant help: try to match against one of the enum's variants | @@ -11,12 +12,13 @@ LL - if let Option(_) = x { LL + if let std::option::Option::Some(_) = x { | -error[E0532]: expected tuple struct or tuple variant, found enum `Example` +error[E0532]: cannot find tuple struct or tuple variant `Example` in this scope --> $DIR/issue-43871-enum-instead-of-variant.rs:27:12 | LL | if let Example(_) = y { | ^^^^^^^ | + = note: an enum named `Example` exists in another namespace = help: you might have meant to match against the enum's non-tuple variant note: the enum is defined here --> $DIR/issue-43871-enum-instead-of-variant.rs:1:1 @@ -28,12 +30,13 @@ help: try to match against one of the enum's variants LL | if let Example::Ex(_) = y { | ++++ -error[E0423]: expected function, tuple struct or tuple variant, found enum `Option` +error[E0423]: cannot find function, tuple struct or tuple variant `Option` in this scope --> $DIR/issue-43871-enum-instead-of-variant.rs:19:13 | LL | let x = Option(1); | ^^^^^^ | + = note: an enum named `Option` exists in another namespace = help: you might have meant to construct the enum's non-tuple variant help: try to construct one of the enum's variants | @@ -41,12 +44,13 @@ LL - let x = Option(1); LL + let x = std::option::Option::Some(1); | -error[E0423]: expected function, tuple struct or tuple variant, found enum `Void` +error[E0423]: cannot find function, tuple struct or tuple variant `Void` in this scope --> $DIR/issue-43871-enum-instead-of-variant.rs:31:13 | LL | let y = Void(); | ^^^^ | + = note: an enum named `Void` exists in another namespace = help: the enum has no tuple variants to construct note: the enum is defined here --> $DIR/issue-43871-enum-instead-of-variant.rs:3:1 @@ -54,12 +58,13 @@ note: the enum is defined here LL | enum Void {} | ^^^^^^^^^^^^ -error[E0423]: expected function, tuple struct or tuple variant, found enum `ManyVariants` +error[E0423]: cannot find function, tuple struct or tuple variant `ManyVariants` in this scope --> $DIR/issue-43871-enum-instead-of-variant.rs:33:13 | LL | let z = ManyVariants(); | ^^^^^^^^^^^^ | + = note: an enum named `ManyVariants` exists in another namespace = help: the enum has no tuple variants to construct = help: you might have meant to construct one of the enum's non-tuple variants note: the enum is defined here diff --git a/tests/ui/ergonomic-clones/async/local-type.rs b/tests/ui/ergonomic-clones/async/local-type.rs index e891686b550ae..297fda2cac152 100644 --- a/tests/ui/ergonomic-clones/async/local-type.rs +++ b/tests/ui/ergonomic-clones/async/local-type.rs @@ -5,6 +5,6 @@ #![allow(incomplete_features)] fn main() { - let _ = async use |x: x| x; //~ ERROR expected type - let _ = async use |x: bool| -> x { x }; //~ ERROR expected type + let _ = async use |x: x| x; //~ ERROR cannot find type `x` in this scope + let _ = async use |x: bool| -> x { x }; //~ ERROR cannot find type `x` in this scope } diff --git a/tests/ui/ergonomic-clones/async/local-type.stderr b/tests/ui/ergonomic-clones/async/local-type.stderr index fd832fbc8d295..bc8d250747cbf 100644 --- a/tests/ui/ergonomic-clones/async/local-type.stderr +++ b/tests/ui/ergonomic-clones/async/local-type.stderr @@ -1,14 +1,18 @@ -error[E0573]: expected type, found local variable `x` +error[E0573]: cannot find type `x` in this scope --> $DIR/local-type.rs:8:27 | LL | let _ = async use |x: x| x; - | ^ not a type + | ^ not found in this scope + | + = note: a local variable named `x` exists in another namespace -error[E0573]: expected type, found local variable `x` +error[E0573]: cannot find type `x` in this scope --> $DIR/local-type.rs:9:36 | LL | let _ = async use |x: bool| -> x { x }; - | ^ not a type + | ^ not found in this scope + | + = note: a local variable named `x` exists in another namespace error: aborting due to 2 previous errors diff --git a/tests/ui/ergonomic-clones/closure/dotuse-no-extra-capture-clone.rs b/tests/ui/ergonomic-clones/closure/dotuse-no-extra-capture-clone.rs new file mode 100644 index 0000000000000..c1662d6f4d1b8 --- /dev/null +++ b/tests/ui/ergonomic-clones/closure/dotuse-no-extra-capture-clone.rs @@ -0,0 +1,69 @@ +//! Regression test for #157141. +//! +//! A non-`move`, non-`use` closure that only `.use`s an upvar should capture it +//! by immutable borrow, not by `use` (which would clone the value into the +//! closure at construction time). The `.use` expression in the body is then the +//! only thing that clones, once per evaluation. + +//@ run-pass + +#![feature(ergonomic_clones)] +#![allow(incomplete_features)] + +use std::sync::atomic::{AtomicUsize, Ordering}; + +static CLONES: AtomicUsize = AtomicUsize::new(0); + +struct Thing; + +impl Clone for Thing { + fn clone(&self) -> Self { + CLONES.fetch_add(1, Ordering::Relaxed); + Thing + } +} + +impl std::clone::UseCloned for Thing {} + +fn clones_during(f: impl FnOnce() -> R) -> usize { + let before = CLONES.load(Ordering::Relaxed); + f(); + CLONES.load(Ordering::Relaxed) - before +} + +fn main() { + // Plain `||` closure: `x` is borrowed, so building the closure clones nothing. + // Each call clones exactly once via the `.use` in the body. + let x = Thing; + let n = clones_during(|| { + let closure = || { + let _y = x.use; + }; + closure(); + closure(); + }); + assert_eq!(n, 2, "plain `||` closure should clone once per call, not also at capture"); + drop(x); + + // `move ||` closure: `x` is moved in (no capture clone), `.use` clones per call. + let x = Thing; + let n = clones_during(|| { + let closure = move || { + let _y = x.use; + }; + closure(); + closure(); + }); + assert_eq!(n, 2, "`move ||` closure should clone once per call"); + + // `use ||` closure: the capture clause clones `x` into the closure once, at + // construction. Calling it afterwards moves the captured value out. + let x = Thing; + let n = clones_during(|| { + let closure = use || { + let _y = &x; + }; + closure(); + }); + assert_eq!(n, 1, "`use ||` closure clones once at construction"); +} diff --git a/tests/ui/ergonomic-clones/closure/local-type.rs b/tests/ui/ergonomic-clones/closure/local-type.rs index b2f99efa1e666..3c9ccb98ae458 100644 --- a/tests/ui/ergonomic-clones/closure/local-type.rs +++ b/tests/ui/ergonomic-clones/closure/local-type.rs @@ -4,6 +4,6 @@ #![allow(incomplete_features)] fn main() { - let _ = use |x: x| x; //~ ERROR expected type - let _ = use |x: bool| -> x { x }; //~ ERROR expected type + let _ = use |x: x| x; //~ ERROR cannot find type `x` in this scope + let _ = use |x: bool| -> x { x }; //~ ERROR cannot find type `x` in this scope } diff --git a/tests/ui/ergonomic-clones/closure/local-type.stderr b/tests/ui/ergonomic-clones/closure/local-type.stderr index 5a42ae63afaf1..b3cc2e15d3110 100644 --- a/tests/ui/ergonomic-clones/closure/local-type.stderr +++ b/tests/ui/ergonomic-clones/closure/local-type.stderr @@ -1,14 +1,18 @@ -error[E0573]: expected type, found local variable `x` +error[E0573]: cannot find type `x` in this scope --> $DIR/local-type.rs:7:21 | LL | let _ = use |x: x| x; - | ^ not a type + | ^ not found in this scope + | + = note: a local variable named `x` exists in another namespace -error[E0573]: expected type, found local variable `x` +error[E0573]: cannot find type `x` in this scope --> $DIR/local-type.rs:8:30 | LL | let _ = use |x: bool| -> x { x }; - | ^ not a type + | ^ not found in this scope + | + = note: a local variable named `x` exists in another namespace error: aborting due to 2 previous errors diff --git a/tests/ui/error-codes/E0423-struct-literal-comment.rs b/tests/ui/error-codes/E0423-struct-literal-comment.rs index f22d27ac37680..88aba2991226e 100644 --- a/tests/ui/error-codes/E0423-struct-literal-comment.rs +++ b/tests/ui/error-codes/E0423-struct-literal-comment.rs @@ -8,7 +8,7 @@ fn main() { // Parser will report an error here if T { x: 10 } == T {} {} //~^ ERROR struct literals are not allowed here - //~| ERROR expected value, found struct `T` + //~| ERROR cannot find value `T` in this scope // Regression test for the `followed_by_brace` helper: // comments inside the braces should not suppress the parenthesized struct literal suggestion. diff --git a/tests/ui/error-codes/E0423-struct-literal-comment.stderr b/tests/ui/error-codes/E0423-struct-literal-comment.stderr index 952200a753ebe..ebdbe9a4e71bd 100644 --- a/tests/ui/error-codes/E0423-struct-literal-comment.stderr +++ b/tests/ui/error-codes/E0423-struct-literal-comment.stderr @@ -15,23 +15,25 @@ error: expected expression, found `==` LL | if U { /* keep comment here */ } == U {} | ^^ expected expression -error[E0423]: expected value, found struct `T` +error[E0423]: cannot find value `T` in this scope --> $DIR/E0423-struct-literal-comment.rs:9:23 | LL | if T { x: 10 } == T {} {} - | ^ not a value + | ^ not found in this scope | + = note: a struct named `T` exists in another namespace help: surround the struct literal with parentheses | LL | if T { x: 10 } == (T {}) {} | + + -error[E0423]: expected value, found struct `U` +error[E0423]: cannot find value `U` in this scope --> $DIR/E0423-struct-literal-comment.rs:15:8 | LL | if U { /* keep comment here */ } == U {} - | ^ not a value + | ^ not found in this scope | + = note: a struct named `U` exists in another namespace help: surround the struct literal with parentheses | LL | if (U { /* keep comment here */ }) == U {} diff --git a/tests/ui/error-codes/E0423.stderr b/tests/ui/error-codes/E0423.stderr index b699e53fb4809..801844c77532f 100644 --- a/tests/ui/error-codes/E0423.stderr +++ b/tests/ui/error-codes/E0423.stderr @@ -26,18 +26,19 @@ help: surround the struct literal with parentheses LL | for _ in (std::ops::Range { start: 0, end: 10 }) {} | + + -error[E0423]: expected value, found struct `T` +error[E0423]: cannot find value `T` in this scope --> $DIR/E0423.rs:14:8 | LL | if T {} == T {} { println!("Ok"); } - | ^ not a value + | ^ not found in this scope | + = note: a struct named `T` exists in another namespace help: surround the struct literal with parentheses | LL | if (T {}) == T {} { println!("Ok"); } | + + -error[E0423]: expected function, tuple struct or tuple variant, found struct `Foo` +error[E0423]: cannot find function, tuple struct or tuple variant `Foo` in this scope --> $DIR/E0423.rs:4:13 | LL | struct Foo { a: bool }; @@ -49,6 +50,7 @@ LL | let f = Foo(); LL | fn foo() { | -------- similarly named function `foo` defined here | + = note: a struct named `Foo` exists in another namespace help: use struct literal syntax instead | LL - let f = Foo(); diff --git a/tests/ui/error-codes/E0424.stderr b/tests/ui/error-codes/E0424.stderr index 831a070bf6cc6..88e60e4665685 100644 --- a/tests/ui/error-codes/E0424.stderr +++ b/tests/ui/error-codes/E0424.stderr @@ -1,4 +1,4 @@ -error[E0424]: expected value, found module `self` +error[E0424]: cannot find value `self` in this scope --> $DIR/E0424.rs:7:9 | LL | fn foo() { @@ -6,12 +6,13 @@ LL | fn foo() { LL | self.bar(); | ^^^^ `self` value is a keyword only available in methods with a `self` parameter | + = note: a module named `self` exists in another namespace help: add a `self` receiver parameter to make the associated `fn` a method | LL | fn foo(&self) { | +++++ -error[E0424]: expected value, found module `self` +error[E0424]: cannot find value `self` in this scope --> $DIR/E0424.rs:11:9 | LL | fn baz(_: i32) { @@ -19,12 +20,13 @@ LL | fn baz(_: i32) { LL | self.bar(); | ^^^^ `self` value is a keyword only available in methods with a `self` parameter | + = note: a module named `self` exists in another namespace help: add a `self` receiver parameter to make the associated `fn` a method | LL | fn baz(&self, _: i32) { | ++++++ -error[E0424]: expected value, found module `self` +error[E0424]: cannot find value `self` in this scope --> $DIR/E0424.rs:15:20 | LL | fn qux() { @@ -32,16 +34,19 @@ LL | fn qux() { LL | let _ = || self.bar(); | ^^^^ `self` value is a keyword only available in methods with a `self` parameter | + = note: a module named `self` exists in another namespace help: add a `self` receiver parameter to make the associated `fn` a method | LL | fn qux(&self) { | +++++ -error[E0424]: expected unit struct, unit variant or constant, found module `self` +error[E0424]: cannot find unit struct, unit variant or constant `self` in this scope --> $DIR/E0424.rs:20:9 | LL | let self = "self"; | ^^^^ `self` value is a keyword and may not be bound to variables or shadowed + | + = note: a module named `self` exists in another namespace error: aborting due to 4 previous errors diff --git a/tests/ui/errors/remap-path-prefix-reverse.local-self.stderr b/tests/ui/errors/remap-path-prefix-reverse.local-self.stderr index b2651f3e03a6d..047916bb7cace 100644 --- a/tests/ui/errors/remap-path-prefix-reverse.local-self.stderr +++ b/tests/ui/errors/remap-path-prefix-reverse.local-self.stderr @@ -1,13 +1,17 @@ -error[E0423]: expected value, found struct `remapped_dep::SomeStruct` - --> $DIR/remap-path-prefix-reverse.rs:15:13 +error[E0423]: cannot find value `SomeStruct` in crate `remapped_dep` + --> $DIR/remap-path-prefix-reverse.rs:15:27 | LL | let _ = remapped_dep::SomeStruct; - | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use struct literal syntax instead: `remapped_dep::SomeStruct {}` + | --------------^^^^^^^^^^ + | | + | help: use struct literal syntax instead: `remapped_dep::SomeStruct {}` | ::: remapped-aux/remapped_dep.rs:4:1 | LL | pub struct SomeStruct {} // This line should be show as part of the error. | --------------------- `remapped_dep::SomeStruct` defined here + | + = note: a struct named `remapped_dep::SomeStruct` exists in another namespace error: aborting due to 1 previous error diff --git a/tests/ui/errors/remap-path-prefix-reverse.remapped-self.stderr b/tests/ui/errors/remap-path-prefix-reverse.remapped-self.stderr index b2651f3e03a6d..047916bb7cace 100644 --- a/tests/ui/errors/remap-path-prefix-reverse.remapped-self.stderr +++ b/tests/ui/errors/remap-path-prefix-reverse.remapped-self.stderr @@ -1,13 +1,17 @@ -error[E0423]: expected value, found struct `remapped_dep::SomeStruct` - --> $DIR/remap-path-prefix-reverse.rs:15:13 +error[E0423]: cannot find value `SomeStruct` in crate `remapped_dep` + --> $DIR/remap-path-prefix-reverse.rs:15:27 | LL | let _ = remapped_dep::SomeStruct; - | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use struct literal syntax instead: `remapped_dep::SomeStruct {}` + | --------------^^^^^^^^^^ + | | + | help: use struct literal syntax instead: `remapped_dep::SomeStruct {}` | ::: remapped-aux/remapped_dep.rs:4:1 | LL | pub struct SomeStruct {} // This line should be show as part of the error. | --------------------- `remapped_dep::SomeStruct` defined here + | + = note: a struct named `remapped_dep::SomeStruct` exists in another namespace error: aborting due to 1 previous error diff --git a/tests/ui/errors/remap-path-prefix-reverse.rs b/tests/ui/errors/remap-path-prefix-reverse.rs index 562e44690f768..41b6979338af6 100644 --- a/tests/ui/errors/remap-path-prefix-reverse.rs +++ b/tests/ui/errors/remap-path-prefix-reverse.rs @@ -13,5 +13,5 @@ fn main() { // The actual error is irrelevant. The important part it that is should show // a snippet of the dependency's source. let _ = remapped_dep::SomeStruct; - //~^ ERROR expected value, found struct `remapped_dep::SomeStruct` + //~^ ERROR cannot find value `SomeStruct` in crate `remapped_dep` } diff --git a/tests/ui/field_representing_types/nonexistent.next.stderr b/tests/ui/field_representing_types/nonexistent.next.stderr index 76026ab4a496f..9f18a667680cd 100644 --- a/tests/ui/field_representing_types/nonexistent.next.stderr +++ b/tests/ui/field_representing_types/nonexistent.next.stderr @@ -1,8 +1,10 @@ -error[E0573]: expected type, found function `main` +error[E0573]: cannot find type `main` in this scope --> $DIR/nonexistent.rs:43:22 | LL | let _: field_of!(main, field); - | ^^^^ not a type + | ^^^^ not found in this scope + | + = note: a function named `main` exists in another namespace error[E0609]: no field `other` on type `Struct` --> $DIR/nonexistent.rs:23:30 diff --git a/tests/ui/field_representing_types/nonexistent.old.stderr b/tests/ui/field_representing_types/nonexistent.old.stderr index 76026ab4a496f..9f18a667680cd 100644 --- a/tests/ui/field_representing_types/nonexistent.old.stderr +++ b/tests/ui/field_representing_types/nonexistent.old.stderr @@ -1,8 +1,10 @@ -error[E0573]: expected type, found function `main` +error[E0573]: cannot find type `main` in this scope --> $DIR/nonexistent.rs:43:22 | LL | let _: field_of!(main, field); - | ^^^^ not a type + | ^^^^ not found in this scope + | + = note: a function named `main` exists in another namespace error[E0609]: no field `other` on type `Struct` --> $DIR/nonexistent.rs:23:30 diff --git a/tests/ui/field_representing_types/nonexistent.rs b/tests/ui/field_representing_types/nonexistent.rs index 74083666af76d..252e2fb85c941 100644 --- a/tests/ui/field_representing_types/nonexistent.rs +++ b/tests/ui/field_representing_types/nonexistent.rs @@ -40,7 +40,7 @@ fn main() { let _: field_of!(*const Struct, field); //~ ERROR: type `*const Struct` doesn't have fields let _: field_of!(fn() -> Struct, field); //~ ERROR: type `fn() -> Struct` doesn't have fields let _: field_of!(dyn Trait, field); //~ ERROR: type `dyn Trait` doesn't have fields - let _: field_of!(main, field); //~ ERROR: expected type, found function `main` + let _: field_of!(main, field); //~ ERROR: cannot find type `main` in this scope let _: field_of!(_, field); //~ ERROR: cannot use `_` in this position } diff --git a/tests/ui/hygiene/missing-self-diag.rs b/tests/ui/hygiene/missing-self-diag.rs index f934f793c7f27..2b76217a3c17f 100644 --- a/tests/ui/hygiene/missing-self-diag.rs +++ b/tests/ui/hygiene/missing-self-diag.rs @@ -7,7 +7,7 @@ pub struct Foo; macro_rules! call_bar { () => { - self.bar(); //~ ERROR expected value + self.bar(); //~ ERROR cannot find value `self` in this scope } } diff --git a/tests/ui/hygiene/missing-self-diag.stderr b/tests/ui/hygiene/missing-self-diag.stderr index 6921ed29e207f..21be48b859eb4 100644 --- a/tests/ui/hygiene/missing-self-diag.stderr +++ b/tests/ui/hygiene/missing-self-diag.stderr @@ -1,4 +1,4 @@ -error[E0424]: expected value, found module `self` +error[E0424]: cannot find value `self` in this scope --> $DIR/missing-self-diag.rs:10:9 | LL | self.bar(); @@ -10,6 +10,7 @@ LL | | call_bar!(); LL | | } | |_____- this function has a `self` parameter, but a macro invocation can only access identifiers it receives from parameters | + = note: a module named `self` exists in another namespace = note: this error originates in the macro `call_bar` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error diff --git a/tests/ui/hygiene/rustc-macro-transparency.rs b/tests/ui/hygiene/rustc-macro-transparency.rs index 0c680abb4153a..69aa8e5f7f43d 100644 --- a/tests/ui/hygiene/rustc-macro-transparency.rs +++ b/tests/ui/hygiene/rustc-macro-transparency.rs @@ -26,6 +26,6 @@ fn main() { Opaque; //~ ERROR cannot find value `Opaque` in this scope transparent; // OK - semiopaque; //~ ERROR expected value, found macro `semiopaque` - opaque; //~ ERROR expected value, found macro `opaque` + semiopaque; //~ ERROR cannot find value `semiopaque` in this scope + opaque; //~ ERROR cannot find value `opaque` in this scope } diff --git a/tests/ui/hygiene/rustc-macro-transparency.stderr b/tests/ui/hygiene/rustc-macro-transparency.stderr index af67bfe66cc84..c24acc8a7fceb 100644 --- a/tests/ui/hygiene/rustc-macro-transparency.stderr +++ b/tests/ui/hygiene/rustc-macro-transparency.stderr @@ -4,26 +4,29 @@ error[E0425]: cannot find value `Opaque` in this scope LL | Opaque; | ^^^^^^ not found in this scope -error[E0423]: expected value, found macro `semiopaque` +error[E0423]: cannot find value `semiopaque` in this scope --> $DIR/rustc-macro-transparency.rs:29:5 | LL | struct SemiOpaque; | ------------------ similarly named unit struct `SemiOpaque` defined here ... LL | semiopaque; - | ^^^^^^^^^^ not a value + | ^^^^^^^^^^ not found in this scope | + = note: a macro named `semiopaque` exists in another namespace help: a unit struct with a similar name exists (notice the capitalization) | LL - semiopaque; LL + SemiOpaque; | -error[E0423]: expected value, found macro `opaque` +error[E0423]: cannot find value `opaque` in this scope --> $DIR/rustc-macro-transparency.rs:30:5 | LL | opaque; - | ^^^^^^ not a value + | ^^^^^^ not found in this scope + | + = note: a macro named `opaque` exists in another namespace error: aborting due to 3 previous errors diff --git a/tests/ui/impl-trait/issues/issue-78722-2.stderr b/tests/ui/impl-trait/issues/issue-78722-2.stderr index ede830bf72c8b..c2aeb0ab13664 100644 --- a/tests/ui/impl-trait/issues/issue-78722-2.stderr +++ b/tests/ui/impl-trait/issues/issue-78722-2.stderr @@ -12,7 +12,7 @@ LL | let f: F = async { 1 }; = note: expected opaque type `F` found `async` block `{async block@$DIR/issue-78722-2.rs:17:20: 17:25}` -error[E0271]: expected `{async block@$DIR/issue-78722-2.rs:14:13: 14:18}` to be a future that resolves to `u8`, but it resolves to `()` +error[E0271]: expected `{async block@issue-78722-2.rs:14:13}` to be a future that resolves to `u8`, but it resolves to `()` --> $DIR/issue-78722-2.rs:12:30 | LL | fn concrete_use() -> F { diff --git a/tests/ui/impl-trait/issues/issue-78722.stderr b/tests/ui/impl-trait/issues/issue-78722.stderr index 84c7dfb033849..9244d18c36b49 100644 --- a/tests/ui/impl-trait/issues/issue-78722.stderr +++ b/tests/ui/impl-trait/issues/issue-78722.stderr @@ -8,7 +8,7 @@ LL | let f: F = async { 1 }; = help: add `#![feature(const_async_blocks)]` 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[E0271]: expected `{async block@$DIR/issue-78722.rs:11:13: 11:18}` to be a future that resolves to `u8`, but it resolves to `()` +error[E0271]: expected `{async block@issue-78722.rs:11:13}` to be a future that resolves to `u8`, but it resolves to `()` --> $DIR/issue-78722.rs:9:30 | LL | fn concrete_use() -> F { diff --git a/tests/ui/impl-trait/nested-return-type4.stderr b/tests/ui/impl-trait/nested-return-type4.stderr index 407800eff1894..63f3bfcdda950 100644 --- a/tests/ui/impl-trait/nested-return-type4.stderr +++ b/tests/ui/impl-trait/nested-return-type4.stderr @@ -4,7 +4,7 @@ error[E0700]: hidden type for `impl Future` captures lifeti LL | fn test<'s: 's>(s: &'s str) -> impl std::future::Future { | -- --------------------------------------------- opaque type defined here | | - | hidden type `{async block@$DIR/nested-return-type4.rs:4:5: 4:15}` captures the lifetime `'s` as defined here + | hidden type `{async block@...}` captures the lifetime `'s` as defined here LL | async move { let _s = s; } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/tests/ui/impl-trait/universal_wrong_bounds.rs b/tests/ui/impl-trait/universal_wrong_bounds.rs index 2182506c7b719..69083f0a84719 100644 --- a/tests/ui/impl-trait/universal_wrong_bounds.rs +++ b/tests/ui/impl-trait/universal_wrong_bounds.rs @@ -6,8 +6,8 @@ fn foo(f: impl Display + Clone) -> String { wants_clone(f); } -fn wants_debug(g: impl Debug) { } //~ ERROR expected trait, found derive macro `Debug` -fn wants_display(g: impl Debug) { } //~ ERROR expected trait, found derive macro `Debug` +fn wants_debug(g: impl Debug) { } //~ ERROR cannot find trait `Debug` in this scope +fn wants_display(g: impl Debug) { } //~ ERROR cannot find trait `Debug` in this scope fn wants_clone(g: impl Clone) { } fn main() {} diff --git a/tests/ui/impl-trait/universal_wrong_bounds.stderr b/tests/ui/impl-trait/universal_wrong_bounds.stderr index 464d689589e91..8826ecc36a49c 100644 --- a/tests/ui/impl-trait/universal_wrong_bounds.stderr +++ b/tests/ui/impl-trait/universal_wrong_bounds.stderr @@ -1,20 +1,22 @@ -error[E0404]: expected trait, found derive macro `Debug` +error[E0404]: cannot find trait `Debug` in this scope --> $DIR/universal_wrong_bounds.rs:9:24 | LL | fn wants_debug(g: impl Debug) { } - | ^^^^^ not a trait + | ^^^^^ not found in this scope | + = note: a derive macro named `Debug` exists in another namespace help: consider importing this trait instead | LL + use std::fmt::Debug; | -error[E0404]: expected trait, found derive macro `Debug` +error[E0404]: cannot find trait `Debug` in this scope --> $DIR/universal_wrong_bounds.rs:10:26 | LL | fn wants_display(g: impl Debug) { } - | ^^^^^ not a trait + | ^^^^^ not found in this scope | + = note: a derive macro named `Debug` exists in another namespace help: consider importing this trait instead | LL + use std::fmt::Debug; diff --git a/tests/ui/imports/glob-resolve1.rs b/tests/ui/imports/glob-resolve1.rs index ef82817e373cc..85cf41a7854d1 100644 --- a/tests/ui/imports/glob-resolve1.rs +++ b/tests/ui/imports/glob-resolve1.rs @@ -26,7 +26,7 @@ fn foo() {} fn main() { fpriv(); //~ ERROR cannot find function `fpriv` in this scope epriv(); //~ ERROR cannot find function `epriv` in this scope - B; //~ ERROR expected value, found enum `B` + B; //~ ERROR cannot find value `B` in this scope C; //~ ERROR cannot find value `C` in this scope import(); //~ ERROR: cannot find function `import` in this scope diff --git a/tests/ui/imports/glob-resolve1.stderr b/tests/ui/imports/glob-resolve1.stderr index 5e02c933836d1..e76a32ae1c53f 100644 --- a/tests/ui/imports/glob-resolve1.stderr +++ b/tests/ui/imports/glob-resolve1.stderr @@ -22,12 +22,13 @@ note: function `bar::epriv` exists but is inaccessible LL | fn epriv(); | ^^^^^^^^^^^ not accessible -error[E0423]: expected value, found enum `B` +error[E0423]: cannot find value `B` in this scope --> $DIR/glob-resolve1.rs:29:5 | LL | B; | ^ | + = note: an enum named `B` exists in another namespace note: the enum is defined here --> $DIR/glob-resolve1.rs:15:5 | diff --git a/tests/ui/imports/issue-38293.rs b/tests/ui/imports/issue-38293.rs index 01c40ca48d2a2..cbd794e652bde 100644 --- a/tests/ui/imports/issue-38293.rs +++ b/tests/ui/imports/issue-38293.rs @@ -13,5 +13,5 @@ mod bar { use bar::baz::{self}; fn main() { - baz(); //~ ERROR expected function, found module `baz` + baz(); //~ ERROR cannot find function `baz` in this scope } diff --git a/tests/ui/imports/issue-38293.stderr b/tests/ui/imports/issue-38293.stderr index 348bb07f203cf..428aa75539cc5 100644 --- a/tests/ui/imports/issue-38293.stderr +++ b/tests/ui/imports/issue-38293.stderr @@ -4,12 +4,13 @@ error[E0432]: unresolved import `foo::f` LL | use foo::f::{self}; | ^ expected type, found function `f` in `foo` -error[E0423]: expected function, found module `baz` +error[E0423]: cannot find function `baz` in this scope --> $DIR/issue-38293.rs:16:5 | LL | baz(); - | ^^^ not a function + | ^^^ not found in this scope | + = note: a module named `baz` exists in another namespace help: consider importing this function instead | LL + use bar::baz; diff --git a/tests/ui/imports/issue-4366-2.rs b/tests/ui/imports/issue-4366-2.rs index a594db91e9f24..ddfb484695c6e 100644 --- a/tests/ui/imports/issue-4366-2.rs +++ b/tests/ui/imports/issue-4366-2.rs @@ -23,5 +23,5 @@ mod m1 { } fn main() { - foo(); //~ ERROR expected function, found module `foo` + foo(); //~ ERROR cannot find function `foo` in this scope } diff --git a/tests/ui/imports/issue-4366-2.stderr b/tests/ui/imports/issue-4366-2.stderr index 6736b39a4070c..bb62b048d0a61 100644 --- a/tests/ui/imports/issue-4366-2.stderr +++ b/tests/ui/imports/issue-4366-2.stderr @@ -10,12 +10,13 @@ note: type alias `a::b::Bar` exists but is inaccessible LL | type Bar = isize; | ^^^^^^^^^^^^^^^^^ not accessible -error[E0423]: expected function, found module `foo` +error[E0423]: cannot find function `foo` in this scope --> $DIR/issue-4366-2.rs:26:5 | LL | foo(); - | ^^^ not a function + | ^^^ not found in this scope | + = note: a module named `foo` exists in another namespace note: function `m1::foo` exists but is inaccessible --> $DIR/issue-4366-2.rs:22:5 | diff --git a/tests/ui/imports/private-from-decl-macro.fail.stderr b/tests/ui/imports/private-from-decl-macro.fail.stderr index a4090ef5dcfd1..9d6941d064767 100644 --- a/tests/ui/imports/private-from-decl-macro.fail.stderr +++ b/tests/ui/imports/private-from-decl-macro.fail.stderr @@ -17,7 +17,7 @@ LL | crate::m::mac_glob!(); | --------------------- in this macro invocation = note: this error originates in the macro `crate::m::mac_glob` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0423]: expected value, found struct `S` +error[E0423]: cannot find value `S` in this scope --> $DIR/private-from-decl-macro.rs:28:17 | LL | pub struct S {} @@ -26,6 +26,7 @@ LL | pub struct S {} LL | let s = S; | ^ | + = note: a struct named `S` exists in another namespace note: constant `m::S` exists but is inaccessible --> $DIR/private-from-decl-macro.rs:10:5 | diff --git a/tests/ui/imports/private-from-decl-macro.rs b/tests/ui/imports/private-from-decl-macro.rs index ff37665b96862..92950b66367f5 100644 --- a/tests/ui/imports/private-from-decl-macro.rs +++ b/tests/ui/imports/private-from-decl-macro.rs @@ -25,7 +25,7 @@ mod single { fn check() { let s = S {}; #[cfg(fail)] - let s = S; //[fail]~ ERROR expected value, found struct `S` + let s = S; //[fail]~ ERROR cannot find value `S` in this scope } } diff --git a/tests/ui/imports/suggest-import-ice-issue-127302.edition2015.stderr b/tests/ui/imports/suggest-import-ice-issue-127302.edition2015.stderr index 24574c8796b9d..a1347be1ef12e 100644 --- a/tests/ui/imports/suggest-import-ice-issue-127302.edition2015.stderr +++ b/tests/ui/imports/suggest-import-ice-issue-127302.edition2015.stderr @@ -29,11 +29,13 @@ help: consider importing this function LL + use std::env::args; | -error[E0532]: expected unit struct, unit variant or constant, found module `crate::config` - --> $DIR/suggest-import-ice-issue-127302.rs:7:9 +error[E0532]: cannot find unit struct, unit variant or constant `config` in the crate root + --> $DIR/suggest-import-ice-issue-127302.rs:7:16 | LL | crate::config => {} - | ^^^^^^^^^^^^^ not a unit struct, unit variant or constant + | ^^^^^^ not found in the crate root + | + = note: a module named `crate::config` exists in another namespace error: aborting due to 4 previous errors diff --git a/tests/ui/imports/suggest-import-ice-issue-127302.edition2021.stderr b/tests/ui/imports/suggest-import-ice-issue-127302.edition2021.stderr index 24574c8796b9d..a1347be1ef12e 100644 --- a/tests/ui/imports/suggest-import-ice-issue-127302.edition2021.stderr +++ b/tests/ui/imports/suggest-import-ice-issue-127302.edition2021.stderr @@ -29,11 +29,13 @@ help: consider importing this function LL + use std::env::args; | -error[E0532]: expected unit struct, unit variant or constant, found module `crate::config` - --> $DIR/suggest-import-ice-issue-127302.rs:7:9 +error[E0532]: cannot find unit struct, unit variant or constant `config` in the crate root + --> $DIR/suggest-import-ice-issue-127302.rs:7:16 | LL | crate::config => {} - | ^^^^^^^^^^^^^ not a unit struct, unit variant or constant + | ^^^^^^ not found in the crate root + | + = note: a module named `crate::config` exists in another namespace error: aborting due to 4 previous errors diff --git a/tests/ui/imports/suggest-import-ice-issue-127302.rs b/tests/ui/imports/suggest-import-ice-issue-127302.rs index 6b8d4c718310e..3f1a8ac4c60fd 100644 --- a/tests/ui/imports/suggest-import-ice-issue-127302.rs +++ b/tests/ui/imports/suggest-import-ice-issue-127302.rs @@ -4,7 +4,7 @@ mod config; //~ ERROR file not found for module fn main() { match &args.cmd { //~ ERROR cannot find value `args` in this scope - crate::config => {} //~ ERROR expected unit struct, unit variant or constant, found module `crate::config` + crate::config => {} //~ ERROR cannot find unit struct, unit variant or constant `config` in the crate root } println!(args.ctx.compiler.display()); diff --git a/tests/ui/issues/issue-38412.stderr b/tests/ui/issues/issue-38412.stderr index ed8b6b60afc06..513e721a40e40 100644 --- a/tests/ui/issues/issue-38412.stderr +++ b/tests/ui/issues/issue-38412.stderr @@ -3,6 +3,8 @@ error[E0532]: cannot match against a tuple struct which contains private fields | LL | let Box(a) = loop { }; | ^^^ constructor is not visible here due to private fields + | + = note: a struct named `Box` exists in another namespace error: aborting due to 1 previous error diff --git a/tests/ui/iterators/generator_returned_from_fn.stderr b/tests/ui/iterators/generator_returned_from_fn.stderr index 8bec119ddbc01..f4620b958f0c6 100644 --- a/tests/ui/iterators/generator_returned_from_fn.stderr +++ b/tests/ui/iterators/generator_returned_from_fn.stderr @@ -28,7 +28,7 @@ error[E0700]: hidden type for `impl FnOnce() -> impl Iterator` captu LL | fn capture_move_once(a: &u32) -> impl FnOnce() -> impl Iterator { | ---- ------------------------------------------ opaque type defined here | | - | hidden type `{gen closure@$DIR/generator_returned_from_fn.rs:43:13: 43:20}` captures the anonymous lifetime defined here + | hidden type `{gen closure@...}` captures the anonymous lifetime defined here LL | iter! { move || { | _____________^ LL | | @@ -49,7 +49,7 @@ error[E0700]: hidden type for `impl Iterator` captures lifetime that LL | fn capture_move_once(a: &u32) -> impl FnOnce() -> impl Iterator { | ---- ------------------------- opaque type defined here | | - | hidden type `{gen closure body@$DIR/generator_returned_from_fn.rs:43:21: 50:6}` captures the anonymous lifetime defined here + | hidden type `{gen closure body@...}` captures the anonymous lifetime defined here LL | iter! { move || { | _____________^ LL | | diff --git a/tests/ui/lang-items/issue-83471.rs b/tests/ui/lang-items/issue-83471.rs index 9952faa2472ae..c37f79001b681 100644 --- a/tests/ui/lang-items/issue-83471.rs +++ b/tests/ui/lang-items/issue-83471.rs @@ -22,7 +22,7 @@ trait Sized: MetaSized {} //~| ERROR: `fn` lang item must be applied to a trait with 1 generic argument trait Fn { fn call(export_name); - //~^ ERROR: expected type + //~^ ERROR: cannot find type `export_name` in this scope //~| WARNING: anonymous parameters are deprecated //~| WARNING: this is accepted in the current edition } diff --git a/tests/ui/lang-items/issue-83471.stderr b/tests/ui/lang-items/issue-83471.stderr index b54080148e366..47db25cc07880 100644 --- a/tests/ui/lang-items/issue-83471.stderr +++ b/tests/ui/lang-items/issue-83471.stderr @@ -1,8 +1,10 @@ -error[E0573]: expected type, found built-in attribute `export_name` +error[E0573]: cannot find type `export_name` in this scope --> $DIR/issue-83471.rs:24:13 | LL | fn call(export_name); - | ^^^^^^^^^^^ not a type + | ^^^^^^^^^^^ not found in this scope + | + = note: a built-in attribute named `export_name` exists in another namespace warning: anonymous parameters are deprecated and will be removed in the next edition --> $DIR/issue-83471.rs:24:13 diff --git a/tests/ui/namespace/namespace-mix.rs b/tests/ui/namespace/namespace-mix.rs index a640a38d7f6cb..b63c0e0fb3a08 100644 --- a/tests/ui/namespace/namespace-mix.rs +++ b/tests/ui/namespace/namespace-mix.rs @@ -32,13 +32,13 @@ mod m2 { fn f12() { check(m1::S{}); //~ ERROR c::Item - check(m1::S); //~ ERROR expected value, found type alias `m1::S` + check(m1::S); //~ ERROR cannot find value `S` in module `m1` check(m2::S{}); //~ ERROR c::S check(m2::S); //~ ERROR c::Item } fn xf12() { check(xm1::S{}); //~ ERROR c::Item - check(xm1::S); //~ ERROR expected value, found type alias `xm1::S` + check(xm1::S); //~ ERROR cannot find value `S` in module `xm1` check(xm2::S{}); //~ ERROR c::S check(xm2::S); //~ ERROR c::Item } @@ -98,13 +98,13 @@ mod m8 { fn f78() { check(m7::V{}); //~ ERROR c::Item - check(m7::V); //~ ERROR expected value, found type alias `m7::V` + check(m7::V); //~ ERROR cannot find value `V` in module `m7` check(m8::V{}); //~ ERROR c::E check(m8::V); //~ ERROR c::Item } fn xf78() { check(xm7::V{}); //~ ERROR c::Item - check(xm7::V); //~ ERROR expected value, found type alias `xm7::V` + check(xm7::V); //~ ERROR cannot find value `V` in module `xm7` check(xm8::V{}); //~ ERROR c::E check(xm8::V); //~ ERROR c::Item } diff --git a/tests/ui/namespace/namespace-mix.stderr b/tests/ui/namespace/namespace-mix.stderr index 78866b4916061..b9b0102541bb7 100644 --- a/tests/ui/namespace/namespace-mix.stderr +++ b/tests/ui/namespace/namespace-mix.stderr @@ -1,12 +1,13 @@ -error[E0423]: expected value, found type alias `m1::S` - --> $DIR/namespace-mix.rs:35:11 +error[E0423]: cannot find value `S` in module `m1` + --> $DIR/namespace-mix.rs:35:15 | LL | pub struct TS(); | ---------------- similarly named tuple struct `TS` defined here ... LL | check(m1::S); - | ^^^^^ + | ^ | + = note: a type alias named `m1::S` exists in another namespace help: a tuple struct with a similar name exists | LL | check(m1::TS); @@ -23,17 +24,18 @@ LL - check(m1::S); LL + check(S); | -error[E0423]: expected value, found type alias `xm1::S` - --> $DIR/namespace-mix.rs:41:11 +error[E0423]: cannot find value `S` in module `xm1` + --> $DIR/namespace-mix.rs:41:16 | LL | check(xm1::S); - | ^^^^^^ + | ^ | ::: $DIR/auxiliary/namespace-mix.rs:5:5 | LL | pub struct TS(); | ------------- similarly named tuple struct `TS` defined here | + = note: a type alias named `xm1::S` exists in another namespace help: a tuple struct with a similar name exists | LL | check(xm1::TS); @@ -50,15 +52,16 @@ LL - check(xm1::S); LL + check(S); | -error[E0423]: expected value, found type alias `m7::V` - --> $DIR/namespace-mix.rs:101:11 +error[E0423]: cannot find value `V` in module `m7` + --> $DIR/namespace-mix.rs:101:15 | LL | TV(), | ---- similarly named tuple variant `TV` defined here ... LL | check(m7::V); - | ^^^^^ + | ^ | + = note: a type alias named `m7::V` exists in another namespace help: a tuple variant with a similar name exists | LL | check(m7::TV); @@ -75,17 +78,18 @@ LL - check(m7::V); LL + check(V); | -error[E0423]: expected value, found type alias `xm7::V` - --> $DIR/namespace-mix.rs:107:11 +error[E0423]: cannot find value `V` in module `xm7` + --> $DIR/namespace-mix.rs:107:16 | LL | check(xm7::V); - | ^^^^^^ + | ^ | ::: $DIR/auxiliary/namespace-mix.rs:9:9 | LL | TV(), | -- similarly named tuple variant `TV` defined here | + = note: a type alias named `xm7::V` exists in another namespace help: a tuple variant with a similar name exists | LL | check(xm7::TV); diff --git a/tests/ui/parallel-rustc/recursive-impl-trait-deadlock-issue-129912.rs b/tests/ui/parallel-rustc/recursive-impl-trait-deadlock-issue-129912.rs index 5b0bd19fff0b0..1c1ab67a4f67b 100644 --- a/tests/ui/parallel-rustc/recursive-impl-trait-deadlock-issue-129912.rs +++ b/tests/ui/parallel-rustc/recursive-impl-trait-deadlock-issue-129912.rs @@ -6,8 +6,8 @@ fn option(i: i32) -> impl Sync { if generator_sig() < 0 { None } else { Sized((option(i - Sized), i)) } - //~^ ERROR expected value, found trait `Sized` - //~| ERROR expected function, tuple struct or tuple variant, found trait `Sized` + //~^ ERROR cannot find value `Sized` in this scope + //~| ERROR cannot find function, tuple struct or tuple variant `Sized` in this scope } fn tuple() -> impl Sized { @@ -70,7 +70,7 @@ fn substs_change() -> impl Sized { } fn generator_hold() -> impl generator_capture { - //~^ ERROR expected trait, found function `generator_capture` + //~^ ERROR cannot find trait `generator_capture` in this scope move || { let x = (); yield; diff --git a/tests/ui/parallel-rustc/recursive-impl-trait-deadlock-issue-129912.stderr b/tests/ui/parallel-rustc/recursive-impl-trait-deadlock-issue-129912.stderr index 420fb36d56003..aadefd9007a20 100644 --- a/tests/ui/parallel-rustc/recursive-impl-trait-deadlock-issue-129912.stderr +++ b/tests/ui/parallel-rustc/recursive-impl-trait-deadlock-issue-129912.stderr @@ -13,11 +13,13 @@ LL | #![feature(generators)] = note: removed in 1.75.0; see for more information = note: renamed to `coroutines` -error[E0423]: expected value, found trait `Sized` +error[E0423]: cannot find value `Sized` in this scope --> $DIR/recursive-impl-trait-deadlock-issue-129912.rs:8:62 | LL | if generator_sig() < 0 { None } else { Sized((option(i - Sized), i)) } - | ^^^^^ not a value + | ^^^^^ not found in this scope + | + = note: a trait named `Sized` exists in another namespace error[E0425]: cannot find value `i` in this scope --> $DIR/recursive-impl-trait-deadlock-issue-129912.rs:52:8 @@ -31,11 +33,13 @@ error[E0404]: expected trait, found builtin type `i32` LL | fn generator_capture() -> impl i32 { | ^^^ not a trait -error[E0404]: expected trait, found function `generator_capture` +error[E0404]: cannot find trait `generator_capture` in this scope --> $DIR/recursive-impl-trait-deadlock-issue-129912.rs:72:29 | LL | fn generator_hold() -> impl generator_capture { - | ^^^^^^^^^^^^^^^^^ not a trait + | ^^^^^^^^^^^^^^^^^ not found in this scope + | + = note: a function named `generator_capture` exists in another namespace error[E0658]: yield syntax is experimental --> $DIR/recursive-impl-trait-deadlock-issue-129912.rs:60:9 @@ -125,11 +129,13 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures LL | fn closure_sig() -> _ { | ^ not allowed in type signatures -error[E0423]: expected function, tuple struct or tuple variant, found trait `Sized` +error[E0423]: cannot find function, tuple struct or tuple variant `Sized` in this scope --> $DIR/recursive-impl-trait-deadlock-issue-129912.rs:8:44 | LL | if generator_sig() < 0 { None } else { Sized((option(i - Sized), i)) } - | ^^^^^ not a function, tuple struct or tuple variant + | ^^^^^ not found in this scope + | + = note: a trait named `Sized` exists in another namespace error: aborting due to 17 previous errors diff --git a/tests/ui/parser/issues/issue-73568-lifetime-after-mut.rs b/tests/ui/parser/issues/issue-73568-lifetime-after-mut.rs index 782a46ab060e0..e835617ad784b 100644 --- a/tests/ui/parser/issues/issue-73568-lifetime-after-mut.rs +++ b/tests/ui/parser/issues/issue-73568-lifetime-after-mut.rs @@ -15,6 +15,6 @@ fn y<'a>(y: &mut 'a + Send) { //~^ ERROR expected a path on the left-hand side of `+` //~| ERROR at least one trait is required for an object type let z = y as &mut 'a + Send; - //~^ ERROR expected value, found trait `Send` + //~^ ERROR cannot find value `Send` in this scope //~| ERROR at least one trait is required for an object type } diff --git a/tests/ui/parser/issues/issue-73568-lifetime-after-mut.stderr b/tests/ui/parser/issues/issue-73568-lifetime-after-mut.stderr index ae1ed72853de3..f967d4a8b3e01 100644 --- a/tests/ui/parser/issues/issue-73568-lifetime-after-mut.stderr +++ b/tests/ui/parser/issues/issue-73568-lifetime-after-mut.stderr @@ -37,11 +37,13 @@ LL - fn w<$lt>(w: &mut $lt i32) {} LL + fn w<$lt>(w: &$lt mut i32) {} | -error[E0423]: expected value, found trait `Send` +error[E0423]: cannot find value `Send` in this scope --> $DIR/issue-73568-lifetime-after-mut.rs:17:28 | LL | let z = y as &mut 'a + Send; - | ^^^^ not a value + | ^^^^ not found in this scope + | + = note: a trait named `Send` exists in another namespace error[E0224]: at least one trait is required for an object type --> $DIR/issue-73568-lifetime-after-mut.rs:14:18 diff --git a/tests/ui/parser/not-a-pred.rs b/tests/ui/parser/not-a-pred.rs index 5518b554d8e53..34ef21f20c22c 100644 --- a/tests/ui/parser/not-a-pred.rs +++ b/tests/ui/parser/not-a-pred.rs @@ -1,8 +1,8 @@ fn f(a: isize, b: isize) : lt(a, b) { } //~^ ERROR return types are denoted using `->` -//~| ERROR expected type, found function `lt` [E0573] -//~| ERROR expected type, found local variable `a` [E0573] -//~| ERROR expected type, found local variable `b` [E0573] +//~| ERROR cannot find type `lt` in this scope [E0573] +//~| ERROR cannot find type `a` in this scope [E0573] +//~| ERROR cannot find type `b` in this scope [E0573] fn lt(a: isize, b: isize) { } diff --git a/tests/ui/parser/not-a-pred.stderr b/tests/ui/parser/not-a-pred.stderr index 9fedd208e1afe..0b45ac7933fdf 100644 --- a/tests/ui/parser/not-a-pred.stderr +++ b/tests/ui/parser/not-a-pred.stderr @@ -10,23 +10,29 @@ LL - fn f(a: isize, b: isize) : lt(a, b) { } LL + fn f(a: isize, b: isize) -> lt(a, b) { } | -error[E0573]: expected type, found function `lt` +error[E0573]: cannot find type `lt` in this scope --> $DIR/not-a-pred.rs:1:28 | LL | fn f(a: isize, b: isize) : lt(a, b) { } - | ^^^^^^^^ not a type + | ^^ not found in this scope + | + = note: a function named `lt` exists in another namespace -error[E0573]: expected type, found local variable `a` +error[E0573]: cannot find type `a` in this scope --> $DIR/not-a-pred.rs:1:31 | LL | fn f(a: isize, b: isize) : lt(a, b) { } - | ^ not a type + | ^ not found in this scope + | + = note: a local variable named `a` exists in another namespace -error[E0573]: expected type, found local variable `b` +error[E0573]: cannot find type `b` in this scope --> $DIR/not-a-pred.rs:1:34 | LL | fn f(a: isize, b: isize) : lt(a, b) { } - | ^ not a type + | ^ not found in this scope + | + = note: a local variable named `b` exists in another namespace error[E0425]: cannot find function `check` in this scope --> $DIR/not-a-pred.rs:12:5 diff --git a/tests/ui/parser/recover/array-type-no-semi.rs b/tests/ui/parser/recover/array-type-no-semi.rs index 499d5719d730a..f0368b60304b1 100644 --- a/tests/ui/parser/recover/array-type-no-semi.rs +++ b/tests/ui/parser/recover/array-type-no-semi.rs @@ -8,7 +8,7 @@ fn main() { //~^ ERROR expected `;` or `]`, found `,` let a: [i32, ]; //~^ ERROR expected `;` or `]`, found `,` - //~| ERROR expected value, found builtin type `i32` [E0423] + //~| ERROR cannot find value `i32` in this scope [E0423] let c: [i32, x]; //~^ ERROR expected `;` or `]`, found `,` //~| ERROR attempt to use a non-constant value in a constant [E0435] diff --git a/tests/ui/parser/recover/array-type-no-semi.stderr b/tests/ui/parser/recover/array-type-no-semi.stderr index 56c78b01ea390..0af085140223e 100644 --- a/tests/ui/parser/recover/array-type-no-semi.stderr +++ b/tests/ui/parser/recover/array-type-no-semi.stderr @@ -71,11 +71,13 @@ LL - let x = 5; LL + const x: /* Type */ = 5; | -error[E0423]: expected value, found builtin type `i32` +error[E0423]: cannot find value `i32` in this scope --> $DIR/array-type-no-semi.rs:9:13 | LL | let a: [i32, ]; - | ^^^ not a value + | ^^^ not found in this scope + | + = note: a builtin type named `i32` exists in another namespace error: aborting due to 7 previous errors diff --git a/tests/ui/parser/suggest-removing-extra-semicolon-in-item-lists.fixed b/tests/ui/parser/suggest-removing-extra-semicolon-in-item-lists.fixed new file mode 100644 index 0000000000000..2e8097394c109 --- /dev/null +++ b/tests/ui/parser/suggest-removing-extra-semicolon-in-item-lists.fixed @@ -0,0 +1,25 @@ +//@ run-rustfix + +#![allow(dead_code)] + +// Extra semicolons after semicolon-terminated items should have a removal suggestion. + +trait Factory { + fn create() -> u32; + //~^ ERROR non-item in item list + fn second() -> u32; +} + +struct Local; + +impl Local { + const VALUE: u32 = 0; + //~^ ERROR non-item in item list +} + +unsafe extern "C" { + fn foreign(); + //~^ ERROR non-item in item list +} + +fn main() {} diff --git a/tests/ui/parser/suggest-removing-extra-semicolon-in-item-lists.rs b/tests/ui/parser/suggest-removing-extra-semicolon-in-item-lists.rs new file mode 100644 index 0000000000000..d781c34bc8fa0 --- /dev/null +++ b/tests/ui/parser/suggest-removing-extra-semicolon-in-item-lists.rs @@ -0,0 +1,25 @@ +//@ run-rustfix + +#![allow(dead_code)] + +// Extra semicolons after semicolon-terminated items should have a removal suggestion. + +trait Factory { + fn create() -> u32;; + //~^ ERROR non-item in item list + fn second() -> u32; +} + +struct Local; + +impl Local { + const VALUE: u32 = 0;; + //~^ ERROR non-item in item list +} + +unsafe extern "C" { + fn foreign();; + //~^ ERROR non-item in item list +} + +fn main() {} diff --git a/tests/ui/parser/suggest-removing-extra-semicolon-in-item-lists.stderr b/tests/ui/parser/suggest-removing-extra-semicolon-in-item-lists.stderr new file mode 100644 index 0000000000000..12ef08fe9d8df --- /dev/null +++ b/tests/ui/parser/suggest-removing-extra-semicolon-in-item-lists.stderr @@ -0,0 +1,53 @@ +error: non-item in item list + --> $DIR/suggest-removing-extra-semicolon-in-item-lists.rs:8:24 + | +LL | trait Factory { + | - item list starts here +LL | fn create() -> u32;; + | ^ non-item starts here +... +LL | } + | - item list ends here + | +help: consider removing this semicolon + | +LL - fn create() -> u32;; +LL + fn create() -> u32; + | + +error: non-item in item list + --> $DIR/suggest-removing-extra-semicolon-in-item-lists.rs:16:26 + | +LL | impl Local { + | - item list starts here +LL | const VALUE: u32 = 0;; + | ^ non-item starts here +LL | +LL | } + | - item list ends here + | +help: consider removing this semicolon + | +LL - const VALUE: u32 = 0;; +LL + const VALUE: u32 = 0; + | + +error: non-item in item list + --> $DIR/suggest-removing-extra-semicolon-in-item-lists.rs:21:18 + | +LL | unsafe extern "C" { + | - item list starts here +LL | fn foreign();; + | ^ non-item starts here +LL | +LL | } + | - item list ends here + | +help: consider removing this semicolon + | +LL - fn foreign();; +LL + fn foreign(); + | + +error: aborting due to 3 previous errors + diff --git a/tests/ui/parser/suggest-removing-semicolon-after-impl-trait-items.stderr b/tests/ui/parser/suggest-removing-semicolon-after-impl-trait-items.stderr index 396c76ac85f2f..f406799bf5543 100644 --- a/tests/ui/parser/suggest-removing-semicolon-after-impl-trait-items.stderr +++ b/tests/ui/parser/suggest-removing-semicolon-after-impl-trait-items.stderr @@ -4,12 +4,15 @@ error: non-item in item list LL | trait Foo { | - item list starts here LL | fn bar() {}; - | ^ - | | - | non-item starts here - | help: consider removing this semicolon + | ^ non-item starts here LL | } | - item list ends here + | +help: consider removing this semicolon + | +LL - fn bar() {}; +LL + fn bar() {} + | error: aborting due to 1 previous error diff --git a/tests/ui/parser/unicode-string-literal-syntax-error-64792.rs b/tests/ui/parser/unicode-string-literal-syntax-error-64792.rs index 6497509a1233c..21d1e078a8be4 100644 --- a/tests/ui/parser/unicode-string-literal-syntax-error-64792.rs +++ b/tests/ui/parser/unicode-string-literal-syntax-error-64792.rs @@ -1,6 +1,6 @@ // https://github.com/rust-lang/rust/issues/64792 struct X {} -const Y: X = X("ö"); //~ ERROR expected function, tuple struct or tuple variant, found struct `X` +const Y: X = X("ö"); //~ ERROR cannot find function, tuple struct or tuple variant `X` in this scope fn main() {} diff --git a/tests/ui/parser/unicode-string-literal-syntax-error-64792.stderr b/tests/ui/parser/unicode-string-literal-syntax-error-64792.stderr index 7a37b4a5f3a0c..bdb2e412f0211 100644 --- a/tests/ui/parser/unicode-string-literal-syntax-error-64792.stderr +++ b/tests/ui/parser/unicode-string-literal-syntax-error-64792.stderr @@ -1,4 +1,4 @@ -error[E0423]: expected function, tuple struct or tuple variant, found struct `X` +error[E0423]: cannot find function, tuple struct or tuple variant `X` in this scope --> $DIR/unicode-string-literal-syntax-error-64792.rs:4:14 | LL | struct X {} @@ -6,6 +6,8 @@ LL | struct X {} LL | LL | const Y: X = X("ö"); | ^^^^^^ help: use struct literal syntax instead: `X {}` + | + = note: a struct named `X` exists in another namespace error: aborting due to 1 previous error diff --git a/tests/ui/pattern/issue-106862.fixed b/tests/ui/pattern/issue-106862.fixed index 82c6e6cfac395..b4e635b4f6bd4 100644 --- a/tests/ui/pattern/issue-106862.fixed +++ b/tests/ui/pattern/issue-106862.fixed @@ -14,31 +14,31 @@ fn main() { match f { FooB { x: a, y: b } => println!("{} {}", a, b), - //~^ ERROR expected tuple struct or tuple variant, found variant `FooB` + //~^ ERROR cannot find tuple struct or tuple variant `FooB` in this scope _ => (), } match f { FooB { x, y } => println!("{} {}", x, y), - //~^ ERROR expected tuple struct or tuple variant, found variant `FooB` + //~^ ERROR cannot find tuple struct or tuple variant `FooB` in this scope _ => (), } match f { FooA { opt_x: Some(x), y } => println!("{} {}", x, y), - //~^ ERROR expected tuple struct or tuple variant, found variant `FooA` + //~^ ERROR cannot find tuple struct or tuple variant `FooA` in this scope _ => (), } match f { FooB { x: a, y: _ } => println!("{}", a), - //~^ ERROR expected tuple struct or tuple variant, found variant `FooB` + //~^ ERROR cannot find tuple struct or tuple variant `FooB` in this scope _ => (), } match f { FooB { x, y } => (), - //~^ ERROR expected tuple struct or tuple variant, found variant `FooB` + //~^ ERROR cannot find tuple struct or tuple variant `FooB` in this scope _ => (), } } diff --git a/tests/ui/pattern/issue-106862.rs b/tests/ui/pattern/issue-106862.rs index 7adbd384c7083..2e7ff3a82a5d6 100644 --- a/tests/ui/pattern/issue-106862.rs +++ b/tests/ui/pattern/issue-106862.rs @@ -14,31 +14,31 @@ fn main() { match f { FooB(a, b) => println!("{} {}", a, b), - //~^ ERROR expected tuple struct or tuple variant, found variant `FooB` + //~^ ERROR cannot find tuple struct or tuple variant `FooB` in this scope _ => (), } match f { FooB(x, y) => println!("{} {}", x, y), - //~^ ERROR expected tuple struct or tuple variant, found variant `FooB` + //~^ ERROR cannot find tuple struct or tuple variant `FooB` in this scope _ => (), } match f { FooA(Some(x), y) => println!("{} {}", x, y), - //~^ ERROR expected tuple struct or tuple variant, found variant `FooA` + //~^ ERROR cannot find tuple struct or tuple variant `FooA` in this scope _ => (), } match f { FooB(a, _, _) => println!("{}", a), - //~^ ERROR expected tuple struct or tuple variant, found variant `FooB` + //~^ ERROR cannot find tuple struct or tuple variant `FooB` in this scope _ => (), } match f { FooB() => (), - //~^ ERROR expected tuple struct or tuple variant, found variant `FooB` + //~^ ERROR cannot find tuple struct or tuple variant `FooB` in this scope _ => (), } } diff --git a/tests/ui/pattern/issue-106862.stderr b/tests/ui/pattern/issue-106862.stderr index 27f8ac97284eb..fc613f3d39156 100644 --- a/tests/ui/pattern/issue-106862.stderr +++ b/tests/ui/pattern/issue-106862.stderr @@ -1,4 +1,4 @@ -error[E0532]: expected tuple struct or tuple variant, found variant `FooB` +error[E0532]: cannot find tuple struct or tuple variant `FooB` in this scope --> $DIR/issue-106862.rs:16:9 | LL | FooB { x: i32, y: i32 } @@ -6,8 +6,10 @@ LL | FooB { x: i32, y: i32 } ... LL | FooB(a, b) => println!("{} {}", a, b), | ^^^^^^^^^^ help: use struct pattern syntax instead: `FooB { x: a, y: b }` + | + = note: a variant named `FooB` exists in another namespace -error[E0532]: expected tuple struct or tuple variant, found variant `FooB` +error[E0532]: cannot find tuple struct or tuple variant `FooB` in this scope --> $DIR/issue-106862.rs:22:9 | LL | FooB { x: i32, y: i32 } @@ -15,8 +17,10 @@ LL | FooB { x: i32, y: i32 } ... LL | FooB(x, y) => println!("{} {}", x, y), | ^^^^^^^^^^ help: use struct pattern syntax instead: `FooB { x, y }` + | + = note: a variant named `FooB` exists in another namespace -error[E0532]: expected tuple struct or tuple variant, found variant `FooA` +error[E0532]: cannot find tuple struct or tuple variant `FooA` in this scope --> $DIR/issue-106862.rs:28:9 | LL | FooA { opt_x: Option, y: i32 }, @@ -24,8 +28,10 @@ LL | FooA { opt_x: Option, y: i32 }, ... LL | FooA(Some(x), y) => println!("{} {}", x, y), | ^^^^^^^^^^^^^^^^ help: use struct pattern syntax instead: `FooA { opt_x: Some(x), y }` + | + = note: a variant named `FooA` exists in another namespace -error[E0532]: expected tuple struct or tuple variant, found variant `FooB` +error[E0532]: cannot find tuple struct or tuple variant `FooB` in this scope --> $DIR/issue-106862.rs:34:9 | LL | FooB { x: i32, y: i32 } @@ -33,8 +39,10 @@ LL | FooB { x: i32, y: i32 } ... LL | FooB(a, _, _) => println!("{}", a), | ^^^^^^^^^^^^^ help: use struct pattern syntax instead: `FooB { x: a, y: _ }` + | + = note: a variant named `FooB` exists in another namespace -error[E0532]: expected tuple struct or tuple variant, found variant `FooB` +error[E0532]: cannot find tuple struct or tuple variant `FooB` in this scope --> $DIR/issue-106862.rs:40:9 | LL | FooB { x: i32, y: i32 } @@ -42,6 +50,8 @@ LL | FooB { x: i32, y: i32 } ... LL | FooB() => (), | ^^^^^^ help: use struct pattern syntax instead: `FooB { x, y }` + | + = note: a variant named `FooB` exists in another namespace error: aborting due to 5 previous errors diff --git a/tests/ui/pattern/no-match-tuple-variant-self-ctor.rs b/tests/ui/pattern/no-match-tuple-variant-self-ctor.rs index 7c2821e77ab94..9c3cce6e5aca0 100644 --- a/tests/ui/pattern/no-match-tuple-variant-self-ctor.rs +++ b/tests/ui/pattern/no-match-tuple-variant-self-ctor.rs @@ -28,7 +28,7 @@ mod struct_ { impl S { fn foo() { let Self = S; - //[struct_]~^ ERROR expected value, found struct `S` + //[struct_]~^ ERROR cannot find value `S` in this scope //[struct_]~| ERROR expected unit struct, found self constructor `Self` } } diff --git a/tests/ui/pattern/no-match-tuple-variant-self-ctor.struct_.stderr b/tests/ui/pattern/no-match-tuple-variant-self-ctor.struct_.stderr index 5ed3979feb807..0627e2b202f63 100644 --- a/tests/ui/pattern/no-match-tuple-variant-self-ctor.struct_.stderr +++ b/tests/ui/pattern/no-match-tuple-variant-self-ctor.struct_.stderr @@ -1,4 +1,4 @@ -error[E0423]: expected value, found struct `S` +error[E0423]: cannot find value `S` in this scope --> $DIR/no-match-tuple-variant-self-ctor.rs:30:24 | LL | struct S {} @@ -6,6 +6,8 @@ LL | struct S {} ... LL | let Self = S; | ^ help: use struct literal syntax instead: `S {}` + | + = note: a struct named `S` exists in another namespace error[E0533]: expected unit struct, found self constructor `Self` --> $DIR/no-match-tuple-variant-self-ctor.rs:30:17 diff --git a/tests/ui/pattern/struct-variant-as-tuple-variant.rs b/tests/ui/pattern/struct-variant-as-tuple-variant.rs index 944371ae9e952..fa2a64fb68860 100644 --- a/tests/ui/pattern/struct-variant-as-tuple-variant.rs +++ b/tests/ui/pattern/struct-variant-as-tuple-variant.rs @@ -10,6 +10,6 @@ fn main() { let f = FooB { x: 3, y: 4 }; match f { FooB(a, b) => println!("{} {}", a, b), - //~^ ERROR expected tuple struct or tuple variant, found variant `FooB` + //~^ ERROR cannot find tuple struct or tuple variant `FooB` in this scope } } diff --git a/tests/ui/pattern/struct-variant-as-tuple-variant.stderr b/tests/ui/pattern/struct-variant-as-tuple-variant.stderr index 1cd063e453100..821ca297802a3 100644 --- a/tests/ui/pattern/struct-variant-as-tuple-variant.stderr +++ b/tests/ui/pattern/struct-variant-as-tuple-variant.stderr @@ -1,4 +1,4 @@ -error[E0532]: expected tuple struct or tuple variant, found variant `FooB` +error[E0532]: cannot find tuple struct or tuple variant `FooB` in this scope --> $DIR/struct-variant-as-tuple-variant.rs:12:9 | LL | FooB { x: i32, y: i32 } @@ -6,6 +6,8 @@ LL | FooB { x: i32, y: i32 } ... LL | FooB(a, b) => println!("{} {}", a, b), | ^^^^^^^^^^ help: use struct pattern syntax instead: `FooB { x: a, y: b }` + | + = note: a variant named `FooB` exists in another namespace error: aborting due to 1 previous error diff --git a/tests/ui/privacy/ctor-not-accessible-due-to-inaccessible-field-in-reexport.fixed b/tests/ui/privacy/ctor-not-accessible-due-to-inaccessible-field-in-reexport.fixed index 63cc3333b6b77..36550706551a9 100644 --- a/tests/ui/privacy/ctor-not-accessible-due-to-inaccessible-field-in-reexport.fixed +++ b/tests/ui/privacy/ctor-not-accessible-due-to-inaccessible-field-in-reexport.fixed @@ -11,8 +11,10 @@ mod my_mod { fn my_func() { let crate::my_mod::Foo(x) = crate::my_mod::Foo(42); //~^ ERROR cannot initialize a tuple struct which contains private fields + //~| NOTE a struct named `crate::Foo` exists in another namespace //~| HELP the type can be constructed directly, because its fields are available from the current scope //~| ERROR cannot match against a tuple struct which contains private fields + //~| NOTE a struct named `crate::Foo` exists in another namespace //~| HELP the type can be constructed directly, because its fields are available from the current scope } } diff --git a/tests/ui/privacy/ctor-not-accessible-due-to-inaccessible-field-in-reexport.rs b/tests/ui/privacy/ctor-not-accessible-due-to-inaccessible-field-in-reexport.rs index 0b695f9065459..f3c95a1054ead 100644 --- a/tests/ui/privacy/ctor-not-accessible-due-to-inaccessible-field-in-reexport.rs +++ b/tests/ui/privacy/ctor-not-accessible-due-to-inaccessible-field-in-reexport.rs @@ -11,8 +11,10 @@ mod my_mod { fn my_func() { let crate::Foo(x) = crate::Foo(42); //~^ ERROR cannot initialize a tuple struct which contains private fields + //~| NOTE a struct named `crate::Foo` exists in another namespace //~| HELP the type can be constructed directly, because its fields are available from the current scope //~| ERROR cannot match against a tuple struct which contains private fields + //~| NOTE a struct named `crate::Foo` exists in another namespace //~| HELP the type can be constructed directly, because its fields are available from the current scope } } diff --git a/tests/ui/privacy/ctor-not-accessible-due-to-inaccessible-field-in-reexport.stderr b/tests/ui/privacy/ctor-not-accessible-due-to-inaccessible-field-in-reexport.stderr index 6ab324cb32f39..91e9eecfd314a 100644 --- a/tests/ui/privacy/ctor-not-accessible-due-to-inaccessible-field-in-reexport.stderr +++ b/tests/ui/privacy/ctor-not-accessible-due-to-inaccessible-field-in-reexport.stderr @@ -1,9 +1,10 @@ error[E0423]: cannot initialize a tuple struct which contains private fields - --> $DIR/ctor-not-accessible-due-to-inaccessible-field-in-reexport.rs:12:33 + --> $DIR/ctor-not-accessible-due-to-inaccessible-field-in-reexport.rs:12:40 | LL | let crate::Foo(x) = crate::Foo(42); - | ^^^^^^^^^^ + | ^^^ | + = note: a struct named `crate::Foo` exists in another namespace note: the type is accessed through this re-export, but the type's constructor is not visible in this import's scope due to private fields --> $DIR/ctor-not-accessible-due-to-inaccessible-field-in-reexport.rs:3:9 | @@ -15,11 +16,12 @@ LL | let crate::Foo(x) = crate::my_mod::Foo(42); | ++++++++ error[E0532]: cannot match against a tuple struct which contains private fields - --> $DIR/ctor-not-accessible-due-to-inaccessible-field-in-reexport.rs:12:17 + --> $DIR/ctor-not-accessible-due-to-inaccessible-field-in-reexport.rs:12:24 | LL | let crate::Foo(x) = crate::Foo(42); - | ^^^^^^^^^^ + | ^^^ | + = note: a struct named `crate::Foo` exists in another namespace note: the type is accessed through this re-export, but the type's constructor is not visible in this import's scope due to private fields --> $DIR/ctor-not-accessible-due-to-inaccessible-field-in-reexport.rs:3:9 | diff --git a/tests/ui/privacy/issue-75906.stderr b/tests/ui/privacy/issue-75906.stderr index c5bbef97c3440..862cb38941610 100644 --- a/tests/ui/privacy/issue-75906.stderr +++ b/tests/ui/privacy/issue-75906.stderr @@ -4,6 +4,7 @@ error[E0423]: cannot initialize a tuple struct which contains private fields LL | let y = Bar(12); | ^^^ | + = note: a struct named `Bar` exists in another namespace note: constructor is not visible here due to private fields --> $DIR/issue-75906.rs:4:20 | diff --git a/tests/ui/privacy/issue-75907.stderr b/tests/ui/privacy/issue-75907.stderr index 8a6484979c009..8e2150cf9a3c7 100644 --- a/tests/ui/privacy/issue-75907.stderr +++ b/tests/ui/privacy/issue-75907.stderr @@ -4,6 +4,7 @@ error[E0532]: cannot match against a tuple struct which contains private fields LL | let Bar(x, y, Foo(z)) = make_bar(); | ^^^ | + = note: a struct named `Bar` exists in another namespace note: constructor is not visible here due to private fields --> $DIR/issue-75907.rs:15:16 | @@ -23,6 +24,7 @@ error[E0532]: cannot match against a tuple struct which contains private fields LL | let Bar(x, y, Foo(z)) = make_bar(); | ^^^ | + = note: a struct named `Foo` exists in another namespace note: constructor is not visible here due to private fields --> $DIR/issue-75907.rs:15:23 | diff --git a/tests/ui/privacy/issue-75907_b.stderr b/tests/ui/privacy/issue-75907_b.stderr index b82d08473c8c9..cb3bd64ec35f4 100644 --- a/tests/ui/privacy/issue-75907_b.stderr +++ b/tests/ui/privacy/issue-75907_b.stderr @@ -4,6 +4,7 @@ error[E0532]: cannot match against a tuple struct which contains private fields LL | let Bar(x, y, z) = make_bar(); | ^^^ | + = note: a struct named `Bar` exists in another namespace note: constructor is not visible here due to private fields --> $DIR/issue-75907_b.rs:9:16 | @@ -18,6 +19,7 @@ error[E0532]: cannot match against a tuple struct which contains private fields LL | let Foo(x, y, z) = Foo::new(); | ^^^ | + = note: a struct named `Foo` exists in another namespace note: constructor is not visible here due to private fields --> $DIR/issue-75907_b.rs:12:13 | diff --git a/tests/ui/privacy/legacy-ctor-visibility.rs b/tests/ui/privacy/legacy-ctor-visibility.rs index e698a481173f7..68b348ecaaef4 100644 --- a/tests/ui/privacy/legacy-ctor-visibility.rs +++ b/tests/ui/privacy/legacy-ctor-visibility.rs @@ -7,7 +7,7 @@ mod m { use crate::S; fn f() { S(10); - //~^ ERROR expected function, tuple struct or tuple variant, found struct `S` + //~^ ERROR cannot find function, tuple struct or tuple variant `S` in this scope } } } diff --git a/tests/ui/privacy/legacy-ctor-visibility.stderr b/tests/ui/privacy/legacy-ctor-visibility.stderr index 78c79fc951e06..ff414d2504a0d 100644 --- a/tests/ui/privacy/legacy-ctor-visibility.stderr +++ b/tests/ui/privacy/legacy-ctor-visibility.stderr @@ -1,8 +1,10 @@ -error[E0423]: expected function, tuple struct or tuple variant, found struct `S` +error[E0423]: cannot find function, tuple struct or tuple variant `S` in this scope --> $DIR/legacy-ctor-visibility.rs:9:13 | LL | S(10); | ^ + | + = note: a struct named `S` exists in another namespace error: aborting due to 1 previous error diff --git a/tests/ui/privacy/privacy-ns1.rs b/tests/ui/privacy/privacy-ns1.rs index 1ae68759b6d71..bb3906e188b80 100644 --- a/tests/ui/privacy/privacy-ns1.rs +++ b/tests/ui/privacy/privacy-ns1.rs @@ -18,7 +18,7 @@ pub mod foo1 { fn test_glob1() { use foo1::*; - Bar(); //~ ERROR expected function, tuple struct or tuple variant, found trait `Bar` + Bar(); //~ ERROR cannot find function, tuple struct or tuple variant `Bar` in this scope } // private type, public value diff --git a/tests/ui/privacy/privacy-ns1.stderr b/tests/ui/privacy/privacy-ns1.stderr index dd4a1e93020bb..2f16fe8cd13df 100644 --- a/tests/ui/privacy/privacy-ns1.stderr +++ b/tests/ui/privacy/privacy-ns1.stderr @@ -1,4 +1,4 @@ -error[E0423]: expected function, tuple struct or tuple variant, found trait `Bar` +error[E0423]: cannot find function, tuple struct or tuple variant `Bar` in this scope --> $DIR/privacy-ns1.rs:21:5 | LL | pub struct Baz; @@ -7,6 +7,7 @@ LL | pub struct Baz; LL | Bar(); | ^^^ | + = note: a trait named `Bar` exists in another namespace note: these functions exist but are inaccessible --> $DIR/privacy-ns1.rs:15:5 | diff --git a/tests/ui/privacy/privacy-ns2.rs b/tests/ui/privacy/privacy-ns2.rs index 8b671f1ee8509..a862a2a05df01 100644 --- a/tests/ui/privacy/privacy-ns2.rs +++ b/tests/ui/privacy/privacy-ns2.rs @@ -18,13 +18,13 @@ pub mod foo1 { fn test_single1() { use foo1::Bar; - Bar(); //~ ERROR expected function, tuple struct or tuple variant, found trait `Bar` + Bar(); //~ ERROR cannot find function, tuple struct or tuple variant `Bar` in this scope } fn test_list1() { use foo1::{Bar,Baz}; - Bar(); //~ ERROR expected function, tuple struct or tuple variant, found trait `Bar` + Bar(); //~ ERROR cannot find function, tuple struct or tuple variant `Bar` in this scope } // private type, public value @@ -40,7 +40,7 @@ fn test_single2() { use foo2::Bar; let _x : Box; //~ ERROR constant provided when a type was expected - let _x : Bar(); //~ ERROR expected type, found function `Bar` + let _x : Bar(); //~ ERROR cannot find type `Bar` in this scope } fn test_list2() { diff --git a/tests/ui/privacy/privacy-ns2.stderr b/tests/ui/privacy/privacy-ns2.stderr index 62cb773681a7e..ef36b124d8ad6 100644 --- a/tests/ui/privacy/privacy-ns2.stderr +++ b/tests/ui/privacy/privacy-ns2.stderr @@ -1,9 +1,10 @@ -error[E0423]: expected function, tuple struct or tuple variant, found trait `Bar` +error[E0423]: cannot find function, tuple struct or tuple variant `Bar` in this scope --> $DIR/privacy-ns2.rs:21:5 | LL | Bar(); - | ^^^ not a function, tuple struct or tuple variant + | ^^^ not found in this scope | + = note: a trait named `Bar` exists in another namespace note: these functions exist but are inaccessible --> $DIR/privacy-ns2.rs:15:5 | @@ -17,7 +18,7 @@ help: consider importing this function instead LL + use foo2::Bar; | -error[E0423]: expected function, tuple struct or tuple variant, found trait `Bar` +error[E0423]: cannot find function, tuple struct or tuple variant `Bar` in this scope --> $DIR/privacy-ns2.rs:27:5 | LL | pub struct Baz; @@ -26,6 +27,7 @@ LL | pub struct Baz; LL | Bar(); | ^^^ | + = note: a trait named `Bar` exists in another namespace note: these functions exist but are inaccessible --> $DIR/privacy-ns2.rs:15:5 | @@ -44,12 +46,13 @@ help: consider importing this function instead LL + use foo2::Bar; | -error[E0573]: expected type, found function `Bar` +error[E0573]: cannot find type `Bar` in this scope --> $DIR/privacy-ns2.rs:43:14 | LL | let _x : Bar(); - | ^^^^^ not a type + | ^^^ not found in this scope | + = note: a function named `Bar` exists in another namespace note: these traits exist but are inaccessible --> $DIR/privacy-ns2.rs:32:5 | diff --git a/tests/ui/privacy/private-fields-diagnostic-issue-151408.stderr b/tests/ui/privacy/private-fields-diagnostic-issue-151408.stderr index 1a49a21d6b793..b612dc76f3e0d 100644 --- a/tests/ui/privacy/private-fields-diagnostic-issue-151408.stderr +++ b/tests/ui/privacy/private-fields-diagnostic-issue-151408.stderr @@ -16,6 +16,7 @@ error[E0423]: cannot initialize a tuple struct which contains private fields LL | let _ = PublicTuple(); | ^^^^^^^^^^^ | + = note: a struct named `PublicTuple` exists in another namespace note: constructor is not visible here due to private fields --> $DIR/auxiliary/private-fields-diagnostic-aux-issue-151408.rs:18:24 | diff --git a/tests/ui/privacy/suggest-box-new.rs b/tests/ui/privacy/suggest-box-new.rs index 87ee13d15edb9..9a9e62edfacdb 100644 --- a/tests/ui/privacy/suggest-box-new.rs +++ b/tests/ui/privacy/suggest-box-new.rs @@ -12,7 +12,7 @@ fn main() { x: () }; let _ = std::collections::HashMap(); - //~^ ERROR expected function, tuple struct or tuple variant, found struct `std::collections::HashMap` + //~^ ERROR cannot find function, tuple struct or tuple variant `HashMap` in module `std::collections` let _ = std::collections::HashMap {}; //~^ ERROR cannot construct `HashMap<_, _, _, _>` with struct literal syntax due to private fields let _ = Box {}; //~ ERROR cannot construct `Box<_, _>` with struct literal syntax due to private fields diff --git a/tests/ui/privacy/suggest-box-new.stderr b/tests/ui/privacy/suggest-box-new.stderr index 0ba4ba97cd1a4..8df8346f772ba 100644 --- a/tests/ui/privacy/suggest-box-new.stderr +++ b/tests/ui/privacy/suggest-box-new.stderr @@ -1,4 +1,4 @@ -error[E0423]: expected function, tuple struct or tuple variant, found struct `std::collections::HashMap` +error[E0423]: cannot find function, tuple struct or tuple variant `HashMap` in module `std::collections` --> $DIR/suggest-box-new.rs:14:13 | LL | let _ = std::collections::HashMap(); @@ -8,6 +8,8 @@ LL | let _ = std::collections::HashMap(); ::: $SRC_DIR/std/src/collections/hash/map.rs:LL:COL | = note: `std::collections::HashMap` defined here + | + = note: a struct named `std::collections::HashMap` exists in another namespace help: you might have meant to use an associated function to build this type | LL | let _ = std::collections::HashMap::new(); @@ -33,6 +35,7 @@ error[E0423]: cannot initialize a tuple struct which contains private fields LL | wtf: Some(Box(U { | ^^^ | + = note: a struct named `Box` exists in another namespace note: constructor is not visible here due to private fields --> $SRC_DIR/alloc/src/boxed.rs:LL:COL | diff --git a/tests/ui/privacy/suggest-making-field-public.stderr b/tests/ui/privacy/suggest-making-field-public.stderr index 3e52232dd59bf..4b108704fb87f 100644 --- a/tests/ui/privacy/suggest-making-field-public.stderr +++ b/tests/ui/privacy/suggest-making-field-public.stderr @@ -24,6 +24,7 @@ error[E0423]: cannot initialize a tuple struct which contains private fields LL | A("".into()); | ^ | + = note: a struct named `A` exists in another namespace note: constructor is not visible here due to private fields --> $DIR/suggest-making-field-public.rs:3:18 | diff --git a/tests/ui/resolve/bad-expr-path2.rs b/tests/ui/resolve/bad-expr-path2.rs index eb88edb9071ef..3d38fe881a59e 100644 --- a/tests/ui/resolve/bad-expr-path2.rs +++ b/tests/ui/resolve/bad-expr-path2.rs @@ -6,5 +6,5 @@ fn main(arguments: Vec) { //~ ERROR `main` function has wrong type log(debug, m1::arguments); //~^ ERROR cannot find function `log` in this scope //~| ERROR cannot find value `debug` in this scope - //~| ERROR expected value, found module `m1::arguments` + //~| ERROR cannot find value `arguments` in module `m1` } diff --git a/tests/ui/resolve/bad-expr-path2.stderr b/tests/ui/resolve/bad-expr-path2.stderr index 9238b1f7023e5..dd62eb1c1a728 100644 --- a/tests/ui/resolve/bad-expr-path2.stderr +++ b/tests/ui/resolve/bad-expr-path2.stderr @@ -4,11 +4,13 @@ error[E0425]: cannot find value `debug` in this scope LL | log(debug, m1::arguments); | ^^^^^ not found in this scope -error[E0423]: expected value, found module `m1::arguments` - --> $DIR/bad-expr-path2.rs:6:16 +error[E0423]: cannot find value `arguments` in module `m1` + --> $DIR/bad-expr-path2.rs:6:20 | LL | log(debug, m1::arguments); - | ^^^^^^^^^^^^^ not a value + | ^^^^^^^^^ not found in `m1` + | + = note: a module named `m1::arguments` exists in another namespace error[E0580]: `main` function has wrong type --> $DIR/bad-expr-path2.rs:5:1 diff --git a/tests/ui/resolve/builtin-attribute-not-value.rs b/tests/ui/resolve/builtin-attribute-not-value.rs new file mode 100644 index 0000000000000..bc5066b69d92a --- /dev/null +++ b/tests/ui/resolve/builtin-attribute-not-value.rs @@ -0,0 +1,29 @@ +fn missing_value() { + path; + //~^ ERROR cannot find value `path` in this scope [E0423] +} + +fn missing_function() { + path(); + //~^ ERROR cannot find function `path` in this scope [E0423] +} + +fn suggested_value() { + let pathh = (); + path; + //~^ ERROR cannot find value `path` in this scope [E0423] + let _ = pathh; +} + +struct Wat { + path: (), +} + +impl Wat { + fn new() -> Wat { + Wat { path } + //~^ ERROR cannot find value `path` in this scope [E0423] + } +} + +fn main() {} diff --git a/tests/ui/resolve/builtin-attribute-not-value.stderr b/tests/ui/resolve/builtin-attribute-not-value.stderr new file mode 100644 index 0000000000000..984259ee60d3b --- /dev/null +++ b/tests/ui/resolve/builtin-attribute-not-value.stderr @@ -0,0 +1,42 @@ +error[E0423]: cannot find value `path` in this scope + --> $DIR/builtin-attribute-not-value.rs:2:5 + | +LL | path; + | ^^^^ not found in this scope + | + = note: a built-in attribute named `path` exists in another namespace + +error[E0423]: cannot find value `path` in this scope + --> $DIR/builtin-attribute-not-value.rs:13:5 + | +LL | path; + | ^^^^ + | + = note: a built-in attribute named `path` exists in another namespace +help: a local variable with a similar name exists + | +LL | pathh; + | + + +error[E0423]: cannot find value `path` in this scope + --> $DIR/builtin-attribute-not-value.rs:24:15 + | +LL | path: (), + | ---- a field by that name exists in `Self` +... +LL | Wat { path } + | ^^^^ + | + = note: a built-in attribute named `path` exists in another namespace + +error[E0423]: cannot find function `path` in this scope + --> $DIR/builtin-attribute-not-value.rs:7:5 + | +LL | path(); + | ^^^^ not found in this scope + | + = note: a built-in attribute named `path` exists in another namespace + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0423`. diff --git a/tests/ui/resolve/change-ty-to-const-param-sugg-0.rs b/tests/ui/resolve/change-ty-to-const-param-sugg-0.rs index 36fe16f64ebeb..fb2467a12ec21 100644 --- a/tests/ui/resolve/change-ty-to-const-param-sugg-0.rs +++ b/tests/ui/resolve/change-ty-to-const-param-sugg-0.rs @@ -5,6 +5,6 @@ fn make() {} struct Array([bool; N]); //~^ ERROR expected trait, found builtin type `usize` //~| HELP you might have meant to write a const parameter here -//~| ERROR expected value, found type parameter `N` +//~| ERROR cannot find value `N` in this scope fn main() {} diff --git a/tests/ui/resolve/change-ty-to-const-param-sugg-0.stderr b/tests/ui/resolve/change-ty-to-const-param-sugg-0.stderr index 4e411eae3cbbb..4c73fe8b0d140 100644 --- a/tests/ui/resolve/change-ty-to-const-param-sugg-0.stderr +++ b/tests/ui/resolve/change-ty-to-const-param-sugg-0.stderr @@ -20,13 +20,13 @@ help: you might have meant to write a const parameter here LL | struct Array([bool; N]); | +++++ -error[E0423]: expected value, found type parameter `N` +error[E0423]: cannot find value `N` in this scope --> $DIR/change-ty-to-const-param-sugg-0.rs:5:31 | LL | struct Array([bool; N]); - | - ^ not a value - | | - | found this type parameter + | ^ not found in this scope + | + = note: a type parameter named `N` exists in another namespace error: aborting due to 3 previous errors diff --git a/tests/ui/resolve/dot-notation-type-namespace-suggest-path-sep.rs b/tests/ui/resolve/dot-notation-type-namespace-suggest-path-sep.rs index e9ff6306e16c2..2890ed5581ebd 100644 --- a/tests/ui/resolve/dot-notation-type-namespace-suggest-path-sep.rs +++ b/tests/ui/resolve/dot-notation-type-namespace-suggest-path-sep.rs @@ -8,54 +8,54 @@ mod foo { fn main() { let _ = String.new(); - //~^ ERROR expected value, found struct `String` + //~^ ERROR cannot find value `String` in this scope //~| HELP use the path separator let _ = String.default; - //~^ ERROR expected value, found struct `String` + //~^ ERROR cannot find value `String` in this scope //~| HELP use the path separator let _ = Vec::<()>.with_capacity(1); - //~^ ERROR expected value, found struct `Vec` + //~^ ERROR cannot find value `Vec` in this scope //~| HELP use the path separator let _ = Alias.new(); - //~^ ERROR expected value, found type alias `Alias` + //~^ ERROR cannot find value `Alias` in this scope //~| HELP use the path separator let _ = Alias.default; - //~^ ERROR expected value, found type alias `Alias` + //~^ ERROR cannot find value `Alias` in this scope //~| HELP use the path separator let _ = foo.bar; - //~^ ERROR expected value, found module `foo` + //~^ ERROR cannot find value `foo` in this scope //~| HELP use the path separator } macro_rules! Type { () => { ::std::cell::Cell - //~^ ERROR expected value, found struct `::std::cell::Cell` - //~| ERROR expected value, found struct `::std::cell::Cell` - //~| ERROR expected value, found struct `::std::cell::Cell` + //~^ ERROR cannot find value `Cell` in module `::std::cell` + //~| ERROR cannot find value `Cell` in module `::std::cell` + //~| ERROR cannot find value `Cell` in module `::std::cell` }; (alias) => { Alias - //~^ ERROR expected value, found type alias `Alias` - //~| ERROR expected value, found type alias `Alias` - //~| ERROR expected value, found type alias `Alias` + //~^ ERROR cannot find value `Alias` in this scope + //~| ERROR cannot find value `Alias` in this scope + //~| ERROR cannot find value `Alias` in this scope }; } macro_rules! create { (type method) => { Vec.new() - //~^ ERROR expected value, found struct `Vec` + //~^ ERROR cannot find value `Vec` in this scope //~| HELP use the path separator }; (type field) => { Vec.new - //~^ ERROR expected value, found struct `Vec` + //~^ ERROR cannot find value `Vec` in this scope //~| HELP use the path separator }; (macro method) => { @@ -71,22 +71,20 @@ macro_rules! create { macro_rules! check_ty { ($Ty:ident) => { $Ty.foo - //~^ ERROR expected value, found type alias `Alias` - //~| HELP use the path separator + //~^ HELP use the path separator }; } macro_rules! check_ident { ($Ident:ident) => { Alias.$Ident - //~^ ERROR expected value, found type alias `Alias` + //~^ ERROR cannot find value `Alias` in this scope //~| HELP use the path separator }; } macro_rules! check_ty_ident { ($Ty:ident, $Ident:ident) => { $Ty.$Ident - //~^ ERROR expected value, found type alias `Alias` - //~| HELP use the path separator + //~^ HELP use the path separator }; } @@ -118,6 +116,8 @@ fn interaction_with_macros() { let _ = create!(macro method alias); let _ = check_ty!(Alias); + //~^ ERROR cannot find value `Alias` in this scope let _ = check_ident!(foo); let _ = check_ty_ident!(Alias, foo); + //~^ ERROR cannot find value `Alias` in this scope } diff --git a/tests/ui/resolve/dot-notation-type-namespace-suggest-path-sep.stderr b/tests/ui/resolve/dot-notation-type-namespace-suggest-path-sep.stderr index e0e2c3a5fd822..c477e94ceb54f 100644 --- a/tests/ui/resolve/dot-notation-type-namespace-suggest-path-sep.stderr +++ b/tests/ui/resolve/dot-notation-type-namespace-suggest-path-sep.stderr @@ -1,84 +1,91 @@ -error[E0423]: expected value, found struct `String` +error[E0423]: cannot find value `String` in this scope --> $DIR/dot-notation-type-namespace-suggest-path-sep.rs:10:13 | LL | let _ = String.new(); | ^^^^^^ | + = note: a struct named `String` exists in another namespace help: use the path separator to refer to an item | LL - let _ = String.new(); LL + let _ = String::new(); | -error[E0423]: expected value, found struct `String` +error[E0423]: cannot find value `String` in this scope --> $DIR/dot-notation-type-namespace-suggest-path-sep.rs:14:13 | LL | let _ = String.default; | ^^^^^^ | + = note: a struct named `String` exists in another namespace help: use the path separator to refer to an item | LL - let _ = String.default; LL + let _ = String::default; | -error[E0423]: expected value, found struct `Vec` +error[E0423]: cannot find value `Vec` in this scope --> $DIR/dot-notation-type-namespace-suggest-path-sep.rs:18:13 | LL | let _ = Vec::<()>.with_capacity(1); - | ^^^^^^^^^ + | ^^^ | + = note: a struct named `Vec` exists in another namespace help: use the path separator to refer to an item | LL - let _ = Vec::<()>.with_capacity(1); LL + let _ = Vec::<()>::with_capacity(1); | -error[E0423]: expected value, found type alias `Alias` +error[E0423]: cannot find value `Alias` in this scope --> $DIR/dot-notation-type-namespace-suggest-path-sep.rs:22:13 | LL | let _ = Alias.new(); | ^^^^^ | + = note: a type alias named `Alias` exists in another namespace help: use the path separator to refer to an item | LL - let _ = Alias.new(); LL + let _ = Alias::new(); | -error[E0423]: expected value, found type alias `Alias` +error[E0423]: cannot find value `Alias` in this scope --> $DIR/dot-notation-type-namespace-suggest-path-sep.rs:26:13 | LL | let _ = Alias.default; | ^^^^^ | + = note: a type alias named `Alias` exists in another namespace help: use the path separator to refer to an item | LL - let _ = Alias.default; LL + let _ = Alias::default; | -error[E0423]: expected value, found module `foo` +error[E0423]: cannot find value `foo` in this scope --> $DIR/dot-notation-type-namespace-suggest-path-sep.rs:30:13 | LL | let _ = foo.bar; | ^^^ | + = note: a module named `foo` exists in another namespace help: use the path separator to refer to an item | LL - let _ = foo.bar; LL + let _ = foo::bar; | -error[E0423]: expected value, found struct `::std::cell::Cell` - --> $DIR/dot-notation-type-namespace-suggest-path-sep.rs:37:9 +error[E0423]: cannot find value `Cell` in module `::std::cell` + --> $DIR/dot-notation-type-namespace-suggest-path-sep.rs:37:22 | LL | ::std::cell::Cell - | ^^^^^^^^^^^^^^^^^ + | ^^^^ ... LL | Type!().get(); | ------- in this macro invocation | + = note: a struct named `::std::cell::Cell` exists in another namespace = note: this error originates in the macro `Type` (in Nightly builds, run with -Z macro-backtrace for more info) help: use the path separator to refer to an item | @@ -86,15 +93,16 @@ LL - Type!().get(); LL + ::get(); | -error[E0423]: expected value, found struct `::std::cell::Cell` - --> $DIR/dot-notation-type-namespace-suggest-path-sep.rs:37:9 +error[E0423]: cannot find value `Cell` in module `::std::cell` + --> $DIR/dot-notation-type-namespace-suggest-path-sep.rs:37:22 | LL | ::std::cell::Cell - | ^^^^^^^^^^^^^^^^^ + | ^^^^ ... LL | Type! {}.get; | -------- in this macro invocation | + = note: a struct named `::std::cell::Cell` exists in another namespace = note: this error originates in the macro `Type` (in Nightly builds, run with -Z macro-backtrace for more info) help: use the path separator to refer to an item | @@ -102,7 +110,7 @@ LL - Type! {}.get; LL + ::get; | -error[E0423]: expected value, found type alias `Alias` +error[E0423]: cannot find value `Alias` in this scope --> $DIR/dot-notation-type-namespace-suggest-path-sep.rs:43:9 | LL | Alias @@ -111,6 +119,7 @@ LL | Alias LL | Type!(alias).get(); | ------------ in this macro invocation | + = note: a type alias named `Alias` exists in another namespace = note: this error originates in the macro `Type` (in Nightly builds, run with -Z macro-backtrace for more info) help: use the path separator to refer to an item | @@ -118,7 +127,7 @@ LL - Type!(alias).get(); LL + ::get(); | -error[E0423]: expected value, found type alias `Alias` +error[E0423]: cannot find value `Alias` in this scope --> $DIR/dot-notation-type-namespace-suggest-path-sep.rs:43:9 | LL | Alias @@ -127,6 +136,7 @@ LL | Alias LL | Type! {alias}.get; | ------------- in this macro invocation | + = note: a type alias named `Alias` exists in another namespace = note: this error originates in the macro `Type` (in Nightly builds, run with -Z macro-backtrace for more info) help: use the path separator to refer to an item | @@ -134,7 +144,7 @@ LL - Type! {alias}.get; LL + ::get; | -error[E0423]: expected value, found struct `Vec` +error[E0423]: cannot find value `Vec` in this scope --> $DIR/dot-notation-type-namespace-suggest-path-sep.rs:52:9 | LL | Vec.new() @@ -143,6 +153,7 @@ LL | Vec.new() LL | let _ = create!(type method); | -------------------- in this macro invocation | + = note: a struct named `Vec` exists in another namespace = note: this error originates in the macro `create` (in Nightly builds, run with -Z macro-backtrace for more info) help: use the path separator to refer to an item | @@ -150,7 +161,7 @@ LL - Vec.new() LL + Vec::new() | -error[E0423]: expected value, found struct `Vec` +error[E0423]: cannot find value `Vec` in this scope --> $DIR/dot-notation-type-namespace-suggest-path-sep.rs:57:9 | LL | Vec.new @@ -159,6 +170,7 @@ LL | Vec.new LL | let _ = create!(type field); | ------------------- in this macro invocation | + = note: a struct named `Vec` exists in another namespace = note: this error originates in the macro `create` (in Nightly builds, run with -Z macro-backtrace for more info) help: use the path separator to refer to an item | @@ -166,15 +178,16 @@ LL - Vec.new LL + Vec::new | -error[E0423]: expected value, found struct `::std::cell::Cell` - --> $DIR/dot-notation-type-namespace-suggest-path-sep.rs:37:9 +error[E0423]: cannot find value `Cell` in module `::std::cell` + --> $DIR/dot-notation-type-namespace-suggest-path-sep.rs:37:22 | LL | ::std::cell::Cell - | ^^^^^^^^^^^^^^^^^ + | ^^^^ ... LL | let _ = create!(macro method); | --------------------- in this macro invocation | + = note: a struct named `::std::cell::Cell` exists in another namespace = note: this error originates in the macro `Type` which comes from the expansion of the macro `create` (in Nightly builds, run with -Z macro-backtrace for more info) help: use the path separator to refer to an item | @@ -182,7 +195,7 @@ LL - Type!().new(0) LL + ::new(0) | -error[E0423]: expected value, found type alias `Alias` +error[E0423]: cannot find value `Alias` in this scope --> $DIR/dot-notation-type-namespace-suggest-path-sep.rs:43:9 | LL | Alias @@ -191,6 +204,7 @@ LL | Alias LL | let _ = create!(macro method alias); | --------------------------- in this macro invocation | + = note: a type alias named `Alias` exists in another namespace = note: this error originates in the macro `Type` which comes from the expansion of the macro `create` (in Nightly builds, run with -Z macro-backtrace for more info) help: use the path separator to refer to an item | @@ -198,24 +212,24 @@ LL - Type!(alias).new(0) LL + ::new(0) | -error[E0423]: expected value, found type alias `Alias` - --> $DIR/dot-notation-type-namespace-suggest-path-sep.rs:73:9 +error[E0423]: cannot find value `Alias` in this scope + --> $DIR/dot-notation-type-namespace-suggest-path-sep.rs:118:23 | LL | $Ty.foo - | ^^^ + | --- due to this macro variable ... LL | let _ = check_ty!(Alias); - | ---------------- in this macro invocation + | ^^^^^ | - = note: this error originates in the macro `check_ty` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: a type alias named `Alias` exists in another namespace help: use the path separator to refer to an item | LL - $Ty.foo LL + $Ty::foo | -error[E0423]: expected value, found type alias `Alias` - --> $DIR/dot-notation-type-namespace-suggest-path-sep.rs:80:9 +error[E0423]: cannot find value `Alias` in this scope + --> $DIR/dot-notation-type-namespace-suggest-path-sep.rs:79:9 | LL | Alias.$Ident | ^^^^^ @@ -223,6 +237,7 @@ LL | Alias.$Ident LL | let _ = check_ident!(foo); | ----------------- in this macro invocation | + = note: a type alias named `Alias` exists in another namespace = note: this error originates in the macro `check_ident` (in Nightly builds, run with -Z macro-backtrace for more info) help: use the path separator to refer to an item | @@ -230,16 +245,16 @@ LL - Alias.$Ident LL + ::$Ident | -error[E0423]: expected value, found type alias `Alias` - --> $DIR/dot-notation-type-namespace-suggest-path-sep.rs:87:9 +error[E0423]: cannot find value `Alias` in this scope + --> $DIR/dot-notation-type-namespace-suggest-path-sep.rs:121:29 | LL | $Ty.$Ident - | ^^^ + | --- due to this macro variable ... LL | let _ = check_ty_ident!(Alias, foo); - | --------------------------- in this macro invocation + | ^^^^^ | - = note: this error originates in the macro `check_ty_ident` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: a type alias named `Alias` exists in another namespace help: use the path separator to refer to an item | LL - $Ty.$Ident diff --git a/tests/ui/resolve/empty-struct-braces-expr.rs b/tests/ui/resolve/empty-struct-braces-expr.rs index f6a174290e341..63b5770db4afe 100644 --- a/tests/ui/resolve/empty-struct-braces-expr.rs +++ b/tests/ui/resolve/empty-struct-braces-expr.rs @@ -12,16 +12,16 @@ enum E { } fn main() { - let e1 = Empty1; //~ ERROR expected value, found struct `Empty1` + let e1 = Empty1; //~ ERROR cannot find value `Empty1` in this scope let e1 = Empty1(); - //~^ ERROR expected function, tuple struct or tuple variant, found struct `Empty1` + //~^ ERROR cannot find function, tuple struct or tuple variant `Empty1` in this scope let e3 = E::Empty3; //~ ERROR expected value, found struct variant `E::Empty3` let e3 = E::Empty3(); //~^ ERROR expected value, found struct variant `E::Empty3` - let xe1 = XEmpty1; //~ ERROR expected value, found struct `XEmpty1` + let xe1 = XEmpty1; //~ ERROR cannot find value `XEmpty1` in this scope let xe1 = XEmpty1(); - //~^ ERROR expected function, tuple struct or tuple variant, found struct `XEmpty1` + //~^ ERROR cannot find function, tuple struct or tuple variant `XEmpty1` in this scope let xe3 = XE::Empty3; //~ ERROR no variant, associated function, or constant named `Empty3` found for enum let xe3 = XE::Empty3(); //~ ERROR no variant, associated function, or constant named `Empty3` found for enum diff --git a/tests/ui/resolve/empty-struct-braces-expr.stderr b/tests/ui/resolve/empty-struct-braces-expr.stderr index f496708512a4d..a38339f25d536 100644 --- a/tests/ui/resolve/empty-struct-braces-expr.stderr +++ b/tests/ui/resolve/empty-struct-braces-expr.stderr @@ -1,4 +1,4 @@ -error[E0423]: expected value, found struct `Empty1` +error[E0423]: cannot find value `Empty1` in this scope --> $DIR/empty-struct-braces-expr.rs:15:14 | LL | struct Empty1 {} @@ -12,6 +12,7 @@ LL | let e1 = Empty1; LL | pub struct XEmpty2; | ------------------ similarly named unit struct `XEmpty2` defined here | + = note: a struct named `Empty1` exists in another namespace help: use struct literal syntax instead | LL | let e1 = Empty1 {}; @@ -22,7 +23,7 @@ LL - let e1 = Empty1; LL + let e1 = XEmpty2; | -error[E0423]: expected value, found struct `XEmpty1` +error[E0423]: cannot find value `XEmpty1` in this scope --> $DIR/empty-struct-braces-expr.rs:22:15 | LL | let xe1 = XEmpty1; @@ -35,6 +36,7 @@ LL | pub struct XEmpty1 {} LL | pub struct XEmpty2; | ------------------ similarly named unit struct `XEmpty2` defined here | + = note: a struct named `XEmpty1` exists in another namespace help: use struct literal syntax instead | LL | let xe1 = XEmpty1 {}; @@ -45,7 +47,7 @@ LL - let xe1 = XEmpty1; LL + let xe1 = XEmpty2; | -error[E0423]: expected function, tuple struct or tuple variant, found struct `Empty1` +error[E0423]: cannot find function, tuple struct or tuple variant `Empty1` in this scope --> $DIR/empty-struct-braces-expr.rs:16:14 | LL | struct Empty1 {} @@ -59,6 +61,7 @@ LL | let e1 = Empty1(); LL | pub struct XEmpty2; | ------------------ similarly named unit struct `XEmpty2` defined here | + = note: a struct named `Empty1` exists in another namespace help: use struct literal syntax instead | LL - let e1 = Empty1(); @@ -93,7 +96,7 @@ LL - let e3 = E::Empty3(); LL + let e3 = E::Empty3 {}; | -error[E0423]: expected function, tuple struct or tuple variant, found struct `XEmpty1` +error[E0423]: cannot find function, tuple struct or tuple variant `XEmpty1` in this scope --> $DIR/empty-struct-braces-expr.rs:23:15 | LL | let xe1 = XEmpty1(); @@ -106,6 +109,7 @@ LL | pub struct XEmpty1 {} LL | pub struct XEmpty2; | ------------------ similarly named unit struct `XEmpty2` defined here | + = note: a struct named `XEmpty1` exists in another namespace help: use struct literal syntax instead | LL - let xe1 = XEmpty1(); diff --git a/tests/ui/resolve/empty-struct-braces-pat-2.rs b/tests/ui/resolve/empty-struct-braces-pat-2.rs index df5a231e26860..cde37d7eb4258 100644 --- a/tests/ui/resolve/empty-struct-braces-pat-2.rs +++ b/tests/ui/resolve/empty-struct-braces-pat-2.rs @@ -12,15 +12,15 @@ fn main() { let xe1 = XEmpty1 {}; match e1 { - Empty1() => () //~ ERROR expected tuple struct or tuple variant, found struct `Empty1` + Empty1() => () //~ ERROR cannot find tuple struct or tuple variant `Empty1` in this scope } match xe1 { - XEmpty1() => () //~ ERROR expected tuple struct or tuple variant, found struct `XEmpty1` + XEmpty1() => () //~ ERROR cannot find tuple struct or tuple variant `XEmpty1` in this scope } match e1 { - Empty1(..) => () //~ ERROR expected tuple struct or tuple variant, found struct `Empty1` + Empty1(..) => () //~ ERROR cannot find tuple struct or tuple variant `Empty1` in this scope } match xe1 { - XEmpty1(..) => () //~ ERROR expected tuple struct or tuple variant, found struct `XEmpty1` + XEmpty1(..) => () //~ ERROR cannot find tuple struct or tuple variant `XEmpty1` in this scope } } diff --git a/tests/ui/resolve/empty-struct-braces-pat-2.stderr b/tests/ui/resolve/empty-struct-braces-pat-2.stderr index 497dc9601a716..733b894a45076 100644 --- a/tests/ui/resolve/empty-struct-braces-pat-2.stderr +++ b/tests/ui/resolve/empty-struct-braces-pat-2.stderr @@ -1,4 +1,4 @@ -error[E0532]: expected tuple struct or tuple variant, found struct `Empty1` +error[E0532]: cannot find tuple struct or tuple variant `Empty1` in this scope --> $DIR/empty-struct-braces-pat-2.rs:15:9 | LL | struct Empty1 {} @@ -12,6 +12,7 @@ LL | Empty1() => () LL | pub struct XEmpty6(); | ------------------ similarly named tuple struct `XEmpty6` defined here | + = note: a struct named `Empty1` exists in another namespace help: use struct pattern syntax instead | LL - Empty1() => () @@ -23,7 +24,7 @@ LL - Empty1() => () LL + XEmpty6() => () | -error[E0532]: expected tuple struct or tuple variant, found struct `XEmpty1` +error[E0532]: cannot find tuple struct or tuple variant `XEmpty1` in this scope --> $DIR/empty-struct-braces-pat-2.rs:18:9 | LL | XEmpty1() => () @@ -37,6 +38,7 @@ LL | pub struct XEmpty2; LL | pub struct XEmpty6(); | ------------------ similarly named tuple struct `XEmpty6` defined here | + = note: a struct named `XEmpty1` exists in another namespace help: use struct pattern syntax instead | LL - XEmpty1() => () @@ -48,7 +50,7 @@ LL - XEmpty1() => () LL + XEmpty6() => () | -error[E0532]: expected tuple struct or tuple variant, found struct `Empty1` +error[E0532]: cannot find tuple struct or tuple variant `Empty1` in this scope --> $DIR/empty-struct-braces-pat-2.rs:21:9 | LL | struct Empty1 {} @@ -62,6 +64,7 @@ LL | Empty1(..) => () LL | pub struct XEmpty6(); | ------------------ similarly named tuple struct `XEmpty6` defined here | + = note: a struct named `Empty1` exists in another namespace help: use struct pattern syntax instead | LL - Empty1(..) => () @@ -73,7 +76,7 @@ LL - Empty1(..) => () LL + XEmpty6(..) => () | -error[E0532]: expected tuple struct or tuple variant, found struct `XEmpty1` +error[E0532]: cannot find tuple struct or tuple variant `XEmpty1` in this scope --> $DIR/empty-struct-braces-pat-2.rs:24:9 | LL | XEmpty1(..) => () @@ -87,6 +90,7 @@ LL | pub struct XEmpty2; LL | pub struct XEmpty6(); | ------------------ similarly named tuple struct `XEmpty6` defined here | + = note: a struct named `XEmpty1` exists in another namespace help: use struct pattern syntax instead | LL - XEmpty1(..) => () diff --git a/tests/ui/resolve/enum-expected-value-suggest-variants.rs b/tests/ui/resolve/enum-expected-value-suggest-variants.rs index c0965ce5e147d..6341f96d0824a 100644 --- a/tests/ui/resolve/enum-expected-value-suggest-variants.rs +++ b/tests/ui/resolve/enum-expected-value-suggest-variants.rs @@ -14,37 +14,37 @@ enum Bar { fn main() { let _: Foo = Foo(0); - //~^ ERROR expected function + //~^ ERROR cannot find function, tuple struct or tuple variant `Foo` in this scope //~| HELP try to construct one of the enum's variants let _: Foo = Foo.A(0); - //~^ ERROR expected value, found enum `Foo` + //~^ ERROR cannot find value `Foo` in this scope //~| HELP use the path separator to refer to a variant let _: Foo = Foo.Bad(0); - //~^ ERROR expected value, found enum `Foo` + //~^ ERROR cannot find value `Foo` in this scope //~| HELP the following enum variants are available let _: Bar = Bar(0); - //~^ ERROR expected function + //~^ ERROR cannot find function, tuple struct or tuple variant `Bar` in this scope //~| HELP try to construct one of the enum's variants //~| HELP you might have meant to construct one of the enum's non-tuple variants let _: Bar = Bar.C(0); - //~^ ERROR expected value, found enum `Bar` + //~^ ERROR cannot find value `Bar` in this scope //~| HELP use the path separator to refer to a variant let _: Bar = Bar.E; - //~^ ERROR expected value, found enum `Bar` + //~^ ERROR cannot find value `Bar` in this scope //~| HELP use the path separator to refer to a variant let _: Bar = Bar.Bad(0); - //~^ ERROR expected value, found enum `Bar` + //~^ ERROR cannot find value `Bar` in this scope //~| HELP you might have meant to use one of the following enum variants //~| HELP alternatively, the following enum variants are also available let _: Bar = Bar.Bad; - //~^ ERROR expected value, found enum `Bar` + //~^ ERROR cannot find value `Bar` in this scope //~| HELP you might have meant to use one of the following enum variants //~| HELP alternatively, the following enum variants are also available @@ -52,7 +52,7 @@ fn main() { A(..) => {} //~^ ERROR cannot find tuple struct or tuple variant `A` in this scope Foo(..) => {} - //~^ ERROR expected tuple struct or tuple variant + //~^ ERROR cannot find tuple struct or tuple variant `Foo` in this scope //~| HELP try to match against one of the enum's variants _ => {} } diff --git a/tests/ui/resolve/enum-expected-value-suggest-variants.stderr b/tests/ui/resolve/enum-expected-value-suggest-variants.stderr index 4b0f291a0fc2d..0bd4f0cbc8f80 100644 --- a/tests/ui/resolve/enum-expected-value-suggest-variants.stderr +++ b/tests/ui/resolve/enum-expected-value-suggest-variants.stderr @@ -1,9 +1,10 @@ -error[E0423]: expected value, found enum `Foo` +error[E0423]: cannot find value `Foo` in this scope --> $DIR/enum-expected-value-suggest-variants.rs:20:18 | LL | let _: Foo = Foo.A(0); | ^^^ | + = note: an enum named `Foo` exists in another namespace note: the enum is defined here --> $DIR/enum-expected-value-suggest-variants.rs:2:1 | @@ -19,12 +20,13 @@ LL - let _: Foo = Foo.A(0); LL + let _: Foo = Foo::A(0); | -error[E0423]: expected value, found enum `Foo` +error[E0423]: cannot find value `Foo` in this scope --> $DIR/enum-expected-value-suggest-variants.rs:24:18 | LL | let _: Foo = Foo.Bad(0); | ^^^ | + = note: an enum named `Foo` exists in another namespace note: the enum is defined here --> $DIR/enum-expected-value-suggest-variants.rs:2:1 | @@ -43,12 +45,13 @@ LL - let _: Foo = Foo.Bad(0); LL + let _: Foo = (Foo::B(/* fields */)).Bad(0); | -error[E0423]: expected value, found enum `Bar` +error[E0423]: cannot find value `Bar` in this scope --> $DIR/enum-expected-value-suggest-variants.rs:33:18 | LL | let _: Bar = Bar.C(0); | ^^^ | + = note: an enum named `Bar` exists in another namespace note: the enum is defined here --> $DIR/enum-expected-value-suggest-variants.rs:8:1 | @@ -65,12 +68,13 @@ LL - let _: Bar = Bar.C(0); LL + let _: Bar = Bar::C(0); | -error[E0423]: expected value, found enum `Bar` +error[E0423]: cannot find value `Bar` in this scope --> $DIR/enum-expected-value-suggest-variants.rs:37:18 | LL | let _: Bar = Bar.E; | ^^^ | + = note: an enum named `Bar` exists in another namespace note: the enum is defined here --> $DIR/enum-expected-value-suggest-variants.rs:8:1 | @@ -87,12 +91,13 @@ LL - let _: Bar = Bar.E; LL + let _: Bar = Bar::E; | -error[E0423]: expected value, found enum `Bar` +error[E0423]: cannot find value `Bar` in this scope --> $DIR/enum-expected-value-suggest-variants.rs:41:18 | LL | let _: Bar = Bar.Bad(0); | ^^^ | + = note: an enum named `Bar` exists in another namespace note: the enum is defined here --> $DIR/enum-expected-value-suggest-variants.rs:8:1 | @@ -118,12 +123,13 @@ LL - let _: Bar = Bar.Bad(0); LL + let _: Bar = (Bar::D(/* fields */)).Bad(0); | -error[E0423]: expected value, found enum `Bar` +error[E0423]: cannot find value `Bar` in this scope --> $DIR/enum-expected-value-suggest-variants.rs:46:18 | LL | let _: Bar = Bar.Bad; | ^^^ | + = note: an enum named `Bar` exists in another namespace note: the enum is defined here --> $DIR/enum-expected-value-suggest-variants.rs:8:1 | @@ -160,12 +166,13 @@ help: consider importing this tuple variant LL + use Foo::A; | -error[E0532]: expected tuple struct or tuple variant, found enum `Foo` +error[E0532]: cannot find tuple struct or tuple variant `Foo` in this scope --> $DIR/enum-expected-value-suggest-variants.rs:54:9 | LL | Foo(..) => {} | ^^^ | + = note: an enum named `Foo` exists in another namespace note: the enum is defined here --> $DIR/enum-expected-value-suggest-variants.rs:2:1 | @@ -182,12 +189,13 @@ LL | Foo::A(..) => {} LL | Foo::B(..) => {} | +++ -error[E0423]: expected function, tuple struct or tuple variant, found enum `Foo` +error[E0423]: cannot find function, tuple struct or tuple variant `Foo` in this scope --> $DIR/enum-expected-value-suggest-variants.rs:16:18 | LL | let _: Foo = Foo(0); | ^^^ | + = note: an enum named `Foo` exists in another namespace note: the enum is defined here --> $DIR/enum-expected-value-suggest-variants.rs:2:1 | @@ -204,12 +212,13 @@ LL | let _: Foo = Foo::A(0); LL | let _: Foo = Foo::B(0); | +++ -error[E0423]: expected function, tuple struct or tuple variant, found enum `Bar` +error[E0423]: cannot find function, tuple struct or tuple variant `Bar` in this scope --> $DIR/enum-expected-value-suggest-variants.rs:28:18 | LL | let _: Bar = Bar(0); | ^^^ | + = note: an enum named `Bar` exists in another namespace = help: you might have meant to construct one of the enum's non-tuple variants note: the enum is defined here --> $DIR/enum-expected-value-suggest-variants.rs:8:1 diff --git a/tests/ui/resolve/impl-on-non-type.rs b/tests/ui/resolve/impl-on-non-type.rs index 3db13d520f9fe..91dc41db700c7 100644 --- a/tests/ui/resolve/impl-on-non-type.rs +++ b/tests/ui/resolve/impl-on-non-type.rs @@ -4,10 +4,10 @@ static Y: u8 = 1; fn foo() {} impl X {} -//~^ ERROR expected type, found constant `X` +//~^ ERROR cannot find type `X` in this scope impl Y {} -//~^ ERROR expected type, found static `Y` +//~^ ERROR cannot find type `Y` in this scope impl foo {} -//~^ ERROR expected type, found function `foo` +//~^ ERROR cannot find type `foo` in this scope fn main() {} diff --git a/tests/ui/resolve/impl-on-non-type.stderr b/tests/ui/resolve/impl-on-non-type.stderr index 99cc405015b58..089b9a105d07d 100644 --- a/tests/ui/resolve/impl-on-non-type.stderr +++ b/tests/ui/resolve/impl-on-non-type.stderr @@ -1,20 +1,26 @@ -error[E0573]: expected type, found constant `X` +error[E0573]: cannot find type `X` in this scope --> $DIR/impl-on-non-type.rs:6:6 | LL | impl X {} - | ^ not a type + | ^ not found in this scope + | + = note: a constant named `X` exists in another namespace -error[E0573]: expected type, found static `Y` +error[E0573]: cannot find type `Y` in this scope --> $DIR/impl-on-non-type.rs:8:6 | LL | impl Y {} - | ^ not a type + | ^ not found in this scope + | + = note: a static named `Y` exists in another namespace -error[E0573]: expected type, found function `foo` +error[E0573]: cannot find type `foo` in this scope --> $DIR/impl-on-non-type.rs:10:6 | LL | impl foo {} - | ^^^ not a type + | ^^^ not found in this scope + | + = note: a function named `foo` exists in another namespace error: aborting due to 3 previous errors diff --git a/tests/ui/resolve/issue-100365.rs b/tests/ui/resolve/issue-100365.rs index 2ecaf93601013..572b245bd48bc 100644 --- a/tests/ui/resolve/issue-100365.rs +++ b/tests/ui/resolve/issue-100365.rs @@ -1,29 +1,29 @@ fn main() { let addr = Into::.into([127, 0, 0, 1]); - //~^ ERROR expected value, found trait `Into` + //~^ ERROR cannot find value `Into` in this scope //~| HELP use the path separator let _ = Into.into(()); - //~^ ERROR expected value, found trait `Into` + //~^ ERROR cannot find value `Into` in this scope //~| HELP use the path separator let _ = Into::<()>.into; - //~^ ERROR expected value, found trait `Into` + //~^ ERROR cannot find value `Into` in this scope //~| HELP use the path separator } macro_rules! Trait { () => { ::std::iter::Iterator - //~^ ERROR expected value, found trait `::std::iter::Iterator` - //~| ERROR expected value, found trait `::std::iter::Iterator` + //~^ ERROR cannot find value `Iterator` in module `::std::iter` + //~| ERROR cannot find value `Iterator` in module `::std::iter` }; } macro_rules! create { () => { Into::.into("") - //~^ ERROR expected value, found trait `Into` + //~^ ERROR cannot find value `Into` in this scope //~| HELP use the path separator }; } diff --git a/tests/ui/resolve/issue-100365.stderr b/tests/ui/resolve/issue-100365.stderr index 7dea31713df2f..d1dd5870f193a 100644 --- a/tests/ui/resolve/issue-100365.stderr +++ b/tests/ui/resolve/issue-100365.stderr @@ -1,70 +1,76 @@ -error[E0423]: expected value, found trait `Into` +error[E0423]: cannot find value `Into` in this scope --> $DIR/issue-100365.rs:2:16 | LL | let addr = Into::.into([127, 0, 0, 1]); - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^ | + = note: a trait named `Into` exists in another namespace help: use the path separator to refer to an item | LL - let addr = Into::.into([127, 0, 0, 1]); LL + let addr = Into::::into([127, 0, 0, 1]); | -error[E0423]: expected value, found trait `Into` +error[E0423]: cannot find value `Into` in this scope --> $DIR/issue-100365.rs:6:13 | LL | let _ = Into.into(()); | ^^^^ | + = note: a trait named `Into` exists in another namespace help: use the path separator to refer to an item | LL - let _ = Into.into(()); LL + let _ = Into::into(()); | -error[E0423]: expected value, found trait `Into` +error[E0423]: cannot find value `Into` in this scope --> $DIR/issue-100365.rs:10:13 | LL | let _ = Into::<()>.into; - | ^^^^^^^^^^ + | ^^^^ | + = note: a trait named `Into` exists in another namespace help: use the path separator to refer to an item | LL - let _ = Into::<()>.into; LL + let _ = Into::<()>::into; | -error[E0423]: expected value, found trait `::std::iter::Iterator` - --> $DIR/issue-100365.rs:17:9 +error[E0423]: cannot find value `Iterator` in module `::std::iter` + --> $DIR/issue-100365.rs:17:22 | LL | ::std::iter::Iterator - | ^^^^^^^^^^^^^^^^^^^^^ not a value + | ^^^^^^^^ not found in `::std::iter` ... LL | Trait!().map(std::convert::identity); // no `help` here! | -------- in this macro invocation | + = note: a trait named `::std::iter::Iterator` exists in another namespace = note: this error originates in the macro `Trait` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0423]: expected value, found trait `::std::iter::Iterator` - --> $DIR/issue-100365.rs:17:9 +error[E0423]: cannot find value `Iterator` in module `::std::iter` + --> $DIR/issue-100365.rs:17:22 | LL | ::std::iter::Iterator - | ^^^^^^^^^^^^^^^^^^^^^ not a value + | ^^^^^^^^ not found in `::std::iter` ... LL | Trait!().map; // no `help` here! | -------- in this macro invocation | + = note: a trait named `::std::iter::Iterator` exists in another namespace = note: this error originates in the macro `Trait` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0423]: expected value, found trait `Into` +error[E0423]: cannot find value `Into` in this scope --> $DIR/issue-100365.rs:25:9 | LL | Into::.into("") - | ^^^^^^^^^^^^^^ + | ^^^^ ... LL | let _ = create!(); | --------- in this macro invocation | + = note: a trait named `Into` exists in another namespace = note: this error originates in the macro `create` (in Nightly builds, run with -Z macro-backtrace for more info) help: use the path separator to refer to an item | diff --git a/tests/ui/resolve/issue-2356.rs b/tests/ui/resolve/issue-2356.rs index fe9bf4d443e72..2a8b3a8c8a449 100644 --- a/tests/ui/resolve/issue-2356.rs +++ b/tests/ui/resolve/issue-2356.rs @@ -63,7 +63,7 @@ impl Cat { impl Cat { fn meow() { if self.whiskers > 3 { - //~^ ERROR expected value, found module `self` + //~^ ERROR cannot find value `self` in this scope println!("MEOW"); } } @@ -90,5 +90,5 @@ impl Cat { fn main() { self += 1; - //~^ ERROR expected value, found module `self` + //~^ ERROR cannot find value `self` in this scope } diff --git a/tests/ui/resolve/issue-2356.stderr b/tests/ui/resolve/issue-2356.stderr index 74a2c9268a2f9..3dfb81d440f6c 100644 --- a/tests/ui/resolve/issue-2356.stderr +++ b/tests/ui/resolve/issue-2356.stderr @@ -7,7 +7,7 @@ LL | whiskers: isize, LL | whiskers -= other; | ^^^^^^^^ -error[E0424]: expected value, found module `self` +error[E0424]: cannot find value `self` in this scope --> $DIR/issue-2356.rs:65:8 | LL | fn meow() { @@ -15,6 +15,7 @@ LL | fn meow() { LL | if self.whiskers > 3 { | ^^^^ `self` value is a keyword only available in methods with a `self` parameter | + = note: a module named `self` exists in another namespace help: add a `self` receiver parameter to make the associated `fn` a method | LL | fn meow(&self) { @@ -40,13 +41,15 @@ LL | whiskers: isize, LL | whiskers = 4; | ^^^^^^^^ -error[E0424]: expected value, found module `self` +error[E0424]: cannot find value `self` in this scope --> $DIR/issue-2356.rs:92:5 | LL | fn main() { | ---- this function can't have a `self` parameter LL | self += 1; | ^^^^ `self` value is a keyword only available in methods with a `self` parameter + | + = note: a module named `self` exists in another namespace error[E0425]: cannot find function `shave` in this scope --> $DIR/issue-2356.rs:17:5 diff --git a/tests/ui/resolve/issue-33876.rs b/tests/ui/resolve/issue-33876.rs index e233ec631cc13..5a0195b9d79ce 100644 --- a/tests/ui/resolve/issue-33876.rs +++ b/tests/ui/resolve/issue-33876.rs @@ -7,6 +7,6 @@ trait Bar {} impl Bar for Foo {} fn main() { - let any: &dyn Any = &Bar; //~ ERROR expected value, found trait `Bar` + let any: &dyn Any = &Bar; //~ ERROR cannot find value `Bar` in this scope if any.is::() { println!("u32"); } } diff --git a/tests/ui/resolve/issue-33876.stderr b/tests/ui/resolve/issue-33876.stderr index 12e1b4b0bd3c3..3fcb4eae8cb15 100644 --- a/tests/ui/resolve/issue-33876.stderr +++ b/tests/ui/resolve/issue-33876.stderr @@ -1,8 +1,10 @@ -error[E0423]: expected value, found trait `Bar` +error[E0423]: cannot find value `Bar` in this scope --> $DIR/issue-33876.rs:10:26 | LL | let any: &dyn Any = &Bar; - | ^^^ not a value + | ^^^ not found in this scope + | + = note: a trait named `Bar` exists in another namespace error: aborting due to 1 previous error diff --git a/tests/ui/resolve/issue-39226.rs b/tests/ui/resolve/issue-39226.rs index 0f784f02b41b6..b9596bac0c556 100644 --- a/tests/ui/resolve/issue-39226.rs +++ b/tests/ui/resolve/issue-39226.rs @@ -9,6 +9,6 @@ fn main() { let s: Something = Something { handle: Handle - //~^ ERROR expected value, found struct `Handle` + //~^ ERROR cannot find value `Handle` in this scope }; } diff --git a/tests/ui/resolve/issue-39226.stderr b/tests/ui/resolve/issue-39226.stderr index 1cd2a5fb2216e..59449c715d04a 100644 --- a/tests/ui/resolve/issue-39226.stderr +++ b/tests/ui/resolve/issue-39226.stderr @@ -1,4 +1,4 @@ -error[E0423]: expected value, found struct `Handle` +error[E0423]: cannot find value `Handle` in this scope --> $DIR/issue-39226.rs:11:17 | LL | struct Handle {} @@ -7,6 +7,7 @@ LL | struct Handle {} LL | handle: Handle | ^^^^^^ | + = note: a struct named `Handle` exists in another namespace help: use struct literal syntax instead | LL | handle: Handle {} diff --git a/tests/ui/resolve/issue-42944.stderr b/tests/ui/resolve/issue-42944.stderr index a528cde61e6f5..e49ee834a7f21 100644 --- a/tests/ui/resolve/issue-42944.stderr +++ b/tests/ui/resolve/issue-42944.stderr @@ -16,6 +16,7 @@ error[E0423]: cannot initialize a tuple struct which contains private fields LL | Bx(()); | ^^ | + = note: a struct named `Bx` exists in another namespace note: constructor is not visible here due to private fields --> $DIR/issue-42944.rs:3:19 | diff --git a/tests/ui/resolve/issue-6702.rs b/tests/ui/resolve/issue-6702.rs index 954dc36f38e30..502a5ae774421 100644 --- a/tests/ui/resolve/issue-6702.rs +++ b/tests/ui/resolve/issue-6702.rs @@ -5,5 +5,5 @@ struct Monster { fn main() { let _m = Monster(); - //~^ ERROR expected function, tuple struct or tuple variant, found struct `Monster` + //~^ ERROR cannot find function, tuple struct or tuple variant `Monster` in this scope } diff --git a/tests/ui/resolve/issue-6702.stderr b/tests/ui/resolve/issue-6702.stderr index d1ceee3e56e82..dd1f2c5d7f819 100644 --- a/tests/ui/resolve/issue-6702.stderr +++ b/tests/ui/resolve/issue-6702.stderr @@ -1,4 +1,4 @@ -error[E0423]: expected function, tuple struct or tuple variant, found struct `Monster` +error[E0423]: cannot find function, tuple struct or tuple variant `Monster` in this scope --> $DIR/issue-6702.rs:7:14 | LL | / struct Monster { @@ -8,6 +8,8 @@ LL | | } ... LL | let _m = Monster(); | ^^^^^^^^^ help: use struct literal syntax instead: `Monster { damage: val }` + | + = note: a struct named `Monster` exists in another namespace error: aborting due to 1 previous error diff --git a/tests/ui/resolve/issue-73427.rs b/tests/ui/resolve/issue-73427.rs index 5c2459a59036d..c08c8bcfdb45f 100644 --- a/tests/ui/resolve/issue-73427.rs +++ b/tests/ui/resolve/issue-73427.rs @@ -31,20 +31,20 @@ fn main() { // is used rather than a variant. A.foo(); - //~^ ERROR expected value, found enum `A` + //~^ ERROR cannot find value `A` in this scope B.foo(); - //~^ ERROR expected value, found enum `B` + //~^ ERROR cannot find value `B` in this scope C.foo(); - //~^ ERROR expected value, found enum `C` + //~^ ERROR cannot find value `C` in this scope D.foo(); - //~^ ERROR expected value, found enum `D` + //~^ ERROR cannot find value `D` in this scope E.foo(); - //~^ ERROR expected value, found enum `E` + //~^ ERROR cannot find value `E` in this scope // Only tuple variants are suggested in calls or tuple struct pattern matching. let x = A(3); - //~^ ERROR expected function, tuple struct or tuple variant, found enum `A` + //~^ ERROR cannot find function, tuple struct or tuple variant `A` in this scope if let A(3) = x { } - //~^ ERROR expected tuple struct or tuple variant, found enum `A` + //~^ ERROR cannot find tuple struct or tuple variant `A` in this scope } diff --git a/tests/ui/resolve/issue-73427.stderr b/tests/ui/resolve/issue-73427.stderr index 655816ca7b384..e5890dd41b926 100644 --- a/tests/ui/resolve/issue-73427.stderr +++ b/tests/ui/resolve/issue-73427.stderr @@ -1,9 +1,10 @@ -error[E0423]: expected value, found enum `A` +error[E0423]: cannot find value `A` in this scope --> $DIR/issue-73427.rs:33:5 | LL | A.foo(); | ^ | + = note: an enum named `A` exists in another namespace note: the enum is defined here --> $DIR/issue-73427.rs:1:1 | @@ -28,12 +29,13 @@ LL - A.foo(); LL + (A::TupleWithFields(/* fields */)).foo(); | -error[E0423]: expected value, found enum `B` +error[E0423]: cannot find value `B` in this scope --> $DIR/issue-73427.rs:35:5 | LL | B.foo(); | ^ | + = note: an enum named `B` exists in another namespace note: the enum is defined here --> $DIR/issue-73427.rs:9:1 | @@ -48,12 +50,13 @@ LL - B.foo(); LL + (B::TupleWithFields(/* fields */)).foo(); | -error[E0423]: expected value, found enum `C` +error[E0423]: cannot find value `C` in this scope --> $DIR/issue-73427.rs:37:5 | LL | C.foo(); | ^ | + = note: an enum named `C` exists in another namespace note: the enum is defined here --> $DIR/issue-73427.rs:14:1 | @@ -73,12 +76,13 @@ LL - C.foo(); LL + (C::TupleWithFields(/* fields */)).foo(); | -error[E0423]: expected value, found enum `D` +error[E0423]: cannot find value `D` in this scope --> $DIR/issue-73427.rs:39:5 | LL | D.foo(); | ^ | + = note: an enum named `D` exists in another namespace note: the enum is defined here --> $DIR/issue-73427.rs:20:1 | @@ -97,12 +101,13 @@ LL - D.foo(); LL + (D::TupleWithFields(/* fields */)).foo(); | -error[E0423]: expected value, found enum `E` +error[E0423]: cannot find value `E` in this scope --> $DIR/issue-73427.rs:41:5 | LL | E.foo(); | ^ | + = note: an enum named `E` exists in another namespace note: the enum is defined here --> $DIR/issue-73427.rs:25:1 | @@ -126,12 +131,13 @@ LL + use std::f32::consts::E; LL + use std::f64::consts::E; | -error[E0532]: expected tuple struct or tuple variant, found enum `A` +error[E0532]: cannot find tuple struct or tuple variant `A` in this scope --> $DIR/issue-73427.rs:48:12 | LL | if let A(3) = x { } | ^ | + = note: an enum named `A` exists in another namespace = help: you might have meant to match against the enum's non-tuple variant note: the enum is defined here --> $DIR/issue-73427.rs:1:1 @@ -151,12 +157,13 @@ LL | if let A::Tuple(3) = x { } LL | if let A::TupleWithFields(3) = x { } | +++++++++++++++++ -error[E0423]: expected function, tuple struct or tuple variant, found enum `A` +error[E0423]: cannot find function, tuple struct or tuple variant `A` in this scope --> $DIR/issue-73427.rs:46:13 | LL | let x = A(3); | ^ | + = note: an enum named `A` exists in another namespace = help: you might have meant to construct the enum's non-tuple variant note: the enum is defined here --> $DIR/issue-73427.rs:1:1 diff --git a/tests/ui/resolve/no-implicit-prelude-nested.rs b/tests/ui/resolve/no-implicit-prelude-nested.rs index c314967da4fb7..fae52c0edc1aa 100644 --- a/tests/ui/resolve/no-implicit-prelude-nested.rs +++ b/tests/ui/resolve/no-implicit-prelude-nested.rs @@ -9,7 +9,7 @@ mod foo { mod baz { struct Test; impl Add for Test {} //~ ERROR cannot find trait `Add` in this scope - impl Clone for Test {} //~ ERROR expected trait, found derive macro `Clone` + impl Clone for Test {} //~ ERROR cannot find trait `Clone` in this scope impl Iterator for Test {} //~ ERROR cannot find trait `Iterator` in this scope impl ToString for Test {} //~ ERROR cannot find trait `ToString` in this scope impl Writer for Test {} //~ ERROR cannot find trait `Writer` in this scope @@ -21,7 +21,7 @@ mod foo { struct Test; impl Add for Test {} //~ ERROR cannot find trait `Add` in this scope - impl Clone for Test {} //~ ERROR expected trait, found derive macro `Clone` + impl Clone for Test {} //~ ERROR cannot find trait `Clone` in this scope impl Iterator for Test {} //~ ERROR cannot find trait `Iterator` in this scope impl ToString for Test {} //~ ERROR cannot find trait `ToString` in this scope impl Writer for Test {} //~ ERROR cannot find trait `Writer` in this scope @@ -36,7 +36,7 @@ fn qux() { mod qux_inner { struct Test; impl Add for Test {} //~ ERROR cannot find trait `Add` in this scope - impl Clone for Test {} //~ ERROR expected trait, found derive macro `Clone` + impl Clone for Test {} //~ ERROR cannot find trait `Clone` in this scope impl Iterator for Test {} //~ ERROR cannot find trait `Iterator` in this scope impl ToString for Test {} //~ ERROR cannot find trait `ToString` in this scope impl Writer for Test {} //~ ERROR cannot find trait `Writer` in this scope diff --git a/tests/ui/resolve/no-implicit-prelude-nested.stderr b/tests/ui/resolve/no-implicit-prelude-nested.stderr index 49cf72bfee2d6..5ba8dafb08baa 100644 --- a/tests/ui/resolve/no-implicit-prelude-nested.stderr +++ b/tests/ui/resolve/no-implicit-prelude-nested.stderr @@ -9,12 +9,13 @@ help: consider importing this trait LL + use std::ops::Add; | -error[E0404]: expected trait, found derive macro `Clone` +error[E0404]: cannot find trait `Clone` in this scope --> $DIR/no-implicit-prelude-nested.rs:12:14 | LL | impl Clone for Test {} - | ^^^^^ not a trait + | ^^^^^ not found in this scope | + = note: a derive macro named `Clone` exists in another namespace help: consider importing this trait instead | LL + use std::clone::Clone; @@ -70,12 +71,13 @@ help: consider importing this trait LL + use std::ops::Add; | -error[E0404]: expected trait, found derive macro `Clone` +error[E0404]: cannot find trait `Clone` in this scope --> $DIR/no-implicit-prelude-nested.rs:24:10 | LL | impl Clone for Test {} - | ^^^^^ not a trait + | ^^^^^ not found in this scope | + = note: a derive macro named `Clone` exists in another namespace help: consider importing this trait instead | LL + use std::clone::Clone; @@ -131,12 +133,13 @@ help: consider importing this trait LL + use std::ops::Add; | -error[E0404]: expected trait, found derive macro `Clone` +error[E0404]: cannot find trait `Clone` in this scope --> $DIR/no-implicit-prelude-nested.rs:39:14 | LL | impl Clone for Test {} - | ^^^^^ not a trait + | ^^^^^ not found in this scope | + = note: a derive macro named `Clone` exists in another namespace help: consider importing this trait instead | LL + use std::clone::Clone; diff --git a/tests/ui/resolve/no-implicit-prelude.rs b/tests/ui/resolve/no-implicit-prelude.rs index 4b0ca4d524e62..e2074bbb8c844 100644 --- a/tests/ui/resolve/no-implicit-prelude.rs +++ b/tests/ui/resolve/no-implicit-prelude.rs @@ -8,7 +8,7 @@ struct Test; impl Add for Test {} //~ ERROR cannot find trait `Add` in this scope -impl Clone for Test {} //~ ERROR expected trait, found derive macro `Clone` +impl Clone for Test {} //~ ERROR cannot find trait `Clone` in this scope impl Iterator for Test {} //~ ERROR cannot find trait `Iterator` in this scope impl ToString for Test {} //~ ERROR cannot find trait `ToString` in this scope impl Writer for Test {} //~ ERROR cannot find trait `Writer` in this scope diff --git a/tests/ui/resolve/no-implicit-prelude.stderr b/tests/ui/resolve/no-implicit-prelude.stderr index 5a759743f7258..ba34a5cb647a0 100644 --- a/tests/ui/resolve/no-implicit-prelude.stderr +++ b/tests/ui/resolve/no-implicit-prelude.stderr @@ -9,12 +9,13 @@ help: consider importing this trait LL + use std::ops::Add; | -error[E0404]: expected trait, found derive macro `Clone` +error[E0404]: cannot find trait `Clone` in this scope --> $DIR/no-implicit-prelude.rs:11:6 | LL | impl Clone for Test {} - | ^^^^^ not a trait + | ^^^^^ not found in this scope | + = note: a derive macro named `Clone` exists in another namespace help: consider importing this trait instead | LL + use std::clone::Clone; diff --git a/tests/ui/resolve/privacy-enum-ctor.rs b/tests/ui/resolve/privacy-enum-ctor.rs index a2e35db4436aa..740a3908fe3a7 100644 --- a/tests/ui/resolve/privacy-enum-ctor.rs +++ b/tests/ui/resolve/privacy-enum-ctor.rs @@ -22,9 +22,9 @@ mod m { fn f() { n::Z; - //~^ ERROR expected value, found enum `n::Z` + //~^ ERROR cannot find value `Z` in module `n` Z; - //~^ ERROR expected value, found enum `Z` + //~^ ERROR cannot find value `Z` in this scope let _: Z = Z::Fn; //~^ ERROR mismatched types let _: Z = Z::Struct; @@ -40,7 +40,7 @@ use m::E; // OK, only the type is imported fn main() { let _: E = m::E; - //~^ ERROR expected value, found enum `m::E` + //~^ ERROR cannot find value `E` in module `m` let _: E = m::E::Fn; //~^ ERROR mismatched types let _: E = m::E::Struct; @@ -48,7 +48,7 @@ fn main() { let _: E = m::E::Unit(); //~^ ERROR expected function, found enum variant `m::E::Unit` let _: E = E; - //~^ ERROR expected value, found enum `E` + //~^ ERROR cannot find value `E` in this scope let _: E = E::Fn; //~^ ERROR mismatched types let _: E = E::Struct; @@ -57,7 +57,7 @@ fn main() { //~^ ERROR expected function, found enum variant `E::Unit` let _: Z = m::n::Z; //~^ ERROR cannot find type `Z` in this scope - //~| ERROR expected value, found enum `m::n::Z` + //~| ERROR cannot find value `Z` in module `m::n` //~| ERROR enum `Z` is private let _: Z = m::n::Z::Fn; //~^ ERROR cannot find type `Z` in this scope diff --git a/tests/ui/resolve/privacy-enum-ctor.stderr b/tests/ui/resolve/privacy-enum-ctor.stderr index 5349108065dc9..a8371df5a53a6 100644 --- a/tests/ui/resolve/privacy-enum-ctor.stderr +++ b/tests/ui/resolve/privacy-enum-ctor.stderr @@ -1,9 +1,10 @@ -error[E0423]: expected value, found enum `n::Z` - --> $DIR/privacy-enum-ctor.rs:24:9 +error[E0423]: cannot find value `Z` in module `n` + --> $DIR/privacy-enum-ctor.rs:24:12 | LL | n::Z; - | ^^^^ + | ^ | + = note: an enum named `n::Z` exists in another namespace note: the enum is defined here --> $DIR/privacy-enum-ctor.rs:12:9 | @@ -26,12 +27,13 @@ LL - n::Z; LL + (m::Z::Fn(/* fields */)); | -error[E0423]: expected value, found enum `Z` +error[E0423]: cannot find value `Z` in this scope --> $DIR/privacy-enum-ctor.rs:26:9 | LL | Z; | ^ | + = note: an enum named `Z` exists in another namespace note: the enum is defined here --> $DIR/privacy-enum-ctor.rs:12:9 | @@ -54,15 +56,16 @@ LL - Z; LL + (m::Z::Fn(/* fields */)); | -error[E0423]: expected value, found enum `m::E` - --> $DIR/privacy-enum-ctor.rs:42:16 +error[E0423]: cannot find value `E` in module `m` + --> $DIR/privacy-enum-ctor.rs:42:19 | LL | fn f() { | ------ similarly named function `f` defined here ... LL | let _: E = m::E; - | ^^^^ + | ^ | + = note: an enum named `m::E` exists in another namespace note: the enum is defined here --> $DIR/privacy-enum-ctor.rs:3:5 | @@ -105,12 +108,13 @@ LL - let _: E = m::E; LL + let _: E = E; | -error[E0423]: expected value, found enum `E` +error[E0423]: cannot find value `E` in this scope --> $DIR/privacy-enum-ctor.rs:50:16 | LL | let _: E = E; | ^ | + = note: an enum named `E` exists in another namespace note: the enum is defined here --> $DIR/privacy-enum-ctor.rs:3:5 | @@ -162,12 +166,13 @@ LL - let _: Z = m::n::Z; LL + let _: E = m::n::Z; | -error[E0423]: expected value, found enum `m::n::Z` - --> $DIR/privacy-enum-ctor.rs:58:16 +error[E0423]: cannot find value `Z` in module `m::n` + --> $DIR/privacy-enum-ctor.rs:58:22 | LL | let _: Z = m::n::Z; - | ^^^^^^^ + | ^ | + = note: an enum named `m::n::Z` exists in another namespace note: the enum is defined here --> $DIR/privacy-enum-ctor.rs:12:9 | diff --git a/tests/ui/resolve/privacy-struct-ctor.rs b/tests/ui/resolve/privacy-struct-ctor.rs index 95575a6cc7c98..b3eab3322d513 100644 --- a/tests/ui/resolve/privacy-struct-ctor.rs +++ b/tests/ui/resolve/privacy-struct-ctor.rs @@ -19,7 +19,7 @@ mod m { n::Z; //~^ ERROR tuple struct constructor `Z` is private Z; - //~^ ERROR expected value, found struct `Z` + //~^ ERROR cannot find value `Z` in this scope } } @@ -32,17 +32,17 @@ fn main() { let _: S = m::S(2); //~^ ERROR tuple struct constructor `S` is private S; - //~^ ERROR expected value, found struct `S` + //~^ ERROR cannot find value `S` in this scope m::n::Z; //~^ ERROR tuple struct constructor `Z` is private S2; - //~^ ERROR expected value, found struct `S2` + //~^ ERROR cannot find value `S2` in this scope xcrate::m::S; //~^ ERROR tuple struct constructor `S` is private xcrate::S; - //~^ ERROR expected value, found struct `xcrate::S` + //~^ ERROR cannot find value `S` in crate `xcrate` xcrate::m::n::Z; //~^ ERROR tuple struct constructor `Z` is private } diff --git a/tests/ui/resolve/privacy-struct-ctor.stderr b/tests/ui/resolve/privacy-struct-ctor.stderr index 5a01d51d24ffd..af4ad6cd5b20e 100644 --- a/tests/ui/resolve/privacy-struct-ctor.stderr +++ b/tests/ui/resolve/privacy-struct-ctor.stderr @@ -1,4 +1,4 @@ -error[E0423]: expected value, found struct `Z` +error[E0423]: cannot find value `Z` in this scope --> $DIR/privacy-struct-ctor.rs:21:9 | LL | pub struct S(u8); @@ -7,19 +7,22 @@ LL | pub struct S(u8); LL | Z; | ^ constructor is not visible here due to private fields | + = note: a struct named `Z` exists in another namespace help: a tuple struct with a similar name exists | LL - Z; LL + S; | -error[E0423]: expected value, found struct `S` +error[E0423]: cannot find value `S` in this scope --> $DIR/privacy-struct-ctor.rs:34:5 | LL | S; | ^ constructor is not visible here due to private fields + | + = note: a struct named `S` exists in another namespace -error[E0423]: expected value, found struct `S2` +error[E0423]: cannot find value `S2` in this scope --> $DIR/privacy-struct-ctor.rs:39:5 | LL | / pub struct S2 { @@ -29,13 +32,18 @@ LL | | } ... LL | S2; | ^^ help: use struct literal syntax instead: `S2 { s: val }` + | + = note: a struct named `S2` exists in another namespace -error[E0423]: expected value, found struct `xcrate::S` - --> $DIR/privacy-struct-ctor.rs:44:5 +error[E0423]: cannot find value `S` in crate `xcrate` + --> $DIR/privacy-struct-ctor.rs:44:13 | LL | xcrate::S; - | ^^^^^^^^^ constructor is not visible here due to private fields + | --------^ + | | + | constructor is not visible here due to private fields | + = note: a struct named `xcrate::S` exists in another namespace note: tuple struct `m::S` exists but is inaccessible --> $DIR/privacy-struct-ctor.rs:7:5 | diff --git a/tests/ui/resolve/private-constructor-self-issue-147343.stderr b/tests/ui/resolve/private-constructor-self-issue-147343.stderr index f9290d7dcb356..2b2e3da0be8a6 100644 --- a/tests/ui/resolve/private-constructor-self-issue-147343.stderr +++ b/tests/ui/resolve/private-constructor-self-issue-147343.stderr @@ -4,6 +4,7 @@ error[E0423]: cannot initialize a tuple struct which contains private fields LL | S(self); | ^ | + = note: a struct named `S` exists in another namespace = note: constructor is not visible here due to private fields error: aborting due to 1 previous error diff --git a/tests/ui/resolve/regression-struct-called-as-function-148919.rs b/tests/ui/resolve/regression-struct-called-as-function-148919.rs index 7358e1716c11a..5c472bae4cc10 100644 --- a/tests/ui/resolve/regression-struct-called-as-function-148919.rs +++ b/tests/ui/resolve/regression-struct-called-as-function-148919.rs @@ -3,7 +3,7 @@ struct Bar {} impl Bar { fn into_self(self) -> Bar { Bar(self) - //~^ ERROR expected function, tuple struct or tuple variant, found struct `Bar` [E0423] + //~^ ERROR cannot find function, tuple struct or tuple variant `Bar` in this scope [E0423] } } diff --git a/tests/ui/resolve/regression-struct-called-as-function-148919.stderr b/tests/ui/resolve/regression-struct-called-as-function-148919.stderr index d3e62b3a5a987..2a1c9465cbf35 100644 --- a/tests/ui/resolve/regression-struct-called-as-function-148919.stderr +++ b/tests/ui/resolve/regression-struct-called-as-function-148919.stderr @@ -1,8 +1,10 @@ -error[E0423]: expected function, tuple struct or tuple variant, found struct `Bar` +error[E0423]: cannot find function, tuple struct or tuple variant `Bar` in this scope --> $DIR/regression-struct-called-as-function-148919.rs:5:9 | LL | Bar(self) | ^^^ + | + = note: a struct named `Bar` exists in another namespace error: aborting due to 1 previous error diff --git a/tests/ui/resolve/resolve-dont-hint-macro.rs b/tests/ui/resolve/resolve-dont-hint-macro.rs index da1752b337ebf..fe8c62e6e1f17 100644 --- a/tests/ui/resolve/resolve-dont-hint-macro.rs +++ b/tests/ui/resolve/resolve-dont-hint-macro.rs @@ -1,4 +1,4 @@ fn main() { let zero = assert_eq::<()>(); - //~^ ERROR expected function, found macro `assert_eq` + //~^ ERROR cannot find function `assert_eq` in this scope } diff --git a/tests/ui/resolve/resolve-dont-hint-macro.stderr b/tests/ui/resolve/resolve-dont-hint-macro.stderr index 597e014d255dc..294c21d3e7582 100644 --- a/tests/ui/resolve/resolve-dont-hint-macro.stderr +++ b/tests/ui/resolve/resolve-dont-hint-macro.stderr @@ -1,8 +1,12 @@ -error[E0423]: expected function, found macro `assert_eq` +error[E0423]: cannot find function `assert_eq` in this scope --> $DIR/resolve-dont-hint-macro.rs:2:16 | LL | let zero = assert_eq::<()>(); - | ^^^^^^^^^^^^^^^ not a function + | ^^^^^^^^^------ + | | + | not found in this scope + | + = note: a macro named `assert_eq` exists in another namespace error: aborting due to 1 previous error diff --git a/tests/ui/resolve/resolve-hint-macro.fixed b/tests/ui/resolve/resolve-hint-macro.fixed index 4821aef1bbd6a..9c87b0bbeeeed 100644 --- a/tests/ui/resolve/resolve-hint-macro.fixed +++ b/tests/ui/resolve/resolve-hint-macro.fixed @@ -1,11 +1,11 @@ //@ run-rustfix fn main() { assert_eq!(1, 1); - //~^ ERROR expected function, found macro `assert_eq` + //~^ ERROR cannot find function `assert_eq` in this scope assert_eq! { 1, 1 }; - //~^ ERROR expected struct, variant or union type, found macro `assert_eq` + //~^ ERROR cannot find struct, variant or union type `assert_eq` in this scope //~| ERROR expected identifier, found `1` //~| ERROR expected identifier, found `1` assert![true]; - //~^ ERROR expected value, found macro `assert` + //~^ ERROR cannot find value `assert` in this scope } diff --git a/tests/ui/resolve/resolve-hint-macro.rs b/tests/ui/resolve/resolve-hint-macro.rs index 101a7cd15156c..b6b385ad19aa5 100644 --- a/tests/ui/resolve/resolve-hint-macro.rs +++ b/tests/ui/resolve/resolve-hint-macro.rs @@ -1,11 +1,11 @@ //@ run-rustfix fn main() { assert_eq(1, 1); - //~^ ERROR expected function, found macro `assert_eq` + //~^ ERROR cannot find function `assert_eq` in this scope assert_eq { 1, 1 }; - //~^ ERROR expected struct, variant or union type, found macro `assert_eq` + //~^ ERROR cannot find struct, variant or union type `assert_eq` in this scope //~| ERROR expected identifier, found `1` //~| ERROR expected identifier, found `1` assert[true]; - //~^ ERROR expected value, found macro `assert` + //~^ ERROR cannot find value `assert` in this scope } diff --git a/tests/ui/resolve/resolve-hint-macro.stderr b/tests/ui/resolve/resolve-hint-macro.stderr index 1e7ab48ef90c2..a49630b4f2384 100644 --- a/tests/ui/resolve/resolve-hint-macro.stderr +++ b/tests/ui/resolve/resolve-hint-macro.stderr @@ -14,34 +14,37 @@ LL | assert_eq { 1, 1 }; | | | while parsing this struct -error[E0574]: expected struct, variant or union type, found macro `assert_eq` +error[E0574]: cannot find struct, variant or union type `assert_eq` in this scope --> $DIR/resolve-hint-macro.rs:5:5 | LL | assert_eq { 1, 1 }; - | ^^^^^^^^^ not a struct, variant or union type + | ^^^^^^^^^ not found in this scope | + = note: a macro named `assert_eq` exists in another namespace help: use `!` to invoke the macro | LL | assert_eq! { 1, 1 }; | + -error[E0423]: expected value, found macro `assert` +error[E0423]: cannot find value `assert` in this scope --> $DIR/resolve-hint-macro.rs:9:5 | LL | assert[true]; - | ^^^^^^ not a value + | ^^^^^^ not found in this scope | + = note: a macro named `assert` exists in another namespace help: use `!` to invoke the macro | LL | assert![true]; | + -error[E0423]: expected function, found macro `assert_eq` +error[E0423]: cannot find function `assert_eq` in this scope --> $DIR/resolve-hint-macro.rs:3:5 | LL | assert_eq(1, 1); - | ^^^^^^^^^ not a function + | ^^^^^^^^^ not found in this scope | + = note: a macro named `assert_eq` exists in another namespace help: use `!` to invoke the macro | LL | assert_eq!(1, 1); diff --git a/tests/ui/resolve/resolve-primitive-fallback.rs b/tests/ui/resolve/resolve-primitive-fallback.rs index ce30f4e0e42f6..2249aaf7d66fa 100644 --- a/tests/ui/resolve/resolve-primitive-fallback.rs +++ b/tests/ui/resolve/resolve-primitive-fallback.rs @@ -2,7 +2,7 @@ fn main() { // Make sure primitive type fallback doesn't work in value namespace std::mem::size_of(u16); - //~^ ERROR expected value, found builtin type `u16` + //~^ ERROR cannot find value `u16` in this scope //~| ERROR function takes 0 arguments but 1 argument was supplied // Make sure primitive type fallback doesn't work with global paths diff --git a/tests/ui/resolve/resolve-primitive-fallback.stderr b/tests/ui/resolve/resolve-primitive-fallback.stderr index 17b8cf805de29..a5c52fd5ee215 100644 --- a/tests/ui/resolve/resolve-primitive-fallback.stderr +++ b/tests/ui/resolve/resolve-primitive-fallback.stderr @@ -1,8 +1,10 @@ -error[E0423]: expected value, found builtin type `u16` +error[E0423]: cannot find value `u16` in this scope --> $DIR/resolve-primitive-fallback.rs:4:23 | LL | std::mem::size_of(u16); - | ^^^ not a value + | ^^^ not found in this scope + | + = note: a builtin type named `u16` exists in another namespace error[E0425]: cannot find type `u8` in the crate root --> $DIR/resolve-primitive-fallback.rs:9:14 diff --git a/tests/ui/resolve/suggestions/suggest-constructor-cycle-error.stderr b/tests/ui/resolve/suggestions/suggest-constructor-cycle-error.stderr index c6ec2465a432c..b2592e99b6f77 100644 --- a/tests/ui/resolve/suggestions/suggest-constructor-cycle-error.stderr +++ b/tests/ui/resolve/suggestions/suggest-constructor-cycle-error.stderr @@ -1,9 +1,10 @@ error[E0423]: cannot initialize a tuple struct which contains private fields - --> $DIR/suggest-constructor-cycle-error.rs:7:29 + --> $DIR/suggest-constructor-cycle-error.rs:7:32 | LL | const CONST_NAME: a::Uuid = a::Uuid(()); - | ^^^^^^^ + | ^^^^ | + = note: a struct named `a::Uuid` exists in another namespace note: constructor is not visible here due to private fields --> $DIR/auxiliary/suggest-constructor-cycle-error.rs:2:21 | diff --git a/tests/ui/resolve/suggestions/suggest-path-for-tuple-struct.rs b/tests/ui/resolve/suggestions/suggest-path-for-tuple-struct.rs index c8bc3e79fe2f0..4cd4ba7513035 100644 --- a/tests/ui/resolve/suggestions/suggest-path-for-tuple-struct.rs +++ b/tests/ui/resolve/suggestions/suggest-path-for-tuple-struct.rs @@ -20,7 +20,7 @@ use module::{SomeTupleStruct, SomeRegularStruct}; fn main() { let _ = SomeTupleStruct.new(); - //~^ ERROR expected value, found struct `SomeTupleStruct` + //~^ ERROR cannot find value `SomeTupleStruct` in this scope let _ = SomeRegularStruct.new(); - //~^ ERROR expected value, found struct `SomeRegularStruct` + //~^ ERROR cannot find value `SomeRegularStruct` in this scope } diff --git a/tests/ui/resolve/suggestions/suggest-path-for-tuple-struct.stderr b/tests/ui/resolve/suggestions/suggest-path-for-tuple-struct.stderr index 68a5b55097826..ae758c1ddccc2 100644 --- a/tests/ui/resolve/suggestions/suggest-path-for-tuple-struct.stderr +++ b/tests/ui/resolve/suggestions/suggest-path-for-tuple-struct.stderr @@ -1,21 +1,23 @@ -error[E0423]: expected value, found struct `SomeTupleStruct` +error[E0423]: cannot find value `SomeTupleStruct` in this scope --> $DIR/suggest-path-for-tuple-struct.rs:22:13 | LL | let _ = SomeTupleStruct.new(); | ^^^^^^^^^^^^^^^ | + = note: a struct named `SomeTupleStruct` exists in another namespace help: use the path separator to refer to an item | LL - let _ = SomeTupleStruct.new(); LL + let _ = SomeTupleStruct::new(); | -error[E0423]: expected value, found struct `SomeRegularStruct` +error[E0423]: cannot find value `SomeRegularStruct` in this scope --> $DIR/suggest-path-for-tuple-struct.rs:24:13 | LL | let _ = SomeRegularStruct.new(); | ^^^^^^^^^^^^^^^^^ | + = note: a struct named `SomeRegularStruct` exists in another namespace help: use the path separator to refer to an item | LL - let _ = SomeRegularStruct.new(); diff --git a/tests/ui/resolve/suggestions/suggest-path-instead-of-mod-dot-item.rs b/tests/ui/resolve/suggestions/suggest-path-instead-of-mod-dot-item.rs index d5d6b13d62c28..d0acff513f1c0 100644 --- a/tests/ui/resolve/suggestions/suggest-path-instead-of-mod-dot-item.rs +++ b/tests/ui/resolve/suggestions/suggest-path-instead-of-mod-dot-item.rs @@ -15,75 +15,75 @@ pub mod a { fn h1() -> i32 { a.I - //~^ ERROR expected value, found module `a` + //~^ ERROR cannot find value `a` in this scope //~| HELP use the path separator } fn h2() -> i32 { a.g() - //~^ ERROR expected value, found module `a` + //~^ ERROR cannot find value `a` in this scope //~| HELP use the path separator } fn h3() -> i32 { a.b.J - //~^ ERROR expected value, found module `a` + //~^ ERROR cannot find value `a` in this scope //~| HELP use the path separator } fn h4() -> i32 { a::b.J - //~^ ERROR expected value, found module `a::b` + //~^ ERROR cannot find value `b` in module `a` //~| HELP a constant with a similar name exists //~| HELP use the path separator } fn h5() { a.b.f(); - //~^ ERROR expected value, found module `a` + //~^ ERROR cannot find value `a` in this scope //~| HELP use the path separator let v = Vec::new(); v.push(a::b); - //~^ ERROR expected value, found module `a::b` + //~^ ERROR cannot find value `b` in module `a` //~| HELP a constant with a similar name exists } fn h6() -> i32 { a::b.f() - //~^ ERROR expected value, found module `a::b` + //~^ ERROR cannot find value `b` in module `a` //~| HELP a constant with a similar name exists //~| HELP use the path separator } fn h7() { a::b - //~^ ERROR expected value, found module `a::b` + //~^ ERROR cannot find value `b` in module `a` //~| HELP a constant with a similar name exists } fn h8() -> i32 { a::b() - //~^ ERROR expected function, found module `a::b` + //~^ ERROR cannot find function `b` in module `a` //~| HELP a constant with a similar name exists } macro_rules! module { () => { a - //~^ ERROR expected value, found module `a` - //~| ERROR expected value, found module `a` + //~^ ERROR cannot find value `a` in this scope + //~| ERROR cannot find value `a` in this scope }; } macro_rules! create { (method) => { a.f() - //~^ ERROR expected value, found module `a` + //~^ ERROR cannot find value `a` in this scope //~| HELP use the path separator }; (field) => { a.f - //~^ ERROR expected value, found module `a` + //~^ ERROR cannot find value `a` in this scope //~| HELP use the path separator }; } diff --git a/tests/ui/resolve/suggestions/suggest-path-instead-of-mod-dot-item.stderr b/tests/ui/resolve/suggestions/suggest-path-instead-of-mod-dot-item.stderr index 89c0cd54faeee..f04a8118210b3 100644 --- a/tests/ui/resolve/suggestions/suggest-path-instead-of-mod-dot-item.stderr +++ b/tests/ui/resolve/suggestions/suggest-path-instead-of-mod-dot-item.stderr @@ -1,48 +1,52 @@ -error[E0423]: expected value, found module `a` +error[E0423]: cannot find value `a` in this scope --> $DIR/suggest-path-instead-of-mod-dot-item.rs:17:5 | LL | a.I | ^ | + = note: a module named `a` exists in another namespace help: use the path separator to refer to an item | LL - a.I LL + a::I | -error[E0423]: expected value, found module `a` +error[E0423]: cannot find value `a` in this scope --> $DIR/suggest-path-instead-of-mod-dot-item.rs:23:5 | LL | a.g() | ^ | + = note: a module named `a` exists in another namespace help: use the path separator to refer to an item | LL - a.g() LL + a::g() | -error[E0423]: expected value, found module `a` +error[E0423]: cannot find value `a` in this scope --> $DIR/suggest-path-instead-of-mod-dot-item.rs:29:5 | LL | a.b.J | ^ | + = note: a module named `a` exists in another namespace help: use the path separator to refer to an item | LL - a.b.J LL + a::b.J | -error[E0423]: expected value, found module `a::b` - --> $DIR/suggest-path-instead-of-mod-dot-item.rs:35:5 +error[E0423]: cannot find value `b` in module `a` + --> $DIR/suggest-path-instead-of-mod-dot-item.rs:35:8 | LL | pub const I: i32 = 1; | --------------------- similarly named constant `I` defined here ... LL | a::b.J - | ^^^^ + | ^ | + = note: a module named `a::b` exists in another namespace help: use the path separator to refer to an item | LL - a::b.J @@ -54,42 +58,45 @@ LL - a::b.J LL + a::I.J | -error[E0423]: expected value, found module `a` +error[E0423]: cannot find value `a` in this scope --> $DIR/suggest-path-instead-of-mod-dot-item.rs:42:5 | LL | a.b.f(); | ^ | + = note: a module named `a` exists in another namespace help: use the path separator to refer to an item | LL - a.b.f(); LL + a::b.f(); | -error[E0423]: expected value, found module `a::b` - --> $DIR/suggest-path-instead-of-mod-dot-item.rs:46:12 +error[E0423]: cannot find value `b` in module `a` + --> $DIR/suggest-path-instead-of-mod-dot-item.rs:46:15 | LL | pub const I: i32 = 1; | --------------------- similarly named constant `I` defined here ... LL | v.push(a::b); - | ^^^^ + | ^ | + = note: a module named `a::b` exists in another namespace help: a constant with a similar name exists | LL - v.push(a::b); LL + v.push(a::I); | -error[E0423]: expected value, found module `a::b` - --> $DIR/suggest-path-instead-of-mod-dot-item.rs:52:5 +error[E0423]: cannot find value `b` in module `a` + --> $DIR/suggest-path-instead-of-mod-dot-item.rs:52:8 | LL | pub const I: i32 = 1; | --------------------- similarly named constant `I` defined here ... LL | a::b.f() - | ^^^^ + | ^ | + = note: a module named `a::b` exists in another namespace help: use the path separator to refer to an item | LL - a::b.f() @@ -101,59 +108,63 @@ LL - a::b.f() LL + a::I.f() | -error[E0423]: expected value, found module `a::b` - --> $DIR/suggest-path-instead-of-mod-dot-item.rs:59:5 +error[E0423]: cannot find value `b` in module `a` + --> $DIR/suggest-path-instead-of-mod-dot-item.rs:59:8 | LL | pub const I: i32 = 1; | --------------------- similarly named constant `I` defined here ... LL | a::b - | ^^^^ + | ^ | + = note: a module named `a::b` exists in another namespace help: a constant with a similar name exists | LL - a::b LL + a::I | -error[E0423]: expected function, found module `a::b` - --> $DIR/suggest-path-instead-of-mod-dot-item.rs:65:5 +error[E0423]: cannot find function `b` in module `a` + --> $DIR/suggest-path-instead-of-mod-dot-item.rs:65:8 | LL | pub const I: i32 = 1; | --------------------- similarly named constant `I` defined here ... LL | a::b() - | ^^^^ + | ^ | + = note: a module named `a::b` exists in another namespace help: a constant with a similar name exists | LL - a::b() LL + a::I() | -error[E0423]: expected value, found module `a` +error[E0423]: cannot find value `a` in this scope --> $DIR/suggest-path-instead-of-mod-dot-item.rs:72:9 | LL | a - | ^ not a value + | ^ not found in this scope ... LL | module!().g::<()>(); // no `help` here! | --------- in this macro invocation | + = note: a module named `a` exists in another namespace = note: this error originates in the macro `module` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0423]: expected value, found module `a` +error[E0423]: cannot find value `a` in this scope --> $DIR/suggest-path-instead-of-mod-dot-item.rs:72:9 | LL | a - | ^ not a value + | ^ not found in this scope ... LL | module!().g; // no `help` here! | --------- in this macro invocation | + = note: a module named `a` exists in another namespace = note: this error originates in the macro `module` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0423]: expected value, found module `a` +error[E0423]: cannot find value `a` in this scope --> $DIR/suggest-path-instead-of-mod-dot-item.rs:80:9 | LL | a.f() @@ -162,6 +173,7 @@ LL | a.f() LL | let _ = create!(method); | --------------- in this macro invocation | + = note: a module named `a` exists in another namespace = note: this error originates in the macro `create` (in Nightly builds, run with -Z macro-backtrace for more info) help: use the path separator to refer to an item | @@ -169,7 +181,7 @@ LL - a.f() LL + a::f() | -error[E0423]: expected value, found module `a` +error[E0423]: cannot find value `a` in this scope --> $DIR/suggest-path-instead-of-mod-dot-item.rs:85:9 | LL | a.f @@ -178,6 +190,7 @@ LL | a.f LL | let _ = create!(field); | -------------- in this macro invocation | + = note: a module named `a` exists in another namespace = note: this error originates in the macro `create` (in Nightly builds, run with -Z macro-backtrace for more info) help: use the path separator to refer to an item | diff --git a/tests/ui/resolve/tuple-struct-alias.rs b/tests/ui/resolve/tuple-struct-alias.rs index 298e7e479983d..cfdd8db67466b 100644 --- a/tests/ui/resolve/tuple-struct-alias.rs +++ b/tests/ui/resolve/tuple-struct-alias.rs @@ -2,8 +2,8 @@ struct S(u8, u16); type A = S; fn main() { - let s = A(0, 1); //~ ERROR expected function + let s = A(0, 1); //~ ERROR cannot find function, tuple struct or tuple variant `A` in this scope match s { - A(..) => {} //~ ERROR expected tuple struct or tuple variant + A(..) => {} //~ ERROR cannot find tuple struct or tuple variant `A` in this scope } } diff --git a/tests/ui/resolve/tuple-struct-alias.stderr b/tests/ui/resolve/tuple-struct-alias.stderr index 89b536708372b..5cba958aa657c 100644 --- a/tests/ui/resolve/tuple-struct-alias.stderr +++ b/tests/ui/resolve/tuple-struct-alias.stderr @@ -1,4 +1,4 @@ -error[E0532]: expected tuple struct or tuple variant, found type alias `A` +error[E0532]: cannot find tuple struct or tuple variant `A` in this scope --> $DIR/tuple-struct-alias.rs:7:9 | LL | struct S(u8, u16); @@ -7,13 +7,14 @@ LL | struct S(u8, u16); LL | A(..) => {} | ^ | + = note: a type alias named `A` exists in another namespace help: a tuple struct with a similar name exists | LL - A(..) => {} LL + S(..) => {} | -error[E0423]: expected function, tuple struct or tuple variant, found type alias `A` +error[E0423]: cannot find function, tuple struct or tuple variant `A` in this scope --> $DIR/tuple-struct-alias.rs:5:13 | LL | struct S(u8, u16); @@ -22,6 +23,7 @@ LL | struct S(u8, u16); LL | let s = A(0, 1); | ^ | + = note: a type alias named `A` exists in another namespace help: a tuple struct with a similar name exists | LL - let s = A(0, 1); diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/struct.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/struct.rs index eb1da3f6ecf3b..52a1e44ea48a7 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/struct.rs +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/struct.rs @@ -27,7 +27,7 @@ fn main() { //~^ ERROR `..` required with struct marked as non-exhaustive let us = UnitStruct; - //~^ ERROR expected value, found struct `UnitStruct` [E0423] + //~^ ERROR cannot find value `UnitStruct` in this scope [E0423] let us_explicit = structs::UnitStruct; //~^ ERROR unit struct `UnitStruct` is private [E0603] diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/struct.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/struct.stderr index 88411f29b16e4..a1cb837a1fd8d 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/struct.stderr +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/struct.stderr @@ -1,8 +1,10 @@ -error[E0423]: expected value, found struct `UnitStruct` +error[E0423]: cannot find value `UnitStruct` in this scope --> $DIR/struct.rs:29:14 | LL | let us = UnitStruct; | ^^^^^^^^^^ constructor is not visible here due to private fields + | + = note: a struct named `UnitStruct` exists in another namespace error[E0603]: tuple struct constructor `TupleStruct` is private --> $DIR/struct.rs:23:32 @@ -66,6 +68,8 @@ error[E0423]: cannot initialize a tuple struct which contains private fields | LL | let ts = TupleStruct(640, 480); | ^^^^^^^^^^^ + | + = note: a struct named `TupleStruct` exists in another namespace error[E0638]: `..` required with struct marked as non-exhaustive --> $DIR/struct.rs:26:9 diff --git a/tests/ui/rfcs/rfc-2126-crate-paths/keyword-crate-as-identifier.rs b/tests/ui/rfcs/rfc-2126-crate-paths/keyword-crate-as-identifier.rs index 019ef8e9dade7..d0c3fe31dc62f 100644 --- a/tests/ui/rfcs/rfc-2126-crate-paths/keyword-crate-as-identifier.rs +++ b/tests/ui/rfcs/rfc-2126-crate-paths/keyword-crate-as-identifier.rs @@ -1,4 +1,4 @@ fn main() { let crate = 0; - //~^ ERROR expected unit struct, unit variant or constant, found module `crate` + //~^ ERROR cannot find unit struct, unit variant or constant `crate` in this scope } diff --git a/tests/ui/rfcs/rfc-2126-crate-paths/keyword-crate-as-identifier.stderr b/tests/ui/rfcs/rfc-2126-crate-paths/keyword-crate-as-identifier.stderr index 771a09abedc6e..1ace9e24c6fc4 100644 --- a/tests/ui/rfcs/rfc-2126-crate-paths/keyword-crate-as-identifier.stderr +++ b/tests/ui/rfcs/rfc-2126-crate-paths/keyword-crate-as-identifier.stderr @@ -1,8 +1,10 @@ -error[E0532]: expected unit struct, unit variant or constant, found module `crate` +error[E0532]: cannot find unit struct, unit variant or constant `crate` in this scope --> $DIR/keyword-crate-as-identifier.rs:2:9 | LL | let crate = 0; - | ^^^^^ not a unit struct, unit variant or constant + | ^^^^^ not found in this scope + | + = note: a module named `crate` exists in another namespace error: aborting due to 1 previous error diff --git a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/single-segment.rs b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/single-segment.rs index b773e419b16dd..f9c3bffd44eb4 100644 --- a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/single-segment.rs +++ b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/single-segment.rs @@ -6,6 +6,7 @@ use crate; //~ ERROR imports need to be explicitly named use *; //~ ERROR cannot glob-import all possible crates fn main() { - let s = ::xcrate; //~ ERROR expected value, found crate `::xcrate` - //~^ NOTE not a value + let s = ::xcrate; //~ ERROR cannot find crate `xcrate` in the list of imported crates + //~^ NOTE not found in the list of imported crates + //~| NOTE a crate named `::xcrate` exists in another namespace } diff --git a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/single-segment.stderr b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/single-segment.stderr index fcd18a847d910..1e0f46811ca81 100644 --- a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/single-segment.stderr +++ b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/single-segment.stderr @@ -15,11 +15,13 @@ error: cannot glob-import all possible crates LL | use *; | ^ -error[E0423]: expected value, found crate `::xcrate` - --> $DIR/single-segment.rs:9:13 +error[E0423]: cannot find crate `xcrate` in the list of imported crates + --> $DIR/single-segment.rs:9:15 | LL | let s = ::xcrate; - | ^^^^^^^^ not a value + | ^^^^^^ not found in the list of imported crates + | + = note: a crate named `::xcrate` exists in another namespace error: aborting due to 3 previous errors diff --git a/tests/ui/sized/relaxing-default-bound-error-37534.rs b/tests/ui/sized/relaxing-default-bound-error-37534.rs index 5aca030908bfa..6e5634c466f81 100644 --- a/tests/ui/sized/relaxing-default-bound-error-37534.rs +++ b/tests/ui/sized/relaxing-default-bound-error-37534.rs @@ -1,5 +1,5 @@ // issue: -struct Foo {} //~ ERROR expected trait, found derive macro `Hash` +struct Foo {} //~ ERROR cannot find trait `Hash` in this scope fn main() {} diff --git a/tests/ui/sized/relaxing-default-bound-error-37534.stderr b/tests/ui/sized/relaxing-default-bound-error-37534.stderr index 5de82206d2692..5a3f600a183d9 100644 --- a/tests/ui/sized/relaxing-default-bound-error-37534.stderr +++ b/tests/ui/sized/relaxing-default-bound-error-37534.stderr @@ -1,9 +1,10 @@ -error[E0404]: expected trait, found derive macro `Hash` +error[E0404]: cannot find trait `Hash` in this scope --> $DIR/relaxing-default-bound-error-37534.rs:3:16 | LL | struct Foo {} - | ^^^^ not a trait + | ^^^^ not found in this scope | + = note: a derive macro named `Hash` exists in another namespace help: consider importing this trait instead | LL + use std::hash::Hash; diff --git a/tests/ui/stats/input-stats.rs b/tests/ui/stats/input-stats.rs index 86e904202c1b1..7aa9c8a737a84 100644 --- a/tests/ui/stats/input-stats.rs +++ b/tests/ui/stats/input-stats.rs @@ -10,8 +10,9 @@ // many or all percentages, which makes the diffs hard to read. //@ normalize-stderr: "\([0-9 ][0-9]\.[0-9]%\)" -> "(NN.N%)" -// Type layouts sometimes change. When that happens, until the next bootstrap -// bump occurs, stage1 and stage2 will give different outputs for this test. +// Type layouts sometimes change when layout algorithm changes. +// When that happens, until the next bootstrap bump occurs, +// stage1 and stage2 will give different outputs for this test. // Add an `ignore-stage1` comment marker to work around that problem during // that time. diff --git a/tests/ui/structs/ice-line-bounds-issue-148684.rs b/tests/ui/structs/ice-line-bounds-issue-148684.rs index 56065fb0de309..22f92fa858964 100644 --- a/tests/ui/structs/ice-line-bounds-issue-148684.rs +++ b/tests/ui/structs/ice-line-bounds-issue-148684.rs @@ -5,5 +5,5 @@ struct A { fn main() { A(2, vec![]) - //~^ ERROR expected function, tuple struct or tuple variant, found struct `A` + //~^ ERROR cannot find function, tuple struct or tuple variant `A` in this scope } diff --git a/tests/ui/structs/ice-line-bounds-issue-148684.stderr b/tests/ui/structs/ice-line-bounds-issue-148684.stderr index 71ed393bf0563..700e59504853c 100644 --- a/tests/ui/structs/ice-line-bounds-issue-148684.stderr +++ b/tests/ui/structs/ice-line-bounds-issue-148684.stderr @@ -1,4 +1,4 @@ -error[E0423]: expected function, tuple struct or tuple variant, found struct `A` +error[E0423]: cannot find function, tuple struct or tuple variant `A` in this scope --> $DIR/ice-line-bounds-issue-148684.rs:7:5 | LL | / struct A { @@ -9,6 +9,8 @@ LL | | } ... LL | A(2, vec![]) | ^^^^^^^^^^^^ + | + = note: a struct named `A` exists in another namespace error: aborting due to 1 previous error diff --git a/tests/ui/structs/struct-construct-with-call-issue-138931.rs b/tests/ui/structs/struct-construct-with-call-issue-138931.rs index 5d50eb14bff1a..29d532f72b513 100644 --- a/tests/ui/structs/struct-construct-with-call-issue-138931.rs +++ b/tests/ui/structs/struct-construct-with-call-issue-138931.rs @@ -12,14 +12,14 @@ struct PersonWithAge { fn main() { let wilfred = PersonOnlyName("Name1".to_owned()); - //~^ ERROR expected function, tuple struct or tuple variant, found struct `PersonOnlyName` [E0423] + //~^ ERROR cannot find function, tuple struct or tuple variant `PersonOnlyName` in this scope [E0423] - let bill = PersonWithAge( //~ ERROR expected function, tuple struct or tuple variant, found struct `PersonWithAge` [E0423] + let bill = PersonWithAge( //~ ERROR cannot find function, tuple struct or tuple variant `PersonWithAge` in this scope [E0423] "Name2".to_owned(), 20, 180, ); let person = PersonWithAge("Name3".to_owned()); - //~^ ERROR expected function, tuple struct or tuple variant, found struct `PersonWithAge` [E0423] + //~^ ERROR cannot find function, tuple struct or tuple variant `PersonWithAge` in this scope [E0423] } diff --git a/tests/ui/structs/struct-construct-with-call-issue-138931.stderr b/tests/ui/structs/struct-construct-with-call-issue-138931.stderr index acae01df56361..9248eebbae3ae 100644 --- a/tests/ui/structs/struct-construct-with-call-issue-138931.stderr +++ b/tests/ui/structs/struct-construct-with-call-issue-138931.stderr @@ -1,4 +1,4 @@ -error[E0423]: expected function, tuple struct or tuple variant, found struct `PersonOnlyName` +error[E0423]: cannot find function, tuple struct or tuple variant `PersonOnlyName` in this scope --> $DIR/struct-construct-with-call-issue-138931.rs:14:19 | LL | / struct PersonOnlyName { @@ -9,13 +9,14 @@ LL | | } LL | let wilfred = PersonOnlyName("Name1".to_owned()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | + = note: a struct named `PersonOnlyName` exists in another namespace help: use struct literal syntax instead of calling | LL - let wilfred = PersonOnlyName("Name1".to_owned()); LL + let wilfred = PersonOnlyName{name: "Name1".to_owned()}; | -error[E0423]: expected function, tuple struct or tuple variant, found struct `PersonWithAge` +error[E0423]: cannot find function, tuple struct or tuple variant `PersonWithAge` in this scope --> $DIR/struct-construct-with-call-issue-138931.rs:17:16 | LL | / struct PersonWithAge { @@ -33,6 +34,7 @@ LL | | 180, LL | | ); | |_____^ | + = note: a struct named `PersonWithAge` exists in another namespace help: use struct literal syntax instead of calling | LL ~ let bill = PersonWithAge{name: "Name2".to_owned(), @@ -40,7 +42,7 @@ LL ~ age: 20, LL ~ height: 180}; | -error[E0423]: expected function, tuple struct or tuple variant, found struct `PersonWithAge` +error[E0423]: cannot find function, tuple struct or tuple variant `PersonWithAge` in this scope --> $DIR/struct-construct-with-call-issue-138931.rs:23:18 | LL | / struct PersonWithAge { @@ -52,6 +54,8 @@ LL | | } ... LL | let person = PersonWithAge("Name3".to_owned()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use struct literal syntax instead: `PersonWithAge { name: val, age: val, height: val }` + | + = note: a struct named `PersonWithAge` exists in another namespace error: aborting due to 3 previous errors diff --git a/tests/ui/suggestions/assoc-const-as-field.rs b/tests/ui/suggestions/assoc-const-as-field.rs index 678b58936a8d6..be60944fa1c42 100644 --- a/tests/ui/suggestions/assoc-const-as-field.rs +++ b/tests/ui/suggestions/assoc-const-as-field.rs @@ -9,5 +9,5 @@ fn foo(_: usize) {} fn main() { foo(Mod::Foo.Bar); - //~^ ERROR expected value, found + //~^ ERROR cannot find value `Foo` in module `Mod` } diff --git a/tests/ui/suggestions/assoc-const-as-field.stderr b/tests/ui/suggestions/assoc-const-as-field.stderr index 54b7ff39926f8..a275a56d88175 100644 --- a/tests/ui/suggestions/assoc-const-as-field.stderr +++ b/tests/ui/suggestions/assoc-const-as-field.stderr @@ -1,9 +1,10 @@ -error[E0423]: expected value, found struct `Mod::Foo` - --> $DIR/assoc-const-as-field.rs:11:9 +error[E0423]: cannot find value `Foo` in module `Mod` + --> $DIR/assoc-const-as-field.rs:11:14 | LL | foo(Mod::Foo.Bar); - | ^^^^^^^^ + | ^^^ | + = note: a struct named `Mod::Foo` exists in another namespace help: use the path separator to refer to an item | LL - foo(Mod::Foo.Bar); diff --git a/tests/ui/suggestions/dont-suggest-boxing-async-closure-body.stderr b/tests/ui/suggestions/dont-suggest-boxing-async-closure-body.stderr index abf8e2d824b5d..c74c9b7b5cf3a 100644 --- a/tests/ui/suggestions/dont-suggest-boxing-async-closure-body.stderr +++ b/tests/ui/suggestions/dont-suggest-boxing-async-closure-body.stderr @@ -1,4 +1,4 @@ -error[E0271]: expected `{async closure@dont-suggest-boxing-async-closure-body.rs:9:9}` to return `Box<_>`, but it returns `{async closure body@$DIR/dont-suggest-boxing-async-closure-body.rs:9:23: 9:25}` +error[E0271]: expected `{async closure@dont-suggest-boxing-async-closure-body.rs:9:9}` to return `Box<_>`, but it returns `{async closure body@dont-suggest-boxing-async-closure-body.rs:9:23}` --> $DIR/dont-suggest-boxing-async-closure-body.rs:9:9 | LL | foo(async move || {}); @@ -18,7 +18,7 @@ error[E0308]: mismatched types --> $DIR/dont-suggest-boxing-async-closure-body.rs:11:9 | LL | bar(async move || {}); - | --- ^^^^^^^^^^^^^^^^ expected `Box _>`, found `{async closure@dont-suggest-boxing-async-closure-body.rs:11:9}` + | --- ^^^^^^^^^^^^^^^^ expected `Box _>`, found `{async closure@...}` | | | arguments to this function are incorrect | diff --git a/tests/ui/suggestions/issue-105226.stderr b/tests/ui/suggestions/issue-105226.stderr index f16a809010390..541608414e871 100644 --- a/tests/ui/suggestions/issue-105226.stderr +++ b/tests/ui/suggestions/issue-105226.stderr @@ -4,12 +4,16 @@ error: non-item in item list LL | impl S { | - item list starts here LL | fn hello

(&self, val: &P) where P: fmt::Display; { - | - ^ non-item starts here - | | - | help: consider removing this semicolon + | ^ non-item starts here ... LL | } | - item list ends here + | +help: consider removing this semicolon + | +LL - fn hello

(&self, val: &P) where P: fmt::Display; { +LL + fn hello

(&self, val: &P) where P: fmt::Display { + | error: associated function in `impl` without body --> $DIR/issue-105226.rs:7:5 diff --git a/tests/ui/suggestions/issue-109396.rs b/tests/ui/suggestions/issue-109396.rs index b6c464d45a2e3..1f87f793f35ab 100644 --- a/tests/ui/suggestions/issue-109396.rs +++ b/tests/ui/suggestions/issue-109396.rs @@ -3,7 +3,7 @@ fn main() { let mut mutex = std::mem::zeroed( //~^ ERROR this function takes 0 arguments but 4 arguments were supplied file.as_raw_fd(), - //~^ ERROR expected value, found macro `file` + //~^ ERROR cannot find value `file` in this scope 0, 0, 0, diff --git a/tests/ui/suggestions/issue-109396.stderr b/tests/ui/suggestions/issue-109396.stderr index 5fac07a9a096b..4d21919a5f884 100644 --- a/tests/ui/suggestions/issue-109396.stderr +++ b/tests/ui/suggestions/issue-109396.stderr @@ -1,8 +1,10 @@ -error[E0423]: expected value, found macro `file` +error[E0423]: cannot find value `file` in this scope --> $DIR/issue-109396.rs:5:13 | LL | file.as_raw_fd(), - | ^^^^ not a value + | ^^^^ not found in this scope + | + = note: a macro named `file` exists in another namespace error[E0061]: this function takes 0 arguments but 4 arguments were supplied --> $DIR/issue-109396.rs:3:25 diff --git a/tests/ui/suggestions/issue-61226.fixed b/tests/ui/suggestions/issue-61226.fixed index 597ee9fe2933d..32a270e11ac9a 100644 --- a/tests/ui/suggestions/issue-61226.fixed +++ b/tests/ui/suggestions/issue-61226.fixed @@ -2,5 +2,5 @@ struct X {} fn main() { let _ = vec![X {}]; //… - //~^ ERROR expected value, found struct `X` + //~^ ERROR cannot find value `X` in this scope } diff --git a/tests/ui/suggestions/issue-61226.rs b/tests/ui/suggestions/issue-61226.rs index 5c5e387663063..c6616d281a309 100644 --- a/tests/ui/suggestions/issue-61226.rs +++ b/tests/ui/suggestions/issue-61226.rs @@ -2,5 +2,5 @@ struct X {} fn main() { let _ = vec![X]; //… - //~^ ERROR expected value, found struct `X` + //~^ ERROR cannot find value `X` in this scope } diff --git a/tests/ui/suggestions/issue-61226.stderr b/tests/ui/suggestions/issue-61226.stderr index 890950b1ae9db..cf21435cc3cbc 100644 --- a/tests/ui/suggestions/issue-61226.stderr +++ b/tests/ui/suggestions/issue-61226.stderr @@ -1,4 +1,4 @@ -error[E0423]: expected value, found struct `X` +error[E0423]: cannot find value `X` in this scope --> $DIR/issue-61226.rs:4:18 | LL | struct X {} @@ -6,6 +6,8 @@ LL | struct X {} LL | fn main() { LL | let _ = vec![X]; //… | ^ help: use struct literal syntax instead: `X {}` + | + = note: a struct named `X` exists in another namespace error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/let-binding-init-expr-as-ty.rs b/tests/ui/suggestions/let-binding-init-expr-as-ty.rs index c108b567b18b5..22240d02d7fd2 100644 --- a/tests/ui/suggestions/let-binding-init-expr-as-ty.rs +++ b/tests/ui/suggestions/let-binding-init-expr-as-ty.rs @@ -1,7 +1,7 @@ fn foo(num: i32) -> i32 { // FIXME: This case doesn't really check that `from_be` is a valid function in `i32`. let foo: i32::from_be(num); - //~^ ERROR expected type, found local variable `num` + //~^ ERROR cannot find type `num` in this scope //~| ERROR expected type, found associated function call foo } @@ -33,9 +33,9 @@ fn main() { let x: ""; //~ ERROR expected type, found `""` // Functions - let x: bar(); //~ ERROR expected type, found function `bar` - let x: bar; //~ ERROR expected type, found function `bar` + let x: bar(); //~ ERROR cannot find type `bar` in this scope + let x: bar; //~ ERROR cannot find type `bar` in this scope // Locals - let x: x; //~ ERROR expected type, found local variable `x` + let x: x; //~ ERROR cannot find type `x` in this scope } diff --git a/tests/ui/suggestions/let-binding-init-expr-as-ty.stderr b/tests/ui/suggestions/let-binding-init-expr-as-ty.stderr index 354d119769119..c096fd8c5556e 100644 --- a/tests/ui/suggestions/let-binding-init-expr-as-ty.stderr +++ b/tests/ui/suggestions/let-binding-init-expr-as-ty.stderr @@ -26,37 +26,41 @@ LL - let x: ""; LL + let x = ""; | -error[E0573]: expected type, found local variable `num` +error[E0573]: cannot find type `num` in this scope --> $DIR/let-binding-init-expr-as-ty.rs:3:27 | LL | let foo: i32::from_be(num); - | ^^^ not a type + | ^^^ not found in this scope | + = note: a local variable named `num` exists in another namespace help: use `=` if you meant to assign | LL - let foo: i32::from_be(num); LL + let foo = i32::from_be(num); | -error[E0573]: expected type, found function `bar` +error[E0573]: cannot find type `bar` in this scope --> $DIR/let-binding-init-expr-as-ty.rs:36:12 | LL | let x: bar(); - | ^^^^^ not a type + | ^^^ not found in this scope | + = note: a function named `bar` exists in another namespace help: use `=` if you meant to assign | LL - let x: bar(); LL + let x = bar(); | -error[E0573]: expected type, found function `bar` +error[E0573]: cannot find type `bar` in this scope --> $DIR/let-binding-init-expr-as-ty.rs:37:12 | LL | let x: bar; - | ^^^ not a type + | ^^^ not found in this scope + | + = note: a function named `bar` exists in another namespace -error[E0573]: expected type, found local variable `x` +error[E0573]: cannot find type `x` in this scope --> $DIR/let-binding-init-expr-as-ty.rs:40:12 | LL | struct K(S::new(())); @@ -65,6 +69,7 @@ LL | struct K(S::new(())); LL | let x: x; | ^ | + = note: a local variable named `x` exists in another namespace help: a struct with a similar name exists | LL - let x: x; diff --git a/tests/ui/suggestions/let-binding-suggest-issue-133713.fixed b/tests/ui/suggestions/let-binding-suggest-issue-133713.fixed index 9f9c1d1bc5aa1..bd17d987b2812 100644 --- a/tests/ui/suggestions/let-binding-suggest-issue-133713.fixed +++ b/tests/ui/suggestions/let-binding-suggest-issue-133713.fixed @@ -2,11 +2,11 @@ #![allow(dead_code)] fn demo1() { - let _last: u64 = 0; //~ ERROR expected value, found builtin type `u64` + let _last: u64 = 0; //~ ERROR cannot find value `u64` in this scope } fn demo2() { - let _val: u64; //~ ERROR expected value, found builtin type `u64` + let _val: u64; //~ ERROR cannot find value `u64` in this scope } fn main() {} diff --git a/tests/ui/suggestions/let-binding-suggest-issue-133713.rs b/tests/ui/suggestions/let-binding-suggest-issue-133713.rs index ae218237a8d5c..f46d2977dd63e 100644 --- a/tests/ui/suggestions/let-binding-suggest-issue-133713.rs +++ b/tests/ui/suggestions/let-binding-suggest-issue-133713.rs @@ -2,11 +2,11 @@ #![allow(dead_code)] fn demo1() { - let _last = u64 = 0; //~ ERROR expected value, found builtin type `u64` + let _last = u64 = 0; //~ ERROR cannot find value `u64` in this scope } fn demo2() { - let _val = u64; //~ ERROR expected value, found builtin type `u64` + let _val = u64; //~ ERROR cannot find value `u64` in this scope } fn main() {} diff --git a/tests/ui/suggestions/let-binding-suggest-issue-133713.stderr b/tests/ui/suggestions/let-binding-suggest-issue-133713.stderr index 185ad9c928b48..3afef8c52859c 100644 --- a/tests/ui/suggestions/let-binding-suggest-issue-133713.stderr +++ b/tests/ui/suggestions/let-binding-suggest-issue-133713.stderr @@ -1,21 +1,23 @@ -error[E0423]: expected value, found builtin type `u64` +error[E0423]: cannot find value `u64` in this scope --> $DIR/let-binding-suggest-issue-133713.rs:5:17 | LL | let _last = u64 = 0; | ^^^ | + = note: a builtin type named `u64` exists in another namespace help: you might have meant to use `:` for type annotation | LL - let _last = u64 = 0; LL + let _last: u64 = 0; | -error[E0423]: expected value, found builtin type `u64` +error[E0423]: cannot find value `u64` in this scope --> $DIR/let-binding-suggest-issue-133713.rs:9:16 | LL | let _val = u64; | ^^^ | + = note: a builtin type named `u64` exists in another namespace help: you might have meant to use `:` for type annotation | LL - let _val = u64; diff --git a/tests/ui/suggestions/multi-suggestion.ascii.stderr b/tests/ui/suggestions/multi-suggestion.ascii.stderr index 9c3669a30939c..ecc4c5aa7c23b 100644 --- a/tests/ui/suggestions/multi-suggestion.ascii.stderr +++ b/tests/ui/suggestions/multi-suggestion.ascii.stderr @@ -1,4 +1,4 @@ -error[E0423]: expected function, tuple struct or tuple variant, found struct `std::collections::HashMap` +error[E0423]: cannot find function, tuple struct or tuple variant `HashMap` in module `std::collections` --> $DIR/multi-suggestion.rs:17:13 | LL | let _ = std::collections::HashMap(); @@ -8,6 +8,8 @@ LL | let _ = std::collections::HashMap(); ::: $SRC_DIR/std/src/collections/hash/map.rs:LL:COL | = note: `std::collections::HashMap` defined here + | + = note: a struct named `std::collections::HashMap` exists in another namespace help: you might have meant to use an associated function to build this type | LL | let _ = std::collections::HashMap::new(); @@ -33,6 +35,7 @@ error[E0423]: cannot initialize a tuple struct which contains private fields LL | wtf: Some(Box(U { | ^^^ | + = note: a struct named `Box` exists in another namespace note: constructor is not visible here due to private fields --> $SRC_DIR/alloc/src/boxed.rs:LL:COL | diff --git a/tests/ui/suggestions/multi-suggestion.rs b/tests/ui/suggestions/multi-suggestion.rs index 6d822a8e5aff5..7b89e2c80bd33 100644 --- a/tests/ui/suggestions/multi-suggestion.rs +++ b/tests/ui/suggestions/multi-suggestion.rs @@ -15,7 +15,7 @@ fn main() { x: () }; let _ = std::collections::HashMap(); - //[ascii]~^ ERROR expected function, tuple struct or tuple variant, found struct `std::collections::HashMap` + //[ascii]~^ ERROR cannot find function, tuple struct or tuple variant `HashMap` in module `std::collections` let _ = std::collections::HashMap {}; //[ascii]~^ ERROR cannot construct `HashMap<_, _, _, _>` with struct literal syntax due to private fields let _ = Box {}; //[ascii]~ ERROR cannot construct `Box<_, _>` with struct literal syntax due to private fields diff --git a/tests/ui/suggestions/multi-suggestion.unicode.stderr b/tests/ui/suggestions/multi-suggestion.unicode.stderr index 50316f7e90b4a..1f28a4d8fa289 100644 --- a/tests/ui/suggestions/multi-suggestion.unicode.stderr +++ b/tests/ui/suggestions/multi-suggestion.unicode.stderr @@ -1,4 +1,4 @@ -error[E0423]: expected function, tuple struct or tuple variant, found struct `std::collections::HashMap` +error[E0423]: cannot find function, tuple struct or tuple variant `HashMap` in module `std::collections` ╭▸ $DIR/multi-suggestion.rs:17:13 │ LL │ let _ = std::collections::HashMap(); @@ -7,7 +7,9 @@ LL │ let _ = std::collections::HashMap(); ╭▸ $SRC_DIR/std/src/collections/hash/map.rs:LL:COL ⸬ $SRC_DIR/std/src/collections/hash/map.rs:LL:COL │ - ╰ note: `std::collections::HashMap` defined here + ├ note: `std::collections::HashMap` defined here + │ + ╰ note: a struct named `std::collections::HashMap` exists in another namespace help: you might have meant to use an associated function to build this type ╭╴ LL │ let _ = std::collections::HashMap::new(); @@ -32,7 +34,8 @@ error[E0423]: cannot initialize a tuple struct which contains private fields │ LL │ wtf: Some(Box(U { │ ━━━ - ╰╴ + │ + ╰ note: a struct named `Box` exists in another namespace note: constructor is not visible here due to private fields ╭▸ $SRC_DIR/alloc/src/boxed.rs:LL:COL │ diff --git a/tests/ui/suggestions/mut-borrow-needed-by-trait.stderr b/tests/ui/suggestions/mut-borrow-needed-by-trait.stderr index eadf512a63b49..5ba7fcb2479bb 100644 --- a/tests/ui/suggestions/mut-borrow-needed-by-trait.stderr +++ b/tests/ui/suggestions/mut-borrow-needed-by-trait.stderr @@ -8,7 +8,7 @@ LL | let fp = BufWriter::new(fp); | = note: `std::io::Write` is implemented for `&mut dyn std::io::Write`, but not for `&dyn std::io::Write` note: required by a bound in `BufWriter::::new` - --> $SRC_DIR/std/src/io/buffered/bufwriter.rs:LL:COL + --> $SRC_DIR/alloc/src/io/buffered/bufwriter.rs:LL:COL error[E0277]: the trait bound `&dyn std::io::Write: std::io::Write` is not satisfied --> $DIR/mut-borrow-needed-by-trait.rs:17:14 @@ -18,7 +18,7 @@ LL | let fp = BufWriter::new(fp); | = note: `std::io::Write` is implemented for `&mut dyn std::io::Write`, but not for `&dyn std::io::Write` note: required by a bound in `BufWriter` - --> $SRC_DIR/std/src/io/buffered/bufwriter.rs:LL:COL + --> $SRC_DIR/alloc/src/io/buffered/bufwriter.rs:LL:COL error[E0599]: the method `write_fmt` exists for struct `BufWriter<&dyn std::io::Write>`, but its trait bounds were not satisfied --> $DIR/mut-borrow-needed-by-trait.rs:21:14 diff --git a/tests/ui/suggestions/suggest-add-self-issue-128042.rs b/tests/ui/suggestions/suggest-add-self-issue-128042.rs index f94d166c4967a..8a42256cebebc 100644 --- a/tests/ui/suggestions/suggest-add-self-issue-128042.rs +++ b/tests/ui/suggestions/suggest-add-self-issue-128042.rs @@ -5,7 +5,7 @@ struct Thing { impl Thing { fn oof(*mut Self) { //~ ERROR expected parameter name, found `*` self.state = 1; - //~^ ERROR expected value, found module `self` + //~^ ERROR cannot find value `self` in this scope } } diff --git a/tests/ui/suggestions/suggest-add-self-issue-128042.stderr b/tests/ui/suggestions/suggest-add-self-issue-128042.stderr index 49ac15632501a..e86f028b078ce 100644 --- a/tests/ui/suggestions/suggest-add-self-issue-128042.stderr +++ b/tests/ui/suggestions/suggest-add-self-issue-128042.stderr @@ -4,7 +4,7 @@ error: expected parameter name, found `*` LL | fn oof(*mut Self) { | ^ expected parameter name -error[E0424]: expected value, found module `self` +error[E0424]: cannot find value `self` in this scope --> $DIR/suggest-add-self-issue-128042.rs:7:9 | LL | fn oof(*mut Self) { @@ -12,6 +12,7 @@ LL | fn oof(*mut Self) { LL | self.state = 1; | ^^^^ `self` value is a keyword only available in methods with a `self` parameter | + = note: a module named `self` exists in another namespace help: add a `self` receiver parameter to make the associated `fn` a method | LL | fn oof(&self, *mut Self) { diff --git a/tests/ui/suggestions/suggest-add-self-issue-131084.rs b/tests/ui/suggestions/suggest-add-self-issue-131084.rs index adad0f56857d8..f62f1b07e72b8 100644 --- a/tests/ui/suggestions/suggest-add-self-issue-131084.rs +++ b/tests/ui/suggestions/suggest-add-self-issue-131084.rs @@ -9,19 +9,19 @@ impl SomeStruct { fn some_fn(&some_name) { //~^ ERROR expected one of `:`, `@`, or `|`, found `)` self - //~^ ERROR expected value, found module `self` + //~^ ERROR cannot find value `self` in this scope } fn mut_param(mut some_name) { //~^ ERROR expected one of `:`, `@`, or `|`, found `)` self - //~^ ERROR expected value, found module `self` + //~^ ERROR cannot find value `self` in this scope } fn type_before_name(String s) { //~^ ERROR expected one of `:`, `@`, or `|`, found `s` self - //~^ ERROR expected value, found module `self` + //~^ ERROR cannot find value `self` in this scope } } diff --git a/tests/ui/suggestions/suggest-add-self-issue-131084.stderr b/tests/ui/suggestions/suggest-add-self-issue-131084.stderr index 1af7eec726273..a7f04395ea019 100644 --- a/tests/ui/suggestions/suggest-add-self-issue-131084.stderr +++ b/tests/ui/suggestions/suggest-add-self-issue-131084.stderr @@ -46,7 +46,7 @@ LL | fn type_before_name(String s) { | | expected one of `:`, `@`, or `|` | help: declare the type after the parameter binding: `: ` -error[E0424]: expected value, found module `self` +error[E0424]: cannot find value `self` in this scope --> $DIR/suggest-add-self-issue-131084.rs:11:9 | LL | fn some_fn(&some_name) { @@ -55,12 +55,13 @@ LL | LL | self | ^^^^ `self` value is a keyword only available in methods with a `self` parameter | + = note: a module named `self` exists in another namespace help: add a `self` receiver parameter to make the associated `fn` a method | LL | fn some_fn(&self, &some_name) { | ++++++ -error[E0424]: expected value, found module `self` +error[E0424]: cannot find value `self` in this scope --> $DIR/suggest-add-self-issue-131084.rs:17:9 | LL | fn mut_param(mut some_name) { @@ -69,12 +70,13 @@ LL | LL | self | ^^^^ `self` value is a keyword only available in methods with a `self` parameter | + = note: a module named `self` exists in another namespace help: add a `self` receiver parameter to make the associated `fn` a method | LL | fn mut_param(&self, mut some_name) { | ++++++ -error[E0424]: expected value, found module `self` +error[E0424]: cannot find value `self` in this scope --> $DIR/suggest-add-self-issue-131084.rs:23:9 | LL | fn type_before_name(String s) { @@ -83,6 +85,7 @@ LL | LL | self | ^^^^ `self` value is a keyword only available in methods with a `self` parameter | + = note: a module named `self` exists in another namespace help: add a `self` receiver parameter to make the associated `fn` a method | LL | fn type_before_name(&self, String s) { diff --git a/tests/ui/suggestions/suggest-add-self.rs b/tests/ui/suggestions/suggest-add-self.rs index 40692c8df2053..7ca1d96e17262 100644 --- a/tests/ui/suggestions/suggest-add-self.rs +++ b/tests/ui/suggestions/suggest-add-self.rs @@ -3,12 +3,12 @@ struct X(i32); impl X { pub(crate) fn f() { self.0 - //~^ ERROR expected value, found module `self` + //~^ ERROR cannot find value `self` in this scope } pub fn g() { self.0 - //~^ ERROR expected value, found module `self` + //~^ ERROR cannot find value `self` in this scope } } diff --git a/tests/ui/suggestions/suggest-add-self.stderr b/tests/ui/suggestions/suggest-add-self.stderr index a5e8f93deb64a..972d034e98438 100644 --- a/tests/ui/suggestions/suggest-add-self.stderr +++ b/tests/ui/suggestions/suggest-add-self.stderr @@ -1,4 +1,4 @@ -error[E0424]: expected value, found module `self` +error[E0424]: cannot find value `self` in this scope --> $DIR/suggest-add-self.rs:5:9 | LL | pub(crate) fn f() { @@ -6,12 +6,13 @@ LL | pub(crate) fn f() { LL | self.0 | ^^^^ `self` value is a keyword only available in methods with a `self` parameter | + = note: a module named `self` exists in another namespace help: add a `self` receiver parameter to make the associated `fn` a method | LL | pub(crate) fn f(&self) { | +++++ -error[E0424]: expected value, found module `self` +error[E0424]: cannot find value `self` in this scope --> $DIR/suggest-add-self.rs:10:9 | LL | pub fn g() { @@ -19,6 +20,7 @@ LL | pub fn g() { LL | self.0 | ^^^^ `self` value is a keyword only available in methods with a `self` parameter | + = note: a module named `self` exists in another namespace help: add a `self` receiver parameter to make the associated `fn` a method | LL | pub fn g(&self) { diff --git a/tests/ui/suggestions/suggest-change-mut.stderr b/tests/ui/suggestions/suggest-change-mut.stderr index c47ae433ab896..fc664c92ceee2 100644 --- a/tests/ui/suggestions/suggest-change-mut.stderr +++ b/tests/ui/suggestions/suggest-change-mut.stderr @@ -7,7 +7,7 @@ LL | let mut stream_reader = BufReader::new(&stream); | required by a bound introduced by this call | note: required by a bound in `BufReader::::new` - --> $SRC_DIR/std/src/io/buffered/bufreader.rs:LL:COL + --> $SRC_DIR/alloc/src/io/buffered/bufreader.rs:LL:COL help: consider removing the leading `&`-reference | LL - let mut stream_reader = BufReader::new(&stream); diff --git a/tests/ui/suggestions/unnamable-types.stderr b/tests/ui/suggestions/unnamable-types.stderr index bcd1a905194ef..e8f12e7476119 100644 --- a/tests/ui/suggestions/unnamable-types.stderr +++ b/tests/ui/suggestions/unnamable-types.stderr @@ -58,7 +58,7 @@ error: missing type for `const` item LL | const G = #[coroutine] || -> i32 { yield 0; return 1; }; | ^ | -note: however, the inferred type `{coroutine@$DIR/unnamable-types.rs:37:24: 37:33}` cannot be named +note: however, the inferred type `{coroutine@unnamable-types.rs:37:24}` cannot be named --> $DIR/unnamable-types.rs:37:24 | LL | const G = #[coroutine] || -> i32 { yield 0; return 1; }; diff --git a/tests/ui/suggestions/use-placement-resolve.fixed b/tests/ui/suggestions/use-placement-resolve.fixed index d15aee004846d..ee2ab41cc3355 100644 --- a/tests/ui/suggestions/use-placement-resolve.fixed +++ b/tests/ui/suggestions/use-placement-resolve.fixed @@ -10,4 +10,4 @@ use std::fmt::Debug; fn main() {} -fn foobar(x: T) {} //~ ERROR expected trait, found derive macro +fn foobar(x: T) {} //~ ERROR cannot find trait `Debug` in this scope diff --git a/tests/ui/suggestions/use-placement-resolve.rs b/tests/ui/suggestions/use-placement-resolve.rs index 7724718ee791e..e581bf71e252f 100644 --- a/tests/ui/suggestions/use-placement-resolve.rs +++ b/tests/ui/suggestions/use-placement-resolve.rs @@ -8,4 +8,4 @@ fn main() {} -fn foobar(x: T) {} //~ ERROR expected trait, found derive macro +fn foobar(x: T) {} //~ ERROR cannot find trait `Debug` in this scope diff --git a/tests/ui/suggestions/use-placement-resolve.stderr b/tests/ui/suggestions/use-placement-resolve.stderr index 562e0bc3fbc1f..e8ac3905d44f4 100644 --- a/tests/ui/suggestions/use-placement-resolve.stderr +++ b/tests/ui/suggestions/use-placement-resolve.stderr @@ -1,9 +1,10 @@ -error[E0404]: expected trait, found derive macro `Debug` +error[E0404]: cannot find trait `Debug` in this scope --> $DIR/use-placement-resolve.rs:11:14 | LL | fn foobar(x: T) {} - | ^^^^^ not a trait + | ^^^^^ not found in this scope | + = note: a derive macro named `Debug` exists in another namespace help: consider importing this trait instead | LL + use std::fmt::Debug; diff --git a/tests/ui/tool-attributes/tool-attributes-misplaced-1.rs b/tests/ui/tool-attributes/tool-attributes-misplaced-1.rs index bf45ba2ed8227..7a5ac47247e2c 100644 --- a/tests/ui/tool-attributes/tool-attributes-misplaced-1.rs +++ b/tests/ui/tool-attributes/tool-attributes-misplaced-1.rs @@ -1,5 +1,5 @@ type A = rustfmt; //~ ERROR expected type, found tool module `rustfmt` -type B = rustfmt::skip; //~ ERROR expected type, found tool attribute `rustfmt::skip` +type B = rustfmt::skip; //~ ERROR cannot find type `skip` in `rustfmt` #[derive(rustfmt)] //~ ERROR cannot find derive macro `rustfmt` in this scope //~| ERROR cannot find derive macro `rustfmt` in this scope @@ -11,8 +11,8 @@ fn check() {} #[rustfmt::skip] // OK fn main() { - rustfmt; //~ ERROR expected value, found tool module `rustfmt` + rustfmt; //~ ERROR cannot find value `rustfmt` in this scope rustfmt!(); //~ ERROR cannot find macro `rustfmt` in this scope - rustfmt::skip; //~ ERROR expected value, found tool attribute `rustfmt::skip` + rustfmt::skip; //~ ERROR cannot find value `skip` in `rustfmt` } diff --git a/tests/ui/tool-attributes/tool-attributes-misplaced-1.stderr b/tests/ui/tool-attributes/tool-attributes-misplaced-1.stderr index 2045dc6a36e1a..8849a05aa2646 100644 --- a/tests/ui/tool-attributes/tool-attributes-misplaced-1.stderr +++ b/tests/ui/tool-attributes/tool-attributes-misplaced-1.stderr @@ -30,23 +30,29 @@ error[E0573]: expected type, found tool module `rustfmt` LL | type A = rustfmt; | ^^^^^^^ not a type -error[E0573]: expected type, found tool attribute `rustfmt::skip` - --> $DIR/tool-attributes-misplaced-1.rs:2:10 +error[E0573]: cannot find type `skip` in `rustfmt` + --> $DIR/tool-attributes-misplaced-1.rs:2:19 | LL | type B = rustfmt::skip; - | ^^^^^^^^^^^^^ not a type + | ^^^^ not found in `rustfmt` + | + = note: a tool attribute named `rustfmt::skip` exists in another namespace -error[E0423]: expected value, found tool module `rustfmt` +error[E0423]: cannot find value `rustfmt` in this scope --> $DIR/tool-attributes-misplaced-1.rs:14:5 | LL | rustfmt; - | ^^^^^^^ not a value + | ^^^^^^^ not found in this scope + | + = note: a tool module named `rustfmt` exists in another namespace -error[E0423]: expected value, found tool attribute `rustfmt::skip` - --> $DIR/tool-attributes-misplaced-1.rs:17:5 +error[E0423]: cannot find value `skip` in `rustfmt` + --> $DIR/tool-attributes-misplaced-1.rs:17:14 | LL | rustfmt::skip; - | ^^^^^^^^^^^^^ not a value + | ^^^^ not found in `rustfmt` + | + = note: a tool attribute named `rustfmt::skip` exists in another namespace error: aborting due to 8 previous errors diff --git a/tests/ui/track-diagnostics/track3.rs b/tests/ui/track-diagnostics/track3.rs index 144f2794e9104..f622457b81e69 100644 --- a/tests/ui/track-diagnostics/track3.rs +++ b/tests/ui/track-diagnostics/track3.rs @@ -10,6 +10,6 @@ fn main() { let _unimported = Blah { field: u8 }; //~^ ERROR cannot find struct, variant or union type `Blah` in this scope //~| NOTE created at - //~| ERROR expected value, found builtin type `u8` + //~| ERROR cannot find value `u8` in this scope //~| NOTE created at } diff --git a/tests/ui/track-diagnostics/track3.stderr b/tests/ui/track-diagnostics/track3.stderr index 3e99c8d5f33fd..5ad528ddb8402 100644 --- a/tests/ui/track-diagnostics/track3.stderr +++ b/tests/ui/track-diagnostics/track3.stderr @@ -6,13 +6,14 @@ LL | let _unimported = Blah { field: u8 }; | = note: -Ztrack-diagnostics: created at compiler/rustc_resolve/src/late/diagnostics.rs:LL:CC -error[E0423]: expected value, found builtin type `u8` +error[E0423]: cannot find value `u8` in this scope --> $DIR/track3.rs:LL:CC | LL | let _unimported = Blah { field: u8 }; - | ^^ not a value + | ^^ not found in this scope | = note: -Ztrack-diagnostics: created at compiler/rustc_resolve/src/late/diagnostics.rs:LL:CC + = note: a builtin type named `u8` exists in another namespace error: aborting due to 2 previous errors diff --git a/tests/ui/traits/associated_type_bound/assoc-type-maybe-trait-147356.rs b/tests/ui/traits/associated_type_bound/assoc-type-maybe-trait-147356.rs index 8d8eab308ba23..32958f72009de 100644 --- a/tests/ui/traits/associated_type_bound/assoc-type-maybe-trait-147356.rs +++ b/tests/ui/traits/associated_type_bound/assoc-type-maybe-trait-147356.rs @@ -1,7 +1,7 @@ use std::str::FromStr; fn foo() -> T where - ::Err: Debug, //~ ERROR expected trait + ::Err: Debug, //~ ERROR cannot find trait `Debug` in this scope { "".parse().unwrap() } diff --git a/tests/ui/traits/associated_type_bound/assoc-type-maybe-trait-147356.stderr b/tests/ui/traits/associated_type_bound/assoc-type-maybe-trait-147356.stderr index b7fc85af82407..151b22578b5c3 100644 --- a/tests/ui/traits/associated_type_bound/assoc-type-maybe-trait-147356.stderr +++ b/tests/ui/traits/associated_type_bound/assoc-type-maybe-trait-147356.stderr @@ -1,9 +1,10 @@ -error[E0404]: expected trait, found derive macro `Debug` +error[E0404]: cannot find trait `Debug` in this scope --> $DIR/assoc-type-maybe-trait-147356.rs:4:26 | LL | ::Err: Debug, - | ^^^^^ not a trait + | ^^^^^ not found in this scope | + = note: a derive macro named `Debug` exists in another namespace help: consider importing this trait instead | LL + use std::fmt::Debug; diff --git a/tests/ui/traits/next-solver/async.fail.stderr b/tests/ui/traits/next-solver/async.fail.stderr index bc89842d16a14..328f1bc7d4384 100644 --- a/tests/ui/traits/next-solver/async.fail.stderr +++ b/tests/ui/traits/next-solver/async.fail.stderr @@ -1,4 +1,4 @@ -error[E0271]: expected `{async block@$DIR/async.rs:12:17: 12:22}` to be a future that resolves to `i32`, but it resolves to `()` +error[E0271]: expected `{async block@async.rs:12:17}` to be a future that resolves to `i32`, but it resolves to `()` --> $DIR/async.rs:12:17 | LL | needs_async(async {}); diff --git a/tests/ui/traits/next-solver/async.rs b/tests/ui/traits/next-solver/async.rs index fded774354759..cc6a99baf8d8d 100644 --- a/tests/ui/traits/next-solver/async.rs +++ b/tests/ui/traits/next-solver/async.rs @@ -10,7 +10,7 @@ fn needs_async(_: impl Future) {} #[cfg(fail)] fn main() { needs_async(async {}); - //[fail]~^ ERROR expected `{async block@$DIR/async.rs:12:17: 12:22}` to be a future that resolves to `i32`, but it resolves to `()` + //[fail]~^ ERROR expected `{async block@async.rs:12:17}` to be a future that resolves to `i32`, but it resolves to `()` } #[cfg(pass)] diff --git a/tests/ui/traits/next-solver/closure-capture-in-loop-120328.rs b/tests/ui/traits/next-solver/closure-capture-in-loop-120328.rs new file mode 100644 index 0000000000000..7a310063984cd --- /dev/null +++ b/tests/ui/traits/next-solver/closure-capture-in-loop-120328.rs @@ -0,0 +1,13 @@ +//@ compile-flags: -Znext-solver +//@ edition: 2021 +//@ check-pass + +// Regression test for . +// Closures capturing an iterated variable in edition 2021 used to ICE +// with the next trait solver during MIR building. + +fn main() { + for item in &[1, 2, 3] { + let _ = || *item; + } +} diff --git a/tests/ui/traits/next-solver/stalled-coroutine-obligations.stderr b/tests/ui/traits/next-solver/stalled-coroutine-obligations.stderr index 6fc64fe4768a5..8da83ef139709 100644 --- a/tests/ui/traits/next-solver/stalled-coroutine-obligations.stderr +++ b/tests/ui/traits/next-solver/stalled-coroutine-obligations.stderr @@ -1,22 +1,22 @@ -error[E0271]: type mismatch resolving `T == {async block@$DIR/stalled-coroutine-obligations.rs:18:18: 18:23}` +error[E0271]: type mismatch resolving `T == {async block@stalled-coroutine-obligations.rs:18:18}` --> $DIR/stalled-coroutine-obligations.rs:18:14 | LL | let foo: T = async {}; | ^ types differ -error[E0271]: type mismatch resolving `U == {async block@$DIR/stalled-coroutine-obligations.rs:22:18: 22:23}` +error[E0271]: type mismatch resolving `U == {async block@stalled-coroutine-obligations.rs:22:18}` --> $DIR/stalled-coroutine-obligations.rs:22:14 | LL | let bar: U = async {}; | ^ types differ -error[E0271]: type mismatch resolving `T == {async block@$DIR/stalled-coroutine-obligations.rs:33:18: 33:23}` +error[E0271]: type mismatch resolving `T == {async block@stalled-coroutine-obligations.rs:33:18}` --> $DIR/stalled-coroutine-obligations.rs:33:14 | LL | let foo: T = async { a }; | ^ types differ -error[E0271]: type mismatch resolving `impl Future + Send == {async block@$DIR/stalled-coroutine-obligations.rs:41:9: 41:19}` +error[E0271]: type mismatch resolving `impl Future + Send == {async block@stalled-coroutine-obligations.rs:41:9}` --> $DIR/stalled-coroutine-obligations.rs:39:43 | LL | fn stalled_send(&self, b: *mut ()) -> impl Future + Send { diff --git a/tests/ui/try-block/try-block-in-edition2015.rs b/tests/ui/try-block/try-block-in-edition2015.rs index 4ebe2d31b81d4..b8c072f87c994 100644 --- a/tests/ui/try-block/try-block-in-edition2015.rs +++ b/tests/ui/try-block/try-block-in-edition2015.rs @@ -2,7 +2,7 @@ pub fn main() { let try_result: Option<_> = try { - //~^ ERROR expected struct, variant or union type, found macro `try` + //~^ ERROR cannot find struct, variant or union type `try` in this scope let x = 5; //~ ERROR expected identifier, found keyword x }; diff --git a/tests/ui/try-block/try-block-in-edition2015.stderr b/tests/ui/try-block/try-block-in-edition2015.stderr index a00064c44d2dc..e9a708b1a0431 100644 --- a/tests/ui/try-block/try-block-in-edition2015.stderr +++ b/tests/ui/try-block/try-block-in-edition2015.stderr @@ -7,12 +7,13 @@ LL | LL | let x = 5; | ^^^ expected identifier, found keyword -error[E0574]: expected struct, variant or union type, found macro `try` +error[E0574]: cannot find struct, variant or union type `try` in this scope --> $DIR/try-block-in-edition2015.rs:4:33 | LL | let try_result: Option<_> = try { - | ^^^ not a struct, variant or union type + | ^^^ not found in this scope | + = note: a macro named `try` exists in another namespace = note: if you want the `try` keyword, you need Rust 2018 or later help: use `!` to invoke the macro | diff --git a/tests/ui/type-alias-impl-trait/define_opaques_attr/non_type.rs b/tests/ui/type-alias-impl-trait/define_opaques_attr/non_type.rs index 0ad87616a518b..c5f00b97df57c 100644 --- a/tests/ui/type-alias-impl-trait/define_opaques_attr/non_type.rs +++ b/tests/ui/type-alias-impl-trait/define_opaques_attr/non_type.rs @@ -3,5 +3,5 @@ fn foo() {} #[define_opaque(foo)] -//~^ ERROR: expected type alias or associated type with opaqaue types +//~^ ERROR: cannot find type alias or associated type with opaqaue types `foo` in this scope fn main() {} diff --git a/tests/ui/type-alias-impl-trait/define_opaques_attr/non_type.stderr b/tests/ui/type-alias-impl-trait/define_opaques_attr/non_type.stderr index 0f91533bf7e17..3e86f2ef5e2ec 100644 --- a/tests/ui/type-alias-impl-trait/define_opaques_attr/non_type.stderr +++ b/tests/ui/type-alias-impl-trait/define_opaques_attr/non_type.stderr @@ -1,8 +1,10 @@ -error[E0573]: expected type alias or associated type with opaqaue types, found function `foo` +error[E0573]: cannot find type alias or associated type with opaqaue types `foo` in this scope --> $DIR/non_type.rs:5:17 | LL | #[define_opaque(foo)] - | ^^^ not a type alias or associated type with opaqaue types + | ^^^ not found in this scope + | + = note: a function named `foo` exists in another namespace error: aborting due to 1 previous error diff --git a/tests/ui/type-alias-impl-trait/issue-94429.stderr b/tests/ui/type-alias-impl-trait/issue-94429.stderr index f41b781f963d2..3f85d23144a4f 100644 --- a/tests/ui/type-alias-impl-trait/issue-94429.stderr +++ b/tests/ui/type-alias-impl-trait/issue-94429.stderr @@ -1,4 +1,4 @@ -error[E0271]: type mismatch resolving `<{coroutine@$DIR/issue-94429.rs:18:9: 18:16} as Coroutine>::Yield == ()` +error[E0271]: type mismatch resolving `<{coroutine@issue-94429.rs:18:9} as Coroutine>::Yield == ()` --> $DIR/issue-94429.rs:15:26 | LL | fn run(&mut self) -> Self::Coro { diff --git a/tests/ui/typeck/issue-84831.rs b/tests/ui/typeck/issue-84831.rs index c646f71072532..7621231e6984d 100644 --- a/tests/ui/typeck/issue-84831.rs +++ b/tests/ui/typeck/issue-84831.rs @@ -1,8 +1,8 @@ fn f() { - std::<0>; //~ ERROR expected value + std::<0>; //~ ERROR cannot find value `std` in this scope } fn j() { - std::<_ as _>; //~ ERROR expected value + std::<_ as _>; //~ ERROR cannot find value `std` in this scope //~^ ERROR expected one of `,` or `>`, found keyword `as` } diff --git a/tests/ui/typeck/issue-84831.stderr b/tests/ui/typeck/issue-84831.stderr index 461ccb142f978..b7ed905d54185 100644 --- a/tests/ui/typeck/issue-84831.stderr +++ b/tests/ui/typeck/issue-84831.stderr @@ -9,17 +9,21 @@ help: expressions must be enclosed in braces to be used as const generic argumen LL | std::<{ _ as _ }>; | + + -error[E0423]: expected value, found crate `std` +error[E0423]: cannot find value `std` in this scope --> $DIR/issue-84831.rs:2:5 | LL | std::<0>; - | ^^^^^^^^ not a value + | ^^^ not found in this scope + | + = note: a crate named `std` exists in another namespace -error[E0423]: expected value, found crate `std` +error[E0423]: cannot find value `std` in this scope --> $DIR/issue-84831.rs:5:5 | LL | std::<_ as _>; - | ^^^^^^^^^^^^^ not a value + | ^^^ not found in this scope + | + = note: a crate named `std` exists in another namespace error: aborting due to 3 previous errors diff --git a/tests/ui/ufcs/ufcs-partially-resolved.rs b/tests/ui/ufcs/ufcs-partially-resolved.rs index ac98aef4e1de6..5907ac2636df8 100644 --- a/tests/ui/ufcs/ufcs-partially-resolved.rs +++ b/tests/ui/ufcs/ufcs-partially-resolved.rs @@ -49,8 +49,8 @@ fn main() { ::NN; //~ ERROR expected trait, found associated type `Tr::Y` ::NN; //~ ERROR expected trait, found variant `E::Y` - let _: ::Z; //~ ERROR expected associated type, found associated function `Dr::Z` - ::X; //~ ERROR expected method or associated constant, found associated type `Dr::X` - let _: ::Z::N; //~ ERROR expected associated type, found associated function `Dr::Z` + let _: ::Z; //~ ERROR cannot find associated type `Z` in trait `Dr` + ::X; //~ ERROR cannot find method or associated constant `X` in trait `Dr` + let _: ::Z::N; //~ ERROR cannot find associated type `Z` in trait `Dr` ::X::N; //~ ERROR no associated function or constant named `N` found for type `u16` } diff --git a/tests/ui/ufcs/ufcs-partially-resolved.stderr b/tests/ui/ufcs/ufcs-partially-resolved.stderr index 9efadec872b36..c39a5dacbcae1 100644 --- a/tests/ui/ufcs/ufcs-partially-resolved.stderr +++ b/tests/ui/ufcs/ufcs-partially-resolved.stderr @@ -278,45 +278,48 @@ error[E0404]: expected trait, found variant `E::Y` LL | ::NN; | ^^^^ not a trait -error[E0575]: expected associated type, found associated function `Dr::Z` - --> $DIR/ufcs-partially-resolved.rs:52:12 +error[E0575]: cannot find associated type `Z` in trait `Dr` + --> $DIR/ufcs-partially-resolved.rs:52:24 | LL | type X = u16; | ------------- similarly named associated type `X` defined here ... LL | let _: ::Z; - | ^^^^^^^^^^^^^ + | ^ | + = note: an associated function named `Dr::Z` exists in another namespace help: an associated type with a similar name exists | LL - let _: ::Z; LL + let _: ::X; | -error[E0575]: expected method or associated constant, found associated type `Dr::X` - --> $DIR/ufcs-partially-resolved.rs:53:5 +error[E0575]: cannot find method or associated constant `X` in trait `Dr` + --> $DIR/ufcs-partially-resolved.rs:53:17 | LL | fn Z() {} | ------ similarly named associated function `Z` defined here ... LL | ::X; - | ^^^^^^^^^^^^^ + | ^ | + = note: an associated type named `Dr::X` exists in another namespace help: an associated function with a similar name exists | LL - ::X; LL + ::Z; | -error[E0575]: expected associated type, found associated function `Dr::Z` - --> $DIR/ufcs-partially-resolved.rs:54:12 +error[E0575]: cannot find associated type `Z` in trait `Dr` + --> $DIR/ufcs-partially-resolved.rs:54:24 | LL | type X = u16; | ------------- similarly named associated type `X` defined here ... LL | let _: ::Z::N; - | ^^^^^^^^^^^^^^^^ + | ^ | + = note: an associated function named `Dr::Z` exists in another namespace help: an associated type with a similar name exists | LL - let _: ::Z::N; diff --git a/tests/ui/unboxed-closures/unboxed-closures-type-mismatch-closure-from-another-scope.stderr b/tests/ui/unboxed-closures/unboxed-closures-type-mismatch-closure-from-another-scope.stderr index 7e295c1d54f9a..b7916f6d884be 100644 --- a/tests/ui/unboxed-closures/unboxed-closures-type-mismatch-closure-from-another-scope.stderr +++ b/tests/ui/unboxed-closures/unboxed-closures-type-mismatch-closure-from-another-scope.stderr @@ -32,12 +32,13 @@ note: closure parameter defined here LL | let mut closure = expect_sig(|p, y| *p = y); | ^ -error[E0423]: expected function, found macro `deref` +error[E0423]: cannot find function `deref` in this scope --> $DIR/unboxed-closures-type-mismatch-closure-from-another-scope.rs:13:5 | LL | deref(p); - | ^^^^^ not a function + | ^^^^^ not found in this scope | + = note: a macro named `deref` exists in another namespace help: use the `.` operator to call the method `Deref::deref` on `&&()` | LL - deref(p); 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 732a5c334e50d..994470736ce35 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 @@ -3,7 +3,7 @@ trait Trait { //~| ERROR cycle detected when computing type of `Trait::N` fn fnc(&self) -> dyn Trait { //~^ ERROR the name `N` is already used for a generic parameter in this item's generic parameters - //~| ERROR expected value, found builtin type `u32` + //~| ERROR cannot find value `u32` in this scope bar //~^ ERROR cannot find value `bar` in this scope } 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 cede8313b2a9b..3b70c2ff13ad0 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 @@ -13,11 +13,13 @@ error[E0425]: cannot find value `bar` in this scope LL | trait Trait { | ^^^ not found in this scope -error[E0423]: expected value, found builtin type `u32` +error[E0423]: cannot find value `u32` in this scope --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:4:33 | LL | fn fnc(&self) -> dyn Trait { - | ^^^ not a value + | ^^^ not found in this scope + | + = note: a builtin type named `u32` exists in another namespace error[E0425]: cannot find value `bar` in this scope --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:7:9