Skip to content

Commit a804c4b

Browse files
committed
Auto merge of #89545 - workingjubilee:rollup-ooxf3p2, r=workingjubilee
Rollup of 15 pull requests Successful merges: - #87993 (Stabilize try_reserve) - #88090 (Perform type inference in range pattern) - #88780 (Added abs_diff for integer types.) - #89270 (path.push() should work as expected on windows verbatim paths) - #89413 (Correctly handle supertraits for min_specialization) - #89456 (Update to the final LLVM 13.0.0 release) - #89466 (Fix bug with query modifier parsing) - #89473 (Fix extra `non_snake_case` warning for shorthand field bindings) - #89474 (rustdoc: Improve doctest pass's name and module's name) - #89478 (Fixed numerus of error message) - #89480 (Add test for issue 89118.) - #89487 (Try to recover from a `=>` -> `=` or `->` typo in a match arm) - #89494 (Deny `where` clauses on `auto` traits) - #89511 (:arrow_up: rust-analyzer) - #89536 (update Miri) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 003d8d3 + 2ae8ced commit a804c4b

File tree

81 files changed

+787
-297
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+787
-297
lines changed

Diff for: .gitmodules

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
[submodule "src/llvm-project"]
3535
path = src/llvm-project
3636
url = https://github.com/rust-lang/llvm-project.git
37-
branch = rustc/13.0-2021-08-08
37+
branch = rustc/13.0-2021-09-30
3838
[submodule "src/doc/embedded-book"]
3939
path = src/doc/embedded-book
4040
url = https://github.com/rust-embedded/book.git

Diff for: Cargo.lock

+14-18
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ version = "0.1.0"
360360
dependencies = [
361361
"directories",
362362
"rustc-workspace-hack",
363-
"rustc_version",
363+
"rustc_version 0.3.3",
364364
"serde",
365365
"serde_json",
366366
"vergen",
@@ -1092,19 +1092,6 @@ dependencies = [
10921092
"termcolor",
10931093
]
10941094

1095-
[[package]]
1096-
name = "env_logger"
1097-
version = "0.8.1"
1098-
source = "registry+https://github.com/rust-lang/crates.io-index"
1099-
checksum = "54532e3223c5af90a6a757c90b5c5521564b07e5e7a958681bcd2afad421cdcd"
1100-
dependencies = [
1101-
"atty",
1102-
"humantime 2.0.1",
1103-
"log",
1104-
"regex",
1105-
"termcolor",
1106-
]
1107-
11081095
[[package]]
11091096
name = "env_logger"
11101097
version = "0.9.0"
@@ -2250,15 +2237,15 @@ version = "0.1.0"
22502237
dependencies = [
22512238
"colored",
22522239
"compiletest_rs",
2253-
"env_logger 0.8.1",
2240+
"env_logger 0.9.0",
22542241
"getrandom 0.2.0",
22552242
"hex 0.4.2",
22562243
"libc",
22572244
"log",
22582245
"measureme",
22592246
"rand 0.8.4",
22602247
"rustc-workspace-hack",
2261-
"rustc_version",
2248+
"rustc_version 0.4.0",
22622249
"shell-escape",
22632250
"smallvec",
22642251
]
@@ -4548,6 +4535,15 @@ dependencies = [
45484535
"semver 0.11.0",
45494536
]
45504537

4538+
[[package]]
4539+
name = "rustc_version"
4540+
version = "0.4.0"
4541+
source = "registry+https://github.com/rust-lang/crates.io-index"
4542+
checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
4543+
dependencies = [
4544+
"semver 1.0.3",
4545+
]
4546+
45514547
[[package]]
45524548
name = "rustdoc"
45534549
version = "0.0.0"
@@ -4908,9 +4904,9 @@ checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
49084904

49094905
[[package]]
49104906
name = "smallvec"
4911-
version = "1.6.1"
4907+
version = "1.7.0"
49124908
source = "registry+https://github.com/rust-lang/crates.io-index"
4913-
checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
4909+
checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309"
49144910

49154911
[[package]]
49164912
name = "snap"

Diff for: compiler/rustc_ast/src/token.rs

+1
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ impl TokenKind {
295295
match *self {
296296
Comma => Some(vec![Dot, Lt, Semi]),
297297
Semi => Some(vec![Colon, Comma]),
298+
FatArrow => Some(vec![Eq, RArrow]),
298299
_ => None,
299300
}
300301
}

Diff for: compiler/rustc_ast_passes/src/ast_validation.rs

+36-13
Original file line numberDiff line numberDiff line change
@@ -683,31 +683,53 @@ impl<'a> AstValidator<'a> {
683683
}
684684
}
685685

686+
fn emit_e0568(&self, span: Span, ident_span: Span) {
687+
struct_span_err!(
688+
self.session,
689+
span,
690+
E0568,
691+
"auto traits cannot have super traits or lifetime bounds"
692+
)
693+
.span_label(ident_span, "auto trait cannot have super traits or lifetime bounds")
694+
.span_suggestion(
695+
span,
696+
"remove the super traits or lifetime bounds",
697+
String::new(),
698+
Applicability::MachineApplicable,
699+
)
700+
.emit();
701+
}
702+
686703
fn deny_super_traits(&self, bounds: &GenericBounds, ident_span: Span) {
687-
if let [first @ last] | [first, .., last] = &bounds[..] {
688-
let span = first.span().to(last.span());
689-
struct_span_err!(self.session, span, E0568, "auto traits cannot have super traits")
690-
.span_label(ident_span, "auto trait cannot have super traits")
691-
.span_suggestion(
692-
span,
693-
"remove the super traits",
694-
String::new(),
695-
Applicability::MachineApplicable,
696-
)
697-
.emit();
704+
if let [.., last] = &bounds[..] {
705+
let span = ident_span.shrink_to_hi().to(last.span());
706+
self.emit_e0568(span, ident_span);
707+
}
708+
}
709+
710+
fn deny_where_clause(&self, where_clause: &WhereClause, ident_span: Span) {
711+
if !where_clause.predicates.is_empty() {
712+
self.emit_e0568(where_clause.span, ident_span);
698713
}
699714
}
700715

701716
fn deny_items(&self, trait_items: &[P<AssocItem>], ident_span: Span) {
702717
if !trait_items.is_empty() {
703718
let spans: Vec<_> = trait_items.iter().map(|i| i.ident.span).collect();
719+
let total_span = trait_items.first().unwrap().span.to(trait_items.last().unwrap().span);
704720
struct_span_err!(
705721
self.session,
706722
spans,
707723
E0380,
708-
"auto traits cannot have methods or associated items"
724+
"auto traits cannot have associated items"
725+
)
726+
.span_suggestion(
727+
total_span,
728+
"remove these associated items",
729+
String::new(),
730+
Applicability::MachineApplicable,
709731
)
710-
.span_label(ident_span, "auto trait cannot have items")
732+
.span_label(ident_span, "auto trait cannot have associated items")
711733
.emit();
712734
}
713735
}
@@ -1184,6 +1206,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
11841206
// Auto traits cannot have generics, super traits nor contain items.
11851207
self.deny_generic_params(generics, item.ident.span);
11861208
self.deny_super_traits(bounds, item.ident.span);
1209+
self.deny_where_clause(&generics.where_clause, item.ident.span);
11871210
self.deny_items(trait_items, item.ident.span);
11881211
}
11891212
self.no_questions_in_bounds(bounds, "supertraits", true);

Diff for: compiler/rustc_data_structures/src/sso/map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const SSO_ARRAY_SIZE: usize = 8;
3131
//
3232
// Missing HashMap API:
3333
// all hasher-related
34-
// try_reserve (unstable)
34+
// try_reserve
3535
// shrink_to (unstable)
3636
// drain_filter (unstable)
3737
// into_keys/into_values (unstable)

Diff for: compiler/rustc_data_structures/src/sso/set.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use super::map::SsoHashMap;
1313
//
1414
// Missing HashSet API:
1515
// all hasher-related
16-
// try_reserve (unstable)
16+
// try_reserve
1717
// shrink_to (unstable)
1818
// drain_filter (unstable)
1919
// replace

Diff for: compiler/rustc_lint/src/nonstandard_style.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -437,12 +437,13 @@ impl<'tcx> LateLintPass<'tcx> for NonSnakeCase {
437437
if let hir::Node::Pat(parent_pat) = cx.tcx.hir().get(cx.tcx.hir().get_parent_node(hid))
438438
{
439439
if let PatKind::Struct(_, field_pats, _) = &parent_pat.kind {
440-
for field in field_pats.iter() {
441-
if field.ident != ident {
442-
// Only check if a new name has been introduced, to avoid warning
443-
// on both the struct definition and this pattern.
444-
self.check_snake_case(cx, "variable", &ident);
445-
}
440+
if field_pats
441+
.iter()
442+
.any(|field| !field.is_shorthand && field.pat.hir_id == p.hir_id)
443+
{
444+
// Only check if a new name has been introduced, to avoid warning
445+
// on both the struct definition and this pattern.
446+
self.check_snake_case(cx, "variable", &ident);
446447
}
447448
return;
448449
}

Diff for: compiler/rustc_macros/src/query.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -455,28 +455,28 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
455455

456456
// Pass on the fatal_cycle modifier
457457
if let Some(fatal_cycle) = &modifiers.fatal_cycle {
458-
attributes.push(quote! { #fatal_cycle });
458+
attributes.push(quote! { (#fatal_cycle) });
459459
};
460460
// Pass on the storage modifier
461461
if let Some(ref ty) = modifiers.storage {
462462
let span = ty.span();
463-
attributes.push(quote_spanned! {span=> storage(#ty) });
463+
attributes.push(quote_spanned! {span=> (storage #ty) });
464464
};
465465
// Pass on the cycle_delay_bug modifier
466466
if let Some(cycle_delay_bug) = &modifiers.cycle_delay_bug {
467-
attributes.push(quote! { #cycle_delay_bug });
467+
attributes.push(quote! { (#cycle_delay_bug) });
468468
};
469469
// Pass on the no_hash modifier
470470
if let Some(no_hash) = &modifiers.no_hash {
471-
attributes.push(quote! { #no_hash });
471+
attributes.push(quote! { (#no_hash) });
472472
};
473473
// Pass on the anon modifier
474474
if let Some(anon) = &modifiers.anon {
475-
attributes.push(quote! { #anon });
475+
attributes.push(quote! { (#anon) });
476476
};
477477
// Pass on the eval_always modifier
478478
if let Some(eval_always) = &modifiers.eval_always {
479-
attributes.push(quote! { #eval_always });
479+
attributes.push(quote! { (#eval_always) });
480480
};
481481

482482
// This uses the span of the query definition for the commas,

Diff for: compiler/rustc_middle/src/dep_graph/dep_node.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,11 @@ macro_rules! is_eval_always_attr {
140140
}
141141

142142
macro_rules! contains_anon_attr {
143-
($($attr:ident $(($($attr_args:tt)*))* ),*) => ({$(is_anon_attr!($attr) | )* false});
143+
($(($attr:ident $($attr_args:tt)* )),*) => ({$(is_anon_attr!($attr) | )* false});
144144
}
145145

146146
macro_rules! contains_eval_always_attr {
147-
($($attr:ident $(($($attr_args:tt)*))* ),*) => ({$(is_eval_always_attr!($attr) | )* false});
147+
($(($attr:ident $($attr_args:tt)* )),*) => ({$(is_eval_always_attr!($attr) | )* false});
148148
}
149149

150150
#[allow(non_upper_case_globals)]

Diff for: compiler/rustc_middle/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
#![feature(thread_local_const_init)]
5353
#![feature(trusted_step)]
5454
#![feature(try_blocks)]
55-
#![feature(try_reserve)]
5655
#![feature(try_reserve_kind)]
5756
#![feature(nonzero_ops)]
5857
#![recursion_limit = "512"]

Diff for: compiler/rustc_middle/src/ty/query.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ macro_rules! query_storage {
111111
([][$K:ty, $V:ty]) => {
112112
<DefaultCacheSelector as CacheSelector<$K, $V>>::Cache
113113
};
114-
([storage($ty:ty) $($rest:tt)*][$K:ty, $V:ty]) => {
114+
([(storage $ty:ty) $($rest:tt)*][$K:ty, $V:ty]) => {
115115
<$ty as CacheSelector<$K, $V>>::Cache
116116
};
117-
([$other:ident $(($($other_args:tt)*))* $(, $($modifiers:tt)*)*][$($args:tt)*]) => {
118-
query_storage!([$($($modifiers)*)*][$($args)*])
117+
([$other:tt $($modifiers:tt)*][$($args:tt)*]) => {
118+
query_storage!([$($modifiers)*][$($args)*])
119119
};
120120
}
121121

Diff for: compiler/rustc_parse/src/parser/expr.rs

+18-1
Original file line numberDiff line numberDiff line change
@@ -2322,7 +2322,24 @@ impl<'a> Parser<'a> {
23222322
None
23232323
};
23242324
let arrow_span = this.token.span;
2325-
this.expect(&token::FatArrow)?;
2325+
if let Err(mut err) = this.expect(&token::FatArrow) {
2326+
// We might have a `=>` -> `=` or `->` typo (issue #89396).
2327+
if TokenKind::FatArrow
2328+
.similar_tokens()
2329+
.map_or(false, |similar_tokens| similar_tokens.contains(&this.token.kind))
2330+
{
2331+
err.span_suggestion(
2332+
this.token.span,
2333+
"try using a fat arrow here",
2334+
"=>".to_string(),
2335+
Applicability::MaybeIncorrect,
2336+
);
2337+
err.emit();
2338+
this.bump();
2339+
} else {
2340+
return Err(err);
2341+
}
2342+
}
23262343
let arm_start_span = this.token.span;
23272344

23282345
let expr = this.parse_expr_res(Restrictions::STMT_EXPR, None).map_err(|mut err| {

Diff for: compiler/rustc_query_impl/src/plumbing.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -253,53 +253,53 @@ macro_rules! handle_cycle_error {
253253
$error.emit();
254254
Value::from_cycle_error($tcx)
255255
}};
256-
([fatal_cycle $($rest:tt)*][$tcx:expr, $error:expr]) => {{
256+
([(fatal_cycle) $($rest:tt)*][$tcx:expr, $error:expr]) => {{
257257
$error.emit();
258258
$tcx.sess.abort_if_errors();
259259
unreachable!()
260260
}};
261-
([cycle_delay_bug $($rest:tt)*][$tcx:expr, $error:expr]) => {{
261+
([(cycle_delay_bug) $($rest:tt)*][$tcx:expr, $error:expr]) => {{
262262
$error.delay_as_bug();
263263
Value::from_cycle_error($tcx)
264264
}};
265-
([$other:ident $(($($other_args:tt)*))* $(, $($modifiers:tt)*)*][$($args:tt)*]) => {
266-
handle_cycle_error!([$($($modifiers)*)*][$($args)*])
265+
([$other:tt $($modifiers:tt)*][$($args:tt)*]) => {
266+
handle_cycle_error!([$($modifiers)*][$($args)*])
267267
};
268268
}
269269

270270
macro_rules! is_anon {
271271
([]) => {{
272272
false
273273
}};
274-
([anon $($rest:tt)*]) => {{
274+
([(anon) $($rest:tt)*]) => {{
275275
true
276276
}};
277-
([$other:ident $(($($other_args:tt)*))* $(, $($modifiers:tt)*)*]) => {
278-
is_anon!([$($($modifiers)*)*])
277+
([$other:tt $($modifiers:tt)*]) => {
278+
is_anon!([$($modifiers)*])
279279
};
280280
}
281281

282282
macro_rules! is_eval_always {
283283
([]) => {{
284284
false
285285
}};
286-
([eval_always $($rest:tt)*]) => {{
286+
([(eval_always) $($rest:tt)*]) => {{
287287
true
288288
}};
289-
([$other:ident $(($($other_args:tt)*))* $(, $($modifiers:tt)*)*]) => {
290-
is_eval_always!([$($($modifiers)*)*])
289+
([$other:tt $($modifiers:tt)*]) => {
290+
is_eval_always!([$($modifiers)*])
291291
};
292292
}
293293

294294
macro_rules! hash_result {
295295
([][$hcx:expr, $result:expr]) => {{
296296
dep_graph::hash_result($hcx, &$result)
297297
}};
298-
([no_hash $($rest:tt)*][$hcx:expr, $result:expr]) => {{
298+
([(no_hash) $($rest:tt)*][$hcx:expr, $result:expr]) => {{
299299
None
300300
}};
301-
([$other:ident $(($($other_args:tt)*))* $(, $($modifiers:tt)*)*][$($args:tt)*]) => {
302-
hash_result!([$($($modifiers)*)*][$($args)*])
301+
([$other:tt $($modifiers:tt)*][$($args:tt)*]) => {
302+
hash_result!([$($modifiers)*][$($args)*])
303303
};
304304
}
305305

Diff for: compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ use crate::traits::normalize_projection_type;
1010
use rustc_data_structures::fx::FxHashSet;
1111
use rustc_data_structures::stack::ensure_sufficient_stack;
1212
use rustc_data_structures::sync::Lrc;
13-
use rustc_errors::{error_code, struct_span_err, Applicability, DiagnosticBuilder, Style};
13+
use rustc_errors::{
14+
error_code, pluralize, struct_span_err, Applicability, DiagnosticBuilder, Style,
15+
};
1416
use rustc_hir as hir;
1517
use rustc_hir::def::DefKind;
1618
use rustc_hir::def_id::DefId;
@@ -2273,7 +2275,11 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
22732275
parent_trait_ref = child_trait_ref;
22742276
}
22752277
if count > 0 {
2276-
err.note(&format!("{} redundant requirements hidden", count));
2278+
err.note(&format!(
2279+
"{} redundant requirement{} hidden",
2280+
count,
2281+
pluralize!(count)
2282+
));
22772283
err.note(&format!(
22782284
"required because of the requirements on the impl of `{}` for `{}`",
22792285
parent_trait_ref.print_only_trait_path(),

0 commit comments

Comments
 (0)