Skip to content

Commit 4581e89

Browse files
committed
Auto merge of #42690 - frewsxcv:rollup, r=frewsxcv
Rollup of 5 pull requests - Successful merges: #42616, #42651, #42654, #42656, #42685 - Failed merges:
2 parents 44eeb21 + f5f74a2 commit 4581e89

File tree

14 files changed

+125
-71
lines changed

14 files changed

+125
-71
lines changed

src/bootstrap/step.rs

+27-2
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules {
463463
rules.test("check-linkchecker", "src/tools/linkchecker")
464464
.dep(|s| s.name("tool-linkchecker").stage(0))
465465
.dep(|s| s.name("default:doc"))
466-
.default(true)
466+
.default(build.config.docs)
467467
.host(true)
468468
.run(move |s| check::linkcheck(build, s.target));
469469
rules.test("check-cargotest", "src/tools/cargotest")
@@ -1407,13 +1407,20 @@ mod tests {
14071407
fn build(args: &[&str],
14081408
extra_host: &[&str],
14091409
extra_target: &[&str]) -> Build {
1410+
build_(args, extra_host, extra_target, true)
1411+
}
1412+
1413+
fn build_(args: &[&str],
1414+
extra_host: &[&str],
1415+
extra_target: &[&str],
1416+
docs: bool) -> Build {
14101417
let mut args = args.iter().map(|s| s.to_string()).collect::<Vec<_>>();
14111418
args.push("--build".to_string());
14121419
args.push("A".to_string());
14131420
let flags = Flags::parse(&args);
14141421

14151422
let mut config = Config::default();
1416-
config.docs = true;
1423+
config.docs = docs;
14171424
config.build = "A".to_string();
14181425
config.host = vec![config.build.clone()];
14191426
config.host.extend(extra_host.iter().map(|s| s.to_string()));
@@ -1768,4 +1775,22 @@ mod tests {
17681775
assert!(!plan.iter().any(|s| s.name.contains("tidy")));
17691776
assert!(plan.iter().any(|s| s.name.contains("valgrind")));
17701777
}
1778+
1779+
#[test]
1780+
fn test_disable_docs() {
1781+
let build = build_(&["test"], &[], &[], false);
1782+
let rules = super::build_rules(&build);
1783+
let plan = rules.plan();
1784+
println!("rules: {:#?}", plan);
1785+
assert!(!plan.iter().any(|s| {
1786+
s.name.contains("doc-") || s.name.contains("default:doc")
1787+
}));
1788+
// none of the dependencies should be a doc rule either
1789+
assert!(!plan.iter().any(|s| {
1790+
rules.rules[s.name].deps.iter().any(|dep| {
1791+
let dep = dep(&rules.sbuild.name(s.name));
1792+
dep.name.contains("doc-") || dep.name.contains("default:doc")
1793+
})
1794+
}));
1795+
}
17711796
}

src/doc/unstable-book/src/SUMMARY.md

-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@
8787
- [start](language-features/start.md)
8888
- [static_nobundle](language-features/static-nobundle.md)
8989
- [stmt_expr_attributes](language-features/stmt-expr-attributes.md)
90-
- [struct_field_attributes](language-features/struct-field-attributes.md)
9190
- [structural_match](language-features/structural-match.md)
9291
- [target_feature](language-features/target-feature.md)
9392
- [thread_local](language-features/thread-local.md)

src/doc/unstable-book/src/language-features/struct-field-attributes.md

-10
This file was deleted.

src/librustc_data_structures/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@
3636
#![feature(discriminant_value)]
3737
#![feature(specialization)]
3838
#![feature(manually_drop)]
39-
#![feature(struct_field_attributes)]
4039

4140
#![cfg_attr(stage0, unstable(feature = "rustc_private", issue = "27812"))]
4241
#![cfg_attr(stage0, feature(rustc_private))]
4342
#![cfg_attr(stage0, feature(staged_api))]
43+
#![cfg_attr(stage0, feature(struct_field_attributes))]
4444

4545
#![cfg_attr(unix, feature(libc))]
4646
#![cfg_attr(test, feature(test))]

src/librustc_errors/emitter.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,11 @@ impl EmitterWriter {
445445
&& next.has_label()) // multiline start/end, move it to a new line
446446
|| (annotation.has_label() // so as not to overlap the orizontal lines.
447447
&& next.takes_space())
448-
|| (annotation.takes_space()
449-
&& next.takes_space())
448+
|| (annotation.takes_space() && next.takes_space())
449+
|| (overlaps(next, annotation, l)
450+
&& next.end_col <= annotation.end_col
451+
&& next.has_label()
452+
&& p == 0) // Avoid #42595.
450453
{
451454
// This annotation needs a new line in the output.
452455
p += 1;

src/librustc_typeck/check/callee.rs

+10-11
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use super::method::MethodCallee;
1515
use hir::def::Def;
1616
use hir::def_id::{DefId, LOCAL_CRATE};
1717
use rustc::{infer, traits};
18-
use rustc::ty::{self, TyCtxt, LvaluePreference, Ty};
18+
use rustc::ty::{self, TyCtxt, TypeFoldable, LvaluePreference, Ty};
1919
use rustc::ty::subst::Subst;
2020
use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow};
2121
use syntax::abi;
@@ -209,17 +209,16 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
209209
}
210210
}
211211
}
212-
let mut err = if let Some(path) = unit_variant {
213-
let mut err = self.type_error_struct(call_expr.span, |_| {
214-
format!("`{}` is being called, but it is not a function", path)
215-
}, callee_ty);
212+
let mut err = type_error_struct!(self.tcx.sess, call_expr.span, callee_ty, E0618,
213+
"expected function, found `{}`",
214+
if let Some(ref path) = unit_variant {
215+
path.to_string()
216+
} else {
217+
callee_ty.to_string()
218+
});
219+
if let Some(path) = unit_variant {
216220
err.help(&format!("did you mean to write `{}`?", path));
217-
err
218-
} else {
219-
self.type_error_struct(call_expr.span, |actual| {
220-
format!("expected function, found `{}`", actual)
221-
}, callee_ty)
222-
};
221+
}
223222

224223
if let hir::ExprCall(ref expr, _) = call_expr.node {
225224
let def = if let hir::ExprPath(ref qpath) = expr.node {

src/librustc_typeck/diagnostics.rs

+28
Original file line numberDiff line numberDiff line change
@@ -4195,6 +4195,34 @@ as possible. For better explanations, see The Rust Book:
41954195
https://doc.rust-lang.org/book/
41964196
"##,
41974197

4198+
E0618: r##"
4199+
Attempted to call something which isn't a function nor a method.
4200+
4201+
Erroneous code examples:
4202+
4203+
```compile_fail,E0618
4204+
enum X {
4205+
Entry,
4206+
}
4207+
4208+
X::Entry(); // error: expected function, found `X::Entry`
4209+
4210+
// Or even simpler:
4211+
let x = 0i32;
4212+
x(); // error: expected function, found `i32`
4213+
```
4214+
4215+
Only functions and methods can be called using `()`. Example:
4216+
4217+
```
4218+
// We declare a function:
4219+
fn i_am_a_function() {}
4220+
4221+
// And we call it:
4222+
i_am_a_function();
4223+
```
4224+
"##,
4225+
41984226
}
41994227

42004228
register_diagnostics! {

src/libstd/io/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ fn read_to_end<R: Read + ?Sized>(r: &mut R, buf: &mut Vec<u8>) -> Result<usize>
389389

390390
/// The `Read` trait allows for reading bytes from a source.
391391
///
392-
/// Implementors of the `Read` trait are sometimes called 'readers'.
392+
/// Implementors of the `Read` trait are called 'readers'.
393393
///
394394
/// Readers are defined by one required method, `read()`. Each call to `read`
395395
/// will attempt to pull bytes from this source into a provided buffer. A

src/libsyntax/config.rs

-28
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ impl<'a> StripUnconfigured<'a> {
223223
ast::ExprKind::Struct(path, fields, base) => {
224224
let fields = fields.into_iter()
225225
.filter_map(|field| {
226-
self.visit_struct_field_attrs(field.attrs());
227226
self.configure(field)
228227
})
229228
.collect();
@@ -256,17 +255,6 @@ impl<'a> StripUnconfigured<'a> {
256255
}
257256

258257
pub fn configure_struct_expr_field(&mut self, field: ast::Field) -> Option<ast::Field> {
259-
if !self.features.map(|features| features.struct_field_attributes).unwrap_or(true) {
260-
if !field.attrs.is_empty() {
261-
let mut err = feature_err(self.sess,
262-
"struct_field_attributes",
263-
field.span,
264-
GateIssue::Language,
265-
"attributes on struct literal fields are unstable");
266-
err.emit();
267-
}
268-
}
269-
270258
self.configure(field)
271259
}
272260

@@ -275,7 +263,6 @@ impl<'a> StripUnconfigured<'a> {
275263
if let ast::PatKind::Struct(path, fields, etc) = pattern.node {
276264
let fields = fields.into_iter()
277265
.filter_map(|field| {
278-
self.visit_struct_field_attrs(field.attrs());
279266
self.configure(field)
280267
})
281268
.collect();
@@ -284,21 +271,6 @@ impl<'a> StripUnconfigured<'a> {
284271
pattern
285272
})
286273
}
287-
288-
fn visit_struct_field_attrs(&mut self, attrs: &[ast::Attribute]) {
289-
// flag the offending attributes
290-
for attr in attrs.iter() {
291-
if !self.features.map(|features| features.struct_field_attributes).unwrap_or(true) {
292-
let mut err = feature_err(
293-
self.sess,
294-
"struct_field_attributes",
295-
attr.span,
296-
GateIssue::Language,
297-
"attributes on struct pattern or literal fields are unstable");
298-
err.emit();
299-
}
300-
}
301-
}
302274
}
303275

304276
impl<'a> fold::Folder for StripUnconfigured<'a> {

src/libsyntax/feature_gate.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,6 @@ declare_features! (
312312
// Declarative macros 2.0 (`macro`).
313313
(active, decl_macro, "1.17.0", Some(39412)),
314314

315-
// Allows attributes on struct literal fields.
316-
(active, struct_field_attributes, "1.16.0", Some(38814)),
317-
318315
// Allows #[link(kind="static-nobundle"...]
319316
(active, static_nobundle, "1.16.0", Some(37403)),
320317

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

435434
// If you change this, please modify src/doc/unstable-book as well. You must

src/libsyntax/test_snippet.rs

+43
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,49 @@ error: foo
735735
"#);
736736
}
737737

738+
#[test]
739+
fn multiple_labels_secondary_without_message_3() {
740+
test_harness(r#"
741+
fn foo() {
742+
a bc d
743+
}
744+
"#,
745+
vec![
746+
SpanLabel {
747+
start: Position {
748+
string: "a",
749+
count: 1,
750+
},
751+
end: Position {
752+
string: "b",
753+
count: 1,
754+
},
755+
label: "`a` is a good letter",
756+
},
757+
SpanLabel {
758+
start: Position {
759+
string: "c",
760+
count: 1,
761+
},
762+
end: Position {
763+
string: "d",
764+
count: 1,
765+
},
766+
label: "",
767+
},
768+
],
769+
r#"
770+
error: foo
771+
--> test.rs:3:3
772+
|
773+
3 | a bc d
774+
| ^^^^----
775+
| |
776+
| `a` is a good letter
777+
778+
"#);
779+
}
780+
738781
#[test]
739782
fn multiple_labels_without_message() {
740783
test_harness(r#"

src/test/compile-fail/struct-field-attr-feature-gate.rs renamed to src/test/compile-fail/E0618.rs

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

11-
// gate-test-struct_field_attributes
12-
13-
struct Foo {
14-
present: (),
11+
enum X {
12+
Entry,
1513
}
1614

1715
fn main() {
18-
let foo = Foo { #[cfg(all())] present: () };
19-
//~^ ERROR attributes on struct pattern or literal fields are unstable
20-
let Foo { #[cfg(all())] present: () } = foo;
21-
//~^ ERROR attributes on struct pattern or literal fields are unstable
16+
X::Entry(); //~ ERROR expected function, found `X::Entry` [E0618]
17+
//~| HELP did you mean to write `X::Entry`?
18+
let x = 0i32;
19+
x(); //~ ERROR expected function, found `i32` [E0618]
2220
}

src/test/compile-fail/empty-struct-unit-expr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ enum E {
2424
fn main() {
2525
let e2 = Empty2(); //~ ERROR expected function, found `Empty2`
2626
let e4 = E::Empty4();
27-
//~^ ERROR `E::Empty4` is being called, but it is not a function
27+
//~^ ERROR expected function, found `E::Empty4` [E0618]
2828
//~| HELP did you mean to write `E::Empty4`?
2929
let xe2 = XEmpty2(); //~ ERROR expected function, found `empty_struct::XEmpty2`
3030
let xe4 = XE::XEmpty4();
31-
//~^ ERROR `XE::XEmpty4` is being called, but it is not a function
31+
//~^ ERROR expected function, found `XE::XEmpty4` [E0618]
3232
//~| HELP did you mean to write `XE::XEmpty4`?
3333
}

src/test/compile-fail/struct-field-cfg.rs

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

11-
#![feature(struct_field_attributes)]
12-
1311
struct Foo {
1412
present: (),
1513
}

0 commit comments

Comments
 (0)