Skip to content

Commit

Permalink
Auto merge of #51257 - GuillaumeGomez:rollup, r=GuillaumeGomez
Browse files Browse the repository at this point in the history
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:
  • Loading branch information
bors committed May 31, 2018
2 parents 5342d40 + 7552c2e commit 1ffb321
Show file tree
Hide file tree
Showing 15 changed files with 133 additions and 42 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Read ["Installation"] from [The Book].
3. Build and install:

```sh
$ git submodule update --init --recursive --progress
$ ./x.py build && sudo ./x.py install
```

Expand Down
8 changes: 4 additions & 4 deletions src/libcore/char/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ use fmt::{self, Write};
use iter::FusedIterator;

// UTF-8 ranges and tags for encoding characters
const TAG_CONT: u8 = 0b1000_0000;
const TAG_TWO_B: u8 = 0b1100_0000;
const TAG_THREE_B: u8 = 0b1110_0000;
const TAG_FOUR_B: u8 = 0b1111_0000;
const TAG_CONT: u8 = 0b1000_0000;
const TAG_TWO_B: u8 = 0b1100_0000;
const TAG_THREE_B: u8 = 0b1110_0000;
const TAG_FOUR_B: u8 = 0b1111_0000;
const MAX_ONE_B: u32 = 0x80;
const MAX_TWO_B: u32 = 0x800;
const MAX_THREE_B: u32 = 0x10000;
Expand Down
14 changes: 1 addition & 13 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1799,19 +1799,7 @@ pub fn build_session_options_and_crate_config(
Some("human") => ErrorOutputType::HumanReadable(color),
Some("json") => ErrorOutputType::Json(false),
Some("pretty-json") => ErrorOutputType::Json(true),
Some("short") => {
if nightly_options::is_unstable_enabled(matches) {
ErrorOutputType::Short(color)
} else {
early_error(
ErrorOutputType::default(),
&format!(
"the `-Z unstable-options` flag must also be passed to \
enable the short error message option"
),
);
}
}
Some("short") => ErrorOutputType::Short(color),
None => ErrorOutputType::HumanReadable(color),

Some(arg) => early_error(
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_errors/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,7 @@ impl EmitterWriter {
}
} else {
buffer.prepend(0,
&format!("{}:{}:{} - ",
&format!("{}:{}:{}: ",
loc.file.name,
cm.doctest_offset_line(loc.line),
loc.col.0 + 1),
Expand Down
13 changes: 10 additions & 3 deletions src/librustc_typeck/check/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -721,8 +721,11 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
self.demand_eqtype(pat.span, expected, pat_ty);

// Type check subpatterns.
self.check_struct_pat_fields(pat_ty, pat.id, pat.span, variant, fields, etc, def_bm);
pat_ty
if self.check_struct_pat_fields(pat_ty, pat.id, pat.span, variant, fields, etc, def_bm) {
pat_ty
} else {
self.tcx.types.err
}
}

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

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

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

let mut inexistent_fields = vec![];
// Typecheck each field.
Expand All @@ -880,6 +884,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
format!("multiple uses of `{}` in pattern", field.ident))
.span_label(*occupied.get(), format!("first use of `{}`", field.ident))
.emit();
no_field_errors = false;
tcx.types.err
}
Vacant(vacant) => {
Expand All @@ -892,6 +897,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
})
.unwrap_or_else(|| {
inexistent_fields.push((span, field.ident));
no_field_errors = false;
tcx.types.err
})
}
Expand Down Expand Up @@ -990,5 +996,6 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
diag.emit();
}
}
no_field_errors
}
}
10 changes: 8 additions & 2 deletions src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1979,7 +1979,7 @@
onEach(e.getElementsByClassName('associatedconstant'), func);
});

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

var wrapper = document.createElement('div');
wrapper.className = 'toggle-wrapper';
if (extraClass) {
wrapper.className += ' ' + extraClass;
}
wrapper.appendChild(mainToggle);
return wrapper;
}
Expand Down Expand Up @@ -2023,10 +2026,13 @@
}
if (e.parentNode.id === "main") {
var otherMessage;
var extraClass;
if (hasClass(e, "type-decl")) {
otherMessage = '&nbsp;Show&nbsp;declaration';
} else if (hasClass(e.childNodes[0], "impl-items")) {
extraClass = "marg-left";
}
e.parentNode.insertBefore(createToggle(otherMessage), e);
e.parentNode.insertBefore(createToggle(otherMessage, extraClass), e);
if (otherMessage && getCurrentValue('rustdoc-item-declarations') !== "false") {
collapseDocs(e.previousSibling.childNodes[0], "toggle");
}
Expand Down
23 changes: 21 additions & 2 deletions src/librustdoc/html/static/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -474,11 +474,30 @@ h4 > code, h3 > code, .invisible > code {
margin-bottom: 15px;
}

.content .impl-items .method, .content .impl-items > .type, .impl-items > .associatedconstant {
margin-left: 20px;
}
.content .impl-items .docblock, .content .impl-items .stability {
margin-bottom: .6em;
}
.content .impl-items .method, .content .impl-items > .type, .impl-items > .associatedconstant {
.content .docblock > .impl-items {
margin-left: 20px;
margin-top: -34px;
}
.content .docblock > .impl-items > h4 {
border-bottom: 0;
}
.content .docblock >.impl-items .table-display {
margin: 0;
}
.content .docblock >.impl-items table td {
padding: 0;
}
.toggle-wrapper.marg-left > .collapse-toggle {
left: -24px;
}
.content .docblock > .impl-items .table-display, .impl-items table td {
border: none;
}

.content .stability code {
Expand Down Expand Up @@ -542,7 +561,7 @@ a {
content: '\2002\00a7\2002';
}

.docblock a:hover, .docblock-short a:hover, .stability a {
.docblock a:not(.srclink):hover, .docblock-short a:not(.srclink):hover, .stability a {
text-decoration: underline;
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/html/static/themes/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.t
background: rgba(0, 0, 0, 0);
}

.docblock code, .docblock-short code {
.docblock p > code, .docblock-short p > code {
background-color: #2A2A2A;
}
pre {
Expand Down Expand Up @@ -163,7 +163,7 @@ a {
color: #ddd;
}

.docblock a, .docblock-short a, .stability a {
.docblock a:not(.srclink), .docblock-short a:not(.srclink), .stability a {
color: #D2991D;
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/html/static/themes/light.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.t
background: rgba(0, 0, 0, 0);
}

.docblock code, .docblock-short code {
.docblock p > code, .docblock-short p > code {
background-color: #F5F5F5;
}
pre {
Expand Down Expand Up @@ -163,7 +163,7 @@ a {
color: #000;
}

.docblock a, .docblock-short a, .stability a {
.docblock a:not(.srclink), .docblock-short a:not(.srclink), .stability a {
color: #3873AD;
}

Expand Down
10 changes: 5 additions & 5 deletions src/libstd/sys/unix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ pub fn canonicalize(p: &Path) -> io::Result<PathBuf> {

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

let ret = io::copy(&mut reader, &mut writer)?;
set_permissions(to, perm)?;
writer.set_permissions(perm)?;
Ok(ret)
}

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

// Kernel prior to 4.5 don't have copy_file_range
Expand Down Expand Up @@ -907,14 +907,14 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
// Try again with fallback method
assert_eq!(written, 0);
let ret = io::copy(&mut reader, &mut writer)?;
set_permissions(to, perm)?;
writer.set_permissions(perm)?;
return Ok(ret)
},
_ => return Err(err),
}
}
}
}
set_permissions(to, perm)?;
writer.set_permissions(perm)?;
Ok(written)
}
8 changes: 3 additions & 5 deletions src/libsyntax/parse/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ impl<'a> StringReader<'a> {
return None;
}
let start = self.pos;
self.bump();
while ident_continue(self.ch) {
self.bump();
}
Expand Down Expand Up @@ -1155,6 +1156,7 @@ impl<'a> StringReader<'a> {
}

let start = self.pos;
self.bump();
while ident_continue(self.ch) {
self.bump();
}
Expand Down Expand Up @@ -1300,11 +1302,7 @@ impl<'a> StringReader<'a> {
}
'-' => {
self.bump();
match self.ch.unwrap_or('\x00') {
_ => {
Ok(token::LArrow)
}
}
Ok(token::LArrow)
}
_ => {
Ok(token::Lt)
Expand Down
48 changes: 48 additions & 0 deletions src/test/ui/issue-51102.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

enum SimpleEnum {
NoState,
}

struct SimpleStruct {
no_state_here: u64,
}

fn main() {
let _ = |simple| {
match simple {
SimpleStruct {
state: 0,
//~^ struct `SimpleStruct` does not have a field named `state` [E0026]
..
} => (),
}
};

let _ = |simple| {
match simple {
SimpleStruct {
no_state_here: 0,
no_state_here: 1
//~^ ERROR field `no_state_here` bound multiple times in the pattern [E0025]
} => (),
}
};

let _ = |simple| {
match simple {
SimpleEnum::NoState {
state: 0
//~^ ERROR variant `SimpleEnum::NoState` does not have a field named `state` [E0026]
} => (),
}
};
}
24 changes: 24 additions & 0 deletions src/test/ui/issue-51102.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
error[E0026]: struct `SimpleStruct` does not have a field named `state`
--> $DIR/issue-51102.rs:23:17
|
LL | state: 0,
| ^^^^^^^^ struct `SimpleStruct` does not have this field

error[E0025]: field `no_state_here` bound multiple times in the pattern
--> $DIR/issue-51102.rs:34:17
|
LL | no_state_here: 0,
| ---------------- first use of `no_state_here`
LL | no_state_here: 1
| ^^^^^^^^^^^^^^^^ multiple uses of `no_state_here` in pattern

error[E0026]: variant `SimpleEnum::NoState` does not have a field named `state`
--> $DIR/issue-51102.rs:43:17
|
LL | state: 0
| ^^^^^^^^ variant `SimpleEnum::NoState` does not have this field

error: aborting due to 3 previous errors

Some errors occurred: E0025, E0026.
For more information about an error, try `rustc --explain E0025`.
2 changes: 1 addition & 1 deletion src/test/ui/short-error-format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: --error-format=short -Zunstable-options
// compile-flags: --error-format=short

fn foo(_: u32) {}

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/short-error-format.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
$DIR/short-error-format.rs:16:9 - error[E0308]: mismatched types
$DIR/short-error-format.rs:18:7 - error[E0599]: no method named `salut` found for type `u32` in the current scope
$DIR/short-error-format.rs:16:9: error[E0308]: mismatched types
$DIR/short-error-format.rs:18:7: error[E0599]: no method named `salut` found for type `u32` in the current scope
error: aborting due to 2 previous errors

0 comments on commit 1ffb321

Please sign in to comment.