Auto merge of #128142 - matthiaskrgr:rollup-rep8ofv, r=matthiaskrgr

Rollup of 9 pull requests

Successful merges:

 - #126152 (size_of_val_raw: for length 0 this is safe to call)
 - #127252 (Add edge-case examples to `{count,leading,trailing}_{ones,zeros}` methods)
 - #127374 (Tweak "wrong # of generics" suggestions)
 - #127457 (Make tidy fast without compromising case alternation)
 - #127480 (Fix build failure on vxworks #127084 )
 - #127733 (Replace some `mem::forget`'s with `ManuallyDrop`)
 - #128120 (Gate `AsyncFn*` under `async_closure` feature)
 - #128131 (Import `c_void` rather than using the full path)
 - #128133 (Improve spans on evaluated `cfg_attr`s.)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2024-07-24 16:44:29 +00:00
commit 6106b05b27
107 changed files with 526 additions and 433 deletions

View file

@ -44,13 +44,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
let mut res = self.lower_res(base_res);
// When we have an `async` kw on a bound, map the trait it resolves to.
let mut bound_modifier_allowed_features = None;
if let Some(TraitBoundModifiers { asyncness: BoundAsyncness::Async(_), .. }) = modifiers {
match res {
Res::Def(DefKind::Trait, def_id) => {
if let Some((async_def_id, features)) = self.map_trait_to_async_trait(def_id) {
if let Some(async_def_id) = self.map_trait_to_async_trait(def_id) {
res = Res::Def(DefKind::Trait, async_def_id);
bound_modifier_allowed_features = Some(features);
} else {
self.dcx().emit_err(AsyncBoundOnlyForFnTraits { span: p.span });
}
@ -67,6 +65,16 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}
}
// Ungate the `async_fn_traits` feature in the path if the trait is
// named via either `async Fn*()` or `AsyncFn*()`.
let bound_modifier_allowed_features = if let Res::Def(DefKind::Trait, async_def_id) = res
&& self.tcx.async_fn_trait_kind_from_def_id(async_def_id).is_some()
{
Some(self.allow_async_fn_traits.clone())
} else {
None
};
let path_span_lo = p.span.shrink_to_lo();
let proj_start = p.segments.len() - unresolved_segments;
let path = self.arena.alloc(hir::Path {
@ -506,14 +514,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
/// This only needs to be done until we unify `AsyncFn` and `Fn` traits into one
/// that is generic over `async`ness, if that's ever possible, or modify the
/// lowering of `async Fn()` bounds to desugar to another trait like `LendingFn`.
fn map_trait_to_async_trait(&self, def_id: DefId) -> Option<(DefId, Lrc<[Symbol]>)> {
fn map_trait_to_async_trait(&self, def_id: DefId) -> Option<DefId> {
let lang_items = self.tcx.lang_items();
if Some(def_id) == lang_items.fn_trait() {
Some((lang_items.async_fn_trait()?, self.allow_async_fn_traits.clone()))
lang_items.async_fn_trait()
} else if Some(def_id) == lang_items.fn_mut_trait() {
Some((lang_items.async_fn_mut_trait()?, self.allow_async_fn_traits.clone()))
lang_items.async_fn_mut_trait()
} else if Some(def_id) == lang_items.fn_once_trait() {
Some((lang_items.async_fn_once_trait()?, self.allow_async_fn_traits.clone()))
lang_items.async_fn_once_trait()
} else {
None
}

View file

@ -6,7 +6,7 @@ use crate::errors::{
};
use rustc_ast::ptr::P;
use rustc_ast::token::{Delimiter, Token, TokenKind};
use rustc_ast::tokenstream::{AttrTokenStream, AttrTokenTree, DelimSpacing, DelimSpan, Spacing};
use rustc_ast::tokenstream::{AttrTokenStream, AttrTokenTree, Spacing};
use rustc_ast::tokenstream::{LazyAttrTokenStream, TokenTree};
use rustc_ast::NodeId;
use rustc_ast::{self as ast, AttrStyle, Attribute, HasAttrs, HasTokens, MetaItem};
@ -298,47 +298,47 @@ impl<'a> StripUnconfigured<'a> {
cfg_attr: &Attribute,
(item, item_span): (ast::AttrItem, Span),
) -> Attribute {
// We are taking an attribute of the form `#[cfg_attr(pred, attr)]`
// and producing an attribute of the form `#[attr]`. We
// have captured tokens for `attr` itself, but we need to
// synthesize tokens for the wrapper `#` and `[]`, which
// we do below.
// Convert `#[cfg_attr(pred, attr)]` to `#[attr]`.
// Use the `#` in `#[cfg_attr(pred, attr)]` as the `#` token
// for `attr` when we expand it to `#[attr]`
// Use the `#` from `#[cfg_attr(pred, attr)]` in the result `#[attr]`.
let mut orig_trees = cfg_attr.token_trees().into_iter();
let TokenTree::Token(pound_token @ Token { kind: TokenKind::Pound, .. }, _) =
orig_trees.next().unwrap().clone()
let Some(TokenTree::Token(pound_token @ Token { kind: TokenKind::Pound, .. }, _)) =
orig_trees.next()
else {
panic!("Bad tokens for attribute {cfg_attr:?}");
};
// We don't really have a good span to use for the synthesized `[]`
// in `#[attr]`, so just use the span of the `#` token.
let bracket_group = AttrTokenTree::Delimited(
DelimSpan::from_single(pound_token.span),
DelimSpacing::new(Spacing::JointHidden, Spacing::Alone),
Delimiter::Bracket,
item.tokens
.as_ref()
.unwrap_or_else(|| panic!("Missing tokens for {item:?}"))
.to_attr_token_stream(),
);
let trees = if cfg_attr.style == AttrStyle::Inner {
// For inner attributes, we do the same thing for the `!` in `#![some_attr]`
let TokenTree::Token(bang_token @ Token { kind: TokenKind::Not, .. }, _) =
orig_trees.next().unwrap().clone()
// For inner attributes, we do the same thing for the `!` in `#![attr]`.
let mut trees = if cfg_attr.style == AttrStyle::Inner {
let Some(TokenTree::Token(bang_token @ Token { kind: TokenKind::Not, .. }, _)) =
orig_trees.next()
else {
panic!("Bad tokens for attribute {cfg_attr:?}");
};
vec![
AttrTokenTree::Token(pound_token, Spacing::Joint),
AttrTokenTree::Token(bang_token, Spacing::JointHidden),
bracket_group,
]
} else {
vec![AttrTokenTree::Token(pound_token, Spacing::JointHidden), bracket_group]
vec![AttrTokenTree::Token(pound_token, Spacing::JointHidden)]
};
// And the same thing for the `[`/`]` delimiters in `#[attr]`.
let Some(TokenTree::Delimited(delim_span, delim_spacing, Delimiter::Bracket, _)) =
orig_trees.next()
else {
panic!("Bad tokens for attribute {cfg_attr:?}");
};
trees.push(AttrTokenTree::Delimited(
delim_span,
delim_spacing,
Delimiter::Bracket,
item.tokens
.as_ref()
.unwrap_or_else(|| panic!("Missing tokens for {item:?}"))
.to_attr_token_stream(),
));
let tokens = Some(LazyAttrTokenStream::new(AttrTokenStream::new(trees)));
let attr = attr::mk_attr_from_item(
&self.sess.psess.attr_id_generator,

View file

@ -888,7 +888,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
let comma = if args.len() > 0 { ", " } else { "" };
let trait_path = self.tcx.def_path_str(trait_def_id);
let method_name = self.tcx.item_name(self.def_id);
err.span_suggestion(
err.span_suggestion_verbose(
expr.span,
msg,
format!("{trait_path}::{generics}::{method_name}({rcvr}{comma}{rest})"),
@ -939,18 +939,20 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
}
}
let span_lo_redundant_lt_args = lt_arg_spans[self.num_expected_lifetime_args()];
let span_lo_redundant_lt_args = if self.num_expected_lifetime_args() == 0 {
lt_arg_spans[0]
} else {
lt_arg_spans[self.num_expected_lifetime_args() - 1]
};
let span_hi_redundant_lt_args = lt_arg_spans[lt_arg_spans.len() - 1];
let span_redundant_lt_args = span_lo_redundant_lt_args.to(span_hi_redundant_lt_args);
let span_redundant_lt_args =
span_lo_redundant_lt_args.shrink_to_hi().to(span_hi_redundant_lt_args);
debug!("span_redundant_lt_args: {:?}", span_redundant_lt_args);
let num_redundant_lt_args = lt_arg_spans.len() - self.num_expected_lifetime_args();
let msg_lifetimes = format!(
"remove {these} lifetime argument{s}",
these = pluralize!("this", num_redundant_lt_args),
s = pluralize!(num_redundant_lt_args),
);
let msg_lifetimes =
format!("remove the lifetime argument{s}", s = pluralize!(num_redundant_lt_args));
err.span_suggestion(
span_redundant_lt_args,
@ -979,18 +981,22 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
}
let span_lo_redundant_type_or_const_args =
gen_arg_spans[self.num_expected_type_or_const_args()];
if self.num_expected_type_or_const_args() == 0 {
gen_arg_spans[0]
} else {
gen_arg_spans[self.num_expected_type_or_const_args() - 1]
};
let span_hi_redundant_type_or_const_args = gen_arg_spans[gen_arg_spans.len() - 1];
let span_redundant_type_or_const_args = span_lo_redundant_type_or_const_args
.shrink_to_hi()
.to(span_hi_redundant_type_or_const_args);
let span_redundant_type_or_const_args =
span_lo_redundant_type_or_const_args.to(span_hi_redundant_type_or_const_args);
debug!("span_redundant_type_or_const_args: {:?}", span_redundant_type_or_const_args);
let num_redundant_gen_args =
gen_arg_spans.len() - self.num_expected_type_or_const_args();
let msg_types_or_consts = format!(
"remove {these} generic argument{s}",
these = pluralize!("this", num_redundant_gen_args),
"remove the unnecessary generic argument{s}",
s = pluralize!(num_redundant_gen_args),
);
@ -1036,7 +1042,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
.with_lo(self.path_segment.ident.span.hi());
let msg = format!(
"remove these {}generics",
"remove the unnecessary {}generics",
if self.gen_args.parenthesized == hir::GenericArgsParentheses::ParenSugar {
"parenthetical "
} else {

View file

@ -101,6 +101,7 @@
#![feature(array_windows)]
#![feature(ascii_char)]
#![feature(assert_matches)]
#![feature(async_closure)]
#![feature(async_fn_traits)]
#![feature(async_iterator)]
#![feature(clone_to_uninit)]

View file

@ -259,7 +259,7 @@ use core::intrinsics::abort;
#[cfg(not(no_global_oom_handling))]
use core::iter;
use core::marker::{PhantomData, Unsize};
use core::mem::{self, align_of_val_raw, forget, ManuallyDrop};
use core::mem::{self, align_of_val_raw, ManuallyDrop};
use core::ops::{CoerceUnsized, Deref, DerefMut, DerefPure, DispatchFromDyn, Receiver};
use core::panic::{RefUnwindSafe, UnwindSafe};
#[cfg(not(no_global_oom_handling))]
@ -908,19 +908,18 @@ impl<T, A: Allocator> Rc<T, A> {
#[stable(feature = "rc_unique", since = "1.4.0")]
pub fn try_unwrap(this: Self) -> Result<T, Self> {
if Rc::strong_count(&this) == 1 {
unsafe {
let val = ptr::read(&*this); // copy the contained object
let alloc = ptr::read(&this.alloc); // copy the allocator
let this = ManuallyDrop::new(this);
// Indicate to Weaks that they can't be promoted by decrementing
// the strong count, and then remove the implicit "strong weak"
// pointer while also handling drop logic by just crafting a
// fake Weak.
this.inner().dec_strong();
let _weak = Weak { ptr: this.ptr, alloc };
forget(this);
Ok(val)
}
let val: T = unsafe { ptr::read(&**this) }; // copy the contained object
let alloc: A = unsafe { ptr::read(&this.alloc) }; // copy the allocator
// Indicate to Weaks that they can't be promoted by decrementing
// the strong count, and then remove the implicit "strong weak"
// pointer while also handling drop logic by just crafting a
// fake Weak.
this.inner().dec_strong();
let _weak = Weak { ptr: this.ptr, alloc };
Ok(val)
} else {
Err(this)
}
@ -1354,9 +1353,8 @@ impl<T: ?Sized, A: Allocator> Rc<T, A> {
#[stable(feature = "rc_raw", since = "1.17.0")]
#[rustc_never_returns_null_ptr]
pub fn into_raw(this: Self) -> *const T {
let ptr = Self::as_ptr(&this);
mem::forget(this);
ptr
let this = ManuallyDrop::new(this);
Self::as_ptr(&*this)
}
/// Consumes the `Rc`, returning the wrapped pointer and allocator.
@ -2127,7 +2125,7 @@ impl<T> Rc<[T]> {
}
// All clear. Forget the guard so it doesn't free the new RcBox.
forget(guard);
mem::forget(guard);
Self::from_ptr(ptr)
}
@ -3080,9 +3078,7 @@ impl<T: ?Sized, A: Allocator> Weak<T, A> {
#[must_use = "losing the pointer will leak memory"]
#[stable(feature = "weak_into_raw", since = "1.45.0")]
pub fn into_raw(self) -> *const T {
let result = self.as_ptr();
mem::forget(self);
result
mem::ManuallyDrop::new(self).as_ptr()
}
/// Consumes the `Weak<T>`, returning the wrapped pointer and allocator.
@ -3762,10 +3758,11 @@ impl<T: ?Sized, A: Allocator> UniqueRcUninit<T, A> {
/// # Safety
///
/// The data must have been initialized (by writing to [`Self::data_ptr()`]).
unsafe fn into_rc(mut self) -> Rc<T, A> {
let ptr = self.ptr;
let alloc = self.alloc.take().unwrap();
mem::forget(self);
unsafe fn into_rc(self) -> Rc<T, A> {
let mut this = ManuallyDrop::new(self);
let ptr = this.ptr;
let alloc = this.alloc.take().unwrap();
// SAFETY: The pointer is valid as per `UniqueRcUninit::new`, and the caller is responsible
// for having initialized the data.
unsafe { Rc::from_ptr_in(ptr.as_ptr(), alloc) }

View file

@ -20,7 +20,7 @@ use core::intrinsics::abort;
#[cfg(not(no_global_oom_handling))]
use core::iter;
use core::marker::{PhantomData, Unsize};
use core::mem::{self, align_of_val_raw};
use core::mem::{self, align_of_val_raw, ManuallyDrop};
use core::ops::{CoerceUnsized, Deref, DerefPure, DispatchFromDyn, Receiver};
use core::panic::{RefUnwindSafe, UnwindSafe};
use core::pin::Pin;
@ -960,16 +960,14 @@ impl<T, A: Allocator> Arc<T, A> {
acquire!(this.inner().strong);
unsafe {
let elem = ptr::read(&this.ptr.as_ref().data);
let alloc = ptr::read(&this.alloc); // copy the allocator
let this = ManuallyDrop::new(this);
let elem: T = unsafe { ptr::read(&this.ptr.as_ref().data) };
let alloc: A = unsafe { ptr::read(&this.alloc) }; // copy the allocator
// Make a weak pointer to clean up the implicit strong-weak reference
let _weak = Weak { ptr: this.ptr, alloc };
mem::forget(this);
// Make a weak pointer to clean up the implicit strong-weak reference
let _weak = Weak { ptr: this.ptr, alloc };
Ok(elem)
}
Ok(elem)
}
/// Returns the inner value, if the `Arc` has exactly one strong reference.
@ -1493,9 +1491,8 @@ impl<T: ?Sized, A: Allocator> Arc<T, A> {
#[stable(feature = "rc_raw", since = "1.17.0")]
#[rustc_never_returns_null_ptr]
pub fn into_raw(this: Self) -> *const T {
let ptr = Self::as_ptr(&this);
mem::forget(this);
ptr
let this = ManuallyDrop::new(this);
Self::as_ptr(&*this)
}
/// Consumes the `Arc`, returning the wrapped pointer and allocator.
@ -2801,9 +2798,7 @@ impl<T: ?Sized, A: Allocator> Weak<T, A> {
#[must_use = "losing the pointer will leak memory"]
#[stable(feature = "weak_into_raw", since = "1.45.0")]
pub fn into_raw(self) -> *const T {
let result = self.as_ptr();
mem::forget(self);
result
ManuallyDrop::new(self).as_ptr()
}
/// Consumes the `Weak<T>`, returning the wrapped pointer and allocator.
@ -3875,13 +3870,14 @@ impl<T: ?Sized, A: Allocator> UniqueArcUninit<T, A> {
/// # Safety
///
/// The data must have been initialized (by writing to [`Self::data_ptr()`]).
unsafe fn into_arc(mut self) -> Arc<T, A> {
let ptr = self.ptr;
let alloc = self.alloc.take().unwrap();
mem::forget(self);
unsafe fn into_arc(self) -> Arc<T, A> {
let mut this = ManuallyDrop::new(self);
let ptr = this.ptr.as_ptr();
let alloc = this.alloc.take().unwrap();
// SAFETY: The pointer is valid as per `UniqueArcUninit::new`, and the caller is responsible
// for having initialized the data.
unsafe { Arc::from_ptr_in(ptr.as_ptr(), alloc) }
unsafe { Arc::from_ptr_in(ptr, alloc) }
}
}

View file

@ -183,6 +183,8 @@ impl Layout {
/// - a [slice], then the length of the slice tail must be an initialized
/// integer, and the size of the *entire value*
/// (dynamic tail length + statically sized prefix) must fit in `isize`.
/// For the special case where the dynamic tail length is 0, this function
/// is safe to call.
/// - a [trait object], then the vtable part of the pointer must point
/// to a valid vtable for the type `T` acquired by an unsizing coercion,
/// and the size of the *entire value*

View file

@ -359,6 +359,12 @@ pub const fn size_of_val<T: ?Sized>(val: &T) -> usize {
/// - a [slice], then the length of the slice tail must be an initialized
/// integer, and the size of the *entire value*
/// (dynamic tail length + statically sized prefix) must fit in `isize`.
/// For the special case where the dynamic tail length is 0, this function
/// is safe to call.
// NOTE: the reason this is safe is that if an overflow were to occur already with size 0,
// then we would stop compilation as even the "statically known" part of the type would
// already be too big (or the call may be in dead code and optimized away, but then it
// doesn't matter).
/// - a [trait object], then the vtable part of the pointer must point
/// to a valid vtable acquired by an unsizing coercion, and the size
/// of the *entire value* (dynamic tail length + statically sized prefix)
@ -506,6 +512,8 @@ pub const fn align_of_val<T: ?Sized>(val: &T) -> usize {
/// - a [slice], then the length of the slice tail must be an initialized
/// integer, and the size of the *entire value*
/// (dynamic tail length + statically sized prefix) must fit in `isize`.
/// For the special case where the dynamic tail length is 0, this function
/// is safe to call.
/// - a [trait object], then the vtable part of the pointer must point
/// to a valid vtable acquired by an unsizing coercion, and the size
/// of the *entire value* (dynamic tail length + statically sized prefix)

View file

@ -65,8 +65,13 @@ macro_rules! uint_impl {
///
/// ```
#[doc = concat!("let n = 0b01001100", stringify!($SelfT), ";")]
///
/// assert_eq!(n.count_ones(), 3);
///
#[doc = concat!("let max = ", stringify!($SelfT),"::MAX;")]
#[doc = concat!("assert_eq!(max.count_ones(), ", stringify!($BITS), ");")]
///
#[doc = concat!("let zero = 0", stringify!($SelfT), ";")]
/// assert_eq!(zero.count_ones(), 0);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "const_math", since = "1.32.0")]
@ -86,7 +91,11 @@ macro_rules! uint_impl {
/// Basic usage:
///
/// ```
#[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.count_zeros(), 0);")]
#[doc = concat!("let zero = 0", stringify!($SelfT), ";")]
#[doc = concat!("assert_eq!(zero.count_zeros(), ", stringify!($BITS), ");")]
///
#[doc = concat!("let max = ", stringify!($SelfT),"::MAX;")]
/// assert_eq!(max.count_zeros(), 0);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "const_math", since = "1.32.0")]
@ -108,8 +117,13 @@ macro_rules! uint_impl {
///
/// ```
#[doc = concat!("let n = ", stringify!($SelfT), "::MAX >> 2;")]
///
/// assert_eq!(n.leading_zeros(), 2);
///
#[doc = concat!("let zero = 0", stringify!($SelfT), ";")]
#[doc = concat!("assert_eq!(zero.leading_zeros(), ", stringify!($BITS), ");")]
///
#[doc = concat!("let max = ", stringify!($SelfT),"::MAX;")]
/// assert_eq!(max.leading_zeros(), 0);
/// ```
#[doc = concat!("[`ilog2`]: ", stringify!($SelfT), "::ilog2")]
#[stable(feature = "rust1", since = "1.0.0")]
@ -130,8 +144,13 @@ macro_rules! uint_impl {
///
/// ```
#[doc = concat!("let n = 0b0101000", stringify!($SelfT), ";")]
///
/// assert_eq!(n.trailing_zeros(), 3);
///
#[doc = concat!("let zero = 0", stringify!($SelfT), ";")]
#[doc = concat!("assert_eq!(zero.trailing_zeros(), ", stringify!($BITS), ");")]
///
#[doc = concat!("let max = ", stringify!($SelfT),"::MAX;")]
#[doc = concat!("assert_eq!(max.trailing_zeros(), 0);")]
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "const_math", since = "1.32.0")]
@ -150,8 +169,13 @@ macro_rules! uint_impl {
///
/// ```
#[doc = concat!("let n = !(", stringify!($SelfT), "::MAX >> 2);")]
///
/// assert_eq!(n.leading_ones(), 2);
///
#[doc = concat!("let zero = 0", stringify!($SelfT), ";")]
/// assert_eq!(zero.leading_ones(), 0);
///
#[doc = concat!("let max = ", stringify!($SelfT),"::MAX;")]
#[doc = concat!("assert_eq!(max.leading_ones(), ", stringify!($BITS), ");")]
/// ```
#[stable(feature = "leading_trailing_ones", since = "1.46.0")]
#[rustc_const_stable(feature = "leading_trailing_ones", since = "1.46.0")]
@ -171,8 +195,13 @@ macro_rules! uint_impl {
///
/// ```
#[doc = concat!("let n = 0b1010111", stringify!($SelfT), ";")]
///
/// assert_eq!(n.trailing_ones(), 3);
///
#[doc = concat!("let zero = 0", stringify!($SelfT), ";")]
/// assert_eq!(zero.trailing_ones(), 0);
///
#[doc = concat!("let max = ", stringify!($SelfT),"::MAX;")]
#[doc = concat!("assert_eq!(max.trailing_ones(), ", stringify!($BITS), ");")]
/// ```
#[stable(feature = "leading_trailing_ones", since = "1.46.0")]
#[rustc_const_stable(feature = "leading_trailing_ones", since = "1.46.0")]

View file

@ -4,7 +4,7 @@ use crate::marker::Tuple;
/// An async-aware version of the [`Fn`](crate::ops::Fn) trait.
///
/// All `async fn` and functions returning futures implement this trait.
#[unstable(feature = "async_fn_traits", issue = "none")]
#[unstable(feature = "async_closure", issue = "62290")]
#[rustc_paren_sugar]
#[fundamental]
#[must_use = "async closures are lazy and do nothing unless called"]
@ -18,7 +18,7 @@ pub trait AsyncFn<Args: Tuple>: AsyncFnMut<Args> {
/// An async-aware version of the [`FnMut`](crate::ops::FnMut) trait.
///
/// All `async fn` and functions returning futures implement this trait.
#[unstable(feature = "async_fn_traits", issue = "none")]
#[unstable(feature = "async_closure", issue = "62290")]
#[rustc_paren_sugar]
#[fundamental]
#[must_use = "async closures are lazy and do nothing unless called"]
@ -39,7 +39,7 @@ pub trait AsyncFnMut<Args: Tuple>: AsyncFnOnce<Args> {
/// An async-aware version of the [`FnOnce`](crate::ops::FnOnce) trait.
///
/// All `async fn` and functions returning futures implement this trait.
#[unstable(feature = "async_fn_traits", issue = "none")]
#[unstable(feature = "async_closure", issue = "62290")]
#[rustc_paren_sugar]
#[fundamental]
#[must_use = "async closures are lazy and do nothing unless called"]

View file

@ -1,10 +1,9 @@
#![stable(feature = "futures_api", since = "1.36.0")]
use crate::mem::transmute;
use crate::any::Any;
use crate::fmt;
use crate::marker::PhantomData;
use crate::mem::{transmute, ManuallyDrop};
use crate::panic::AssertUnwindSafe;
use crate::ptr;
@ -465,16 +464,14 @@ impl Waker {
pub fn wake(self) {
// The actual wakeup call is delegated through a virtual function call
// to the implementation which is defined by the executor.
let wake = self.waker.vtable.wake;
let data = self.waker.data;
// Don't call `drop` -- the waker will be consumed by `wake`.
crate::mem::forget(self);
let this = ManuallyDrop::new(self);
// SAFETY: This is safe because `Waker::from_raw` is the only way
// to initialize `wake` and `data` requiring the user to acknowledge
// that the contract of `RawWaker` is upheld.
unsafe { (wake)(data) };
unsafe { (this.waker.vtable.wake)(this.waker.data) };
}
/// Wake up the task associated with this `Waker` without consuming the `Waker`.
@ -726,16 +723,14 @@ impl LocalWaker {
pub fn wake(self) {
// The actual wakeup call is delegated through a virtual function call
// to the implementation which is defined by the executor.
let wake = self.waker.vtable.wake;
let data = self.waker.data;
// Don't call `drop` -- the waker will be consumed by `wake`.
crate::mem::forget(self);
let this = ManuallyDrop::new(self);
// SAFETY: This is safe because `Waker::from_raw` is the only way
// to initialize `wake` and `data` requiring the user to acknowledge
// that the contract of `RawWaker` is upheld.
unsafe { (wake)(data) };
unsafe { (this.waker.vtable.wake)(this.waker.data) };
}
/// Wake up the task associated with this `LocalWaker` without consuming the `LocalWaker`.

View file

@ -1,7 +1,7 @@
//! Buffer management for same-process client<->server communication.
use std::io::{self, Write};
use std::mem;
use std::mem::{self, ManuallyDrop};
use std::ops::{Deref, DerefMut};
use std::slice;
@ -129,17 +129,16 @@ impl Drop for Buffer {
}
impl From<Vec<u8>> for Buffer {
fn from(mut v: Vec<u8>) -> Self {
fn from(v: Vec<u8>) -> Self {
let mut v = ManuallyDrop::new(v);
let (data, len, capacity) = (v.as_mut_ptr(), v.len(), v.capacity());
mem::forget(v);
// This utility function is nested in here because it can *only*
// be safely called on `Buffer`s created by *this* `proc_macro`.
fn to_vec(b: Buffer) -> Vec<u8> {
unsafe {
let Buffer { data, len, capacity, .. } = b;
mem::forget(b);
Vec::from_raw_parts(data, len, capacity)
let b = ManuallyDrop::new(b);
Vec::from_raw_parts(b.data, b.len, b.capacity)
}
}

View file

@ -51,9 +51,7 @@ macro_rules! define_client_handles {
impl<S> Encode<S> for $oty {
fn encode(self, w: &mut Writer, s: &mut S) {
let handle = self.handle;
mem::forget(self);
handle.encode(w, s);
mem::ManuallyDrop::new(self).handle.encode(w, s);
}
}

View file

@ -8,7 +8,7 @@ use crate::fmt;
use crate::fs;
use crate::io;
use crate::marker::PhantomData;
use crate::mem::forget;
use crate::mem::ManuallyDrop;
#[cfg(not(any(target_arch = "wasm32", target_env = "sgx", target_os = "hermit")))]
use crate::sys::cvt;
use crate::sys_common::{AsInner, FromInner, IntoInner};
@ -148,9 +148,7 @@ impl AsRawFd for OwnedFd {
impl IntoRawFd for OwnedFd {
#[inline]
fn into_raw_fd(self) -> RawFd {
let fd = self.fd;
forget(self);
fd
ManuallyDrop::new(self).fd
}
}

View file

@ -48,7 +48,7 @@
use crate::fmt;
use crate::marker::PhantomData;
use crate::mem::forget;
use crate::mem::ManuallyDrop;
use crate::net;
use crate::sys;
use crate::sys_common::{self, AsInner, FromInner, IntoInner};
@ -148,9 +148,7 @@ impl AsRawFd for OwnedFd {
impl IntoRawFd for OwnedFd {
#[inline]
fn into_raw_fd(self) -> RawFd {
let fd = self.fd;
forget(self);
fd
ManuallyDrop::new(self).fd
}
}

View file

@ -1064,7 +1064,7 @@ pub fn lchown<P: AsRef<Path>>(dir: P, uid: Option<u32>, gid: Option<u32>) -> io:
/// }
/// ```
#[stable(feature = "unix_chroot", since = "1.56.0")]
#[cfg(not(any(target_os = "fuchsia", target_os = "vxworks")))]
#[cfg(not(target_os = "fuchsia"))]
pub fn chroot<P: AsRef<Path>>(dir: P) -> io::Result<()> {
sys::fs::chroot(dir.as_ref())
}

View file

@ -7,7 +7,7 @@ use crate::fmt;
use crate::fs;
use crate::io;
use crate::marker::PhantomData;
use crate::mem::{forget, ManuallyDrop};
use crate::mem::ManuallyDrop;
use crate::ptr;
use crate::sys;
use crate::sys::cvt;
@ -319,9 +319,7 @@ impl AsRawHandle for OwnedHandle {
impl IntoRawHandle for OwnedHandle {
#[inline]
fn into_raw_handle(self) -> RawHandle {
let handle = self.handle;
forget(self);
handle
ManuallyDrop::new(self).handle
}
}

View file

@ -6,8 +6,7 @@ use super::raw::{AsRawSocket, FromRawSocket, IntoRawSocket, RawSocket};
use crate::fmt;
use crate::io;
use crate::marker::PhantomData;
use crate::mem;
use crate::mem::forget;
use crate::mem::{self, ManuallyDrop};
use crate::sys;
#[cfg(not(target_vendor = "uwp"))]
use crate::sys::cvt;
@ -191,9 +190,7 @@ impl AsRawSocket for OwnedSocket {
impl IntoRawSocket for OwnedSocket {
#[inline]
fn into_raw_socket(self) -> RawSocket {
let socket = self.socket;
forget(self);
socket
ManuallyDrop::new(self).socket
}
}

View file

@ -3,7 +3,7 @@
use super::hermit_abi;
use crate::ffi::CStr;
use crate::io;
use crate::mem;
use crate::mem::ManuallyDrop;
use crate::num::NonZero;
use crate::ptr;
use crate::time::Duration;
@ -90,9 +90,7 @@ impl Thread {
#[inline]
pub fn into_id(self) -> Tid {
let id = self.tid;
mem::forget(self);
id
ManuallyDrop::new(self).tid
}
}

View file

@ -95,8 +95,8 @@ impl Tls {
#[allow(unused)]
pub unsafe fn activate_persistent(self: Box<Self>) {
// FIXME: Needs safety information. See entry.S for `set_tls_ptr` definition.
unsafe { set_tls_ptr(core::ptr::addr_of!(*self) as _) };
mem::forget(self);
let ptr = Box::into_raw(self).cast_const().cast::<u8>();
unsafe { set_tls_ptr(ptr) };
}
unsafe fn current<'a>() -> &'a Tls {

View file

@ -5,7 +5,7 @@ use crate::cell::UnsafeCell;
use crate::cmp;
use crate::convert::TryInto;
use crate::intrinsics;
use crate::mem;
use crate::mem::{self, ManuallyDrop};
use crate::ops::{CoerceUnsized, Deref, DerefMut, Index, IndexMut};
use crate::ptr::{self, NonNull};
use crate::slice;
@ -176,6 +176,7 @@ unsafe impl<T: UserSafeSized> UserSafe for [T] {
/// are used solely to indicate intent: a mutable reference is for writing to
/// user memory, an immutable reference for reading from user memory.
#[unstable(feature = "sgx_platform", issue = "56975")]
#[repr(transparent)]
pub struct UserRef<T: ?Sized>(UnsafeCell<T>);
/// An owned type in userspace memory. `User<T>` is equivalent to `Box<T>` in
/// enclave memory. Access to the memory is only allowed by copying to avoid
@ -266,9 +267,7 @@ where
/// Converts this value into a raw pointer. The value will no longer be
/// automatically freed.
pub fn into_raw(self) -> *mut T {
let ret = self.0;
mem::forget(self);
ret.as_ptr() as _
ManuallyDrop::new(self).0.as_ptr() as _
}
}

View file

@ -2,7 +2,7 @@ use fortanix_sgx_abi::Fd;
use super::abi::usercalls;
use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut};
use crate::mem;
use crate::mem::ManuallyDrop;
use crate::sys::{AsInner, FromInner, IntoInner};
#[derive(Debug)]
@ -21,9 +21,7 @@ impl FileDesc {
/// Extracts the actual file descriptor without closing it.
pub fn into_raw(self) -> Fd {
let fd = self.fd;
mem::forget(self);
fd
ManuallyDrop::new(self).fd
}
pub fn read(&self, buf: &mut [u8]) -> io::Result<usize> {
@ -70,9 +68,7 @@ impl AsInner<Fd> for FileDesc {
impl IntoInner<Fd> for FileDesc {
fn into_inner(self) -> Fd {
let fd = self.fd;
mem::forget(self);
fd
ManuallyDrop::new(self).fd
}
}

View file

@ -1,9 +1,7 @@
use core::convert::TryInto;
use crate::cmp;
use crate::ffi::CStr;
use crate::io;
use crate::mem;
use crate::mem::{self, ManuallyDrop};
use crate::num::NonZero;
use crate::ptr;
use crate::sys::os;
@ -115,11 +113,9 @@ impl Thread {
/// must join, because no pthread_detach supported
pub fn join(self) {
unsafe {
let ret = libc::pthread_join(self.id, ptr::null_mut());
mem::forget(self);
assert!(ret == 0, "failed to join thread: {}", io::Error::from_raw_os_error(ret));
}
let id = self.into_id();
let ret = unsafe { libc::pthread_join(id, ptr::null_mut()) };
assert!(ret == 0, "failed to join thread: {}", io::Error::from_raw_os_error(ret));
}
pub fn id(&self) -> libc::pthread_t {
@ -127,9 +123,7 @@ impl Thread {
}
pub fn into_id(self) -> libc::pthread_t {
let id = self.id;
mem::forget(self);
id
ManuallyDrop::new(self).id
}
}

View file

@ -125,6 +125,7 @@ impl FileDesc {
(&mut me).read_to_end(buf)
}
#[cfg_attr(target_os = "vxworks", allow(unused_unsafe))]
pub fn read_at(&self, buf: &mut [u8], offset: u64) -> io::Result<usize> {
#[cfg(not(any(
all(target_os = "linux", not(target_env = "musl")),
@ -318,6 +319,7 @@ impl FileDesc {
cfg!(not(any(target_os = "espidf", target_os = "horizon", target_os = "vita")))
}
#[cfg_attr(target_os = "vxworks", allow(unused_unsafe))]
pub fn write_at(&self, buf: &[u8], offset: u64) -> io::Result<usize> {
#[cfg(not(any(
all(target_os = "linux", not(target_env = "musl")),

View file

@ -857,6 +857,7 @@ impl Drop for Dir {
target_os = "espidf",
target_os = "fuchsia",
target_os = "horizon",
target_os = "vxworks",
)))]
{
let fd = unsafe { libc::dirfd(self.0) };
@ -1313,7 +1314,12 @@ impl File {
}
pub fn set_times(&self, times: FileTimes) -> io::Result<()> {
#[cfg(not(any(target_os = "redox", target_os = "espidf", target_os = "horizon")))]
#[cfg(not(any(
target_os = "redox",
target_os = "espidf",
target_os = "horizon",
target_os = "vxworks"
)))]
let to_timespec = |time: Option<SystemTime>| match time {
Some(time) if let Some(ts) = time.t.to_timespec() => Ok(ts),
Some(time) if time > crate::sys::time::UNIX_EPOCH => Err(io::const_io_error!(
@ -1327,10 +1333,11 @@ impl File {
None => Ok(libc::timespec { tv_sec: 0, tv_nsec: libc::UTIME_OMIT as _ }),
};
cfg_if::cfg_if! {
if #[cfg(any(target_os = "redox", target_os = "espidf", target_os = "horizon"))] {
if #[cfg(any(target_os = "redox", target_os = "espidf", target_os = "horizon", target_os = "vxworks"))] {
// Redox doesn't appear to support `UTIME_OMIT`.
// ESP-IDF and HorizonOS do not support `futimens` at all and the behavior for those OS is therefore
// the same as for Redox.
// `futimens` and `UTIME_OMIT` are a work in progress for vxworks.
let _ = times;
Err(io::const_io_error!(
io::ErrorKind::Unsupported,
@ -1962,6 +1969,7 @@ pub fn fchown(fd: c_int, uid: u32, gid: u32) -> io::Result<()> {
Ok(())
}
#[cfg(not(target_os = "vxworks"))]
pub fn lchown(path: &Path, uid: u32, gid: u32) -> io::Result<()> {
run_path_with_cstr(path, &|path| {
cvt(unsafe { libc::lchown(path.as_ptr(), uid as libc::uid_t, gid as libc::gid_t) })
@ -1969,11 +1977,23 @@ pub fn lchown(path: &Path, uid: u32, gid: u32) -> io::Result<()> {
})
}
#[cfg(target_os = "vxworks")]
pub fn lchown(path: &Path, uid: u32, gid: u32) -> io::Result<()> {
let (_, _, _) = (path, uid, gid);
Err(io::const_io_error!(io::ErrorKind::Unsupported, "lchown not supported by vxworks"))
}
#[cfg(not(any(target_os = "fuchsia", target_os = "vxworks")))]
pub fn chroot(dir: &Path) -> io::Result<()> {
run_path_with_cstr(dir, &|dir| cvt(unsafe { libc::chroot(dir.as_ptr()) }).map(|_| ()))
}
#[cfg(target_os = "vxworks")]
pub fn chroot(dir: &Path) -> io::Result<()> {
let _ = dir;
Err(io::const_io_error!(io::ErrorKind::Unsupported, "chroot not supported by vxworks"))
}
pub use remove_dir_impl::remove_dir_all;
// Fallback for REDOX, ESP-ID, Horizon, Vita, Vxworks and Miri

View file

@ -164,6 +164,7 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) {
target_os = "emscripten",
target_os = "fuchsia",
target_os = "horizon",
target_os = "vxworks",
// Unikraft's `signal` implementation is currently broken:
// https://github.com/unikraft/lib-musl/issues/57
target_vendor = "unikraft",
@ -209,6 +210,7 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) {
target_os = "emscripten",
target_os = "fuchsia",
target_os = "horizon",
target_os = "vxworks",
)))]
static ON_BROKEN_PIPE_FLAG_USED: crate::sync::atomic::AtomicBool =
crate::sync::atomic::AtomicBool::new(false);
@ -218,6 +220,7 @@ static ON_BROKEN_PIPE_FLAG_USED: crate::sync::atomic::AtomicBool =
target_os = "emscripten",
target_os = "fuchsia",
target_os = "horizon",
target_os = "vxworks",
)))]
pub(crate) fn on_broken_pipe_flag_used() -> bool {
ON_BROKEN_PIPE_FLAG_USED.load(crate::sync::atomic::Ordering::Relaxed)

View file

@ -3,8 +3,8 @@ use crate::io::{self, ErrorKind};
use crate::num::NonZero;
use crate::sys;
use crate::sys::cvt;
use crate::sys::pal::unix::thread;
use crate::sys::process::process_common::*;
use crate::sys_common::thread;
use libc::RTP_ID;
use libc::{self, c_char, c_int};
@ -68,7 +68,12 @@ impl Command {
.as_ref()
.map(|c| c.as_ptr())
.unwrap_or_else(|| *sys::os::environ() as *const _);
let stack_size = thread::min_stack();
let stack_size = crate::cmp::max(
crate::env::var_os("RUST_MIN_STACK")
.and_then(|s| s.to_str().and_then(|s| s.parse().ok()))
.unwrap_or(thread::DEFAULT_MIN_STACK_SIZE),
libc::PTHREAD_STACK_MIN,
);
// ensure that access to the environment is synchronized
let _lock = sys::os::env_read_lock();

View file

@ -1,7 +1,7 @@
use crate::cmp;
use crate::ffi::CStr;
use crate::io;
use crate::mem;
use crate::mem::{self, ManuallyDrop};
use crate::num::NonZero;
use crate::ptr;
use crate::sys::{os, stack_overflow};
@ -268,11 +268,9 @@ impl Thread {
}
pub fn join(self) {
unsafe {
let ret = libc::pthread_join(self.id, ptr::null_mut());
mem::forget(self);
assert!(ret == 0, "failed to join thread: {}", io::Error::from_raw_os_error(ret));
}
let id = self.into_id();
let ret = unsafe { libc::pthread_join(id, ptr::null_mut()) };
assert!(ret == 0, "failed to join thread: {}", io::Error::from_raw_os_error(ret));
}
pub fn id(&self) -> libc::pthread_t {
@ -280,9 +278,7 @@ impl Thread {
}
pub fn into_id(self) -> libc::pthread_t {
let id = self.id;
mem::forget(self);
id
ManuallyDrop::new(self).id
}
}

View file

@ -172,12 +172,10 @@ impl Thread {
pub fn join(self) {
cfg_if::cfg_if! {
if #[cfg(target_feature = "atomics")] {
unsafe {
let ret = libc::pthread_join(self.id, ptr::null_mut());
mem::forget(self);
if ret != 0 {
rtabort!("failed to join thread: {}", io::Error::from_raw_os_error(ret));
}
let id = mem::ManuallyDrop::new(self).id;
let ret = unsafe { libc::pthread_join(id, ptr::null_mut()) };
if ret != 0 {
rtabort!("failed to join thread: {}", io::Error::from_raw_os_error(ret));
}
} else {
self.0

View file

@ -37,7 +37,7 @@ windows_targets::link!("kernel32.dll" "system" fn GetProcessHeap() -> c::HANDLE)
// Note that `dwBytes` is allowed to be zero, contrary to some other allocators.
//
// See https://docs.microsoft.com/windows/win32/api/heapapi/nf-heapapi-heapalloc
windows_targets::link!("kernel32.dll" "system" fn HeapAlloc(hheap: c::HANDLE, dwflags: u32, dwbytes: usize) -> *mut core::ffi::c_void);
windows_targets::link!("kernel32.dll" "system" fn HeapAlloc(hheap: c::HANDLE, dwflags: u32, dwbytes: usize) -> *mut c_void);
// Reallocate a block of memory behind a given pointer `lpMem` from a given heap `hHeap`,
// to a block of at least `dwBytes` bytes, either shrinking the block in place,
@ -61,9 +61,9 @@ windows_targets::link!("kernel32.dll" "system" fn HeapAlloc(hheap: c::HANDLE, dw
windows_targets::link!("kernel32.dll" "system" fn HeapReAlloc(
hheap: c::HANDLE,
dwflags : u32,
lpmem: *const core::ffi::c_void,
lpmem: *const c_void,
dwbytes: usize
) -> *mut core::ffi::c_void);
) -> *mut c_void);
// Free a block of memory behind a given pointer `lpMem` from a given heap `hHeap`.
// Returns a nonzero value if the operation is successful, and zero if the operation fails.
@ -79,7 +79,7 @@ windows_targets::link!("kernel32.dll" "system" fn HeapReAlloc(
// Note that `lpMem` is allowed to be null, which will not cause the operation to fail.
//
// See https://docs.microsoft.com/windows/win32/api/heapapi/nf-heapapi-heapfree
windows_targets::link!("kernel32.dll" "system" fn HeapFree(hheap: c::HANDLE, dwflags: u32, lpmem: *const core::ffi::c_void) -> c::BOOL);
windows_targets::link!("kernel32.dll" "system" fn HeapFree(hheap: c::HANDLE, dwflags: u32, lpmem: *const c_void) -> c::BOOL);
// Cached handle to the default heap of the current process.
// Either a non-null handle returned by `GetProcessHeap`, or null when not yet initialized or `GetProcessHeap` failed.

View file

@ -4,12 +4,10 @@
#![cfg_attr(test, allow(dead_code))]
#![unstable(issue = "none", feature = "windows_c")]
#![allow(clippy::style)]
#![allow(unsafe_op_in_unsafe_fn)]
use crate::ffi::CStr;
use crate::mem;
use crate::os::raw::{c_uint, c_ulong, c_ushort, c_void};
use crate::ptr;
use core::ffi::{c_uint, c_ulong, c_ushort, c_void, CStr};
use core::mem;
use core::ptr;
pub(super) mod windows_targets;
@ -136,26 +134,26 @@ compat_fn_with_fallback! {
// >= Win10 1607
// https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-setthreaddescription
pub fn SetThreadDescription(hthread: HANDLE, lpthreaddescription: PCWSTR) -> HRESULT {
SetLastError(ERROR_CALL_NOT_IMPLEMENTED as u32); E_NOTIMPL
unsafe { SetLastError(ERROR_CALL_NOT_IMPLEMENTED as u32); E_NOTIMPL }
}
// >= Win10 1607
// https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getthreaddescription
pub fn GetThreadDescription(hthread: HANDLE, lpthreaddescription: *mut PWSTR) -> HRESULT {
SetLastError(ERROR_CALL_NOT_IMPLEMENTED as u32); E_NOTIMPL
unsafe { SetLastError(ERROR_CALL_NOT_IMPLEMENTED as u32); E_NOTIMPL }
}
// >= Win8 / Server 2012
// https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimepreciseasfiletime
#[cfg(target_vendor = "win7")]
pub fn GetSystemTimePreciseAsFileTime(lpsystemtimeasfiletime: *mut FILETIME) -> () {
GetSystemTimeAsFileTime(lpsystemtimeasfiletime)
unsafe { GetSystemTimeAsFileTime(lpsystemtimeasfiletime) }
}
// >= Win11 / Server 2022
// https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppath2a
pub fn GetTempPath2W(bufferlength: u32, buffer: PWSTR) -> u32 {
GetTempPathW(bufferlength, buffer)
unsafe { GetTempPathW(bufferlength, buffer) }
}
}
@ -188,12 +186,12 @@ extern "system" {
compat_fn_optional! {
crate::sys::compat::load_synch_functions();
pub fn WaitOnAddress(
address: *const ::core::ffi::c_void,
compareaddress: *const ::core::ffi::c_void,
address: *const c_void,
compareaddress: *const c_void,
addresssize: usize,
dwmilliseconds: u32
) -> BOOL;
pub fn WakeByAddressSingle(address: *const ::core::ffi::c_void);
pub fn WakeByAddressSingle(address: *const c_void);
}
#[cfg(any(target_vendor = "win7", target_vendor = "uwp"))]
@ -240,7 +238,7 @@ compat_fn_with_fallback! {
shareaccess: FILE_SHARE_MODE,
createdisposition: NTCREATEFILE_CREATE_DISPOSITION,
createoptions: NTCREATEFILE_CREATE_OPTIONS,
eabuffer: *const ::core::ffi::c_void,
eabuffer: *const c_void,
ealength: u32
) -> NTSTATUS {
STATUS_NOT_IMPLEMENTED
@ -250,9 +248,9 @@ compat_fn_with_fallback! {
filehandle: HANDLE,
event: HANDLE,
apcroutine: PIO_APC_ROUTINE,
apccontext: *const core::ffi::c_void,
apccontext: *const c_void,
iostatusblock: *mut IO_STATUS_BLOCK,
buffer: *mut core::ffi::c_void,
buffer: *mut c_void,
length: u32,
byteoffset: *const i64,
key: *const u32
@ -264,9 +262,9 @@ compat_fn_with_fallback! {
filehandle: HANDLE,
event: HANDLE,
apcroutine: PIO_APC_ROUTINE,
apccontext: *const core::ffi::c_void,
apccontext: *const c_void,
iostatusblock: *mut IO_STATUS_BLOCK,
buffer: *const core::ffi::c_void,
buffer: *const c_void,
length: u32,
byteoffset: *const i64,
key: *const u32

View file

@ -158,8 +158,10 @@ macro_rules! compat_fn_with_fallback {
static PTR: AtomicPtr<c_void> = AtomicPtr::new(load as *mut _);
unsafe extern "system" fn load($($argname: $argtype),*) -> $rettype {
let func = load_from_module(Module::new($module));
func($($argname),*)
unsafe {
let func = load_from_module(Module::new($module));
func($($argname),*)
}
}
fn load_from_module(module: Option<Module>) -> F {
@ -182,8 +184,10 @@ macro_rules! compat_fn_with_fallback {
#[inline(always)]
pub unsafe fn call($($argname: $argtype),*) -> $rettype {
let func: F = mem::transmute(PTR.load(Ordering::Relaxed));
func($($argname),*)
unsafe {
let func: F = mem::transmute(PTR.load(Ordering::Relaxed));
func($($argname),*)
}
}
}
#[allow(unused)]
@ -225,7 +229,7 @@ macro_rules! compat_fn_optional {
}
#[inline]
pub unsafe extern "system" fn $symbol($($argname: $argtype),*) $(-> $rettype)? {
$symbol::option().unwrap()($($argname),*)
unsafe { $symbol::option().unwrap()($($argname),*) }
}
)+
)

View file

@ -3,16 +3,17 @@
#[cfg(test)]
mod tests;
use crate::cmp;
use crate::io::{self, BorrowedCursor, ErrorKind, IoSlice, IoSliceMut, Read};
use crate::mem;
use crate::os::windows::io::{
AsHandle, AsRawHandle, BorrowedHandle, FromRawHandle, IntoRawHandle, OwnedHandle, RawHandle,
};
use crate::ptr;
use crate::sys::c;
use crate::sys::cvt;
use crate::sys_common::{AsInner, FromInner, IntoInner};
use core::cmp;
use core::ffi::c_void;
use core::mem;
use core::ptr;
/// An owned container for `HANDLE` object, closing them on Drop.
///
@ -255,7 +256,7 @@ impl Handle {
None,
ptr::null_mut(),
&mut io_status,
buf.cast::<core::ffi::c_void>(),
buf.cast::<c_void>(),
len,
offset.as_ref().map(|n| ptr::from_ref(n).cast::<i64>()).unwrap_or(ptr::null()),
ptr::null(),
@ -305,7 +306,7 @@ impl Handle {
None,
ptr::null_mut(),
&mut io_status,
buf.as_ptr().cast::<core::ffi::c_void>(),
buf.as_ptr().cast::<c_void>(),
len,
offset.as_ref().map(|n| ptr::from_ref(n).cast::<i64>()).unwrap_or(ptr::null()),
ptr::null(),

View file

@ -1,5 +1,5 @@
#![allow(missing_docs, nonstandard_style)]
#![deny(unsafe_op_in_unsafe_fn)]
#![forbid(unsafe_op_in_unsafe_fn)]
use crate::ffi::{OsStr, OsString};
use crate::io::ErrorKind;

View file

@ -165,7 +165,7 @@ use crate::ffi::CStr;
use crate::fmt;
use crate::io;
use crate::marker::PhantomData;
use crate::mem::{self, forget};
use crate::mem::{self, forget, ManuallyDrop};
use crate::num::NonZero;
use crate::panic;
use crate::panicking;
@ -510,11 +510,10 @@ impl Builder {
MaybeDangling(mem::MaybeUninit::new(x))
}
fn into_inner(self) -> T {
// SAFETY: we are always initialized.
let ret = unsafe { self.0.assume_init_read() };
// Make sure we don't drop.
mem::forget(self);
ret
let this = ManuallyDrop::new(self);
// SAFETY: we are always initialized.
unsafe { this.0.assume_init_read() }
}
}
impl<T> Drop for MaybeDangling<T> {

View file

@ -10,7 +10,7 @@ LL | assert_eq!(libc::pthread_mutex_lock(lock_copy.0.get() as *mut _
error: deadlock: the evaluated program deadlocked
--> RUSTLIB/std/src/sys/pal/PLATFORM/thread.rs:LL:CC
|
LL | let ret = libc::pthread_join(self.id, ptr::null_mut());
LL | let ret = unsafe { libc::pthread_join(id, ptr::null_mut()) };
| ^ the evaluated program deadlocked
|
= note: BACKTRACE:

View file

@ -10,7 +10,7 @@ LL | assert_eq!(libc::pthread_rwlock_wrlock(lock_copy.0.get() as *mu
error: deadlock: the evaluated program deadlocked
--> RUSTLIB/std/src/sys/pal/PLATFORM/thread.rs:LL:CC
|
LL | let ret = libc::pthread_join(self.id, ptr::null_mut());
LL | let ret = unsafe { libc::pthread_join(id, ptr::null_mut()) };
| ^ the evaluated program deadlocked
|
= note: BACKTRACE:

View file

@ -10,7 +10,7 @@ LL | assert_eq!(libc::pthread_rwlock_wrlock(lock_copy.0.get() as *mu
error: deadlock: the evaluated program deadlocked
--> RUSTLIB/std/src/sys/pal/PLATFORM/thread.rs:LL:CC
|
LL | let ret = libc::pthread_join(self.id, ptr::null_mut());
LL | let ret = unsafe { libc::pthread_join(id, ptr::null_mut()) };
| ^ the evaluated program deadlocked
|
= note: BACKTRACE:

View file

@ -18,9 +18,9 @@
// ignore-tidy-dbg
use crate::walk::{filter_dirs, walk};
use regex::RegexSet;
use regex::RegexSetBuilder;
use rustc_hash::FxHashMap;
use std::{ffi::OsStr, path::Path};
use std::{ffi::OsStr, path::Path, sync::LazyLock};
#[cfg(test)]
mod tests;
@ -110,16 +110,26 @@ const ROOT_PROBLEMATIC_CONSTS: &[u32] = &[
173390526, 721077,
];
const LETTER_DIGIT: &[(char, char)] = &[('A', '4'), ('B', '8'), ('E', '3')];
// Returns all permutations of problematic consts, over 2000 elements.
fn generate_problematic_strings(
consts: &[u32],
letter_digit: &FxHashMap<char, char>,
) -> Vec<String> {
generate_problems(consts, letter_digit)
.flat_map(|v| vec![v.to_string(), format!("{:x}", v), format!("{:X}", v)])
.flat_map(|v| vec![v.to_string(), format!("{:X}", v)])
.collect()
}
static PROBLEMATIC_CONSTS_STRINGS: LazyLock<Vec<String>> = LazyLock::new(|| {
generate_problematic_strings(ROOT_PROBLEMATIC_CONSTS, &LETTER_DIGIT.iter().cloned().collect())
});
fn contains_problematic_const(trimmed: &str) -> bool {
PROBLEMATIC_CONSTS_STRINGS.iter().any(|s| trimmed.to_uppercase().contains(s))
}
const INTERNAL_COMPILER_DOCS_LINE: &str = "#### This error code is internal to the compiler and will not be emitted with normal Rust code.";
/// Parser states for `line_is_url`.
@ -316,14 +326,14 @@ pub fn check(path: &Path, bad: &mut bool) {
// We only check CSS files in rustdoc.
path.extension().map_or(false, |e| e == "css") && !is_in(path, "src", "librustdoc")
}
let problematic_consts_strings = generate_problematic_strings(
ROOT_PROBLEMATIC_CONSTS,
&[('A', '4'), ('B', '8'), ('E', '3')].iter().cloned().collect(),
);
// This creates a RegexSet as regex contains performance optimizations to be able to deal with these over
// 2000 needles efficiently. This runs over the entire source code, so performance matters.
let problematic_regex = RegexSet::new(problematic_consts_strings.as_slice()).unwrap();
let problematic_regex = RegexSetBuilder::new(PROBLEMATIC_CONSTS_STRINGS.as_slice())
.case_insensitive(true)
.build()
.unwrap();
let style_file = Path::new(file!());
walk(path, skip, &mut |entry, contents| {
let file = entry.path();
let filename = file.file_name().unwrap().to_string_lossy();
@ -389,10 +399,15 @@ pub fn check(path: &Path, bad: &mut bool) {
let mut lines = 0;
let mut last_safety_comment = false;
let mut comment_block: Option<(usize, usize)> = None;
let is_test = file.components().any(|c| c.as_os_str() == "tests");
let is_test = file.components().any(|c| c.as_os_str() == "tests")
|| file.file_stem().unwrap() == "tests";
let is_style = file.ends_with(style_file) || style_file.ends_with(file);
let is_style_test =
is_test && file.parent().unwrap().ends_with(style_file.with_extension(""));
// scanning the whole file for multiple needles at once is more efficient than
// executing lines times needles separate searches.
let any_problematic_line = problematic_regex.is_match(contents);
let any_problematic_line =
!is_style && !is_style_test && problematic_regex.is_match(contents);
for (i, line) in contents.split('\n').enumerate() {
if line.is_empty() {
if i == 0 {
@ -451,7 +466,7 @@ pub fn check(path: &Path, bad: &mut bool) {
if line.contains('\r') {
suppressible_tidy_err!(err, skip_cr, "CR character");
}
if filename != "style.rs" {
if !is_style {
// Allow using TODO in diagnostic suggestions by marking the
// relevant line with `// ignore-tidy-todo`.
if trimmed.contains("TODO") && !trimmed.contains("ignore-tidy-todo") {
@ -462,12 +477,8 @@ pub fn check(path: &Path, bad: &mut bool) {
if trimmed.contains("//") && trimmed.contains(" XXX") {
err("Instead of XXX use FIXME")
}
if any_problematic_line {
for s in problematic_consts_strings.iter() {
if trimmed.contains(s) {
err("Don't use magic numbers that spell things (consider 0x12345678)");
}
}
if any_problematic_line && contains_problematic_const(trimmed) {
err("Don't use magic numbers that spell things (consider 0x12345678)");
}
}
// for now we just check libcore

View file

@ -1,17 +1,10 @@
use super::*;
#[test]
fn test_generate_problematic_strings() {
let problematic_regex = RegexSet::new(
generate_problematic_strings(
ROOT_PROBLEMATIC_CONSTS,
&[('A', '4'), ('B', '8'), ('E', '3'), ('0', 'F')].iter().cloned().collect(), // use "futile" F intentionally
)
.as_slice(),
)
.unwrap();
assert!(problematic_regex.is_match("786357")); // check with no "decimal" hex digits - converted to integer
assert!(problematic_regex.is_match("589701")); // check with "decimal" replacements - converted to integer
assert!(problematic_regex.is_match("8FF85")); // check for hex display
assert!(!problematic_regex.is_match("1193046")); // check for non-matching value
fn test_contains_problematic_const() {
assert!(contains_problematic_const("721077")); // check with no "decimal" hex digits - converted to integer
assert!(contains_problematic_const("524421")); // check with "decimal" replacements - converted to integer
assert!(contains_problematic_const(&(285 * 281).to_string())); // check for hex display
assert!(contains_problematic_const(&format!("{:x}B5", 2816))); // check for case-alternating hex display
assert!(!contains_problematic_const("1193046")); // check for non-matching value
}

View file

@ -18,7 +18,7 @@ error[E0107]: associated type takes 0 generic arguments but 1 generic argument w
--> $DIR/invalid_const_in_lifetime_position.rs:4:26
|
LL | fn f<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
| ^--- help: remove these generics
| ^--- help: remove the unnecessary generics
| |
| expected 0 generic arguments
|
@ -49,7 +49,7 @@ error[E0107]: associated type takes 0 generic arguments but 1 generic argument w
--> $DIR/invalid_const_in_lifetime_position.rs:4:26
|
LL | fn f<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
| ^--- help: remove these generics
| ^--- help: remove the unnecessary generics
| |
| expected 0 generic arguments
|
@ -81,7 +81,7 @@ error[E0107]: associated type takes 0 generic arguments but 1 generic argument w
--> $DIR/invalid_const_in_lifetime_position.rs:4:26
|
LL | fn f<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
| ^--- help: remove these generics
| ^--- help: remove the unnecessary generics
| |
| expected 0 generic arguments
|

View file

@ -2,7 +2,7 @@ error[E0107]: type alias takes 1 lifetime argument but 2 lifetime arguments were
--> $DIR/mismatched_arg_count.rs:7:29
|
LL | fn bar<'a, T: Trait<'a>>(_: Alias<'a, 'a, T>) {}
| ^^^^^ -- help: remove this lifetime argument
| ^^^^^ ---- help: remove the lifetime argument
| |
| expected 1 lifetime argument
|

View file

@ -2,7 +2,7 @@ error[E0107]: function takes 0 generic arguments but 1 generic argument was supp
--> $DIR/issue-100154.rs:4:5
|
LL | foo::<()>(());
| ^^^------ help: remove these generics
| ^^^------ help: remove the unnecessary generics
| |
| expected 0 generic arguments
|

View file

@ -3,5 +3,7 @@ fn foo(x: impl async Fn()) -> impl async Fn() { x }
//~| ERROR `async` trait bounds are only allowed in Rust 2018 or later
//~| ERROR async closures are unstable
//~| ERROR async closures are unstable
//~| ERROR use of unstable library feature 'async_closure'
//~| ERROR use of unstable library feature 'async_closure'
fn main() {}

View file

@ -38,6 +38,26 @@ LL | fn foo(x: impl async Fn()) -> impl async Fn() { x }
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
= help: to use an async block, remove the `||`: `async {`
error: aborting due to 4 previous errors
error[E0658]: use of unstable library feature 'async_closure'
--> $DIR/edition-2015.rs:1:22
|
LL | fn foo(x: impl async Fn()) -> impl async Fn() { x }
| ^^^^
|
= note: see issue #62290 <https://github.com/rust-lang/rust/issues/62290> for more information
= help: add `#![feature(async_closure)]` 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[E0658]: use of unstable library feature 'async_closure'
--> $DIR/edition-2015.rs:1:42
|
LL | fn foo(x: impl async Fn()) -> impl async Fn() { x }
| ^^^^
|
= note: see issue #62290 <https://github.com/rust-lang/rust/issues/62290> for more information
= help: add `#![feature(async_closure)]` 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: aborting due to 6 previous errors
For more information about this error, try `rustc --explain E0658`.

View file

@ -2,7 +2,7 @@
//@ edition: 2021
//@ build-pass
#![feature(async_fn_traits)]
#![feature(async_closure)]
extern crate block_on;

View file

@ -2,7 +2,7 @@ error[E0107]: struct takes 0 lifetime arguments but 1 lifetime argument was supp
--> $DIR/issue-82126-mismatched-subst-and-hir.rs:16:59
|
LL | async fn buy_lock(coroutine: &Mutex<MarketMultiplier>) -> LockedMarket<'_> {
| ^^^^^^^^^^^^---- help: remove these generics
| ^^^^^^^^^^^^---- help: remove the unnecessary generics
| |
| expected 0 lifetime arguments
|
@ -32,7 +32,7 @@ error[E0107]: struct takes 0 lifetime arguments but 1 lifetime argument was supp
--> $DIR/issue-82126-mismatched-subst-and-hir.rs:16:59
|
LL | async fn buy_lock(coroutine: &Mutex<MarketMultiplier>) -> LockedMarket<'_> {
| ^^^^^^^^^^^^---- help: remove these generics
| ^^^^^^^^^^^^---- help: remove the unnecessary generics
| |
| expected 0 lifetime arguments
|

View file

@ -2,7 +2,7 @@ error[E0107]: trait takes at most 2 generic arguments but 3 generic arguments we
--> $DIR/transmutable-ice-110969.rs:11:14
|
LL | Dst: BikeshedIntrinsicFrom<Src, Context, ASSUME>,
| ^^^^^^^^^^^^^^^^^^^^^ ------ help: remove this generic argument
| ^^^^^^^^^^^^^^^^^^^^^ -------- help: remove the unnecessary generic argument
| |
| expected at most 2 generic arguments

View file

@ -23,7 +23,7 @@ error[E0107]: struct takes 2 generic arguments but 3 generic arguments were supp
--> $DIR/infer-arg-test.rs:18:10
|
LL | let a: All<_, _, _>;
| ^^^ - help: remove this generic argument
| ^^^ --- help: remove the unnecessary generic argument
| |
| expected 2 generic arguments
|

View file

@ -2,7 +2,7 @@ error[E0107]: function takes 1 generic argument but 2 generic arguments were sup
--> $DIR/issue_114151.rs:17:5
|
LL | foo::<_, L>([(); L + 1 + L]);
| ^^^ - help: remove this generic argument
| ^^^ --- help: remove the unnecessary generic argument
| |
| expected 1 generic argument
|

View file

@ -18,7 +18,7 @@ error[E0107]: associated type takes 0 generic arguments but 1 generic argument w
--> $DIR/issue-102768.rs:9:30
|
LL | fn f2<'a>(arg: Box<dyn X<Y<1> = &'a ()>>) {}
| ^--- help: remove these generics
| ^--- help: remove the unnecessary generics
| |
| expected 0 generic arguments
|
@ -49,7 +49,7 @@ error[E0107]: associated type takes 0 generic arguments but 1 generic argument w
--> $DIR/issue-102768.rs:9:30
|
LL | fn f2<'a>(arg: Box<dyn X<Y<1> = &'a ()>>) {}
| ^--- help: remove these generics
| ^--- help: remove the unnecessary generics
| |
| expected 0 generic arguments
|
@ -81,7 +81,7 @@ error[E0107]: associated type takes 0 generic arguments but 1 generic argument w
--> $DIR/issue-102768.rs:9:30
|
LL | fn f2<'a>(arg: Box<dyn X<Y<1> = &'a ()>>) {}
| ^--- help: remove these generics
| ^--- help: remove the unnecessary generics
| |
| expected 0 generic arguments
|

View file

@ -20,7 +20,7 @@ error[E0107]: function takes 2 generic arguments but 3 generic arguments were su
--> $DIR/incorrect-number-of-const-args.rs:9:5
|
LL | foo::<0, 0, 0>();
| ^^^ - help: remove this generic argument
| ^^^ --- help: remove the unnecessary generic argument
| |
| expected 2 generic arguments
|

View file

@ -8,7 +8,7 @@ help: consider moving this generic argument to the `TryInto` trait, which takes
|
LL | let _: u32 = TryInto::<32>::try_into(5i32).unwrap();
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
help: remove these generics
help: remove the unnecessary generics
|
LL - let _: u32 = 5i32.try_into::<32>().unwrap();
LL + let _: u32 = 5i32.try_into().unwrap();
@ -27,7 +27,7 @@ error[E0107]: struct takes 0 generic arguments but 1 generic argument was suppli
--> $DIR/invalid-const-arg-for-type-param.rs:12:5
|
LL | S::<0>;
| ^----- help: remove these generics
| ^----- help: remove the unnecessary generics
| |
| expected 0 generic arguments
|

View file

@ -2,7 +2,7 @@ error[E0107]: struct takes 1 generic argument but 2 generic arguments were suppl
--> $DIR/invalid-constant-in-args.rs:4:12
|
LL | let _: Cell<&str, "a"> = Cell::new("");
| ^^^^ --- help: remove this generic argument
| ^^^^ ----- help: remove the unnecessary generic argument
| |
| expected 1 generic argument

View file

@ -20,7 +20,7 @@ error[E0107]: struct takes 2 lifetime arguments but 3 lifetime arguments were su
--> $DIR/constructor-lifetime-args.rs:19:5
|
LL | S::<'static, 'static, 'static>(&0, &0);
| ^ ------- help: remove this lifetime argument
| ^ --------- help: remove the lifetime argument
| |
| expected 2 lifetime arguments
|
@ -52,7 +52,7 @@ error[E0107]: enum takes 2 lifetime arguments but 3 lifetime arguments were supp
--> $DIR/constructor-lifetime-args.rs:24:8
|
LL | E::V::<'static, 'static, 'static>(&0);
| ^ ------- help: remove this lifetime argument
| ^ --------- help: remove the lifetime argument
| |
| expected 2 lifetime arguments
|

View file

@ -2,7 +2,7 @@ error[E0107]: method takes 0 generic arguments but 1 generic argument was suppli
--> $DIR/effect_param.rs:11:9
|
LL | i8::checked_sub::<false>(42, 43);
| ^^^^^^^^^^^--------- help: remove these generics
| ^^^^^^^^^^^--------- help: remove the unnecessary generics
| |
| expected 0 generic arguments
@ -10,7 +10,7 @@ error[E0107]: method takes 0 generic arguments but 1 generic argument was suppli
--> $DIR/effect_param.rs:13:9
|
LL | i8::checked_sub::<true>(42, 43);
| ^^^^^^^^^^^-------- help: remove these generics
| ^^^^^^^^^^^-------- help: remove the unnecessary generics
| |
| expected 0 generic arguments
@ -18,7 +18,7 @@ error[E0107]: method takes 0 generic arguments but 1 generic argument was suppli
--> $DIR/effect_param.rs:4:9
|
LL | i8::checked_sub::<true>(42, 43);
| ^^^^^^^^^^^-------- help: remove these generics
| ^^^^^^^^^^^-------- help: remove the unnecessary generics
| |
| expected 0 generic arguments
@ -26,7 +26,7 @@ error[E0107]: method takes 0 generic arguments but 1 generic argument was suppli
--> $DIR/effect_param.rs:6:9
|
LL | i8::checked_sub::<false>(42, 43);
| ^^^^^^^^^^^--------- help: remove these generics
| ^^^^^^^^^^^--------- help: remove the unnecessary generics
| |
| expected 0 generic arguments

View file

@ -16,35 +16,35 @@ struct Baz<'a, 'b, 'c> {
bar: Bar<'a>,
//~^ ERROR enum takes 0 lifetime arguments
//~| HELP remove these generics
//~| HELP remove the unnecessary generics
foo2: Foo<'a, 'b, 'c>,
//~^ ERROR struct takes 1 lifetime argument
//~| HELP remove these lifetime arguments
//~| HELP remove the lifetime arguments
qux1: Qux<'a, 'b, i32>,
//~^ ERROR struct takes 1 lifetime argument
//~| HELP remove this lifetime argument
//~| HELP remove the lifetime argument
qux2: Qux<'a, i32, 'b>,
//~^ ERROR struct takes 1 lifetime argument
//~| HELP remove this lifetime argument
//~| HELP remove the lifetime argument
qux3: Qux<'a, 'b, 'c, i32>,
//~^ ERROR struct takes 1 lifetime argument
//~| HELP remove these lifetime arguments
//~| HELP remove the lifetime arguments
qux4: Qux<'a, i32, 'b, 'c>,
//~^ ERROR struct takes 1 lifetime argument
//~| HELP remove these lifetime arguments
//~| HELP remove the lifetime arguments
qux5: Qux<'a, 'b, i32, 'c>,
//~^ ERROR struct takes 1 lifetime argument
//~| HELP remove this lifetime argument
//~| HELP remove the lifetime argument
quux: Quux<'a, i32, 'b>,
//~^ ERROR struct takes 0 lifetime arguments
//~| HELP remove this lifetime argument
//~| HELP remove the lifetime argument
}
pub trait T {

View file

@ -20,7 +20,7 @@ error[E0107]: enum takes 0 lifetime arguments but 1 lifetime argument was suppli
--> $DIR/E0107.rs:17:10
|
LL | bar: Bar<'a>,
| ^^^---- help: remove these generics
| ^^^---- help: remove the unnecessary generics
| |
| expected 0 lifetime arguments
|
@ -34,7 +34,7 @@ error[E0107]: struct takes 1 lifetime argument but 3 lifetime arguments were sup
--> $DIR/E0107.rs:21:11
|
LL | foo2: Foo<'a, 'b, 'c>,
| ^^^ ------ help: remove these lifetime arguments
| ^^^ -------- help: remove the lifetime arguments
| |
| expected 1 lifetime argument
|
@ -48,7 +48,7 @@ error[E0107]: struct takes 1 lifetime argument but 2 lifetime arguments were sup
--> $DIR/E0107.rs:25:11
|
LL | qux1: Qux<'a, 'b, i32>,
| ^^^ -- help: remove this lifetime argument
| ^^^ ---- help: remove the lifetime argument
| |
| expected 1 lifetime argument
|
@ -62,7 +62,7 @@ error[E0107]: struct takes 1 lifetime argument but 2 lifetime arguments were sup
--> $DIR/E0107.rs:29:11
|
LL | qux2: Qux<'a, i32, 'b>,
| ^^^ -- help: remove this lifetime argument
| ^^^ --------- help: remove the lifetime argument
| |
| expected 1 lifetime argument
|
@ -76,7 +76,7 @@ error[E0107]: struct takes 1 lifetime argument but 3 lifetime arguments were sup
--> $DIR/E0107.rs:33:11
|
LL | qux3: Qux<'a, 'b, 'c, i32>,
| ^^^ ------ help: remove these lifetime arguments
| ^^^ -------- help: remove the lifetime arguments
| |
| expected 1 lifetime argument
|
@ -90,7 +90,7 @@ error[E0107]: struct takes 1 lifetime argument but 3 lifetime arguments were sup
--> $DIR/E0107.rs:37:11
|
LL | qux4: Qux<'a, i32, 'b, 'c>,
| ^^^ ------ help: remove these lifetime arguments
| ^^^ ------------- help: remove the lifetime arguments
| |
| expected 1 lifetime argument
|
@ -104,7 +104,7 @@ error[E0107]: struct takes 1 lifetime argument but 3 lifetime arguments were sup
--> $DIR/E0107.rs:41:11
|
LL | qux5: Qux<'a, 'b, i32, 'c>,
| ^^^ -- help: remove this lifetime argument
| ^^^ ---- help: remove the lifetime argument
| |
| expected 1 lifetime argument
|
@ -118,7 +118,7 @@ error[E0107]: struct takes 0 lifetime arguments but 2 lifetime arguments were su
--> $DIR/E0107.rs:45:11
|
LL | quux: Quux<'a, i32, 'b>,
| ^^^^ -- help: remove this lifetime argument
| ^^^^ -- help: remove the lifetime argument
| |
| expected 0 lifetime arguments
|

View file

@ -43,7 +43,7 @@ error[E0107]: associated type takes 0 generic arguments but 1 generic argument w
--> $DIR/gat-trait-path-parenthesised-args.rs:5:27
|
LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
| ^---- help: remove these generics
| ^---- help: remove the unnecessary generics
| |
| expected 0 generic arguments
|
@ -74,7 +74,7 @@ error[E0107]: associated type takes 0 generic arguments but 1 generic argument w
--> $DIR/gat-trait-path-parenthesised-args.rs:5:27
|
LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
| ^---- help: remove these generics
| ^---- help: remove the unnecessary generics
| |
| expected 0 generic arguments
|
@ -106,7 +106,7 @@ error[E0107]: associated type takes 0 generic arguments but 1 generic argument w
--> $DIR/gat-trait-path-parenthesised-args.rs:5:27
|
LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
| ^---- help: remove these generics
| ^---- help: remove the unnecessary generics
| |
| expected 0 generic arguments
|

View file

@ -2,7 +2,7 @@ error[E0107]: associated type takes 1 lifetime argument but 2 lifetime arguments
--> $DIR/parameter_number_and_kind.rs:11:24
|
LL | type FErr1 = Self::E<'static, 'static>;
| ^ ------- help: remove this lifetime argument
| ^ --------- help: remove the lifetime argument
| |
| expected 1 lifetime argument
|
@ -32,7 +32,7 @@ error[E0107]: associated type takes 1 generic argument but 2 generic arguments w
--> $DIR/parameter_number_and_kind.rs:14:27
|
LL | type FErr2<T> = Self::E<'static, T, u32>;
| ^ --- help: remove this generic argument
| ^ ----- help: remove the unnecessary generic argument
| |
| expected 1 generic argument
|

View file

@ -18,7 +18,7 @@ error[E0107]: associated type takes 0 generic arguments but 1 generic argument w
--> $DIR/trait-path-type-error-once-implemented.rs:6:29
|
LL | fn f2<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
| ^--- help: remove these generics
| ^--- help: remove the unnecessary generics
| |
| expected 0 generic arguments
|
@ -49,7 +49,7 @@ error[E0107]: associated type takes 0 generic arguments but 1 generic argument w
--> $DIR/trait-path-type-error-once-implemented.rs:6:29
|
LL | fn f2<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
| ^--- help: remove these generics
| ^--- help: remove the unnecessary generics
| |
| expected 0 generic arguments
|
@ -81,7 +81,7 @@ error[E0107]: associated type takes 0 generic arguments but 1 generic argument w
--> $DIR/trait-path-type-error-once-implemented.rs:6:29
|
LL | fn f2<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
| ^--- help: remove these generics
| ^--- help: remove the unnecessary generics
| |
| expected 0 generic arguments
|

View file

@ -2,7 +2,7 @@ error[E0107]: associated function takes 1 generic argument but 2 generic argumen
--> $DIR/bad-mid-path-type-params.rs:30:16
|
LL | let _ = S::new::<isize,f64>(1, 1.0);
| ^^^ --- help: remove this generic argument
| ^^^ ---- help: remove the unnecessary generic argument
| |
| expected 1 generic argument
|
@ -16,7 +16,7 @@ error[E0107]: struct takes 0 lifetime arguments but 1 lifetime argument was supp
--> $DIR/bad-mid-path-type-params.rs:33:13
|
LL | let _ = S::<'a,isize>::new::<f64>(1, 1.0);
| ^ -- help: remove this lifetime argument
| ^ -- help: remove the lifetime argument
| |
| expected 0 lifetime arguments
|
@ -30,7 +30,7 @@ error[E0107]: associated function takes 1 generic argument but 2 generic argumen
--> $DIR/bad-mid-path-type-params.rs:36:24
|
LL | let _: S2 = Trait::new::<isize,f64>(1, 1.0);
| ^^^ --- help: remove this generic argument
| ^^^ ---- help: remove the unnecessary generic argument
| |
| expected 1 generic argument
|
@ -44,7 +44,7 @@ error[E0107]: trait takes 0 lifetime arguments but 1 lifetime argument was suppl
--> $DIR/bad-mid-path-type-params.rs:39:17
|
LL | let _: S2 = Trait::<'a,isize>::new::<f64,f64>(1, 1.0);
| ^^^^^ -- help: remove this lifetime argument
| ^^^^^ -- help: remove the lifetime argument
| |
| expected 0 lifetime arguments
|
@ -58,7 +58,7 @@ error[E0107]: associated function takes 1 generic argument but 2 generic argumen
--> $DIR/bad-mid-path-type-params.rs:39:36
|
LL | let _: S2 = Trait::<'a,isize>::new::<f64,f64>(1, 1.0);
| ^^^ --- help: remove this generic argument
| ^^^ ---- help: remove the unnecessary generic argument
| |
| expected 1 generic argument
|

View file

@ -20,7 +20,7 @@ error[E0107]: function takes 1 lifetime argument but 2 lifetime arguments were s
--> $DIR/foreign-generic-mismatch.rs:8:31
|
LL | foreign_generic_mismatch::lt_arg::<'static, 'static>();
| ^^^^^^ ------- help: remove this lifetime argument
| ^^^^^^ --------- help: remove the lifetime argument
| |
| expected 1 lifetime argument
|

View file

@ -2,7 +2,7 @@ error[E0107]: struct takes 1 lifetime argument but 2 lifetime arguments were sup
--> $DIR/generic-arg-mismatch-recover.rs:6:5
|
LL | Foo::<'static, 'static, ()>(&0);
| ^^^ ------- help: remove this lifetime argument
| ^^^ --------- help: remove the lifetime argument
| |
| expected 1 lifetime argument
|
@ -16,7 +16,7 @@ error[E0107]: struct takes 1 lifetime argument but 2 lifetime arguments were sup
--> $DIR/generic-arg-mismatch-recover.rs:9:5
|
LL | Bar::<'static, 'static, ()>(&());
| ^^^ ------- help: remove this lifetime argument
| ^^^ --------- help: remove the lifetime argument
| |
| expected 1 lifetime argument
|
@ -30,7 +30,7 @@ error[E0107]: struct takes 0 generic arguments but 1 generic argument was suppli
--> $DIR/generic-arg-mismatch-recover.rs:9:5
|
LL | Bar::<'static, 'static, ()>(&());
| ^^^ -- help: remove this generic argument
| ^^^ -- help: remove the unnecessary generic argument
| |
| expected 0 generic arguments
|

View file

@ -2,7 +2,7 @@ error[E0107]: struct takes at most 2 generic arguments but 3 generic arguments w
--> $DIR/generic-impl-more-params-with-defaults.rs:13:5
|
LL | Vec::<isize, Heap, bool>::new();
| ^^^ ---- help: remove this generic argument
| ^^^ ------ help: remove the unnecessary generic argument
| |
| expected at most 2 generic arguments
|

View file

@ -2,7 +2,7 @@ error[E0107]: struct takes at most 2 generic arguments but 3 generic arguments w
--> $DIR/generic-type-more-params-with-defaults.rs:9:12
|
LL | let _: Vec<isize, Heap, bool>;
| ^^^ ---- help: remove this generic argument
| ^^^ ------ help: remove the unnecessary generic argument
| |
| expected at most 2 generic arguments
|

View file

@ -5,19 +5,19 @@ mod no_generics {
type B = Ty<'static>;
//~^ ERROR struct takes 0 lifetime arguments but 1 lifetime argument
//~| HELP remove these generics
//~| HELP remove the unnecessary generics
type C = Ty<'static, usize>;
//~^ ERROR struct takes 0 lifetime arguments but 1 lifetime argument
//~| ERROR struct takes 0 generic arguments but 1 generic argument
//~| HELP remove this lifetime argument
//~| HELP remove this generic argument
//~| HELP remove the lifetime argument
//~| HELP remove the unnecessary generic argument
type D = Ty<'static, usize, { 0 }>;
//~^ ERROR struct takes 0 lifetime arguments but 1 lifetime argument
//~| ERROR struct takes 0 generic arguments but 2 generic arguments
//~| HELP remove this lifetime argument
//~| HELP remove these generic arguments
//~| HELP remove the lifetime argument
//~| HELP remove the unnecessary generic arguments
}
mod type_and_type {
@ -35,7 +35,7 @@ mod type_and_type {
type D = Ty<usize, String, char>;
//~^ ERROR struct takes 2 generic arguments but 3 generic arguments
//~| HELP remove this
//~| HELP remove the
type E = Ty<>;
//~^ ERROR struct takes 2 generic arguments but 0 generic arguments were supplied
@ -70,8 +70,8 @@ mod lifetime_and_type {
type F = Ty<'static, usize, 'static, usize>;
//~^ ERROR struct takes 1 lifetime argument but 2 lifetime arguments
//~| ERROR struct takes 1 generic argument but 2 generic arguments
//~| HELP remove this lifetime argument
//~| HELP remove this generic argument
//~| HELP remove the lifetime argument
//~| HELP remove the unnecessary generic argument
}
mod type_and_type_and_type {
@ -317,13 +317,13 @@ mod stdlib {
type C = HashMap<'static>;
//~^ ERROR struct takes 0 lifetime arguments but 1 lifetime argument
//~| HELP remove these generics
//~| HELP remove the
//~| ERROR struct takes at least 2
//~| HELP add missing
type D = HashMap<usize, String, char, f64>;
//~^ ERROR struct takes at most 3
//~| HELP remove this
//~| HELP remove the
type E = HashMap<>;
//~^ ERROR struct takes at least 2 generic arguments but 0 generic arguments
@ -341,7 +341,7 @@ mod stdlib {
type C = Result<'static>;
//~^ ERROR enum takes 0 lifetime arguments but 1 lifetime argument
//~| HELP remove these generics
//~| HELP remove the unnecessary generics
//~| ERROR enum takes 2 generic arguments but 0 generic arguments
//~| HELP add missing

View file

@ -171,7 +171,7 @@ error[E0107]: struct takes 0 lifetime arguments but 1 lifetime argument was supp
--> $DIR/wrong-number-of-args.rs:6:14
|
LL | type B = Ty<'static>;
| ^^--------- help: remove these generics
| ^^--------- help: remove the unnecessary generics
| |
| expected 0 lifetime arguments
|
@ -185,7 +185,7 @@ error[E0107]: struct takes 0 lifetime arguments but 1 lifetime argument was supp
--> $DIR/wrong-number-of-args.rs:10:14
|
LL | type C = Ty<'static, usize>;
| ^^ ------- help: remove this lifetime argument
| ^^ ------- help: remove the lifetime argument
| |
| expected 0 lifetime arguments
|
@ -199,7 +199,7 @@ error[E0107]: struct takes 0 generic arguments but 1 generic argument was suppli
--> $DIR/wrong-number-of-args.rs:10:14
|
LL | type C = Ty<'static, usize>;
| ^^ ----- help: remove this generic argument
| ^^ ----- help: remove the unnecessary generic argument
| |
| expected 0 generic arguments
|
@ -213,7 +213,7 @@ error[E0107]: struct takes 0 lifetime arguments but 1 lifetime argument was supp
--> $DIR/wrong-number-of-args.rs:16:14
|
LL | type D = Ty<'static, usize, { 0 }>;
| ^^ ------- help: remove this lifetime argument
| ^^ ------- help: remove the lifetime argument
| |
| expected 0 lifetime arguments
|
@ -227,7 +227,7 @@ error[E0107]: struct takes 0 generic arguments but 2 generic arguments were supp
--> $DIR/wrong-number-of-args.rs:16:14
|
LL | type D = Ty<'static, usize, { 0 }>;
| ^^ ------------ help: remove these generic arguments
| ^^ ------- help: remove the unnecessary generic arguments
| |
| expected 0 generic arguments
|
@ -275,7 +275,7 @@ error[E0107]: struct takes 2 generic arguments but 3 generic arguments were supp
--> $DIR/wrong-number-of-args.rs:36:14
|
LL | type D = Ty<usize, String, char>;
| ^^ ---- help: remove this generic argument
| ^^ ------ help: remove the unnecessary generic argument
| |
| expected 2 generic arguments
|
@ -353,7 +353,7 @@ error[E0107]: struct takes 1 lifetime argument but 2 lifetime arguments were sup
--> $DIR/wrong-number-of-args.rs:70:14
|
LL | type F = Ty<'static, usize, 'static, usize>;
| ^^ ------- help: remove this lifetime argument
| ^^ ---------------- help: remove the lifetime argument
| |
| expected 1 lifetime argument
|
@ -367,7 +367,7 @@ error[E0107]: struct takes 1 generic argument but 2 generic arguments were suppl
--> $DIR/wrong-number-of-args.rs:70:14
|
LL | type F = Ty<'static, usize, 'static, usize>;
| ^^ ----- help: remove this generic argument
| ^^ ---------------- help: remove the unnecessary generic argument
| |
| expected 1 generic argument
|
@ -415,7 +415,7 @@ error[E0107]: struct takes at most 3 generic arguments but 4 generic arguments w
--> $DIR/wrong-number-of-args.rs:92:14
|
LL | type E = Ty<usize, String, char, f64>;
| ^^ --- help: remove this generic argument
| ^^ ----- help: remove the unnecessary generic argument
| |
| expected at most 3 generic arguments
|
@ -445,7 +445,7 @@ error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplie
--> $DIR/wrong-number-of-args.rs:116:22
|
LL | type A = Box<dyn NonGeneric<usize>>;
| ^^^^^^^^^^------- help: remove these generics
| ^^^^^^^^^^------- help: remove the unnecessary generics
| |
| expected 0 generic arguments
|
@ -459,7 +459,7 @@ error[E0107]: trait takes 1 lifetime argument but 2 lifetime arguments were supp
--> $DIR/wrong-number-of-args.rs:125:22
|
LL | type C = Box<dyn GenericLifetime<'static, 'static>>;
| ^^^^^^^^^^^^^^^ ------- help: remove this lifetime argument
| ^^^^^^^^^^^^^^^ --------- help: remove the lifetime argument
| |
| expected 1 lifetime argument
|
@ -489,7 +489,7 @@ error[E0107]: trait takes 1 generic argument but 2 generic arguments were suppli
--> $DIR/wrong-number-of-args.rs:133:22
|
LL | type E = Box<dyn GenericType<String, usize>>;
| ^^^^^^^^^^^ ----- help: remove this generic argument
| ^^^^^^^^^^^ ------- help: remove the unnecessary generic argument
| |
| expected 1 generic argument
|
@ -519,7 +519,7 @@ error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplie
--> $DIR/wrong-number-of-args.rs:153:26
|
LL | type A = Box<dyn NonGenericAT<usize, AssocTy=()>>;
| ^^^^^^^^^^^^------------------- help: remove these generics
| ^^^^^^^^^^^^------------------- help: remove the unnecessary generics
| |
| expected 0 generic arguments
|
@ -533,7 +533,7 @@ error[E0107]: trait takes 1 lifetime argument but 2 lifetime arguments were supp
--> $DIR/wrong-number-of-args.rs:168:26
|
LL | type B = Box<dyn GenericLifetimeAT<'static, 'static, AssocTy=()>>;
| ^^^^^^^^^^^^^^^^^ ------- help: remove this lifetime argument
| ^^^^^^^^^^^^^^^^^ --------- help: remove the lifetime argument
| |
| expected 1 lifetime argument
|
@ -547,7 +547,7 @@ error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplie
--> $DIR/wrong-number-of-args.rs:172:26
|
LL | type C = Box<dyn GenericLifetimeAT<(), AssocTy=()>>;
| ^^^^^^^^^^^^^^^^^ -- help: remove this generic argument
| ^^^^^^^^^^^^^^^^^ -- help: remove the unnecessary generic argument
| |
| expected 0 generic arguments
|
@ -577,7 +577,7 @@ error[E0107]: trait takes 1 generic argument but 2 generic arguments were suppli
--> $DIR/wrong-number-of-args.rs:189:26
|
LL | type B = Box<dyn GenericTypeAT<(), (), AssocTy=()>>;
| ^^^^^^^^^^^^^ -- help: remove this generic argument
| ^^^^^^^^^^^^^ ---- help: remove the unnecessary generic argument
| |
| expected 1 generic argument
|
@ -591,7 +591,7 @@ error[E0107]: trait takes 0 lifetime arguments but 1 lifetime argument was suppl
--> $DIR/wrong-number-of-args.rs:193:26
|
LL | type C = Box<dyn GenericTypeAT<'static, AssocTy=()>>;
| ^^^^^^^^^^^^^--------------------- help: remove these generics
| ^^^^^^^^^^^^^--------------------- help: remove the unnecessary generics
| |
| expected 0 lifetime arguments
|
@ -653,7 +653,7 @@ error[E0107]: trait takes 1 lifetime argument but 2 lifetime arguments were supp
--> $DIR/wrong-number-of-args.rs:216:26
|
LL | type C = Box<dyn GenericLifetimeTypeAT<'static, 'static, AssocTy=()>>;
| ^^^^^^^^^^^^^^^^^^^^^ ------- help: remove this lifetime argument
| ^^^^^^^^^^^^^^^^^^^^^ --------- help: remove the lifetime argument
| |
| expected 1 lifetime argument
|
@ -683,7 +683,7 @@ error[E0107]: trait takes 1 generic argument but 2 generic arguments were suppli
--> $DIR/wrong-number-of-args.rs:227:26
|
LL | type E = Box<dyn GenericLifetimeTypeAT<(), (), AssocTy=()>>;
| ^^^^^^^^^^^^^^^^^^^^^ -- help: remove this generic argument
| ^^^^^^^^^^^^^^^^^^^^^ ---- help: remove the unnecessary generic argument
| |
| expected 1 generic argument
|
@ -697,7 +697,7 @@ error[E0107]: trait takes 1 lifetime argument but 2 lifetime arguments were supp
--> $DIR/wrong-number-of-args.rs:234:26
|
LL | type F = Box<dyn GenericLifetimeTypeAT<'static, 'static, (), AssocTy=()>>;
| ^^^^^^^^^^^^^^^^^^^^^ ------- help: remove this lifetime argument
| ^^^^^^^^^^^^^^^^^^^^^ --------- help: remove the lifetime argument
| |
| expected 1 lifetime argument
|
@ -711,7 +711,7 @@ error[E0107]: trait takes 1 generic argument but 2 generic arguments were suppli
--> $DIR/wrong-number-of-args.rs:238:26
|
LL | type G = Box<dyn GenericLifetimeTypeAT<'static, (), (), AssocTy=()>>;
| ^^^^^^^^^^^^^^^^^^^^^ -- help: remove this generic argument
| ^^^^^^^^^^^^^^^^^^^^^ ---- help: remove the unnecessary generic argument
| |
| expected 1 generic argument
|
@ -725,7 +725,7 @@ error[E0107]: trait takes 1 lifetime argument but 2 lifetime arguments were supp
--> $DIR/wrong-number-of-args.rs:242:26
|
LL | type H = Box<dyn GenericLifetimeTypeAT<'static, 'static, (), (), AssocTy=()>>;
| ^^^^^^^^^^^^^^^^^^^^^ ------- help: remove this lifetime argument
| ^^^^^^^^^^^^^^^^^^^^^ --------- help: remove the lifetime argument
| |
| expected 1 lifetime argument
|
@ -739,7 +739,7 @@ error[E0107]: trait takes 1 generic argument but 2 generic arguments were suppli
--> $DIR/wrong-number-of-args.rs:242:26
|
LL | type H = Box<dyn GenericLifetimeTypeAT<'static, 'static, (), (), AssocTy=()>>;
| ^^^^^^^^^^^^^^^^^^^^^ -- help: remove this generic argument
| ^^^^^^^^^^^^^^^^^^^^^ ---- help: remove the unnecessary generic argument
| |
| expected 1 generic argument
|
@ -787,7 +787,7 @@ error[E0107]: trait takes 2 generic arguments but 3 generic arguments were suppl
--> $DIR/wrong-number-of-args.rs:262:26
|
LL | type C = Box<dyn GenericTypeTypeAT<(), (), (), AssocTy=()>>;
| ^^^^^^^^^^^^^^^^^ -- help: remove this generic argument
| ^^^^^^^^^^^^^^^^^ ---- help: remove the unnecessary generic argument
| |
| expected 2 generic arguments
|
@ -911,7 +911,7 @@ error[E0107]: struct takes 0 lifetime arguments but 1 lifetime argument was supp
--> $DIR/wrong-number-of-args.rs:318:18
|
LL | type C = HashMap<'static>;
| ^^^^^^^--------- help: remove these generics
| ^^^^^^^--------- help: remove the unnecessary generics
| |
| expected 0 lifetime arguments
@ -930,7 +930,7 @@ error[E0107]: struct takes at most 3 generic arguments but 4 generic arguments w
--> $DIR/wrong-number-of-args.rs:324:18
|
LL | type D = HashMap<usize, String, char, f64>;
| ^^^^^^^ --- help: remove this generic argument
| ^^^^^^^ ----- help: remove the unnecessary generic argument
| |
| expected at most 3 generic arguments
@ -973,7 +973,7 @@ error[E0107]: enum takes 0 lifetime arguments but 1 lifetime argument was suppli
--> $DIR/wrong-number-of-args.rs:342:18
|
LL | type C = Result<'static>;
| ^^^^^^--------- help: remove these generics
| ^^^^^^--------- help: remove the unnecessary generics
| |
| expected 0 lifetime arguments
@ -992,7 +992,7 @@ error[E0107]: enum takes 2 generic arguments but 3 generic arguments were suppli
--> $DIR/wrong-number-of-args.rs:348:18
|
LL | type D = Result<usize, String, char>;
| ^^^^^^ ---- help: remove this generic argument
| ^^^^^^ ------ help: remove the unnecessary generic argument
| |
| expected 2 generic arguments

View file

@ -2,7 +2,7 @@ error[E0107]: function takes 1 generic argument but 2 generic arguments were sup
--> $DIR/explicit-generic-args-for-impl.rs:4:5
|
LL | foo::<str, String>("".to_string());
| ^^^ ------ help: remove this generic argument
| ^^^ -------- help: remove the unnecessary generic argument
| |
| expected 1 generic argument
|

View file

@ -38,7 +38,7 @@ error[E0107]: struct takes 0 generic arguments but 1 generic argument was suppli
--> $DIR/opaque-and-lifetime-mismatch.rs:4:17
|
LL | fn bar() -> Wrapper<impl Sized>;
| ^^^^^^^ ---------- help: remove this generic argument
| ^^^^^^^ ---------- help: remove the unnecessary generic argument
| |
| expected 0 generic arguments
|
@ -52,7 +52,7 @@ error[E0107]: struct takes 0 generic arguments but 1 generic argument was suppli
--> $DIR/opaque-and-lifetime-mismatch.rs:18:17
|
LL | fn foo() -> Wrapper<impl Sized>;
| ^^^^^^^ ---------- help: remove this generic argument
| ^^^^^^^ ---------- help: remove the unnecessary generic argument
| |
| expected 0 generic arguments
|
@ -93,7 +93,7 @@ error[E0107]: struct takes 0 generic arguments but 1 generic argument was suppli
--> $DIR/opaque-and-lifetime-mismatch.rs:24:17
|
LL | fn foo() -> Wrapper<impl Sized> {
| ^^^^^^^ ---------- help: remove this generic argument
| ^^^^^^^ ---------- help: remove the unnecessary generic argument
| |
| expected 0 generic arguments
|

View file

@ -2,7 +2,7 @@ error[E0107]: struct takes 0 lifetime arguments but 1 lifetime argument was supp
--> $DIR/issue-18423.rs:4:8
|
LL | x: Box<'a, isize>
| ^^^ -- help: remove this lifetime argument
| ^^^ -- help: remove the lifetime argument
| |
| expected 0 lifetime arguments

View file

@ -2,7 +2,7 @@ error[E0107]: associated function takes 0 generic arguments but 1 generic argume
--> $DIR/issue-53251.rs:11:20
|
LL | S::f::<i64>();
| ^------- help: remove these generics
| ^------- help: remove the unnecessary generics
| |
| expected 0 generic arguments
...
@ -20,7 +20,7 @@ error[E0107]: associated function takes 0 generic arguments but 1 generic argume
--> $DIR/issue-53251.rs:11:20
|
LL | S::f::<i64>();
| ^------- help: remove these generics
| ^------- help: remove the unnecessary generics
| |
| expected 0 generic arguments
...

View file

@ -20,7 +20,7 @@ error[E0107]: method takes 0 generic arguments but 1 generic argument was suppli
--> $DIR/issue-60622.rs:10:7
|
LL | b.a::<'_, T>();
| ^ - help: remove this generic argument
| ^ - help: remove the unnecessary generic argument
| |
| expected 0 generic arguments
|

View file

@ -2,7 +2,7 @@ error[E0107]: type alias takes 1 lifetime argument but 2 lifetime arguments were
--> $DIR/mismatched_arg_count.rs:9:29
|
LL | fn bar<'a, T: Trait<'a>>(_: Alias<'a, 'a, T>) {}
| ^^^^^ -- help: remove this lifetime argument
| ^^^^^ ---- help: remove the lifetime argument
| |
| expected 1 lifetime argument
|

View file

@ -0,0 +1,18 @@
//@ build-fail
//@ compile-flags: --crate-type lib
//@ only-32bit Layout computation rejects this layout for different reasons on 64-bit.
//@ error-pattern: too big for the current architecture
#![feature(core_intrinsics)]
#![allow(internal_features)]
// isize::MAX is fine, but with the padding for the unsized tail it is too big.
#[repr(C)]
pub struct Example([u8; isize::MAX as usize], [u16]);
// We guarantee that with length 0, `size_of_val_raw` (which calls the `size_of_val` intrinsic)
// is safe to call. The compiler aborts compilation if a length of 0 would overflow.
// So let's construct a case where length 0 just barely overflows, and ensure that
// does abort compilation.
pub fn check(x: *const Example) -> usize {
unsafe { std::intrinsics::size_of_val(x) }
}

View file

@ -0,0 +1,4 @@
error: values of the type `Example` are too big for the current architecture
error: aborting due to 1 previous error

View file

@ -2,7 +2,7 @@ error[E0107]: struct takes 2 lifetime arguments but 3 lifetime arguments were su
--> $DIR/noisy-follow-up-erro.rs:12:30
|
LL | fn boom(&self, foo: &mut Foo<'_, '_, 'a>) -> Result<(), &'a ()> {
| ^^^ -- help: remove this lifetime argument
| ^^^ ---- help: remove the lifetime argument
| |
| expected 2 lifetime arguments
|

View file

@ -20,7 +20,7 @@ error[E0107]: method takes 2 lifetime arguments but 3 lifetime arguments were su
--> $DIR/method-call-lifetime-args-fail.rs:18:7
|
LL | S.early::<'static, 'static, 'static>();
| ^^^^^ ------- help: remove this lifetime argument
| ^^^^^ --------- help: remove the lifetime argument
| |
| expected 2 lifetime arguments
|
@ -220,7 +220,7 @@ error[E0107]: method takes 2 lifetime arguments but 3 lifetime arguments were su
--> $DIR/method-call-lifetime-args-fail.rs:65:8
|
LL | S::early::<'static, 'static, 'static>(S);
| ^^^^^ ------- help: remove this lifetime argument
| ^^^^^ --------- help: remove the lifetime argument
| |
| expected 2 lifetime arguments
|

View file

@ -73,7 +73,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
span: $DIR/cfg-eval-inner.rs:19:40: 19:54 (#0),
},
],
span: $DIR/cfg-eval-inner.rs:19:5: 19:6 (#0),
span: $DIR/cfg-eval-inner.rs:19:7: 19:56 (#0),
},
Punct {
ch: '#',
@ -168,7 +168,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
span: $DIR/cfg-eval-inner.rs:23:48: 23:70 (#0),
},
],
span: $DIR/cfg-eval-inner.rs:23:13: 23:14 (#0),
span: $DIR/cfg-eval-inner.rs:23:15: 23:72 (#0),
},
Literal {
kind: Integer,
@ -233,7 +233,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
span: $DIR/cfg-eval-inner.rs:32:40: 32:56 (#0),
},
],
span: $DIR/cfg-eval-inner.rs:32:5: 32:6 (#0),
span: $DIR/cfg-eval-inner.rs:32:7: 32:58 (#0),
},
Ident {
ident: "fn",

View file

@ -60,7 +60,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
span: $DIR/cfg-eval.rs:22:36: 22:38 (#0),
},
],
span: $DIR/cfg-eval.rs:22:5: 22:6 (#0),
span: $DIR/cfg-eval.rs:22:6: 22:40 (#0),
},
Ident {
ident: "field_true",
@ -99,7 +99,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
span: $DIR/cfg-eval.rs:35:62: 35:73 (#0),
},
],
span: $DIR/cfg-eval.rs:35:39: 35:40 (#0),
span: $DIR/cfg-eval.rs:35:40: 35:75 (#0),
},
Group {
delimiter: Parenthesis,

View file

@ -57,7 +57,7 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [
span: $DIR/expand-to-derive.rs:27:28: 27:39 (#0),
},
],
span: $DIR/expand-to-derive.rs:27:5: 27:6 (#0),
span: $DIR/expand-to-derive.rs:27:6: 27:41 (#0),
},
Ident {
ident: "struct",

View file

@ -674,7 +674,7 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [
span: $DIR/inner-attrs.rs:41:52: 41:59 (#0),
},
],
span: $DIR/inner-attrs.rs:41:17: 41:18 (#0),
span: $DIR/inner-attrs.rs:41:19: 41:61 (#0),
},
Ident {
ident: "true",

View file

@ -119,7 +119,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
span: $DIR/issue-75930-derive-cfg.rs:50:29: 50:40 (#0),
},
],
span: $DIR/issue-75930-derive-cfg.rs:50:1: 50:2 (#0),
span: $DIR/issue-75930-derive-cfg.rs:50:2: 50:42 (#0),
},
Punct {
ch: '#',
@ -1395,7 +1395,7 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [
span: $DIR/issue-75930-derive-cfg.rs:50:29: 50:40 (#0),
},
],
span: $DIR/issue-75930-derive-cfg.rs:50:1: 50:2 (#0),
span: $DIR/issue-75930-derive-cfg.rs:50:2: 50:42 (#0),
},
Punct {
ch: '#',
@ -1571,7 +1571,7 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [
span: $DIR/issue-75930-derive-cfg.rs:63:41: 63:51 (#0),
},
],
span: $DIR/issue-75930-derive-cfg.rs:63:13: 63:14 (#0),
span: $DIR/issue-75930-derive-cfg.rs:63:14: 63:53 (#0),
},
Ident {
ident: "false",

View file

@ -88,7 +88,7 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [
span: $DIR/macro-rules-derive-cfg.rs:19:59: 19:66 (#3),
},
],
span: $DIR/macro-rules-derive-cfg.rs:19:25: 19:26 (#3),
span: $DIR/macro-rules-derive-cfg.rs:19:26: 19:68 (#3),
},
Punct {
ch: '#',
@ -113,7 +113,7 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [
span: $DIR/macro-rules-derive-cfg.rs:26:47: 26:55 (#0),
},
],
span: $DIR/macro-rules-derive-cfg.rs:26:13: 26:14 (#0),
span: $DIR/macro-rules-derive-cfg.rs:26:14: 26:57 (#0),
},
Group {
delimiter: Brace,
@ -146,7 +146,7 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [
span: $DIR/macro-rules-derive-cfg.rs:27:34: 27:42 (#0),
},
],
span: $DIR/macro-rules-derive-cfg.rs:27:5: 27:6 (#0),
span: $DIR/macro-rules-derive-cfg.rs:27:7: 27:44 (#0),
},
Literal {
kind: Integer,

View file

@ -12,7 +12,7 @@ error[E0107]: struct takes 0 generic arguments but 1 generic argument was suppli
--> $DIR/issue-3214.rs:6:22
|
LL | impl<T> Drop for Foo<T> {
| ^^^--- help: remove these generics
| ^^^--- help: remove the unnecessary generics
| |
| expected 0 generic arguments
|

View file

@ -2,7 +2,7 @@ error[E0107]: function takes 0 generic arguments but 1 generic argument was supp
--> $DIR/no-explicit-const-params-cross-crate.rs:14:5
|
LL | foo::<false>();
| ^^^--------- help: remove these generics
| ^^^--------- help: remove the unnecessary generics
| |
| expected 0 generic arguments
|
@ -32,7 +32,7 @@ error[E0107]: function takes 0 generic arguments but 1 generic argument was supp
--> $DIR/no-explicit-const-params-cross-crate.rs:7:5
|
LL | foo::<true>();
| ^^^-------- help: remove these generics
| ^^^-------- help: remove the unnecessary generics
| |
| expected 0 generic arguments
|

View file

@ -16,7 +16,7 @@ error[E0107]: function takes 0 generic arguments but 1 generic argument was supp
--> $DIR/no-explicit-const-params.rs:22:5
|
LL | foo::<false>();
| ^^^--------- help: remove these generics
| ^^^--------- help: remove the unnecessary generics
| |
| expected 0 generic arguments
|
@ -55,7 +55,7 @@ error[E0107]: function takes 0 generic arguments but 1 generic argument was supp
--> $DIR/no-explicit-const-params.rs:15:5
|
LL | foo::<true>();
| ^^^-------- help: remove these generics
| ^^^-------- help: remove the unnecessary generics
| |
| expected 0 generic arguments
|

View file

@ -2,7 +2,7 @@ error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplie
--> $DIR/seq-args.rs:4:13
|
LL | impl<T> Seq<T> for Vec<T> {
| ^^^--- help: remove these generics
| ^^^--- help: remove the unnecessary generics
| |
| expected 0 generic arguments
|
@ -16,7 +16,7 @@ error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplie
--> $DIR/seq-args.rs:9:10
|
LL | impl Seq<bool> for u32 {
| ^^^------ help: remove these generics
| ^^^------ help: remove the unnecessary generics
| |
| expected 0 generic arguments
|

View file

@ -8,7 +8,7 @@ error[E0107]: associated type takes 0 generic arguments but 1 generic argument w
--> $DIR/struct-path-associated-type.rs:14:16
|
LL | let z = T::A::<u8> {};
| ^------ help: remove these generics
| ^------ help: remove the unnecessary generics
| |
| expected 0 generic arguments
|
@ -34,7 +34,7 @@ error[E0107]: associated type takes 0 generic arguments but 1 generic argument w
--> $DIR/struct-path-associated-type.rs:25:16
|
LL | let z = T::A::<u8> {};
| ^------ help: remove these generics
| ^------ help: remove the unnecessary generics
| |
| expected 0 generic arguments
|

View file

@ -68,7 +68,7 @@ error[E0107]: type alias takes 0 generic arguments but 1 generic argument was su
--> $DIR/structure-constructor-type-mismatch.rs:48:15
|
LL | let pt3 = PointF::<i32> {
| ^^^^^^------- help: remove these generics
| ^^^^^^------- help: remove the unnecessary generics
| |
| expected 0 generic arguments
|
@ -104,7 +104,7 @@ error[E0107]: type alias takes 0 generic arguments but 1 generic argument was su
--> $DIR/structure-constructor-type-mismatch.rs:54:9
|
LL | PointF::<u32> { .. } => {}
| ^^^^^^------- help: remove these generics
| ^^^^^^------- help: remove the unnecessary generics
| |
| expected 0 generic arguments
|

View file

@ -2,7 +2,7 @@ error[E0107]: method takes 0 generic arguments but 1 generic argument was suppli
--> $DIR/issue-101421.rs:10:8
|
LL | ().f::<()>(());
| ^------ help: remove these generics
| ^------ help: remove the unnecessary generics
| |
| expected 0 generic arguments
|

View file

@ -2,7 +2,7 @@ error[E0107]: method takes 0 generic arguments but 1 generic argument was suppli
--> $DIR/issue-104287.rs:10:5
|
LL | foo::<()>(x);
| ^^^------ help: remove these generics
| ^^^------ help: remove the unnecessary generics
| |
| expected 0 generic arguments
|

View file

@ -16,20 +16,20 @@ impl<T, U> B<T, U> for S {}
fn main() {
let _ = A::foo::<S>();
//~^ ERROR
//~| HELP remove these generics
//~| HELP remove the unnecessary generics
//~| HELP consider moving this generic argument
let _ = B::bar::<S, S>();
//~^ ERROR
//~| HELP remove these generics
//~| HELP remove the unnecessary generics
//~| HELP consider moving these generic arguments
let _ = A::<S>::foo::<S>();
//~^ ERROR
//~| HELP remove these generics
//~| HELP remove the unnecessary generics
let _ = 42.into::<Option<_>>();
//~^ ERROR
//~| HELP remove these generics
//~| HELP remove the unnecessary generics
//~| HELP consider moving this generic argument
}

View file

@ -14,7 +14,7 @@ help: consider moving this generic argument to the `A` trait, which takes up to
LL - let _ = A::foo::<S>();
LL + let _ = A::<S>::foo();
|
help: remove these generics
help: remove the unnecessary generics
|
LL - let _ = A::foo::<S>();
LL + let _ = A::foo();
@ -36,7 +36,7 @@ help: consider moving these generic arguments to the `B` trait, which takes up t
LL - let _ = B::bar::<S, S>();
LL + let _ = B::<S, S>::bar();
|
help: remove these generics
help: remove the unnecessary generics
|
LL - let _ = B::bar::<S, S>();
LL + let _ = B::bar();
@ -46,7 +46,7 @@ error[E0107]: associated function takes 0 generic arguments but 1 generic argume
--> $DIR/issue-89064.rs:27:21
|
LL | let _ = A::<S>::foo::<S>();
| ^^^----- help: remove these generics
| ^^^----- help: remove the unnecessary generics
| |
| expected 0 generic arguments
|
@ -66,7 +66,7 @@ help: consider moving this generic argument to the `Into` trait, which takes up
|
LL | let _ = Into::<Option<_>>::into(42);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
help: remove these generics
help: remove the unnecessary generics
|
LL - let _ = 42.into::<Option<_>>();
LL + let _ = 42.into();

View file

@ -14,5 +14,5 @@ fn main() {
1.bar::<i32>(0);
//~^ ERROR method takes 0 generic arguments but 1 generic argument was supplied
//~| HELP consider moving this generic argument to the `Foo` trait, which takes up to 1 argument
//~| HELP remove these generics
//~| HELP remove the unnecessary generics
}

View file

@ -13,7 +13,7 @@ help: consider moving this generic argument to the `Foo` trait, which takes up t
|
LL | Foo::<i32>::bar(1, 0);
| ~~~~~~~~~~~~~~~~~~~~~
help: remove these generics
help: remove the unnecessary generics
|
LL - 1.bar::<i32>(0);
LL + 1.bar(0);

View file

@ -117,7 +117,7 @@ error[E0107]: struct takes 1 generic argument but 2 generic arguments were suppl
--> $DIR/116464-invalid-assoc-type-suggestion-in-trait-impl.rs:40:58
|
LL | impl<T: Trait<u32, Assoc=String>, U> YetAnotherTrait for Struct<T, U> {}
| ^^^^^^ - help: remove this generic argument
| ^^^^^^ --- help: remove the unnecessary generic argument
| |
| expected 1 generic argument
|

View file

@ -8,7 +8,7 @@ error[E0107]: struct takes 1 lifetime argument but 2 lifetime arguments were sup
--> $DIR/vs-lifetime.rs:11:12
|
LL | let _: S<'static, 'static>;
| ^ ------- help: remove this lifetime argument
| ^ --------- help: remove the lifetime argument
| |
| expected 1 lifetime argument
|

View file

@ -2,7 +2,7 @@ error[E0107]: method takes 0 generic arguments but 1 generic argument was suppli
--> $DIR/test-2.rs:9:8
|
LL | 10.dup::<i32>();
| ^^^------- help: remove these generics
| ^^^------- help: remove the unnecessary generics
| |
| expected 0 generic arguments
|
@ -16,7 +16,7 @@ error[E0107]: method takes 1 generic argument but 2 generic arguments were suppl
--> $DIR/test-2.rs:11:8
|
LL | 10.blah::<i32, i32>();
| ^^^^ --- help: remove this generic argument
| ^^^^ ----- help: remove the unnecessary generic argument
| |
| expected 1 generic argument
|

View file

@ -3,11 +3,13 @@ error[E0107]: trait takes at most 2 generic arguments but 5 generic arguments we
|
LL | Dst: BikeshedIntrinsicFrom<
| ^^^^^^^^^^^^^^^^^^^^^ expected at most 2 generic arguments
...
LL | / ASSUME_LIFETIMES,
LL | Src,
LL | ASSUME_ALIGNMENT,
| _____________________________-
LL | | ASSUME_LIFETIMES,
LL | | ASSUME_VALIDITY,
LL | | ASSUME_VISIBILITY,
| |_____________________________- help: remove these generic arguments
| |_____________________________- help: remove the unnecessary generic arguments
error: aborting due to 1 previous error

Some files were not shown because too many files have changed in this diff Show more