mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-19 18:34:08 +00:00
Auto merge of #112624 - matthiaskrgr:rollup-db6ta1b, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #98202 (Implement `TryFrom<&OsStr>` for `&str`) - #107619 (Specify behavior of HashSet::insert) - #109814 (Stabilize String::leak) - #111974 (Update runtime guarantee for `select_nth_unstable`) - #112109 (Don't print unsupported split-debuginfo modes with `-Zunstable-options`) - #112506 (Properly check associated consts for infer placeholders) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
0b475c705f
@ -771,9 +771,7 @@ fn print_crate_info(
|
|||||||
use rustc_target::spec::SplitDebuginfo::{Off, Packed, Unpacked};
|
use rustc_target::spec::SplitDebuginfo::{Off, Packed, Unpacked};
|
||||||
|
|
||||||
for split in &[Off, Packed, Unpacked] {
|
for split in &[Off, Packed, Unpacked] {
|
||||||
let stable = sess.target.options.supported_split_debuginfo.contains(split);
|
if sess.target.options.supported_split_debuginfo.contains(split) {
|
||||||
let unstable_ok = sess.unstable_options();
|
|
||||||
if stable || unstable_ok {
|
|
||||||
safe_println!("{split}");
|
safe_println!("{split}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -666,17 +666,15 @@ fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::TraitItemId) {
|
|||||||
tcx.ensure().fn_sig(def_id);
|
tcx.ensure().fn_sig(def_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
hir::TraitItemKind::Const(.., Some(_)) => {
|
hir::TraitItemKind::Const(ty, body_id) => {
|
||||||
tcx.ensure().type_of(def_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
hir::TraitItemKind::Const(hir_ty, _) => {
|
|
||||||
tcx.ensure().type_of(def_id);
|
tcx.ensure().type_of(def_id);
|
||||||
|
if !tcx.sess.diagnostic().has_stashed_diagnostic(ty.span, StashKey::ItemNoType)
|
||||||
|
&& !(is_suggestable_infer_ty(ty) && body_id.is_some())
|
||||||
|
{
|
||||||
// Account for `const C: _;`.
|
// Account for `const C: _;`.
|
||||||
let mut visitor = HirPlaceholderCollector::default();
|
let mut visitor = HirPlaceholderCollector::default();
|
||||||
visitor.visit_trait_item(trait_item);
|
visitor.visit_trait_item(trait_item);
|
||||||
if !tcx.sess.diagnostic().has_stashed_diagnostic(hir_ty.span, StashKey::ItemNoType) {
|
placeholder_type_error(tcx, None, visitor.0, false, None, "associated constant");
|
||||||
placeholder_type_error(tcx, None, visitor.0, false, None, "constant");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -721,7 +719,14 @@ fn convert_impl_item(tcx: TyCtxt<'_>, impl_item_id: hir::ImplItemId) {
|
|||||||
|
|
||||||
placeholder_type_error(tcx, None, visitor.0, false, None, "associated type");
|
placeholder_type_error(tcx, None, visitor.0, false, None, "associated type");
|
||||||
}
|
}
|
||||||
hir::ImplItemKind::Const(..) => {}
|
hir::ImplItemKind::Const(ty, _) => {
|
||||||
|
// Account for `const T: _ = ..;`
|
||||||
|
if !is_suggestable_infer_ty(ty) {
|
||||||
|
let mut visitor = HirPlaceholderCollector::default();
|
||||||
|
visitor.visit_impl_item(impl_item);
|
||||||
|
placeholder_type_error(tcx, None, visitor.0, false, None, "associated constant");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -341,7 +341,12 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<Ty
|
|||||||
.and_then(|body_id| {
|
.and_then(|body_id| {
|
||||||
is_suggestable_infer_ty(ty).then(|| {
|
is_suggestable_infer_ty(ty).then(|| {
|
||||||
infer_placeholder_type(
|
infer_placeholder_type(
|
||||||
tcx, def_id, body_id, ty.span, item.ident, "constant",
|
tcx,
|
||||||
|
def_id,
|
||||||
|
body_id,
|
||||||
|
ty.span,
|
||||||
|
item.ident,
|
||||||
|
"associated constant",
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -359,7 +364,14 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<Ty
|
|||||||
}
|
}
|
||||||
ImplItemKind::Const(ty, body_id) => {
|
ImplItemKind::Const(ty, body_id) => {
|
||||||
if is_suggestable_infer_ty(ty) {
|
if is_suggestable_infer_ty(ty) {
|
||||||
infer_placeholder_type(tcx, def_id, body_id, ty.span, item.ident, "constant")
|
infer_placeholder_type(
|
||||||
|
tcx,
|
||||||
|
def_id,
|
||||||
|
body_id,
|
||||||
|
ty.span,
|
||||||
|
item.ident,
|
||||||
|
"associated constant",
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
icx.to_ty(ty)
|
icx.to_ty(ty)
|
||||||
}
|
}
|
||||||
|
@ -1853,26 +1853,27 @@ impl String {
|
|||||||
/// Consumes and leaks the `String`, returning a mutable reference to the contents,
|
/// Consumes and leaks the `String`, returning a mutable reference to the contents,
|
||||||
/// `&'a mut str`.
|
/// `&'a mut str`.
|
||||||
///
|
///
|
||||||
/// This is mainly useful for data that lives for the remainder of
|
/// The caller has free choice over the returned lifetime, including `'static`. Indeed,
|
||||||
/// the program's life. Dropping the returned reference will cause a memory
|
/// this function is ideally used for data that lives for the remainder of the program's life,
|
||||||
/// leak.
|
/// as dropping the returned reference will cause a memory leak.
|
||||||
///
|
///
|
||||||
/// It does not reallocate or shrink the `String`,
|
/// It does not reallocate or shrink the `String`,
|
||||||
/// so the leaked allocation may include unused capacity that is not part
|
/// so the leaked allocation may include unused capacity that is not part
|
||||||
/// of the returned slice.
|
/// of the returned slice. If you don't want that, call [`into_boxed_str`],
|
||||||
|
/// and then [`Box::leak`].
|
||||||
|
///
|
||||||
|
/// [`into_boxed_str`]: Self::into_boxed_str
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// Simple usage:
|
/// Simple usage:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(string_leak)]
|
|
||||||
///
|
|
||||||
/// let x = String::from("bucket");
|
/// let x = String::from("bucket");
|
||||||
/// let static_ref: &'static mut str = x.leak();
|
/// let static_ref: &'static mut str = x.leak();
|
||||||
/// assert_eq!(static_ref, "bucket");
|
/// assert_eq!(static_ref, "bucket");
|
||||||
/// ```
|
/// ```
|
||||||
#[unstable(feature = "string_leak", issue = "102929")]
|
#[stable(feature = "string_leak", since = "CURRENT_RUSTC_VERSION")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn leak<'a>(self) -> &'a mut str {
|
pub fn leak<'a>(self) -> &'a mut str {
|
||||||
let slice = self.vec.leak();
|
let slice = self.vec.leak();
|
||||||
|
@ -2995,7 +2995,7 @@ impl<T> [T] {
|
|||||||
/// This reordering has the additional property that any value at position `i < index` will be
|
/// This reordering has the additional property that any value at position `i < index` will be
|
||||||
/// less than or equal to any value at a position `j > index`. Additionally, this reordering is
|
/// less than or equal to any value at a position `j > index`. Additionally, this reordering is
|
||||||
/// unstable (i.e. any number of equal elements may end up at position `index`), in-place
|
/// unstable (i.e. any number of equal elements may end up at position `index`), in-place
|
||||||
/// (i.e. does not allocate), and *O*(*n*) on average. The worst-case performance is *O*(*n* log *n*).
|
/// (i.e. does not allocate), and runs in *O*(*n*) time.
|
||||||
/// This function is also known as "kth element" in other libraries.
|
/// This function is also known as "kth element" in other libraries.
|
||||||
///
|
///
|
||||||
/// It returns a triplet of the following from the reordered slice:
|
/// It returns a triplet of the following from the reordered slice:
|
||||||
@ -3045,9 +3045,8 @@ impl<T> [T] {
|
|||||||
/// This reordering has the additional property that any value at position `i < index` will be
|
/// This reordering has the additional property that any value at position `i < index` will be
|
||||||
/// less than or equal to any value at a position `j > index` using the comparator function.
|
/// less than or equal to any value at a position `j > index` using the comparator function.
|
||||||
/// Additionally, this reordering is unstable (i.e. any number of equal elements may end up at
|
/// Additionally, this reordering is unstable (i.e. any number of equal elements may end up at
|
||||||
/// position `index`), in-place (i.e. does not allocate), and *O*(*n*) on average.
|
/// position `index`), in-place (i.e. does not allocate), and runs in *O*(*n*) time.
|
||||||
/// The worst-case performance is *O*(*n* log *n*). This function is also known as
|
/// This function is also known as "kth element" in other libraries.
|
||||||
/// "kth element" in other libraries.
|
|
||||||
///
|
///
|
||||||
/// It returns a triplet of the following from
|
/// It returns a triplet of the following from
|
||||||
/// the slice reordered according to the provided comparator function: the subslice prior to
|
/// the slice reordered according to the provided comparator function: the subslice prior to
|
||||||
@ -3101,8 +3100,7 @@ impl<T> [T] {
|
|||||||
/// This reordering has the additional property that any value at position `i < index` will be
|
/// This reordering has the additional property that any value at position `i < index` will be
|
||||||
/// less than or equal to any value at a position `j > index` using the key extraction function.
|
/// less than or equal to any value at a position `j > index` using the key extraction function.
|
||||||
/// Additionally, this reordering is unstable (i.e. any number of equal elements may end up at
|
/// Additionally, this reordering is unstable (i.e. any number of equal elements may end up at
|
||||||
/// position `index`), in-place (i.e. does not allocate), and *O*(*n*) on average.
|
/// position `index`), in-place (i.e. does not allocate), and runs in *O*(*n*) time.
|
||||||
/// The worst-case performance is *O*(*n* log *n*).
|
|
||||||
/// This function is also known as "kth element" in other libraries.
|
/// This function is also known as "kth element" in other libraries.
|
||||||
///
|
///
|
||||||
/// It returns a triplet of the following from
|
/// It returns a triplet of the following from
|
||||||
|
@ -868,7 +868,9 @@ where
|
|||||||
/// Returns whether the value was newly inserted. That is:
|
/// Returns whether the value was newly inserted. That is:
|
||||||
///
|
///
|
||||||
/// - If the set did not previously contain this value, `true` is returned.
|
/// - If the set did not previously contain this value, `true` is returned.
|
||||||
/// - If the set already contained this value, `false` is returned.
|
/// - If the set already contained this value, `false` is returned,
|
||||||
|
/// and the set is not modified: original value is not replaced,
|
||||||
|
/// and the value passed as argument is dropped.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
@ -3,6 +3,7 @@ use super::HashSet;
|
|||||||
|
|
||||||
use crate::panic::{catch_unwind, AssertUnwindSafe};
|
use crate::panic::{catch_unwind, AssertUnwindSafe};
|
||||||
use crate::sync::atomic::{AtomicU32, Ordering};
|
use crate::sync::atomic::{AtomicU32, Ordering};
|
||||||
|
use crate::sync::Arc;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_zero_capacities() {
|
fn test_zero_capacities() {
|
||||||
@ -502,3 +503,22 @@ fn const_with_hasher() {
|
|||||||
const X: HashSet<(), ()> = HashSet::with_hasher(());
|
const X: HashSet<(), ()> = HashSet::with_hasher(());
|
||||||
assert_eq!(X.len(), 0);
|
assert_eq!(X.len(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_insert_does_not_overwrite_the_value() {
|
||||||
|
let first_value = Arc::new(17);
|
||||||
|
let second_value = Arc::new(17);
|
||||||
|
|
||||||
|
let mut set = HashSet::new();
|
||||||
|
let inserted = set.insert(first_value.clone());
|
||||||
|
assert!(inserted);
|
||||||
|
|
||||||
|
let inserted = set.insert(second_value);
|
||||||
|
assert!(!inserted);
|
||||||
|
|
||||||
|
assert!(
|
||||||
|
Arc::ptr_eq(set.iter().next().unwrap(), &first_value),
|
||||||
|
"Insert must not overwrite the value, so the contained value pointer \
|
||||||
|
must be the same as first value pointer we inserted"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
@ -745,7 +745,7 @@ impl OsStr {
|
|||||||
without modifying the original"]
|
without modifying the original"]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn to_str(&self) -> Option<&str> {
|
pub fn to_str(&self) -> Option<&str> {
|
||||||
self.inner.to_str()
|
self.inner.to_str().ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converts an `OsStr` to a <code>[Cow]<[str]></code>.
|
/// Converts an `OsStr` to a <code>[Cow]<[str]></code>.
|
||||||
@ -1165,6 +1165,24 @@ impl<'a> From<Cow<'a, OsStr>> for OsString {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[stable(feature = "str_tryfrom_osstr_impl", since = "CURRENT_RUSTC_VERSION")]
|
||||||
|
impl<'a> TryFrom<&'a OsStr> for &'a str {
|
||||||
|
type Error = crate::str::Utf8Error;
|
||||||
|
|
||||||
|
/// Tries to convert an `&OsStr` to a `&str`.
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// use std::ffi::OsStr;
|
||||||
|
///
|
||||||
|
/// let os_str = OsStr::new("foo");
|
||||||
|
/// let as_str = <&str>::try_from(os_str).unwrap();
|
||||||
|
/// assert_eq!(as_str, "foo");
|
||||||
|
/// ```
|
||||||
|
fn try_from(value: &'a OsStr) -> Result<Self, Self::Error> {
|
||||||
|
value.inner.to_str()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[stable(feature = "box_default_extra", since = "1.17.0")]
|
#[stable(feature = "box_default_extra", since = "1.17.0")]
|
||||||
impl Default for Box<OsStr> {
|
impl Default for Box<OsStr> {
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -207,8 +207,8 @@ impl Slice {
|
|||||||
unsafe { Slice::from_os_str_bytes_unchecked(s.as_bytes()) }
|
unsafe { Slice::from_os_str_bytes_unchecked(s.as_bytes()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_str(&self) -> Option<&str> {
|
pub fn to_str(&self) -> Result<&str, crate::str::Utf8Error> {
|
||||||
str::from_utf8(&self.inner).ok()
|
str::from_utf8(&self.inner)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_string_lossy(&self) -> Cow<'_, str> {
|
pub fn to_string_lossy(&self) -> Cow<'_, str> {
|
||||||
|
@ -166,7 +166,7 @@ impl Slice {
|
|||||||
unsafe { mem::transmute(Wtf8::from_str(s)) }
|
unsafe { mem::transmute(Wtf8::from_str(s)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_str(&self) -> Option<&str> {
|
pub fn to_str(&self) -> Result<&str, crate::str::Utf8Error> {
|
||||||
self.inner.as_str()
|
self.inner.as_str()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -626,13 +626,8 @@ impl Wtf8 {
|
|||||||
///
|
///
|
||||||
/// This does not copy the data.
|
/// This does not copy the data.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn as_str(&self) -> Option<&str> {
|
pub fn as_str(&self) -> Result<&str, str::Utf8Error> {
|
||||||
// Well-formed WTF-8 is also well-formed UTF-8
|
str::from_utf8(&self.bytes)
|
||||||
// if and only if it contains no surrogate.
|
|
||||||
match self.next_surrogate(0) {
|
|
||||||
None => Some(unsafe { str::from_utf8_unchecked(&self.bytes) }),
|
|
||||||
Some(_) => None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates an owned `Wtf8Buf` from a borrowed `Wtf8`.
|
/// Creates an owned `Wtf8Buf` from a borrowed `Wtf8`.
|
||||||
|
@ -521,11 +521,11 @@ fn wtf8_code_points() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn wtf8_as_str() {
|
fn wtf8_as_str() {
|
||||||
assert_eq!(Wtf8::from_str("").as_str(), Some(""));
|
assert_eq!(Wtf8::from_str("").as_str(), Ok(""));
|
||||||
assert_eq!(Wtf8::from_str("aé 💩").as_str(), Some("aé 💩"));
|
assert_eq!(Wtf8::from_str("aé 💩").as_str(), Ok("aé 💩"));
|
||||||
let mut string = Wtf8Buf::new();
|
let mut string = Wtf8Buf::new();
|
||||||
string.push(CodePoint::from_u32(0xD800).unwrap());
|
string.push(CodePoint::from_u32(0xD800).unwrap());
|
||||||
assert_eq!(string.as_str(), None);
|
assert!(string.as_str().is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
trait Trait {
|
||||||
|
const ASSOC: i32;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Trait for () {
|
||||||
|
const ASSOC: &dyn Fn(_) = 1i32;
|
||||||
|
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated constants
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
@ -0,0 +1,9 @@
|
|||||||
|
error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants
|
||||||
|
--> $DIR/infer-placeholder-in-non-suggestable-pos.rs:6:26
|
||||||
|
|
|
||||||
|
LL | const ASSOC: &dyn Fn(_) = 1i32;
|
||||||
|
| ^ not allowed in type signatures
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0121`.
|
@ -33,15 +33,15 @@ static TY_STATIC_MIXED: Bar<_, _> = Bar::<i32, 3>(0);
|
|||||||
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for static variables
|
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for static variables
|
||||||
trait ArrAssocConst {
|
trait ArrAssocConst {
|
||||||
const ARR: [u8; _];
|
const ARR: [u8; _];
|
||||||
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants
|
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated constants
|
||||||
}
|
}
|
||||||
trait TyAssocConst {
|
trait TyAssocConst {
|
||||||
const ARR: Bar<i32, _>;
|
const ARR: Bar<i32, _>;
|
||||||
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants
|
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated constants
|
||||||
}
|
}
|
||||||
trait TyAssocConstMixed {
|
trait TyAssocConstMixed {
|
||||||
const ARR: Bar<_, _>;
|
const ARR: Bar<_, _>;
|
||||||
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants
|
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated constants
|
||||||
}
|
}
|
||||||
|
|
||||||
trait AssocTy {
|
trait AssocTy {
|
||||||
|
@ -74,19 +74,19 @@ LL | static TY_STATIC_MIXED: Bar<_, _> = Bar::<i32, 3>(0);
|
|||||||
| not allowed in type signatures
|
| not allowed in type signatures
|
||||||
| help: replace with the correct type: `Bar<i32, 3>`
|
| help: replace with the correct type: `Bar<i32, 3>`
|
||||||
|
|
||||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants
|
error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants
|
||||||
--> $DIR/in-signature.rs:35:21
|
--> $DIR/in-signature.rs:35:21
|
||||||
|
|
|
|
||||||
LL | const ARR: [u8; _];
|
LL | const ARR: [u8; _];
|
||||||
| ^ not allowed in type signatures
|
| ^ not allowed in type signatures
|
||||||
|
|
||||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants
|
error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants
|
||||||
--> $DIR/in-signature.rs:39:25
|
--> $DIR/in-signature.rs:39:25
|
||||||
|
|
|
|
||||||
LL | const ARR: Bar<i32, _>;
|
LL | const ARR: Bar<i32, _>;
|
||||||
| ^ not allowed in type signatures
|
| ^ not allowed in type signatures
|
||||||
|
|
||||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants
|
error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants
|
||||||
--> $DIR/in-signature.rs:43:20
|
--> $DIR/in-signature.rs:43:20
|
||||||
|
|
|
|
||||||
LL | const ARR: Bar<_, _>;
|
LL | const ARR: Bar<_, _>;
|
||||||
|
@ -3,12 +3,13 @@ struct MyStruct;
|
|||||||
trait Test {
|
trait Test {
|
||||||
const TEST: fn() -> _;
|
const TEST: fn() -> _;
|
||||||
//~^ ERROR: the placeholder `_` is not allowed within types on item signatures for functions [E0121]
|
//~^ ERROR: the placeholder `_` is not allowed within types on item signatures for functions [E0121]
|
||||||
//~| ERROR: the placeholder `_` is not allowed within types on item signatures for constants [E0121]
|
//~| ERROR: the placeholder `_` is not allowed within types on item signatures for associated constants [E0121]
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Test for MyStruct {
|
impl Test for MyStruct {
|
||||||
const TEST: fn() -> _ = 42;
|
const TEST: fn() -> _ = 42;
|
||||||
//~^ ERROR: the placeholder `_` is not allowed within types on item signatures for functions [E0121]
|
//~^ ERROR: the placeholder `_` is not allowed within types on item signatures for functions [E0121]
|
||||||
|
//~| ERROR: the placeholder `_` is not allowed within types on item signatures for associated constants [E0121]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
@ -4,7 +4,7 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures
|
|||||||
LL | const TEST: fn() -> _;
|
LL | const TEST: fn() -> _;
|
||||||
| ^ not allowed in type signatures
|
| ^ not allowed in type signatures
|
||||||
|
|
||||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants
|
error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants
|
||||||
--> $DIR/type-placeholder-fn-in-const.rs:4:25
|
--> $DIR/type-placeholder-fn-in-const.rs:4:25
|
||||||
|
|
|
|
||||||
LL | const TEST: fn() -> _;
|
LL | const TEST: fn() -> _;
|
||||||
@ -16,6 +16,12 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures
|
|||||||
LL | const TEST: fn() -> _ = 42;
|
LL | const TEST: fn() -> _ = 42;
|
||||||
| ^ not allowed in type signatures
|
| ^ not allowed in type signatures
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants
|
||||||
|
--> $DIR/type-placeholder-fn-in-const.rs:10:25
|
||||||
|
|
|
||||||
|
LL | const TEST: fn() -> _ = 42;
|
||||||
|
| ^ not allowed in type signatures
|
||||||
|
|
||||||
|
error: aborting due to 4 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0121`.
|
For more information about this error, try `rustc --explain E0121`.
|
||||||
|
@ -190,9 +190,9 @@ trait Qux {
|
|||||||
type B = _;
|
type B = _;
|
||||||
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated types
|
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated types
|
||||||
const C: _;
|
const C: _;
|
||||||
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants
|
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated constants
|
||||||
const D: _ = 42;
|
const D: _ = 42;
|
||||||
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants
|
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated constants
|
||||||
// type E: _; // FIXME: make the parser propagate the existence of `B`
|
// type E: _; // FIXME: make the parser propagate the existence of `B`
|
||||||
type F: std::ops::Fn(_);
|
type F: std::ops::Fn(_);
|
||||||
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated types
|
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated types
|
||||||
@ -203,10 +203,10 @@ impl Qux for Struct {
|
|||||||
type B = _;
|
type B = _;
|
||||||
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated types
|
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated types
|
||||||
const C: _;
|
const C: _;
|
||||||
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants
|
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated constants
|
||||||
//~| ERROR associated constant in `impl` without body
|
//~| ERROR associated constant in `impl` without body
|
||||||
const D: _ = 42;
|
const D: _ = 42;
|
||||||
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants
|
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated constants
|
||||||
}
|
}
|
||||||
|
|
||||||
fn map<T>(_: fn() -> Option<&'static T>) -> Option<T> {
|
fn map<T>(_: fn() -> Option<&'static T>) -> Option<T> {
|
||||||
|
@ -525,13 +525,13 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures
|
|||||||
LL | type B = _;
|
LL | type B = _;
|
||||||
| ^ not allowed in type signatures
|
| ^ not allowed in type signatures
|
||||||
|
|
||||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants
|
error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants
|
||||||
--> $DIR/typeck_type_placeholder_item.rs:192:14
|
--> $DIR/typeck_type_placeholder_item.rs:192:14
|
||||||
|
|
|
|
||||||
LL | const C: _;
|
LL | const C: _;
|
||||||
| ^ not allowed in type signatures
|
| ^ not allowed in type signatures
|
||||||
|
|
||||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants
|
error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants
|
||||||
--> $DIR/typeck_type_placeholder_item.rs:194:14
|
--> $DIR/typeck_type_placeholder_item.rs:194:14
|
||||||
|
|
|
|
||||||
LL | const D: _ = 42;
|
LL | const D: _ = 42;
|
||||||
@ -642,13 +642,13 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures
|
|||||||
LL | type B = _;
|
LL | type B = _;
|
||||||
| ^ not allowed in type signatures
|
| ^ not allowed in type signatures
|
||||||
|
|
||||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants
|
error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants
|
||||||
--> $DIR/typeck_type_placeholder_item.rs:205:14
|
--> $DIR/typeck_type_placeholder_item.rs:205:14
|
||||||
|
|
|
|
||||||
LL | const C: _;
|
LL | const C: _;
|
||||||
| ^ not allowed in type signatures
|
| ^ not allowed in type signatures
|
||||||
|
|
||||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants
|
error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants
|
||||||
--> $DIR/typeck_type_placeholder_item.rs:208:14
|
--> $DIR/typeck_type_placeholder_item.rs:208:14
|
||||||
|
|
|
|
||||||
LL | const D: _ = 42;
|
LL | const D: _ = 42;
|
||||||
|
@ -16,14 +16,14 @@ const TEST4: fn() -> _ = 42;
|
|||||||
|
|
||||||
trait Test5 {
|
trait Test5 {
|
||||||
const TEST5: _ = 42;
|
const TEST5: _ = 42;
|
||||||
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants
|
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated constants
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Test6;
|
struct Test6;
|
||||||
|
|
||||||
impl Test6 {
|
impl Test6 {
|
||||||
const TEST6: _ = 13;
|
const TEST6: _ = 13;
|
||||||
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants
|
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated constants
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
|
@ -37,7 +37,7 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures
|
|||||||
LL | const TEST4: fn() -> _ = 42;
|
LL | const TEST4: fn() -> _ = 42;
|
||||||
| ^ not allowed in type signatures
|
| ^ not allowed in type signatures
|
||||||
|
|
||||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants
|
error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants
|
||||||
--> $DIR/typeck_type_placeholder_item_help.rs:18:18
|
--> $DIR/typeck_type_placeholder_item_help.rs:18:18
|
||||||
|
|
|
|
||||||
LL | const TEST5: _ = 42;
|
LL | const TEST5: _ = 42;
|
||||||
@ -46,7 +46,7 @@ LL | const TEST5: _ = 42;
|
|||||||
| not allowed in type signatures
|
| not allowed in type signatures
|
||||||
| help: replace with the correct type: `i32`
|
| help: replace with the correct type: `i32`
|
||||||
|
|
||||||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants
|
error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants
|
||||||
--> $DIR/typeck_type_placeholder_item_help.rs:25:18
|
--> $DIR/typeck_type_placeholder_item_help.rs:25:18
|
||||||
|
|
|
|
||||||
LL | const TEST6: _ = 13;
|
LL | const TEST6: _ = 13;
|
||||||
|
Loading…
Reference in New Issue
Block a user