Skip to content

Commit b8c0a01

Browse files
committedAug 14, 2022
Auto merge of rust-lang#100540 - matthiaskrgr:rollup-734hkpt, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - rust-lang#100249 (Fix HorizonOS regression in FileTimes) - rust-lang#100253 (Recover from mutable variable declaration where `mut` is placed before `let`) - rust-lang#100482 (Add Duration rounding change to release note) - rust-lang#100523 ([rustdoc] remove Clean trait) - rust-lang#100524 (Impl `Debug` for some structs of rustbuild) - rust-lang#100526 (Add tests for the drop behavior of some control flow constructs) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 801821d + 59795d0 commit b8c0a01

File tree

10 files changed

+196
-19
lines changed

10 files changed

+196
-19
lines changed
 

‎RELEASES.md

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Libraries
2727
- [Extend `ptr::null` and `null_mut` to all thin (including extern) types.][94954]
2828
- [`impl Read and Write for VecDeque<u8>`.][95632]
2929
- [STD support for the Nintendo 3DS.][95897]
30+
- [Use rounding in float to Duration conversion methods.][96051]
3031
- [Make write/print macros eagerly drop temporaries.][96455]
3132
- [Implement internal traits that enable `[OsStr]::join`.][96881]
3233
- [Implement `Hash` for `core::alloc::Layout`.][97034]
@@ -99,6 +100,8 @@ Compatibility Notes
99100

100101
- [`#[link]` attributes are now checked more strictly,][96885] which may introduce
101102
errors for invalid attribute arguments that were previously ignored.
103+
- [Rounding is now used when converting a float to a `Duration`.][96051] The converted
104+
duration can differ slightly from what it was.
102105

103106
Internal Changes
104107
----------------
@@ -118,6 +121,7 @@ and related tools.
118121
[95818]: https://github.com/rust-lang/rust/pull/95818/
119122
[95897]: https://github.com/rust-lang/rust/pull/95897/
120123
[95953]: https://github.com/rust-lang/rust/pull/95953/
124+
[96051]: https://github.com/rust-lang/rust/pull/96051/
121125
[96296]: https://github.com/rust-lang/rust/pull/96296/
122126
[96455]: https://github.com/rust-lang/rust/pull/96455/
123127
[96737]: https://github.com/rust-lang/rust/pull/96737/

‎compiler/rustc_parse/src/parser/stmt.rs

+13
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,19 @@ impl<'a> Parser<'a> {
5555
return Ok(Some(stmt.into_inner()));
5656
}
5757

58+
if self.token.is_keyword(kw::Mut) && self.is_keyword_ahead(1, &[kw::Let]) {
59+
self.bump();
60+
let mut_let_span = lo.to(self.token.span);
61+
self.struct_span_err(mut_let_span, "invalid variable declaration")
62+
.span_suggestion(
63+
mut_let_span,
64+
"switch the order of `mut` and `let`",
65+
"let mut",
66+
Applicability::MaybeIncorrect,
67+
)
68+
.emit();
69+
}
70+
5871
Ok(Some(if self.token.is_keyword(kw::Let) {
5972
self.parse_local_mk(lo, attrs, capture_semi, force_collect)?
6073
} else if self.is_kw_followed_by_ident(kw::Mut) {

‎library/std/src/sys/unix/fs.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -544,11 +544,11 @@ impl Default for FileTimes {
544544
fn default() -> Self {
545545
// Redox doesn't appear to support `UTIME_OMIT`, so we stub it out here, and always return
546546
// an error in `set_times`.
547-
// ESP-IDF does not support `futimens` at all and the behavior for that OS is therefore
547+
// ESP-IDF and HorizonOS do not support `futimens` at all and the behavior for those OS is therefore
548548
// the same as for Redox.
549-
#[cfg(any(target_os = "redox", target_os = "espidf"))]
549+
#[cfg(any(target_os = "redox", target_os = "espidf", target_os = "horizon"))]
550550
let omit = libc::timespec { tv_sec: 0, tv_nsec: 0 };
551-
#[cfg(not(any(target_os = "redox", target_os = "espidf")))]
551+
#[cfg(not(any(target_os = "redox", target_os = "espidf", target_os = "horizon")))]
552552
let omit = libc::timespec { tv_sec: 0, tv_nsec: libc::UTIME_OMIT as _ };
553553
Self([omit; 2])
554554
}
@@ -1083,9 +1083,9 @@ impl File {
10831083

10841084
pub fn set_times(&self, times: FileTimes) -> io::Result<()> {
10851085
cfg_if::cfg_if! {
1086-
if #[cfg(any(target_os = "redox", target_os = "espidf"))] {
1086+
if #[cfg(any(target_os = "redox", target_os = "espidf", target_os = "horizon"))] {
10871087
// Redox doesn't appear to support `UTIME_OMIT`.
1088-
// ESP-IDF does not support `futimens` at all and the behavior for that OS is therefore
1088+
// ESP-IDF and HorizonOS do not support `futimens` at all and the behavior for those OS is therefore
10891089
// the same as for Redox.
10901090
drop(times);
10911091
Err(io::const_io_error!(

‎src/bootstrap/flags.rs

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ pub struct Flags {
8080
pub llvm_profile_generate: bool,
8181
}
8282

83+
#[derive(Debug)]
8384
#[cfg_attr(test, derive(Clone))]
8485
pub enum Subcommand {
8586
Build {

‎src/bootstrap/setup.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::{
1111
io::{self, Write},
1212
};
1313

14-
#[derive(Clone, Copy, Eq, PartialEq)]
14+
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
1515
pub enum Profile {
1616
Compiler,
1717
Codegen,

‎src/librustdoc/clean/mod.rs

+7-13
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ use utils::*;
4444
pub(crate) use self::types::*;
4545
pub(crate) use self::utils::{get_auto_trait_and_blanket_impls, krate, register_res};
4646

47-
pub(crate) trait Clean<'tcx, T> {
48-
fn clean(&self, cx: &mut DocContext<'tcx>) -> T;
49-
}
50-
5147
pub(crate) fn clean_doc_module<'tcx>(doc: &DocModule<'tcx>, cx: &mut DocContext<'tcx>) -> Item {
5248
let mut items: Vec<Item> = vec![];
5349
let mut inserted = FxHashSet::default();
@@ -1925,7 +1921,7 @@ fn clean_maybe_renamed_item<'tcx>(
19251921
}))
19261922
}
19271923
ItemKind::Enum(ref def, generics) => EnumItem(Enum {
1928-
variants: def.variants.iter().map(|v| v.clean(cx)).collect(),
1924+
variants: def.variants.iter().map(|v| clean_variant(v, cx)).collect(),
19291925
generics: clean_generics(generics, cx),
19301926
}),
19311927
ItemKind::TraitAlias(generics, bounds) => TraitAliasItem(TraitAlias {
@@ -1978,14 +1974,12 @@ fn clean_maybe_renamed_item<'tcx>(
19781974
})
19791975
}
19801976

1981-
impl<'tcx> Clean<'tcx, Item> for hir::Variant<'tcx> {
1982-
fn clean(&self, cx: &mut DocContext<'tcx>) -> Item {
1983-
let kind = VariantItem(clean_variant_data(&self.data, cx));
1984-
let what_rustc_thinks =
1985-
Item::from_hir_id_and_parts(self.id, Some(self.ident.name), kind, cx);
1986-
// don't show `pub` for variants, which are always public
1987-
Item { visibility: Inherited, ..what_rustc_thinks }
1988-
}
1977+
fn clean_variant<'tcx>(variant: &hir::Variant<'tcx>, cx: &mut DocContext<'tcx>) -> Item {
1978+
let kind = VariantItem(clean_variant_data(&variant.data, cx));
1979+
let what_rustc_thinks =
1980+
Item::from_hir_id_and_parts(variant.id, Some(variant.ident.name), kind, cx);
1981+
// don't show `pub` for variants, which are always public
1982+
Item { visibility: Inherited, ..what_rustc_thinks }
19891983
}
19901984

19911985
fn clean_impl<'tcx>(

‎src/test/ui/drop/drop_order.rs

+145
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
// run-pass
2+
3+
use std::cell::RefCell;
4+
use std::convert::TryInto;
5+
6+
#[derive(Default)]
7+
struct DropOrderCollector(RefCell<Vec<u32>>);
8+
9+
struct LoudDrop<'a>(&'a DropOrderCollector, u32);
10+
11+
impl Drop for LoudDrop<'_> {
12+
fn drop(&mut self) {
13+
println!("{}", self.1);
14+
self.0.0.borrow_mut().push(self.1);
15+
}
16+
}
17+
18+
impl DropOrderCollector {
19+
fn option_loud_drop(&self, n: u32) -> Option<LoudDrop> {
20+
Some(LoudDrop(self, n))
21+
}
22+
23+
fn loud_drop(&self, n: u32) -> LoudDrop {
24+
LoudDrop(self, n)
25+
}
26+
27+
fn print(&self, n: u32) {
28+
println!("{}", n);
29+
self.0.borrow_mut().push(n)
30+
}
31+
32+
fn if_(&self) {
33+
if self.option_loud_drop(1).is_some() {
34+
self.print(2);
35+
}
36+
37+
if self.option_loud_drop(3).is_none() {
38+
unreachable!();
39+
} else if self.option_loud_drop(4).is_some() {
40+
self.print(5);
41+
}
42+
43+
if {
44+
if self.option_loud_drop(7).is_some() && self.option_loud_drop(6).is_some() {
45+
self.loud_drop(8);
46+
true
47+
} else {
48+
false
49+
}
50+
} {
51+
self.print(9);
52+
}
53+
}
54+
55+
fn if_let(&self) {
56+
if let None = self.option_loud_drop(2) {
57+
unreachable!();
58+
} else {
59+
self.print(1);
60+
}
61+
62+
if let Some(_) = self.option_loud_drop(4) {
63+
self.print(3);
64+
}
65+
66+
if let Some(_d) = self.option_loud_drop(6) {
67+
self.print(5);
68+
}
69+
}
70+
71+
fn match_(&self) {
72+
match self.option_loud_drop(2) {
73+
_any => self.print(1),
74+
}
75+
76+
match self.option_loud_drop(4) {
77+
_ => self.print(3),
78+
}
79+
80+
match self.option_loud_drop(6) {
81+
Some(_) => self.print(5),
82+
_ => unreachable!(),
83+
}
84+
85+
match {
86+
let _ = self.loud_drop(7);
87+
let _d = self.loud_drop(9);
88+
self.print(8);
89+
()
90+
} {
91+
() => self.print(10),
92+
}
93+
94+
match {
95+
match self.option_loud_drop(14) {
96+
_ => {
97+
self.print(11);
98+
self.option_loud_drop(13)
99+
}
100+
}
101+
} {
102+
_ => self.print(12),
103+
}
104+
105+
match {
106+
loop {
107+
break match self.option_loud_drop(16) {
108+
_ => {
109+
self.print(15);
110+
self.option_loud_drop(18)
111+
}
112+
};
113+
}
114+
} {
115+
_ => self.print(17),
116+
}
117+
}
118+
119+
fn assert_sorted(self) {
120+
assert!(
121+
self.0
122+
.into_inner()
123+
.into_iter()
124+
.enumerate()
125+
.all(|(idx, item)| idx + 1 == item.try_into().unwrap())
126+
);
127+
}
128+
}
129+
130+
fn main() {
131+
println!("-- if --");
132+
let collector = DropOrderCollector::default();
133+
collector.if_();
134+
collector.assert_sorted();
135+
136+
println!("-- if let --");
137+
let collector = DropOrderCollector::default();
138+
collector.if_let();
139+
collector.assert_sorted();
140+
141+
println!("-- match --");
142+
let collector = DropOrderCollector::default();
143+
collector.match_();
144+
collector.assert_sorted();
145+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// run-rustfix
2+
3+
fn main() {
4+
let mut _x = 123;
5+
//~^ ERROR invalid variable declaration
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// run-rustfix
2+
3+
fn main() {
4+
mut let _x = 123;
5+
//~^ ERROR invalid variable declaration
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: invalid variable declaration
2+
--> $DIR/issue-100197-mut-let.rs:4:5
3+
|
4+
LL | mut let _x = 123;
5+
| ^^^^^^^ help: switch the order of `mut` and `let`: `let mut`
6+
7+
error: aborting due to previous error
8+

0 commit comments

Comments
 (0)
Please sign in to comment.