mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Auto merge of #128155 - matthiaskrgr:rollup-lxtal9f, r=matthiaskrgr
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: rollup
This commit is contained in:
commit
e7d66eac5e
@ -100,7 +100,33 @@ impl Qualif for HasMutInterior {
|
||||
}
|
||||
|
||||
fn in_any_value_of_ty<'tcx>(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> bool {
|
||||
!ty.is_freeze(cx.tcx, cx.param_env)
|
||||
// Avoid selecting for simple cases, such as builtin types.
|
||||
if ty.is_trivially_freeze() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// We do not use `ty.is_freeze` here, because that requires revealing opaque types, which
|
||||
// requires borrowck, which in turn will invoke mir_const_qualifs again, causing a cycle error.
|
||||
// Instead we invoke an obligation context manually, and provide the opaque type inference settings
|
||||
// that allow the trait solver to just error out instead of cycling.
|
||||
let freeze_def_id = cx.tcx.require_lang_item(LangItem::Freeze, Some(cx.body.span));
|
||||
|
||||
let obligation = Obligation::new(
|
||||
cx.tcx,
|
||||
ObligationCause::dummy_with_span(cx.body.span),
|
||||
cx.param_env,
|
||||
ty::TraitRef::new(cx.tcx, freeze_def_id, [ty::GenericArg::from(ty)]),
|
||||
);
|
||||
|
||||
let infcx = cx
|
||||
.tcx
|
||||
.infer_ctxt()
|
||||
.with_opaque_type_inference(cx.body.source.def_id().expect_local())
|
||||
.build();
|
||||
let ocx = ObligationCtxt::new(&infcx);
|
||||
ocx.register_obligation(obligation);
|
||||
let errors = ocx.select_all_or_error();
|
||||
!errors.is_empty()
|
||||
}
|
||||
|
||||
fn in_adt_inherently<'tcx>(
|
||||
|
@ -763,7 +763,7 @@ impl<'hir> Generics<'hir> {
|
||||
)
|
||||
}
|
||||
|
||||
fn span_for_predicate_removal(&self, pos: usize) -> Span {
|
||||
pub fn span_for_predicate_removal(&self, pos: usize) -> Span {
|
||||
let predicate = &self.predicates[pos];
|
||||
let span = predicate.span();
|
||||
|
||||
@ -806,15 +806,21 @@ impl<'hir> Generics<'hir> {
|
||||
return self.span_for_predicate_removal(predicate_pos);
|
||||
}
|
||||
|
||||
let span = bounds[bound_pos].span();
|
||||
if bound_pos == 0 {
|
||||
// where T: ?Sized + Bar, Foo: Bar,
|
||||
// ^^^^^^^^^
|
||||
span.to(bounds[1].span().shrink_to_lo())
|
||||
let bound_span = bounds[bound_pos].span();
|
||||
if bound_pos < bounds.len() - 1 {
|
||||
// If there's another bound after the current bound
|
||||
// include the following '+' e.g.:
|
||||
//
|
||||
// `T: Foo + CurrentBound + Bar`
|
||||
// ^^^^^^^^^^^^^^^
|
||||
bound_span.to(bounds[bound_pos + 1].span().shrink_to_lo())
|
||||
} else {
|
||||
// where T: Bar + ?Sized, Foo: Bar,
|
||||
// ^^^^^^^^^
|
||||
bounds[bound_pos - 1].span().shrink_to_hi().to(span)
|
||||
// If the current bound is the last bound
|
||||
// include the preceding '+' E.g.:
|
||||
//
|
||||
// `T: Foo + Bar + CurrentBound`
|
||||
// ^^^^^^^^^^^^^^^
|
||||
bound_span.with_lo(bounds[bound_pos - 1].span().hi())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1846,7 +1846,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
||||
/// Determine if the associated item with the given DefId matches
|
||||
/// the desired name via a doc alias.
|
||||
fn matches_by_doc_alias(&self, def_id: DefId) -> bool {
|
||||
let Some(name) = self.method_name else {
|
||||
let Some(method) = self.method_name else {
|
||||
return false;
|
||||
};
|
||||
let Some(local_def_id) = def_id.as_local() else {
|
||||
@ -1863,7 +1863,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
||||
// #[rustc_confusables("foo", "bar"))]
|
||||
for n in confusables {
|
||||
if let Some(lit) = n.lit()
|
||||
&& name.as_str() == lit.symbol.as_str()
|
||||
&& method.name == lit.symbol
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -1883,14 +1883,14 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
||||
// #[doc(alias("foo", "bar"))]
|
||||
for n in nested {
|
||||
if let Some(lit) = n.lit()
|
||||
&& name.as_str() == lit.symbol.as_str()
|
||||
&& method.name == lit.symbol
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if let Some(meta) = v.meta_item()
|
||||
&& let Some(lit) = meta.name_value_literal()
|
||||
&& name.as_str() == lit.symbol.as_str()
|
||||
&& method.name == lit.symbol
|
||||
{
|
||||
// #[doc(alias = "foo")]
|
||||
return true;
|
||||
|
@ -1424,7 +1424,7 @@ declare_lint! {
|
||||
Deny,
|
||||
"detects missing fragment specifiers in unused `macro_rules!` patterns",
|
||||
@future_incompatible = FutureIncompatibleInfo {
|
||||
reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
|
||||
reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
|
||||
reference: "issue #40107 <https://github.com/rust-lang/rust/issues/40107>",
|
||||
};
|
||||
}
|
||||
|
@ -188,31 +188,60 @@ fn suggest_changing_unsized_bound(
|
||||
continue;
|
||||
};
|
||||
|
||||
for (pos, bound) in predicate.bounds.iter().enumerate() {
|
||||
let hir::GenericBound::Trait(poly, hir::TraitBoundModifier::Maybe) = bound else {
|
||||
continue;
|
||||
};
|
||||
if poly.trait_ref.trait_def_id() != def_id {
|
||||
continue;
|
||||
}
|
||||
if predicate.origin == PredicateOrigin::ImplTrait && predicate.bounds.len() == 1 {
|
||||
// For `impl ?Sized` with no other bounds, suggest `impl Sized` instead.
|
||||
let bound_span = bound.span();
|
||||
if bound_span.can_be_used_for_suggestions() {
|
||||
let question_span = bound_span.with_hi(bound_span.lo() + BytePos(1));
|
||||
suggestions.push((
|
||||
let unsized_bounds = predicate
|
||||
.bounds
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(_, bound)| {
|
||||
if let hir::GenericBound::Trait(poly, hir::TraitBoundModifier::Maybe) = bound
|
||||
&& poly.trait_ref.trait_def_id() == def_id
|
||||
{
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
if unsized_bounds.is_empty() {
|
||||
continue;
|
||||
}
|
||||
|
||||
let mut push_suggestion = |sp, msg| suggestions.push((sp, String::new(), msg));
|
||||
|
||||
if predicate.bounds.len() == unsized_bounds.len() {
|
||||
// All the bounds are unsized bounds, e.g.
|
||||
// `T: ?Sized + ?Sized` or `_: impl ?Sized + ?Sized`,
|
||||
// so in this case:
|
||||
// - if it's an impl trait predicate suggest changing the
|
||||
// the first bound to sized and removing the rest
|
||||
// - Otherwise simply suggest removing the entire predicate
|
||||
if predicate.origin == PredicateOrigin::ImplTrait {
|
||||
let first_bound = unsized_bounds[0].1;
|
||||
let first_bound_span = first_bound.span();
|
||||
if first_bound_span.can_be_used_for_suggestions() {
|
||||
let question_span =
|
||||
first_bound_span.with_hi(first_bound_span.lo() + BytePos(1));
|
||||
push_suggestion(
|
||||
question_span,
|
||||
String::new(),
|
||||
SuggestChangingConstraintsMessage::ReplaceMaybeUnsizedWithSized,
|
||||
));
|
||||
);
|
||||
|
||||
for (pos, _) in unsized_bounds.iter().skip(1) {
|
||||
let sp = generics.span_for_bound_removal(where_pos, *pos);
|
||||
push_suggestion(sp, SuggestChangingConstraintsMessage::RemoveMaybeUnsized);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let sp = generics.span_for_predicate_removal(where_pos);
|
||||
push_suggestion(sp, SuggestChangingConstraintsMessage::RemoveMaybeUnsized);
|
||||
}
|
||||
} else {
|
||||
// Some of the bounds are other than unsized.
|
||||
// So push separate removal suggestion for each unsized bound
|
||||
for (pos, _) in unsized_bounds {
|
||||
let sp = generics.span_for_bound_removal(where_pos, pos);
|
||||
suggestions.push((
|
||||
sp,
|
||||
String::new(),
|
||||
SuggestChangingConstraintsMessage::RemoveMaybeUnsized,
|
||||
));
|
||||
push_suggestion(sp, SuggestChangingConstraintsMessage::RemoveMaybeUnsized);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1268,7 +1268,7 @@ impl<'tcx> Ty<'tcx> {
|
||||
///
|
||||
/// Returning true means the type is known to be `Freeze`. Returning
|
||||
/// `false` means nothing -- could be `Freeze`, might not be.
|
||||
fn is_trivially_freeze(self) -> bool {
|
||||
pub fn is_trivially_freeze(self) -> bool {
|
||||
match self.kind() {
|
||||
ty::Int(_)
|
||||
| ty::Uint(_)
|
||||
|
@ -772,7 +772,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
);
|
||||
}
|
||||
|
||||
ty::Alias(ty::Opaque, _) => {
|
||||
ty::Alias(ty::Opaque, alias) => {
|
||||
if candidates.vec.iter().any(|c| matches!(c, ProjectionCandidate(_))) {
|
||||
// We do not generate an auto impl candidate for `impl Trait`s which already
|
||||
// reference our auto trait.
|
||||
@ -787,6 +787,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
// We do not emit auto trait candidates for opaque types in coherence.
|
||||
// Doing so can result in weird dependency cycles.
|
||||
candidates.ambiguous = true;
|
||||
} else if self.infcx.can_define_opaque_ty(alias.def_id) {
|
||||
// We do not emit auto trait candidates for opaque types in their defining scope, as
|
||||
// we need to know the hidden type first, which we can't reliably know within the defining
|
||||
// scope.
|
||||
candidates.ambiguous = true;
|
||||
} else {
|
||||
candidates.vec.push(AutoImplCandidate)
|
||||
}
|
||||
|
@ -2386,13 +2386,17 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
||||
}
|
||||
|
||||
ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) => {
|
||||
// We can resolve the `impl Trait` to its concrete type,
|
||||
// which enforces a DAG between the functions requiring
|
||||
// the auto trait bounds in question.
|
||||
match self.tcx().type_of_opaque(def_id) {
|
||||
Ok(ty) => t.rebind(vec![ty.instantiate(self.tcx(), args)]),
|
||||
Err(_) => {
|
||||
return Err(SelectionError::OpaqueTypeAutoTraitLeakageUnknown(def_id));
|
||||
if self.infcx.can_define_opaque_ty(def_id) {
|
||||
unreachable!()
|
||||
} else {
|
||||
// We can resolve the `impl Trait` to its concrete type,
|
||||
// which enforces a DAG between the functions requiring
|
||||
// the auto trait bounds in question.
|
||||
match self.tcx().type_of_opaque(def_id) {
|
||||
Ok(ty) => t.rebind(vec![ty.instantiate(self.tcx(), args)]),
|
||||
Err(_) => {
|
||||
return Err(SelectionError::OpaqueTypeAutoTraitLeakageUnknown(def_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -506,7 +506,7 @@ where
|
||||
/// ```
|
||||
///
|
||||
#[unstable(feature = "error_generic_member_access", issue = "99301")]
|
||||
#[cfg_attr(not(doc), repr(transparent))] // work around https://github.com/rust-lang/rust/issues/90435
|
||||
#[repr(transparent)]
|
||||
pub struct Request<'a>(Tagged<dyn Erased<'a> + 'a>);
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
|
@ -103,7 +103,7 @@ use crate::str;
|
||||
// However, `CStr` layout is considered an implementation detail and must not be relied upon. We
|
||||
// want `repr(transparent)` but we don't want it to show up in rustdoc, so we hide it under
|
||||
// `cfg(doc)`. This is an ad-hoc implementation of attribute privacy.
|
||||
#[cfg_attr(not(doc), repr(transparent))]
|
||||
#[repr(transparent)]
|
||||
#[allow(clippy::derived_hash_with_manual_eq)]
|
||||
pub struct CStr {
|
||||
// FIXME: this should not be represented with a DST slice but rather with
|
||||
|
@ -191,7 +191,7 @@ mod c_long_definition {
|
||||
// be UB.
|
||||
#[doc = include_str!("c_void.md")]
|
||||
#[lang = "c_void"]
|
||||
#[cfg_attr(not(doc), repr(u8))] // work around https://github.com/rust-lang/rust/issues/90435
|
||||
#[cfg_attr(not(doc), repr(u8))] // An implementation detail we don't want to show up in rustdoc
|
||||
#[stable(feature = "core_c_void", since = "1.30.0")]
|
||||
pub enum c_void {
|
||||
#[unstable(
|
||||
|
@ -23,7 +23,7 @@ use crate::ops::{Deref, DerefMut};
|
||||
target_os = "uefi",
|
||||
windows,
|
||||
))]
|
||||
#[cfg_attr(not(doc), repr(transparent))] // work around https://github.com/rust-lang/rust/issues/90435
|
||||
#[repr(transparent)]
|
||||
#[lang = "va_list"]
|
||||
pub struct VaListImpl<'f> {
|
||||
ptr: *mut c_void,
|
||||
@ -115,7 +115,7 @@ pub struct VaListImpl<'f> {
|
||||
}
|
||||
|
||||
/// A wrapper for a `va_list`
|
||||
#[cfg_attr(not(doc), repr(transparent))] // work around https://github.com/rust-lang/rust/issues/90435
|
||||
#[repr(transparent)]
|
||||
#[derive(Debug)]
|
||||
pub struct VaList<'a, 'f: 'a> {
|
||||
#[cfg(any(
|
||||
|
@ -765,6 +765,67 @@ macro_rules! uint_impl {
|
||||
}
|
||||
}
|
||||
|
||||
#[doc = concat!(
|
||||
"Checked integer subtraction. Computes `self - rhs` and checks if the result fits into an [`",
|
||||
stringify!($SignedT), "`], returning `None` if overflow occurred."
|
||||
)]
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(unsigned_signed_diff)]
|
||||
#[doc = concat!("assert_eq!(10", stringify!($SelfT), ".checked_signed_diff(2), Some(8));")]
|
||||
#[doc = concat!("assert_eq!(2", stringify!($SelfT), ".checked_signed_diff(10), Some(-8));")]
|
||||
#[doc = concat!(
|
||||
"assert_eq!(",
|
||||
stringify!($SelfT),
|
||||
"::MAX.checked_signed_diff(",
|
||||
stringify!($SignedT),
|
||||
"::MAX as ",
|
||||
stringify!($SelfT),
|
||||
"), None);"
|
||||
)]
|
||||
#[doc = concat!(
|
||||
"assert_eq!((",
|
||||
stringify!($SignedT),
|
||||
"::MAX as ",
|
||||
stringify!($SelfT),
|
||||
").checked_signed_diff(",
|
||||
stringify!($SelfT),
|
||||
"::MAX), Some(",
|
||||
stringify!($SignedT),
|
||||
"::MIN));"
|
||||
)]
|
||||
#[doc = concat!(
|
||||
"assert_eq!((",
|
||||
stringify!($SignedT),
|
||||
"::MAX as ",
|
||||
stringify!($SelfT),
|
||||
" + 1).checked_signed_diff(0), None);"
|
||||
)]
|
||||
#[doc = concat!(
|
||||
"assert_eq!(",
|
||||
stringify!($SelfT),
|
||||
"::MAX.checked_signed_diff(",
|
||||
stringify!($SelfT),
|
||||
"::MAX), Some(0));"
|
||||
)]
|
||||
/// ```
|
||||
#[unstable(feature = "unsigned_signed_diff", issue = "126041")]
|
||||
#[inline]
|
||||
pub const fn checked_signed_diff(self, rhs: Self) -> Option<$SignedT> {
|
||||
let res = self.wrapping_sub(rhs) as $SignedT;
|
||||
let overflow = (self >= rhs) == (res < 0);
|
||||
|
||||
if !overflow {
|
||||
Some(res)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// Checked integer multiplication. Computes `self * rhs`, returning
|
||||
/// `None` if overflow occurred.
|
||||
///
|
||||
|
@ -428,7 +428,7 @@ impl<'a> ContextBuilder<'a> {
|
||||
/// [`Future::poll()`]: core::future::Future::poll
|
||||
/// [`Poll::Pending`]: core::task::Poll::Pending
|
||||
/// [`Wake`]: ../../alloc/task/trait.Wake.html
|
||||
#[cfg_attr(not(doc), repr(transparent))] // work around https://github.com/rust-lang/rust/issues/66401
|
||||
#[repr(transparent)]
|
||||
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||
pub struct Waker {
|
||||
waker: RawWaker,
|
||||
@ -692,7 +692,7 @@ impl fmt::Debug for Waker {
|
||||
/// [`Poll::Pending`]: core::task::Poll::Pending
|
||||
/// [`local_waker`]: core::task::Context::local_waker
|
||||
#[unstable(feature = "local_waker", issue = "118959")]
|
||||
#[cfg_attr(not(doc), repr(transparent))] // work around https://github.com/rust-lang/rust/issues/66401
|
||||
#[repr(transparent)]
|
||||
pub struct LocalWaker {
|
||||
waker: RawWaker,
|
||||
}
|
||||
|
@ -115,10 +115,8 @@ impl crate::sealed::Sealed for OsString {}
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
// `OsStr::from_inner` current implementation relies
|
||||
// on `OsStr` being layout-compatible with `Slice`.
|
||||
// However, `OsStr` layout is considered an implementation detail and must not be relied upon. We
|
||||
// want `repr(transparent)` but we don't want it to show up in rustdoc, so we hide it under
|
||||
// `cfg(doc)`. This is an ad-hoc implementation of attribute privacy.
|
||||
#[cfg_attr(not(doc), repr(transparent))]
|
||||
// However, `OsStr` layout is considered an implementation detail and must not be relied upon.
|
||||
#[repr(transparent)]
|
||||
pub struct OsStr {
|
||||
inner: Slice,
|
||||
}
|
||||
|
@ -2400,13 +2400,8 @@ pub fn create_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// This function will return an error in the following situations, but is not
|
||||
/// limited to just these cases:
|
||||
///
|
||||
/// * If any directory in the path specified by `path`
|
||||
/// does not already exist and it could not be created otherwise. The specific
|
||||
/// error conditions for when a directory is being created (after it is
|
||||
/// determined to not exist) are outlined by [`fs::create_dir`].
|
||||
/// The function will return an error if any directory specified in path does not exist and
|
||||
/// could not be created. There may be other error conditions; see [`fs::create_dir`] for specifics.
|
||||
///
|
||||
/// Notable exception is made for situations where any of the directories
|
||||
/// specified in the `path` could not be created as it was being created concurrently.
|
||||
|
@ -2079,10 +2079,8 @@ impl AsRef<OsStr> for PathBuf {
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
// `Path::new` current implementation relies
|
||||
// on `Path` being layout-compatible with `OsStr`.
|
||||
// However, `Path` layout is considered an implementation detail and must not be relied upon. We
|
||||
// want `repr(transparent)` but we don't want it to show up in rustdoc, so we hide it under
|
||||
// `cfg(doc)`. This is an ad-hoc implementation of attribute privacy.
|
||||
#[cfg_attr(not(doc), repr(transparent))]
|
||||
// However, `Path` layout is considered an implementation detail and must not be relied upon.
|
||||
#[repr(transparent)]
|
||||
pub struct Path {
|
||||
inner: OsStr,
|
||||
}
|
||||
|
@ -192,22 +192,14 @@ pub use scoped::{scope, Scope, ScopedJoinHandle};
|
||||
#[macro_use]
|
||||
mod local;
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(test)] {
|
||||
// Avoid duplicating the global state associated with thread-locals between this crate and
|
||||
// realstd. Miri relies on this.
|
||||
pub use realstd::thread::{local_impl, AccessError, LocalKey};
|
||||
} else {
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub use self::local::{AccessError, LocalKey};
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub use self::local::{AccessError, LocalKey};
|
||||
|
||||
// Implementation details used by the thread_local!{} macro.
|
||||
#[doc(hidden)]
|
||||
#[unstable(feature = "thread_local_internals", issue = "none")]
|
||||
pub mod local_impl {
|
||||
pub use crate::sys::thread_local::*;
|
||||
}
|
||||
}
|
||||
// Implementation details used by the thread_local!{} macro.
|
||||
#[doc(hidden)]
|
||||
#[unstable(feature = "thread_local_internals", issue = "none")]
|
||||
pub mod local_impl {
|
||||
pub use crate::sys::thread_local::*;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -122,8 +122,6 @@ note: ...which requires const checking `main::{constant#0}`...
|
||||
|
|
||||
LL | foo::<42>();
|
||||
| ^^
|
||||
= note: ...which requires computing whether `Foo` is freeze...
|
||||
= note: ...which requires evaluating trait selection obligation `Foo: core::marker::Freeze`...
|
||||
= note: ...which again requires computing type of opaque `Foo::{opaque#0}`, completing the cycle
|
||||
note: cycle used when computing type of `Foo::{opaque#0}`
|
||||
--> $DIR/opaque_types.rs:3:12
|
||||
|
@ -7,6 +7,8 @@
|
||||
/// to end up revealing opaque types (the RPIT in `many`'s return type),
|
||||
/// which can quickly lead to cycles.
|
||||
|
||||
//@ check-pass
|
||||
|
||||
pub struct Parser<H>(H);
|
||||
|
||||
impl<H, T> Parser<H>
|
||||
@ -18,7 +20,6 @@ where
|
||||
}
|
||||
|
||||
pub const fn many<'s>(&'s self) -> Parser<impl for<'a> Fn(&'a str) -> Vec<T> + 's> {
|
||||
//~^ ERROR: cycle detected
|
||||
Parser::new(|_| unimplemented!())
|
||||
}
|
||||
}
|
||||
|
@ -1,34 +0,0 @@
|
||||
error[E0391]: cycle detected when computing type of opaque `<impl at $DIR/const-fn-cycle.rs:12:1: 14:33>::many::{opaque#0}`
|
||||
--> $DIR/const-fn-cycle.rs:20:47
|
||||
|
|
||||
LL | pub const fn many<'s>(&'s self) -> Parser<impl for<'a> Fn(&'a str) -> Vec<T> + 's> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: ...which requires borrow-checking `<impl at $DIR/const-fn-cycle.rs:12:1: 14:33>::many`...
|
||||
--> $DIR/const-fn-cycle.rs:20:5
|
||||
|
|
||||
LL | pub const fn many<'s>(&'s self) -> Parser<impl for<'a> Fn(&'a str) -> Vec<T> + 's> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: ...which requires promoting constants in MIR for `<impl at $DIR/const-fn-cycle.rs:12:1: 14:33>::many`...
|
||||
--> $DIR/const-fn-cycle.rs:20:5
|
||||
|
|
||||
LL | pub const fn many<'s>(&'s self) -> Parser<impl for<'a> Fn(&'a str) -> Vec<T> + 's> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: ...which requires const checking `<impl at $DIR/const-fn-cycle.rs:12:1: 14:33>::many`...
|
||||
--> $DIR/const-fn-cycle.rs:20:5
|
||||
|
|
||||
LL | pub const fn many<'s>(&'s self) -> Parser<impl for<'a> Fn(&'a str) -> Vec<T> + 's> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: ...which requires computing whether `Parser<<impl at $DIR/const-fn-cycle.rs:12:1: 14:33>::many::{opaque#0}>` is freeze...
|
||||
= 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`...
|
||||
= 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
|
||||
note: cycle used when computing type of `<impl at $DIR/const-fn-cycle.rs:12:1: 14:33>::many::{opaque#0}`
|
||||
--> $DIR/const-fn-cycle.rs:20:47
|
||||
|
|
||||
LL | pub const fn many<'s>(&'s self) -> Parser<impl for<'a> Fn(&'a str) -> Vec<T> + 's> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0391`.
|
@ -1,5 +1,5 @@
|
||||
error[E0658]: cannot borrow here, since the borrowed element may contain interior mutability
|
||||
--> $DIR/const-promoted-opaque.rs:29:25
|
||||
--> $DIR/const-promoted-opaque.rs:28:25
|
||||
|
|
||||
LL | let _: &'static _ = &FOO;
|
||||
| ^^^^
|
||||
@ -9,7 +9,7 @@ LL | let _: &'static _ = &FOO;
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0493]: destructor of `helper::Foo` cannot be evaluated at compile-time
|
||||
--> $DIR/const-promoted-opaque.rs:29:26
|
||||
--> $DIR/const-promoted-opaque.rs:28:26
|
||||
|
|
||||
LL | let _: &'static _ = &FOO;
|
||||
| ^^^ the destructor for this type cannot be evaluated in constants
|
||||
@ -18,13 +18,13 @@ LL | };
|
||||
| - value is dropped here
|
||||
|
||||
error[E0492]: constants cannot refer to interior mutable data
|
||||
--> $DIR/const-promoted-opaque.rs:34:19
|
||||
--> $DIR/const-promoted-opaque.rs:33:19
|
||||
|
|
||||
LL | const BAZ: &Foo = &FOO;
|
||||
| ^^^^ this borrow of an interior mutable value may end up in the final value
|
||||
|
||||
error[E0716]: temporary value dropped while borrowed
|
||||
--> $DIR/const-promoted-opaque.rs:38:26
|
||||
--> $DIR/const-promoted-opaque.rs:37:26
|
||||
|
|
||||
LL | let _: &'static _ = &FOO;
|
||||
| ---------- ^^^ creates a temporary value which is freed while still in use
|
||||
@ -34,38 +34,7 @@ LL |
|
||||
LL | }
|
||||
| - temporary value is freed at the end of this statement
|
||||
|
||||
error[E0391]: cycle detected when computing type of opaque `helper::Foo::{opaque#0}`
|
||||
--> $DIR/const-promoted-opaque.rs:14:20
|
||||
|
|
||||
LL | pub type Foo = impl Sized;
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
note: ...which requires borrow-checking `helper::FOO`...
|
||||
--> $DIR/const-promoted-opaque.rs:21:5
|
||||
|
|
||||
LL | pub const FOO: Foo = std::sync::atomic::AtomicU8::new(42);
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
note: ...which requires promoting constants in MIR for `helper::FOO`...
|
||||
--> $DIR/const-promoted-opaque.rs:21:5
|
||||
|
|
||||
LL | pub const FOO: Foo = std::sync::atomic::AtomicU8::new(42);
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
note: ...which requires const checking `helper::FOO`...
|
||||
--> $DIR/const-promoted-opaque.rs:21:5
|
||||
|
|
||||
LL | pub const FOO: Foo = std::sync::atomic::AtomicU8::new(42);
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
= note: ...which requires computing whether `helper::Foo` is freeze...
|
||||
= note: ...which requires evaluating trait selection obligation `helper::Foo: core::marker::Freeze`...
|
||||
= note: ...which again requires computing type of opaque `helper::Foo::{opaque#0}`, completing the cycle
|
||||
note: cycle used when computing type of `helper::Foo::{opaque#0}`
|
||||
--> $DIR/const-promoted-opaque.rs:14:20
|
||||
|
|
||||
LL | pub type Foo = impl Sized;
|
||||
| ^^^^^^^^^^
|
||||
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0391, E0492, E0493, E0658, E0716.
|
||||
For more information about an error, try `rustc --explain E0391`.
|
||||
Some errors have detailed explanations: E0492, E0493, E0658, E0716.
|
||||
For more information about an error, try `rustc --explain E0492`.
|
||||
|
@ -12,7 +12,6 @@
|
||||
|
||||
mod helper {
|
||||
pub type Foo = impl Sized;
|
||||
//[string,atomic]~^ ERROR cycle detected
|
||||
|
||||
#[cfg(string)]
|
||||
pub const FOO: Foo = String::new();
|
||||
@ -28,11 +27,11 @@ use helper::*;
|
||||
const BAR: () = {
|
||||
let _: &'static _ = &FOO;
|
||||
//[string,atomic]~^ ERROR: destructor of `helper::Foo` cannot be evaluated at compile-time
|
||||
//[string,atomic]~| ERROR: cannot borrow here
|
||||
//[atomic]~| ERROR: cannot borrow here
|
||||
};
|
||||
|
||||
const BAZ: &Foo = &FOO;
|
||||
//[string,atomic]~^ ERROR: constants cannot refer to interior mutable data
|
||||
//[atomic]~^ ERROR: constants cannot refer to interior mutable data
|
||||
|
||||
fn main() {
|
||||
let _: &'static _ = &FOO;
|
||||
|
@ -1,15 +1,5 @@
|
||||
error[E0658]: cannot borrow here, since the borrowed element may contain interior mutability
|
||||
--> $DIR/const-promoted-opaque.rs:29:25
|
||||
|
|
||||
LL | let _: &'static _ = &FOO;
|
||||
| ^^^^
|
||||
|
|
||||
= note: see issue #80384 <https://github.com/rust-lang/rust/issues/80384> for more information
|
||||
= help: add `#![feature(const_refs_to_cell)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0493]: destructor of `helper::Foo` cannot be evaluated at compile-time
|
||||
--> $DIR/const-promoted-opaque.rs:29:26
|
||||
--> $DIR/const-promoted-opaque.rs:28:26
|
||||
|
|
||||
LL | let _: &'static _ = &FOO;
|
||||
| ^^^ the destructor for this type cannot be evaluated in constants
|
||||
@ -17,14 +7,8 @@ LL | let _: &'static _ = &FOO;
|
||||
LL | };
|
||||
| - value is dropped here
|
||||
|
||||
error[E0492]: constants cannot refer to interior mutable data
|
||||
--> $DIR/const-promoted-opaque.rs:34:19
|
||||
|
|
||||
LL | const BAZ: &Foo = &FOO;
|
||||
| ^^^^ this borrow of an interior mutable value may end up in the final value
|
||||
|
||||
error[E0716]: temporary value dropped while borrowed
|
||||
--> $DIR/const-promoted-opaque.rs:38:26
|
||||
--> $DIR/const-promoted-opaque.rs:37:26
|
||||
|
|
||||
LL | let _: &'static _ = &FOO;
|
||||
| ---------- ^^^ creates a temporary value which is freed while still in use
|
||||
@ -34,38 +18,7 @@ LL |
|
||||
LL | }
|
||||
| - temporary value is freed at the end of this statement
|
||||
|
||||
error[E0391]: cycle detected when computing type of opaque `helper::Foo::{opaque#0}`
|
||||
--> $DIR/const-promoted-opaque.rs:14:20
|
||||
|
|
||||
LL | pub type Foo = impl Sized;
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
note: ...which requires borrow-checking `helper::FOO`...
|
||||
--> $DIR/const-promoted-opaque.rs:18:5
|
||||
|
|
||||
LL | pub const FOO: Foo = String::new();
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
note: ...which requires promoting constants in MIR for `helper::FOO`...
|
||||
--> $DIR/const-promoted-opaque.rs:18:5
|
||||
|
|
||||
LL | pub const FOO: Foo = String::new();
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
note: ...which requires const checking `helper::FOO`...
|
||||
--> $DIR/const-promoted-opaque.rs:18:5
|
||||
|
|
||||
LL | pub const FOO: Foo = String::new();
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
= note: ...which requires computing whether `helper::Foo` is freeze...
|
||||
= note: ...which requires evaluating trait selection obligation `helper::Foo: core::marker::Freeze`...
|
||||
= note: ...which again requires computing type of opaque `helper::Foo::{opaque#0}`, completing the cycle
|
||||
note: cycle used when computing type of `helper::Foo::{opaque#0}`
|
||||
--> $DIR/const-promoted-opaque.rs:14:20
|
||||
|
|
||||
LL | pub type Foo = impl Sized;
|
||||
| ^^^^^^^^^^
|
||||
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0391, E0492, E0493, E0658, E0716.
|
||||
For more information about an error, try `rustc --explain E0391`.
|
||||
Some errors have detailed explanations: E0493, E0716.
|
||||
For more information about an error, try `rustc --explain E0493`.
|
||||
|
22
tests/ui/impl-trait/auto-trait-selection-freeze.next.stderr
Normal file
22
tests/ui/impl-trait/auto-trait-selection-freeze.next.stderr
Normal file
@ -0,0 +1,22 @@
|
||||
error[E0283]: type annotations needed
|
||||
--> $DIR/auto-trait-selection-freeze.rs:19:16
|
||||
|
|
||||
LL | if false { is_trait(foo()) } else { Default::default() }
|
||||
| ^^^^^^^^ ----- type must be known at this point
|
||||
| |
|
||||
| cannot infer type of the type parameter `T` declared on the function `is_trait`
|
||||
|
|
||||
= note: cannot satisfy `_: Trait<_>`
|
||||
note: required by a bound in `is_trait`
|
||||
--> $DIR/auto-trait-selection-freeze.rs:11:16
|
||||
|
|
||||
LL | fn is_trait<T: Trait<U>, U: Default>(_: T) -> U {
|
||||
| ^^^^^^^^ required by this bound in `is_trait`
|
||||
help: consider specifying the generic arguments
|
||||
|
|
||||
LL | if false { is_trait::<T, U>(foo()) } else { Default::default() }
|
||||
| ++++++++
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0283`.
|
26
tests/ui/impl-trait/auto-trait-selection-freeze.old.stderr
Normal file
26
tests/ui/impl-trait/auto-trait-selection-freeze.old.stderr
Normal file
@ -0,0 +1,26 @@
|
||||
error[E0283]: type annotations needed
|
||||
--> $DIR/auto-trait-selection-freeze.rs:19:16
|
||||
|
|
||||
LL | if false { is_trait(foo()) } else { Default::default() }
|
||||
| ^^^^^^^^ cannot infer type of the type parameter `U` declared on the function `is_trait`
|
||||
|
|
||||
note: multiple `impl`s satisfying `impl Sized: Trait<_>` found
|
||||
--> $DIR/auto-trait-selection-freeze.rs:16:1
|
||||
|
|
||||
LL | impl<T: Freeze> Trait<u32> for T {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | impl<T> Trait<i32> for T {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `is_trait`
|
||||
--> $DIR/auto-trait-selection-freeze.rs:11:16
|
||||
|
|
||||
LL | fn is_trait<T: Trait<U>, U: Default>(_: T) -> U {
|
||||
| ^^^^^^^^ required by this bound in `is_trait`
|
||||
help: consider specifying the generic arguments
|
||||
|
|
||||
LL | if false { is_trait::<_, U>(foo()) } else { Default::default() }
|
||||
| ++++++++
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0283`.
|
23
tests/ui/impl-trait/auto-trait-selection-freeze.rs
Normal file
23
tests/ui/impl-trait/auto-trait-selection-freeze.rs
Normal file
@ -0,0 +1,23 @@
|
||||
//! This test shows how we fail selection in a way that can influence
|
||||
//! selection in a code path that succeeds.
|
||||
|
||||
//@ revisions: next old
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
|
||||
#![feature(freeze)]
|
||||
|
||||
use std::marker::Freeze;
|
||||
|
||||
fn is_trait<T: Trait<U>, U: Default>(_: T) -> U {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
trait Trait<T> {}
|
||||
impl<T: Freeze> Trait<u32> for T {}
|
||||
impl<T> Trait<i32> for T {}
|
||||
fn foo() -> impl Sized {
|
||||
if false { is_trait(foo()) } else { Default::default() }
|
||||
//~^ ERROR: type annotations needed
|
||||
}
|
||||
|
||||
fn main() {}
|
22
tests/ui/impl-trait/auto-trait-selection.next.stderr
Normal file
22
tests/ui/impl-trait/auto-trait-selection.next.stderr
Normal file
@ -0,0 +1,22 @@
|
||||
error[E0283]: type annotations needed
|
||||
--> $DIR/auto-trait-selection.rs:15:16
|
||||
|
|
||||
LL | if false { is_trait(foo()) } else { Default::default() }
|
||||
| ^^^^^^^^ ----- type must be known at this point
|
||||
| |
|
||||
| cannot infer type of the type parameter `T` declared on the function `is_trait`
|
||||
|
|
||||
= note: cannot satisfy `_: Trait<_>`
|
||||
note: required by a bound in `is_trait`
|
||||
--> $DIR/auto-trait-selection.rs:7:16
|
||||
|
|
||||
LL | fn is_trait<T: Trait<U>, U: Default>(_: T) -> U {
|
||||
| ^^^^^^^^ required by this bound in `is_trait`
|
||||
help: consider specifying the generic arguments
|
||||
|
|
||||
LL | if false { is_trait::<T, U>(foo()) } else { Default::default() }
|
||||
| ++++++++
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0283`.
|
26
tests/ui/impl-trait/auto-trait-selection.old.stderr
Normal file
26
tests/ui/impl-trait/auto-trait-selection.old.stderr
Normal file
@ -0,0 +1,26 @@
|
||||
error[E0283]: type annotations needed
|
||||
--> $DIR/auto-trait-selection.rs:15:16
|
||||
|
|
||||
LL | if false { is_trait(foo()) } else { Default::default() }
|
||||
| ^^^^^^^^ cannot infer type of the type parameter `U` declared on the function `is_trait`
|
||||
|
|
||||
note: multiple `impl`s satisfying `impl Sized: Trait<_>` found
|
||||
--> $DIR/auto-trait-selection.rs:12:1
|
||||
|
|
||||
LL | impl<T: Send> Trait<u32> for T {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | impl<T> Trait<i32> for T {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `is_trait`
|
||||
--> $DIR/auto-trait-selection.rs:7:16
|
||||
|
|
||||
LL | fn is_trait<T: Trait<U>, U: Default>(_: T) -> U {
|
||||
| ^^^^^^^^ required by this bound in `is_trait`
|
||||
help: consider specifying the generic arguments
|
||||
|
|
||||
LL | if false { is_trait::<_, U>(foo()) } else { Default::default() }
|
||||
| ++++++++
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0283`.
|
19
tests/ui/impl-trait/auto-trait-selection.rs
Normal file
19
tests/ui/impl-trait/auto-trait-selection.rs
Normal file
@ -0,0 +1,19 @@
|
||||
//! This test shows how we fail selection in a way that can influence
|
||||
//! selection in a code path that succeeds.
|
||||
|
||||
//@ revisions: next old
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
|
||||
fn is_trait<T: Trait<U>, U: Default>(_: T) -> U {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
trait Trait<T> {}
|
||||
impl<T: Send> Trait<u32> for T {}
|
||||
impl<T> Trait<i32> for T {}
|
||||
fn foo() -> impl Sized {
|
||||
if false { is_trait(foo()) } else { Default::default() }
|
||||
//~^ ERROR: type annotations needed
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -1,5 +1,5 @@
|
||||
error[E0599]: no method named `my_debug` found for opaque type `impl Debug` in the current scope
|
||||
--> $DIR/call_method_on_inherent_impl_ref.rs:20:11
|
||||
--> $DIR/call_method_on_inherent_impl_ref.rs:19:11
|
||||
|
|
||||
LL | fn my_debug(&self);
|
||||
| -------- 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
|
||||
LL | trait MyDebug {
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error[E0391]: cycle detected when computing type of opaque `my_foo::{opaque#0}`
|
||||
--> $DIR/call_method_on_inherent_impl_ref.rs:15:16
|
||||
|
|
||||
LL | fn my_foo() -> impl std::fmt::Debug {
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: ...which requires type-checking `my_foo`...
|
||||
--> $DIR/call_method_on_inherent_impl_ref.rs:20:9
|
||||
|
|
||||
LL | x.my_debug();
|
||||
| ^
|
||||
= note: ...which requires evaluating trait selection obligation `my_foo::{opaque#0}: core::marker::Unpin`...
|
||||
= note: ...which again requires computing type of opaque `my_foo::{opaque#0}`, completing the cycle
|
||||
note: cycle used when computing type of `my_foo::{opaque#0}`
|
||||
--> $DIR/call_method_on_inherent_impl_ref.rs:15:16
|
||||
|
|
||||
LL | fn my_foo() -> impl std::fmt::Debug {
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0391, E0599.
|
||||
For more information about an error, try `rustc --explain E0391`.
|
||||
For more information about this error, try `rustc --explain E0599`.
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0282]: type annotations needed
|
||||
--> $DIR/call_method_on_inherent_impl_ref.rs:18:13
|
||||
--> $DIR/call_method_on_inherent_impl_ref.rs:17:13
|
||||
|
|
||||
LL | let x = my_foo();
|
||||
| ^
|
||||
@ -13,7 +13,7 @@ LL | let x: /* Type */ = my_foo();
|
||||
| ++++++++++++
|
||||
|
||||
error[E0282]: type annotations needed for `&_`
|
||||
--> $DIR/call_method_on_inherent_impl_ref.rs:28:13
|
||||
--> $DIR/call_method_on_inherent_impl_ref.rs:27:13
|
||||
|
|
||||
LL | let x = &my_bar();
|
||||
| ^
|
||||
|
@ -13,7 +13,6 @@ where
|
||||
}
|
||||
|
||||
fn my_foo() -> impl std::fmt::Debug {
|
||||
//[current]~^ cycle
|
||||
if false {
|
||||
let x = my_foo();
|
||||
//[next]~^ type annotations needed
|
||||
|
14
tests/ui/impl-trait/rpit/const_check_false_cycle.rs
Normal file
14
tests/ui/impl-trait/rpit/const_check_false_cycle.rs
Normal file
@ -0,0 +1,14 @@
|
||||
//! This test caused a cycle error when checking whether the
|
||||
//! return type is `Freeze` during const checking, even though
|
||||
//! the information is readily available.
|
||||
|
||||
//@ revisions: current next
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
//@ check-pass
|
||||
|
||||
const fn f() -> impl Eq {
|
||||
g()
|
||||
}
|
||||
const fn g() {}
|
||||
|
||||
fn main() {}
|
@ -5,7 +5,7 @@ LL | let x = hello();
|
||||
| ^^^^^^^ types differ
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/unsized_coercion3.rs:19:14
|
||||
--> $DIR/unsized_coercion3.rs:18:14
|
||||
|
|
||||
LL | fn hello() -> Box<impl Trait + ?Sized> {
|
||||
| ------------------- the expected opaque type
|
||||
@ -21,7 +21,7 @@ note: associated function defined here
|
||||
--> $SRC_DIR/alloc/src/boxed.rs:LL:COL
|
||||
|
||||
error[E0277]: the size for values of type `impl Trait + ?Sized` cannot be known at compilation time
|
||||
--> $DIR/unsized_coercion3.rs:19:14
|
||||
--> $DIR/unsized_coercion3.rs:18:14
|
||||
|
|
||||
LL | Box::new(1u32)
|
||||
| -------- ^^^^ doesn't have a size known at compile-time
|
||||
|
@ -1,17 +1,3 @@
|
||||
error: cannot check whether the hidden type of opaque type satisfies auto traits
|
||||
--> $DIR/unsized_coercion3.rs:15:32
|
||||
|
|
||||
LL | let y: Box<dyn Send> = x;
|
||||
| ^
|
||||
|
|
||||
= 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
|
||||
note: opaque type is declared here
|
||||
--> $DIR/unsized_coercion3.rs:11:19
|
||||
|
|
||||
LL | fn hello() -> Box<impl Trait + ?Sized> {
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
= note: required for the cast from `Box<impl Trait + ?Sized>` to `Box<dyn Send>`
|
||||
|
||||
error[E0277]: the size for values of type `impl Trait + ?Sized` cannot be known at compilation time
|
||||
--> $DIR/unsized_coercion3.rs:15:32
|
||||
|
|
||||
@ -21,6 +7,6 @@ LL | let y: Box<dyn Send> = x;
|
||||
= help: the trait `Sized` is not implemented for `impl Trait + ?Sized`
|
||||
= note: required for the cast from `Box<impl Trait + ?Sized>` to `Box<dyn Send>`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
@ -14,7 +14,6 @@ fn hello() -> Box<impl Trait + ?Sized> {
|
||||
//[next]~^ ERROR: type mismatch resolving `impl Trait + ?Sized <: dyn Send`
|
||||
let y: Box<dyn Send> = x;
|
||||
//[old]~^ ERROR: the size for values of type `impl Trait + ?Sized` cannot be know
|
||||
//[old]~| ERROR: cannot check whether the hidden type of opaque type satisfies auto traits
|
||||
}
|
||||
Box::new(1u32)
|
||||
//[next]~^ ERROR: mismatched types
|
||||
|
@ -9,20 +9,6 @@ LL | let y: Box<dyn Send> = x as Box<dyn Trait + Send>;
|
||||
= note: expected struct `Box<dyn Send>`
|
||||
found struct `Box<dyn Trait + Send>`
|
||||
|
||||
error: cannot check whether the hidden type of opaque type satisfies auto traits
|
||||
--> $DIR/unsized_coercion5.rs:16:32
|
||||
|
|
||||
LL | let y: Box<dyn Send> = x as Box<dyn Trait + Send>;
|
||||
| ^
|
||||
|
|
||||
= 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
|
||||
note: opaque type is declared here
|
||||
--> $DIR/unsized_coercion5.rs:13:19
|
||||
|
|
||||
LL | fn hello() -> Box<impl Trait + ?Sized> {
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
= note: required for the cast from `Box<impl Trait + ?Sized>` to `Box<dyn Trait + Send>`
|
||||
|
||||
error[E0277]: the size for values of type `impl Trait + ?Sized` cannot be known at compilation time
|
||||
--> $DIR/unsized_coercion5.rs:16:32
|
||||
|
|
||||
@ -32,7 +18,7 @@ LL | let y: Box<dyn Send> = x as Box<dyn Trait + Send>;
|
||||
= help: the trait `Sized` is not implemented for `impl Trait + ?Sized`
|
||||
= note: required for the cast from `Box<impl Trait + ?Sized>` to `Box<dyn Trait + Send>`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0277, E0308.
|
||||
For more information about an error, try `rustc --explain E0277`.
|
||||
|
@ -15,8 +15,7 @@ fn hello() -> Box<impl Trait + ?Sized> {
|
||||
let x = hello();
|
||||
let y: Box<dyn Send> = x as Box<dyn Trait + Send>;
|
||||
//[old]~^ ERROR: the size for values of type `impl Trait + ?Sized` cannot be know
|
||||
//[old]~| ERROR: cannot check whether the hidden type of opaque type satisfies auto traits
|
||||
//~^^^ ERROR: mismatched types
|
||||
//~^^ ERROR: mismatched types
|
||||
}
|
||||
Box::new(1u32)
|
||||
}
|
||||
|
@ -55,6 +55,21 @@ LL | #[warn(incomplete_include)]
|
||||
warning: 4 warnings emitted
|
||||
|
||||
Future incompatibility report: Future breakage diagnostic:
|
||||
warning: missing fragment specifier
|
||||
--> $DIR/expansion-time.rs:9:19
|
||||
|
|
||||
LL | macro_rules! m { ($i) => {} }
|
||||
| ^^
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
|
||||
note: the lint level is defined here
|
||||
--> $DIR/expansion-time.rs:8:8
|
||||
|
|
||||
LL | #[warn(missing_fragment_specifier)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Future breakage diagnostic:
|
||||
warning: use of unstable library feature 'test': `bench` is a part of custom test frameworks which are unstable
|
||||
--> $DIR/expansion-time.rs:14:7
|
||||
|
|
||||
|
@ -10,3 +10,14 @@ LL | macro_rules! m { ($i) => {} }
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
Future incompatibility report: Future breakage diagnostic:
|
||||
error: missing fragment specifier
|
||||
--> $DIR/issue-39404.rs:3:19
|
||||
|
|
||||
LL | macro_rules! m { ($i) => {} }
|
||||
| ^^
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
|
||||
= note: `#[deny(missing_fragment_specifier)]` on by default
|
||||
|
||||
|
@ -25,3 +25,25 @@ LL | ($a, $b) => {
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Future incompatibility report: Future breakage diagnostic:
|
||||
error: missing fragment specifier
|
||||
--> $DIR/macro-match-nonterminal.rs:2:8
|
||||
|
|
||||
LL | ($a, $b) => {
|
||||
| ^
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
|
||||
= note: `#[deny(missing_fragment_specifier)]` on by default
|
||||
|
||||
Future breakage diagnostic:
|
||||
error: missing fragment specifier
|
||||
--> $DIR/macro-match-nonterminal.rs:2:10
|
||||
|
|
||||
LL | ($a, $b) => {
|
||||
| ^^
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
|
||||
= note: `#[deny(missing_fragment_specifier)]` on by default
|
||||
|
||||
|
@ -16,3 +16,14 @@ LL | ($name) => {}
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Future incompatibility report: Future breakage diagnostic:
|
||||
error: missing fragment specifier
|
||||
--> $DIR/macro-missing-fragment-deduplication.rs:4:6
|
||||
|
|
||||
LL | ($name) => {}
|
||||
| ^^^^^
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
|
||||
= note: `#[deny(missing_fragment_specifier)]` on by default
|
||||
|
||||
|
@ -38,3 +38,48 @@ LL | ( $name ) => {};
|
||||
|
||||
error: aborting due to 1 previous error; 3 warnings emitted
|
||||
|
||||
Future incompatibility report: Future breakage diagnostic:
|
||||
warning: missing fragment specifier
|
||||
--> $DIR/macro-missing-fragment.rs:4:20
|
||||
|
|
||||
LL | ( $( any_token $field_rust_type )* ) => {};
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
|
||||
note: the lint level is defined here
|
||||
--> $DIR/macro-missing-fragment.rs:1:9
|
||||
|
|
||||
LL | #![warn(missing_fragment_specifier)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Future breakage diagnostic:
|
||||
warning: missing fragment specifier
|
||||
--> $DIR/macro-missing-fragment.rs:12:7
|
||||
|
|
||||
LL | ( $name ) => {};
|
||||
| ^^^^^
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
|
||||
note: the lint level is defined here
|
||||
--> $DIR/macro-missing-fragment.rs:1:9
|
||||
|
|
||||
LL | #![warn(missing_fragment_specifier)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Future breakage diagnostic:
|
||||
warning: missing fragment specifier
|
||||
--> $DIR/macro-missing-fragment.rs:18:7
|
||||
|
|
||||
LL | ( $name ) => {};
|
||||
| ^^^^^
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
|
||||
note: the lint level is defined here
|
||||
--> $DIR/macro-missing-fragment.rs:1:9
|
||||
|
|
||||
LL | #![warn(missing_fragment_specifier)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
@ -28,3 +28,14 @@ LL | { $+ } => {
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Future incompatibility report: Future breakage diagnostic:
|
||||
error: missing fragment specifier
|
||||
--> $DIR/issue-33569.rs:2:8
|
||||
|
|
||||
LL | { $+ } => {
|
||||
| ^
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107>
|
||||
= note: `#[deny(missing_fragment_specifier)]` on by default
|
||||
|
||||
|
@ -9,7 +9,6 @@ impl MyTrait for i32 {
|
||||
//~| ERROR functions in trait impls cannot be declared const
|
||||
//~| ERROR functions cannot be both `const` and `async`
|
||||
//~| ERROR method `bar` is not a member
|
||||
//~| ERROR cycle detected when computing type
|
||||
main8().await;
|
||||
//~^ ERROR cannot find function
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ error: using `#![feature(effects)]` without enabling next trait solver globally
|
||||
= help: use `-Znext-solver` to enable
|
||||
|
||||
error[E0425]: cannot find function `main8` in this scope
|
||||
--> $DIR/ice-120503-async-const-method.rs:13:9
|
||||
--> $DIR/ice-120503-async-const-method.rs:12:9
|
||||
|
|
||||
LL | main8().await;
|
||||
| ^^^^^ help: a function with a similar name exists: `main`
|
||||
@ -69,38 +69,7 @@ LL | main8().await;
|
||||
LL | fn main() {}
|
||||
| --------- similarly named function `main` defined here
|
||||
|
||||
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}`
|
||||
--> $DIR/ice-120503-async-const-method.rs:7:5
|
||||
|
|
||||
LL | async const fn bar(&self) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: ...which requires borrow-checking `<impl at $DIR/ice-120503-async-const-method.rs:6:1: 6:21>::bar`...
|
||||
--> $DIR/ice-120503-async-const-method.rs:7:5
|
||||
|
|
||||
LL | async const fn bar(&self) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: ...which requires promoting constants in MIR for `<impl at $DIR/ice-120503-async-const-method.rs:6:1: 6:21>::bar`...
|
||||
--> $DIR/ice-120503-async-const-method.rs:7:5
|
||||
|
|
||||
LL | async const fn bar(&self) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: ...which requires const checking `<impl at $DIR/ice-120503-async-const-method.rs:6:1: 6:21>::bar`...
|
||||
--> $DIR/ice-120503-async-const-method.rs:7:5
|
||||
|
|
||||
LL | async const fn bar(&self) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: ...which requires computing whether `<impl at $DIR/ice-120503-async-const-method.rs:6:1: 6:21>::bar::{opaque#0}` is freeze...
|
||||
= 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`...
|
||||
= 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
|
||||
note: cycle used when computing type of `<impl at $DIR/ice-120503-async-const-method.rs:6:1: 6:21>::bar::{opaque#0}`
|
||||
--> $DIR/ice-120503-async-const-method.rs:7:5
|
||||
|
|
||||
LL | async const fn bar(&self) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
|
||||
error: aborting due to 6 previous errors; 1 warning emitted
|
||||
|
||||
error: aborting due to 7 previous errors; 1 warning emitted
|
||||
|
||||
Some errors have detailed explanations: E0379, E0391, E0407, E0425.
|
||||
Some errors have detailed explanations: E0379, E0407, E0425.
|
||||
For more information about an error, try `rustc --explain E0379`.
|
||||
|
@ -0,0 +1,39 @@
|
||||
// Regression test for #127441
|
||||
|
||||
// Tests that we make the correct suggestion
|
||||
// in case there are more than one `?Sized`
|
||||
// bounds on a function parameter
|
||||
|
||||
use std::fmt::Debug;
|
||||
|
||||
fn foo1<T: ?Sized>(a: T) {}
|
||||
//~^ ERROR he size for values of type `T` cannot be known at compilation time
|
||||
|
||||
fn foo2<T: ?Sized + ?Sized>(a: T) {}
|
||||
//~^ ERROR type parameter has more than one relaxed default bound, only one is supported
|
||||
//~| ERROR the size for values of type `T` cannot be known at compilation time
|
||||
|
||||
fn foo3<T: ?Sized + ?Sized + Debug>(a: T) {}
|
||||
//~^ ERROR type parameter has more than one relaxed default bound, only one is supported
|
||||
//~| ERROR he size for values of type `T` cannot be known at compilation time
|
||||
|
||||
fn foo4<T: ?Sized + Debug + ?Sized >(a: T) {}
|
||||
//~^ ERROR type parameter has more than one relaxed default bound, only one is supported
|
||||
//~| ERROR the size for values of type `T` cannot be known at compilation time
|
||||
|
||||
fn foo5(_: impl ?Sized) {}
|
||||
//~^ ERROR the size for values of type `impl ?Sized` cannot be known at compilation time
|
||||
|
||||
fn foo6(_: impl ?Sized + ?Sized) {}
|
||||
//~^ ERROR type parameter has more than one relaxed default bound, only one is supported
|
||||
//~| ERROR the size for values of type `impl ?Sized + ?Sized` cannot be known at compilation tim
|
||||
|
||||
fn foo7(_: impl ?Sized + ?Sized + Debug) {}
|
||||
//~^ ERROR type parameter has more than one relaxed default bound, only one is supported
|
||||
//~| ERROR the size for values of type `impl ?Sized + ?Sized + Debug` cannot be known at compilation time
|
||||
|
||||
fn foo8(_: impl ?Sized + Debug + ?Sized ) {}
|
||||
//~^ ERROR type parameter has more than one relaxed default bound, only one is supported
|
||||
//~| ERROR the size for values of type `impl ?Sized + Debug + ?Sized` cannot be known at compilation time
|
||||
|
||||
fn main() {}
|
@ -0,0 +1,192 @@
|
||||
error[E0203]: type parameter has more than one relaxed default bound, only one is supported
|
||||
--> $DIR/bad-suggestionf-for-repeated-unsized-bound-127441.rs:12:12
|
||||
|
|
||||
LL | fn foo2<T: ?Sized + ?Sized>(a: T) {}
|
||||
| ^^^^^^ ^^^^^^
|
||||
|
||||
error[E0203]: type parameter has more than one relaxed default bound, only one is supported
|
||||
--> $DIR/bad-suggestionf-for-repeated-unsized-bound-127441.rs:16:12
|
||||
|
|
||||
LL | fn foo3<T: ?Sized + ?Sized + Debug>(a: T) {}
|
||||
| ^^^^^^ ^^^^^^
|
||||
|
||||
error[E0203]: type parameter has more than one relaxed default bound, only one is supported
|
||||
--> $DIR/bad-suggestionf-for-repeated-unsized-bound-127441.rs:20:12
|
||||
|
|
||||
LL | fn foo4<T: ?Sized + Debug + ?Sized >(a: T) {}
|
||||
| ^^^^^^ ^^^^^^
|
||||
|
||||
error[E0203]: type parameter has more than one relaxed default bound, only one is supported
|
||||
--> $DIR/bad-suggestionf-for-repeated-unsized-bound-127441.rs:27:17
|
||||
|
|
||||
LL | fn foo6(_: impl ?Sized + ?Sized) {}
|
||||
| ^^^^^^ ^^^^^^
|
||||
|
||||
error[E0203]: type parameter has more than one relaxed default bound, only one is supported
|
||||
--> $DIR/bad-suggestionf-for-repeated-unsized-bound-127441.rs:31:17
|
||||
|
|
||||
LL | fn foo7(_: impl ?Sized + ?Sized + Debug) {}
|
||||
| ^^^^^^ ^^^^^^
|
||||
|
||||
error[E0203]: type parameter has more than one relaxed default bound, only one is supported
|
||||
--> $DIR/bad-suggestionf-for-repeated-unsized-bound-127441.rs:35:17
|
||||
|
|
||||
LL | fn foo8(_: impl ?Sized + Debug + ?Sized ) {}
|
||||
| ^^^^^^ ^^^^^^
|
||||
|
||||
error[E0277]: the size for values of type `T` cannot be known at compilation time
|
||||
--> $DIR/bad-suggestionf-for-repeated-unsized-bound-127441.rs:9:20
|
||||
|
|
||||
LL | fn foo1<T: ?Sized>(a: T) {}
|
||||
| - ^ doesn't have a size known at compile-time
|
||||
| |
|
||||
| this type parameter needs to be `Sized`
|
||||
|
|
||||
= help: unsized fn params are gated as an unstable feature
|
||||
help: consider removing the `?Sized` bound to make the type parameter `Sized`
|
||||
|
|
||||
LL - fn foo1<T: ?Sized>(a: T) {}
|
||||
LL + fn foo1<T>(a: T) {}
|
||||
|
|
||||
help: function arguments must have a statically known size, borrowed types always have a known size
|
||||
|
|
||||
LL | fn foo1<T: ?Sized>(a: &T) {}
|
||||
| +
|
||||
|
||||
error[E0277]: the size for values of type `T` cannot be known at compilation time
|
||||
--> $DIR/bad-suggestionf-for-repeated-unsized-bound-127441.rs:12:29
|
||||
|
|
||||
LL | fn foo2<T: ?Sized + ?Sized>(a: T) {}
|
||||
| - ^ doesn't have a size known at compile-time
|
||||
| |
|
||||
| this type parameter needs to be `Sized`
|
||||
|
|
||||
= help: unsized fn params are gated as an unstable feature
|
||||
help: consider removing the `?Sized` bound to make the type parameter `Sized`
|
||||
|
|
||||
LL - fn foo2<T: ?Sized + ?Sized>(a: T) {}
|
||||
LL + fn foo2<T>(a: T) {}
|
||||
|
|
||||
help: function arguments must have a statically known size, borrowed types always have a known size
|
||||
|
|
||||
LL | fn foo2<T: ?Sized + ?Sized>(a: &T) {}
|
||||
| +
|
||||
|
||||
error[E0277]: the size for values of type `T` cannot be known at compilation time
|
||||
--> $DIR/bad-suggestionf-for-repeated-unsized-bound-127441.rs:16:37
|
||||
|
|
||||
LL | fn foo3<T: ?Sized + ?Sized + Debug>(a: T) {}
|
||||
| - ^ doesn't have a size known at compile-time
|
||||
| |
|
||||
| this type parameter needs to be `Sized`
|
||||
|
|
||||
= help: unsized fn params are gated as an unstable feature
|
||||
help: consider restricting type parameters
|
||||
|
|
||||
LL - fn foo3<T: ?Sized + ?Sized + Debug>(a: T) {}
|
||||
LL + fn foo3<T: Debug>(a: T) {}
|
||||
|
|
||||
help: function arguments must have a statically known size, borrowed types always have a known size
|
||||
|
|
||||
LL | fn foo3<T: ?Sized + ?Sized + Debug>(a: &T) {}
|
||||
| +
|
||||
|
||||
error[E0277]: the size for values of type `T` cannot be known at compilation time
|
||||
--> $DIR/bad-suggestionf-for-repeated-unsized-bound-127441.rs:20:38
|
||||
|
|
||||
LL | fn foo4<T: ?Sized + Debug + ?Sized >(a: T) {}
|
||||
| - ^ doesn't have a size known at compile-time
|
||||
| |
|
||||
| this type parameter needs to be `Sized`
|
||||
|
|
||||
= help: unsized fn params are gated as an unstable feature
|
||||
help: consider restricting type parameters
|
||||
|
|
||||
LL - fn foo4<T: ?Sized + Debug + ?Sized >(a: T) {}
|
||||
LL + fn foo4<T: Debug >(a: T) {}
|
||||
|
|
||||
help: function arguments must have a statically known size, borrowed types always have a known size
|
||||
|
|
||||
LL | fn foo4<T: ?Sized + Debug + ?Sized >(a: &T) {}
|
||||
| +
|
||||
|
||||
error[E0277]: the size for values of type `impl ?Sized` cannot be known at compilation time
|
||||
--> $DIR/bad-suggestionf-for-repeated-unsized-bound-127441.rs:24:9
|
||||
|
|
||||
LL | fn foo5(_: impl ?Sized) {}
|
||||
| ^ ----------- this type parameter needs to be `Sized`
|
||||
| |
|
||||
| doesn't have a size known at compile-time
|
||||
|
|
||||
= help: unsized fn params are gated as an unstable feature
|
||||
help: consider replacing `?Sized` with `Sized`
|
||||
|
|
||||
LL - fn foo5(_: impl ?Sized) {}
|
||||
LL + fn foo5(_: impl Sized) {}
|
||||
|
|
||||
help: function arguments must have a statically known size, borrowed types always have a known size
|
||||
|
|
||||
LL | fn foo5(_: &impl ?Sized) {}
|
||||
| +
|
||||
|
||||
error[E0277]: the size for values of type `impl ?Sized + ?Sized` cannot be known at compilation time
|
||||
--> $DIR/bad-suggestionf-for-repeated-unsized-bound-127441.rs:27:9
|
||||
|
|
||||
LL | fn foo6(_: impl ?Sized + ?Sized) {}
|
||||
| ^ -------------------- this type parameter needs to be `Sized`
|
||||
| |
|
||||
| doesn't have a size known at compile-time
|
||||
|
|
||||
= help: unsized fn params are gated as an unstable feature
|
||||
help: consider restricting type parameters
|
||||
|
|
||||
LL - fn foo6(_: impl ?Sized + ?Sized) {}
|
||||
LL + fn foo6(_: impl Sized) {}
|
||||
|
|
||||
help: function arguments must have a statically known size, borrowed types always have a known size
|
||||
|
|
||||
LL | fn foo6(_: &impl ?Sized + ?Sized) {}
|
||||
| +
|
||||
|
||||
error[E0277]: the size for values of type `impl ?Sized + ?Sized + Debug` cannot be known at compilation time
|
||||
--> $DIR/bad-suggestionf-for-repeated-unsized-bound-127441.rs:31:9
|
||||
|
|
||||
LL | fn foo7(_: impl ?Sized + ?Sized + Debug) {}
|
||||
| ^ ---------------------------- this type parameter needs to be `Sized`
|
||||
| |
|
||||
| doesn't have a size known at compile-time
|
||||
|
|
||||
= help: unsized fn params are gated as an unstable feature
|
||||
help: consider restricting type parameters
|
||||
|
|
||||
LL - fn foo7(_: impl ?Sized + ?Sized + Debug) {}
|
||||
LL + fn foo7(_: impl Debug) {}
|
||||
|
|
||||
help: function arguments must have a statically known size, borrowed types always have a known size
|
||||
|
|
||||
LL | fn foo7(_: &impl ?Sized + ?Sized + Debug) {}
|
||||
| +
|
||||
|
||||
error[E0277]: the size for values of type `impl ?Sized + Debug + ?Sized` cannot be known at compilation time
|
||||
--> $DIR/bad-suggestionf-for-repeated-unsized-bound-127441.rs:35:9
|
||||
|
|
||||
LL | fn foo8(_: impl ?Sized + Debug + ?Sized ) {}
|
||||
| ^ ---------------------------- this type parameter needs to be `Sized`
|
||||
| |
|
||||
| doesn't have a size known at compile-time
|
||||
|
|
||||
= help: unsized fn params are gated as an unstable feature
|
||||
help: consider restricting type parameters
|
||||
|
|
||||
LL - fn foo8(_: impl ?Sized + Debug + ?Sized ) {}
|
||||
LL + fn foo8(_: impl Debug ) {}
|
||||
|
|
||||
help: function arguments must have a statically known size, borrowed types always have a known size
|
||||
|
|
||||
LL | fn foo8(_: &impl ?Sized + Debug + ?Sized ) {}
|
||||
| +
|
||||
|
||||
error: aborting due to 14 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0203, E0277.
|
||||
For more information about an error, try `rustc --explain E0203`.
|
@ -4,13 +4,13 @@
|
||||
#![feature(type_alias_impl_trait)]
|
||||
type Bar = impl Sized;
|
||||
//~^ ERROR: cycle
|
||||
//~| ERROR: cycle
|
||||
|
||||
fn foo() -> Bar
|
||||
where
|
||||
Bar: Send,
|
||||
{
|
||||
[0; 1 + 2]
|
||||
//~^ ERROR: type annotations needed: cannot satisfy `Bar: Send`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -10,7 +10,7 @@ note: ...which requires computing type of opaque `Bar::{opaque#0}`...
|
||||
LL | type Bar = impl Sized;
|
||||
| ^^^^^^^^^^
|
||||
note: ...which requires type-checking `foo`...
|
||||
--> $DIR/in-where-clause.rs:9:1
|
||||
--> $DIR/in-where-clause.rs:8:1
|
||||
|
|
||||
LL | / fn foo() -> Bar
|
||||
LL | | where
|
||||
@ -25,26 +25,23 @@ LL | type Bar = impl Sized;
|
||||
| ^^^^^^^^^^
|
||||
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
|
||||
|
||||
error[E0391]: cycle detected when computing type of opaque `Bar::{opaque#0}`
|
||||
--> $DIR/in-where-clause.rs:5:12
|
||||
|
|
||||
LL | type Bar = impl Sized;
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
note: ...which requires type-checking `foo`...
|
||||
--> $DIR/in-where-clause.rs:13:9
|
||||
error[E0283]: type annotations needed: cannot satisfy `Bar: Send`
|
||||
--> $DIR/in-where-clause.rs:12:9
|
||||
|
|
||||
LL | [0; 1 + 2]
|
||||
| ^^^^^
|
||||
= note: ...which requires evaluating trait selection obligation `Bar: core::marker::Send`...
|
||||
= note: ...which again requires computing type of opaque `Bar::{opaque#0}`, completing the cycle
|
||||
note: cycle used when computing type of `Bar::{opaque#0}`
|
||||
--> $DIR/in-where-clause.rs:5:12
|
||||
|
|
||||
LL | type Bar = impl Sized;
|
||||
| ^^^^^^^^^^
|
||||
= 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
|
||||
= note: cannot satisfy `Bar: Send`
|
||||
note: required by a bound in `foo`
|
||||
--> $DIR/in-where-clause.rs:10:10
|
||||
|
|
||||
LL | fn foo() -> Bar
|
||||
| --- required by a bound in this function
|
||||
LL | where
|
||||
LL | Bar: Send,
|
||||
| ^^^^ required by this bound in `foo`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0391`.
|
||||
Some errors have detailed explanations: E0283, E0391.
|
||||
For more information about an error, try `rustc --explain E0283`.
|
||||
|
@ -20,7 +20,7 @@ fn not_gooder() -> Foo {
|
||||
// while we could know this from the hidden type, it would
|
||||
// need extra roundabout logic to support it.
|
||||
is_send::<Foo>();
|
||||
//~^ ERROR: cannot check whether the hidden type of `reveal_local[9507]::Foo::{opaque#0}` satisfies auto traits
|
||||
//~^ ERROR: type annotations needed: cannot satisfy `Foo: Send`
|
||||
|
||||
x
|
||||
}
|
||||
|
@ -16,18 +16,13 @@ note: required by a bound in `is_send`
|
||||
LL | fn is_send<T: Send>() {}
|
||||
| ^^^^ required by this bound in `is_send`
|
||||
|
||||
error: cannot check whether the hidden type of `reveal_local[9507]::Foo::{opaque#0}` satisfies auto traits
|
||||
error[E0283]: type annotations needed: cannot satisfy `Foo: Send`
|
||||
--> $DIR/reveal_local.rs:22:15
|
||||
|
|
||||
LL | is_send::<Foo>();
|
||||
| ^^^
|
||||
|
|
||||
= 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
|
||||
note: opaque type is declared here
|
||||
--> $DIR/reveal_local.rs:5:12
|
||||
|
|
||||
LL | type Foo = impl Debug;
|
||||
| ^^^^^^^^^^
|
||||
= note: cannot satisfy `Foo: Send`
|
||||
note: required by a bound in `is_send`
|
||||
--> $DIR/reveal_local.rs:7:15
|
||||
|
|
||||
@ -36,3 +31,4 @@ LL | fn is_send<T: Send>() {}
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0283`.
|
||||
|
Loading…
Reference in New Issue
Block a user