Skip to content

Commit

Permalink
Auto merge of #42690 - frewsxcv:rollup, r=frewsxcv
Browse files Browse the repository at this point in the history
Rollup of 5 pull requests

- Successful merges: #42616, #42651, #42654, #42656, #42685
- Failed merges:
  • Loading branch information
bors committed Jun 16, 2017
2 parents 44eeb21 + f5f74a2 commit 4581e89
Show file tree
Hide file tree
Showing 14 changed files with 125 additions and 71 deletions.
29 changes: 27 additions & 2 deletions src/bootstrap/step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules {
rules.test("check-linkchecker", "src/tools/linkchecker")
.dep(|s| s.name("tool-linkchecker").stage(0))
.dep(|s| s.name("default:doc"))
.default(true)
.default(build.config.docs)
.host(true)
.run(move |s| check::linkcheck(build, s.target));
rules.test("check-cargotest", "src/tools/cargotest")
Expand Down Expand Up @@ -1407,13 +1407,20 @@ mod tests {
fn build(args: &[&str],
extra_host: &[&str],
extra_target: &[&str]) -> Build {
build_(args, extra_host, extra_target, true)
}

fn build_(args: &[&str],
extra_host: &[&str],
extra_target: &[&str],
docs: bool) -> Build {
let mut args = args.iter().map(|s| s.to_string()).collect::<Vec<_>>();
args.push("--build".to_string());
args.push("A".to_string());
let flags = Flags::parse(&args);

let mut config = Config::default();
config.docs = true;
config.docs = docs;
config.build = "A".to_string();
config.host = vec![config.build.clone()];
config.host.extend(extra_host.iter().map(|s| s.to_string()));
Expand Down Expand Up @@ -1768,4 +1775,22 @@ mod tests {
assert!(!plan.iter().any(|s| s.name.contains("tidy")));
assert!(plan.iter().any(|s| s.name.contains("valgrind")));
}

#[test]
fn test_disable_docs() {
let build = build_(&["test"], &[], &[], false);
let rules = super::build_rules(&build);
let plan = rules.plan();
println!("rules: {:#?}", plan);
assert!(!plan.iter().any(|s| {
s.name.contains("doc-") || s.name.contains("default:doc")
}));
// none of the dependencies should be a doc rule either
assert!(!plan.iter().any(|s| {
rules.rules[s.name].deps.iter().any(|dep| {
let dep = dep(&rules.sbuild.name(s.name));
dep.name.contains("doc-") || dep.name.contains("default:doc")
})
}));
}
}
1 change: 0 additions & 1 deletion src/doc/unstable-book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
- [start](language-features/start.md)
- [static_nobundle](language-features/static-nobundle.md)
- [stmt_expr_attributes](language-features/stmt-expr-attributes.md)
- [struct_field_attributes](language-features/struct-field-attributes.md)
- [structural_match](language-features/structural-match.md)
- [target_feature](language-features/target-feature.md)
- [thread_local](language-features/thread-local.md)
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion src/librustc_data_structures/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
#![feature(discriminant_value)]
#![feature(specialization)]
#![feature(manually_drop)]
#![feature(struct_field_attributes)]

#![cfg_attr(stage0, unstable(feature = "rustc_private", issue = "27812"))]
#![cfg_attr(stage0, feature(rustc_private))]
#![cfg_attr(stage0, feature(staged_api))]
#![cfg_attr(stage0, feature(struct_field_attributes))]

#![cfg_attr(unix, feature(libc))]
#![cfg_attr(test, feature(test))]
Expand Down
7 changes: 5 additions & 2 deletions src/librustc_errors/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,11 @@ impl EmitterWriter {
&& next.has_label()) // multiline start/end, move it to a new line
|| (annotation.has_label() // so as not to overlap the orizontal lines.
&& next.takes_space())
|| (annotation.takes_space()
&& next.takes_space())
|| (annotation.takes_space() && next.takes_space())
|| (overlaps(next, annotation, l)
&& next.end_col <= annotation.end_col
&& next.has_label()
&& p == 0) // Avoid #42595.
{
// This annotation needs a new line in the output.
p += 1;
Expand Down
21 changes: 10 additions & 11 deletions src/librustc_typeck/check/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use super::method::MethodCallee;
use hir::def::Def;
use hir::def_id::{DefId, LOCAL_CRATE};
use rustc::{infer, traits};
use rustc::ty::{self, TyCtxt, LvaluePreference, Ty};
use rustc::ty::{self, TyCtxt, TypeFoldable, LvaluePreference, Ty};
use rustc::ty::subst::Subst;
use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow};
use syntax::abi;
Expand Down Expand Up @@ -209,17 +209,16 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
}
}
}
let mut err = if let Some(path) = unit_variant {
let mut err = self.type_error_struct(call_expr.span, |_| {
format!("`{}` is being called, but it is not a function", path)
}, callee_ty);
let mut err = type_error_struct!(self.tcx.sess, call_expr.span, callee_ty, E0618,
"expected function, found `{}`",
if let Some(ref path) = unit_variant {
path.to_string()
} else {
callee_ty.to_string()
});
if let Some(path) = unit_variant {
err.help(&format!("did you mean to write `{}`?", path));
err
} else {
self.type_error_struct(call_expr.span, |actual| {
format!("expected function, found `{}`", actual)
}, callee_ty)
};
}

if let hir::ExprCall(ref expr, _) = call_expr.node {
let def = if let hir::ExprPath(ref qpath) = expr.node {
Expand Down
28 changes: 28 additions & 0 deletions src/librustc_typeck/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4195,6 +4195,34 @@ as possible. For better explanations, see The Rust Book:
https://doc.rust-lang.org/book/
"##,

E0618: r##"
Attempted to call something which isn't a function nor a method.
Erroneous code examples:
```compile_fail,E0618
enum X {
Entry,
}
X::Entry(); // error: expected function, found `X::Entry`
// Or even simpler:
let x = 0i32;
x(); // error: expected function, found `i32`
```
Only functions and methods can be called using `()`. Example:
```
// We declare a function:
fn i_am_a_function() {}
// And we call it:
i_am_a_function();
```
"##,

}

register_diagnostics! {
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ fn read_to_end<R: Read + ?Sized>(r: &mut R, buf: &mut Vec<u8>) -> Result<usize>

/// The `Read` trait allows for reading bytes from a source.
///
/// Implementors of the `Read` trait are sometimes called 'readers'.
/// Implementors of the `Read` trait are called 'readers'.
///
/// Readers are defined by one required method, `read()`. Each call to `read`
/// will attempt to pull bytes from this source into a provided buffer. A
Expand Down
28 changes: 0 additions & 28 deletions src/libsyntax/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ impl<'a> StripUnconfigured<'a> {
ast::ExprKind::Struct(path, fields, base) => {
let fields = fields.into_iter()
.filter_map(|field| {
self.visit_struct_field_attrs(field.attrs());
self.configure(field)
})
.collect();
Expand Down Expand Up @@ -256,17 +255,6 @@ impl<'a> StripUnconfigured<'a> {
}

pub fn configure_struct_expr_field(&mut self, field: ast::Field) -> Option<ast::Field> {
if !self.features.map(|features| features.struct_field_attributes).unwrap_or(true) {
if !field.attrs.is_empty() {
let mut err = feature_err(self.sess,
"struct_field_attributes",
field.span,
GateIssue::Language,
"attributes on struct literal fields are unstable");
err.emit();
}
}

self.configure(field)
}

Expand All @@ -275,7 +263,6 @@ impl<'a> StripUnconfigured<'a> {
if let ast::PatKind::Struct(path, fields, etc) = pattern.node {
let fields = fields.into_iter()
.filter_map(|field| {
self.visit_struct_field_attrs(field.attrs());
self.configure(field)
})
.collect();
Expand All @@ -284,21 +271,6 @@ impl<'a> StripUnconfigured<'a> {
pattern
})
}

fn visit_struct_field_attrs(&mut self, attrs: &[ast::Attribute]) {
// flag the offending attributes
for attr in attrs.iter() {
if !self.features.map(|features| features.struct_field_attributes).unwrap_or(true) {
let mut err = feature_err(
self.sess,
"struct_field_attributes",
attr.span,
GateIssue::Language,
"attributes on struct pattern or literal fields are unstable");
err.emit();
}
}
}
}

impl<'a> fold::Folder for StripUnconfigured<'a> {
Expand Down
5 changes: 2 additions & 3 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,6 @@ declare_features! (
// Declarative macros 2.0 (`macro`).
(active, decl_macro, "1.17.0", Some(39412)),

// Allows attributes on struct literal fields.
(active, struct_field_attributes, "1.16.0", Some(38814)),

// Allows #[link(kind="static-nobundle"...]
(active, static_nobundle, "1.16.0", Some(37403)),

Expand Down Expand Up @@ -430,6 +427,8 @@ declare_features! (
(accepted, relaxed_adts, "1.19.0", Some(35626)),
// Coerces non capturing closures to function pointers
(accepted, closure_to_fn_coercion, "1.19.0", Some(39817)),
// Allows attributes on struct literal fields.
(accepted, struct_field_attributes, "1.20.0", Some(38814)),
);

// If you change this, please modify src/doc/unstable-book as well. You must
Expand Down
43 changes: 43 additions & 0 deletions src/libsyntax/test_snippet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,49 @@ error: foo
"#);
}

#[test]
fn multiple_labels_secondary_without_message_3() {
test_harness(r#"
fn foo() {
a bc d
}
"#,
vec![
SpanLabel {
start: Position {
string: "a",
count: 1,
},
end: Position {
string: "b",
count: 1,
},
label: "`a` is a good letter",
},
SpanLabel {
start: Position {
string: "c",
count: 1,
},
end: Position {
string: "d",
count: 1,
},
label: "",
},
],
r#"
error: foo
--> test.rs:3:3
|
3 | a bc d
| ^^^^----
| |
| `a` is a good letter
"#);
}

#[test]
fn multiple_labels_without_message() {
test_harness(r#"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// gate-test-struct_field_attributes

struct Foo {
present: (),
enum X {
Entry,
}

fn main() {
let foo = Foo { #[cfg(all())] present: () };
//~^ ERROR attributes on struct pattern or literal fields are unstable
let Foo { #[cfg(all())] present: () } = foo;
//~^ ERROR attributes on struct pattern or literal fields are unstable
X::Entry(); //~ ERROR expected function, found `X::Entry` [E0618]
//~| HELP did you mean to write `X::Entry`?
let x = 0i32;
x(); //~ ERROR expected function, found `i32` [E0618]
}
4 changes: 2 additions & 2 deletions src/test/compile-fail/empty-struct-unit-expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ enum E {
fn main() {
let e2 = Empty2(); //~ ERROR expected function, found `Empty2`
let e4 = E::Empty4();
//~^ ERROR `E::Empty4` is being called, but it is not a function
//~^ ERROR expected function, found `E::Empty4` [E0618]
//~| HELP did you mean to write `E::Empty4`?
let xe2 = XEmpty2(); //~ ERROR expected function, found `empty_struct::XEmpty2`
let xe4 = XE::XEmpty4();
//~^ ERROR `XE::XEmpty4` is being called, but it is not a function
//~^ ERROR expected function, found `XE::XEmpty4` [E0618]
//~| HELP did you mean to write `XE::XEmpty4`?
}
2 changes: 0 additions & 2 deletions src/test/compile-fail/struct-field-cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(struct_field_attributes)]

struct Foo {
present: (),
}
Expand Down

0 comments on commit 4581e89

Please sign in to comment.