diff --git a/.mailmap b/.mailmap index fa0728bd79461..f476926832158 100644 --- a/.mailmap +++ b/.mailmap @@ -29,7 +29,6 @@ Ariel Ben-Yehuda arielb1 Austin Seipp Aydin Kim aydin.kim Barosl Lee Barosl LEE -Bastian Kauschke Ben Alpert Ben Sago Ben S Ben Sago Ben S @@ -161,6 +160,7 @@ Kyle J Strand Kyle J Strand Kyle J Strand Laurențiu Nicola +lcnr Lee Jeffery Lee Jeffery Lee Wondong Lennart Kudling diff --git a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs index 2f3089f1a92c1..21023a06bb2d9 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs @@ -91,17 +91,6 @@ impl<'a, 'tcx> Visitor<'tcx> for FindHirNodeVisitor<'a, 'tcx> { if let (None, Some(ty)) = (self.found_local_pattern, self.node_ty_contains_target(local.hir_id)) { - // FIXME: There's a trade-off here - we can either check that our target span - // is contained in `local.span` or not. If we choose to check containment - // we can avoid some spurious suggestions (see #72690), but we lose - // the ability to report on things like: - // - // ``` - // let x = vec![]; - // ``` - // - // because the target span will be in the macro expansion of `vec![]`. - // At present we choose not to check containment. self.found_local_pattern = Some(&*local.pat); self.found_node_ty = Some(ty); } @@ -113,10 +102,8 @@ impl<'a, 'tcx> Visitor<'tcx> for FindHirNodeVisitor<'a, 'tcx> { if let (None, Some(ty)) = (self.found_arg_pattern, self.node_ty_contains_target(param.hir_id)) { - if self.target_span.contains(param.pat.span) { - self.found_arg_pattern = Some(&*param.pat); - self.found_node_ty = Some(ty); - } + self.found_arg_pattern = Some(&*param.pat); + self.found_node_ty = Some(ty); } } intravisit::walk_body(self, body); diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs index 4bff7f317cbc9..2409069031d93 100644 --- a/compiler/rustc_lint/src/unused.rs +++ b/compiler/rustc_lint/src/unused.rs @@ -751,13 +751,20 @@ impl UnusedDelimLint for UnusedParens { if !Self::is_expr_delims_necessary(inner, followed_by_block) && value.attrs.is_empty() && !value.span.from_expansion() + && (ctx != UnusedDelimsCtx::LetScrutineeExpr + || match inner.kind { + ast::ExprKind::Binary( + rustc_span::source_map::Spanned { node, .. }, + _, + _, + ) if node.lazy() => false, + _ => true, + }) { self.emit_unused_delims_expr(cx, value, ctx, left_pos, right_pos) } } ast::ExprKind::Let(_, ref expr) => { - // FIXME(#60336): Properly handle `let true = (false && true)` - // actually needing the parenthesis. self.check_unused_delims_expr( cx, expr, diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index f53465266d2ac..f8bd3ab96e254 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -1462,9 +1462,8 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> { let bound_predicate = predicate.bound_atom(); let mut err = match bound_predicate.skip_binder() { ty::PredicateAtom::Trait(data, _) => { - let self_ty = data.trait_ref.self_ty(); let trait_ref = bound_predicate.rebind(data.trait_ref); - debug!("self_ty {:?} {:?} trait_ref {:?}", self_ty, self_ty.kind(), trait_ref); + debug!("trait_ref {:?}", trait_ref); if predicate.references_error() { return; @@ -1479,6 +1478,17 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> { // known, since we don't dispatch based on region // relationships. + // Pick the first substitution that still contains inference variables as the one + // we're going to emit an error for. If there are none (see above), fall back to + // the substitution for `Self`. + let subst = { + let substs = data.trait_ref.substs; + substs + .iter() + .find(|s| s.has_infer_types_or_consts()) + .unwrap_or_else(|| substs[0]) + }; + // This is kind of a hack: it frequently happens that some earlier // error prevents types from being fully inferred, and then we get // a bunch of uninteresting errors saying something like " InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> { // check upstream for type errors and don't add the obligations to // begin with in those cases. if self.tcx.lang_items().sized_trait() == Some(trait_ref.def_id()) { - self.emit_inference_failure_err( - body_id, - span, - self_ty.into(), - ErrorCode::E0282, - ) - .emit(); + self.emit_inference_failure_err(body_id, span, subst, ErrorCode::E0282).emit(); return; } - let mut err = self.emit_inference_failure_err( - body_id, - span, - self_ty.into(), - ErrorCode::E0283, - ); + let mut err = + self.emit_inference_failure_err(body_id, span, subst, ErrorCode::E0283); err.note(&format!("cannot satisfy `{}`", predicate)); if let ObligationCauseCode::ItemObligation(def_id) = obligation.cause.code { self.suggest_fully_qualified_path(&mut err, def_id, span, trait_ref.def_id()); diff --git a/compiler/rustc_typeck/src/check/generator_interior.rs b/compiler/rustc_typeck/src/check/generator_interior.rs index 3fc5f02a4a47d..4473aa2081f23 100644 --- a/compiler/rustc_typeck/src/check/generator_interior.rs +++ b/compiler/rustc_typeck/src/check/generator_interior.rs @@ -250,10 +250,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> { let mut scope_var_ids = self.guard_bindings.pop().expect("should have pushed at least one earlier"); for var_id in scope_var_ids.drain(..) { - assert!( - self.guard_bindings_set.remove(&var_id), - "variable should be placed in scope earlier" - ); + self.guard_bindings_set.remove(&var_id); } } self.visit_expr(body); diff --git a/library/alloc/src/collections/btree/map/tests.rs b/library/alloc/src/collections/btree/map/tests.rs index 118e173bb16db..b51b95a635c87 100644 --- a/library/alloc/src/collections/btree/map/tests.rs +++ b/library/alloc/src/collections/btree/map/tests.rs @@ -1,4 +1,4 @@ -use super::super::{navigate::Position, node, DeterministicRng}; +use super::super::{node, DeterministicRng}; use super::Entry::{Occupied, Vacant}; use super::*; use crate::boxed::Box; @@ -7,7 +7,7 @@ use crate::rc::Rc; use crate::string::{String, ToString}; use crate::vec::Vec; use std::convert::TryFrom; -use std::iter::FromIterator; +use std::iter::{self, FromIterator}; use std::mem; use std::ops::Bound::{self, Excluded, Included, Unbounded}; use std::ops::RangeBounds; @@ -42,19 +42,6 @@ fn test_all_refs<'a, T: 'a>(dummy: &mut T, iter: impl Iterator } } -struct SeriesChecker { - previous: Option, -} - -impl SeriesChecker { - fn is_ascending(&mut self, next: T) { - if let Some(previous) = self.previous { - assert!(previous < next, "{:?} >= {:?}", previous, next); - } - self.previous = Some(next); - } -} - impl<'a, K: 'a, V: 'a> BTreeMap { /// Panics if the map (or the code navigating it) is corrupted. fn check(&self) @@ -63,44 +50,10 @@ impl<'a, K: 'a, V: 'a> BTreeMap { { if let Some(root) = &self.root { let root_node = root.node_as_ref(); - let mut checker = SeriesChecker { previous: None }; - let mut internal_length = 0; - let mut internal_kv_count = 0; - let mut leaf_length = 0; - root_node.visit_nodes_in_order(|pos| match pos { - Position::Leaf(node) => { - let is_root = root_node.height() == 0; - let min_len = if is_root { 0 } else { node::MIN_LEN }; - assert!(node.len() >= min_len, "{} < {}", node.len(), min_len); - - for idx in 0..node.len() { - let key = *unsafe { node.key_at(idx) }; - checker.is_ascending(key); - } - leaf_length += node.len(); - } - Position::Internal(node) => { - let is_root = root_node.height() == node.height(); - let min_len = if is_root { 1 } else { node::MIN_LEN }; - assert!(node.len() >= min_len, "{} < {}", node.len(), min_len); - - for idx in 0..=node.len() { - let edge = unsafe { node::Handle::new_edge(node, idx) }; - assert!(edge.descend().ascend().ok().unwrap() == edge); - } - - internal_length += node.len(); - } - Position::InternalKV(kv) => { - let key = *kv.into_kv().0; - checker.is_ascending(key); - - internal_kv_count += 1; - } - }); - assert_eq!(internal_length, internal_kv_count); - assert_eq!(root_node.calc_length(), internal_length + leaf_length); - assert_eq!(self.length, internal_length + leaf_length); + assert!(root_node.ascend().is_err()); + root_node.assert_back_pointers(); + root_node.assert_ascending(); + assert_eq!(self.length, root_node.assert_and_add_lengths()); } else { assert_eq!(self.length, 0); } @@ -116,28 +69,7 @@ impl<'a, K: 'a, V: 'a> BTreeMap { K: Debug, { if let Some(root) = self.root.as_ref() { - let mut result = String::new(); - let root_node = root.node_as_ref(); - root_node.visit_nodes_in_order(|pos| match pos { - Position::Leaf(leaf) => { - let depth = root_node.height(); - let indent = " ".repeat(depth); - result += &format!("\n{}", indent); - for idx in 0..leaf.len() { - if idx > 0 { - result += ", "; - } - result += &format!("{:?}", unsafe { leaf.key_at(idx) }); - } - } - Position::Internal(_) => {} - Position::InternalKV(kv) => { - let depth = root_node.height() - kv.into_node().height(); - let indent = " ".repeat(depth); - result += &format!("\n{}{:?}", indent, kv.into_kv().0); - } - }); - result + root.node_as_ref().dump_keys() } else { String::from("not yet allocated") } @@ -170,7 +102,6 @@ fn test_levels() { let last_key = *map.last_key_value().unwrap().0; map.insert(last_key + 1, ()); } - println!("{}", map.dump_keys()); map.check(); // Structure: // - 1 element in internal root node with 2 children @@ -372,7 +303,7 @@ fn test_iter_rev() { fn do_test_iter_mut_mutation(size: usize) where T: Copy + Debug + Ord + TryFrom, - >::Error: std::fmt::Debug, + >::Error: Debug, { let zero = T::try_from(0).unwrap(); let mut map: BTreeMap = (0..size).map(|i| (T::try_from(i).unwrap(), zero)).collect(); @@ -857,7 +788,7 @@ mod test_drain_filter { fn consuming_nothing() { let pairs = (0..3).map(|i| (i, i)); let mut map: BTreeMap<_, _> = pairs.collect(); - assert!(map.drain_filter(|_, _| false).eq(std::iter::empty())); + assert!(map.drain_filter(|_, _| false).eq(iter::empty())); map.check(); } @@ -878,7 +809,7 @@ mod test_drain_filter { *v += 6; false }) - .eq(std::iter::empty()) + .eq(iter::empty()) ); assert!(map.keys().copied().eq(0..3)); assert!(map.values().copied().eq(6..9)); diff --git a/library/alloc/src/collections/btree/node/tests.rs b/library/alloc/src/collections/btree/node/tests.rs index 2ef9aad0ccdcf..e56fc2aa51e7c 100644 --- a/library/alloc/src/collections/btree/node/tests.rs +++ b/library/alloc/src/collections/btree/node/tests.rs @@ -1,6 +1,111 @@ +use super::super::navigate; use super::*; +use crate::fmt::Debug; +use crate::string::String; use core::cmp::Ordering::*; +impl<'a, K: 'a, V: 'a> NodeRef, K, V, marker::LeafOrInternal> { + pub fn assert_back_pointers(self) { + match self.force() { + ForceResult::Leaf(_) => {} + ForceResult::Internal(node) => { + for idx in 0..=node.len() { + let edge = unsafe { Handle::new_edge(node, idx) }; + let child = edge.descend(); + assert!(child.ascend().ok() == Some(edge)); + child.assert_back_pointers(); + } + } + } + } + + pub fn assert_ascending(self) + where + K: Copy + Debug + Ord, + { + struct SeriesChecker { + previous: Option, + } + impl SeriesChecker { + fn is_ascending(&mut self, next: T) { + if let Some(previous) = self.previous { + assert!(previous < next, "{:?} >= {:?}", previous, next); + } + self.previous = Some(next); + } + } + + let mut checker = SeriesChecker { previous: None }; + self.visit_nodes_in_order(|pos| match pos { + navigate::Position::Leaf(node) => { + for idx in 0..node.len() { + let key = *unsafe { node.key_at(idx) }; + checker.is_ascending(key); + } + } + navigate::Position::InternalKV(kv) => { + let key = *kv.into_kv().0; + checker.is_ascending(key); + } + navigate::Position::Internal(_) => {} + }); + } + + pub fn assert_and_add_lengths(self) -> usize { + let mut internal_length = 0; + let mut internal_kv_count = 0; + let mut leaf_length = 0; + self.visit_nodes_in_order(|pos| match pos { + navigate::Position::Leaf(node) => { + let is_root = self.height() == 0; + let min_len = if is_root { 0 } else { MIN_LEN }; + assert!(node.len() >= min_len, "{} < {}", node.len(), min_len); + leaf_length += node.len(); + } + navigate::Position::Internal(node) => { + let is_root = self.height() == node.height(); + let min_len = if is_root { 1 } else { MIN_LEN }; + assert!(node.len() >= min_len, "{} < {}", node.len(), min_len); + internal_length += node.len(); + } + navigate::Position::InternalKV(_) => { + internal_kv_count += 1; + } + }); + assert_eq!(internal_length, internal_kv_count); + let total = internal_length + leaf_length; + assert_eq!(self.calc_length(), total); + total + } + + pub fn dump_keys(self) -> String + where + K: Debug, + { + let mut result = String::new(); + self.visit_nodes_in_order(|pos| match pos { + navigate::Position::Leaf(leaf) => { + let depth = self.height(); + let indent = " ".repeat(depth); + result += &format!("\n{}", indent); + for idx in 0..leaf.len() { + if idx > 0 { + result += ", "; + } + result += &format!("{:?}", unsafe { leaf.key_at(idx) }); + } + } + navigate::Position::Internal(_) => {} + navigate::Position::InternalKV(kv) => { + let depth = self.height() - kv.into_node().height(); + let indent = " ".repeat(depth); + result += &format!("\n{}{:?}", indent, kv.into_kv().0); + } + }); + result + } +} + #[test] fn test_splitpoint() { for idx in 0..=CAPACITY { diff --git a/library/std/src/keyword_docs.rs b/library/std/src/keyword_docs.rs index 54ce0e7b831f4..a4bbb18da5983 100644 --- a/library/std/src/keyword_docs.rs +++ b/library/std/src/keyword_docs.rs @@ -102,7 +102,9 @@ mod break_keyword {} #[doc(keyword = "const")] // -/// Compile-time constants and deterministic functions. +/// Compile-time constants and compile-time evaluable functions. +/// +/// ## Compile-time constants /// /// Sometimes a certain value is used many times throughout a program, and it can become /// inconvenient to copy it over and over. What's more, it's not always possible or desirable to @@ -145,15 +147,28 @@ mod break_keyword {} /// /// Constants, like statics, should always be in `SCREAMING_SNAKE_CASE`. /// +/// For more detail on `const`, see the [Rust Book] or the [Reference]. +/// +/// ## Compile-time evaluable functions +/// +/// The other main use of the `const` keyword is in `const fn`. This marks a function as being +/// callable in the body of a `const` or `static` item and in array initializers (commonly called +/// "const contexts"). `const fn` are restricted in the set of operations they can perform, to +/// ensure that they can be evaluated at compile-time. See the [Reference][const-eval] for more +/// detail. +/// +/// Turning a `fn` into a `const fn` has no effect on run-time uses of that function. +/// +/// ## Other uses of `const` +/// /// The `const` keyword is also used in raw pointers in combination with `mut`, as seen in `*const /// T` and `*mut T`. More about `const` as used in raw pointers can be read at the Rust docs for the [pointer primitive]. /// -/// For more detail on `const`, see the [Rust Book] or the [Reference]. -/// /// [pointer primitive]: primitive.pointer.html /// [Rust Book]: /// ../book/ch03-01-variables-and-mutability.html#differences-between-variables-and-constants /// [Reference]: ../reference/items/constant-items.html +/// [const-eval]: ../reference/const_eval.html mod const_keyword {} #[doc(keyword = "continue")] diff --git a/library/std/src/net/ip.rs b/library/std/src/net/ip.rs index f01a7b72a6559..8089d7a8ba6f1 100644 --- a/library/std/src/net/ip.rs +++ b/library/std/src/net/ip.rs @@ -456,10 +456,7 @@ impl Ipv4Addr { #[rustc_const_unstable(feature = "const_ipv4", issue = "76205")] #[stable(since = "1.7.0", feature = "ip_17")] pub const fn is_link_local(&self) -> bool { - match self.octets() { - [169, 254, ..] => true, - _ => false, - } + matches!(self.octets(), [169, 254, ..]) } /// Returns [`true`] if the address appears to be globally routable. @@ -1262,10 +1259,7 @@ impl Ipv6Addr { /// [RFC 4291 errata 4406]: https://www.rfc-editor.org/errata/eid4406 #[rustc_const_unstable(feature = "const_ipv6", issue = "76205")] pub const fn is_unicast_link_local_strict(&self) -> bool { - (self.segments()[0] & 0xffff) == 0xfe80 - && (self.segments()[1] & 0xffff) == 0 - && (self.segments()[2] & 0xffff) == 0 - && (self.segments()[3] & 0xffff) == 0 + matches!(self.segments(), [0xfe80, 0, 0, 0, ..]) } /// Returns [`true`] if the address is a unicast link-local address (`fe80::/10`). diff --git a/library/std/src/sys/unix/mod.rs b/library/std/src/sys/unix/mod.rs index 776f4f18ecfa2..b28c6d85b7c72 100644 --- a/library/std/src/sys/unix/mod.rs +++ b/library/std/src/sys/unix/mod.rs @@ -220,6 +220,10 @@ where } } +pub fn cvt_nz(error: libc::c_int) -> crate::io::Result<()> { + if error == 0 { Ok(()) } else { Err(crate::io::Error::from_raw_os_error(error)) } +} + // On Unix-like platforms, libc::abort will unregister signal handlers // including the SIGABRT handler, preventing the abort from being blocked, and // fclose streams, with the side effect of flushing them so libc buffered diff --git a/library/std/src/sys/unix/mutex.rs b/library/std/src/sys/unix/mutex.rs index ebc737b75ae0b..89c55eb859d09 100644 --- a/library/std/src/sys/unix/mutex.rs +++ b/library/std/src/sys/unix/mutex.rs @@ -1,5 +1,6 @@ use crate::cell::UnsafeCell; use crate::mem::MaybeUninit; +use crate::sys::cvt_nz; pub struct Mutex { inner: UnsafeCell, @@ -51,14 +52,11 @@ impl Mutex { // PTHREAD_MUTEX_NORMAL which is guaranteed to deadlock if we try to // re-lock it from the same thread, thus avoiding undefined behavior. let mut attr = MaybeUninit::::uninit(); - let r = libc::pthread_mutexattr_init(attr.as_mut_ptr()); - debug_assert_eq!(r, 0); - let r = libc::pthread_mutexattr_settype(attr.as_mut_ptr(), libc::PTHREAD_MUTEX_NORMAL); - debug_assert_eq!(r, 0); - let r = libc::pthread_mutex_init(self.inner.get(), attr.as_ptr()); - debug_assert_eq!(r, 0); - let r = libc::pthread_mutexattr_destroy(attr.as_mut_ptr()); - debug_assert_eq!(r, 0); + cvt_nz(libc::pthread_mutexattr_init(attr.as_mut_ptr())).unwrap(); + let attr = PthreadMutexAttr(&mut attr); + cvt_nz(libc::pthread_mutexattr_settype(attr.0.as_mut_ptr(), libc::PTHREAD_MUTEX_NORMAL)) + .unwrap(); + cvt_nz(libc::pthread_mutex_init(self.inner.get(), attr.0.as_ptr())).unwrap(); } #[inline] pub unsafe fn lock(&self) { @@ -106,15 +104,11 @@ impl ReentrantMutex { pub unsafe fn init(&self) { let mut attr = MaybeUninit::::uninit(); - let result = libc::pthread_mutexattr_init(attr.as_mut_ptr()); - debug_assert_eq!(result, 0); - let result = - libc::pthread_mutexattr_settype(attr.as_mut_ptr(), libc::PTHREAD_MUTEX_RECURSIVE); - debug_assert_eq!(result, 0); - let result = libc::pthread_mutex_init(self.inner.get(), attr.as_ptr()); - debug_assert_eq!(result, 0); - let result = libc::pthread_mutexattr_destroy(attr.as_mut_ptr()); - debug_assert_eq!(result, 0); + cvt_nz(libc::pthread_mutexattr_init(attr.as_mut_ptr())).unwrap(); + let attr = PthreadMutexAttr(&mut attr); + cvt_nz(libc::pthread_mutexattr_settype(attr.0.as_mut_ptr(), libc::PTHREAD_MUTEX_RECURSIVE)) + .unwrap(); + cvt_nz(libc::pthread_mutex_init(self.inner.get(), attr.0.as_ptr())).unwrap(); } pub unsafe fn lock(&self) { @@ -137,3 +131,14 @@ impl ReentrantMutex { debug_assert_eq!(result, 0); } } + +struct PthreadMutexAttr<'a>(&'a mut MaybeUninit); + +impl Drop for PthreadMutexAttr<'_> { + fn drop(&mut self) { + unsafe { + let result = libc::pthread_mutexattr_destroy(self.0.as_mut_ptr()); + debug_assert_eq!(result, 0); + } + } +} diff --git a/library/std/src/sys/unix/process/process_unix.rs b/library/std/src/sys/unix/process/process_unix.rs index b05319c89e8f2..a590c74435639 100644 --- a/library/std/src/sys/unix/process/process_unix.rs +++ b/library/std/src/sys/unix/process/process_unix.rs @@ -281,7 +281,7 @@ impl Command { envp: Option<&CStringArray>, ) -> io::Result> { use crate::mem::MaybeUninit; - use crate::sys; + use crate::sys::{self, cvt_nz}; if self.get_gid().is_some() || self.get_uid().is_some() @@ -343,10 +343,6 @@ impl Command { } } - fn cvt_nz(error: libc::c_int) -> io::Result<()> { - if error == 0 { Ok(()) } else { Err(io::Error::from_raw_os_error(error)) } - } - unsafe { let mut attrs = MaybeUninit::uninit(); cvt_nz(libc::posix_spawnattr_init(attrs.as_mut_ptr()))?; diff --git a/src/bootstrap/setup.rs b/src/bootstrap/setup.rs index a281061ace15b..c6e1c99564c09 100644 --- a/src/bootstrap/setup.rs +++ b/src/bootstrap/setup.rs @@ -1,6 +1,7 @@ use crate::{t, VERSION}; use std::fmt::Write as _; use std::path::{Path, PathBuf}; +use std::process::Command; use std::str::FromStr; use std::{ env, fmt, fs, @@ -196,10 +197,17 @@ simply delete the `pre-commit` file from .git/hooks." Ok(if should_install { let src = src_path.join("src").join("etc").join("pre-commit.sh"); - let dst = src_path.join(".git").join("hooks").join("pre-commit"); - match fs::hard_link(src, dst) { + let git = t!(Command::new("git").args(&["rev-parse", "--git-common-dir"]).output().map( + |output| { + assert!(output.status.success(), "failed to run `git`"); + PathBuf::from(t!(String::from_utf8(output.stdout)).trim()) + } + )); + let dst = git.join("hooks").join("pre-commit"); + match fs::hard_link(src, &dst) { Err(e) => println!( - "x.py encountered an error -- do you already have the git hook installed?\n{}", + "error: could not create hook {}: do you already have the git hook installed?\n{}", + dst.display(), e ), Ok(_) => println!("Linked `src/etc/pre-commit.sh` to `.git/hooks/pre-commit`"), diff --git a/src/test/ui/associated-const/associated-const-ambiguity-report.rs b/src/test/ui/associated-consts/associated-const-ambiguity-report.rs similarity index 100% rename from src/test/ui/associated-const/associated-const-ambiguity-report.rs rename to src/test/ui/associated-consts/associated-const-ambiguity-report.rs diff --git a/src/test/ui/associated-const/associated-const-ambiguity-report.stderr b/src/test/ui/associated-consts/associated-const-ambiguity-report.stderr similarity index 100% rename from src/test/ui/associated-const/associated-const-ambiguity-report.stderr rename to src/test/ui/associated-consts/associated-const-ambiguity-report.stderr diff --git a/src/test/ui/associated-const/associated-const-array-len.rs b/src/test/ui/associated-consts/associated-const-array-len.rs similarity index 100% rename from src/test/ui/associated-const/associated-const-array-len.rs rename to src/test/ui/associated-consts/associated-const-array-len.rs diff --git a/src/test/ui/associated-const/associated-const-array-len.stderr b/src/test/ui/associated-consts/associated-const-array-len.stderr similarity index 100% rename from src/test/ui/associated-const/associated-const-array-len.stderr rename to src/test/ui/associated-consts/associated-const-array-len.stderr diff --git a/src/test/ui/associated-const/associated-const-dead-code.rs b/src/test/ui/associated-consts/associated-const-dead-code.rs similarity index 100% rename from src/test/ui/associated-const/associated-const-dead-code.rs rename to src/test/ui/associated-consts/associated-const-dead-code.rs diff --git a/src/test/ui/associated-const/associated-const-dead-code.stderr b/src/test/ui/associated-consts/associated-const-dead-code.stderr similarity index 100% rename from src/test/ui/associated-const/associated-const-dead-code.stderr rename to src/test/ui/associated-consts/associated-const-dead-code.stderr diff --git a/src/test/ui/associated-const/associated-const-generic-obligations.rs b/src/test/ui/associated-consts/associated-const-generic-obligations.rs similarity index 100% rename from src/test/ui/associated-const/associated-const-generic-obligations.rs rename to src/test/ui/associated-consts/associated-const-generic-obligations.rs diff --git a/src/test/ui/associated-const/associated-const-generic-obligations.stderr b/src/test/ui/associated-consts/associated-const-generic-obligations.stderr similarity index 100% rename from src/test/ui/associated-const/associated-const-generic-obligations.stderr rename to src/test/ui/associated-consts/associated-const-generic-obligations.stderr diff --git a/src/test/ui/associated-const/associated-const-impl-wrong-lifetime.rs b/src/test/ui/associated-consts/associated-const-impl-wrong-lifetime.rs similarity index 100% rename from src/test/ui/associated-const/associated-const-impl-wrong-lifetime.rs rename to src/test/ui/associated-consts/associated-const-impl-wrong-lifetime.rs diff --git a/src/test/ui/associated-const/associated-const-impl-wrong-lifetime.stderr b/src/test/ui/associated-consts/associated-const-impl-wrong-lifetime.stderr similarity index 100% rename from src/test/ui/associated-const/associated-const-impl-wrong-lifetime.stderr rename to src/test/ui/associated-consts/associated-const-impl-wrong-lifetime.stderr diff --git a/src/test/ui/associated-const/associated-const-impl-wrong-type.rs b/src/test/ui/associated-consts/associated-const-impl-wrong-type.rs similarity index 100% rename from src/test/ui/associated-const/associated-const-impl-wrong-type.rs rename to src/test/ui/associated-consts/associated-const-impl-wrong-type.rs diff --git a/src/test/ui/associated-const/associated-const-impl-wrong-type.stderr b/src/test/ui/associated-consts/associated-const-impl-wrong-type.stderr similarity index 100% rename from src/test/ui/associated-const/associated-const-impl-wrong-type.stderr rename to src/test/ui/associated-consts/associated-const-impl-wrong-type.stderr diff --git a/src/test/ui/associated-const/associated-const-in-trait.rs b/src/test/ui/associated-consts/associated-const-in-trait.rs similarity index 100% rename from src/test/ui/associated-const/associated-const-in-trait.rs rename to src/test/ui/associated-consts/associated-const-in-trait.rs diff --git a/src/test/ui/associated-const/associated-const-in-trait.stderr b/src/test/ui/associated-consts/associated-const-in-trait.stderr similarity index 100% rename from src/test/ui/associated-const/associated-const-in-trait.stderr rename to src/test/ui/associated-consts/associated-const-in-trait.stderr diff --git a/src/test/ui/associated-const/associated-const-no-item.rs b/src/test/ui/associated-consts/associated-const-no-item.rs similarity index 100% rename from src/test/ui/associated-const/associated-const-no-item.rs rename to src/test/ui/associated-consts/associated-const-no-item.rs diff --git a/src/test/ui/associated-const/associated-const-no-item.stderr b/src/test/ui/associated-consts/associated-const-no-item.stderr similarity index 100% rename from src/test/ui/associated-const/associated-const-no-item.stderr rename to src/test/ui/associated-consts/associated-const-no-item.stderr diff --git a/src/test/ui/associated-const/associated-const-private-impl.rs b/src/test/ui/associated-consts/associated-const-private-impl.rs similarity index 100% rename from src/test/ui/associated-const/associated-const-private-impl.rs rename to src/test/ui/associated-consts/associated-const-private-impl.rs diff --git a/src/test/ui/associated-const/associated-const-private-impl.stderr b/src/test/ui/associated-consts/associated-const-private-impl.stderr similarity index 100% rename from src/test/ui/associated-const/associated-const-private-impl.stderr rename to src/test/ui/associated-consts/associated-const-private-impl.stderr diff --git a/src/test/ui/associated-const/associated-const-trait-bound.rs b/src/test/ui/associated-consts/associated-const-trait-bound.rs similarity index 100% rename from src/test/ui/associated-const/associated-const-trait-bound.rs rename to src/test/ui/associated-consts/associated-const-trait-bound.rs diff --git a/src/test/ui/associated-const/associated-const-type-parameter-arms.rs b/src/test/ui/associated-consts/associated-const-type-parameter-arms.rs similarity index 100% rename from src/test/ui/associated-const/associated-const-type-parameter-arms.rs rename to src/test/ui/associated-consts/associated-const-type-parameter-arms.rs diff --git a/src/test/ui/associated-const/associated-const-type-parameter-arms.stderr b/src/test/ui/associated-consts/associated-const-type-parameter-arms.stderr similarity index 100% rename from src/test/ui/associated-const/associated-const-type-parameter-arms.stderr rename to src/test/ui/associated-consts/associated-const-type-parameter-arms.stderr diff --git a/src/test/ui/associated-const/associated-const-type-parameter-arrays-2.rs b/src/test/ui/associated-consts/associated-const-type-parameter-arrays-2.rs similarity index 100% rename from src/test/ui/associated-const/associated-const-type-parameter-arrays-2.rs rename to src/test/ui/associated-consts/associated-const-type-parameter-arrays-2.rs diff --git a/src/test/ui/associated-const/associated-const-type-parameter-arrays-2.stderr b/src/test/ui/associated-consts/associated-const-type-parameter-arrays-2.stderr similarity index 100% rename from src/test/ui/associated-const/associated-const-type-parameter-arrays-2.stderr rename to src/test/ui/associated-consts/associated-const-type-parameter-arrays-2.stderr diff --git a/src/test/ui/associated-const/associated-const-type-parameter-arrays.rs b/src/test/ui/associated-consts/associated-const-type-parameter-arrays.rs similarity index 100% rename from src/test/ui/associated-const/associated-const-type-parameter-arrays.rs rename to src/test/ui/associated-consts/associated-const-type-parameter-arrays.rs diff --git a/src/test/ui/associated-const/associated-const-type-parameter-arrays.stderr b/src/test/ui/associated-consts/associated-const-type-parameter-arrays.stderr similarity index 100% rename from src/test/ui/associated-const/associated-const-type-parameter-arrays.stderr rename to src/test/ui/associated-consts/associated-const-type-parameter-arrays.stderr diff --git a/src/test/ui/associated-const/defaults-cyclic-fail.rs b/src/test/ui/associated-consts/defaults-cyclic-fail.rs similarity index 100% rename from src/test/ui/associated-const/defaults-cyclic-fail.rs rename to src/test/ui/associated-consts/defaults-cyclic-fail.rs diff --git a/src/test/ui/associated-const/defaults-cyclic-fail.stderr b/src/test/ui/associated-consts/defaults-cyclic-fail.stderr similarity index 100% rename from src/test/ui/associated-const/defaults-cyclic-fail.stderr rename to src/test/ui/associated-consts/defaults-cyclic-fail.stderr diff --git a/src/test/ui/associated-const/defaults-cyclic-pass.rs b/src/test/ui/associated-consts/defaults-cyclic-pass.rs similarity index 100% rename from src/test/ui/associated-const/defaults-cyclic-pass.rs rename to src/test/ui/associated-consts/defaults-cyclic-pass.rs diff --git a/src/test/ui/associated-const/defaults-not-assumed-fail.rs b/src/test/ui/associated-consts/defaults-not-assumed-fail.rs similarity index 100% rename from src/test/ui/associated-const/defaults-not-assumed-fail.rs rename to src/test/ui/associated-consts/defaults-not-assumed-fail.rs diff --git a/src/test/ui/associated-const/defaults-not-assumed-fail.stderr b/src/test/ui/associated-consts/defaults-not-assumed-fail.stderr similarity index 100% rename from src/test/ui/associated-const/defaults-not-assumed-fail.stderr rename to src/test/ui/associated-consts/defaults-not-assumed-fail.stderr diff --git a/src/test/ui/associated-const/defaults-not-assumed-pass.rs b/src/test/ui/associated-consts/defaults-not-assumed-pass.rs similarity index 100% rename from src/test/ui/associated-const/defaults-not-assumed-pass.rs rename to src/test/ui/associated-consts/defaults-not-assumed-pass.rs diff --git a/src/test/ui/associated-const/issue-63496.rs b/src/test/ui/associated-consts/issue-63496.rs similarity index 100% rename from src/test/ui/associated-const/issue-63496.rs rename to src/test/ui/associated-consts/issue-63496.rs diff --git a/src/test/ui/associated-const/issue-63496.stderr b/src/test/ui/associated-consts/issue-63496.stderr similarity index 100% rename from src/test/ui/associated-const/issue-63496.stderr rename to src/test/ui/associated-consts/issue-63496.stderr diff --git a/src/test/ui/associated-const/issue-69020-assoc-const-arith-overflow.noopt.stderr b/src/test/ui/associated-consts/issue-69020-assoc-const-arith-overflow.noopt.stderr similarity index 100% rename from src/test/ui/associated-const/issue-69020-assoc-const-arith-overflow.noopt.stderr rename to src/test/ui/associated-consts/issue-69020-assoc-const-arith-overflow.noopt.stderr diff --git a/src/test/ui/associated-const/issue-69020-assoc-const-arith-overflow.opt.stderr b/src/test/ui/associated-consts/issue-69020-assoc-const-arith-overflow.opt.stderr similarity index 100% rename from src/test/ui/associated-const/issue-69020-assoc-const-arith-overflow.opt.stderr rename to src/test/ui/associated-consts/issue-69020-assoc-const-arith-overflow.opt.stderr diff --git a/src/test/ui/associated-const/issue-69020-assoc-const-arith-overflow.opt_with_overflow_checks.stderr b/src/test/ui/associated-consts/issue-69020-assoc-const-arith-overflow.opt_with_overflow_checks.stderr similarity index 100% rename from src/test/ui/associated-const/issue-69020-assoc-const-arith-overflow.opt_with_overflow_checks.stderr rename to src/test/ui/associated-consts/issue-69020-assoc-const-arith-overflow.opt_with_overflow_checks.stderr diff --git a/src/test/ui/associated-const/issue-69020-assoc-const-arith-overflow.rs b/src/test/ui/associated-consts/issue-69020-assoc-const-arith-overflow.rs similarity index 100% rename from src/test/ui/associated-const/issue-69020-assoc-const-arith-overflow.rs rename to src/test/ui/associated-consts/issue-69020-assoc-const-arith-overflow.rs diff --git a/src/test/ui/associated-type/associated-type-projection-ambig-between-bound-and-where-clause.rs b/src/test/ui/associated-types/associated-type-projection-ambig-between-bound-and-where-clause.rs similarity index 100% rename from src/test/ui/associated-type/associated-type-projection-ambig-between-bound-and-where-clause.rs rename to src/test/ui/associated-types/associated-type-projection-ambig-between-bound-and-where-clause.rs diff --git a/src/test/ui/associated-type/associated-type-projection-ambig-between-bound-and-where-clause.stderr b/src/test/ui/associated-types/associated-type-projection-ambig-between-bound-and-where-clause.stderr similarity index 100% rename from src/test/ui/associated-type/associated-type-projection-ambig-between-bound-and-where-clause.stderr rename to src/test/ui/associated-types/associated-type-projection-ambig-between-bound-and-where-clause.stderr diff --git a/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.rs b/src/test/ui/associated-types/associated-type-projection-from-multiple-supertraits.rs similarity index 100% rename from src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.rs rename to src/test/ui/associated-types/associated-type-projection-from-multiple-supertraits.rs diff --git a/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.stderr b/src/test/ui/associated-types/associated-type-projection-from-multiple-supertraits.stderr similarity index 100% rename from src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.stderr rename to src/test/ui/associated-types/associated-type-projection-from-multiple-supertraits.stderr diff --git a/src/test/ui/associated-type/associated-type-projection-from-supertrait.rs b/src/test/ui/associated-types/associated-type-projection-from-supertrait.rs similarity index 100% rename from src/test/ui/associated-type/associated-type-projection-from-supertrait.rs rename to src/test/ui/associated-types/associated-type-projection-from-supertrait.rs diff --git a/src/test/ui/associated-type/associated-type-projection-from-supertrait.stderr b/src/test/ui/associated-types/associated-type-projection-from-supertrait.stderr similarity index 100% rename from src/test/ui/associated-type/associated-type-projection-from-supertrait.stderr rename to src/test/ui/associated-types/associated-type-projection-from-supertrait.stderr diff --git a/src/test/ui/closure-expected-type/expect-two-infer-vars-supply-ty-with-bound-region.stderr b/src/test/ui/closure-expected-type/expect-two-infer-vars-supply-ty-with-bound-region.stderr index 0c6d11cd3211d..2005bd4dd5ca7 100644 --- a/src/test/ui/closure-expected-type/expect-two-infer-vars-supply-ty-with-bound-region.stderr +++ b/src/test/ui/closure-expected-type/expect-two-infer-vars-supply-ty-with-bound-region.stderr @@ -1,8 +1,8 @@ error[E0282]: type annotations needed - --> $DIR/expect-two-infer-vars-supply-ty-with-bound-region.rs:8:5 + --> $DIR/expect-two-infer-vars-supply-ty-with-bound-region.rs:8:27 | LL | with_closure(|x: u32, y| {}); - | ^^^^^^^^^^^^ cannot infer type for type parameter `B` declared on the function `with_closure` + | ^ consider giving this closure parameter a type error: aborting due to previous error diff --git a/src/test/ui/generic/generic-arg-mismatch-recover.rs b/src/test/ui/generics/generic-arg-mismatch-recover.rs similarity index 100% rename from src/test/ui/generic/generic-arg-mismatch-recover.rs rename to src/test/ui/generics/generic-arg-mismatch-recover.rs diff --git a/src/test/ui/generic/generic-arg-mismatch-recover.stderr b/src/test/ui/generics/generic-arg-mismatch-recover.stderr similarity index 100% rename from src/test/ui/generic/generic-arg-mismatch-recover.stderr rename to src/test/ui/generics/generic-arg-mismatch-recover.stderr diff --git a/src/test/ui/generic/generic-extern-lifetime.rs b/src/test/ui/generics/generic-extern-lifetime.rs similarity index 100% rename from src/test/ui/generic/generic-extern-lifetime.rs rename to src/test/ui/generics/generic-extern-lifetime.rs diff --git a/src/test/ui/generic/generic-extern-lifetime.stderr b/src/test/ui/generics/generic-extern-lifetime.stderr similarity index 100% rename from src/test/ui/generic/generic-extern-lifetime.stderr rename to src/test/ui/generics/generic-extern-lifetime.stderr diff --git a/src/test/ui/generic/generic-extern.rs b/src/test/ui/generics/generic-extern.rs similarity index 100% rename from src/test/ui/generic/generic-extern.rs rename to src/test/ui/generics/generic-extern.rs diff --git a/src/test/ui/generic/generic-extern.stderr b/src/test/ui/generics/generic-extern.stderr similarity index 100% rename from src/test/ui/generic/generic-extern.stderr rename to src/test/ui/generics/generic-extern.stderr diff --git a/src/test/ui/generic/generic-impl-less-params-with-defaults.rs b/src/test/ui/generics/generic-impl-less-params-with-defaults.rs similarity index 100% rename from src/test/ui/generic/generic-impl-less-params-with-defaults.rs rename to src/test/ui/generics/generic-impl-less-params-with-defaults.rs diff --git a/src/test/ui/generic/generic-impl-less-params-with-defaults.stderr b/src/test/ui/generics/generic-impl-less-params-with-defaults.stderr similarity index 100% rename from src/test/ui/generic/generic-impl-less-params-with-defaults.stderr rename to src/test/ui/generics/generic-impl-less-params-with-defaults.stderr diff --git a/src/test/ui/generic/generic-impl-more-params-with-defaults.rs b/src/test/ui/generics/generic-impl-more-params-with-defaults.rs similarity index 100% rename from src/test/ui/generic/generic-impl-more-params-with-defaults.rs rename to src/test/ui/generics/generic-impl-more-params-with-defaults.rs diff --git a/src/test/ui/generic/generic-impl-more-params-with-defaults.stderr b/src/test/ui/generics/generic-impl-more-params-with-defaults.stderr similarity index 100% rename from src/test/ui/generic/generic-impl-more-params-with-defaults.stderr rename to src/test/ui/generics/generic-impl-more-params-with-defaults.stderr diff --git a/src/test/ui/generic/generic-lifetime-trait-impl.rs b/src/test/ui/generics/generic-lifetime-trait-impl.rs similarity index 100% rename from src/test/ui/generic/generic-lifetime-trait-impl.rs rename to src/test/ui/generics/generic-lifetime-trait-impl.rs diff --git a/src/test/ui/generic/generic-lifetime-trait-impl.stderr b/src/test/ui/generics/generic-lifetime-trait-impl.stderr similarity index 100% rename from src/test/ui/generic/generic-lifetime-trait-impl.stderr rename to src/test/ui/generics/generic-lifetime-trait-impl.stderr diff --git a/src/test/ui/generic/generic-no-mangle.fixed b/src/test/ui/generics/generic-no-mangle.fixed similarity index 100% rename from src/test/ui/generic/generic-no-mangle.fixed rename to src/test/ui/generics/generic-no-mangle.fixed diff --git a/src/test/ui/generic/generic-no-mangle.rs b/src/test/ui/generics/generic-no-mangle.rs similarity index 100% rename from src/test/ui/generic/generic-no-mangle.rs rename to src/test/ui/generics/generic-no-mangle.rs diff --git a/src/test/ui/generic/generic-no-mangle.stderr b/src/test/ui/generics/generic-no-mangle.stderr similarity index 100% rename from src/test/ui/generic/generic-no-mangle.stderr rename to src/test/ui/generics/generic-no-mangle.stderr diff --git a/src/test/ui/generic/generic-non-trailing-defaults.rs b/src/test/ui/generics/generic-non-trailing-defaults.rs similarity index 100% rename from src/test/ui/generic/generic-non-trailing-defaults.rs rename to src/test/ui/generics/generic-non-trailing-defaults.rs diff --git a/src/test/ui/generic/generic-non-trailing-defaults.stderr b/src/test/ui/generics/generic-non-trailing-defaults.stderr similarity index 100% rename from src/test/ui/generic/generic-non-trailing-defaults.stderr rename to src/test/ui/generics/generic-non-trailing-defaults.stderr diff --git a/src/test/ui/generic/generic-param-attrs.rs b/src/test/ui/generics/generic-param-attrs.rs similarity index 100% rename from src/test/ui/generic/generic-param-attrs.rs rename to src/test/ui/generics/generic-param-attrs.rs diff --git a/src/test/ui/generic/generic-type-less-params-with-defaults.rs b/src/test/ui/generics/generic-type-less-params-with-defaults.rs similarity index 100% rename from src/test/ui/generic/generic-type-less-params-with-defaults.rs rename to src/test/ui/generics/generic-type-less-params-with-defaults.rs diff --git a/src/test/ui/generic/generic-type-less-params-with-defaults.stderr b/src/test/ui/generics/generic-type-less-params-with-defaults.stderr similarity index 100% rename from src/test/ui/generic/generic-type-less-params-with-defaults.stderr rename to src/test/ui/generics/generic-type-less-params-with-defaults.stderr diff --git a/src/test/ui/generic/generic-type-more-params-with-defaults.rs b/src/test/ui/generics/generic-type-more-params-with-defaults.rs similarity index 100% rename from src/test/ui/generic/generic-type-more-params-with-defaults.rs rename to src/test/ui/generics/generic-type-more-params-with-defaults.rs diff --git a/src/test/ui/generic/generic-type-more-params-with-defaults.stderr b/src/test/ui/generics/generic-type-more-params-with-defaults.stderr similarity index 100% rename from src/test/ui/generic/generic-type-more-params-with-defaults.stderr rename to src/test/ui/generics/generic-type-more-params-with-defaults.stderr diff --git a/src/test/ui/generic/generic-type-params-forward-mention.rs b/src/test/ui/generics/generic-type-params-forward-mention.rs similarity index 100% rename from src/test/ui/generic/generic-type-params-forward-mention.rs rename to src/test/ui/generics/generic-type-params-forward-mention.rs diff --git a/src/test/ui/generic/generic-type-params-forward-mention.stderr b/src/test/ui/generics/generic-type-params-forward-mention.stderr similarity index 100% rename from src/test/ui/generic/generic-type-params-forward-mention.stderr rename to src/test/ui/generics/generic-type-params-forward-mention.stderr diff --git a/src/test/ui/generic/generic-type-params-name-repr.rs b/src/test/ui/generics/generic-type-params-name-repr.rs similarity index 100% rename from src/test/ui/generic/generic-type-params-name-repr.rs rename to src/test/ui/generics/generic-type-params-name-repr.rs diff --git a/src/test/ui/generic/generic-type-params-name-repr.stderr b/src/test/ui/generics/generic-type-params-name-repr.stderr similarity index 100% rename from src/test/ui/generic/generic-type-params-name-repr.stderr rename to src/test/ui/generics/generic-type-params-name-repr.stderr diff --git a/src/test/ui/generic/param-in-ct-in-ty-param-default.rs b/src/test/ui/generics/param-in-ct-in-ty-param-default.rs similarity index 100% rename from src/test/ui/generic/param-in-ct-in-ty-param-default.rs rename to src/test/ui/generics/param-in-ct-in-ty-param-default.rs diff --git a/src/test/ui/generic/param-in-ct-in-ty-param-default.stderr b/src/test/ui/generics/param-in-ct-in-ty-param-default.stderr similarity index 100% rename from src/test/ui/generic/param-in-ct-in-ty-param-default.stderr rename to src/test/ui/generics/param-in-ct-in-ty-param-default.stderr diff --git a/src/test/ui/issues/issue-23046.rs b/src/test/ui/issues/issue-23046.rs index 75be4a11efd22..a68369616d8b6 100644 --- a/src/test/ui/issues/issue-23046.rs +++ b/src/test/ui/issues/issue-23046.rs @@ -14,7 +14,7 @@ pub fn let_<'var, VAR, F: for<'v> Fn(Expr<'v, VAR>) -> Expr<'v, VAR>> } fn main() { - let ex = |x| { - let_(add(x,x), |y| { //~ ERROR type annotations needed + let ex = |x| { //~ ERROR type annotations needed + let_(add(x,x), |y| { let_(add(x, x), |x|x)})}; } diff --git a/src/test/ui/issues/issue-23046.stderr b/src/test/ui/issues/issue-23046.stderr index 77555fce7c460..12b2eb48e7eaa 100644 --- a/src/test/ui/issues/issue-23046.stderr +++ b/src/test/ui/issues/issue-23046.stderr @@ -1,13 +1,8 @@ -error[E0282]: type annotations needed for the closure `fn(Expr<'_, _>) -> Expr<'_, _>` - --> $DIR/issue-23046.rs:18:9 +error[E0282]: type annotations needed for `Expr<'_, VAR>` + --> $DIR/issue-23046.rs:17:15 | -LL | let_(add(x,x), |y| { - | ^^^^ cannot infer type for type parameter `VAR` declared on the function `let_` - | -help: give this closure an explicit return type without `_` placeholders - | -LL | let_(add(x, x), |x|-> Expr<'_, _> { x })})}; - | ^^^^^^^^^^^^^^^^ ^ +LL | let ex = |x| { + | ^ consider giving this closure parameter the explicit type `Expr<'_, VAR>`, where the type parameter `VAR` is specified error: aborting due to previous error diff --git a/src/test/ui/issues/issue-72690.stderr b/src/test/ui/issues/issue-72690.stderr index feb1316357e5c..3443cca5f3270 100644 --- a/src/test/ui/issues/issue-72690.stderr +++ b/src/test/ui/issues/issue-72690.stderr @@ -2,7 +2,7 @@ error[E0283]: type annotations needed --> $DIR/issue-72690.rs:7:5 | LL | String::from("x".as_ref()); - | ^^^^^^^^^^^^ cannot infer type for struct `String` + | ^^^^^^^^^^^^ cannot infer type for reference `&_` | = note: cannot satisfy `String: From<&_>` = note: required by `from` @@ -13,11 +13,13 @@ error[E0282]: type annotations needed LL | |x| String::from("x".as_ref()); | ^ consider giving this closure parameter a type -error[E0283]: type annotations needed +error[E0283]: type annotations needed for `&T` --> $DIR/issue-72690.rs:15:17 | LL | let _ = "x".as_ref(); - | ^^^^^^ cannot infer type for type `str` + | - ^^^^^^ cannot infer type for type parameter `T` declared on the trait `AsRef` + | | + | consider giving this pattern the explicit type `&T`, where the type parameter `T` is specified | = note: cannot satisfy `str: AsRef<_>` @@ -25,7 +27,7 @@ error[E0283]: type annotations needed --> $DIR/issue-72690.rs:19:5 | LL | String::from("x".as_ref()); - | ^^^^^^^^^^^^ cannot infer type for struct `String` + | ^^^^^^^^^^^^ cannot infer type for reference `&_` | = note: cannot satisfy `String: From<&_>` = note: required by `from` @@ -34,7 +36,7 @@ error[E0283]: type annotations needed --> $DIR/issue-72690.rs:25:5 | LL | String::from("x".as_ref()); - | ^^^^^^^^^^^^ cannot infer type for struct `String` + | ^^^^^^^^^^^^ cannot infer type for reference `&_` | = note: cannot satisfy `String: From<&_>` = note: required by `from` @@ -43,41 +45,34 @@ error[E0283]: type annotations needed --> $DIR/issue-72690.rs:33:5 | LL | String::from("x".as_ref()); - | ^^^^^^^^^^^^ cannot infer type for struct `String` + | ^^^^^^^^^^^^ cannot infer type for reference `&_` | = note: cannot satisfy `String: From<&_>` = note: required by `from` -error[E0283]: type annotations needed for `String` +error[E0283]: type annotations needed --> $DIR/issue-72690.rs:41:5 | LL | String::from("x".as_ref()); - | ^^^^^^^^^^^^ cannot infer type for struct `String` -LL | let _ = String::from("x"); - | - consider giving this pattern a type + | ^^^^^^^^^^^^ cannot infer type for reference `&_` | = note: cannot satisfy `String: From<&_>` = note: required by `from` -error[E0283]: type annotations needed for `String` +error[E0283]: type annotations needed --> $DIR/issue-72690.rs:47:5 | -LL | let _ = String::from("x"); - | - consider giving this pattern a type LL | String::from("x".as_ref()); - | ^^^^^^^^^^^^ cannot infer type for struct `String` + | ^^^^^^^^^^^^ cannot infer type for reference `&_` | = note: cannot satisfy `String: From<&_>` = note: required by `from` -error[E0283]: type annotations needed for `String` +error[E0283]: type annotations needed --> $DIR/issue-72690.rs:55:5 | -LL | let _ = String::from("x"); - | - consider giving this pattern a type -... LL | String::from("x".as_ref()); - | ^^^^^^^^^^^^ cannot infer type for struct `String` + | ^^^^^^^^^^^^ cannot infer type for reference `&_` | = note: cannot satisfy `String: From<&_>` = note: required by `from` diff --git a/src/test/ui/issues/issue-78115.rs b/src/test/ui/issues/issue-78115.rs new file mode 100644 index 0000000000000..ac18470c62113 --- /dev/null +++ b/src/test/ui/issues/issue-78115.rs @@ -0,0 +1,19 @@ +// Regression test for issue #78115: "ICE: variable should be placed in scope earlier" + +// check-pass +// edition:2018 + +#[allow(dead_code)] +struct Foo { + a: () +} + +async fn _bar() { + let foo = Foo { a: () }; + match foo { + Foo { a: _a } | Foo { a: _a } if true => {} + _ => {} + } +} + +fn main() {} diff --git a/src/test/ui/lint/lint-unnecessary-parens.fixed b/src/test/ui/lint/lint-unnecessary-parens.fixed index c9dec395580f1..9c144324f2f7e 100644 --- a/src/test/ui/lint/lint-unnecessary-parens.fixed +++ b/src/test/ui/lint/lint-unnecessary-parens.fixed @@ -60,6 +60,8 @@ fn main() { if (v == X { y: true }) {} if (X { y: true } == v) {} if (X { y: false }.y) {} + // this shouldn't warn, because the parens are necessary to disambiguate let chains + if let true = (true && false) {} while (X { y: false }.foo(true)) {} while (true | X { y: false }.y) {} diff --git a/src/test/ui/lint/lint-unnecessary-parens.rs b/src/test/ui/lint/lint-unnecessary-parens.rs index 884bb4d2e99b6..4fd9cabb3b0b2 100644 --- a/src/test/ui/lint/lint-unnecessary-parens.rs +++ b/src/test/ui/lint/lint-unnecessary-parens.rs @@ -60,6 +60,8 @@ fn main() { if (v == X { y: true }) {} if (X { y: true } == v) {} if (X { y: false }.y) {} + // this shouldn't warn, because the parens are necessary to disambiguate let chains + if let true = (true && false) {} while (X { y: false }.foo(true)) {} while (true | X { y: false }.y) {} diff --git a/src/test/ui/lint/lint-unnecessary-parens.stderr b/src/test/ui/lint/lint-unnecessary-parens.stderr index 1abf47c8af521..9eae7da90047e 100644 --- a/src/test/ui/lint/lint-unnecessary-parens.stderr +++ b/src/test/ui/lint/lint-unnecessary-parens.stderr @@ -83,25 +83,25 @@ LL | while let 1 = (2) {} | ^^^ help: remove these parentheses error: unnecessary parentheses around method argument - --> $DIR/lint-unnecessary-parens.rs:71:24 + --> $DIR/lint-unnecessary-parens.rs:73:24 | LL | X { y: false }.foo((true)); | ^^^^^^ help: remove these parentheses error: unnecessary parentheses around assigned value - --> $DIR/lint-unnecessary-parens.rs:73:18 + --> $DIR/lint-unnecessary-parens.rs:75:18 | LL | let mut _a = (0); | ^^^ help: remove these parentheses error: unnecessary parentheses around assigned value - --> $DIR/lint-unnecessary-parens.rs:74:10 + --> $DIR/lint-unnecessary-parens.rs:76:10 | LL | _a = (0); | ^^^ help: remove these parentheses error: unnecessary parentheses around assigned value - --> $DIR/lint-unnecessary-parens.rs:75:11 + --> $DIR/lint-unnecessary-parens.rs:77:11 | LL | _a += (1); | ^^^ help: remove these parentheses diff --git a/src/test/ui/mod/mod_file_aux.rs b/src/test/ui/modules_and_files_visibility/mod_file_aux.rs similarity index 100% rename from src/test/ui/mod/mod_file_aux.rs rename to src/test/ui/modules_and_files_visibility/mod_file_aux.rs diff --git a/src/test/ui/mod/mod_file_correct_spans.rs b/src/test/ui/modules_and_files_visibility/mod_file_correct_spans.rs similarity index 100% rename from src/test/ui/mod/mod_file_correct_spans.rs rename to src/test/ui/modules_and_files_visibility/mod_file_correct_spans.rs diff --git a/src/test/ui/mod/mod_file_correct_spans.stderr b/src/test/ui/modules_and_files_visibility/mod_file_correct_spans.stderr similarity index 100% rename from src/test/ui/mod/mod_file_correct_spans.stderr rename to src/test/ui/modules_and_files_visibility/mod_file_correct_spans.stderr diff --git a/src/test/ui/mod/mod_file_disambig.rs b/src/test/ui/modules_and_files_visibility/mod_file_disambig.rs similarity index 100% rename from src/test/ui/mod/mod_file_disambig.rs rename to src/test/ui/modules_and_files_visibility/mod_file_disambig.rs diff --git a/src/test/ui/mod/mod_file_disambig.stderr b/src/test/ui/modules_and_files_visibility/mod_file_disambig.stderr similarity index 100% rename from src/test/ui/mod/mod_file_disambig.stderr rename to src/test/ui/modules_and_files_visibility/mod_file_disambig.stderr diff --git a/src/test/ui/mod/mod_file_disambig_aux.rs b/src/test/ui/modules_and_files_visibility/mod_file_disambig_aux.rs similarity index 100% rename from src/test/ui/mod/mod_file_disambig_aux.rs rename to src/test/ui/modules_and_files_visibility/mod_file_disambig_aux.rs diff --git a/src/test/ui/mod/mod_file_disambig_aux/mod.rs b/src/test/ui/modules_and_files_visibility/mod_file_disambig_aux/mod.rs similarity index 100% rename from src/test/ui/mod/mod_file_disambig_aux/mod.rs rename to src/test/ui/modules_and_files_visibility/mod_file_disambig_aux/mod.rs diff --git a/src/test/ui/rfc1445/allow-hide-behind-direct-unsafe-ptr-embedded.rs b/src/test/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-embedded.rs similarity index 100% rename from src/test/ui/rfc1445/allow-hide-behind-direct-unsafe-ptr-embedded.rs rename to src/test/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-embedded.rs diff --git a/src/test/ui/rfc1445/allow-hide-behind-direct-unsafe-ptr-param.rs b/src/test/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-param.rs similarity index 100% rename from src/test/ui/rfc1445/allow-hide-behind-direct-unsafe-ptr-param.rs rename to src/test/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-param.rs diff --git a/src/test/ui/rfc1445/allow-hide-behind-indirect-unsafe-ptr-embedded.rs b/src/test/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-embedded.rs similarity index 100% rename from src/test/ui/rfc1445/allow-hide-behind-indirect-unsafe-ptr-embedded.rs rename to src/test/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-embedded.rs diff --git a/src/test/ui/rfc1445/allow-hide-behind-indirect-unsafe-ptr-param.rs b/src/test/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-param.rs similarity index 100% rename from src/test/ui/rfc1445/allow-hide-behind-indirect-unsafe-ptr-param.rs rename to src/test/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-param.rs diff --git a/src/test/ui/rfc1445/allow-use-behind-cousin-variant.rs b/src/test/ui/rfc-1445-restrict-constants-in-patterns/allow-use-behind-cousin-variant.rs similarity index 100% rename from src/test/ui/rfc1445/allow-use-behind-cousin-variant.rs rename to src/test/ui/rfc-1445-restrict-constants-in-patterns/allow-use-behind-cousin-variant.rs diff --git a/src/test/ui/rfc1445/cant-hide-behind-direct-struct-embedded.rs b/src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.rs similarity index 100% rename from src/test/ui/rfc1445/cant-hide-behind-direct-struct-embedded.rs rename to src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.rs diff --git a/src/test/ui/rfc1445/cant-hide-behind-direct-struct-embedded.stderr b/src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.stderr similarity index 100% rename from src/test/ui/rfc1445/cant-hide-behind-direct-struct-embedded.stderr rename to src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.stderr diff --git a/src/test/ui/rfc1445/cant-hide-behind-direct-struct-param.rs b/src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.rs similarity index 100% rename from src/test/ui/rfc1445/cant-hide-behind-direct-struct-param.rs rename to src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.rs diff --git a/src/test/ui/rfc1445/cant-hide-behind-direct-struct-param.stderr b/src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.stderr similarity index 100% rename from src/test/ui/rfc1445/cant-hide-behind-direct-struct-param.stderr rename to src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.stderr diff --git a/src/test/ui/rfc1445/cant-hide-behind-doubly-indirect-embedded.rs b/src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.rs similarity index 100% rename from src/test/ui/rfc1445/cant-hide-behind-doubly-indirect-embedded.rs rename to src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.rs diff --git a/src/test/ui/rfc1445/cant-hide-behind-doubly-indirect-embedded.stderr b/src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.stderr similarity index 100% rename from src/test/ui/rfc1445/cant-hide-behind-doubly-indirect-embedded.stderr rename to src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.stderr diff --git a/src/test/ui/rfc1445/cant-hide-behind-doubly-indirect-param.rs b/src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.rs similarity index 100% rename from src/test/ui/rfc1445/cant-hide-behind-doubly-indirect-param.rs rename to src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.rs diff --git a/src/test/ui/rfc1445/cant-hide-behind-doubly-indirect-param.stderr b/src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.stderr similarity index 100% rename from src/test/ui/rfc1445/cant-hide-behind-doubly-indirect-param.stderr rename to src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.stderr diff --git a/src/test/ui/rfc1445/cant-hide-behind-indirect-struct-embedded.rs b/src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.rs similarity index 100% rename from src/test/ui/rfc1445/cant-hide-behind-indirect-struct-embedded.rs rename to src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.rs diff --git a/src/test/ui/rfc1445/cant-hide-behind-indirect-struct-embedded.stderr b/src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.stderr similarity index 100% rename from src/test/ui/rfc1445/cant-hide-behind-indirect-struct-embedded.stderr rename to src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.stderr diff --git a/src/test/ui/rfc1445/cant-hide-behind-indirect-struct-param.rs b/src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.rs similarity index 100% rename from src/test/ui/rfc1445/cant-hide-behind-indirect-struct-param.rs rename to src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.rs diff --git a/src/test/ui/rfc1445/cant-hide-behind-indirect-struct-param.stderr b/src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.stderr similarity index 100% rename from src/test/ui/rfc1445/cant-hide-behind-indirect-struct-param.stderr rename to src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.stderr diff --git a/src/test/ui/rfc1445/feature-gate.no_gate.stderr b/src/test/ui/rfc-1445-restrict-constants-in-patterns/feature-gate.no_gate.stderr similarity index 100% rename from src/test/ui/rfc1445/feature-gate.no_gate.stderr rename to src/test/ui/rfc-1445-restrict-constants-in-patterns/feature-gate.no_gate.stderr diff --git a/src/test/ui/rfc1445/feature-gate.rs b/src/test/ui/rfc-1445-restrict-constants-in-patterns/feature-gate.rs similarity index 100% rename from src/test/ui/rfc1445/feature-gate.rs rename to src/test/ui/rfc-1445-restrict-constants-in-patterns/feature-gate.rs diff --git a/src/test/ui/rfc1445/feature-gate.with_gate.stderr b/src/test/ui/rfc-1445-restrict-constants-in-patterns/feature-gate.with_gate.stderr similarity index 100% rename from src/test/ui/rfc1445/feature-gate.with_gate.stderr rename to src/test/ui/rfc-1445-restrict-constants-in-patterns/feature-gate.with_gate.stderr diff --git a/src/test/ui/rfc1445/fn-ptr-is-structurally-matchable.rs b/src/test/ui/rfc-1445-restrict-constants-in-patterns/fn-ptr-is-structurally-matchable.rs similarity index 100% rename from src/test/ui/rfc1445/fn-ptr-is-structurally-matchable.rs rename to src/test/ui/rfc-1445-restrict-constants-in-patterns/fn-ptr-is-structurally-matchable.rs diff --git a/src/test/ui/rfc1445/issue-61188-match-slice-forbidden-without-eq.rs b/src/test/ui/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.rs similarity index 100% rename from src/test/ui/rfc1445/issue-61188-match-slice-forbidden-without-eq.rs rename to src/test/ui/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.rs diff --git a/src/test/ui/rfc1445/issue-61188-match-slice-forbidden-without-eq.stderr b/src/test/ui/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr similarity index 100% rename from src/test/ui/rfc1445/issue-61188-match-slice-forbidden-without-eq.stderr rename to src/test/ui/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr diff --git a/src/test/ui/rfc1445/issue-62307-match-ref-ref-forbidden-without-eq.rs b/src/test/ui/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.rs similarity index 100% rename from src/test/ui/rfc1445/issue-62307-match-ref-ref-forbidden-without-eq.rs rename to src/test/ui/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.rs diff --git a/src/test/ui/rfc1445/issue-62307-match-ref-ref-forbidden-without-eq.stderr b/src/test/ui/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.stderr similarity index 100% rename from src/test/ui/rfc1445/issue-62307-match-ref-ref-forbidden-without-eq.stderr rename to src/test/ui/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.stderr diff --git a/src/test/ui/rfc1445/issue-63479-match-fnptr.rs b/src/test/ui/rfc-1445-restrict-constants-in-patterns/issue-63479-match-fnptr.rs similarity index 100% rename from src/test/ui/rfc1445/issue-63479-match-fnptr.rs rename to src/test/ui/rfc-1445-restrict-constants-in-patterns/issue-63479-match-fnptr.rs diff --git a/src/test/ui/rfc1445/issue-63479-match-fnptr.stderr b/src/test/ui/rfc-1445-restrict-constants-in-patterns/issue-63479-match-fnptr.stderr similarity index 100% rename from src/test/ui/rfc1445/issue-63479-match-fnptr.stderr rename to src/test/ui/rfc-1445-restrict-constants-in-patterns/issue-63479-match-fnptr.stderr diff --git a/src/test/ui/rfc1445/match-empty-array-allowed-without-eq-issue-62336.rs b/src/test/ui/rfc-1445-restrict-constants-in-patterns/match-empty-array-allowed-without-eq-issue-62336.rs similarity index 100% rename from src/test/ui/rfc1445/match-empty-array-allowed-without-eq-issue-62336.rs rename to src/test/ui/rfc-1445-restrict-constants-in-patterns/match-empty-array-allowed-without-eq-issue-62336.rs diff --git a/src/test/ui/rfc1445/match-forbidden-without-eq.rs b/src/test/ui/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.rs similarity index 100% rename from src/test/ui/rfc1445/match-forbidden-without-eq.rs rename to src/test/ui/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.rs diff --git a/src/test/ui/rfc1445/match-forbidden-without-eq.stderr b/src/test/ui/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.stderr similarity index 100% rename from src/test/ui/rfc1445/match-forbidden-without-eq.stderr rename to src/test/ui/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.stderr diff --git a/src/test/ui/rfc1445/match-nonempty-array-forbidden-without-eq.rs b/src/test/ui/rfc-1445-restrict-constants-in-patterns/match-nonempty-array-forbidden-without-eq.rs similarity index 100% rename from src/test/ui/rfc1445/match-nonempty-array-forbidden-without-eq.rs rename to src/test/ui/rfc-1445-restrict-constants-in-patterns/match-nonempty-array-forbidden-without-eq.rs diff --git a/src/test/ui/rfc1445/match-nonempty-array-forbidden-without-eq.stderr b/src/test/ui/rfc-1445-restrict-constants-in-patterns/match-nonempty-array-forbidden-without-eq.stderr similarity index 100% rename from src/test/ui/rfc1445/match-nonempty-array-forbidden-without-eq.stderr rename to src/test/ui/rfc-1445-restrict-constants-in-patterns/match-nonempty-array-forbidden-without-eq.stderr diff --git a/src/test/ui/rfc1445/match-requires-both-partialeq-and-eq.rs b/src/test/ui/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.rs similarity index 100% rename from src/test/ui/rfc1445/match-requires-both-partialeq-and-eq.rs rename to src/test/ui/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.rs diff --git a/src/test/ui/rfc1445/match-requires-both-partialeq-and-eq.stderr b/src/test/ui/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.stderr similarity index 100% rename from src/test/ui/rfc1445/match-requires-both-partialeq-and-eq.stderr rename to src/test/ui/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.stderr diff --git a/src/test/ui/rfc1445/phantom-data-is-structurally-matchable.rs b/src/test/ui/rfc-1445-restrict-constants-in-patterns/phantom-data-is-structurally-matchable.rs similarity index 100% rename from src/test/ui/rfc1445/phantom-data-is-structurally-matchable.rs rename to src/test/ui/rfc-1445-restrict-constants-in-patterns/phantom-data-is-structurally-matchable.rs diff --git a/src/test/ui/rfc1717/missing-link-attr.rs b/src/test/ui/rfc-1717-dllimport/missing-link-attr.rs similarity index 100% rename from src/test/ui/rfc1717/missing-link-attr.rs rename to src/test/ui/rfc-1717-dllimport/missing-link-attr.rs diff --git a/src/test/ui/rfc1717/missing-link-attr.stderr b/src/test/ui/rfc-1717-dllimport/missing-link-attr.stderr similarity index 100% rename from src/test/ui/rfc1717/missing-link-attr.stderr rename to src/test/ui/rfc-1717-dllimport/missing-link-attr.stderr diff --git a/src/test/ui/rfc1717/multiple-renames.rs b/src/test/ui/rfc-1717-dllimport/multiple-renames.rs similarity index 100% rename from src/test/ui/rfc1717/multiple-renames.rs rename to src/test/ui/rfc-1717-dllimport/multiple-renames.rs diff --git a/src/test/ui/rfc1717/multiple-renames.stderr b/src/test/ui/rfc-1717-dllimport/multiple-renames.stderr similarity index 100% rename from src/test/ui/rfc1717/multiple-renames.stderr rename to src/test/ui/rfc-1717-dllimport/multiple-renames.stderr diff --git a/src/test/ui/rfc1717/rename-to-empty.rs b/src/test/ui/rfc-1717-dllimport/rename-to-empty.rs similarity index 100% rename from src/test/ui/rfc1717/rename-to-empty.rs rename to src/test/ui/rfc-1717-dllimport/rename-to-empty.rs diff --git a/src/test/ui/rfc1717/rename-to-empty.stderr b/src/test/ui/rfc-1717-dllimport/rename-to-empty.stderr similarity index 100% rename from src/test/ui/rfc1717/rename-to-empty.stderr rename to src/test/ui/rfc-1717-dllimport/rename-to-empty.stderr diff --git a/src/test/ui/traits/issue-77982.rs b/src/test/ui/traits/issue-77982.rs new file mode 100644 index 0000000000000..03d4fe23cc5bc --- /dev/null +++ b/src/test/ui/traits/issue-77982.rs @@ -0,0 +1,40 @@ +use std::collections::HashMap; + +fn what() { + let descr = String::new(); + let mut opts = HashMap::::new(); + let opt = String::new(); + + opts.get(opt.as_ref()); //~ ERROR type annotations needed +} + +fn main() { + let ips: Vec<_> = (0..100_000).map(|_| u32::from(0u32.into())).collect(); + //~^ ERROR type annotations needed +} + +trait Foo<'a, T: ?Sized> { + fn foo(&self) -> Box { + todo!() + } +} + +trait Bar<'a, T: ?Sized> { + fn bar(&self) -> Box { + todo!() + } +} + +impl Foo<'static, u32> for () {} +impl<'a> Foo<'a, i16> for () {} + +impl<'a> Bar<'static, u32> for &'a () {} +impl<'a> Bar<'a, i16> for &'a () {} + +fn foo() { + let _ = ().foo(); //~ ERROR type annotations needed +} + +fn bar() { + let _ = (&()).bar(); //~ ERROR type annotations needed +} diff --git a/src/test/ui/traits/issue-77982.stderr b/src/test/ui/traits/issue-77982.stderr new file mode 100644 index 0000000000000..d788f1871ffac --- /dev/null +++ b/src/test/ui/traits/issue-77982.stderr @@ -0,0 +1,44 @@ +error[E0283]: type annotations needed + --> $DIR/issue-77982.rs:8:10 + | +LL | opts.get(opt.as_ref()); + | ^^^ ------------ this method call resolves to `&T` + | | + | cannot infer type for type parameter `Q` declared on the associated function `get` + | + = note: cannot satisfy `String: Borrow<_>` + +error[E0283]: type annotations needed + --> $DIR/issue-77982.rs:12:44 + | +LL | let ips: Vec<_> = (0..100_000).map(|_| u32::from(0u32.into())).collect(); + | ^^^^^^^^^ ----------- this method call resolves to `T` + | | + | cannot infer type for type parameter `T` declared on the trait `From` + | + = note: cannot satisfy `u32: From<_>` + = note: required by `from` + +error[E0283]: type annotations needed for `Box` + --> $DIR/issue-77982.rs:35:16 + | +LL | let _ = ().foo(); + | - ^^^ cannot infer type for type parameter `T` declared on the trait `Foo` + | | + | consider giving this pattern the explicit type `Box`, where the type parameter `T` is specified + | + = note: cannot satisfy `(): Foo<'_, _>` + +error[E0283]: type annotations needed for `Box` + --> $DIR/issue-77982.rs:39:19 + | +LL | let _ = (&()).bar(); + | - ^^^ cannot infer type for type parameter `T` declared on the trait `Bar` + | | + | consider giving this pattern the explicit type `Box`, where the type parameter `T` is specified + | + = note: cannot satisfy `&(): Bar<'_, _>` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0283`.