Skip to content

Commit 1ffb321

Browse files
committed
Auto merge of #51257 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 7 pull requests Successful merges: - #49546 (Stabilize short error format) - #51123 (Update build instructions) - #51146 (typeck: Do not pass the field check on field error) - #51193 (Fixes some style issues in rustdoc "implementations on Foreign types") - #51213 (fs: copy: Use File::set_permissions instead of fs::set_permissions) - #51227 (mod.rs isn't beautiful) - #51240 (Two minor parsing tweaks) Failed merges:
2 parents 5342d40 + 7552c2e commit 1ffb321

File tree

15 files changed

+133
-42
lines changed

15 files changed

+133
-42
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Read ["Installation"] from [The Book].
3838
3. Build and install:
3939

4040
```sh
41+
$ git submodule update --init --recursive --progress
4142
$ ./x.py build && sudo ./x.py install
4243
```
4344

src/libcore/char/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ use fmt::{self, Write};
6060
use iter::FusedIterator;
6161

6262
// UTF-8 ranges and tags for encoding characters
63-
const TAG_CONT: u8 = 0b1000_0000;
64-
const TAG_TWO_B: u8 = 0b1100_0000;
65-
const TAG_THREE_B: u8 = 0b1110_0000;
66-
const TAG_FOUR_B: u8 = 0b1111_0000;
63+
const TAG_CONT: u8 = 0b1000_0000;
64+
const TAG_TWO_B: u8 = 0b1100_0000;
65+
const TAG_THREE_B: u8 = 0b1110_0000;
66+
const TAG_FOUR_B: u8 = 0b1111_0000;
6767
const MAX_ONE_B: u32 = 0x80;
6868
const MAX_TWO_B: u32 = 0x800;
6969
const MAX_THREE_B: u32 = 0x10000;

src/librustc/session/config.rs

+1-13
Original file line numberDiff line numberDiff line change
@@ -1799,19 +1799,7 @@ pub fn build_session_options_and_crate_config(
17991799
Some("human") => ErrorOutputType::HumanReadable(color),
18001800
Some("json") => ErrorOutputType::Json(false),
18011801
Some("pretty-json") => ErrorOutputType::Json(true),
1802-
Some("short") => {
1803-
if nightly_options::is_unstable_enabled(matches) {
1804-
ErrorOutputType::Short(color)
1805-
} else {
1806-
early_error(
1807-
ErrorOutputType::default(),
1808-
&format!(
1809-
"the `-Z unstable-options` flag must also be passed to \
1810-
enable the short error message option"
1811-
),
1812-
);
1813-
}
1814-
}
1802+
Some("short") => ErrorOutputType::Short(color),
18151803
None => ErrorOutputType::HumanReadable(color),
18161804

18171805
Some(arg) => early_error(

src/librustc_errors/emitter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,7 @@ impl EmitterWriter {
10471047
}
10481048
} else {
10491049
buffer.prepend(0,
1050-
&format!("{}:{}:{} - ",
1050+
&format!("{}:{}:{}: ",
10511051
loc.file.name,
10521052
cm.doctest_offset_line(loc.line),
10531053
loc.col.0 + 1),

src/librustc_typeck/check/_match.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -721,8 +721,11 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
721721
self.demand_eqtype(pat.span, expected, pat_ty);
722722

723723
// Type check subpatterns.
724-
self.check_struct_pat_fields(pat_ty, pat.id, pat.span, variant, fields, etc, def_bm);
725-
pat_ty
724+
if self.check_struct_pat_fields(pat_ty, pat.id, pat.span, variant, fields, etc, def_bm) {
725+
pat_ty
726+
} else {
727+
self.tcx.types.err
728+
}
726729
}
727730

728731
fn check_pat_path(&self,
@@ -847,7 +850,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
847850
variant: &'tcx ty::VariantDef,
848851
fields: &'gcx [Spanned<hir::FieldPat>],
849852
etc: bool,
850-
def_bm: ty::BindingMode) {
853+
def_bm: ty::BindingMode) -> bool {
851854
let tcx = self.tcx;
852855

853856
let (substs, adt) = match adt_ty.sty {
@@ -865,6 +868,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
865868

866869
// Keep track of which fields have already appeared in the pattern.
867870
let mut used_fields = FxHashMap();
871+
let mut no_field_errors = true;
868872

869873
let mut inexistent_fields = vec![];
870874
// Typecheck each field.
@@ -880,6 +884,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
880884
format!("multiple uses of `{}` in pattern", field.ident))
881885
.span_label(*occupied.get(), format!("first use of `{}`", field.ident))
882886
.emit();
887+
no_field_errors = false;
883888
tcx.types.err
884889
}
885890
Vacant(vacant) => {
@@ -892,6 +897,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
892897
})
893898
.unwrap_or_else(|| {
894899
inexistent_fields.push((span, field.ident));
900+
no_field_errors = false;
895901
tcx.types.err
896902
})
897903
}
@@ -990,5 +996,6 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
990996
diag.emit();
991997
}
992998
}
999+
no_field_errors
9931000
}
9941001
}

src/librustdoc/html/static/main.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -1979,7 +1979,7 @@
19791979
onEach(e.getElementsByClassName('associatedconstant'), func);
19801980
});
19811981

1982-
function createToggle(otherMessage) {
1982+
function createToggle(otherMessage, extraClass) {
19831983
var span = document.createElement('span');
19841984
span.className = 'toggle-label';
19851985
span.style.display = 'none';
@@ -1995,6 +1995,9 @@
19951995

19961996
var wrapper = document.createElement('div');
19971997
wrapper.className = 'toggle-wrapper';
1998+
if (extraClass) {
1999+
wrapper.className += ' ' + extraClass;
2000+
}
19982001
wrapper.appendChild(mainToggle);
19992002
return wrapper;
20002003
}
@@ -2023,10 +2026,13 @@
20232026
}
20242027
if (e.parentNode.id === "main") {
20252028
var otherMessage;
2029+
var extraClass;
20262030
if (hasClass(e, "type-decl")) {
20272031
otherMessage = '&nbsp;Show&nbsp;declaration';
2032+
} else if (hasClass(e.childNodes[0], "impl-items")) {
2033+
extraClass = "marg-left";
20282034
}
2029-
e.parentNode.insertBefore(createToggle(otherMessage), e);
2035+
e.parentNode.insertBefore(createToggle(otherMessage, extraClass), e);
20302036
if (otherMessage && getCurrentValue('rustdoc-item-declarations') !== "false") {
20312037
collapseDocs(e.previousSibling.childNodes[0], "toggle");
20322038
}

src/librustdoc/html/static/rustdoc.css

+21-2
Original file line numberDiff line numberDiff line change
@@ -474,11 +474,30 @@ h4 > code, h3 > code, .invisible > code {
474474
margin-bottom: 15px;
475475
}
476476

477+
.content .impl-items .method, .content .impl-items > .type, .impl-items > .associatedconstant {
478+
margin-left: 20px;
479+
}
477480
.content .impl-items .docblock, .content .impl-items .stability {
478481
margin-bottom: .6em;
479482
}
480-
.content .impl-items .method, .content .impl-items > .type, .impl-items > .associatedconstant {
483+
.content .docblock > .impl-items {
481484
margin-left: 20px;
485+
margin-top: -34px;
486+
}
487+
.content .docblock > .impl-items > h4 {
488+
border-bottom: 0;
489+
}
490+
.content .docblock >.impl-items .table-display {
491+
margin: 0;
492+
}
493+
.content .docblock >.impl-items table td {
494+
padding: 0;
495+
}
496+
.toggle-wrapper.marg-left > .collapse-toggle {
497+
left: -24px;
498+
}
499+
.content .docblock > .impl-items .table-display, .impl-items table td {
500+
border: none;
482501
}
483502

484503
.content .stability code {
@@ -542,7 +561,7 @@ a {
542561
content: '\2002\00a7\2002';
543562
}
544563

545-
.docblock a:hover, .docblock-short a:hover, .stability a {
564+
.docblock a:not(.srclink):hover, .docblock-short a:not(.srclink):hover, .stability a {
546565
text-decoration: underline;
547566
}
548567

src/librustdoc/html/static/themes/dark.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.t
3333
background: rgba(0, 0, 0, 0);
3434
}
3535

36-
.docblock code, .docblock-short code {
36+
.docblock p > code, .docblock-short p > code {
3737
background-color: #2A2A2A;
3838
}
3939
pre {
@@ -163,7 +163,7 @@ a {
163163
color: #ddd;
164164
}
165165

166-
.docblock a, .docblock-short a, .stability a {
166+
.docblock a:not(.srclink), .docblock-short a:not(.srclink), .stability a {
167167
color: #D2991D;
168168
}
169169

src/librustdoc/html/static/themes/light.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.t
3535
background: rgba(0, 0, 0, 0);
3636
}
3737

38-
.docblock code, .docblock-short code {
38+
.docblock p > code, .docblock-short p > code {
3939
background-color: #F5F5F5;
4040
}
4141
pre {
@@ -163,7 +163,7 @@ a {
163163
color: #000;
164164
}
165165

166-
.docblock a, .docblock-short a, .stability a {
166+
.docblock a:not(.srclink), .docblock-short a:not(.srclink), .stability a {
167167
color: #3873AD;
168168
}
169169

src/libstd/sys/unix/fs.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ pub fn canonicalize(p: &Path) -> io::Result<PathBuf> {
817817

818818
#[cfg(not(any(target_os = "linux", target_os = "android")))]
819819
pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
820-
use fs::{File, set_permissions};
820+
use fs::File;
821821
if !from.is_file() {
822822
return Err(Error::new(ErrorKind::InvalidInput,
823823
"the source path is not an existing regular file"))
@@ -828,14 +828,14 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
828828
let perm = reader.metadata()?.permissions();
829829

830830
let ret = io::copy(&mut reader, &mut writer)?;
831-
set_permissions(to, perm)?;
831+
writer.set_permissions(perm)?;
832832
Ok(ret)
833833
}
834834

835835
#[cfg(any(target_os = "linux", target_os = "android"))]
836836
pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
837837
use cmp;
838-
use fs::{File, set_permissions};
838+
use fs::File;
839839
use sync::atomic::{AtomicBool, Ordering};
840840

841841
// Kernel prior to 4.5 don't have copy_file_range
@@ -907,14 +907,14 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
907907
// Try again with fallback method
908908
assert_eq!(written, 0);
909909
let ret = io::copy(&mut reader, &mut writer)?;
910-
set_permissions(to, perm)?;
910+
writer.set_permissions(perm)?;
911911
return Ok(ret)
912912
},
913913
_ => return Err(err),
914914
}
915915
}
916916
}
917917
}
918-
set_permissions(to, perm)?;
918+
writer.set_permissions(perm)?;
919919
Ok(written)
920920
}

src/libsyntax/parse/lexer/mod.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@ impl<'a> StringReader<'a> {
516516
return None;
517517
}
518518
let start = self.pos;
519+
self.bump();
519520
while ident_continue(self.ch) {
520521
self.bump();
521522
}
@@ -1155,6 +1156,7 @@ impl<'a> StringReader<'a> {
11551156
}
11561157

11571158
let start = self.pos;
1159+
self.bump();
11581160
while ident_continue(self.ch) {
11591161
self.bump();
11601162
}
@@ -1300,11 +1302,7 @@ impl<'a> StringReader<'a> {
13001302
}
13011303
'-' => {
13021304
self.bump();
1303-
match self.ch.unwrap_or('\x00') {
1304-
_ => {
1305-
Ok(token::LArrow)
1306-
}
1307-
}
1305+
Ok(token::LArrow)
13081306
}
13091307
_ => {
13101308
Ok(token::Lt)

src/test/ui/issue-51102.rs

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
enum SimpleEnum {
12+
NoState,
13+
}
14+
15+
struct SimpleStruct {
16+
no_state_here: u64,
17+
}
18+
19+
fn main() {
20+
let _ = |simple| {
21+
match simple {
22+
SimpleStruct {
23+
state: 0,
24+
//~^ struct `SimpleStruct` does not have a field named `state` [E0026]
25+
..
26+
} => (),
27+
}
28+
};
29+
30+
let _ = |simple| {
31+
match simple {
32+
SimpleStruct {
33+
no_state_here: 0,
34+
no_state_here: 1
35+
//~^ ERROR field `no_state_here` bound multiple times in the pattern [E0025]
36+
} => (),
37+
}
38+
};
39+
40+
let _ = |simple| {
41+
match simple {
42+
SimpleEnum::NoState {
43+
state: 0
44+
//~^ ERROR variant `SimpleEnum::NoState` does not have a field named `state` [E0026]
45+
} => (),
46+
}
47+
};
48+
}

src/test/ui/issue-51102.stderr

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
error[E0026]: struct `SimpleStruct` does not have a field named `state`
2+
--> $DIR/issue-51102.rs:23:17
3+
|
4+
LL | state: 0,
5+
| ^^^^^^^^ struct `SimpleStruct` does not have this field
6+
7+
error[E0025]: field `no_state_here` bound multiple times in the pattern
8+
--> $DIR/issue-51102.rs:34:17
9+
|
10+
LL | no_state_here: 0,
11+
| ---------------- first use of `no_state_here`
12+
LL | no_state_here: 1
13+
| ^^^^^^^^^^^^^^^^ multiple uses of `no_state_here` in pattern
14+
15+
error[E0026]: variant `SimpleEnum::NoState` does not have a field named `state`
16+
--> $DIR/issue-51102.rs:43:17
17+
|
18+
LL | state: 0
19+
| ^^^^^^^^ variant `SimpleEnum::NoState` does not have this field
20+
21+
error: aborting due to 3 previous errors
22+
23+
Some errors occurred: E0025, E0026.
24+
For more information about an error, try `rustc --explain E0025`.

src/test/ui/short-error-format.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// compile-flags: --error-format=short -Zunstable-options
11+
// compile-flags: --error-format=short
1212

1313
fn foo(_: u32) {}
1414

src/test/ui/short-error-format.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
$DIR/short-error-format.rs:16:9 - error[E0308]: mismatched types
2-
$DIR/short-error-format.rs:18:7 - error[E0599]: no method named `salut` found for type `u32` in the current scope
1+
$DIR/short-error-format.rs:16:9: error[E0308]: mismatched types
2+
$DIR/short-error-format.rs:18:7: error[E0599]: no method named `salut` found for type `u32` in the current scope
33
error: aborting due to 2 previous errors

0 commit comments

Comments
 (0)