Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 11 pull requests #74322

Closed
wants to merge 60 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
7527409
Constify most non-trait `Duration` methods as described in #72440
marmeladema May 21, 2020
37570e8
Substantial refactor to the design of LineWriter
Lucretiel May 29, 2020
0f38158
Updated comments; only pre-flush newline terminated buffers
Lucretiel May 31, 2020
4a1597f
Expressionify `LineWriterShim::write`
Lucretiel May 31, 2020
5edad37
Expressionify write_all
Lucretiel May 31, 2020
1bf8ba3
x.py fmt
Lucretiel May 31, 2020
e0dfdc6
Added check for `is_write_vectored`
Lucretiel Jun 1, 2020
2c3024b
Add comment describing erroneous_flush_retried
Lucretiel Jun 1, 2020
e89e2e4
Added test stubs
Lucretiel Jun 1, 2020
f0a0807
Various testing & implementation updates:
Lucretiel Jun 1, 2020
b6296e8
Tons of testing updates, other minor changes
Lucretiel Jun 2, 2020
e022d34
Fixed typo in test
Lucretiel Jun 2, 2020
e4328ae
Code review updates: all minor style fixes
Lucretiel Jun 2, 2020
f7650fe
Add comment
Lucretiel Jun 2, 2020
7a6a12b
Tidy fixes
Lucretiel Jun 2, 2020
338a2c0
Reimplement flush_buf with a Guard. Longer, but cleaner.
Lucretiel Jun 2, 2020
c869638
Added comment about BufWrite::write_all
Lucretiel Jun 2, 2020
61f591e
Improved line_vectored_ignored. Added stylistic semicolon.
Lucretiel Jun 2, 2020
2d22c77
Fixed bug in write_vectored & empty buffers
Lucretiel Jun 2, 2020
2c23b90
Comment updates
Lucretiel Jun 2, 2020
e999ca5
Remove inline from write_to_buf
Lucretiel Jun 2, 2020
70ba320
More minor changes
Lucretiel Jun 2, 2020
5b1a40c
BufWriter::write* methods now use fewer runtime checks
Lucretiel Jun 2, 2020
8df5ae0
x.py fix AGAIN
Lucretiel Jun 2, 2020
60ab99f
Fixed corner case related to partial-line buffering
Lucretiel Jun 2, 2020
38017a3
Update comments with relevant issue numbers
Lucretiel Jun 2, 2020
59710fb
Clarified comment in `partial_multiline_buffering` test
Lucretiel Jun 2, 2020
3e48aae
Clean up E0704 error explanation
GuillaumeGomez Jun 25, 2020
98a3b07
Add missing Stdin and StdinLock exampels
GuillaumeGomez Jun 26, 2020
9448ed4
Obviate #[allow(improper_ctypes_definitions)]
Goirad Jun 29, 2020
bddb266
typeck: check for infer before type impls trait
davidtwco Jul 2, 2020
23d7b3f
Remove an unwrap in layout computation
erikdesjardins Jul 10, 2020
b8632e1
Removed FIXME
Lucretiel Jul 11, 2020
140bfc5
Removed another FIXME
Lucretiel Jul 11, 2020
997accc
Remove doubled "is_write_vectored"
Lucretiel Jul 11, 2020
6a7b5df
Removed unused method
Lucretiel Jul 11, 2020
606593f
Minor updates
Lucretiel Jul 12, 2020
9a8b516
Sorting feature attributes in std
tesuji Jul 10, 2020
1e05e09
Remove the useless indentation
tesuji Jul 10, 2020
0ff820c
Move constants to top file
tesuji Jul 12, 2020
90a7d24
Make is_valid_drive_letter function
tesuji Jul 10, 2020
27a966a
Make use of slice::strip_prefix and slice pattern
tesuji Jul 10, 2020
b1d6798
Rewrite parse_two_comps
tesuji Jul 10, 2020
0281a05
Prefer empty OsStr over unsafe cast from [u8]
tesuji Jul 10, 2020
e31898b
Reduce unsafe scope
tesuji Jul 12, 2020
083c2f6
pprust: support multiline comments within lines
davidtwco Jul 12, 2020
5daedea
Detect tuple struct incorrectly used as struct pat
estebank Jul 9, 2020
0e89f50
Clean up handling of style files in rustdoc
Cldfire Jul 12, 2020
8c45cf8
Add Ayu theme to rustdoc
Cldfire Jul 12, 2020
d716d1c
Rollup merge of #71237 - Cldfire:rustdoc-ayu-theme, r=GuilliaumeGomez
Dylan-DPC Jul 14, 2020
246a47b
Rollup merge of #72481 - marmeladema:duration-consts-2, r=oli-obk
Dylan-DPC Jul 14, 2020
8fdcf94
Rollup merge of #72808 - Lucretiel:line-writer-reimpl, r=Amanieu
Dylan-DPC Jul 14, 2020
27b2897
Rollup merge of #73720 - GuillaumeGomez:cleanup-e0704, r=Dylan-DPC
Dylan-DPC Jul 14, 2020
92f6bf3
Rollup merge of #73759 - GuillaumeGomez:stdin-examples, r=Dylan-DPC
Dylan-DPC Jul 14, 2020
5acc42f
Rollup merge of #73866 - Goirad:fix-entry-improper-ctypes, r=davidtwco
Dylan-DPC Jul 14, 2020
af56daa
Rollup merge of #73965 - davidtwco:issue-73886-non-primitive-slice-ca…
Dylan-DPC Jul 14, 2020
88f072b
Rollup merge of #74173 - estebank:struct-pat-as-enum, r=petrochenkov
Dylan-DPC Jul 14, 2020
7adb86d
Rollup merge of #74220 - lzutao:windows-path-com, r=LukasKalbertodt
Dylan-DPC Jul 14, 2020
38fc369
Rollup merge of #74227 - erikdesjardins:layun, r=estebank
Dylan-DPC Jul 14, 2020
317c840
Rollup merge of #74272 - davidtwco:issue-73626-multiline-mixed-commen…
Dylan-DPC Jul 14, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3996,6 +3996,7 @@ dependencies = [
"rustc_data_structures",
"rustc_errors",
"rustc_hir",
"rustc_hir_pretty",
"rustc_index",
"rustc_infer",
"rustc_middle",
Expand Down
1 change: 1 addition & 0 deletions src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
#![feature(custom_inner_attributes)]
#![feature(decl_macro)]
#![feature(doc_cfg)]
#![feature(duration_consts_2)]
#![feature(extern_types)]
#![feature(fundamental)]
#![feature(intrinsics)]
Expand Down
47 changes: 28 additions & 19 deletions src/libcore/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,12 @@ impl Duration {
/// ```
#[stable(feature = "duration", since = "1.3.0")]
#[inline]
#[rustc_const_stable(feature = "duration_consts", since = "1.32.0")]
pub fn new(secs: u64, nanos: u32) -> Duration {
let secs =
secs.checked_add((nanos / NANOS_PER_SEC) as u64).expect("overflow in Duration::new");
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
pub const fn new(secs: u64, nanos: u32) -> Duration {
let secs = match secs.checked_add((nanos / NANOS_PER_SEC) as u64) {
Some(secs) => secs,
None => panic!("overflow in Duration::new"),
};
let nanos = nanos % NANOS_PER_SEC;
Duration { secs, nanos }
}
Expand Down Expand Up @@ -433,7 +435,8 @@ impl Duration {
/// ```
#[stable(feature = "duration_checked_ops", since = "1.16.0")]
#[inline]
pub fn checked_add(self, rhs: Duration) -> Option<Duration> {
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
pub const fn checked_add(self, rhs: Duration) -> Option<Duration> {
if let Some(mut secs) = self.secs.checked_add(rhs.secs) {
let mut nanos = self.nanos + rhs.nanos;
if nanos >= NANOS_PER_SEC {
Expand Down Expand Up @@ -468,7 +471,8 @@ impl Duration {
/// ```
#[stable(feature = "duration_checked_ops", since = "1.16.0")]
#[inline]
pub fn checked_sub(self, rhs: Duration) -> Option<Duration> {
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
pub const fn checked_sub(self, rhs: Duration) -> Option<Duration> {
if let Some(mut secs) = self.secs.checked_sub(rhs.secs) {
let nanos = if self.nanos >= rhs.nanos {
self.nanos - rhs.nanos
Expand Down Expand Up @@ -504,19 +508,19 @@ impl Duration {
/// ```
#[stable(feature = "duration_checked_ops", since = "1.16.0")]
#[inline]
pub fn checked_mul(self, rhs: u32) -> Option<Duration> {
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
pub const fn checked_mul(self, rhs: u32) -> Option<Duration> {
// Multiply nanoseconds as u64, because it cannot overflow that way.
let total_nanos = self.nanos as u64 * rhs as u64;
let extra_secs = total_nanos / (NANOS_PER_SEC as u64);
let nanos = (total_nanos % (NANOS_PER_SEC as u64)) as u32;
if let Some(secs) =
self.secs.checked_mul(rhs as u64).and_then(|s| s.checked_add(extra_secs))
{
debug_assert!(nanos < NANOS_PER_SEC);
Some(Duration { secs, nanos })
} else {
None
if let Some(s) = self.secs.checked_mul(rhs as u64) {
if let Some(secs) = s.checked_add(extra_secs) {
debug_assert!(nanos < NANOS_PER_SEC);
return Some(Duration { secs, nanos });
}
}
None
}

/// Checked `Duration` division. Computes `self / other`, returning [`None`]
Expand All @@ -537,7 +541,8 @@ impl Duration {
/// ```
#[stable(feature = "duration_checked_ops", since = "1.16.0")]
#[inline]
pub fn checked_div(self, rhs: u32) -> Option<Duration> {
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
pub const fn checked_div(self, rhs: u32) -> Option<Duration> {
if rhs != 0 {
let secs = self.secs / (rhs as u64);
let carry = self.secs - secs * (rhs as u64);
Expand All @@ -563,7 +568,8 @@ impl Duration {
/// ```
#[stable(feature = "duration_float", since = "1.38.0")]
#[inline]
pub fn as_secs_f64(&self) -> f64 {
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
pub const fn as_secs_f64(&self) -> f64 {
(self.secs as f64) + (self.nanos as f64) / (NANOS_PER_SEC as f64)
}

Expand All @@ -580,7 +586,8 @@ impl Duration {
/// ```
#[stable(feature = "duration_float", since = "1.38.0")]
#[inline]
pub fn as_secs_f32(&self) -> f32 {
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
pub const fn as_secs_f32(&self) -> f32 {
(self.secs as f32) + (self.nanos as f32) / (NANOS_PER_SEC as f32)
}

Expand Down Expand Up @@ -747,7 +754,8 @@ impl Duration {
/// ```
#[unstable(feature = "div_duration", issue = "63139")]
#[inline]
pub fn div_duration_f64(self, rhs: Duration) -> f64 {
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
pub const fn div_duration_f64(self, rhs: Duration) -> f64 {
self.as_secs_f64() / rhs.as_secs_f64()
}

Expand All @@ -764,7 +772,8 @@ impl Duration {
/// ```
#[unstable(feature = "div_duration", issue = "63139")]
#[inline]
pub fn div_duration_f32(self, rhs: Duration) -> f32 {
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
pub const fn div_duration_f32(self, rhs: Duration) -> f32 {
self.as_secs_f32() / rhs.as_secs_f32()
}
}
Expand Down
15 changes: 13 additions & 2 deletions src/librustc_ast_pretty/pprust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,20 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
fn print_comment(&mut self, cmnt: &comments::Comment) {
match cmnt.style {
comments::Mixed => {
assert_eq!(cmnt.lines.len(), 1);
self.zerobreak();
self.word(cmnt.lines[0].clone());
if let Some((last, lines)) = cmnt.lines.split_last() {
self.ibox(0);

for line in lines {
self.word(line.clone());
self.hardbreak()
}

self.word(last.clone());
self.space();

self.end();
}
self.zerobreak()
}
comments::Isolated => {
Expand Down
1 change: 1 addition & 0 deletions src/librustc_error_codes/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ E0765: include_str!("./error_codes/E0765.md"),
E0766: include_str!("./error_codes/E0766.md"),
E0767: include_str!("./error_codes/E0767.md"),
E0768: include_str!("./error_codes/E0768.md"),
E0769: include_str!("./error_codes/E0769.md"),
;
// E0006, // merged with E0005
// E0008, // cannot bind by-move into a pattern guard
Expand Down
5 changes: 3 additions & 2 deletions src/librustc_error_codes/error_codes/E0704.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
This error indicates that a incorrect visibility restriction was specified.
An incorrect visibility restriction was specified.

Example of erroneous code:
Erroneous code example:

```compile_fail,E0704
mod foo {
Expand All @@ -12,6 +12,7 @@ mod foo {

To make struct `Bar` only visible in module `foo` the `in` keyword should be
used:

```
mod foo {
pub(in crate::foo) struct Bar {
Expand Down
39 changes: 39 additions & 0 deletions src/librustc_error_codes/error_codes/E0769.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
A tuple struct or tuple variant was used in a pattern as if it were a
struct or struct variant.

Erroneous code example:

```compile_fail,E0769
enum E {
A(i32),
}
let e = E::A(42);
match e {
E::A { number } => println!("{}", x),
}
```

To fix this error, you can use the tuple pattern:

```
# enum E {
# A(i32),
# }
# let e = E::A(42);
match e {
E::A(number) => println!("{}", number),
}
```

Alternatively, you can also use the struct pattern by using the correct
field names and binding them to new identifiers:

```
# enum E {
# A(i32),
# }
# let e = E::A(42);
match e {
E::A { 0: number } => println!("{}", number),
}
```
6 changes: 3 additions & 3 deletions src/librustc_middle/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -774,12 +774,12 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
(present_variants.next(), present_variants.next())
};
let present_first = match present_first {
present_first @ Some(_) => present_first,
Some(present_first) => present_first,
// Uninhabited because it has no variants, or only absent ones.
None if def.is_enum() => return tcx.layout_raw(param_env.and(tcx.types.never)),
// If it's a struct, still compute a layout so that we can still compute the
// field offsets.
None => Some(VariantIdx::new(0)),
None => VariantIdx::new(0),
};

let is_struct = !def.is_enum() ||
Expand All @@ -791,7 +791,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
// Struct, or univariant enum equivalent to a struct.
// (Typechecking will reject discriminant-sizing attrs.)

let v = present_first.unwrap();
let v = present_first;
let kind = if def.is_enum() || variants[v].is_empty() {
StructKind::AlwaysSized
} else {
Expand Down
1 change: 1 addition & 0 deletions src/librustc_typeck/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ rustc_attr = { path = "../librustc_attr" }
rustc_data_structures = { path = "../librustc_data_structures" }
rustc_errors = { path = "../librustc_errors" }
rustc_hir = { path = "../librustc_hir" }
rustc_hir_pretty = { path = "../librustc_hir_pretty" }
rustc_target = { path = "../librustc_target" }
rustc_session = { path = "../librustc_session" }
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
Expand Down
1 change: 1 addition & 0 deletions src/librustc_typeck/check/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
// Check for infer types because cases like `Option<{integer}>` would
// panic otherwise.
if !expr_ty.has_infer_types()
&& !ty.has_infer_types()
&& fcx.tcx.type_implements_trait((
from_trait,
ty,
Expand Down
Loading