Skip to content

Commit cbb48a5

Browse files
committed
Auto merge of rust-lang#114756 - matthiaskrgr:rollup-4m7l4p6, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#94455 (Partially stabilize `int_roundings`) - rust-lang#114132 (Better Debug for Vars and VarsOs) - rust-lang#114584 (E0277 nolonger points at phantom `.await`) - rust-lang#114667 (Record binder for bare trait object in LifetimeCollectVisitor) - rust-lang#114692 (downgrade `internal_features` to warn) - rust-lang#114703 (Cover ParamConst in smir) - rust-lang#114734 (Mark oli as "on vacation") r? `@ghost` `@rustbot` modify labels: rollup
2 parents 1e836d1 + cf9081c commit cbb48a5

File tree

24 files changed

+386
-100
lines changed

24 files changed

+386
-100
lines changed

compiler/rustc_ast_lowering/src/lifetime_collector.rs

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use super::ResolverAstLoweringExt;
22
use rustc_ast::visit::{self, BoundKind, LifetimeCtxt, Visitor};
33
use rustc_ast::{GenericBounds, Lifetime, NodeId, PathSegment, PolyTraitRef, Ty, TyKind};
4-
use rustc_hir::def::LifetimeRes;
4+
use rustc_hir::def::{DefKind, LifetimeRes, Res};
55
use rustc_middle::span_bug;
66
use rustc_middle::ty::ResolverAstLowering;
77
use rustc_span::symbol::{kw, Ident};
@@ -77,7 +77,20 @@ impl<'ast> Visitor<'ast> for LifetimeCollectVisitor<'ast> {
7777
}
7878

7979
fn visit_ty(&mut self, t: &'ast Ty) {
80-
match t.kind {
80+
match &t.kind {
81+
TyKind::Path(None, _) => {
82+
// We can sometimes encounter bare trait objects
83+
// which are represented in AST as paths.
84+
if let Some(partial_res) = self.resolver.get_partial_res(t.id)
85+
&& let Some(Res::Def(DefKind::Trait | DefKind::TraitAlias, _)) = partial_res.full_res()
86+
{
87+
self.current_binders.push(t.id);
88+
visit::walk_ty(self, t);
89+
self.current_binders.pop();
90+
} else {
91+
visit::walk_ty(self, t);
92+
}
93+
}
8194
TyKind::BareFn(_) => {
8295
self.current_binders.push(t.id);
8396
visit::walk_ty(self, t);

compiler/rustc_codegen_ssa/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#![feature(associated_type_bounds)]
33
#![feature(box_patterns)]
44
#![feature(if_let_guard)]
5-
#![feature(int_roundings)]
65
#![feature(let_chains)]
76
#![feature(negative_impls)]
87
#![feature(never_type)]

compiler/rustc_lint/src/builtin.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2215,7 +2215,7 @@ declare_lint! {
22152215
///
22162216
/// ### Example
22172217
///
2218-
/// ```rust,compile_fail
2218+
/// ```rust
22192219
/// #![feature(rustc_attrs)]
22202220
/// ```
22212221
///
@@ -2226,7 +2226,7 @@ declare_lint! {
22262226
/// These features are an implementation detail of the compiler and standard
22272227
/// library and are not supposed to be used in user code.
22282228
pub INTERNAL_FEATURES,
2229-
Deny,
2229+
Warn,
22302230
"internal features are not supposed to be used"
22312231
}
22322232

compiler/rustc_parse/src/parser/diagnostics.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -1717,13 +1717,7 @@ impl<'a> Parser<'a> {
17171717
self.recover_await_prefix(await_sp)?
17181718
};
17191719
let sp = self.error_on_incorrect_await(lo, hi, &expr, is_question);
1720-
let kind = match expr.kind {
1721-
// Avoid knock-down errors as we don't know whether to interpret this as `foo().await?`
1722-
// or `foo()?.await` (the very reason we went with postfix syntax 😅).
1723-
ExprKind::Try(_) => ExprKind::Err,
1724-
_ => ExprKind::Await(expr, await_sp),
1725-
};
1726-
let expr = self.mk_expr(lo.to(sp), kind);
1720+
let expr = self.mk_expr(lo.to(sp), ExprKind::Err);
17271721
self.maybe_recover_from_bad_qpath(expr)
17281722
}
17291723

compiler/rustc_smir/src/rustc_smir/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1165,7 +1165,9 @@ impl<'tcx> Stable<'tcx> for rustc_middle::mir::ConstantKind<'tcx> {
11651165
let const_val = tables.tcx.valtree_to_const_val((c.ty(), val));
11661166
stable_mir::ty::ConstantKind::Allocated(new_allocation(self, const_val, tables))
11671167
}
1168-
_ => todo!(),
1168+
ty::ParamCt(param) => stable_mir::ty::ConstantKind::ParamCt(opaque(&param)),
1169+
ty::ErrorCt(_) => unreachable!(),
1170+
_ => unimplemented!(),
11691171
},
11701172
ConstantKind::Unevaluated(unev_const, ty) => {
11711173
stable_mir::ty::ConstantKind::Unevaluated(stable_mir::ty::UnevaluatedConst {

compiler/rustc_smir/src/stable_mir/ty.rs

+1
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ pub fn allocation_filter<'tcx>(
417417
pub enum ConstantKind {
418418
Allocated(Allocation),
419419
Unevaluated(UnevaluatedConst),
420+
ParamCt(Opaque),
420421
}
421422

422423
#[derive(Clone, Debug)]

library/core/src/num/uint_macros.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -2074,10 +2074,10 @@ macro_rules! uint_impl {
20742074
/// Basic usage:
20752075
///
20762076
/// ```
2077-
/// #![feature(int_roundings)]
20782077
#[doc = concat!("assert_eq!(7_", stringify!($SelfT), ".div_ceil(4), 2);")]
20792078
/// ```
2080-
#[unstable(feature = "int_roundings", issue = "88581")]
2079+
#[stable(feature = "int_roundings1", since = "CURRENT_RUSTC_VERSION")]
2080+
#[rustc_const_stable(feature = "int_roundings1", since = "CURRENT_RUSTC_VERSION")]
20812081
#[must_use = "this returns the result of the operation, \
20822082
without modifying the original"]
20832083
#[inline]
@@ -2109,11 +2109,11 @@ macro_rules! uint_impl {
21092109
/// Basic usage:
21102110
///
21112111
/// ```
2112-
/// #![feature(int_roundings)]
21132112
#[doc = concat!("assert_eq!(16_", stringify!($SelfT), ".next_multiple_of(8), 16);")]
21142113
#[doc = concat!("assert_eq!(23_", stringify!($SelfT), ".next_multiple_of(8), 24);")]
21152114
/// ```
2116-
#[unstable(feature = "int_roundings", issue = "88581")]
2115+
#[stable(feature = "int_roundings1", since = "CURRENT_RUSTC_VERSION")]
2116+
#[rustc_const_stable(feature = "int_roundings1", since = "CURRENT_RUSTC_VERSION")]
21172117
#[must_use = "this returns the result of the operation, \
21182118
without modifying the original"]
21192119
#[inline]
@@ -2134,13 +2134,13 @@ macro_rules! uint_impl {
21342134
/// Basic usage:
21352135
///
21362136
/// ```
2137-
/// #![feature(int_roundings)]
21382137
#[doc = concat!("assert_eq!(16_", stringify!($SelfT), ".checked_next_multiple_of(8), Some(16));")]
21392138
#[doc = concat!("assert_eq!(23_", stringify!($SelfT), ".checked_next_multiple_of(8), Some(24));")]
21402139
#[doc = concat!("assert_eq!(1_", stringify!($SelfT), ".checked_next_multiple_of(0), None);")]
21412140
#[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.checked_next_multiple_of(2), None);")]
21422141
/// ```
2143-
#[unstable(feature = "int_roundings", issue = "88581")]
2142+
#[stable(feature = "int_roundings1", since = "CURRENT_RUSTC_VERSION")]
2143+
#[rustc_const_stable(feature = "int_roundings1", since = "CURRENT_RUSTC_VERSION")]
21442144
#[must_use = "this returns the result of the operation, \
21452145
without modifying the original"]
21462146
#[inline]

library/std/src/env.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ impl Iterator for Vars {
178178
#[stable(feature = "std_debug", since = "1.16.0")]
179179
impl fmt::Debug for Vars {
180180
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
181-
f.debug_struct("Vars").finish_non_exhaustive()
181+
let Self { inner: VarsOs { inner } } = self;
182+
f.debug_struct("Vars").field("inner", &inner.str_debug()).finish()
182183
}
183184
}
184185

@@ -196,7 +197,8 @@ impl Iterator for VarsOs {
196197
#[stable(feature = "std_debug", since = "1.16.0")]
197198
impl fmt::Debug for VarsOs {
198199
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
199-
f.debug_struct("VarOs").finish_non_exhaustive()
200+
let Self { inner } = self;
201+
f.debug_struct("VarsOs").field("inner", inner).finish()
200202
}
201203
}
202204

@@ -829,7 +831,8 @@ impl DoubleEndedIterator for Args {
829831
#[stable(feature = "std_debug", since = "1.16.0")]
830832
impl fmt::Debug for Args {
831833
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
832-
f.debug_struct("Args").field("inner", &self.inner.inner).finish()
834+
let Self { inner: ArgsOs { inner } } = self;
835+
f.debug_struct("Args").field("inner", inner).finish()
833836
}
834837
}
835838

@@ -870,7 +873,8 @@ impl DoubleEndedIterator for ArgsOs {
870873
#[stable(feature = "std_debug", since = "1.16.0")]
871874
impl fmt::Debug for ArgsOs {
872875
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
873-
f.debug_struct("ArgsOs").field("inner", &self.inner).finish()
876+
let Self { inner } = self;
877+
f.debug_struct("ArgsOs").field("inner", inner).finish()
874878
}
875879
}
876880

library/std/src/env/tests.rs

+20
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,28 @@ fn args_debug() {
9595
format!("Args {{ inner: {:?} }}", args().collect::<Vec<_>>()),
9696
format!("{:?}", args())
9797
);
98+
}
99+
100+
#[test]
101+
fn args_os_debug() {
98102
assert_eq!(
99103
format!("ArgsOs {{ inner: {:?} }}", args_os().collect::<Vec<_>>()),
100104
format!("{:?}", args_os())
101105
);
102106
}
107+
108+
#[test]
109+
fn vars_debug() {
110+
assert_eq!(
111+
format!("Vars {{ inner: {:?} }}", vars().collect::<Vec<_>>()),
112+
format!("{:?}", vars())
113+
);
114+
}
115+
116+
#[test]
117+
fn vars_os_debug() {
118+
assert_eq!(
119+
format!("VarsOs {{ inner: {:?} }}", vars_os().collect::<Vec<_>>()),
120+
format!("{:?}", vars_os())
121+
);
122+
}

library/std/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,6 @@
293293
#![feature(float_next_up_down)]
294294
#![feature(hasher_prefixfree_extras)]
295295
#![feature(hashmap_internals)]
296-
#![feature(int_roundings)]
297296
#![feature(ip)]
298297
#![feature(ip_in_core)]
299298
#![feature(maybe_uninit_slice)]

library/std/src/sys/hermit/os.rs

+28
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,34 @@ pub struct Env {
112112
iter: vec::IntoIter<(OsString, OsString)>,
113113
}
114114

115+
// FIXME(https://github.com./rust-lang/rust/issues/114583): Remove this when <OsStr as Debug>::fmt matches <str as Debug>::fmt.
116+
pub struct EnvStrDebug<'a> {
117+
slice: &'a [(OsString, OsString)],
118+
}
119+
120+
impl fmt::Debug for EnvStrDebug<'_> {
121+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
122+
let Self { slice } = self;
123+
f.debug_list()
124+
.entries(slice.iter().map(|(a, b)| (a.to_str().unwrap(), b.to_str().unwrap())))
125+
.finish()
126+
}
127+
}
128+
129+
impl Env {
130+
pub fn str_debug(&self) -> impl fmt::Debug + '_ {
131+
let Self { iter } = self;
132+
EnvStrDebug { slice: iter.as_slice() }
133+
}
134+
}
135+
136+
impl fmt::Debug for Env {
137+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
138+
let Self { iter } = self;
139+
f.debug_list().entries(iter.as_slice()).finish()
140+
}
141+
}
142+
115143
impl !Send for Env {}
116144
impl !Sync for Env {}
117145

library/std/src/sys/sgx/os.rs

+49-2
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,61 @@ fn create_env_store() -> &'static EnvStore {
9696
unsafe { &*(ENV.load(Ordering::Relaxed) as *const EnvStore) }
9797
}
9898

99-
pub type Env = vec::IntoIter<(OsString, OsString)>;
99+
pub struct Env {
100+
iter: vec::IntoIter<(OsString, OsString)>,
101+
}
102+
103+
// FIXME(https://github.com./rust-lang/rust/issues/114583): Remove this when <OsStr as Debug>::fmt matches <str as Debug>::fmt.
104+
pub struct EnvStrDebug<'a> {
105+
slice: &'a [(OsString, OsString)],
106+
}
107+
108+
impl fmt::Debug for EnvStrDebug<'_> {
109+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
110+
let Self { slice } = self;
111+
f.debug_list()
112+
.entries(slice.iter().map(|(a, b)| (a.to_str().unwrap(), b.to_str().unwrap())))
113+
.finish()
114+
}
115+
}
116+
117+
impl Env {
118+
pub fn str_debug(&self) -> impl fmt::Debug + '_ {
119+
let Self { iter } = self;
120+
EnvStrDebug { slice: iter.as_slice() }
121+
}
122+
}
123+
124+
impl fmt::Debug for Env {
125+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
126+
let Self { iter } = self;
127+
f.debug_list().entries(iter.as_slice()).finish()
128+
}
129+
}
130+
131+
impl !Send for Env {}
132+
impl !Sync for Env {}
133+
134+
impl Iterator for Env {
135+
type Item = (OsString, OsString);
136+
fn next(&mut self) -> Option<(OsString, OsString)> {
137+
self.iter.next()
138+
}
139+
fn size_hint(&self) -> (usize, Option<usize>) {
140+
self.iter.size_hint()
141+
}
142+
}
100143

101144
pub fn env() -> Env {
102145
let clone_to_vec = |map: &HashMap<OsString, OsString>| -> Vec<_> {
103146
map.iter().map(|(k, v)| (k.clone(), v.clone())).collect()
104147
};
105148

106-
get_env_store().map(|env| clone_to_vec(&env.lock().unwrap())).unwrap_or_default().into_iter()
149+
let iter = get_env_store()
150+
.map(|env| clone_to_vec(&env.lock().unwrap()))
151+
.unwrap_or_default()
152+
.into_iter();
153+
Env { iter }
107154
}
108155

109156
pub fn getenv(k: &OsStr) -> Option<OsString> {

library/std/src/sys/solid/os.rs

+28
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,34 @@ pub struct Env {
8585
iter: vec::IntoIter<(OsString, OsString)>,
8686
}
8787

88+
// FIXME(https://github.com./rust-lang/rust/issues/114583): Remove this when <OsStr as Debug>::fmt matches <str as Debug>::fmt.
89+
pub struct EnvStrDebug<'a> {
90+
slice: &'a [(OsString, OsString)],
91+
}
92+
93+
impl fmt::Debug for EnvStrDebug<'_> {
94+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
95+
let Self { slice } = self;
96+
f.debug_list()
97+
.entries(slice.iter().map(|(a, b)| (a.to_str().unwrap(), b.to_str().unwrap())))
98+
.finish()
99+
}
100+
}
101+
102+
impl Env {
103+
pub fn str_debug(&self) -> impl fmt::Debug + '_ {
104+
let Self { iter } = self;
105+
EnvStrDebug { slice: iter.as_slice() }
106+
}
107+
}
108+
109+
impl fmt::Debug for Env {
110+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
111+
let Self { iter } = self;
112+
f.debug_list().entries(iter.as_slice()).finish()
113+
}
114+
}
115+
88116
impl !Send for Env {}
89117
impl !Sync for Env {}
90118

library/std/src/sys/unix/os.rs

+28
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,34 @@ pub struct Env {
495495
iter: vec::IntoIter<(OsString, OsString)>,
496496
}
497497

498+
// FIXME(https://github.com./rust-lang/rust/issues/114583): Remove this when <OsStr as Debug>::fmt matches <str as Debug>::fmt.
499+
pub struct EnvStrDebug<'a> {
500+
slice: &'a [(OsString, OsString)],
501+
}
502+
503+
impl fmt::Debug for EnvStrDebug<'_> {
504+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
505+
let Self { slice } = self;
506+
f.debug_list()
507+
.entries(slice.iter().map(|(a, b)| (a.to_str().unwrap(), b.to_str().unwrap())))
508+
.finish()
509+
}
510+
}
511+
512+
impl Env {
513+
pub fn str_debug(&self) -> impl fmt::Debug + '_ {
514+
let Self { iter } = self;
515+
EnvStrDebug { slice: iter.as_slice() }
516+
}
517+
}
518+
519+
impl fmt::Debug for Env {
520+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
521+
let Self { iter } = self;
522+
f.debug_list().entries(iter.as_slice()).finish()
523+
}
524+
}
525+
498526
impl !Send for Env {}
499527
impl !Sync for Env {}
500528

0 commit comments

Comments
 (0)