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:
This commit is contained in:
commit
1ffb321477
@ -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
|
||||
```
|
||||
|
||||
|
@ -60,10 +60,10 @@
|
||||
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;
|
||||
|
@ -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(
|
||||
|
@ -1047,7 +1047,7 @@ fn emit_message_default(&mut self,
|
||||
}
|
||||
} else {
|
||||
buffer.prepend(0,
|
||||
&format!("{}:{}:{} - ",
|
||||
&format!("{}:{}:{}: ",
|
||||
loc.file.name,
|
||||
cm.doctest_offset_line(loc.line),
|
||||
loc.col.0 + 1),
|
||||
|
@ -721,8 +721,11 @@ fn check_pat_struct(&self,
|
||||
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,
|
||||
@ -847,7 +850,7 @@ fn check_struct_pat_fields(&self,
|
||||
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 {
|
||||
@ -865,6 +868,7 @@ fn check_struct_pat_fields(&self,
|
||||
|
||||
// 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.
|
||||
@ -880,6 +884,7 @@ fn check_struct_pat_fields(&self,
|
||||
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) => {
|
||||
@ -892,6 +897,7 @@ fn check_struct_pat_fields(&self,
|
||||
})
|
||||
.unwrap_or_else(|| {
|
||||
inexistent_fields.push((span, field.ident));
|
||||
no_field_errors = false;
|
||||
tcx.types.err
|
||||
})
|
||||
}
|
||||
@ -990,5 +996,6 @@ fn check_struct_pat_fields(&self,
|
||||
diag.emit();
|
||||
}
|
||||
}
|
||||
no_field_errors
|
||||
}
|
||||
}
|
||||
|
@ -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';
|
||||
@ -1995,6 +1995,9 @@
|
||||
|
||||
var wrapper = document.createElement('div');
|
||||
wrapper.className = 'toggle-wrapper';
|
||||
if (extraClass) {
|
||||
wrapper.className += ' ' + extraClass;
|
||||
}
|
||||
wrapper.appendChild(mainToggle);
|
||||
return wrapper;
|
||||
}
|
||||
@ -2023,10 +2026,13 @@
|
||||
}
|
||||
if (e.parentNode.id === "main") {
|
||||
var otherMessage;
|
||||
var extraClass;
|
||||
if (hasClass(e, "type-decl")) {
|
||||
otherMessage = ' Show 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");
|
||||
}
|
||||
|
@ -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 {
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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"))
|
||||
@ -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
|
||||
@ -907,7 +907,7 @@ unsafe fn copy_file_range(
|
||||
// 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),
|
||||
@ -915,6 +915,6 @@ unsafe fn copy_file_range(
|
||||
}
|
||||
}
|
||||
}
|
||||
set_permissions(to, perm)?;
|
||||
writer.set_permissions(perm)?;
|
||||
Ok(written)
|
||||
}
|
||||
|
@ -516,6 +516,7 @@ fn scan_optional_raw_name(&mut self) -> Option<ast::Name> {
|
||||
return None;
|
||||
}
|
||||
let start = self.pos;
|
||||
self.bump();
|
||||
while ident_continue(self.ch) {
|
||||
self.bump();
|
||||
}
|
||||
@ -1155,6 +1156,7 @@ fn next_token_inner(&mut self) -> Result<token::Token, ()> {
|
||||
}
|
||||
|
||||
let start = self.pos;
|
||||
self.bump();
|
||||
while ident_continue(self.ch) {
|
||||
self.bump();
|
||||
}
|
||||
@ -1300,11 +1302,7 @@ fn next_token_inner(&mut self) -> Result<token::Token, ()> {
|
||||
}
|
||||
'-' => {
|
||||
self.bump();
|
||||
match self.ch.unwrap_or('\x00') {
|
||||
_ => {
|
||||
Ok(token::LArrow)
|
||||
}
|
||||
}
|
||||
Ok(token::LArrow)
|
||||
}
|
||||
_ => {
|
||||
Ok(token::Lt)
|
||||
|
48
src/test/ui/issue-51102.rs
Normal file
48
src/test/ui/issue-51102.rs
Normal file
@ -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
src/test/ui/issue-51102.stderr
Normal file
24
src/test/ui/issue-51102.stderr
Normal file
@ -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`.
|
@ -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) {}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user