Skip to content

Commit ee5ed4a

Browse files
committed
Auto merge of rust-lang#87118 - JohnTitor:rollup-8ltidsq, r=JohnTitor
Rollup of 6 pull requests Successful merges: - rust-lang#87085 (Search result colors) - rust-lang#87090 (Make BTreeSet::split_off name elements like other set methods do) - rust-lang#87098 (Unignore some pretty printing tests) - rust-lang#87099 (Upgrade `cc` crate to 1.0.69) - rust-lang#87101 (Suggest a path separator if a stray colon is found in a match arm) - rust-lang#87102 (Add GUI test for "go to first" feature) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents a08f25a + afaca5b commit ee5ed4a

File tree

24 files changed

+296
-39
lines changed

24 files changed

+296
-39
lines changed

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -435,9 +435,9 @@ version = "0.1.0"
435435

436436
[[package]]
437437
name = "cc"
438-
version = "1.0.68"
438+
version = "1.0.69"
439439
source = "registry+https://github.com/rust-lang/crates.io-index"
440-
checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787"
440+
checksum = "e70cc2f62c6ce1868963827bd677764c62d07c3d9a3e1fb1177ee1a9ab199eb2"
441441
dependencies = [
442442
"jobserver",
443443
]

compiler/rustc_codegen_ssa/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ test = false
99

1010
[dependencies]
1111
bitflags = "1.2.1"
12-
cc = "1.0.68"
12+
cc = "1.0.69"
1313
itertools = "0.9"
1414
tracing = "0.1"
1515
libc = "0.2.50"

compiler/rustc_expand/src/expand.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ use rustc_data_structures::stack::ensure_sufficient_stack;
2222
use rustc_data_structures::sync::Lrc;
2323
use rustc_errors::{Applicability, FatalError, PResult};
2424
use rustc_feature::Features;
25-
use rustc_parse::parser::{AttemptLocalParseRecovery, ForceCollect, Parser, RecoverComma};
25+
use rustc_parse::parser::{
26+
AttemptLocalParseRecovery, ForceCollect, Parser, RecoverColon, RecoverComma,
27+
};
2628
use rustc_parse::validate_attr;
2729
use rustc_session::lint::builtin::UNUSED_DOC_COMMENTS;
2830
use rustc_session::lint::BuiltinLintDiagnostics;
@@ -930,9 +932,11 @@ pub fn parse_ast_fragment<'a>(
930932
}
931933
}
932934
AstFragmentKind::Ty => AstFragment::Ty(this.parse_ty()?),
933-
AstFragmentKind::Pat => {
934-
AstFragment::Pat(this.parse_pat_allow_top_alt(None, RecoverComma::No)?)
935-
}
935+
AstFragmentKind::Pat => AstFragment::Pat(this.parse_pat_allow_top_alt(
936+
None,
937+
RecoverComma::No,
938+
RecoverColon::Yes,
939+
)?),
936940
AstFragmentKind::Arms
937941
| AstFragmentKind::Fields
938942
| AstFragmentKind::FieldPats

compiler/rustc_llvm/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ libc = "0.2.73"
1313

1414
[build-dependencies]
1515
build_helper = { path = "../../src/build_helper" }
16-
cc = "1.0.68"
16+
cc = "1.0.69"

compiler/rustc_parse/src/parser/expr.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::pat::{RecoverComma, PARAM_EXPECTED};
1+
use super::pat::{RecoverColon, RecoverComma, PARAM_EXPECTED};
22
use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign};
33
use super::{AttrWrapper, BlockMode, ForceCollect, Parser, PathStyle, Restrictions, TokenType};
44
use super::{SemiColonMode, SeqSep, TokenExpectType, TrailingToken};
@@ -1813,7 +1813,7 @@ impl<'a> Parser<'a> {
18131813
/// The `let` token has already been eaten.
18141814
fn parse_let_expr(&mut self, attrs: AttrVec) -> PResult<'a, P<Expr>> {
18151815
let lo = self.prev_token.span;
1816-
let pat = self.parse_pat_allow_top_alt(None, RecoverComma::Yes)?;
1816+
let pat = self.parse_pat_allow_top_alt(None, RecoverComma::Yes, RecoverColon::Yes)?;
18171817
self.expect(&token::Eq)?;
18181818
let expr = self.with_res(self.restrictions | Restrictions::NO_STRUCT_LITERAL, |this| {
18191819
this.parse_assoc_expr_with(1 + prec_let_scrutinee_needs_par(), None.into())
@@ -1876,7 +1876,7 @@ impl<'a> Parser<'a> {
18761876
_ => None,
18771877
};
18781878

1879-
let pat = self.parse_pat_allow_top_alt(None, RecoverComma::Yes)?;
1879+
let pat = self.parse_pat_allow_top_alt(None, RecoverComma::Yes, RecoverColon::Yes)?;
18801880
if !self.eat_keyword(kw::In) {
18811881
self.error_missing_in_for_loop();
18821882
}
@@ -2083,7 +2083,7 @@ impl<'a> Parser<'a> {
20832083
let attrs = self.parse_outer_attributes()?;
20842084
self.collect_tokens_trailing_token(attrs, ForceCollect::No, |this, attrs| {
20852085
let lo = this.token.span;
2086-
let pat = this.parse_pat_allow_top_alt(None, RecoverComma::Yes)?;
2086+
let pat = this.parse_pat_allow_top_alt(None, RecoverComma::Yes, RecoverColon::Yes)?;
20872087
let guard = if this.eat_keyword(kw::If) {
20882088
let if_span = this.prev_token.span;
20892089
let cond = this.parse_expr()?;

compiler/rustc_parse/src/parser/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::lexer::UnmatchedBrace;
1414
pub use attr_wrapper::AttrWrapper;
1515
pub use diagnostics::AttemptLocalParseRecovery;
1616
use diagnostics::Error;
17-
pub use pat::RecoverComma;
17+
pub use pat::{RecoverColon, RecoverComma};
1818
pub use path::PathStyle;
1919

2020
use rustc_ast::ptr::P;

compiler/rustc_parse/src/parser/nonterminal.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_ast_pretty::pprust;
55
use rustc_errors::PResult;
66
use rustc_span::symbol::{kw, Ident};
77

8-
use crate::parser::pat::RecoverComma;
8+
use crate::parser::pat::{RecoverColon, RecoverComma};
99
use crate::parser::{FollowedByType, ForceCollect, Parser, PathStyle};
1010

1111
impl<'a> Parser<'a> {
@@ -125,7 +125,7 @@ impl<'a> Parser<'a> {
125125
token::NtPat(self.collect_tokens_no_attrs(|this| match kind {
126126
NonterminalKind::PatParam { .. } => this.parse_pat_no_top_alt(None),
127127
NonterminalKind::PatWithOr { .. } => {
128-
this.parse_pat_allow_top_alt(None, RecoverComma::No)
128+
this.parse_pat_allow_top_alt(None, RecoverComma::No, RecoverColon::No)
129129
}
130130
_ => unreachable!(),
131131
})?)

compiler/rustc_parse/src/parser/pat.rs

+70-8
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ pub enum RecoverComma {
2424
No,
2525
}
2626

27+
/// Whether or not to recover a `:` when parsing patterns that were meant to be paths.
28+
#[derive(PartialEq, Copy, Clone)]
29+
pub enum RecoverColon {
30+
Yes,
31+
No,
32+
}
33+
2734
/// The result of `eat_or_separator`. We want to distinguish which case we are in to avoid
2835
/// emitting duplicate diagnostics.
2936
#[derive(Debug, Clone, Copy)]
@@ -58,8 +65,9 @@ impl<'a> Parser<'a> {
5865
&mut self,
5966
expected: Expected,
6067
rc: RecoverComma,
68+
ra: RecoverColon,
6169
) -> PResult<'a, P<Pat>> {
62-
self.parse_pat_allow_top_alt_inner(expected, rc).map(|(pat, _)| pat)
70+
self.parse_pat_allow_top_alt_inner(expected, rc, ra).map(|(pat, _)| pat)
6371
}
6472

6573
/// Returns the pattern and a bool indicating whether we recovered from a trailing vert (true =
@@ -68,6 +76,7 @@ impl<'a> Parser<'a> {
6876
&mut self,
6977
expected: Expected,
7078
rc: RecoverComma,
79+
ra: RecoverColon,
7180
) -> PResult<'a, (P<Pat>, bool)> {
7281
// Keep track of whether we recovered from a trailing vert so that we can avoid duplicated
7382
// suggestions (which bothers rustfix).
@@ -89,6 +98,56 @@ impl<'a> Parser<'a> {
8998
// If we parsed a leading `|` which should be gated,
9099
// then we should really gate the leading `|`.
91100
// This complicated procedure is done purely for diagnostics UX.
101+
let mut first_pat = first_pat;
102+
103+
if let (RecoverColon::Yes, token::Colon) = (ra, &self.token.kind) {
104+
if matches!(
105+
first_pat.kind,
106+
PatKind::Ident(BindingMode::ByValue(Mutability::Not), _, None)
107+
| PatKind::Path(..)
108+
) && self.look_ahead(1, |token| token.is_ident() && !token.is_reserved_ident())
109+
{
110+
// The pattern looks like it might be a path with a `::` -> `:` typo:
111+
// `match foo { bar:baz => {} }`
112+
let span = self.token.span;
113+
// We only emit "unexpected `:`" error here if we can successfully parse the
114+
// whole pattern correctly in that case.
115+
let snapshot = self.clone();
116+
117+
// Create error for "unexpected `:`".
118+
match self.expected_one_of_not_found(&[], &[]) {
119+
Err(mut err) => {
120+
self.bump(); // Skip the `:`.
121+
match self.parse_pat_no_top_alt(expected) {
122+
Err(mut inner_err) => {
123+
// Carry on as if we had not done anything, callers will emit a
124+
// reasonable error.
125+
inner_err.cancel();
126+
err.cancel();
127+
*self = snapshot;
128+
}
129+
Ok(pat) => {
130+
// We've parsed the rest of the pattern.
131+
err.span_suggestion(
132+
span,
133+
"maybe write a path separator here",
134+
"::".to_string(),
135+
Applicability::MachineApplicable,
136+
);
137+
err.emit();
138+
first_pat =
139+
self.mk_pat(first_pat.span.to(pat.span), PatKind::Wild);
140+
}
141+
}
142+
}
143+
_ => {
144+
// Carry on as if we had not done anything. This should be unreachable.
145+
*self = snapshot;
146+
}
147+
};
148+
}
149+
}
150+
92151
if let Some(leading_vert_span) = leading_vert_span {
93152
// If there was a leading vert, treat this as an or-pattern. This improves
94153
// diagnostics.
@@ -140,7 +199,8 @@ impl<'a> Parser<'a> {
140199
// We use `parse_pat_allow_top_alt` regardless of whether we actually want top-level
141200
// or-patterns so that we can detect when a user tries to use it. This allows us to print a
142201
// better error message.
143-
let (pat, trailing_vert) = self.parse_pat_allow_top_alt_inner(expected, rc)?;
202+
let (pat, trailing_vert) =
203+
self.parse_pat_allow_top_alt_inner(expected, rc, RecoverColon::No)?;
144204
let colon = self.eat(&token::Colon);
145205

146206
if let PatKind::Or(pats) = &pat.kind {
@@ -350,7 +410,7 @@ impl<'a> Parser<'a> {
350410
} else if self.check(&token::OpenDelim(token::Bracket)) {
351411
// Parse `[pat, pat,...]` as a slice pattern.
352412
let (pats, _) = self.parse_delim_comma_seq(token::Bracket, |p| {
353-
p.parse_pat_allow_top_alt(None, RecoverComma::No)
413+
p.parse_pat_allow_top_alt(None, RecoverComma::No, RecoverColon::No)
354414
})?;
355415
PatKind::Slice(pats)
356416
} else if self.check(&token::DotDot) && !self.is_pat_range_end_start(1) {
@@ -563,8 +623,9 @@ impl<'a> Parser<'a> {
563623

564624
/// Parse a tuple or parenthesis pattern.
565625
fn parse_pat_tuple_or_parens(&mut self) -> PResult<'a, PatKind> {
566-
let (fields, trailing_comma) =
567-
self.parse_paren_comma_seq(|p| p.parse_pat_allow_top_alt(None, RecoverComma::No))?;
626+
let (fields, trailing_comma) = self.parse_paren_comma_seq(|p| {
627+
p.parse_pat_allow_top_alt(None, RecoverComma::No, RecoverColon::No)
628+
})?;
568629

569630
// Here, `(pat,)` is a tuple pattern.
570631
// For backward compatibility, `(..)` is a tuple pattern as well.
@@ -873,8 +934,9 @@ impl<'a> Parser<'a> {
873934

874935
/// Parse tuple struct or tuple variant pattern (e.g. `Foo(...)` or `Foo::Bar(...)`).
875936
fn parse_pat_tuple_struct(&mut self, qself: Option<QSelf>, path: Path) -> PResult<'a, PatKind> {
876-
let (fields, _) =
877-
self.parse_paren_comma_seq(|p| p.parse_pat_allow_top_alt(None, RecoverComma::No))?;
937+
let (fields, _) = self.parse_paren_comma_seq(|p| {
938+
p.parse_pat_allow_top_alt(None, RecoverComma::No, RecoverColon::No)
939+
})?;
878940
if qself.is_some() {
879941
self.sess.gated_spans.gate(sym::more_qualified_paths, path.span);
880942
}
@@ -1033,7 +1095,7 @@ impl<'a> Parser<'a> {
10331095
// Parsing a pattern of the form `fieldname: pat`.
10341096
let fieldname = self.parse_field_name()?;
10351097
self.bump();
1036-
let pat = self.parse_pat_allow_top_alt(None, RecoverComma::No)?;
1098+
let pat = self.parse_pat_allow_top_alt(None, RecoverComma::No, RecoverColon::No)?;
10371099
hi = pat.span;
10381100
(pat, fieldname, false)
10391101
} else {

library/alloc/src/collections/btree/set.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -903,8 +903,8 @@ impl<T> BTreeSet<T> {
903903
self.map.append(&mut other.map);
904904
}
905905

906-
/// Splits the collection into two at the given key. Returns everything after the given key,
907-
/// including the key.
906+
/// Splits the collection into two at the given value. Returns everything after the given value,
907+
/// including the value.
908908
///
909909
/// # Examples
910910
///
@@ -933,11 +933,11 @@ impl<T> BTreeSet<T> {
933933
/// assert!(b.contains(&41));
934934
/// ```
935935
#[stable(feature = "btree_split_off", since = "1.11.0")]
936-
pub fn split_off<Q: ?Sized + Ord>(&mut self, key: &Q) -> Self
936+
pub fn split_off<Q: ?Sized + Ord>(&mut self, value: &Q) -> Self
937937
where
938938
T: Borrow<Q> + Ord,
939939
{
940-
BTreeSet { map: self.map.split_off(key) }
940+
BTreeSet { map: self.map.split_off(value) }
941941
}
942942

943943
/// Creates an iterator that visits all values in ascending order and uses a closure

library/profiler_builtins/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ core = { path = "../core" }
1414
compiler_builtins = { version = "0.1.0", features = ['rustc-dep-of-std'] }
1515

1616
[build-dependencies]
17-
cc = "1.0.68"
17+
cc = "1.0.69"

library/unwind/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ compiler_builtins = "0.1.0"
2121
cfg-if = "0.1.8"
2222

2323
[build-dependencies]
24-
cc = "1.0.68"
24+
cc = "1.0.69"
2525

2626
[features]
2727

src/bootstrap/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ cmake = "0.1.38"
4040
filetime = "0.2"
4141
num_cpus = "1.0"
4242
getopts = "0.2.19"
43-
cc = "1.0.68"
43+
cc = "1.0.69"
4444
libc = "0.2"
4545
serde = { version = "1.0.8", features = ["derive"] }
4646
serde_json = "1.0.2"

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ pre, .rustdoc.source .example-wrap {
161161
.search-results a {
162162
color: #0096cf;
163163
}
164-
.search-results a span.desc {
164+
.search-results a div.desc {
165165
color: #c5c5c5;
166166
}
167167

@@ -286,7 +286,7 @@ details.undocumented > summary::before {
286286
color: grey;
287287
}
288288

289-
tr.result span.primitive::after, tr.result span.keyword::after {
289+
.result-name .primitive > i, .result-name .keyword > i {
290290
color: #788797;
291291
}
292292

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ details.undocumented > summary::before {
247247
color: grey;
248248
}
249249

250-
tr.result span.primitive::after, tr.result span.keyword::after {
250+
.result-name .primitive > i, .result-name .keyword > i {
251251
color: #ddd;
252252
}
253253

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ details.undocumented > summary::before {
237237
color: grey;
238238
}
239239

240-
tr.result span.primitive::after, tr.result span.keyword::after {
240+
.result-name .primitive > i, .result-name .keyword > i {
241241
color: black;
242242
}
243243

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// The goal of this test is to ensure the color of the text is the one expected.
2+
goto: file://|DOC_PATH|/test_docs/index.html?search=coo
3+
4+
// This is needed so that the text color is computed.
5+
show-text: true
6+
7+
// Ayu theme
8+
local-storage: {"rustdoc-theme": "ayu", "rustdoc-preferred-dark-theme": "ayu", "rustdoc-use-system-theme": "false"}
9+
reload:
10+
11+
// Waiting for the search results to appear...
12+
wait-for: "#titles"
13+
assert-css: ("//*[@class='desc']//*[text()='Just a normal struct.']", {"color": "rgb(197, 197, 197)"})
14+
assert-css: ("//*[@class='result-name']/*[text()='test_docs::']", {"color": "rgb(0, 150, 207)"})
15+
16+
// Checking the color for "keyword".
17+
assert-css: ("//*[@class='result-name']//*[text()='(keyword)']", {"color": "rgb(120, 135, 151)"})
18+
19+
// Dark theme
20+
local-storage: {"rustdoc-theme": "dark", "rustdoc-preferred-dark-theme": "dark", "rustdoc-use-system-theme": "false"}
21+
reload:
22+
23+
// Waiting for the search results to appear...
24+
wait-for: "#titles"
25+
assert-css: ("//*[@class='desc']//*[text()='Just a normal struct.']", {"color": "rgb(221, 221, 221)"})
26+
assert-css: ("//*[@class='result-name']/*[text()='test_docs::']", {"color": "rgb(221, 221, 221)"})
27+
28+
// Checking the color for "keyword".
29+
assert-css: ("//*[@class='result-name']//*[text()='(keyword)']", {"color": "rgb(221, 221, 221)"})
30+
31+
// Light theme
32+
local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"}
33+
reload:
34+
35+
// Waiting for the search results to appear...
36+
wait-for: "#titles"
37+
assert-css: ("//*[@class='desc']//*[text()='Just a normal struct.']", {"color": "rgb(0, 0, 0)"})
38+
assert-css: ("//*[@class='result-name']/*[text()='test_docs::']", {"color": "rgb(0, 0, 0)"})
39+
40+
// Checking the color for "keyword".
41+
assert-css: ("//*[@class='result-name']//*[text()='(keyword)']", {"color": "rgb(0, 0, 0)"})

0 commit comments

Comments
 (0)