| author | bors <bors@rust-lang.org> 2024-07-24 22:37:03 UTC |
| committer | bors <bors@rust-lang.org> 2024-07-24 22:37:03 UTC |
| log | e7d66eac5e8e8f60370c98d186aee9fa0ebd7845 |
| tree | 97016eb7002b3db48e8c6d44226eaf59c49eb214 |
| parent | c1a6199e9d92bb785c17a6d7ffd8b8b552f79c10 |
| parent | 104a421a46f9756a3ebc1a77c40878479e99993e |
Rollup of 8 pull requests
Successful merges:
- #122192 (Do not try to reveal hidden types when trying to prove auto-traits in the defining scope)
- #126042 (Implement `unsigned_signed_diff`)
- #126548 (Improved clarity of documentation for std::fs::create_dir_all)
- #127717 (Fix malformed suggestion for repeated maybe unsized bounds)
- #128046 (Fix some `#[cfg_attr(not(doc), repr(..))]`)
- #128122 (Mark `missing_fragment_specifier` as `FutureReleaseErrorReportInDeps`)
- #128135 (std: use duplicate thread local state in tests)
- #128140 (Remove Unnecessary `.as_str()` Conversions)
r? `@ghost`
`@rustbot` modify labels: rollup53 files changed, 742 insertions(+), 335 deletions(-)
compiler/rustc_const_eval/src/check_consts/qualifs.rs+27-1| ... | ... | @@ -100,7 +100,33 @@ impl Qualif for HasMutInterior { |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | fn in_any_value_of_ty<'tcx>(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> bool { |
| 103 | !ty.is_freeze(cx.tcx, cx.param_env) | |
| 103 | // Avoid selecting for simple cases, such as builtin types. | |
| 104 | if ty.is_trivially_freeze() { | |
| 105 | return false; | |
| 106 | } | |
| 107 | ||
| 108 | // We do not use `ty.is_freeze` here, because that requires revealing opaque types, which | |
| 109 | // requires borrowck, which in turn will invoke mir_const_qualifs again, causing a cycle error. | |
| 110 | // Instead we invoke an obligation context manually, and provide the opaque type inference settings | |
| 111 | // that allow the trait solver to just error out instead of cycling. | |
| 112 | let freeze_def_id = cx.tcx.require_lang_item(LangItem::Freeze, Some(cx.body.span)); | |
| 113 | ||
| 114 | let obligation = Obligation::new( | |
| 115 | cx.tcx, | |
| 116 | ObligationCause::dummy_with_span(cx.body.span), | |
| 117 | cx.param_env, | |
| 118 | ty::TraitRef::new(cx.tcx, freeze_def_id, [ty::GenericArg::from(ty)]), | |
| 119 | ); | |
| 120 | ||
| 121 | let infcx = cx | |
| 122 | .tcx | |
| 123 | .infer_ctxt() | |
| 124 | .with_opaque_type_inference(cx.body.source.def_id().expect_local()) | |
| 125 | .build(); | |
| 126 | let ocx = ObligationCtxt::new(&infcx); | |
| 127 | ocx.register_obligation(obligation); | |
| 128 | let errors = ocx.select_all_or_error(); | |
| 129 | !errors.is_empty() | |
| 104 | 130 | } |
| 105 | 131 | |
| 106 | 132 | fn in_adt_inherently<'tcx>( |
compiler/rustc_hir/src/hir.rs+15-9| ... | ... | @@ -763,7 +763,7 @@ impl<'hir> Generics<'hir> { |
| 763 | 763 | ) |
| 764 | 764 | } |
| 765 | 765 | |
| 766 | fn span_for_predicate_removal(&self, pos: usize) -> Span { | |
| 766 | pub fn span_for_predicate_removal(&self, pos: usize) -> Span { | |
| 767 | 767 | let predicate = &self.predicates[pos]; |
| 768 | 768 | let span = predicate.span(); |
| 769 | 769 | |
| ... | ... | @@ -806,15 +806,21 @@ impl<'hir> Generics<'hir> { |
| 806 | 806 | return self.span_for_predicate_removal(predicate_pos); |
| 807 | 807 | } |
| 808 | 808 | |
| 809 | let span = bounds[bound_pos].span(); | |
| 810 | if bound_pos == 0 { | |
| 811 | // where T: ?Sized + Bar, Foo: Bar, | |
| 812 | // ^^^^^^^^^ | |
| 813 | span.to(bounds[1].span().shrink_to_lo()) | |
| 809 | let bound_span = bounds[bound_pos].span(); | |
| 810 | if bound_pos < bounds.len() - 1 { | |
| 811 | // If there's another bound after the current bound | |
| 812 | // include the following '+' e.g.: | |
| 813 | // | |
| 814 | // `T: Foo + CurrentBound + Bar` | |
| 815 | // ^^^^^^^^^^^^^^^ | |
| 816 | bound_span.to(bounds[bound_pos + 1].span().shrink_to_lo()) | |
| 814 | 817 | } else { |
| 815 | // where T: Bar + ?Sized, Foo: Bar, | |
| 816 | // ^^^^^^^^^ | |
| 817 | bounds[bound_pos - 1].span().shrink_to_hi().to(span) | |
| 818 | // If the current bound is the last bound | |
| 819 | // include the preceding '+' E.g.: | |
| 820 | // | |
| 821 | // `T: Foo + Bar + CurrentBound` | |
| 822 | // ^^^^^^^^^^^^^^^ | |
| 823 | bound_span.with_lo(bounds[bound_pos - 1].span().hi()) | |
| 818 | 824 | } |
| 819 | 825 | } |
| 820 | 826 | } |
compiler/rustc_hir_typeck/src/method/probe.rs+4-4| ... | ... | @@ -1846,7 +1846,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { |
| 1846 | 1846 | /// Determine if the associated item with the given DefId matches |
| 1847 | 1847 | /// the desired name via a doc alias. |
| 1848 | 1848 | fn matches_by_doc_alias(&self, def_id: DefId) -> bool { |
| 1849 | let Some(name) = self.method_name else { | |
| 1849 | let Some(method) = self.method_name else { | |
| 1850 | 1850 | return false; |
| 1851 | 1851 | }; |
| 1852 | 1852 | let Some(local_def_id) = def_id.as_local() else { |
| ... | ... | @@ -1863,7 +1863,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { |
| 1863 | 1863 | // #[rustc_confusables("foo", "bar"))] |
| 1864 | 1864 | for n in confusables { |
| 1865 | 1865 | if let Some(lit) = n.lit() |
| 1866 | && name.as_str() == lit.symbol.as_str() | |
| 1866 | && method.name == lit.symbol | |
| 1867 | 1867 | { |
| 1868 | 1868 | return true; |
| 1869 | 1869 | } |
| ... | ... | @@ -1883,14 +1883,14 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { |
| 1883 | 1883 | // #[doc(alias("foo", "bar"))] |
| 1884 | 1884 | for n in nested { |
| 1885 | 1885 | if let Some(lit) = n.lit() |
| 1886 | && name.as_str() == lit.symbol.as_str() | |
| 1886 | && method.name == lit.symbol | |
| 1887 | 1887 | { |
| 1888 | 1888 | return true; |
| 1889 | 1889 | } |
| 1890 | 1890 | } |
| 1891 | 1891 | } else if let Some(meta) = v.meta_item() |
| 1892 | 1892 | && let Some(lit) = meta.name_value_literal() |
| 1893 | && name.as_str() == lit.symbol.as_str() | |
| 1893 | && method.name == lit.symbol | |
| 1894 | 1894 | { |
| 1895 | 1895 | // #[doc(alias = "foo")] |
| 1896 | 1896 | return true; |
compiler/rustc_lint_defs/src/builtin.rs+1-1| ... | ... | @@ -1424,7 +1424,7 @@ declare_lint! { |
| 1424 | 1424 | Deny, |
| 1425 | 1425 | "detects missing fragment specifiers in unused `macro_rules!` patterns", |
| 1426 | 1426 | @future_incompatible = FutureIncompatibleInfo { |
| 1427 | reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps, | |
| 1427 | reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps, | |
| 1428 | 1428 | reference: "issue #40107 <https://github.com/rust-lang/rust/issues/40107>", |
| 1429 | 1429 | }; |
| 1430 | 1430 | } |
compiler/rustc_middle/src/ty/diagnostics.rs+49-20| ... | ... | @@ -188,31 +188,60 @@ fn suggest_changing_unsized_bound( |
| 188 | 188 | continue; |
| 189 | 189 | }; |
| 190 | 190 | |
| 191 | for (pos, bound) in predicate.bounds.iter().enumerate() { | |
| 192 | let hir::GenericBound::Trait(poly, hir::TraitBoundModifier::Maybe) = bound else { | |
| 193 | continue; | |
| 194 | }; | |
| 195 | if poly.trait_ref.trait_def_id() != def_id { | |
| 196 | continue; | |
| 197 | } | |
| 198 | if predicate.origin == PredicateOrigin::ImplTrait && predicate.bounds.len() == 1 { | |
| 199 | // For `impl ?Sized` with no other bounds, suggest `impl Sized` instead. | |
| 200 | let bound_span = bound.span(); | |
| 201 | if bound_span.can_be_used_for_suggestions() { | |
| 202 | let question_span = bound_span.with_hi(bound_span.lo() + BytePos(1)); | |
| 203 | suggestions.push(( | |
| 191 | let unsized_bounds = predicate | |
| 192 | .bounds | |
| 193 | .iter() | |
| 194 | .enumerate() | |
| 195 | .filter(|(_, bound)| { | |
| 196 | if let hir::GenericBound::Trait(poly, hir::TraitBoundModifier::Maybe) = bound | |
| 197 | && poly.trait_ref.trait_def_id() == def_id | |
| 198 | { | |
| 199 | true | |
| 200 | } else { | |
| 201 | false | |
| 202 | } | |
| 203 | }) | |
| 204 | .collect::<Vec<_>>(); | |
| 205 | ||
| 206 | if unsized_bounds.is_empty() { | |
| 207 | continue; | |
| 208 | } | |
| 209 | ||
| 210 | let mut push_suggestion = |sp, msg| suggestions.push((sp, String::new(), msg)); | |
| 211 | ||
| 212 | if predicate.bounds.len() == unsized_bounds.len() { | |
| 213 | // All the bounds are unsized bounds, e.g. | |
| 214 | // `T: ?Sized + ?Sized` or `_: impl ?Sized + ?Sized`, | |
| 215 | // so in this case: | |
| 216 | // - if it's an impl trait predicate suggest changing the | |
| 217 | // the first bound to sized and removing the rest | |
| 218 | // - Otherwise simply suggest removing the entire predicate | |
| 219 | if predicate.origin == PredicateOrigin::ImplTrait { | |
| 220 | let first_bound = unsized_bounds[0].1; | |
| 221 | let first_bound_span = first_bound.span(); | |
| 222 | if first_bound_span.can_be_used_for_suggestions() { | |
| 223 | let question_span = | |
| 224 | first_bound_span.with_hi(first_bound_span.lo() + BytePos(1)); | |
| 225 | push_suggestion( | |
| 204 | 226 | question_span, |
| 205 | String::new(), | |
| 206 | 227 | SuggestChangingConstraintsMessage::ReplaceMaybeUnsizedWithSized, |
| 207 | )); | |
| 228 | ); | |
| 229 | ||
| 230 | for (pos, _) in unsized_bounds.iter().skip(1) { | |
| 231 | let sp = generics.span_for_bound_removal(where_pos, *pos); | |
| 232 | push_suggestion(sp, SuggestChangingConstraintsMessage::RemoveMaybeUnsized); | |
| 233 | } | |
| 208 | 234 | } |
| 209 | 235 | } else { |
| 236 | let sp = generics.span_for_predicate_removal(where_pos); | |
| 237 | push_suggestion(sp, SuggestChangingConstraintsMessage::RemoveMaybeUnsized); | |
| 238 | } | |
| 239 | } else { | |
| 240 | // Some of the bounds are other than unsized. | |
| 241 | // So push separate removal suggestion for each unsized bound | |
| 242 | for (pos, _) in unsized_bounds { | |
| 210 | 243 | let sp = generics.span_for_bound_removal(where_pos, pos); |
| 211 | suggestions.push(( | |
| 212 | sp, | |
| 213 | String::new(), | |
| 214 | SuggestChangingConstraintsMessage::RemoveMaybeUnsized, | |
| 215 | )); | |
| 244 | push_suggestion(sp, SuggestChangingConstraintsMessage::RemoveMaybeUnsized); | |
| 216 | 245 | } |
| 217 | 246 | } |
| 218 | 247 | } |
compiler/rustc_middle/src/ty/util.rs+1-1| ... | ... | @@ -1268,7 +1268,7 @@ impl<'tcx> Ty<'tcx> { |
| 1268 | 1268 | /// |
| 1269 | 1269 | /// Returning true means the type is known to be `Freeze`. Returning |
| 1270 | 1270 | /// `false` means nothing -- could be `Freeze`, might not be. |
| 1271 | fn is_trivially_freeze(self) -> bool { | |
| 1271 | pub fn is_trivially_freeze(self) -> bool { | |
| 1272 | 1272 | match self.kind() { |
| 1273 | 1273 | ty::Int(_) |
| 1274 | 1274 | | ty::Uint(_) |
compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs+6-1| ... | ... | @@ -772,7 +772,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { |
| 772 | 772 | ); |
| 773 | 773 | } |
| 774 | 774 | |
| 775 | ty::Alias(ty::Opaque, _) => { | |
| 775 | ty::Alias(ty::Opaque, alias) => { | |
| 776 | 776 | if candidates.vec.iter().any(|c| matches!(c, ProjectionCandidate(_))) { |
| 777 | 777 | // We do not generate an auto impl candidate for `impl Trait`s which already |
| 778 | 778 | // reference our auto trait. |
| ... | ... | @@ -787,6 +787,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { |
| 787 | 787 | // We do not emit auto trait candidates for opaque types in coherence. |
| 788 | 788 | // Doing so can result in weird dependency cycles. |
| 789 | 789 | candidates.ambiguous = true; |
| 790 | } else if self.infcx.can_define_opaque_ty(alias.def_id) { | |
| 791 | // We do not emit auto trait candidates for opaque types in their defining scope, as | |
| 792 | // we need to know the hidden type first, which we can't reliably know within the defining | |
| 793 | // scope. | |
| 794 | candidates.ambiguous = true; | |
| 790 | 795 | } else { |
| 791 | 796 | candidates.vec.push(AutoImplCandidate) |
| 792 | 797 | } |
compiler/rustc_trait_selection/src/traits/select/mod.rs+11-7| ... | ... | @@ -2386,13 +2386,17 @@ impl<'tcx> SelectionContext<'_, 'tcx> { |
| 2386 | 2386 | } |
| 2387 | 2387 | |
| 2388 | 2388 | ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) => { |
| 2389 | // We can resolve the `impl Trait` to its concrete type, | |
| 2390 | // which enforces a DAG between the functions requiring | |
| 2391 | // the auto trait bounds in question. | |
| 2392 | match self.tcx().type_of_opaque(def_id) { | |
| 2393 | Ok(ty) => t.rebind(vec![ty.instantiate(self.tcx(), args)]), | |
| 2394 | Err(_) => { | |
| 2395 | return Err(SelectionError::OpaqueTypeAutoTraitLeakageUnknown(def_id)); | |
| 2389 | if self.infcx.can_define_opaque_ty(def_id) { | |
| 2390 | unreachable!() | |
| 2391 | } else { | |
| 2392 | // We can resolve the `impl Trait` to its concrete type, | |
| 2393 | // which enforces a DAG between the functions requiring | |
| 2394 | // the auto trait bounds in question. | |
| 2395 | match self.tcx().type_of_opaque(def_id) { | |
| 2396 | Ok(ty) => t.rebind(vec![ty.instantiate(self.tcx(), args)]), | |
| 2397 | Err(_) => { | |
| 2398 | return Err(SelectionError::OpaqueTypeAutoTraitLeakageUnknown(def_id)); | |
| 2399 | } | |
| 2396 | 2400 | } |
| 2397 | 2401 | } |
| 2398 | 2402 | } |
library/core/src/error.rs+1-1| ... | ... | @@ -506,7 +506,7 @@ where |
| 506 | 506 | /// ``` |
| 507 | 507 | /// |
| 508 | 508 | #[unstable(feature = "error_generic_member_access", issue = "99301")] |
| 509 | #[cfg_attr(not(doc), repr(transparent))] // work around https://github.com/rust-lang/rust/issues/90435 | |
| 509 | #[repr(transparent)] | |
| 510 | 510 | pub struct Request<'a>(Tagged<dyn Erased<'a> + 'a>); |
| 511 | 511 | |
| 512 | 512 | impl<'a> Request<'a> { |
library/core/src/ffi/c_str.rs+1-1| ... | ... | @@ -103,7 +103,7 @@ use crate::str; |
| 103 | 103 | // However, `CStr` layout is considered an implementation detail and must not be relied upon. We |
| 104 | 104 | // want `repr(transparent)` but we don't want it to show up in rustdoc, so we hide it under |
| 105 | 105 | // `cfg(doc)`. This is an ad-hoc implementation of attribute privacy. |
| 106 | #[cfg_attr(not(doc), repr(transparent))] | |
| 106 | #[repr(transparent)] | |
| 107 | 107 | #[allow(clippy::derived_hash_with_manual_eq)] |
| 108 | 108 | pub struct CStr { |
| 109 | 109 | // FIXME: this should not be represented with a DST slice but rather with |
library/core/src/ffi/mod.rs+1-1| ... | ... | @@ -191,7 +191,7 @@ mod c_long_definition { |
| 191 | 191 | // be UB. |
| 192 | 192 | #[doc = include_str!("c_void.md")] |
| 193 | 193 | #[lang = "c_void"] |
| 194 | #[cfg_attr(not(doc), repr(u8))] // work around https://github.com/rust-lang/rust/issues/90435 | |
| 194 | #[cfg_attr(not(doc), repr(u8))] // An implementation detail we don't want to show up in rustdoc | |
| 195 | 195 | #[stable(feature = "core_c_void", since = "1.30.0")] |
| 196 | 196 | pub enum c_void { |
| 197 | 197 | #[unstable( |
library/core/src/ffi/va_list.rs+2-2| ... | ... | @@ -23,7 +23,7 @@ use crate::ops::{Deref, DerefMut}; |
| 23 | 23 | target_os = "uefi", |
| 24 | 24 | windows, |
| 25 | 25 | ))] |
| 26 | #[cfg_attr(not(doc), repr(transparent))] // work around https://github.com/rust-lang/rust/issues/90435 | |
| 26 | #[repr(transparent)] | |
| 27 | 27 | #[lang = "va_list"] |
| 28 | 28 | pub struct VaListImpl<'f> { |
| 29 | 29 | ptr: *mut c_void, |
| ... | ... | @@ -115,7 +115,7 @@ pub struct VaListImpl<'f> { |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /// A wrapper for a `va_list` |
| 118 | #[cfg_attr(not(doc), repr(transparent))] // work around https://github.com/rust-lang/rust/issues/90435 | |
| 118 | #[repr(transparent)] | |
| 119 | 119 | #[derive(Debug)] |
| 120 | 120 | pub struct VaList<'a, 'f: 'a> { |
| 121 | 121 | #[cfg(any( |
library/core/src/num/uint_macros.rs+61| ... | ... | @@ -765,6 +765,67 @@ macro_rules! uint_impl { |
| 765 | 765 | } |
| 766 | 766 | } |
| 767 | 767 | |
| 768 | #[doc = concat!( | |
| 769 | "Checked integer subtraction. Computes `self - rhs` and checks if the result fits into an [`", | |
| 770 | stringify!($SignedT), "`], returning `None` if overflow occurred." | |
| 771 | )] | |
| 772 | /// | |
| 773 | /// # Examples | |
| 774 | /// | |
| 775 | /// Basic usage: | |
| 776 | /// | |
| 777 | /// ``` | |
| 778 | /// #![feature(unsigned_signed_diff)] | |
| 779 | #[doc = concat!("assert_eq!(10", stringify!($SelfT), ".checked_signed_diff(2), Some(8));")] | |
| 780 | #[doc = concat!("assert_eq!(2", stringify!($SelfT), ".checked_signed_diff(10), Some(-8));")] | |
| 781 | #[doc = concat!( | |
| 782 | "assert_eq!(", | |
| 783 | stringify!($SelfT), | |
| 784 | "::MAX.checked_signed_diff(", | |
| 785 | stringify!($SignedT), | |
| 786 | "::MAX as ", | |
| 787 | stringify!($SelfT), | |
| 788 | "), None);" | |
| 789 | )] | |
| 790 | #[doc = concat!( | |
| 791 | "assert_eq!((", | |
| 792 | stringify!($SignedT), | |
| 793 | "::MAX as ", | |
| 794 | stringify!($SelfT), | |
| 795 | ").checked_signed_diff(", | |
| 796 | stringify!($SelfT), | |
| 797 | "::MAX), Some(", | |
| 798 | stringify!($SignedT), | |
| 799 | "::MIN));" | |
| 800 | )] | |
| 801 | #[doc = concat!( | |
| 802 | "assert_eq!((", | |
| 803 | stringify!($SignedT), | |
| 804 | "::MAX as ", | |
| 805 | stringify!($SelfT), | |
| 806 | " + 1).checked_signed_diff(0), None);" | |
| 807 | )] | |
| 808 | #[doc = concat!( | |
| 809 | "assert_eq!(", | |
| 810 | stringify!($SelfT), | |
| 811 | "::MAX.checked_signed_diff(", | |
| 812 | stringify!($SelfT), | |
| 813 | "::MAX), Some(0));" | |
| 814 | )] | |
| 815 | /// ``` | |
| 816 | #[unstable(feature = "unsigned_signed_diff", issue = "126041")] | |
| 817 | #[inline] | |
| 818 | pub const fn checked_signed_diff(self, rhs: Self) -> Option<$SignedT> { | |
| 819 | let res = self.wrapping_sub(rhs) as $SignedT; | |
| 820 | let overflow = (self >= rhs) == (res < 0); | |
| 821 | ||
| 822 | if !overflow { | |
| 823 | Some(res) | |
| 824 | } else { | |
| 825 | None | |
| 826 | } | |
| 827 | } | |
| 828 | ||
| 768 | 829 | /// Checked integer multiplication. Computes `self * rhs`, returning |
| 769 | 830 | /// `None` if overflow occurred. |
| 770 | 831 | /// |
library/core/src/task/wake.rs+2-2| ... | ... | @@ -428,7 +428,7 @@ impl<'a> ContextBuilder<'a> { |
| 428 | 428 | /// [`Future::poll()`]: core::future::Future::poll |
| 429 | 429 | /// [`Poll::Pending`]: core::task::Poll::Pending |
| 430 | 430 | /// [`Wake`]: ../../alloc/task/trait.Wake.html |
| 431 | #[cfg_attr(not(doc), repr(transparent))] // work around https://github.com/rust-lang/rust/issues/66401 | |
| 431 | #[repr(transparent)] | |
| 432 | 432 | #[stable(feature = "futures_api", since = "1.36.0")] |
| 433 | 433 | pub struct Waker { |
| 434 | 434 | waker: RawWaker, |
| ... | ... | @@ -692,7 +692,7 @@ impl fmt::Debug for Waker { |
| 692 | 692 | /// [`Poll::Pending`]: core::task::Poll::Pending |
| 693 | 693 | /// [`local_waker`]: core::task::Context::local_waker |
| 694 | 694 | #[unstable(feature = "local_waker", issue = "118959")] |
| 695 | #[cfg_attr(not(doc), repr(transparent))] // work around https://github.com/rust-lang/rust/issues/66401 | |
| 695 | #[repr(transparent)] | |
| 696 | 696 | pub struct LocalWaker { |
| 697 | 697 | waker: RawWaker, |
| 698 | 698 | } |
library/std/src/ffi/os_str.rs+2-4| ... | ... | @@ -115,10 +115,8 @@ impl crate::sealed::Sealed for OsString {} |
| 115 | 115 | #[stable(feature = "rust1", since = "1.0.0")] |
| 116 | 116 | // `OsStr::from_inner` current implementation relies |
| 117 | 117 | // on `OsStr` being layout-compatible with `Slice`. |
| 118 | // However, `OsStr` layout is considered an implementation detail and must not be relied upon. We | |
| 119 | // want `repr(transparent)` but we don't want it to show up in rustdoc, so we hide it under | |
| 120 | // `cfg(doc)`. This is an ad-hoc implementation of attribute privacy. | |
| 121 | #[cfg_attr(not(doc), repr(transparent))] | |
| 118 | // However, `OsStr` layout is considered an implementation detail and must not be relied upon. | |
| 119 | #[repr(transparent)] | |
| 122 | 120 | pub struct OsStr { |
| 123 | 121 | inner: Slice, |
| 124 | 122 | } |
library/std/src/fs.rs+2-7| ... | ... | @@ -2400,13 +2400,8 @@ pub fn create_dir<P: AsRef<Path>>(path: P) -> io::Result<()> { |
| 2400 | 2400 | /// |
| 2401 | 2401 | /// # Errors |
| 2402 | 2402 | /// |
| 2403 | /// This function will return an error in the following situations, but is not | |
| 2404 | /// limited to just these cases: | |
| 2405 | /// | |
| 2406 | /// * If any directory in the path specified by `path` | |
| 2407 | /// does not already exist and it could not be created otherwise. The specific | |
| 2408 | /// error conditions for when a directory is being created (after it is | |
| 2409 | /// determined to not exist) are outlined by [`fs::create_dir`]. | |
| 2403 | /// The function will return an error if any directory specified in path does not exist and | |
| 2404 | /// could not be created. There may be other error conditions; see [`fs::create_dir`] for specifics. | |
| 2410 | 2405 | /// |
| 2411 | 2406 | /// Notable exception is made for situations where any of the directories |
| 2412 | 2407 | /// specified in the `path` could not be created as it was being created concurrently. |
library/std/src/path.rs+2-4| ... | ... | @@ -2079,10 +2079,8 @@ impl AsRef<OsStr> for PathBuf { |
| 2079 | 2079 | #[stable(feature = "rust1", since = "1.0.0")] |
| 2080 | 2080 | // `Path::new` current implementation relies |
| 2081 | 2081 | // on `Path` being layout-compatible with `OsStr`. |
| 2082 | // However, `Path` layout is considered an implementation detail and must not be relied upon. We | |
| 2083 | // want `repr(transparent)` but we don't want it to show up in rustdoc, so we hide it under | |
| 2084 | // `cfg(doc)`. This is an ad-hoc implementation of attribute privacy. | |
| 2085 | #[cfg_attr(not(doc), repr(transparent))] | |
| 2082 | // However, `Path` layout is considered an implementation detail and must not be relied upon. | |
| 2083 | #[repr(transparent)] | |
| 2086 | 2084 | pub struct Path { |
| 2087 | 2085 | inner: OsStr, |
| 2088 | 2086 | } |
library/std/src/thread/mod.rs+8-16| ... | ... | @@ -192,22 +192,14 @@ pub use scoped::{scope, Scope, ScopedJoinHandle}; |
| 192 | 192 | #[macro_use] |
| 193 | 193 | mod local; |
| 194 | 194 | |
| 195 | cfg_if::cfg_if! { | |
| 196 | if #[cfg(test)] { | |
| 197 | // Avoid duplicating the global state associated with thread-locals between this crate and | |
| 198 | // realstd. Miri relies on this. | |
| 199 | pub use realstd::thread::{local_impl, AccessError, LocalKey}; | |
| 200 | } else { | |
| 201 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 202 | pub use self::local::{AccessError, LocalKey}; | |
| 203 | ||
| 204 | // Implementation details used by the thread_local!{} macro. | |
| 205 | #[doc(hidden)] | |
| 206 | #[unstable(feature = "thread_local_internals", issue = "none")] | |
| 207 | pub mod local_impl { | |
| 208 | pub use crate::sys::thread_local::*; | |
| 209 | } | |
| 210 | } | |
| 195 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 196 | pub use self::local::{AccessError, LocalKey}; | |
| 197 | ||
| 198 | // Implementation details used by the thread_local!{} macro. | |
| 199 | #[doc(hidden)] | |
| 200 | #[unstable(feature = "thread_local_internals", issue = "none")] | |
| 201 | pub mod local_impl { | |
| 202 | pub use crate::sys::thread_local::*; | |
| 211 | 203 | } |
| 212 | 204 | |
| 213 | 205 | //////////////////////////////////////////////////////////////////////////////// |
tests/ui/const-generics/opaque_types.stderr-2| ... | ... | @@ -122,8 +122,6 @@ note: ...which requires const checking `main::{constant#0}`... |
| 122 | 122 | | |
| 123 | 123 | LL | foo::<42>(); |
| 124 | 124 | | ^^ |
| 125 | = note: ...which requires computing whether `Foo` is freeze... | |
| 126 | = note: ...which requires evaluating trait selection obligation `Foo: core::marker::Freeze`... | |
| 127 | 125 | = note: ...which again requires computing type of opaque `Foo::{opaque#0}`, completing the cycle |
| 128 | 126 | note: cycle used when computing type of `Foo::{opaque#0}` |
| 129 | 127 | --> $DIR/opaque_types.rs:3:12 |
tests/ui/consts/const-fn-cycle.rs+2-1| ... | ... | @@ -7,6 +7,8 @@ |
| 7 | 7 | /// to end up revealing opaque types (the RPIT in `many`'s return type), |
| 8 | 8 | /// which can quickly lead to cycles. |
| 9 | 9 | |
| 10 | //@ check-pass | |
| 11 | ||
| 10 | 12 | pub struct Parser<H>(H); |
| 11 | 13 | |
| 12 | 14 | impl<H, T> Parser<H> |
| ... | ... | @@ -18,7 +20,6 @@ where |
| 18 | 20 | } |
| 19 | 21 | |
| 20 | 22 | pub const fn many<'s>(&'s self) -> Parser<impl for<'a> Fn(&'a str) -> Vec<T> + 's> { |
| 21 | //~^ ERROR: cycle detected | |
| 22 | 23 | Parser::new(|_| unimplemented!()) |
| 23 | 24 | } |
| 24 | 25 | } |
tests/ui/consts/const-fn-cycle.stderr deleted-34| ... | ... | @@ -1,34 +0,0 @@ |
| 1 | error[E0391]: cycle detected when computing type of opaque `<impl at $DIR/const-fn-cycle.rs:12:1: 14:33>::many::{opaque#0}` | |
| 2 | --> $DIR/const-fn-cycle.rs:20:47 | |
| 3 | | | |
| 4 | LL | pub const fn many<'s>(&'s self) -> Parser<impl for<'a> Fn(&'a str) -> Vec<T> + 's> { | |
| 5 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 6 | | | |
| 7 | note: ...which requires borrow-checking `<impl at $DIR/const-fn-cycle.rs:12:1: 14:33>::many`... | |
| 8 | --> $DIR/const-fn-cycle.rs:20:5 | |
| 9 | | | |
| 10 | LL | pub const fn many<'s>(&'s self) -> Parser<impl for<'a> Fn(&'a str) -> Vec<T> + 's> { | |
| 11 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 12 | note: ...which requires promoting constants in MIR for `<impl at $DIR/const-fn-cycle.rs:12:1: 14:33>::many`... | |
| 13 | --> $DIR/const-fn-cycle.rs:20:5 | |
| 14 | | | |
| 15 | LL | pub const fn many<'s>(&'s self) -> Parser<impl for<'a> Fn(&'a str) -> Vec<T> + 's> { | |
| 16 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 17 | note: ...which requires const checking `<impl at $DIR/const-fn-cycle.rs:12:1: 14:33>::many`... | |
| 18 | --> $DIR/const-fn-cycle.rs:20:5 | |
| 19 | | | |
| 20 | LL | pub const fn many<'s>(&'s self) -> Parser<impl for<'a> Fn(&'a str) -> Vec<T> + 's> { | |
| 21 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 22 | = note: ...which requires computing whether `Parser<<impl at $DIR/const-fn-cycle.rs:12:1: 14:33>::many::{opaque#0}>` is freeze... | |
| 23 | = note: ...which requires evaluating trait selection obligation `Parser<<impl at $DIR/const-fn-cycle.rs:12:1: 14:33>::many::{opaque#0}>: core::marker::Freeze`... | |
| 24 | = note: ...which again requires computing type of opaque `<impl at $DIR/const-fn-cycle.rs:12:1: 14:33>::many::{opaque#0}`, completing the cycle | |
| 25 | note: cycle used when computing type of `<impl at $DIR/const-fn-cycle.rs:12:1: 14:33>::many::{opaque#0}` | |
| 26 | --> $DIR/const-fn-cycle.rs:20:47 | |
| 27 | | | |
| 28 | LL | pub const fn many<'s>(&'s self) -> Parser<impl for<'a> Fn(&'a str) -> Vec<T> + 's> { | |
| 29 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 30 | = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information | |
| 31 | ||
| 32 | error: aborting due to 1 previous error | |
| 33 | ||
| 34 | For more information about this error, try `rustc --explain E0391`. |
tests/ui/consts/const-promoted-opaque.atomic.stderr+7-38| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | error[E0658]: cannot borrow here, since the borrowed element may contain interior mutability |
| 2 | --> $DIR/const-promoted-opaque.rs:29:25 | |
| 2 | --> $DIR/const-promoted-opaque.rs:28:25 | |
| 3 | 3 | | |
| 4 | 4 | LL | let _: &'static _ = &FOO; |
| 5 | 5 | | ^^^^ |
| ... | ... | @@ -9,7 +9,7 @@ LL | let _: &'static _ = &FOO; |
| 9 | 9 | = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date |
| 10 | 10 | |
| 11 | 11 | error[E0493]: destructor of `helper::Foo` cannot be evaluated at compile-time |
| 12 | --> $DIR/const-promoted-opaque.rs:29:26 | |
| 12 | --> $DIR/const-promoted-opaque.rs:28:26 | |
| 13 | 13 | | |
| 14 | 14 | LL | let _: &'static _ = &FOO; |
| 15 | 15 | | ^^^ the destructor for this type cannot be evaluated in constants |
| ... | ... | @@ -18,13 +18,13 @@ LL | }; |
| 18 | 18 | | - value is dropped here |
| 19 | 19 | |
| 20 | 20 | error[E0492]: constants cannot refer to interior mutable data |
| 21 | --> $DIR/const-promoted-opaque.rs:34:19 | |
| 21 | --> $DIR/const-promoted-opaque.rs:33:19 | |
| 22 | 22 | | |
| 23 | 23 | LL | const BAZ: &Foo = &FOO; |
| 24 | 24 | | ^^^^ this borrow of an interior mutable value may end up in the final value |
| 25 | 25 | |
| 26 | 26 | error[E0716]: temporary value dropped while borrowed |
| 27 | --> $DIR/const-promoted-opaque.rs:38:26 | |
| 27 | --> $DIR/const-promoted-opaque.rs:37:26 | |
| 28 | 28 | | |
| 29 | 29 | LL | let _: &'static _ = &FOO; |
| 30 | 30 | | ---------- ^^^ creates a temporary value which is freed while still in use |
| ... | ... | @@ -34,38 +34,7 @@ LL | |
| 34 | 34 | LL | } |
| 35 | 35 | | - temporary value is freed at the end of this statement |
| 36 | 36 | |
| 37 | error[E0391]: cycle detected when computing type of opaque `helper::Foo::{opaque#0}` | |
| 38 | --> $DIR/const-promoted-opaque.rs:14:20 | |
| 39 | | | |
| 40 | LL | pub type Foo = impl Sized; | |
| 41 | | ^^^^^^^^^^ | |
| 42 | | | |
| 43 | note: ...which requires borrow-checking `helper::FOO`... | |
| 44 | --> $DIR/const-promoted-opaque.rs:21:5 | |
| 45 | | | |
| 46 | LL | pub const FOO: Foo = std::sync::atomic::AtomicU8::new(42); | |
| 47 | | ^^^^^^^^^^^^^^^^^^ | |
| 48 | note: ...which requires promoting constants in MIR for `helper::FOO`... | |
| 49 | --> $DIR/const-promoted-opaque.rs:21:5 | |
| 50 | | | |
| 51 | LL | pub const FOO: Foo = std::sync::atomic::AtomicU8::new(42); | |
| 52 | | ^^^^^^^^^^^^^^^^^^ | |
| 53 | note: ...which requires const checking `helper::FOO`... | |
| 54 | --> $DIR/const-promoted-opaque.rs:21:5 | |
| 55 | | | |
| 56 | LL | pub const FOO: Foo = std::sync::atomic::AtomicU8::new(42); | |
| 57 | | ^^^^^^^^^^^^^^^^^^ | |
| 58 | = note: ...which requires computing whether `helper::Foo` is freeze... | |
| 59 | = note: ...which requires evaluating trait selection obligation `helper::Foo: core::marker::Freeze`... | |
| 60 | = note: ...which again requires computing type of opaque `helper::Foo::{opaque#0}`, completing the cycle | |
| 61 | note: cycle used when computing type of `helper::Foo::{opaque#0}` | |
| 62 | --> $DIR/const-promoted-opaque.rs:14:20 | |
| 63 | | | |
| 64 | LL | pub type Foo = impl Sized; | |
| 65 | | ^^^^^^^^^^ | |
| 66 | = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information | |
| 67 | ||
| 68 | error: aborting due to 5 previous errors | |
| 37 | error: aborting due to 4 previous errors | |
| 69 | 38 | |
| 70 | Some errors have detailed explanations: E0391, E0492, E0493, E0658, E0716. | |
| 71 | For more information about an error, try `rustc --explain E0391`. | |
| 39 | Some errors have detailed explanations: E0492, E0493, E0658, E0716. | |
| 40 | For more information about an error, try `rustc --explain E0492`. |
tests/ui/consts/const-promoted-opaque.rs+2-3| ... | ... | @@ -12,7 +12,6 @@ |
| 12 | 12 | |
| 13 | 13 | mod helper { |
| 14 | 14 | pub type Foo = impl Sized; |
| 15 | //[string,atomic]~^ ERROR cycle detected | |
| 16 | 15 | |
| 17 | 16 | #[cfg(string)] |
| 18 | 17 | pub const FOO: Foo = String::new(); |
| ... | ... | @@ -28,11 +27,11 @@ use helper::*; |
| 28 | 27 | const BAR: () = { |
| 29 | 28 | let _: &'static _ = &FOO; |
| 30 | 29 | //[string,atomic]~^ ERROR: destructor of `helper::Foo` cannot be evaluated at compile-time |
| 31 | //[string,atomic]~| ERROR: cannot borrow here | |
| 30 | //[atomic]~| ERROR: cannot borrow here | |
| 32 | 31 | }; |
| 33 | 32 | |
| 34 | 33 | const BAZ: &Foo = &FOO; |
| 35 | //[string,atomic]~^ ERROR: constants cannot refer to interior mutable data | |
| 34 | //[atomic]~^ ERROR: constants cannot refer to interior mutable data | |
| 36 | 35 | |
| 37 | 36 | fn main() { |
| 38 | 37 | let _: &'static _ = &FOO; |
tests/ui/consts/const-promoted-opaque.string.stderr+5-52| ... | ... | @@ -1,15 +1,5 @@ |
| 1 | error[E0658]: cannot borrow here, since the borrowed element may contain interior mutability | |
| 2 | --> $DIR/const-promoted-opaque.rs:29:25 | |
| 3 | | | |
| 4 | LL | let _: &'static _ = &FOO; | |
| 5 | | ^^^^ | |
| 6 | | | |
| 7 | = note: see issue #80384 <https://github.com/rust-lang/rust/issues/80384> for more information | |
| 8 | = help: add `#![feature(const_refs_to_cell)]` to the crate attributes to enable | |
| 9 | = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | |
| 10 | ||
| 11 | 1 | error[E0493]: destructor of `helper::Foo` cannot be evaluated at compile-time |
| 12 | --> $DIR/const-promoted-opaque.rs:29:26 | |
| 2 | --> $DIR/const-promoted-opaque.rs:28:26 | |
| 13 | 3 | | |
| 14 | 4 | LL | let _: &'static _ = &FOO; |
| 15 | 5 | | ^^^ the destructor for this type cannot be evaluated in constants |
| ... | ... | @@ -17,14 +7,8 @@ LL | let _: &'static _ = &FOO; |
| 17 | 7 | LL | }; |
| 18 | 8 | | - value is dropped here |
| 19 | 9 | |
| 20 | error[E0492]: constants cannot refer to interior mutable data | |
| 21 | --> $DIR/const-promoted-opaque.rs:34:19 | |
| 22 | | | |
| 23 | LL | const BAZ: &Foo = &FOO; | |
| 24 | | ^^^^ this borrow of an interior mutable value may end up in the final value | |
| 25 | ||
| 26 | 10 | error[E0716]: temporary value dropped while borrowed |
| 27 | --> $DIR/const-promoted-opaque.rs:38:26 | |
| 11 | --> $DIR/const-promoted-opaque.rs:37:26 | |
| 28 | 12 | | |
| 29 | 13 | LL | let _: &'static _ = &FOO; |
| 30 | 14 | | ---------- ^^^ creates a temporary value which is freed while still in use |
| ... | ... | @@ -34,38 +18,7 @@ LL | |
| 34 | 18 | LL | } |
| 35 | 19 | | - temporary value is freed at the end of this statement |
| 36 | 20 | |
| 37 | error[E0391]: cycle detected when computing type of opaque `helper::Foo::{opaque#0}` | |
| 38 | --> $DIR/const-promoted-opaque.rs:14:20 | |
| 39 | | | |
| 40 | LL | pub type Foo = impl Sized; | |
| 41 | | ^^^^^^^^^^ | |
| 42 | | | |
| 43 | note: ...which requires borrow-checking `helper::FOO`... | |
| 44 | --> $DIR/const-promoted-opaque.rs:18:5 | |
| 45 | | | |
| 46 | LL | pub const FOO: Foo = String::new(); | |
| 47 | | ^^^^^^^^^^^^^^^^^^ | |
| 48 | note: ...which requires promoting constants in MIR for `helper::FOO`... | |
| 49 | --> $DIR/const-promoted-opaque.rs:18:5 | |
| 50 | | | |
| 51 | LL | pub const FOO: Foo = String::new(); | |
| 52 | | ^^^^^^^^^^^^^^^^^^ | |
| 53 | note: ...which requires const checking `helper::FOO`... | |
| 54 | --> $DIR/const-promoted-opaque.rs:18:5 | |
| 55 | | | |
| 56 | LL | pub const FOO: Foo = String::new(); | |
| 57 | | ^^^^^^^^^^^^^^^^^^ | |
| 58 | = note: ...which requires computing whether `helper::Foo` is freeze... | |
| 59 | = note: ...which requires evaluating trait selection obligation `helper::Foo: core::marker::Freeze`... | |
| 60 | = note: ...which again requires computing type of opaque `helper::Foo::{opaque#0}`, completing the cycle | |
| 61 | note: cycle used when computing type of `helper::Foo::{opaque#0}` | |
| 62 | --> $DIR/const-promoted-opaque.rs:14:20 | |
| 63 | | | |
| 64 | LL | pub type Foo = impl Sized; | |
| 65 | | ^^^^^^^^^^ | |
| 66 | = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information | |
| 67 | ||
| 68 | error: aborting due to 5 previous errors | |
| 21 | error: aborting due to 2 previous errors | |
| 69 | 22 | |
| 70 | Some errors have detailed explanations: E0391, E0492, E0493, E0658, E0716. | |
| 71 | For more information about an error, try `rustc --explain E0391`. | |
| 23 | Some errors have detailed explanations: E0493, E0716. | |
| 24 | For more information about an error, try `rustc --explain E0493`. |
tests/ui/impl-trait/auto-trait-selection-freeze.next.stderr created+22| ... | ... | @@ -0,0 +1,22 @@ |
| 1 | error[E0283]: type annotations needed | |
| 2 | --> $DIR/auto-trait-selection-freeze.rs:19:16 | |
| 3 | | | |
| 4 | LL | if false { is_trait(foo()) } else { Default::default() } | |
| 5 | | ^^^^^^^^ ----- type must be known at this point | |
| 6 | | | | |
| 7 | | cannot infer type of the type parameter `T` declared on the function `is_trait` | |
| 8 | | | |
| 9 | = note: cannot satisfy `_: Trait<_>` | |
| 10 | note: required by a bound in `is_trait` | |
| 11 | --> $DIR/auto-trait-selection-freeze.rs:11:16 | |
| 12 | | | |
| 13 | LL | fn is_trait<T: Trait<U>, U: Default>(_: T) -> U { | |
| 14 | | ^^^^^^^^ required by this bound in `is_trait` | |
| 15 | help: consider specifying the generic arguments | |
| 16 | | | |
| 17 | LL | if false { is_trait::<T, U>(foo()) } else { Default::default() } | |
| 18 | | ++++++++ | |
| 19 | ||
| 20 | error: aborting due to 1 previous error | |
| 21 | ||
| 22 | For more information about this error, try `rustc --explain E0283`. |
tests/ui/impl-trait/auto-trait-selection-freeze.old.stderr created+26| ... | ... | @@ -0,0 +1,26 @@ |
| 1 | error[E0283]: type annotations needed | |
| 2 | --> $DIR/auto-trait-selection-freeze.rs:19:16 | |
| 3 | | | |
| 4 | LL | if false { is_trait(foo()) } else { Default::default() } | |
| 5 | | ^^^^^^^^ cannot infer type of the type parameter `U` declared on the function `is_trait` | |
| 6 | | | |
| 7 | note: multiple `impl`s satisfying `impl Sized: Trait<_>` found | |
| 8 | --> $DIR/auto-trait-selection-freeze.rs:16:1 | |
| 9 | | | |
| 10 | LL | impl<T: Freeze> Trait<u32> for T {} | |
| 11 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 12 | LL | impl<T> Trait<i32> for T {} | |
| 13 | | ^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 14 | note: required by a bound in `is_trait` | |
| 15 | --> $DIR/auto-trait-selection-freeze.rs:11:16 | |
| 16 | | | |
| 17 | LL | fn is_trait<T: Trait<U>, U: Default>(_: T) -> U { | |
| 18 | | ^^^^^^^^ required by this bound in `is_trait` | |
| 19 | help: consider specifying the generic arguments | |
| 20 | | | |
| 21 | LL | if false { is_trait::<_, U>(foo()) } else { Default::default() } | |
| 22 | | ++++++++ | |
| 23 | ||
| 24 | error: aborting due to 1 previous error | |
| 25 | ||
| 26 | For more information about this error, try `rustc --explain E0283`. |
tests/ui/impl-trait/auto-trait-selection-freeze.rs created+23| ... | ... | @@ -0,0 +1,23 @@ |
| 1 | //! This test shows how we fail selection in a way that can influence | |
| 2 | //! selection in a code path that succeeds. | |
| 3 | ||
| 4 | //@ revisions: next old | |
| 5 | //@[next] compile-flags: -Znext-solver | |
| 6 | ||
| 7 | #![feature(freeze)] | |
| 8 | ||
| 9 | use std::marker::Freeze; | |
| 10 | ||
| 11 | fn is_trait<T: Trait<U>, U: Default>(_: T) -> U { | |
| 12 | Default::default() | |
| 13 | } | |
| 14 | ||
| 15 | trait Trait<T> {} | |
| 16 | impl<T: Freeze> Trait<u32> for T {} | |
| 17 | impl<T> Trait<i32> for T {} | |
| 18 | fn foo() -> impl Sized { | |
| 19 | if false { is_trait(foo()) } else { Default::default() } | |
| 20 | //~^ ERROR: type annotations needed | |
| 21 | } | |
| 22 | ||
| 23 | fn main() {} |
tests/ui/impl-trait/auto-trait-selection.next.stderr created+22| ... | ... | @@ -0,0 +1,22 @@ |
| 1 | error[E0283]: type annotations needed | |
| 2 | --> $DIR/auto-trait-selection.rs:15:16 | |
| 3 | | | |
| 4 | LL | if false { is_trait(foo()) } else { Default::default() } | |
| 5 | | ^^^^^^^^ ----- type must be known at this point | |
| 6 | | | | |
| 7 | | cannot infer type of the type parameter `T` declared on the function `is_trait` | |
| 8 | | | |
| 9 | = note: cannot satisfy `_: Trait<_>` | |
| 10 | note: required by a bound in `is_trait` | |
| 11 | --> $DIR/auto-trait-selection.rs:7:16 | |
| 12 | | | |
| 13 | LL | fn is_trait<T: Trait<U>, U: Default>(_: T) -> U { | |
| 14 | | ^^^^^^^^ required by this bound in `is_trait` | |
| 15 | help: consider specifying the generic arguments | |
| 16 | | | |
| 17 | LL | if false { is_trait::<T, U>(foo()) } else { Default::default() } | |
| 18 | | ++++++++ | |
| 19 | ||
| 20 | error: aborting due to 1 previous error | |
| 21 | ||
| 22 | For more information about this error, try `rustc --explain E0283`. |
tests/ui/impl-trait/auto-trait-selection.old.stderr created+26| ... | ... | @@ -0,0 +1,26 @@ |
| 1 | error[E0283]: type annotations needed | |
| 2 | --> $DIR/auto-trait-selection.rs:15:16 | |
| 3 | | | |
| 4 | LL | if false { is_trait(foo()) } else { Default::default() } | |
| 5 | | ^^^^^^^^ cannot infer type of the type parameter `U` declared on the function `is_trait` | |
| 6 | | | |
| 7 | note: multiple `impl`s satisfying `impl Sized: Trait<_>` found | |
| 8 | --> $DIR/auto-trait-selection.rs:12:1 | |
| 9 | | | |
| 10 | LL | impl<T: Send> Trait<u32> for T {} | |
| 11 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 12 | LL | impl<T> Trait<i32> for T {} | |
| 13 | | ^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 14 | note: required by a bound in `is_trait` | |
| 15 | --> $DIR/auto-trait-selection.rs:7:16 | |
| 16 | | | |
| 17 | LL | fn is_trait<T: Trait<U>, U: Default>(_: T) -> U { | |
| 18 | | ^^^^^^^^ required by this bound in `is_trait` | |
| 19 | help: consider specifying the generic arguments | |
| 20 | | | |
| 21 | LL | if false { is_trait::<_, U>(foo()) } else { Default::default() } | |
| 22 | | ++++++++ | |
| 23 | ||
| 24 | error: aborting due to 1 previous error | |
| 25 | ||
| 26 | For more information about this error, try `rustc --explain E0283`. |
tests/ui/impl-trait/auto-trait-selection.rs created+19| ... | ... | @@ -0,0 +1,19 @@ |
| 1 | //! This test shows how we fail selection in a way that can influence | |
| 2 | //! selection in a code path that succeeds. | |
| 3 | ||
| 4 | //@ revisions: next old | |
| 5 | //@[next] compile-flags: -Znext-solver | |
| 6 | ||
| 7 | fn is_trait<T: Trait<U>, U: Default>(_: T) -> U { | |
| 8 | Default::default() | |
| 9 | } | |
| 10 | ||
| 11 | trait Trait<T> {} | |
| 12 | impl<T: Send> Trait<u32> for T {} | |
| 13 | impl<T> Trait<i32> for T {} | |
| 14 | fn foo() -> impl Sized { | |
| 15 | if false { is_trait(foo()) } else { Default::default() } | |
| 16 | //~^ ERROR: type annotations needed | |
| 17 | } | |
| 18 | ||
| 19 | fn main() {} |
tests/ui/impl-trait/call_method_on_inherent_impl_ref.current.stderr+3-24| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | error[E0599]: no method named `my_debug` found for opaque type `impl Debug` in the current scope |
| 2 | --> $DIR/call_method_on_inherent_impl_ref.rs:20:11 | |
| 2 | --> $DIR/call_method_on_inherent_impl_ref.rs:19:11 | |
| 3 | 3 | | |
| 4 | 4 | LL | fn my_debug(&self); |
| 5 | 5 | | -------- the method is available for `&impl Debug` here |
| ... | ... | @@ -14,27 +14,6 @@ note: `MyDebug` defines an item `my_debug`, perhaps you need to implement it |
| 14 | 14 | LL | trait MyDebug { |
| 15 | 15 | | ^^^^^^^^^^^^^ |
| 16 | 16 | |
| 17 | error[E0391]: cycle detected when computing type of opaque `my_foo::{opaque#0}` | |
| 18 | --> $DIR/call_method_on_inherent_impl_ref.rs:15:16 | |
| 19 | | | |
| 20 | LL | fn my_foo() -> impl std::fmt::Debug { | |
| 21 | | ^^^^^^^^^^^^^^^^^^^^ | |
| 22 | | | |
| 23 | note: ...which requires type-checking `my_foo`... | |
| 24 | --> $DIR/call_method_on_inherent_impl_ref.rs:20:9 | |
| 25 | | | |
| 26 | LL | x.my_debug(); | |
| 27 | | ^ | |
| 28 | = note: ...which requires evaluating trait selection obligation `my_foo::{opaque#0}: core::marker::Unpin`... | |
| 29 | = note: ...which again requires computing type of opaque `my_foo::{opaque#0}`, completing the cycle | |
| 30 | note: cycle used when computing type of `my_foo::{opaque#0}` | |
| 31 | --> $DIR/call_method_on_inherent_impl_ref.rs:15:16 | |
| 32 | | | |
| 33 | LL | fn my_foo() -> impl std::fmt::Debug { | |
| 34 | | ^^^^^^^^^^^^^^^^^^^^ | |
| 35 | = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information | |
| 36 | ||
| 37 | error: aborting due to 2 previous errors | |
| 17 | error: aborting due to 1 previous error | |
| 38 | 18 | |
| 39 | Some errors have detailed explanations: E0391, E0599. | |
| 40 | For more information about an error, try `rustc --explain E0391`. | |
| 19 | For more information about this error, try `rustc --explain E0599`. |
tests/ui/impl-trait/call_method_on_inherent_impl_ref.next.stderr+2-2| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | error[E0282]: type annotations needed |
| 2 | --> $DIR/call_method_on_inherent_impl_ref.rs:18:13 | |
| 2 | --> $DIR/call_method_on_inherent_impl_ref.rs:17:13 | |
| 3 | 3 | | |
| 4 | 4 | LL | let x = my_foo(); |
| 5 | 5 | | ^ |
| ... | ... | @@ -13,7 +13,7 @@ LL | let x: /* Type */ = my_foo(); |
| 13 | 13 | | ++++++++++++ |
| 14 | 14 | |
| 15 | 15 | error[E0282]: type annotations needed for `&_` |
| 16 | --> $DIR/call_method_on_inherent_impl_ref.rs:28:13 | |
| 16 | --> $DIR/call_method_on_inherent_impl_ref.rs:27:13 | |
| 17 | 17 | | |
| 18 | 18 | LL | let x = &my_bar(); |
| 19 | 19 | | ^ |
tests/ui/impl-trait/call_method_on_inherent_impl_ref.rs-1| ... | ... | @@ -13,7 +13,6 @@ where |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | fn my_foo() -> impl std::fmt::Debug { |
| 16 | //[current]~^ cycle | |
| 17 | 16 | if false { |
| 18 | 17 | let x = my_foo(); |
| 19 | 18 | //[next]~^ type annotations needed |
tests/ui/impl-trait/rpit/const_check_false_cycle.rs created+14| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | //! This test caused a cycle error when checking whether the | |
| 2 | //! return type is `Freeze` during const checking, even though | |
| 3 | //! the information is readily available. | |
| 4 | ||
| 5 | //@ revisions: current next | |
| 6 | //@[next] compile-flags: -Znext-solver | |
| 7 | //@ check-pass | |
| 8 | ||
| 9 | const fn f() -> impl Eq { | |
| 10 | g() | |
| 11 | } | |
| 12 | const fn g() {} | |
| 13 | ||
| 14 | fn main() {} |
tests/ui/impl-trait/unsized_coercion3.next.stderr+2-2| ... | ... | @@ -5,7 +5,7 @@ LL | let x = hello(); |
| 5 | 5 | | ^^^^^^^ types differ |
| 6 | 6 | |
| 7 | 7 | error[E0308]: mismatched types |
| 8 | --> $DIR/unsized_coercion3.rs:19:14 | |
| 8 | --> $DIR/unsized_coercion3.rs:18:14 | |
| 9 | 9 | | |
| 10 | 10 | LL | fn hello() -> Box<impl Trait + ?Sized> { |
| 11 | 11 | | ------------------- the expected opaque type |
| ... | ... | @@ -21,7 +21,7 @@ note: associated function defined here |
| 21 | 21 | --> $SRC_DIR/alloc/src/boxed.rs:LL:COL |
| 22 | 22 | |
| 23 | 23 | error[E0277]: the size for values of type `impl Trait + ?Sized` cannot be known at compilation time |
| 24 | --> $DIR/unsized_coercion3.rs:19:14 | |
| 24 | --> $DIR/unsized_coercion3.rs:18:14 | |
| 25 | 25 | | |
| 26 | 26 | LL | Box::new(1u32) |
| 27 | 27 | | -------- ^^^^ doesn't have a size known at compile-time |
tests/ui/impl-trait/unsized_coercion3.old.stderr+1-15| ... | ... | @@ -1,17 +1,3 @@ |
| 1 | error: cannot check whether the hidden type of opaque type satisfies auto traits | |
| 2 | --> $DIR/unsized_coercion3.rs:15:32 | |
| 3 | | | |
| 4 | LL | let y: Box<dyn Send> = x; | |
| 5 | | ^ | |
| 6 | | | |
| 7 | = note: fetching the hidden types of an opaque inside of the defining scope is not supported. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule | |
| 8 | note: opaque type is declared here | |
| 9 | --> $DIR/unsized_coercion3.rs:11:19 | |
| 10 | | | |
| 11 | LL | fn hello() -> Box<impl Trait + ?Sized> { | |
| 12 | | ^^^^^^^^^^^^^^^^^^^ | |
| 13 | = note: required for the cast from `Box<impl Trait + ?Sized>` to `Box<dyn Send>` | |
| 14 | ||
| 15 | 1 | error[E0277]: the size for values of type `impl Trait + ?Sized` cannot be known at compilation time |
| 16 | 2 | --> $DIR/unsized_coercion3.rs:15:32 |
| 17 | 3 | | |
| ... | ... | @@ -21,6 +7,6 @@ LL | let y: Box<dyn Send> = x; |
| 21 | 7 | = help: the trait `Sized` is not implemented for `impl Trait + ?Sized` |
| 22 | 8 | = note: required for the cast from `Box<impl Trait + ?Sized>` to `Box<dyn Send>` |
| 23 | 9 | |
| 24 | error: aborting due to 2 previous errors | |
| 10 | error: aborting due to 1 previous error | |
| 25 | 11 | |
| 26 | 12 | For more information about this error, try `rustc --explain E0277`. |
tests/ui/impl-trait/unsized_coercion3.rs-1| ... | ... | @@ -14,7 +14,6 @@ fn hello() -> Box<impl Trait + ?Sized> { |
| 14 | 14 | //[next]~^ ERROR: type mismatch resolving `impl Trait + ?Sized <: dyn Send` |
| 15 | 15 | let y: Box<dyn Send> = x; |
| 16 | 16 | //[old]~^ ERROR: the size for values of type `impl Trait + ?Sized` cannot be know |
| 17 | //[old]~| ERROR: cannot check whether the hidden type of opaque type satisfies auto traits | |
| 18 | 17 | } |
| 19 | 18 | Box::new(1u32) |
| 20 | 19 | //[next]~^ ERROR: mismatched types |
tests/ui/impl-trait/unsized_coercion5.old.stderr+1-15| ... | ... | @@ -9,20 +9,6 @@ LL | let y: Box<dyn Send> = x as Box<dyn Trait + Send>; |
| 9 | 9 | = note: expected struct `Box<dyn Send>` |
| 10 | 10 | found struct `Box<dyn Trait + Send>` |
| 11 | 11 | |
| 12 | error: cannot check whether the hidden type of opaque type satisfies auto traits | |
| 13 | --> $DIR/unsized_coercion5.rs:16:32 | |
| 14 | | | |
| 15 | LL | let y: Box<dyn Send> = x as Box<dyn Trait + Send>; | |
| 16 | | ^ | |
| 17 | | | |
| 18 | = note: fetching the hidden types of an opaque inside of the defining scope is not supported. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule | |
| 19 | note: opaque type is declared here | |
| 20 | --> $DIR/unsized_coercion5.rs:13:19 | |
| 21 | | | |
| 22 | LL | fn hello() -> Box<impl Trait + ?Sized> { | |
| 23 | | ^^^^^^^^^^^^^^^^^^^ | |
| 24 | = note: required for the cast from `Box<impl Trait + ?Sized>` to `Box<dyn Trait + Send>` | |
| 25 | ||
| 26 | 12 | error[E0277]: the size for values of type `impl Trait + ?Sized` cannot be known at compilation time |
| 27 | 13 | --> $DIR/unsized_coercion5.rs:16:32 |
| 28 | 14 | | |
| ... | ... | @@ -32,7 +18,7 @@ LL | let y: Box<dyn Send> = x as Box<dyn Trait + Send>; |
| 32 | 18 | = help: the trait `Sized` is not implemented for `impl Trait + ?Sized` |
| 33 | 19 | = note: required for the cast from `Box<impl Trait + ?Sized>` to `Box<dyn Trait + Send>` |
| 34 | 20 | |
| 35 | error: aborting due to 3 previous errors | |
| 21 | error: aborting due to 2 previous errors | |
| 36 | 22 | |
| 37 | 23 | Some errors have detailed explanations: E0277, E0308. |
| 38 | 24 | For more information about an error, try `rustc --explain E0277`. |
tests/ui/impl-trait/unsized_coercion5.rs+1-2| ... | ... | @@ -15,8 +15,7 @@ fn hello() -> Box<impl Trait + ?Sized> { |
| 15 | 15 | let x = hello(); |
| 16 | 16 | let y: Box<dyn Send> = x as Box<dyn Trait + Send>; |
| 17 | 17 | //[old]~^ ERROR: the size for values of type `impl Trait + ?Sized` cannot be know |
| 18 | //[old]~| ERROR: cannot check whether the hidden type of opaque type satisfies auto traits | |
| 19 | //~^^^ ERROR: mismatched types | |
| 18 | //~^^ ERROR: mismatched types | |
| 20 | 19 | } |
| 21 | 20 | Box::new(1u32) |
| 22 | 21 | } |
tests/ui/lint/expansion-time.stderr+15| ... | ... | @@ -55,6 +55,21 @@ LL | #[warn(incomplete_include)] |
| 55 | 55 | warning: 4 warnings emitted |
| 56 | 56 | |
| 57 | 57 | Future incompatibility report: Future breakage diagnostic: |
| 58 | warning: missing fragment specifier | |
| 59 | --> $DIR/expansion-time.rs:9:19 | |
| 60 | | | |
| 61 | LL | macro_rules! m { ($i) => {} } | |
| 62 | | ^^ | |
| 63 | | | |
| 64 | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | |
| 65 | = note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107> | |
| 66 | note: the lint level is defined here | |
| 67 | --> $DIR/expansion-time.rs:8:8 | |
| 68 | | | |
| 69 | LL | #[warn(missing_fragment_specifier)] | |
| 70 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 71 | ||
| 72 | Future breakage diagnostic: | |
| 58 | 73 | warning: use of unstable library feature 'test': `bench` is a part of custom test frameworks which are unstable |
| 59 | 74 | --> $DIR/expansion-time.rs:14:7 |
| 60 | 75 | | |
tests/ui/macros/issue-39404.stderr+11| ... | ... | @@ -10,3 +10,14 @@ LL | macro_rules! m { ($i) => {} } |
| 10 | 10 | |
| 11 | 11 | error: aborting due to 1 previous error |
| 12 | 12 | |
| 13 | Future incompatibility report: Future breakage diagnostic: | |
| 14 | error: missing fragment specifier | |
| 15 | --> $DIR/issue-39404.rs:3:19 | |
| 16 | | | |
| 17 | LL | macro_rules! m { ($i) => {} } | |
| 18 | | ^^ | |
| 19 | | | |
| 20 | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | |
| 21 | = note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107> | |
| 22 | = note: `#[deny(missing_fragment_specifier)]` on by default | |
| 23 |
tests/ui/macros/macro-match-nonterminal.stderr+22| ... | ... | @@ -25,3 +25,25 @@ LL | ($a, $b) => { |
| 25 | 25 | |
| 26 | 26 | error: aborting due to 3 previous errors |
| 27 | 27 | |
| 28 | Future incompatibility report: Future breakage diagnostic: | |
| 29 | error: missing fragment specifier | |
| 30 | --> $DIR/macro-match-nonterminal.rs:2:8 | |
| 31 | | | |
| 32 | LL | ($a, $b) => { | |
| 33 | | ^ | |
| 34 | | | |
| 35 | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | |
| 36 | = note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107> | |
| 37 | = note: `#[deny(missing_fragment_specifier)]` on by default | |
| 38 | ||
| 39 | Future breakage diagnostic: | |
| 40 | error: missing fragment specifier | |
| 41 | --> $DIR/macro-match-nonterminal.rs:2:10 | |
| 42 | | | |
| 43 | LL | ($a, $b) => { | |
| 44 | | ^^ | |
| 45 | | | |
| 46 | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | |
| 47 | = note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107> | |
| 48 | = note: `#[deny(missing_fragment_specifier)]` on by default | |
| 49 |
tests/ui/macros/macro-missing-fragment-deduplication.stderr+11| ... | ... | @@ -16,3 +16,14 @@ LL | ($name) => {} |
| 16 | 16 | |
| 17 | 17 | error: aborting due to 2 previous errors |
| 18 | 18 | |
| 19 | Future incompatibility report: Future breakage diagnostic: | |
| 20 | error: missing fragment specifier | |
| 21 | --> $DIR/macro-missing-fragment-deduplication.rs:4:6 | |
| 22 | | | |
| 23 | LL | ($name) => {} | |
| 24 | | ^^^^^ | |
| 25 | | | |
| 26 | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | |
| 27 | = note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107> | |
| 28 | = note: `#[deny(missing_fragment_specifier)]` on by default | |
| 29 |
tests/ui/macros/macro-missing-fragment.stderr+45| ... | ... | @@ -38,3 +38,48 @@ LL | ( $name ) => {}; |
| 38 | 38 | |
| 39 | 39 | error: aborting due to 1 previous error; 3 warnings emitted |
| 40 | 40 | |
| 41 | Future incompatibility report: Future breakage diagnostic: | |
| 42 | warning: missing fragment specifier | |
| 43 | --> $DIR/macro-missing-fragment.rs:4:20 | |
| 44 | | | |
| 45 | LL | ( $( any_token $field_rust_type )* ) => {}; | |
| 46 | | ^^^^^^^^^^^^^^^^ | |
| 47 | | | |
| 48 | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | |
| 49 | = note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107> | |
| 50 | note: the lint level is defined here | |
| 51 | --> $DIR/macro-missing-fragment.rs:1:9 | |
| 52 | | | |
| 53 | LL | #![warn(missing_fragment_specifier)] | |
| 54 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 55 | ||
| 56 | Future breakage diagnostic: | |
| 57 | warning: missing fragment specifier | |
| 58 | --> $DIR/macro-missing-fragment.rs:12:7 | |
| 59 | | | |
| 60 | LL | ( $name ) => {}; | |
| 61 | | ^^^^^ | |
| 62 | | | |
| 63 | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | |
| 64 | = note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107> | |
| 65 | note: the lint level is defined here | |
| 66 | --> $DIR/macro-missing-fragment.rs:1:9 | |
| 67 | | | |
| 68 | LL | #![warn(missing_fragment_specifier)] | |
| 69 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 70 | ||
| 71 | Future breakage diagnostic: | |
| 72 | warning: missing fragment specifier | |
| 73 | --> $DIR/macro-missing-fragment.rs:18:7 | |
| 74 | | | |
| 75 | LL | ( $name ) => {}; | |
| 76 | | ^^^^^ | |
| 77 | | | |
| 78 | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | |
| 79 | = note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107> | |
| 80 | note: the lint level is defined here | |
| 81 | --> $DIR/macro-missing-fragment.rs:1:9 | |
| 82 | | | |
| 83 | LL | #![warn(missing_fragment_specifier)] | |
| 84 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 85 |
tests/ui/parser/macro/issue-33569.stderr+11| ... | ... | @@ -28,3 +28,14 @@ LL | { $+ } => { |
| 28 | 28 | |
| 29 | 29 | error: aborting due to 4 previous errors |
| 30 | 30 | |
| 31 | Future incompatibility report: Future breakage diagnostic: | |
| 32 | error: missing fragment specifier | |
| 33 | --> $DIR/issue-33569.rs:2:8 | |
| 34 | | | |
| 35 | LL | { $+ } => { | |
| 36 | | ^ | |
| 37 | | | |
| 38 | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | |
| 39 | = note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107> | |
| 40 | = note: `#[deny(missing_fragment_specifier)]` on by default | |
| 41 |
tests/ui/rfcs/rfc-2632-const-trait-impl/ice-120503-async-const-method.rs-1| ... | ... | @@ -9,7 +9,6 @@ impl MyTrait for i32 { |
| 9 | 9 | //~| ERROR functions in trait impls cannot be declared const |
| 10 | 10 | //~| ERROR functions cannot be both `const` and `async` |
| 11 | 11 | //~| ERROR method `bar` is not a member |
| 12 | //~| ERROR cycle detected when computing type | |
| 13 | 12 | main8().await; |
| 14 | 13 | //~^ ERROR cannot find function |
| 15 | 14 | } |
tests/ui/rfcs/rfc-2632-const-trait-impl/ice-120503-async-const-method.stderr+3-34| ... | ... | @@ -61,7 +61,7 @@ error: using `#![feature(effects)]` without enabling next trait solver globally |
| 61 | 61 | = help: use `-Znext-solver` to enable |
| 62 | 62 | |
| 63 | 63 | error[E0425]: cannot find function `main8` in this scope |
| 64 | --> $DIR/ice-120503-async-const-method.rs:13:9 | |
| 64 | --> $DIR/ice-120503-async-const-method.rs:12:9 | |
| 65 | 65 | | |
| 66 | 66 | LL | main8().await; |
| 67 | 67 | | ^^^^^ help: a function with a similar name exists: `main` |
| ... | ... | @@ -69,38 +69,7 @@ LL | main8().await; |
| 69 | 69 | LL | fn main() {} |
| 70 | 70 | | --------- similarly named function `main` defined here |
| 71 | 71 | |
| 72 | error[E0391]: cycle detected when computing type of opaque `<impl at $DIR/ice-120503-async-const-method.rs:6:1: 6:21>::bar::{opaque#0}` | |
| 73 | --> $DIR/ice-120503-async-const-method.rs:7:5 | |
| 74 | | | |
| 75 | LL | async const fn bar(&self) { | |
| 76 | | ^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 77 | | | |
| 78 | note: ...which requires borrow-checking `<impl at $DIR/ice-120503-async-const-method.rs:6:1: 6:21>::bar`... | |
| 79 | --> $DIR/ice-120503-async-const-method.rs:7:5 | |
| 80 | | | |
| 81 | LL | async const fn bar(&self) { | |
| 82 | | ^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 83 | note: ...which requires promoting constants in MIR for `<impl at $DIR/ice-120503-async-const-method.rs:6:1: 6:21>::bar`... | |
| 84 | --> $DIR/ice-120503-async-const-method.rs:7:5 | |
| 85 | | | |
| 86 | LL | async const fn bar(&self) { | |
| 87 | | ^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 88 | note: ...which requires const checking `<impl at $DIR/ice-120503-async-const-method.rs:6:1: 6:21>::bar`... | |
| 89 | --> $DIR/ice-120503-async-const-method.rs:7:5 | |
| 90 | | | |
| 91 | LL | async const fn bar(&self) { | |
| 92 | | ^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 93 | = note: ...which requires computing whether `<impl at $DIR/ice-120503-async-const-method.rs:6:1: 6:21>::bar::{opaque#0}` is freeze... | |
| 94 | = note: ...which requires evaluating trait selection obligation `<impl at $DIR/ice-120503-async-const-method.rs:6:1: 6:21>::bar::{opaque#0}: core::marker::Freeze`... | |
| 95 | = note: ...which again requires computing type of opaque `<impl at $DIR/ice-120503-async-const-method.rs:6:1: 6:21>::bar::{opaque#0}`, completing the cycle | |
| 96 | note: cycle used when computing type of `<impl at $DIR/ice-120503-async-const-method.rs:6:1: 6:21>::bar::{opaque#0}` | |
| 97 | --> $DIR/ice-120503-async-const-method.rs:7:5 | |
| 98 | | | |
| 99 | LL | async const fn bar(&self) { | |
| 100 | | ^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 101 | = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information | |
| 102 | ||
| 103 | error: aborting due to 7 previous errors; 1 warning emitted | |
| 72 | error: aborting due to 6 previous errors; 1 warning emitted | |
| 104 | 73 | |
| 105 | Some errors have detailed explanations: E0379, E0391, E0407, E0425. | |
| 74 | Some errors have detailed explanations: E0379, E0407, E0425. | |
| 106 | 75 | For more information about an error, try `rustc --explain E0379`. |
tests/ui/trait-bounds/bad-suggestionf-for-repeated-unsized-bound-127441.rs created+39| ... | ... | @@ -0,0 +1,39 @@ |
| 1 | // Regression test for #127441 | |
| 2 | ||
| 3 | // Tests that we make the correct suggestion | |
| 4 | // in case there are more than one `?Sized` | |
| 5 | // bounds on a function parameter | |
| 6 | ||
| 7 | use std::fmt::Debug; | |
| 8 | ||
| 9 | fn foo1<T: ?Sized>(a: T) {} | |
| 10 | //~^ ERROR he size for values of type `T` cannot be known at compilation time | |
| 11 | ||
| 12 | fn foo2<T: ?Sized + ?Sized>(a: T) {} | |
| 13 | //~^ ERROR type parameter has more than one relaxed default bound, only one is supported | |
| 14 | //~| ERROR the size for values of type `T` cannot be known at compilation time | |
| 15 | ||
| 16 | fn foo3<T: ?Sized + ?Sized + Debug>(a: T) {} | |
| 17 | //~^ ERROR type parameter has more than one relaxed default bound, only one is supported | |
| 18 | //~| ERROR he size for values of type `T` cannot be known at compilation time | |
| 19 | ||
| 20 | fn foo4<T: ?Sized + Debug + ?Sized >(a: T) {} | |
| 21 | //~^ ERROR type parameter has more than one relaxed default bound, only one is supported | |
| 22 | //~| ERROR the size for values of type `T` cannot be known at compilation time | |
| 23 | ||
| 24 | fn foo5(_: impl ?Sized) {} | |
| 25 | //~^ ERROR the size for values of type `impl ?Sized` cannot be known at compilation time | |
| 26 | ||
| 27 | fn foo6(_: impl ?Sized + ?Sized) {} | |
| 28 | //~^ ERROR type parameter has more than one relaxed default bound, only one is supported | |
| 29 | //~| ERROR the size for values of type `impl ?Sized + ?Sized` cannot be known at compilation tim | |
| 30 | ||
| 31 | fn foo7(_: impl ?Sized + ?Sized + Debug) {} | |
| 32 | //~^ ERROR type parameter has more than one relaxed default bound, only one is supported | |
| 33 | //~| ERROR the size for values of type `impl ?Sized + ?Sized + Debug` cannot be known at compilation time | |
| 34 | ||
| 35 | fn foo8(_: impl ?Sized + Debug + ?Sized ) {} | |
| 36 | //~^ ERROR type parameter has more than one relaxed default bound, only one is supported | |
| 37 | //~| ERROR the size for values of type `impl ?Sized + Debug + ?Sized` cannot be known at compilation time | |
| 38 | ||
| 39 | fn main() {} |
tests/ui/trait-bounds/bad-suggestionf-for-repeated-unsized-bound-127441.stderr created+192| ... | ... | @@ -0,0 +1,192 @@ |
| 1 | error[E0203]: type parameter has more than one relaxed default bound, only one is supported | |
| 2 | --> $DIR/bad-suggestionf-for-repeated-unsized-bound-127441.rs:12:12 | |
| 3 | | | |
| 4 | LL | fn foo2<T: ?Sized + ?Sized>(a: T) {} | |
| 5 | | ^^^^^^ ^^^^^^ | |
| 6 | ||
| 7 | error[E0203]: type parameter has more than one relaxed default bound, only one is supported | |
| 8 | --> $DIR/bad-suggestionf-for-repeated-unsized-bound-127441.rs:16:12 | |
| 9 | | | |
| 10 | LL | fn foo3<T: ?Sized + ?Sized + Debug>(a: T) {} | |
| 11 | | ^^^^^^ ^^^^^^ | |
| 12 | ||
| 13 | error[E0203]: type parameter has more than one relaxed default bound, only one is supported | |
| 14 | --> $DIR/bad-suggestionf-for-repeated-unsized-bound-127441.rs:20:12 | |
| 15 | | | |
| 16 | LL | fn foo4<T: ?Sized + Debug + ?Sized >(a: T) {} | |
| 17 | | ^^^^^^ ^^^^^^ | |
| 18 | ||
| 19 | error[E0203]: type parameter has more than one relaxed default bound, only one is supported | |
| 20 | --> $DIR/bad-suggestionf-for-repeated-unsized-bound-127441.rs:27:17 | |
| 21 | | | |
| 22 | LL | fn foo6(_: impl ?Sized + ?Sized) {} | |
| 23 | | ^^^^^^ ^^^^^^ | |
| 24 | ||
| 25 | error[E0203]: type parameter has more than one relaxed default bound, only one is supported | |
| 26 | --> $DIR/bad-suggestionf-for-repeated-unsized-bound-127441.rs:31:17 | |
| 27 | | | |
| 28 | LL | fn foo7(_: impl ?Sized + ?Sized + Debug) {} | |
| 29 | | ^^^^^^ ^^^^^^ | |
| 30 | ||
| 31 | error[E0203]: type parameter has more than one relaxed default bound, only one is supported | |
| 32 | --> $DIR/bad-suggestionf-for-repeated-unsized-bound-127441.rs:35:17 | |
| 33 | | | |
| 34 | LL | fn foo8(_: impl ?Sized + Debug + ?Sized ) {} | |
| 35 | | ^^^^^^ ^^^^^^ | |
| 36 | ||
| 37 | error[E0277]: the size for values of type `T` cannot be known at compilation time | |
| 38 | --> $DIR/bad-suggestionf-for-repeated-unsized-bound-127441.rs:9:20 | |
| 39 | | | |
| 40 | LL | fn foo1<T: ?Sized>(a: T) {} | |
| 41 | | - ^ doesn't have a size known at compile-time | |
| 42 | | | | |
| 43 | | this type parameter needs to be `Sized` | |
| 44 | | | |
| 45 | = help: unsized fn params are gated as an unstable feature | |
| 46 | help: consider removing the `?Sized` bound to make the type parameter `Sized` | |
| 47 | | | |
| 48 | LL - fn foo1<T: ?Sized>(a: T) {} | |
| 49 | LL + fn foo1<T>(a: T) {} | |
| 50 | | | |
| 51 | help: function arguments must have a statically known size, borrowed types always have a known size | |
| 52 | | | |
| 53 | LL | fn foo1<T: ?Sized>(a: &T) {} | |
| 54 | | + | |
| 55 | ||
| 56 | error[E0277]: the size for values of type `T` cannot be known at compilation time | |
| 57 | --> $DIR/bad-suggestionf-for-repeated-unsized-bound-127441.rs:12:29 | |
| 58 | | | |
| 59 | LL | fn foo2<T: ?Sized + ?Sized>(a: T) {} | |
| 60 | | - ^ doesn't have a size known at compile-time | |
| 61 | | | | |
| 62 | | this type parameter needs to be `Sized` | |
| 63 | | | |
| 64 | = help: unsized fn params are gated as an unstable feature | |
| 65 | help: consider removing the `?Sized` bound to make the type parameter `Sized` | |
| 66 | | | |
| 67 | LL - fn foo2<T: ?Sized + ?Sized>(a: T) {} | |
| 68 | LL + fn foo2<T>(a: T) {} | |
| 69 | | | |
| 70 | help: function arguments must have a statically known size, borrowed types always have a known size | |
| 71 | | | |
| 72 | LL | fn foo2<T: ?Sized + ?Sized>(a: &T) {} | |
| 73 | | + | |
| 74 | ||
| 75 | error[E0277]: the size for values of type `T` cannot be known at compilation time | |
| 76 | --> $DIR/bad-suggestionf-for-repeated-unsized-bound-127441.rs:16:37 | |
| 77 | | | |
| 78 | LL | fn foo3<T: ?Sized + ?Sized + Debug>(a: T) {} | |
| 79 | | - ^ doesn't have a size known at compile-time | |
| 80 | | | | |
| 81 | | this type parameter needs to be `Sized` | |
| 82 | | | |
| 83 | = help: unsized fn params are gated as an unstable feature | |
| 84 | help: consider restricting type parameters | |
| 85 | | | |
| 86 | LL - fn foo3<T: ?Sized + ?Sized + Debug>(a: T) {} | |
| 87 | LL + fn foo3<T: Debug>(a: T) {} | |
| 88 | | | |
| 89 | help: function arguments must have a statically known size, borrowed types always have a known size | |
| 90 | | | |
| 91 | LL | fn foo3<T: ?Sized + ?Sized + Debug>(a: &T) {} | |
| 92 | | + | |
| 93 | ||
| 94 | error[E0277]: the size for values of type `T` cannot be known at compilation time | |
| 95 | --> $DIR/bad-suggestionf-for-repeated-unsized-bound-127441.rs:20:38 | |
| 96 | | | |
| 97 | LL | fn foo4<T: ?Sized + Debug + ?Sized >(a: T) {} | |
| 98 | | - ^ doesn't have a size known at compile-time | |
| 99 | | | | |
| 100 | | this type parameter needs to be `Sized` | |
| 101 | | | |
| 102 | = help: unsized fn params are gated as an unstable feature | |
| 103 | help: consider restricting type parameters | |
| 104 | | | |
| 105 | LL - fn foo4<T: ?Sized + Debug + ?Sized >(a: T) {} | |
| 106 | LL + fn foo4<T: Debug >(a: T) {} | |
| 107 | | | |
| 108 | help: function arguments must have a statically known size, borrowed types always have a known size | |
| 109 | | | |
| 110 | LL | fn foo4<T: ?Sized + Debug + ?Sized >(a: &T) {} | |
| 111 | | + | |
| 112 | ||
| 113 | error[E0277]: the size for values of type `impl ?Sized` cannot be known at compilation time | |
| 114 | --> $DIR/bad-suggestionf-for-repeated-unsized-bound-127441.rs:24:9 | |
| 115 | | | |
| 116 | LL | fn foo5(_: impl ?Sized) {} | |
| 117 | | ^ ----------- this type parameter needs to be `Sized` | |
| 118 | | | | |
| 119 | | doesn't have a size known at compile-time | |
| 120 | | | |
| 121 | = help: unsized fn params are gated as an unstable feature | |
| 122 | help: consider replacing `?Sized` with `Sized` | |
| 123 | | | |
| 124 | LL - fn foo5(_: impl ?Sized) {} | |
| 125 | LL + fn foo5(_: impl Sized) {} | |
| 126 | | | |
| 127 | help: function arguments must have a statically known size, borrowed types always have a known size | |
| 128 | | | |
| 129 | LL | fn foo5(_: &impl ?Sized) {} | |
| 130 | | + | |
| 131 | ||
| 132 | error[E0277]: the size for values of type `impl ?Sized + ?Sized` cannot be known at compilation time | |
| 133 | --> $DIR/bad-suggestionf-for-repeated-unsized-bound-127441.rs:27:9 | |
| 134 | | | |
| 135 | LL | fn foo6(_: impl ?Sized + ?Sized) {} | |
| 136 | | ^ -------------------- this type parameter needs to be `Sized` | |
| 137 | | | | |
| 138 | | doesn't have a size known at compile-time | |
| 139 | | | |
| 140 | = help: unsized fn params are gated as an unstable feature | |
| 141 | help: consider restricting type parameters | |
| 142 | | | |
| 143 | LL - fn foo6(_: impl ?Sized + ?Sized) {} | |
| 144 | LL + fn foo6(_: impl Sized) {} | |
| 145 | | | |
| 146 | help: function arguments must have a statically known size, borrowed types always have a known size | |
| 147 | | | |
| 148 | LL | fn foo6(_: &impl ?Sized + ?Sized) {} | |
| 149 | | + | |
| 150 | ||
| 151 | error[E0277]: the size for values of type `impl ?Sized + ?Sized + Debug` cannot be known at compilation time | |
| 152 | --> $DIR/bad-suggestionf-for-repeated-unsized-bound-127441.rs:31:9 | |
| 153 | | | |
| 154 | LL | fn foo7(_: impl ?Sized + ?Sized + Debug) {} | |
| 155 | | ^ ---------------------------- this type parameter needs to be `Sized` | |
| 156 | | | | |
| 157 | | doesn't have a size known at compile-time | |
| 158 | | | |
| 159 | = help: unsized fn params are gated as an unstable feature | |
| 160 | help: consider restricting type parameters | |
| 161 | | | |
| 162 | LL - fn foo7(_: impl ?Sized + ?Sized + Debug) {} | |
| 163 | LL + fn foo7(_: impl Debug) {} | |
| 164 | | | |
| 165 | help: function arguments must have a statically known size, borrowed types always have a known size | |
| 166 | | | |
| 167 | LL | fn foo7(_: &impl ?Sized + ?Sized + Debug) {} | |
| 168 | | + | |
| 169 | ||
| 170 | error[E0277]: the size for values of type `impl ?Sized + Debug + ?Sized` cannot be known at compilation time | |
| 171 | --> $DIR/bad-suggestionf-for-repeated-unsized-bound-127441.rs:35:9 | |
| 172 | | | |
| 173 | LL | fn foo8(_: impl ?Sized + Debug + ?Sized ) {} | |
| 174 | | ^ ---------------------------- this type parameter needs to be `Sized` | |
| 175 | | | | |
| 176 | | doesn't have a size known at compile-time | |
| 177 | | | |
| 178 | = help: unsized fn params are gated as an unstable feature | |
| 179 | help: consider restricting type parameters | |
| 180 | | | |
| 181 | LL - fn foo8(_: impl ?Sized + Debug + ?Sized ) {} | |
| 182 | LL + fn foo8(_: impl Debug ) {} | |
| 183 | | | |
| 184 | help: function arguments must have a statically known size, borrowed types always have a known size | |
| 185 | | | |
| 186 | LL | fn foo8(_: &impl ?Sized + Debug + ?Sized ) {} | |
| 187 | | + | |
| 188 | ||
| 189 | error: aborting due to 14 previous errors | |
| 190 | ||
| 191 | Some errors have detailed explanations: E0203, E0277. | |
| 192 | For more information about an error, try `rustc --explain E0203`. |
tests/ui/type-alias-impl-trait/in-where-clause.rs+1-1| ... | ... | @@ -4,13 +4,13 @@ |
| 4 | 4 | #![feature(type_alias_impl_trait)] |
| 5 | 5 | type Bar = impl Sized; |
| 6 | 6 | //~^ ERROR: cycle |
| 7 | //~| ERROR: cycle | |
| 8 | 7 | |
| 9 | 8 | fn foo() -> Bar |
| 10 | 9 | where |
| 11 | 10 | Bar: Send, |
| 12 | 11 | { |
| 13 | 12 | [0; 1 + 2] |
| 13 | //~^ ERROR: type annotations needed: cannot satisfy `Bar: Send` | |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | fn main() {} |
tests/ui/type-alias-impl-trait/in-where-clause.stderr+14-17| ... | ... | @@ -10,7 +10,7 @@ note: ...which requires computing type of opaque `Bar::{opaque#0}`... |
| 10 | 10 | LL | type Bar = impl Sized; |
| 11 | 11 | | ^^^^^^^^^^ |
| 12 | 12 | note: ...which requires type-checking `foo`... |
| 13 | --> $DIR/in-where-clause.rs:9:1 | |
| 13 | --> $DIR/in-where-clause.rs:8:1 | |
| 14 | 14 | | |
| 15 | 15 | LL | / fn foo() -> Bar |
| 16 | 16 | LL | | where |
| ... | ... | @@ -25,26 +25,23 @@ LL | type Bar = impl Sized; |
| 25 | 25 | | ^^^^^^^^^^ |
| 26 | 26 | = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information |
| 27 | 27 | |
| 28 | error[E0391]: cycle detected when computing type of opaque `Bar::{opaque#0}` | |
| 29 | --> $DIR/in-where-clause.rs:5:12 | |
| 30 | | | |
| 31 | LL | type Bar = impl Sized; | |
| 32 | | ^^^^^^^^^^ | |
| 33 | | | |
| 34 | note: ...which requires type-checking `foo`... | |
| 35 | --> $DIR/in-where-clause.rs:13:9 | |
| 28 | error[E0283]: type annotations needed: cannot satisfy `Bar: Send` | |
| 29 | --> $DIR/in-where-clause.rs:12:9 | |
| 36 | 30 | | |
| 37 | 31 | LL | [0; 1 + 2] |
| 38 | 32 | | ^^^^^ |
| 39 | = note: ...which requires evaluating trait selection obligation `Bar: core::marker::Send`... | |
| 40 | = note: ...which again requires computing type of opaque `Bar::{opaque#0}`, completing the cycle | |
| 41 | note: cycle used when computing type of `Bar::{opaque#0}` | |
| 42 | --> $DIR/in-where-clause.rs:5:12 | |
| 43 | 33 | | |
| 44 | LL | type Bar = impl Sized; | |
| 45 | | ^^^^^^^^^^ | |
| 46 | = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information | |
| 34 | = note: cannot satisfy `Bar: Send` | |
| 35 | note: required by a bound in `foo` | |
| 36 | --> $DIR/in-where-clause.rs:10:10 | |
| 37 | | | |
| 38 | LL | fn foo() -> Bar | |
| 39 | | --- required by a bound in this function | |
| 40 | LL | where | |
| 41 | LL | Bar: Send, | |
| 42 | | ^^^^ required by this bound in `foo` | |
| 47 | 43 | |
| 48 | 44 | error: aborting due to 2 previous errors |
| 49 | 45 | |
| 50 | For more information about this error, try `rustc --explain E0391`. | |
| 46 | Some errors have detailed explanations: E0283, E0391. | |
| 47 | For more information about an error, try `rustc --explain E0283`. |
tests/ui/type-alias-impl-trait/reveal_local.rs+1-1| ... | ... | @@ -20,7 +20,7 @@ fn not_gooder() -> Foo { |
| 20 | 20 | // while we could know this from the hidden type, it would |
| 21 | 21 | // need extra roundabout logic to support it. |
| 22 | 22 | is_send::<Foo>(); |
| 23 | //~^ ERROR: cannot check whether the hidden type of `reveal_local[9507]::Foo::{opaque#0}` satisfies auto traits | |
| 23 | //~^ ERROR: type annotations needed: cannot satisfy `Foo: Send` | |
| 24 | 24 | |
| 25 | 25 | x |
| 26 | 26 | } |
tests/ui/type-alias-impl-trait/reveal_local.stderr+3-7| ... | ... | @@ -16,18 +16,13 @@ note: required by a bound in `is_send` |
| 16 | 16 | LL | fn is_send<T: Send>() {} |
| 17 | 17 | | ^^^^ required by this bound in `is_send` |
| 18 | 18 | |
| 19 | error: cannot check whether the hidden type of `reveal_local[9507]::Foo::{opaque#0}` satisfies auto traits | |
| 19 | error[E0283]: type annotations needed: cannot satisfy `Foo: Send` | |
| 20 | 20 | --> $DIR/reveal_local.rs:22:15 |
| 21 | 21 | | |
| 22 | 22 | LL | is_send::<Foo>(); |
| 23 | 23 | | ^^^ |
| 24 | 24 | | |
| 25 | = note: fetching the hidden types of an opaque inside of the defining scope is not supported. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule | |
| 26 | note: opaque type is declared here | |
| 27 | --> $DIR/reveal_local.rs:5:12 | |
| 28 | | | |
| 29 | LL | type Foo = impl Debug; | |
| 30 | | ^^^^^^^^^^ | |
| 25 | = note: cannot satisfy `Foo: Send` | |
| 31 | 26 | note: required by a bound in `is_send` |
| 32 | 27 | --> $DIR/reveal_local.rs:7:15 |
| 33 | 28 | | |
| ... | ... | @@ -36,3 +31,4 @@ LL | fn is_send<T: Send>() {} |
| 36 | 31 | |
| 37 | 32 | error: aborting due to 2 previous errors |
| 38 | 33 | |
| 34 | For more information about this error, try `rustc --explain E0283`. |