Skip to content

Commit 4087dea

Browse files
committed
Auto merge of #110249 - matthiaskrgr:rollup-7iig04q, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #110153 (Fix typos in compiler) - #110165 (rustdoc: use CSS `overscroll-behavior` instead of JavaScript) - #110175 (Symbol cleanups) - #110203 (Remove `..` from return type notation) - #110205 (rustdoc: make settings radio and checks thicker, less contrast) - #110222 (Improve the error message when forwarding a matched fragment to another macro) - #110237 (Split out a separate feature gate for impl trait in associated types) - #110241 (tidy: Issue an error when UI test limits are too high) Failed merges: - #110218 (Remove `ToRegionVid`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 59a05ad + 4844164 commit 4087dea

File tree

177 files changed

+635
-555
lines changed

Some content is hidden

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

177 files changed

+635
-555
lines changed

compiler/rustc_ast/src/ast.rs

-4
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,6 @@ pub enum GenericArgs {
167167
AngleBracketed(AngleBracketedArgs),
168168
/// The `(A, B)` and `C` in `Foo(A, B) -> C`.
169169
Parenthesized(ParenthesizedArgs),
170-
/// Associated return type bounds, like `T: Trait<method(..): Send>`
171-
/// which applies the `Send` bound to the return-type of `method`.
172-
ReturnTypeNotation(Span),
173170
}
174171

175172
impl GenericArgs {
@@ -181,7 +178,6 @@ impl GenericArgs {
181178
match self {
182179
AngleBracketed(data) => data.span,
183180
Parenthesized(data) => data.span,
184-
ReturnTypeNotation(span) => *span,
185181
}
186182
}
187183
}

compiler/rustc_ast/src/format.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl FormatArguments {
9494
}
9595
if !matches!(arg.kind, FormatArgumentKind::Captured(..)) {
9696
// This is an explicit argument.
97-
// Make sure that all arguments so far are explcit.
97+
// Make sure that all arguments so far are explicit.
9898
assert_eq!(
9999
self.num_explicit_args,
100100
self.arguments.len(),

compiler/rustc_ast/src/mut_visit.rs

-1
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,6 @@ pub fn noop_visit_generic_args<T: MutVisitor>(generic_args: &mut GenericArgs, vi
561561
match generic_args {
562562
GenericArgs::AngleBracketed(data) => vis.visit_angle_bracketed_parameter_data(data),
563563
GenericArgs::Parenthesized(data) => vis.visit_parenthesized_parameter_data(data),
564-
GenericArgs::ReturnTypeNotation(_span) => {}
565564
}
566565
}
567566

compiler/rustc_ast/src/visit.rs

-1
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,6 @@ where
482482
walk_list!(visitor, visit_ty, &data.inputs);
483483
walk_fn_ret_ty(visitor, &data.output);
484484
}
485-
GenericArgs::ReturnTypeNotation(_span) => {}
486485
}
487486
}
488487

compiler/rustc_ast_lowering/src/errors.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ pub struct AsyncNonMoveClosureNotSupported {
137137

138138
#[derive(Diagnostic, Clone, Copy)]
139139
#[diag(ast_lowering_functional_record_update_destructuring_assignment)]
140-
pub struct FunctionalRecordUpdateDestructuringAssignemnt {
140+
pub struct FunctionalRecordUpdateDestructuringAssignment {
141141
#[primary_span]
142142
#[suggestion(code = "", applicability = "machine-applicable")]
143143
pub span: Span,
@@ -353,13 +353,7 @@ pub enum BadReturnTypeNotation {
353353
#[diag(ast_lowering_bad_return_type_notation_inputs)]
354354
Inputs {
355355
#[primary_span]
356-
#[suggestion(code = "(..)", applicability = "maybe-incorrect")]
357-
span: Span,
358-
},
359-
#[diag(ast_lowering_bad_return_type_notation_needs_dots)]
360-
NeedsDots {
361-
#[primary_span]
362-
#[suggestion(code = "(..)", applicability = "maybe-incorrect")]
356+
#[suggestion(code = "()", applicability = "maybe-incorrect")]
363357
span: Span,
364358
},
365359
#[diag(ast_lowering_bad_return_type_notation_output)]

compiler/rustc_ast_lowering/src/expr.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::errors::{
22
AsyncGeneratorsNotSupported, AsyncNonMoveClosureNotSupported, AwaitOnlyInAsyncFnAndBlocks,
3-
BaseExpressionDoubleDot, ClosureCannotBeStatic, FunctionalRecordUpdateDestructuringAssignemnt,
3+
BaseExpressionDoubleDot, ClosureCannotBeStatic, FunctionalRecordUpdateDestructuringAssignment,
44
GeneratorTooManyParameters, InclusiveRangeWithNoEnd, NotSupportedForLifetimeBinderAsyncClosure,
55
UnderscoreExprLhsAssign,
66
};
@@ -434,7 +434,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
434434
// `if let pat = val` or `if foo && let pat = val`, as we _do_ want `val` to live beyond the
435435
// condition in this case.
436436
//
437-
// In order to mantain the drop behavior for the non `let` parts of the condition,
437+
// In order to maintain the drop behavior for the non `let` parts of the condition,
438438
// we still wrap them in terminating scopes, e.g. `if foo && let pat = val` essentially
439439
// gets transformed into `if { let _t = foo; _t } && let pat = val`
440440
match &cond.kind {
@@ -1232,7 +1232,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
12321232
);
12331233
let fields_omitted = match &se.rest {
12341234
StructRest::Base(e) => {
1235-
self.tcx.sess.emit_err(FunctionalRecordUpdateDestructuringAssignemnt {
1235+
self.tcx.sess.emit_err(FunctionalRecordUpdateDestructuringAssignment {
12361236
span: e.span,
12371237
});
12381238
true

compiler/rustc_ast_lowering/src/lib.rs

+16-11
Original file line numberDiff line numberDiff line change
@@ -987,15 +987,22 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
987987
GenericArgs::AngleBracketed(data) => {
988988
self.lower_angle_bracketed_parameter_data(data, ParamMode::Explicit, itctx).0
989989
}
990-
&GenericArgs::ReturnTypeNotation(span) => GenericArgsCtor {
991-
args: Default::default(),
992-
bindings: &[],
993-
parenthesized: hir::GenericArgsParentheses::ReturnTypeNotation,
994-
span,
995-
},
996990
GenericArgs::Parenthesized(data) => {
997-
if let Some(start_char) = constraint.ident.as_str().chars().next()
998-
&& start_char.is_ascii_lowercase()
991+
if data.inputs.is_empty() && matches!(data.output, FnRetTy::Default(..)) {
992+
let parenthesized = if self.tcx.features().return_type_notation {
993+
hir::GenericArgsParentheses::ReturnTypeNotation
994+
} else {
995+
self.emit_bad_parenthesized_trait_in_assoc_ty(data);
996+
hir::GenericArgsParentheses::No
997+
};
998+
GenericArgsCtor {
999+
args: Default::default(),
1000+
bindings: &[],
1001+
parenthesized,
1002+
span: data.inputs_span,
1003+
}
1004+
} else if let Some(first_char) = constraint.ident.as_str().chars().next()
1005+
&& first_char.is_ascii_lowercase()
9991006
{
10001007
let mut err = if !data.inputs.is_empty() {
10011008
self.tcx.sess.create_err(errors::BadReturnTypeNotation::Inputs {
@@ -1006,9 +1013,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
10061013
span: data.inputs_span.shrink_to_hi().to(ty.span),
10071014
})
10081015
} else {
1009-
self.tcx.sess.create_err(errors::BadReturnTypeNotation::NeedsDots {
1010-
span: data.inputs_span,
1011-
})
1016+
unreachable!("inputs are empty and return type is not provided")
10121017
};
10131018
if !self.tcx.features().return_type_notation
10141019
&& self.tcx.sess.is_nightly_build()

compiler/rustc_ast_lowering/src/path.rs

-13
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use rustc_span::symbol::{kw, sym, Ident};
1313
use rustc_span::{BytePos, Span, DUMMY_SP};
1414

1515
use smallvec::{smallvec, SmallVec};
16-
use thin_vec::ThinVec;
1716

1817
impl<'a, 'hir> LoweringContext<'a, 'hir> {
1918
#[instrument(level = "trace", skip(self))]
@@ -219,18 +218,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
219218
)
220219
}
221220
},
222-
&GenericArgs::ReturnTypeNotation(span) => {
223-
self.tcx.sess.emit_err(GenericTypeWithParentheses { span, sub: None });
224-
(
225-
self.lower_angle_bracketed_parameter_data(
226-
&AngleBracketedArgs { span, args: ThinVec::default() },
227-
param_mode,
228-
itctx,
229-
)
230-
.0,
231-
false,
232-
)
233-
}
234221
}
235222
} else {
236223
(

compiler/rustc_ast_passes/src/ast_validation.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,6 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
10801080
self.with_impl_trait(None, |this| this.visit_ty(ty));
10811081
}
10821082
}
1083-
GenericArgs::ReturnTypeNotation(_span) => {}
10841083
}
10851084
}
10861085

@@ -1391,7 +1390,6 @@ fn deny_equality_constraints(
13911390
match &mut assoc_path.segments[len].args {
13921391
Some(args) => match args.deref_mut() {
13931392
GenericArgs::Parenthesized(_) => continue,
1394-
GenericArgs::ReturnTypeNotation(_span) => continue,
13951393
GenericArgs::AngleBracketed(args) => {
13961394
args.args.push(arg);
13971395
}

compiler/rustc_ast_passes/src/feature_gate.rs

+31-18
Original file line numberDiff line numberDiff line change
@@ -121,24 +121,34 @@ impl<'a> PostExpansionVisitor<'a> {
121121
}
122122

123123
/// Feature gate `impl Trait` inside `type Alias = $type_expr;`.
124-
fn check_impl_trait(&self, ty: &ast::Ty) {
124+
fn check_impl_trait(&self, ty: &ast::Ty, in_associated_ty: bool) {
125125
struct ImplTraitVisitor<'a> {
126126
vis: &'a PostExpansionVisitor<'a>,
127+
in_associated_ty: bool,
127128
}
128129
impl Visitor<'_> for ImplTraitVisitor<'_> {
129130
fn visit_ty(&mut self, ty: &ast::Ty) {
130131
if let ast::TyKind::ImplTrait(..) = ty.kind {
131-
gate_feature_post!(
132-
&self.vis,
133-
type_alias_impl_trait,
134-
ty.span,
135-
"`impl Trait` in type aliases is unstable"
136-
);
132+
if self.in_associated_ty {
133+
gate_feature_post!(
134+
&self.vis,
135+
impl_trait_in_assoc_type,
136+
ty.span,
137+
"`impl Trait` in associated types is unstable"
138+
);
139+
} else {
140+
gate_feature_post!(
141+
&self.vis,
142+
type_alias_impl_trait,
143+
ty.span,
144+
"`impl Trait` in type aliases is unstable"
145+
);
146+
}
137147
}
138148
visit::walk_ty(self, ty);
139149
}
140150
}
141-
ImplTraitVisitor { vis: self }.visit_ty(ty);
151+
ImplTraitVisitor { vis: self, in_associated_ty }.visit_ty(ty);
142152
}
143153

144154
fn check_late_bound_lifetime_defs(&self, params: &[ast::GenericParam]) {
@@ -294,7 +304,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
294304
}
295305

296306
ast::ItemKind::TyAlias(box ast::TyAlias { ty: Some(ty), .. }) => {
297-
self.check_impl_trait(&ty)
307+
self.check_impl_trait(&ty, false)
298308
}
299309

300310
_ => {}
@@ -485,20 +495,23 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
485495

486496
fn visit_assoc_constraint(&mut self, constraint: &'a AssocConstraint) {
487497
if let AssocConstraintKind::Bound { .. } = constraint.kind {
488-
if let Some(args) = constraint.gen_args.as_ref()
489-
&& matches!(
490-
args,
491-
ast::GenericArgs::ReturnTypeNotation(..)
492-
)
498+
if let Some(ast::GenericArgs::Parenthesized(args)) = constraint.gen_args.as_ref()
499+
&& args.inputs.is_empty()
500+
&& matches!(args.output, ast::FnRetTy::Default(..))
493501
{
494-
// RTN is gated below with a `gate_all`.
502+
gate_feature_post!(
503+
&self,
504+
return_type_notation,
505+
constraint.span,
506+
"return type notation is experimental"
507+
);
495508
} else {
496509
gate_feature_post!(
497510
&self,
498511
associated_type_bounds,
499512
constraint.span,
500513
"associated type bounds are unstable"
501-
)
514+
);
502515
}
503516
}
504517
visit::walk_assoc_constraint(self, constraint)
@@ -517,7 +530,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
517530
);
518531
}
519532
if let Some(ty) = ty {
520-
self.check_impl_trait(ty);
533+
self.check_impl_trait(ty, true);
521534
}
522535
false
523536
}
@@ -589,7 +602,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session) {
589602
gate_all!(yeet_expr, "`do yeet` expression is experimental");
590603
gate_all!(dyn_star, "`dyn*` trait objects are experimental");
591604
gate_all!(const_closures, "const closures are experimental");
592-
gate_all!(return_type_notation, "return type notation is experimental");
593605

594606
// All uses of `gate_all!` below this point were added in #65742,
595607
// and subsequently disabled (with the non-early gating readded).
@@ -605,6 +617,7 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session) {
605617

606618
gate_all!(trait_alias, "trait aliases are experimental");
607619
gate_all!(associated_type_bounds, "associated type bounds are unstable");
620+
gate_all!(return_type_notation, "return type notation is experimental");
608621
gate_all!(decl_macro, "`macro` is experimental");
609622
gate_all!(box_patterns, "box pattern syntax is experimental");
610623
gate_all!(exclusive_range_pattern, "exclusive range pattern syntax is experimental");

compiler/rustc_ast_pretty/src/pprust/state.rs

-4
Original file line numberDiff line numberDiff line change
@@ -936,10 +936,6 @@ impl<'a> PrintState<'a> for State<'a> {
936936
self.word(")");
937937
self.print_fn_ret_ty(&data.output);
938938
}
939-
940-
ast::GenericArgs::ReturnTypeNotation(_span) => {
941-
self.word("(..)");
942-
}
943939
}
944940
}
945941
}

0 commit comments

Comments
 (0)