Skip to content

Commit 70e52ca

Browse files
committedMay 12, 2021
Auto merge of rust-lang#85231 - GuillaumeGomez:rollup-hufe4gz, r=GuillaumeGomez
Rollup of 5 pull requests Successful merges: - rust-lang#84793 (Recover from invalid `struct` item syntax) - rust-lang#85117 (Move global click handlers to per-element ones.) - rust-lang#85141 (Update documentation for SharedContext::maybe_collapsed_doc_value) - rust-lang#85174 (Fix border radius for doc code blocks in rustdoc) - rust-lang#85205 (Update books) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 28e2b29 + 7684247 commit 70e52ca

18 files changed

+354
-138
lines changed
 

‎compiler/rustc_parse/src/parser/item.rs

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1399,6 +1399,37 @@ impl<'a> Parser<'a> {
13991399
Ok(a_var)
14001400
}
14011401

1402+
fn expect_field_ty_separator(&mut self) -> PResult<'a, ()> {
1403+
if let Err(mut err) = self.expect(&token::Colon) {
1404+
let sm = self.sess.source_map();
1405+
let eq_typo = self.token.kind == token::Eq && self.look_ahead(1, |t| t.is_path_start());
1406+
let semi_typo = self.token.kind == token::Semi
1407+
&& self.look_ahead(1, |t| {
1408+
t.is_path_start()
1409+
// We check that we are in a situation like `foo; bar` to avoid bad suggestions
1410+
// when there's no type and `;` was used instead of a comma.
1411+
&& match (sm.lookup_line(self.token.span.hi()), sm.lookup_line(t.span.lo())) {
1412+
(Ok(l), Ok(r)) => l.line == r.line,
1413+
_ => true,
1414+
}
1415+
});
1416+
if eq_typo || semi_typo {
1417+
self.bump();
1418+
// Gracefully handle small typos.
1419+
err.span_suggestion_short(
1420+
self.prev_token.span,
1421+
"field names and their types are separated with `:`",
1422+
":".to_string(),
1423+
Applicability::MachineApplicable,
1424+
);
1425+
err.emit();
1426+
} else {
1427+
return Err(err);
1428+
}
1429+
}
1430+
Ok(())
1431+
}
1432+
14021433
/// Parses a structure field.
14031434
fn parse_name_and_ty(
14041435
&mut self,
@@ -1408,8 +1439,21 @@ impl<'a> Parser<'a> {
14081439
attrs: Vec<Attribute>,
14091440
) -> PResult<'a, FieldDef> {
14101441
let name = self.parse_field_ident(adt_ty, lo)?;
1411-
self.expect(&token::Colon)?;
1442+
self.expect_field_ty_separator()?;
14121443
let ty = self.parse_ty()?;
1444+
if self.token.kind == token::Eq {
1445+
self.bump();
1446+
let const_expr = self.parse_anon_const_expr()?;
1447+
let sp = ty.span.shrink_to_hi().to(const_expr.value.span);
1448+
self.struct_span_err(sp, "default values on `struct` fields aren't supported")
1449+
.span_suggestion(
1450+
sp,
1451+
"remove this unsupported default value",
1452+
String::new(),
1453+
Applicability::MachineApplicable,
1454+
)
1455+
.emit();
1456+
}
14131457
Ok(FieldDef {
14141458
span: lo.to(self.prev_token.span),
14151459
ident: Some(name),

‎src/doc/book

Submodule book updated 34 files

‎src/librustdoc/html/layout.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ crate fn render<T: Print, S: Print>(
105105
placeholder=\"Click or press ‘S’ to search, ‘?’ for more options…\" \
106106
type=\"search\">\
107107
</div>\
108-
<button type=\"button\" class=\"help-button\">?</button>
108+
<button type=\"button\" id=\"help-button\">?</button>
109109
<a id=\"settings-menu\" href=\"{root_path}settings.html\">\
110110
<img src=\"{static_root_path}wheel{suffix}.svg\" \
111111
width=\"18\" height=\"18\" \

‎src/librustdoc/html/markdown.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,6 +1347,7 @@ fn init_id_map() -> FxHashMap<String, usize> {
13471347
map.insert("theme-picker".to_owned(), 1);
13481348
map.insert("theme-choices".to_owned(), 1);
13491349
map.insert("settings-menu".to_owned(), 1);
1350+
map.insert("help-button".to_owned(), 1);
13501351
map.insert("main".to_owned(), 1);
13511352
map.insert("search".to_owned(), 1);
13521353
map.insert("crate-search".to_owned(), 1);

‎src/librustdoc/html/render/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ impl SharedContext<'_> {
137137
Ok(())
138138
}
139139

140-
/// Based on whether the `collapse-docs` pass was run, return either the `doc_value` or the
141-
/// `collapsed_doc_value` of the given item.
140+
/// Returns the `collapsed_doc_value` of the given item if this is the main crate, otherwise
141+
/// returns the `doc_value`.
142142
crate fn maybe_collapsed_doc_value<'a>(&self, item: &'a clean::Item) -> Option<String> {
143143
if self.collapsed { item.collapsed_doc_value() } else { item.doc_value() }
144144
}

‎src/librustdoc/html/static/main.js

Lines changed: 29 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -381,56 +381,9 @@ function hideThemeButtonState() {
381381
}
382382
}
383383

384-
function highlightSourceLines(match, ev) {
385-
if (typeof match === "undefined") {
386-
// If we're in mobile mode, we should hide the sidebar in any case.
387-
hideSidebar();
388-
match = window.location.hash.match(/^#?(\d+)(?:-(\d+))?$/);
389-
}
390-
if (!match) {
391-
return;
392-
}
393-
var from = parseInt(match[1], 10);
394-
var to = from;
395-
if (typeof match[2] !== "undefined") {
396-
to = parseInt(match[2], 10);
397-
}
398-
if (to < from) {
399-
var tmp = to;
400-
to = from;
401-
from = tmp;
402-
}
403-
var elem = document.getElementById(from);
404-
if (!elem) {
405-
return;
406-
}
407-
if (!ev) {
408-
var x = document.getElementById(from);
409-
if (x) {
410-
x.scrollIntoView();
411-
}
412-
}
413-
onEachLazy(document.getElementsByClassName("line-numbers"), function(e) {
414-
onEachLazy(e.getElementsByTagName("span"), function(i_e) {
415-
removeClass(i_e, "line-highlighted");
416-
});
417-
});
418-
for (var i = from; i <= to; ++i) {
419-
elem = document.getElementById(i);
420-
if (!elem) {
421-
break;
422-
}
423-
addClass(elem, "line-highlighted");
424-
}
425-
}
426-
427384
function onHashChange(ev) {
428385
// If we're in mobile mode, we should hide the sidebar in any case.
429386
hideSidebar();
430-
var match = window.location.hash.match(/^#?(\d+)(?:-(\d+))?$/);
431-
if (match) {
432-
return highlightSourceLines(match, ev);
433-
}
434387
handleHashes(ev);
435388
}
436389

@@ -585,78 +538,9 @@ function hideThemeButtonState() {
585538
}
586539
}
587540

588-
function findParentElement(elem, tagName) {
589-
do {
590-
if (elem && elem.tagName === tagName) {
591-
return elem;
592-
}
593-
elem = elem.parentNode;
594-
} while (elem);
595-
return null;
596-
}
597-
598541
document.addEventListener("keypress", handleShortcut);
599542
document.addEventListener("keydown", handleShortcut);
600543

601-
var handleSourceHighlight = (function() {
602-
var prev_line_id = 0;
603-
604-
var set_fragment = function(name) {
605-
var x = window.scrollX,
606-
y = window.scrollY;
607-
if (searchState.browserSupportsHistoryApi()) {
608-
history.replaceState(null, null, "#" + name);
609-
highlightSourceLines();
610-
} else {
611-
location.replace("#" + name);
612-
}
613-
// Prevent jumps when selecting one or many lines
614-
window.scrollTo(x, y);
615-
};
616-
617-
return function(ev) {
618-
var cur_line_id = parseInt(ev.target.id, 10);
619-
ev.preventDefault();
620-
621-
if (ev.shiftKey && prev_line_id) {
622-
// Swap selection if needed
623-
if (prev_line_id > cur_line_id) {
624-
var tmp = prev_line_id;
625-
prev_line_id = cur_line_id;
626-
cur_line_id = tmp;
627-
}
628-
629-
set_fragment(prev_line_id + "-" + cur_line_id);
630-
} else {
631-
prev_line_id = cur_line_id;
632-
633-
set_fragment(cur_line_id);
634-
}
635-
};
636-
}());
637-
638-
document.addEventListener("click", function(ev) {
639-
var helpElem = getHelpElement(false);
640-
if (hasClass(ev.target, "help-button")) {
641-
displayHelp(true, ev);
642-
} else if (ev.target.tagName === "SPAN" && hasClass(ev.target.parentNode, "line-numbers")) {
643-
handleSourceHighlight(ev);
644-
} else if (helpElem && hasClass(helpElem, "hidden") === false) {
645-
var is_inside_help_popup = ev.target !== helpElem && helpElem.contains(ev.target);
646-
if (is_inside_help_popup === false) {
647-
addClass(helpElem, "hidden");
648-
removeClass(document.body, "blur");
649-
}
650-
} else {
651-
// Making a collapsed element visible on onhashchange seems
652-
// too late
653-
var a = findParentElement(ev.target, "A");
654-
if (a && a.hash) {
655-
expandSection(a.hash.replace(/^#/, ""));
656-
}
657-
}
658-
});
659-
660544
(function() {
661545
var x = document.getElementsByClassName("version-selector");
662546
if (x.length > 0) {
@@ -1121,6 +1005,27 @@ function hideThemeButtonState() {
11211005
});
11221006
}());
11231007

1008+
function handleClick(id, f) {
1009+
var elem = document.getElementById(id);
1010+
if (elem) {
1011+
elem.addEventListener("click", f);
1012+
}
1013+
}
1014+
handleClick("help-button", function(ev) {
1015+
displayHelp(true, ev);
1016+
});
1017+
1018+
onEachLazy(document.getElementsByTagName("a"), function(el) {
1019+
// For clicks on internal links (<A> tags with a hash property), we expand the section we're
1020+
// jumping to *before* jumping there. We can't do this in onHashChange, because it changes
1021+
// the height of the document so we wind up scrolled to the wrong place.
1022+
if (el.hash) {
1023+
el.addEventListener("click", function() {
1024+
expandSection(el.hash.slice(1));
1025+
});
1026+
}
1027+
});
1028+
11241029
onEachLazy(document.getElementsByClassName("notable-traits"), function(e) {
11251030
e.onclick = function() {
11261031
this.getElementsByClassName('notable-traits-tooltiptext')[0]
@@ -1165,6 +1070,13 @@ function hideThemeButtonState() {
11651070
addClass(popup, "hidden");
11661071
popup.id = "help";
11671072

1073+
popup.addEventListener("click", function(ev) {
1074+
if (ev.target === popup) {
1075+
// Clicked the blurred zone outside the help popup; dismiss help.
1076+
displayHelp(false, ev);
1077+
}
1078+
});
1079+
11681080
var book_info = document.createElement("span");
11691081
book_info.innerHTML = "You can find more information in \
11701082
<a href=\"https://doc.rust-lang.org/rustdoc/\">the rustdoc book</a>.";
@@ -1223,7 +1135,7 @@ function hideThemeButtonState() {
12231135
}
12241136

12251137
onHashChange(null);
1226-
window.onhashchange = onHashChange;
1138+
window.addEventListener("hashchange", onHashChange);
12271139
searchState.setup();
12281140
}());
12291141

‎src/librustdoc/html/static/rustdoc.css

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,8 @@ nav.sub {
371371
border: 1px solid;
372372
padding: 13px 8px;
373373
text-align: right;
374+
border-top-left-radius: 5px;
375+
border-bottom-left-radius: 5px;
374376
}
375377

376378
.rustdoc:not(.source) .example-wrap > pre.rust {
@@ -398,8 +400,6 @@ nav.sub {
398400
-moz-user-select: none;
399401
-ms-user-select: none;
400402
user-select: none;
401-
border-top-left-radius: 5px;
402-
border-bottom-left-radius: 5px;
403403
}
404404
.line-numbers span {
405405
cursor: pointer;
@@ -1289,7 +1289,7 @@ h4 > .notable-traits {
12891289
outline: none;
12901290
}
12911291

1292-
#settings-menu, .help-button {
1292+
#settings-menu, #help-button {
12931293
position: absolute;
12941294
top: 10px;
12951295
}
@@ -1299,7 +1299,7 @@ h4 > .notable-traits {
12991299
outline: none;
13001300
}
13011301

1302-
#theme-picker, #settings-menu, .help-button, #copy-path {
1302+
#theme-picker, #settings-menu, #help-button, #copy-path {
13031303
padding: 4px;
13041304
width: 27px;
13051305
height: 29px;
@@ -1308,7 +1308,7 @@ h4 > .notable-traits {
13081308
cursor: pointer;
13091309
}
13101310

1311-
.help-button {
1311+
#help-button {
13121312
right: 30px;
13131313
font-family: "Fira Sans", Arial, sans-serif;
13141314
text-align: center;
@@ -1593,7 +1593,7 @@ h4 > .notable-traits {
15931593
}
15941594

15951595
/* We don't display the help button on mobile devices. */
1596-
.help-button {
1596+
#help-button {
15971597
display: none;
15981598
}
15991599
.search-container > div {

‎src/librustdoc/html/static/source-script.js

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
// Local js definitions:
55
/* global addClass, getCurrentValue, hasClass, removeClass, updateLocalStorage */
6+
(function() {
67

78
function getCurrentFilePath() {
89
var parts = window.location.pathname.split("/");
@@ -149,3 +150,99 @@ function createSourceSidebar() {
149150
selected_elem.focus();
150151
}
151152
}
153+
154+
var lineNumbersRegex = /^#?(\d+)(?:-(\d+))?$/;
155+
156+
function highlightSourceLines(match, ev) {
157+
if (typeof match === "undefined") {
158+
match = window.location.hash.match(lineNumbersRegex);
159+
}
160+
if (!match) {
161+
return;
162+
}
163+
var from = parseInt(match[1], 10);
164+
var to = from;
165+
if (typeof match[2] !== "undefined") {
166+
to = parseInt(match[2], 10);
167+
}
168+
if (to < from) {
169+
var tmp = to;
170+
to = from;
171+
from = tmp;
172+
}
173+
var elem = document.getElementById(from);
174+
if (!elem) {
175+
return;
176+
}
177+
if (!ev) {
178+
var x = document.getElementById(from);
179+
if (x) {
180+
x.scrollIntoView();
181+
}
182+
}
183+
onEachLazy(document.getElementsByClassName("line-numbers"), function(e) {
184+
onEachLazy(e.getElementsByTagName("span"), function(i_e) {
185+
removeClass(i_e, "line-highlighted");
186+
});
187+
});
188+
for (var i = from; i <= to; ++i) {
189+
elem = document.getElementById(i);
190+
if (!elem) {
191+
break;
192+
}
193+
addClass(elem, "line-highlighted");
194+
}
195+
}
196+
197+
var handleSourceHighlight = (function() {
198+
var prev_line_id = 0;
199+
200+
var set_fragment = function(name) {
201+
var x = window.scrollX,
202+
y = window.scrollY;
203+
if (searchState.browserSupportsHistoryApi()) {
204+
history.replaceState(null, null, "#" + name);
205+
highlightSourceLines();
206+
} else {
207+
location.replace("#" + name);
208+
}
209+
// Prevent jumps when selecting one or many lines
210+
window.scrollTo(x, y);
211+
};
212+
213+
return function(ev) {
214+
var cur_line_id = parseInt(ev.target.id, 10);
215+
ev.preventDefault();
216+
217+
if (ev.shiftKey && prev_line_id) {
218+
// Swap selection if needed
219+
if (prev_line_id > cur_line_id) {
220+
var tmp = prev_line_id;
221+
prev_line_id = cur_line_id;
222+
cur_line_id = tmp;
223+
}
224+
225+
set_fragment(prev_line_id + "-" + cur_line_id);
226+
} else {
227+
prev_line_id = cur_line_id;
228+
229+
set_fragment(cur_line_id);
230+
}
231+
};
232+
}());
233+
234+
window.addEventListener("hashchange", function() {
235+
var match = window.location.hash.match(lineNumbersRegex);
236+
if (match) {
237+
return highlightSourceLines(match, ev);
238+
}
239+
});
240+
241+
onEachLazy(document.getElementsByClassName("line-numbers"), function(el) {
242+
el.addEventListener("click", handleSourceHighlight);
243+
});
244+
245+
highlightSourceLines();
246+
247+
window.createSourceSidebar = createSourceSidebar;
248+
})();

‎src/librustdoc/html/static/themes/ayu.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ kbd {
503503
box-shadow-color: #c6cbd1;
504504
}
505505

506-
#theme-picker, #settings-menu, .help-button, #copy-path {
506+
#theme-picker, #settings-menu, #help-button, #copy-path {
507507
border-color: #5c6773;
508508
background-color: #0f1419;
509509
color: #fff;
@@ -515,7 +515,7 @@ kbd {
515515

516516
#theme-picker:hover, #theme-picker:focus,
517517
#settings-menu:hover, #settings-menu:focus,
518-
.help-button:hover, .help-button:focus,
518+
#help-button:hover, #help-button:focus,
519519
#copy-path:hover, #copy-path:focus {
520520
border-color: #e0e0e0;
521521
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,15 +393,15 @@ kbd {
393393
box-shadow-color: #c6cbd1;
394394
}
395395

396-
#theme-picker, #settings-menu, .help-button, #copy-path {
396+
#theme-picker, #settings-menu, #help-button, #copy-path {
397397
border-color: #e0e0e0;
398398
background: #f0f0f0;
399399
color: #000;
400400
}
401401

402402
#theme-picker:hover, #theme-picker:focus,
403403
#settings-menu:hover, #settings-menu:focus,
404-
.help-button:hover, .help-button:focus,
404+
#help-button:hover, #help-button:focus,
405405
#copy-path:hover, #copy-path:focus {
406406
border-color: #ffb900;
407407
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,14 +385,14 @@ kbd {
385385
box-shadow-color: #c6cbd1;
386386
}
387387

388-
#theme-picker, #settings-menu, .help-button, #copy-path {
388+
#theme-picker, #settings-menu, #help-button, #copy-path {
389389
border-color: #e0e0e0;
390390
background-color: #fff;
391391
}
392392

393393
#theme-picker:hover, #theme-picker:focus,
394394
#settings-menu:hover, #settings-menu:focus,
395-
.help-button:hover, .help-button:focus,
395+
#help-button:hover, #help-button:focus,
396396
#copy-path:hover, #copy-path:focus {
397397
border-color: #717171;
398398
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// run-rustfix
2+
#![allow(dead_code)]
3+
4+
enum E {
5+
A,
6+
}
7+
8+
struct S {
9+
field1: i32, //~ ERROR default values on `struct` fields aren't supported
10+
field2: E, //~ ERROR default values on `struct` fields aren't supported
11+
field3: i32, //~ ERROR default values on `struct` fields aren't supported
12+
field4: i32, //~ ERROR default values on `struct` fields aren't supported
13+
field5: E, //~ ERROR default values on `struct` fields aren't supported
14+
field6: E, //~ ERROR default values on `struct` fields aren't supported
15+
}
16+
17+
struct S1 {
18+
field1: i32, //~ ERROR expected `,`, or `}`, found `field2`
19+
field2: E, //~ ERROR expected `,`, or `}`, found `field3`
20+
field3: i32, //~ ERROR default values on `struct` fields aren't supported
21+
field4: i32, //~ ERROR default values on `struct` fields aren't supported
22+
field5: E, //~ ERROR default values on `struct` fields aren't supported
23+
field6: E, //~ ERROR default values on `struct` fields aren't supported
24+
}
25+
26+
struct S2 {
27+
field1 : i32, //~ ERROR expected `:`, found `=`
28+
field2: E, //~ ERROR expected `:`, found `;`
29+
}
30+
31+
const fn foo(_: i32) -> E {
32+
E::A
33+
}
34+
35+
fn main() {}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// run-rustfix
2+
#![allow(dead_code)]
3+
4+
enum E {
5+
A,
6+
}
7+
8+
struct S {
9+
field1: i32 = 42, //~ ERROR default values on `struct` fields aren't supported
10+
field2: E = E::A, //~ ERROR default values on `struct` fields aren't supported
11+
field3: i32 = 1 + 2, //~ ERROR default values on `struct` fields aren't supported
12+
field4: i32 = { 1 + 2 }, //~ ERROR default values on `struct` fields aren't supported
13+
field5: E = foo(42), //~ ERROR default values on `struct` fields aren't supported
14+
field6: E = { foo(42) }, //~ ERROR default values on `struct` fields aren't supported
15+
}
16+
17+
struct S1 {
18+
field1: i32 //~ ERROR expected `,`, or `}`, found `field2`
19+
field2: E //~ ERROR expected `,`, or `}`, found `field3`
20+
field3: i32 = 1 + 2, //~ ERROR default values on `struct` fields aren't supported
21+
field4: i32 = { 1 + 2 }, //~ ERROR default values on `struct` fields aren't supported
22+
field5: E = foo(42), //~ ERROR default values on `struct` fields aren't supported
23+
field6: E = { foo(42) }, //~ ERROR default values on `struct` fields aren't supported
24+
}
25+
26+
struct S2 {
27+
field1 = i32, //~ ERROR expected `:`, found `=`
28+
field2; E, //~ ERROR expected `:`, found `;`
29+
}
30+
31+
const fn foo(_: i32) -> E {
32+
E::A
33+
}
34+
35+
fn main() {}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
error: default values on `struct` fields aren't supported
2+
--> $DIR/struct-default-values-and-missing-field-separator.rs:9:16
3+
|
4+
LL | field1: i32 = 42,
5+
| ^^^^^ help: remove this unsupported default value
6+
7+
error: default values on `struct` fields aren't supported
8+
--> $DIR/struct-default-values-and-missing-field-separator.rs:10:14
9+
|
10+
LL | field2: E = E::A,
11+
| ^^^^^^^ help: remove this unsupported default value
12+
13+
error: default values on `struct` fields aren't supported
14+
--> $DIR/struct-default-values-and-missing-field-separator.rs:11:16
15+
|
16+
LL | field3: i32 = 1 + 2,
17+
| ^^^^^^^^ help: remove this unsupported default value
18+
19+
error: default values on `struct` fields aren't supported
20+
--> $DIR/struct-default-values-and-missing-field-separator.rs:12:16
21+
|
22+
LL | field4: i32 = { 1 + 2 },
23+
| ^^^^^^^^^^^^ help: remove this unsupported default value
24+
25+
error: default values on `struct` fields aren't supported
26+
--> $DIR/struct-default-values-and-missing-field-separator.rs:13:14
27+
|
28+
LL | field5: E = foo(42),
29+
| ^^^^^^^^^^ help: remove this unsupported default value
30+
31+
error: default values on `struct` fields aren't supported
32+
--> $DIR/struct-default-values-and-missing-field-separator.rs:14:14
33+
|
34+
LL | field6: E = { foo(42) },
35+
| ^^^^^^^^^^^^^^ help: remove this unsupported default value
36+
37+
error: expected `,`, or `}`, found `field2`
38+
--> $DIR/struct-default-values-and-missing-field-separator.rs:18:16
39+
|
40+
LL | field1: i32
41+
| ^ help: try adding a comma: `,`
42+
43+
error: expected `,`, or `}`, found `field3`
44+
--> $DIR/struct-default-values-and-missing-field-separator.rs:19:14
45+
|
46+
LL | field2: E
47+
| ^ help: try adding a comma: `,`
48+
49+
error: default values on `struct` fields aren't supported
50+
--> $DIR/struct-default-values-and-missing-field-separator.rs:20:16
51+
|
52+
LL | field3: i32 = 1 + 2,
53+
| ^^^^^^^^ help: remove this unsupported default value
54+
55+
error: default values on `struct` fields aren't supported
56+
--> $DIR/struct-default-values-and-missing-field-separator.rs:21:16
57+
|
58+
LL | field4: i32 = { 1 + 2 },
59+
| ^^^^^^^^^^^^ help: remove this unsupported default value
60+
61+
error: default values on `struct` fields aren't supported
62+
--> $DIR/struct-default-values-and-missing-field-separator.rs:22:14
63+
|
64+
LL | field5: E = foo(42),
65+
| ^^^^^^^^^^ help: remove this unsupported default value
66+
67+
error: default values on `struct` fields aren't supported
68+
--> $DIR/struct-default-values-and-missing-field-separator.rs:23:14
69+
|
70+
LL | field6: E = { foo(42) },
71+
| ^^^^^^^^^^^^^^ help: remove this unsupported default value
72+
73+
error: expected `:`, found `=`
74+
--> $DIR/struct-default-values-and-missing-field-separator.rs:27:12
75+
|
76+
LL | field1 = i32,
77+
| ^
78+
| |
79+
| expected `:`
80+
| help: field names and their types are separated with `:`
81+
82+
error: expected `:`, found `;`
83+
--> $DIR/struct-default-values-and-missing-field-separator.rs:28:11
84+
|
85+
LL | field2; E,
86+
| ^
87+
| |
88+
| expected `:`
89+
| help: field names and their types are separated with `:`
90+
91+
error: aborting due to 14 previous errors
92+

0 commit comments

Comments
 (0)
Please sign in to comment.