mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-02 15:32:06 +00:00
Auto merge of #114756 - matthiaskrgr:rollup-4m7l4p6, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #94455 (Partially stabilize `int_roundings`) - #114132 (Better Debug for Vars and VarsOs) - #114584 (E0277 nolonger points at phantom `.await`) - #114667 (Record binder for bare trait object in LifetimeCollectVisitor) - #114692 (downgrade `internal_features` to warn) - #114703 (Cover ParamConst in smir) - #114734 (Mark oli as "on vacation") r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
cbb48a5e93
@ -1,7 +1,7 @@
|
|||||||
use super::ResolverAstLoweringExt;
|
use super::ResolverAstLoweringExt;
|
||||||
use rustc_ast::visit::{self, BoundKind, LifetimeCtxt, Visitor};
|
use rustc_ast::visit::{self, BoundKind, LifetimeCtxt, Visitor};
|
||||||
use rustc_ast::{GenericBounds, Lifetime, NodeId, PathSegment, PolyTraitRef, Ty, TyKind};
|
use rustc_ast::{GenericBounds, Lifetime, NodeId, PathSegment, PolyTraitRef, Ty, TyKind};
|
||||||
use rustc_hir::def::LifetimeRes;
|
use rustc_hir::def::{DefKind, LifetimeRes, Res};
|
||||||
use rustc_middle::span_bug;
|
use rustc_middle::span_bug;
|
||||||
use rustc_middle::ty::ResolverAstLowering;
|
use rustc_middle::ty::ResolverAstLowering;
|
||||||
use rustc_span::symbol::{kw, Ident};
|
use rustc_span::symbol::{kw, Ident};
|
||||||
@ -77,7 +77,20 @@ impl<'ast> Visitor<'ast> for LifetimeCollectVisitor<'ast> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn visit_ty(&mut self, t: &'ast Ty) {
|
fn visit_ty(&mut self, t: &'ast Ty) {
|
||||||
match t.kind {
|
match &t.kind {
|
||||||
|
TyKind::Path(None, _) => {
|
||||||
|
// We can sometimes encounter bare trait objects
|
||||||
|
// which are represented in AST as paths.
|
||||||
|
if let Some(partial_res) = self.resolver.get_partial_res(t.id)
|
||||||
|
&& let Some(Res::Def(DefKind::Trait | DefKind::TraitAlias, _)) = partial_res.full_res()
|
||||||
|
{
|
||||||
|
self.current_binders.push(t.id);
|
||||||
|
visit::walk_ty(self, t);
|
||||||
|
self.current_binders.pop();
|
||||||
|
} else {
|
||||||
|
visit::walk_ty(self, t);
|
||||||
|
}
|
||||||
|
}
|
||||||
TyKind::BareFn(_) => {
|
TyKind::BareFn(_) => {
|
||||||
self.current_binders.push(t.id);
|
self.current_binders.push(t.id);
|
||||||
visit::walk_ty(self, t);
|
visit::walk_ty(self, t);
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#![feature(associated_type_bounds)]
|
#![feature(associated_type_bounds)]
|
||||||
#![feature(box_patterns)]
|
#![feature(box_patterns)]
|
||||||
#![feature(if_let_guard)]
|
#![feature(if_let_guard)]
|
||||||
#![feature(int_roundings)]
|
|
||||||
#![feature(let_chains)]
|
#![feature(let_chains)]
|
||||||
#![feature(negative_impls)]
|
#![feature(negative_impls)]
|
||||||
#![feature(never_type)]
|
#![feature(never_type)]
|
||||||
|
@ -2215,7 +2215,7 @@ declare_lint! {
|
|||||||
///
|
///
|
||||||
/// ### Example
|
/// ### Example
|
||||||
///
|
///
|
||||||
/// ```rust,compile_fail
|
/// ```rust
|
||||||
/// #![feature(rustc_attrs)]
|
/// #![feature(rustc_attrs)]
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
@ -2226,7 +2226,7 @@ declare_lint! {
|
|||||||
/// These features are an implementation detail of the compiler and standard
|
/// These features are an implementation detail of the compiler and standard
|
||||||
/// library and are not supposed to be used in user code.
|
/// library and are not supposed to be used in user code.
|
||||||
pub INTERNAL_FEATURES,
|
pub INTERNAL_FEATURES,
|
||||||
Deny,
|
Warn,
|
||||||
"internal features are not supposed to be used"
|
"internal features are not supposed to be used"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1717,13 +1717,7 @@ impl<'a> Parser<'a> {
|
|||||||
self.recover_await_prefix(await_sp)?
|
self.recover_await_prefix(await_sp)?
|
||||||
};
|
};
|
||||||
let sp = self.error_on_incorrect_await(lo, hi, &expr, is_question);
|
let sp = self.error_on_incorrect_await(lo, hi, &expr, is_question);
|
||||||
let kind = match expr.kind {
|
let expr = self.mk_expr(lo.to(sp), ExprKind::Err);
|
||||||
// Avoid knock-down errors as we don't know whether to interpret this as `foo().await?`
|
|
||||||
// or `foo()?.await` (the very reason we went with postfix syntax 😅).
|
|
||||||
ExprKind::Try(_) => ExprKind::Err,
|
|
||||||
_ => ExprKind::Await(expr, await_sp),
|
|
||||||
};
|
|
||||||
let expr = self.mk_expr(lo.to(sp), kind);
|
|
||||||
self.maybe_recover_from_bad_qpath(expr)
|
self.maybe_recover_from_bad_qpath(expr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1165,7 +1165,9 @@ impl<'tcx> Stable<'tcx> for rustc_middle::mir::ConstantKind<'tcx> {
|
|||||||
let const_val = tables.tcx.valtree_to_const_val((c.ty(), val));
|
let const_val = tables.tcx.valtree_to_const_val((c.ty(), val));
|
||||||
stable_mir::ty::ConstantKind::Allocated(new_allocation(self, const_val, tables))
|
stable_mir::ty::ConstantKind::Allocated(new_allocation(self, const_val, tables))
|
||||||
}
|
}
|
||||||
_ => todo!(),
|
ty::ParamCt(param) => stable_mir::ty::ConstantKind::ParamCt(opaque(¶m)),
|
||||||
|
ty::ErrorCt(_) => unreachable!(),
|
||||||
|
_ => unimplemented!(),
|
||||||
},
|
},
|
||||||
ConstantKind::Unevaluated(unev_const, ty) => {
|
ConstantKind::Unevaluated(unev_const, ty) => {
|
||||||
stable_mir::ty::ConstantKind::Unevaluated(stable_mir::ty::UnevaluatedConst {
|
stable_mir::ty::ConstantKind::Unevaluated(stable_mir::ty::UnevaluatedConst {
|
||||||
|
@ -417,6 +417,7 @@ pub fn allocation_filter<'tcx>(
|
|||||||
pub enum ConstantKind {
|
pub enum ConstantKind {
|
||||||
Allocated(Allocation),
|
Allocated(Allocation),
|
||||||
Unevaluated(UnevaluatedConst),
|
Unevaluated(UnevaluatedConst),
|
||||||
|
ParamCt(Opaque),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
@ -2074,10 +2074,10 @@ macro_rules! uint_impl {
|
|||||||
/// Basic usage:
|
/// Basic usage:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(int_roundings)]
|
|
||||||
#[doc = concat!("assert_eq!(7_", stringify!($SelfT), ".div_ceil(4), 2);")]
|
#[doc = concat!("assert_eq!(7_", stringify!($SelfT), ".div_ceil(4), 2);")]
|
||||||
/// ```
|
/// ```
|
||||||
#[unstable(feature = "int_roundings", issue = "88581")]
|
#[stable(feature = "int_roundings1", since = "CURRENT_RUSTC_VERSION")]
|
||||||
|
#[rustc_const_stable(feature = "int_roundings1", since = "CURRENT_RUSTC_VERSION")]
|
||||||
#[must_use = "this returns the result of the operation, \
|
#[must_use = "this returns the result of the operation, \
|
||||||
without modifying the original"]
|
without modifying the original"]
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -2109,11 +2109,11 @@ macro_rules! uint_impl {
|
|||||||
/// Basic usage:
|
/// Basic usage:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(int_roundings)]
|
|
||||||
#[doc = concat!("assert_eq!(16_", stringify!($SelfT), ".next_multiple_of(8), 16);")]
|
#[doc = concat!("assert_eq!(16_", stringify!($SelfT), ".next_multiple_of(8), 16);")]
|
||||||
#[doc = concat!("assert_eq!(23_", stringify!($SelfT), ".next_multiple_of(8), 24);")]
|
#[doc = concat!("assert_eq!(23_", stringify!($SelfT), ".next_multiple_of(8), 24);")]
|
||||||
/// ```
|
/// ```
|
||||||
#[unstable(feature = "int_roundings", issue = "88581")]
|
#[stable(feature = "int_roundings1", since = "CURRENT_RUSTC_VERSION")]
|
||||||
|
#[rustc_const_stable(feature = "int_roundings1", since = "CURRENT_RUSTC_VERSION")]
|
||||||
#[must_use = "this returns the result of the operation, \
|
#[must_use = "this returns the result of the operation, \
|
||||||
without modifying the original"]
|
without modifying the original"]
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -2134,13 +2134,13 @@ macro_rules! uint_impl {
|
|||||||
/// Basic usage:
|
/// Basic usage:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(int_roundings)]
|
|
||||||
#[doc = concat!("assert_eq!(16_", stringify!($SelfT), ".checked_next_multiple_of(8), Some(16));")]
|
#[doc = concat!("assert_eq!(16_", stringify!($SelfT), ".checked_next_multiple_of(8), Some(16));")]
|
||||||
#[doc = concat!("assert_eq!(23_", stringify!($SelfT), ".checked_next_multiple_of(8), Some(24));")]
|
#[doc = concat!("assert_eq!(23_", stringify!($SelfT), ".checked_next_multiple_of(8), Some(24));")]
|
||||||
#[doc = concat!("assert_eq!(1_", stringify!($SelfT), ".checked_next_multiple_of(0), None);")]
|
#[doc = concat!("assert_eq!(1_", stringify!($SelfT), ".checked_next_multiple_of(0), None);")]
|
||||||
#[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.checked_next_multiple_of(2), None);")]
|
#[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.checked_next_multiple_of(2), None);")]
|
||||||
/// ```
|
/// ```
|
||||||
#[unstable(feature = "int_roundings", issue = "88581")]
|
#[stable(feature = "int_roundings1", since = "CURRENT_RUSTC_VERSION")]
|
||||||
|
#[rustc_const_stable(feature = "int_roundings1", since = "CURRENT_RUSTC_VERSION")]
|
||||||
#[must_use = "this returns the result of the operation, \
|
#[must_use = "this returns the result of the operation, \
|
||||||
without modifying the original"]
|
without modifying the original"]
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -178,7 +178,8 @@ impl Iterator for Vars {
|
|||||||
#[stable(feature = "std_debug", since = "1.16.0")]
|
#[stable(feature = "std_debug", since = "1.16.0")]
|
||||||
impl fmt::Debug for Vars {
|
impl fmt::Debug for Vars {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.debug_struct("Vars").finish_non_exhaustive()
|
let Self { inner: VarsOs { inner } } = self;
|
||||||
|
f.debug_struct("Vars").field("inner", &inner.str_debug()).finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,7 +197,8 @@ impl Iterator for VarsOs {
|
|||||||
#[stable(feature = "std_debug", since = "1.16.0")]
|
#[stable(feature = "std_debug", since = "1.16.0")]
|
||||||
impl fmt::Debug for VarsOs {
|
impl fmt::Debug for VarsOs {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.debug_struct("VarOs").finish_non_exhaustive()
|
let Self { inner } = self;
|
||||||
|
f.debug_struct("VarsOs").field("inner", inner).finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -829,7 +831,8 @@ impl DoubleEndedIterator for Args {
|
|||||||
#[stable(feature = "std_debug", since = "1.16.0")]
|
#[stable(feature = "std_debug", since = "1.16.0")]
|
||||||
impl fmt::Debug for Args {
|
impl fmt::Debug for Args {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.debug_struct("Args").field("inner", &self.inner.inner).finish()
|
let Self { inner: ArgsOs { inner } } = self;
|
||||||
|
f.debug_struct("Args").field("inner", inner).finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -870,7 +873,8 @@ impl DoubleEndedIterator for ArgsOs {
|
|||||||
#[stable(feature = "std_debug", since = "1.16.0")]
|
#[stable(feature = "std_debug", since = "1.16.0")]
|
||||||
impl fmt::Debug for ArgsOs {
|
impl fmt::Debug for ArgsOs {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.debug_struct("ArgsOs").field("inner", &self.inner).finish()
|
let Self { inner } = self;
|
||||||
|
f.debug_struct("ArgsOs").field("inner", inner).finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
20
library/std/src/env/tests.rs
vendored
20
library/std/src/env/tests.rs
vendored
@ -95,8 +95,28 @@ fn args_debug() {
|
|||||||
format!("Args {{ inner: {:?} }}", args().collect::<Vec<_>>()),
|
format!("Args {{ inner: {:?} }}", args().collect::<Vec<_>>()),
|
||||||
format!("{:?}", args())
|
format!("{:?}", args())
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn args_os_debug() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
format!("ArgsOs {{ inner: {:?} }}", args_os().collect::<Vec<_>>()),
|
format!("ArgsOs {{ inner: {:?} }}", args_os().collect::<Vec<_>>()),
|
||||||
format!("{:?}", args_os())
|
format!("{:?}", args_os())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn vars_debug() {
|
||||||
|
assert_eq!(
|
||||||
|
format!("Vars {{ inner: {:?} }}", vars().collect::<Vec<_>>()),
|
||||||
|
format!("{:?}", vars())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn vars_os_debug() {
|
||||||
|
assert_eq!(
|
||||||
|
format!("VarsOs {{ inner: {:?} }}", vars_os().collect::<Vec<_>>()),
|
||||||
|
format!("{:?}", vars_os())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
@ -293,7 +293,6 @@
|
|||||||
#![feature(float_next_up_down)]
|
#![feature(float_next_up_down)]
|
||||||
#![feature(hasher_prefixfree_extras)]
|
#![feature(hasher_prefixfree_extras)]
|
||||||
#![feature(hashmap_internals)]
|
#![feature(hashmap_internals)]
|
||||||
#![feature(int_roundings)]
|
|
||||||
#![feature(ip)]
|
#![feature(ip)]
|
||||||
#![feature(ip_in_core)]
|
#![feature(ip_in_core)]
|
||||||
#![feature(maybe_uninit_slice)]
|
#![feature(maybe_uninit_slice)]
|
||||||
|
@ -112,6 +112,34 @@ pub struct Env {
|
|||||||
iter: vec::IntoIter<(OsString, OsString)>,
|
iter: vec::IntoIter<(OsString, OsString)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME(https://github.com/rust-lang/rust/issues/114583): Remove this when <OsStr as Debug>::fmt matches <str as Debug>::fmt.
|
||||||
|
pub struct EnvStrDebug<'a> {
|
||||||
|
slice: &'a [(OsString, OsString)],
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for EnvStrDebug<'_> {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
let Self { slice } = self;
|
||||||
|
f.debug_list()
|
||||||
|
.entries(slice.iter().map(|(a, b)| (a.to_str().unwrap(), b.to_str().unwrap())))
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Env {
|
||||||
|
pub fn str_debug(&self) -> impl fmt::Debug + '_ {
|
||||||
|
let Self { iter } = self;
|
||||||
|
EnvStrDebug { slice: iter.as_slice() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for Env {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
let Self { iter } = self;
|
||||||
|
f.debug_list().entries(iter.as_slice()).finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl !Send for Env {}
|
impl !Send for Env {}
|
||||||
impl !Sync for Env {}
|
impl !Sync for Env {}
|
||||||
|
|
||||||
|
@ -96,14 +96,61 @@ fn create_env_store() -> &'static EnvStore {
|
|||||||
unsafe { &*(ENV.load(Ordering::Relaxed) as *const EnvStore) }
|
unsafe { &*(ENV.load(Ordering::Relaxed) as *const EnvStore) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type Env = vec::IntoIter<(OsString, OsString)>;
|
pub struct Env {
|
||||||
|
iter: vec::IntoIter<(OsString, OsString)>,
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME(https://github.com/rust-lang/rust/issues/114583): Remove this when <OsStr as Debug>::fmt matches <str as Debug>::fmt.
|
||||||
|
pub struct EnvStrDebug<'a> {
|
||||||
|
slice: &'a [(OsString, OsString)],
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for EnvStrDebug<'_> {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
let Self { slice } = self;
|
||||||
|
f.debug_list()
|
||||||
|
.entries(slice.iter().map(|(a, b)| (a.to_str().unwrap(), b.to_str().unwrap())))
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Env {
|
||||||
|
pub fn str_debug(&self) -> impl fmt::Debug + '_ {
|
||||||
|
let Self { iter } = self;
|
||||||
|
EnvStrDebug { slice: iter.as_slice() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for Env {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
let Self { iter } = self;
|
||||||
|
f.debug_list().entries(iter.as_slice()).finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl !Send for Env {}
|
||||||
|
impl !Sync for Env {}
|
||||||
|
|
||||||
|
impl Iterator for Env {
|
||||||
|
type Item = (OsString, OsString);
|
||||||
|
fn next(&mut self) -> Option<(OsString, OsString)> {
|
||||||
|
self.iter.next()
|
||||||
|
}
|
||||||
|
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||||
|
self.iter.size_hint()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn env() -> Env {
|
pub fn env() -> Env {
|
||||||
let clone_to_vec = |map: &HashMap<OsString, OsString>| -> Vec<_> {
|
let clone_to_vec = |map: &HashMap<OsString, OsString>| -> Vec<_> {
|
||||||
map.iter().map(|(k, v)| (k.clone(), v.clone())).collect()
|
map.iter().map(|(k, v)| (k.clone(), v.clone())).collect()
|
||||||
};
|
};
|
||||||
|
|
||||||
get_env_store().map(|env| clone_to_vec(&env.lock().unwrap())).unwrap_or_default().into_iter()
|
let iter = get_env_store()
|
||||||
|
.map(|env| clone_to_vec(&env.lock().unwrap()))
|
||||||
|
.unwrap_or_default()
|
||||||
|
.into_iter();
|
||||||
|
Env { iter }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn getenv(k: &OsStr) -> Option<OsString> {
|
pub fn getenv(k: &OsStr) -> Option<OsString> {
|
||||||
|
@ -85,6 +85,34 @@ pub struct Env {
|
|||||||
iter: vec::IntoIter<(OsString, OsString)>,
|
iter: vec::IntoIter<(OsString, OsString)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME(https://github.com/rust-lang/rust/issues/114583): Remove this when <OsStr as Debug>::fmt matches <str as Debug>::fmt.
|
||||||
|
pub struct EnvStrDebug<'a> {
|
||||||
|
slice: &'a [(OsString, OsString)],
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for EnvStrDebug<'_> {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
let Self { slice } = self;
|
||||||
|
f.debug_list()
|
||||||
|
.entries(slice.iter().map(|(a, b)| (a.to_str().unwrap(), b.to_str().unwrap())))
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Env {
|
||||||
|
pub fn str_debug(&self) -> impl fmt::Debug + '_ {
|
||||||
|
let Self { iter } = self;
|
||||||
|
EnvStrDebug { slice: iter.as_slice() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for Env {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
let Self { iter } = self;
|
||||||
|
f.debug_list().entries(iter.as_slice()).finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl !Send for Env {}
|
impl !Send for Env {}
|
||||||
impl !Sync for Env {}
|
impl !Sync for Env {}
|
||||||
|
|
||||||
|
@ -495,6 +495,34 @@ pub struct Env {
|
|||||||
iter: vec::IntoIter<(OsString, OsString)>,
|
iter: vec::IntoIter<(OsString, OsString)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME(https://github.com/rust-lang/rust/issues/114583): Remove this when <OsStr as Debug>::fmt matches <str as Debug>::fmt.
|
||||||
|
pub struct EnvStrDebug<'a> {
|
||||||
|
slice: &'a [(OsString, OsString)],
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for EnvStrDebug<'_> {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
let Self { slice } = self;
|
||||||
|
f.debug_list()
|
||||||
|
.entries(slice.iter().map(|(a, b)| (a.to_str().unwrap(), b.to_str().unwrap())))
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Env {
|
||||||
|
pub fn str_debug(&self) -> impl fmt::Debug + '_ {
|
||||||
|
let Self { iter } = self;
|
||||||
|
EnvStrDebug { slice: iter.as_slice() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for Env {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
let Self { iter } = self;
|
||||||
|
f.debug_list().entries(iter.as_slice()).finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl !Send for Env {}
|
impl !Send for Env {}
|
||||||
impl !Sync for Env {}
|
impl !Sync for Env {}
|
||||||
|
|
||||||
|
@ -65,10 +65,26 @@ pub fn current_exe() -> io::Result<PathBuf> {
|
|||||||
|
|
||||||
pub struct Env(!);
|
pub struct Env(!);
|
||||||
|
|
||||||
|
impl Env {
|
||||||
|
// FIXME(https://github.com/rust-lang/rust/issues/114583): Remove this when <OsStr as Debug>::fmt matches <str as Debug>::fmt.
|
||||||
|
pub fn str_debug(&self) -> impl fmt::Debug + '_ {
|
||||||
|
let Self(inner) = self;
|
||||||
|
match *inner {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for Env {
|
||||||
|
fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
let Self(inner) = self;
|
||||||
|
match *inner {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Iterator for Env {
|
impl Iterator for Env {
|
||||||
type Item = (OsString, OsString);
|
type Item = (OsString, OsString);
|
||||||
fn next(&mut self) -> Option<(OsString, OsString)> {
|
fn next(&mut self) -> Option<(OsString, OsString)> {
|
||||||
self.0
|
let Self(inner) = self;
|
||||||
|
match *inner {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,10 +142,39 @@ impl StdError for JoinPathsError {
|
|||||||
pub fn current_exe() -> io::Result<PathBuf> {
|
pub fn current_exe() -> io::Result<PathBuf> {
|
||||||
unsupported()
|
unsupported()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Env {
|
pub struct Env {
|
||||||
iter: vec::IntoIter<(OsString, OsString)>,
|
iter: vec::IntoIter<(OsString, OsString)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME(https://github.com/rust-lang/rust/issues/114583): Remove this when <OsStr as Debug>::fmt matches <str as Debug>::fmt.
|
||||||
|
pub struct EnvStrDebug<'a> {
|
||||||
|
slice: &'a [(OsString, OsString)],
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for EnvStrDebug<'_> {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
let Self { slice } = self;
|
||||||
|
f.debug_list()
|
||||||
|
.entries(slice.iter().map(|(a, b)| (a.to_str().unwrap(), b.to_str().unwrap())))
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Env {
|
||||||
|
pub fn str_debug(&self) -> impl fmt::Debug + '_ {
|
||||||
|
let Self { iter } = self;
|
||||||
|
EnvStrDebug { slice: iter.as_slice() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for Env {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
let Self { iter } = self;
|
||||||
|
f.debug_list().entries(iter.as_slice()).finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl !Send for Env {}
|
impl !Send for Env {}
|
||||||
impl !Sync for Env {}
|
impl !Sync for Env {}
|
||||||
|
|
||||||
|
@ -85,25 +85,69 @@ pub fn error_string(mut errnum: i32) -> String {
|
|||||||
|
|
||||||
pub struct Env {
|
pub struct Env {
|
||||||
base: c::LPWCH,
|
base: c::LPWCH,
|
||||||
cur: c::LPWCH,
|
iter: EnvIterator,
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME(https://github.com/rust-lang/rust/issues/114583): Remove this when <OsStr as Debug>::fmt matches <str as Debug>::fmt.
|
||||||
|
pub struct EnvStrDebug<'a> {
|
||||||
|
iter: &'a EnvIterator,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for EnvStrDebug<'_> {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
let Self { iter } = self;
|
||||||
|
let iter: EnvIterator = (*iter).clone();
|
||||||
|
let mut list = f.debug_list();
|
||||||
|
for (a, b) in iter {
|
||||||
|
list.entry(&(a.to_str().unwrap(), b.to_str().unwrap()));
|
||||||
|
}
|
||||||
|
list.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Env {
|
||||||
|
pub fn str_debug(&self) -> impl fmt::Debug + '_ {
|
||||||
|
let Self { base: _, iter } = self;
|
||||||
|
EnvStrDebug { iter }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for Env {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
let Self { base: _, iter } = self;
|
||||||
|
f.debug_list().entries(iter.clone()).finish()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Iterator for Env {
|
impl Iterator for Env {
|
||||||
type Item = (OsString, OsString);
|
type Item = (OsString, OsString);
|
||||||
|
|
||||||
fn next(&mut self) -> Option<(OsString, OsString)> {
|
fn next(&mut self) -> Option<(OsString, OsString)> {
|
||||||
|
let Self { base: _, iter } = self;
|
||||||
|
iter.next()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
struct EnvIterator(c::LPWCH);
|
||||||
|
|
||||||
|
impl Iterator for EnvIterator {
|
||||||
|
type Item = (OsString, OsString);
|
||||||
|
|
||||||
|
fn next(&mut self) -> Option<(OsString, OsString)> {
|
||||||
|
let Self(cur) = self;
|
||||||
loop {
|
loop {
|
||||||
unsafe {
|
unsafe {
|
||||||
if *self.cur == 0 {
|
if **cur == 0 {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let p = self.cur as *const u16;
|
let p = *cur as *const u16;
|
||||||
let mut len = 0;
|
let mut len = 0;
|
||||||
while *p.add(len) != 0 {
|
while *p.add(len) != 0 {
|
||||||
len += 1;
|
len += 1;
|
||||||
}
|
}
|
||||||
let s = slice::from_raw_parts(p, len);
|
let s = slice::from_raw_parts(p, len);
|
||||||
self.cur = self.cur.add(len + 1);
|
*cur = cur.add(len + 1);
|
||||||
|
|
||||||
// Windows allows environment variables to start with an equals
|
// Windows allows environment variables to start with an equals
|
||||||
// symbol (in any other position, this is the separator between
|
// symbol (in any other position, this is the separator between
|
||||||
@ -137,7 +181,7 @@ pub fn env() -> Env {
|
|||||||
if ch.is_null() {
|
if ch.is_null() {
|
||||||
panic!("failure getting env string from OS: {}", io::Error::last_os_error());
|
panic!("failure getting env string from OS: {}", io::Error::last_os_error());
|
||||||
}
|
}
|
||||||
Env { base: ch, cur: ch }
|
Env { base: ch, iter: EnvIterator(ch) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,13 +49,11 @@ async fn foo8() -> Result<(), ()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn foo9() -> Result<(), ()> {
|
fn foo9() -> Result<(), ()> {
|
||||||
let _ = await bar(); //~ ERROR `await` is only allowed inside `async` functions and blocks
|
let _ = await bar(); //~ ERROR incorrect use of `await`
|
||||||
//~^ ERROR incorrect use of `await`
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn foo10() -> Result<(), ()> {
|
fn foo10() -> Result<(), ()> {
|
||||||
let _ = await? bar(); //~ ERROR `await` is only allowed inside `async` functions and blocks
|
let _ = await? bar(); //~ ERROR incorrect use of `await`
|
||||||
//~^ ERROR incorrect use of `await`
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn foo11() -> Result<(), ()> {
|
fn foo11() -> Result<(), ()> {
|
||||||
@ -63,8 +61,7 @@ fn foo11() -> Result<(), ()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn foo12() -> Result<(), ()> {
|
fn foo12() -> Result<(), ()> {
|
||||||
let _ = (await bar())?; //~ ERROR `await` is only allowed inside `async` functions and blocks
|
let _ = (await bar())?; //~ ERROR incorrect use of `await`
|
||||||
//~^ ERROR incorrect use of `await`
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn foo13() -> Result<(), ()> {
|
fn foo13() -> Result<(), ()> {
|
||||||
@ -111,7 +108,6 @@ async fn foo27() -> Result<(), ()> {
|
|||||||
fn foo28() -> Result<(), ()> {
|
fn foo28() -> Result<(), ()> {
|
||||||
fn foo() -> Result<(), ()> {
|
fn foo() -> Result<(), ()> {
|
||||||
let _ = await!(bar())?; //~ ERROR incorrect use of `await`
|
let _ = await!(bar())?; //~ ERROR incorrect use of `await`
|
||||||
//~^ ERROR `await` is only allowed inside `async` functions
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
foo()
|
foo()
|
||||||
@ -119,7 +115,6 @@ fn foo28() -> Result<(), ()> {
|
|||||||
fn foo29() -> Result<(), ()> {
|
fn foo29() -> Result<(), ()> {
|
||||||
let foo = || {
|
let foo = || {
|
||||||
let _ = await!(bar())?; //~ ERROR incorrect use of `await`
|
let _ = await!(bar())?; //~ ERROR incorrect use of `await`
|
||||||
//~^ ERROR `await` is only allowed inside `async` functions
|
|
||||||
Ok(())
|
Ok(())
|
||||||
};
|
};
|
||||||
foo()
|
foo()
|
||||||
|
@ -59,61 +59,61 @@ LL | let _ = await bar();
|
|||||||
| ^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await`
|
| ^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await`
|
||||||
|
|
||||||
error: incorrect use of `await`
|
error: incorrect use of `await`
|
||||||
--> $DIR/incorrect-syntax-suggestions.rs:57:13
|
--> $DIR/incorrect-syntax-suggestions.rs:56:13
|
||||||
|
|
|
|
||||||
LL | let _ = await? bar();
|
LL | let _ = await? bar();
|
||||||
| ^^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await?`
|
| ^^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await?`
|
||||||
|
|
||||||
error: incorrect use of `await`
|
error: incorrect use of `await`
|
||||||
--> $DIR/incorrect-syntax-suggestions.rs:62:13
|
--> $DIR/incorrect-syntax-suggestions.rs:60:13
|
||||||
|
|
|
|
||||||
LL | let _ = await bar()?;
|
LL | let _ = await bar()?;
|
||||||
| ^^^^^^^^^^^^ help: `await` is a postfix operation: `bar()?.await`
|
| ^^^^^^^^^^^^ help: `await` is a postfix operation: `bar()?.await`
|
||||||
|
|
||||||
error: incorrect use of `await`
|
error: incorrect use of `await`
|
||||||
--> $DIR/incorrect-syntax-suggestions.rs:66:14
|
--> $DIR/incorrect-syntax-suggestions.rs:64:14
|
||||||
|
|
|
|
||||||
LL | let _ = (await bar())?;
|
LL | let _ = (await bar())?;
|
||||||
| ^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await`
|
| ^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await`
|
||||||
|
|
||||||
error: incorrect use of `await`
|
error: incorrect use of `await`
|
||||||
--> $DIR/incorrect-syntax-suggestions.rs:71:24
|
--> $DIR/incorrect-syntax-suggestions.rs:68:24
|
||||||
|
|
|
|
||||||
LL | let _ = bar().await();
|
LL | let _ = bar().await();
|
||||||
| ^^ help: `await` is not a method call, remove the parentheses
|
| ^^ help: `await` is not a method call, remove the parentheses
|
||||||
|
|
||||||
error: incorrect use of `await`
|
error: incorrect use of `await`
|
||||||
--> $DIR/incorrect-syntax-suggestions.rs:76:24
|
--> $DIR/incorrect-syntax-suggestions.rs:73:24
|
||||||
|
|
|
|
||||||
LL | let _ = bar().await()?;
|
LL | let _ = bar().await()?;
|
||||||
| ^^ help: `await` is not a method call, remove the parentheses
|
| ^^ help: `await` is not a method call, remove the parentheses
|
||||||
|
|
||||||
error: incorrect use of `await`
|
error: incorrect use of `await`
|
||||||
--> $DIR/incorrect-syntax-suggestions.rs:104:13
|
--> $DIR/incorrect-syntax-suggestions.rs:101:13
|
||||||
|
|
|
|
||||||
LL | let _ = await!(bar());
|
LL | let _ = await!(bar());
|
||||||
| ^^^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await`
|
| ^^^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await`
|
||||||
|
|
||||||
error: incorrect use of `await`
|
error: incorrect use of `await`
|
||||||
--> $DIR/incorrect-syntax-suggestions.rs:108:13
|
--> $DIR/incorrect-syntax-suggestions.rs:105:13
|
||||||
|
|
|
|
||||||
LL | let _ = await!(bar())?;
|
LL | let _ = await!(bar())?;
|
||||||
| ^^^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await`
|
| ^^^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await`
|
||||||
|
|
||||||
error: incorrect use of `await`
|
error: incorrect use of `await`
|
||||||
--> $DIR/incorrect-syntax-suggestions.rs:113:17
|
--> $DIR/incorrect-syntax-suggestions.rs:110:17
|
||||||
|
|
|
|
||||||
LL | let _ = await!(bar())?;
|
LL | let _ = await!(bar())?;
|
||||||
| ^^^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await`
|
| ^^^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await`
|
||||||
|
|
||||||
error: incorrect use of `await`
|
error: incorrect use of `await`
|
||||||
--> $DIR/incorrect-syntax-suggestions.rs:121:17
|
--> $DIR/incorrect-syntax-suggestions.rs:117:17
|
||||||
|
|
|
|
||||||
LL | let _ = await!(bar())?;
|
LL | let _ = await!(bar())?;
|
||||||
| ^^^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await`
|
| ^^^^^^^^^^^^^ help: `await` is a postfix operation: `bar().await`
|
||||||
|
|
||||||
error: expected expression, found `=>`
|
error: expected expression, found `=>`
|
||||||
--> $DIR/incorrect-syntax-suggestions.rs:129:25
|
--> $DIR/incorrect-syntax-suggestions.rs:124:25
|
||||||
|
|
|
|
||||||
LL | match await { await => () }
|
LL | match await { await => () }
|
||||||
| ----- ^^ expected expression
|
| ----- ^^ expected expression
|
||||||
@ -121,13 +121,13 @@ LL | match await { await => () }
|
|||||||
| while parsing this incorrect await expression
|
| while parsing this incorrect await expression
|
||||||
|
|
||||||
error: incorrect use of `await`
|
error: incorrect use of `await`
|
||||||
--> $DIR/incorrect-syntax-suggestions.rs:129:11
|
--> $DIR/incorrect-syntax-suggestions.rs:124:11
|
||||||
|
|
|
|
||||||
LL | match await { await => () }
|
LL | match await { await => () }
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^ help: `await` is a postfix operation: `{ await => () }.await`
|
| ^^^^^^^^^^^^^^^^^^^^^ help: `await` is a postfix operation: `{ await => () }.await`
|
||||||
|
|
||||||
error: expected one of `.`, `?`, `{`, or an operator, found `}`
|
error: expected one of `.`, `?`, `{`, or an operator, found `}`
|
||||||
--> $DIR/incorrect-syntax-suggestions.rs:132:1
|
--> $DIR/incorrect-syntax-suggestions.rs:127:1
|
||||||
|
|
|
|
||||||
LL | match await { await => () }
|
LL | match await { await => () }
|
||||||
| ----- - expected one of `.`, `?`, `{`, or an operator
|
| ----- - expected one of `.`, `?`, `{`, or an operator
|
||||||
@ -138,31 +138,7 @@ LL | }
|
|||||||
| ^ unexpected token
|
| ^ unexpected token
|
||||||
|
|
||||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||||
--> $DIR/incorrect-syntax-suggestions.rs:52:13
|
--> $DIR/incorrect-syntax-suggestions.rs:68:19
|
||||||
|
|
|
||||||
LL | fn foo9() -> Result<(), ()> {
|
|
||||||
| ---- this is not `async`
|
|
||||||
LL | let _ = await bar();
|
|
||||||
| ^^^^^ only allowed inside `async` functions and blocks
|
|
||||||
|
|
||||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
|
||||||
--> $DIR/incorrect-syntax-suggestions.rs:57:13
|
|
||||||
|
|
|
||||||
LL | fn foo10() -> Result<(), ()> {
|
|
||||||
| ----- this is not `async`
|
|
||||||
LL | let _ = await? bar();
|
|
||||||
| ^^^^^ only allowed inside `async` functions and blocks
|
|
||||||
|
|
||||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
|
||||||
--> $DIR/incorrect-syntax-suggestions.rs:66:14
|
|
||||||
|
|
|
||||||
LL | fn foo12() -> Result<(), ()> {
|
|
||||||
| ----- this is not `async`
|
|
||||||
LL | let _ = (await bar())?;
|
|
||||||
| ^^^^^ only allowed inside `async` functions and blocks
|
|
||||||
|
|
||||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
|
||||||
--> $DIR/incorrect-syntax-suggestions.rs:71:19
|
|
||||||
|
|
|
|
||||||
LL | fn foo13() -> Result<(), ()> {
|
LL | fn foo13() -> Result<(), ()> {
|
||||||
| ----- this is not `async`
|
| ----- this is not `async`
|
||||||
@ -170,7 +146,7 @@ LL | let _ = bar().await();
|
|||||||
| ^^^^^ only allowed inside `async` functions and blocks
|
| ^^^^^ only allowed inside `async` functions and blocks
|
||||||
|
|
||||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||||
--> $DIR/incorrect-syntax-suggestions.rs:76:19
|
--> $DIR/incorrect-syntax-suggestions.rs:73:19
|
||||||
|
|
|
|
||||||
LL | fn foo14() -> Result<(), ()> {
|
LL | fn foo14() -> Result<(), ()> {
|
||||||
| ----- this is not `async`
|
| ----- this is not `async`
|
||||||
@ -178,7 +154,7 @@ LL | let _ = bar().await()?;
|
|||||||
| ^^^^^ only allowed inside `async` functions and blocks
|
| ^^^^^ only allowed inside `async` functions and blocks
|
||||||
|
|
||||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||||
--> $DIR/incorrect-syntax-suggestions.rs:81:19
|
--> $DIR/incorrect-syntax-suggestions.rs:78:19
|
||||||
|
|
|
|
||||||
LL | fn foo15() -> Result<(), ()> {
|
LL | fn foo15() -> Result<(), ()> {
|
||||||
| ----- this is not `async`
|
| ----- this is not `async`
|
||||||
@ -186,7 +162,7 @@ LL | let _ = bar().await;
|
|||||||
| ^^^^^ only allowed inside `async` functions and blocks
|
| ^^^^^ only allowed inside `async` functions and blocks
|
||||||
|
|
||||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||||
--> $DIR/incorrect-syntax-suggestions.rs:85:19
|
--> $DIR/incorrect-syntax-suggestions.rs:82:19
|
||||||
|
|
|
|
||||||
LL | fn foo16() -> Result<(), ()> {
|
LL | fn foo16() -> Result<(), ()> {
|
||||||
| ----- this is not `async`
|
| ----- this is not `async`
|
||||||
@ -194,7 +170,7 @@ LL | let _ = bar().await?;
|
|||||||
| ^^^^^ only allowed inside `async` functions and blocks
|
| ^^^^^ only allowed inside `async` functions and blocks
|
||||||
|
|
||||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||||
--> $DIR/incorrect-syntax-suggestions.rs:90:23
|
--> $DIR/incorrect-syntax-suggestions.rs:87:23
|
||||||
|
|
|
|
||||||
LL | fn foo() -> Result<(), ()> {
|
LL | fn foo() -> Result<(), ()> {
|
||||||
| --- this is not `async`
|
| --- this is not `async`
|
||||||
@ -202,29 +178,13 @@ LL | let _ = bar().await?;
|
|||||||
| ^^^^^ only allowed inside `async` functions and blocks
|
| ^^^^^ only allowed inside `async` functions and blocks
|
||||||
|
|
||||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
||||||
--> $DIR/incorrect-syntax-suggestions.rs:97:23
|
--> $DIR/incorrect-syntax-suggestions.rs:94:23
|
||||||
|
|
|
|
||||||
LL | let foo = || {
|
LL | let foo = || {
|
||||||
| -- this is not `async`
|
| -- this is not `async`
|
||||||
LL | let _ = bar().await?;
|
LL | let _ = bar().await?;
|
||||||
| ^^^^^ only allowed inside `async` functions and blocks
|
| ^^^^^ only allowed inside `async` functions and blocks
|
||||||
|
|
||||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
error: aborting due to 28 previous errors
|
||||||
--> $DIR/incorrect-syntax-suggestions.rs:113:17
|
|
||||||
|
|
|
||||||
LL | fn foo() -> Result<(), ()> {
|
|
||||||
| --- this is not `async`
|
|
||||||
LL | let _ = await!(bar())?;
|
|
||||||
| ^^^^^ only allowed inside `async` functions and blocks
|
|
||||||
|
|
||||||
error[E0728]: `await` is only allowed inside `async` functions and blocks
|
|
||||||
--> $DIR/incorrect-syntax-suggestions.rs:121:17
|
|
||||||
|
|
|
||||||
LL | let foo = || {
|
|
||||||
| -- this is not `async`
|
|
||||||
LL | let _ = await!(bar())?;
|
|
||||||
| ^^^^^ only allowed inside `async` functions and blocks
|
|
||||||
|
|
||||||
error: aborting due to 33 previous errors
|
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0728`.
|
For more information about this error, try `rustc --explain E0728`.
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
// edition:2015
|
||||||
|
// check-pass
|
||||||
|
// issue: 114664
|
||||||
|
|
||||||
|
fn ice() -> impl AsRef<Fn(&())> {
|
||||||
|
//~^ WARN trait objects without an explicit `dyn` are deprecated
|
||||||
|
//~| WARN trait objects without an explicit `dyn` are deprecated
|
||||||
|
//~| WARN trait objects without an explicit `dyn` are deprecated
|
||||||
|
//~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
||||||
|
//~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
||||||
|
//~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
||||||
|
Foo
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Foo;
|
||||||
|
impl AsRef<dyn Fn(&())> for Foo {
|
||||||
|
fn as_ref(&self) -> &(dyn for<'a> Fn(&'a ()) + 'static) {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn main() {}
|
@ -0,0 +1,42 @@
|
|||||||
|
warning: trait objects without an explicit `dyn` are deprecated
|
||||||
|
--> $DIR/fresh-lifetime-from-bare-trait-obj-114664.rs:5:24
|
||||||
|
|
|
||||||
|
LL | fn ice() -> impl AsRef<Fn(&())> {
|
||||||
|
| ^^^^^^^
|
||||||
|
|
|
||||||
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
||||||
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
|
||||||
|
= note: `#[warn(bare_trait_objects)]` on by default
|
||||||
|
help: use `dyn`
|
||||||
|
|
|
||||||
|
LL | fn ice() -> impl AsRef<dyn Fn(&())> {
|
||||||
|
| +++
|
||||||
|
|
||||||
|
warning: trait objects without an explicit `dyn` are deprecated
|
||||||
|
--> $DIR/fresh-lifetime-from-bare-trait-obj-114664.rs:5:24
|
||||||
|
|
|
||||||
|
LL | fn ice() -> impl AsRef<Fn(&())> {
|
||||||
|
| ^^^^^^^
|
||||||
|
|
|
||||||
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
||||||
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
|
||||||
|
help: use `dyn`
|
||||||
|
|
|
||||||
|
LL | fn ice() -> impl AsRef<dyn Fn(&())> {
|
||||||
|
| +++
|
||||||
|
|
||||||
|
warning: trait objects without an explicit `dyn` are deprecated
|
||||||
|
--> $DIR/fresh-lifetime-from-bare-trait-obj-114664.rs:5:24
|
||||||
|
|
|
||||||
|
LL | fn ice() -> impl AsRef<Fn(&())> {
|
||||||
|
| ^^^^^^^
|
||||||
|
|
|
||||||
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
||||||
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
|
||||||
|
help: use `dyn`
|
||||||
|
|
|
||||||
|
LL | fn ice() -> impl AsRef<dyn Fn(&())> {
|
||||||
|
| +++
|
||||||
|
|
||||||
|
warning: 3 warnings emitted
|
||||||
|
|
7
tests/ui/parser/issues/issue-113203.rs
Normal file
7
tests/ui/parser/issues/issue-113203.rs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
// Checks what happens when we attempt to use the await keyword as a prefix. Span
|
||||||
|
// incorrectly emitted an `.await` in E0277 which does not exist
|
||||||
|
// edition:2018
|
||||||
|
fn main() {
|
||||||
|
await {}()
|
||||||
|
//~^ ERROR incorrect use of `await`
|
||||||
|
}
|
8
tests/ui/parser/issues/issue-113203.stderr
Normal file
8
tests/ui/parser/issues/issue-113203.stderr
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
error: incorrect use of `await`
|
||||||
|
--> $DIR/issue-113203.rs:5:5
|
||||||
|
|
|
||||||
|
LL | await {}()
|
||||||
|
| ^^^^^^^^ help: `await` is a postfix operation: `{}.await`
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
@ -490,7 +490,7 @@ cc = ["@nnethercote"]
|
|||||||
[assign]
|
[assign]
|
||||||
warn_non_default_branch = true
|
warn_non_default_branch = true
|
||||||
contributing_url = "https://rustc-dev-guide.rust-lang.org/getting-started.html"
|
contributing_url = "https://rustc-dev-guide.rust-lang.org/getting-started.html"
|
||||||
users_on_vacation = ["jyn514", "WaffleLapkin", "clubby789"]
|
users_on_vacation = ["jyn514", "WaffleLapkin", "clubby789", "oli-obk"]
|
||||||
|
|
||||||
[assign.adhoc_groups]
|
[assign.adhoc_groups]
|
||||||
compiler-team = [
|
compiler-team = [
|
||||||
|
Loading…
Reference in New Issue
Block a user