Skip to content

Commit b454012

Browse files
committed
Auto merge of rust-lang#127296 - matthiaskrgr:rollup-1t1isa7, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - rust-lang#127092 (Change return-type-notation to use `(..)`) - rust-lang#127184 (More refactorings to rustc_interface) - rust-lang#127190 (Update LLVM submodule) - rust-lang#127253 (Fix incorrect suggestion for extra argument with a type error) - rust-lang#127280 (Disable rmake test rustdoc-io-error on riscv64gc-gnu) - rust-lang#127294 (Less magic number for corountine) r? `@ghost` `@rustbot` modify labels: rollup
2 parents aa1d4f6 + 79bdb89 commit b454012

File tree

63 files changed

+478
-235
lines changed

Some content is hidden

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

63 files changed

+478
-235
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ pub enum GenericArgs {
176176
AngleBracketed(AngleBracketedArgs),
177177
/// The `(A, B)` and `C` in `Foo(A, B) -> C`.
178178
Parenthesized(ParenthesizedArgs),
179+
/// `(..)` in return type notation
180+
ParenthesizedElided(Span),
179181
}
180182

181183
impl GenericArgs {
@@ -187,6 +189,7 @@ impl GenericArgs {
187189
match self {
188190
AngleBracketed(data) => data.span,
189191
Parenthesized(data) => data.span,
192+
ParenthesizedElided(span) => *span,
190193
}
191194
}
192195
}
@@ -2051,7 +2054,7 @@ impl UintTy {
20512054
/// * the `A: Bound` in `Trait<A: Bound>`
20522055
/// * the `RetTy` in `Trait(ArgTy, ArgTy) -> RetTy`
20532056
/// * the `C = { Ct }` in `Trait<C = { Ct }>` (feature `associated_const_equality`)
2054-
/// * the `f(): Bound` in `Trait<f(): Bound>` (feature `return_type_notation`)
2057+
/// * the `f(..): Bound` in `Trait<f(..): Bound>` (feature `return_type_notation`)
20552058
#[derive(Clone, Encodable, Decodable, Debug)]
20562059
pub struct AssocItemConstraint {
20572060
pub id: NodeId,

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,7 @@ fn noop_visit_generic_args<T: MutVisitor>(generic_args: &mut GenericArgs, vis: &
582582
match generic_args {
583583
GenericArgs::AngleBracketed(data) => vis.visit_angle_bracketed_parameter_data(data),
584584
GenericArgs::Parenthesized(data) => vis.visit_parenthesized_parameter_data(data),
585+
GenericArgs::ParenthesizedElided(span) => vis.visit_span(span),
585586
}
586587
}
587588

compiler/rustc_ast/src/util/classify.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,6 @@ fn path_return_type(path: &ast::Path) -> Option<&ast::Ty> {
311311
ast::FnRetTy::Default(_) => None,
312312
ast::FnRetTy::Ty(ret) => Some(ret),
313313
},
314-
ast::GenericArgs::AngleBracketed(_) => None,
314+
ast::GenericArgs::AngleBracketed(_) | ast::GenericArgs::ParenthesizedElided(_) => None,
315315
}
316316
}

compiler/rustc_ast/src/visit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,7 @@ where
609609
walk_list!(visitor, visit_ty, inputs);
610610
try_visit!(visitor.visit_fn_ret_ty(output));
611611
}
612+
GenericArgs::ParenthesizedElided(_span) => {}
612613
}
613614
V::Result::output()
614615
}

compiler/rustc_ast_lowering/messages.ftl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,15 @@ ast_lowering_bad_return_type_notation_inputs =
3636
argument types not allowed with return type notation
3737
.suggestion = remove the input types
3838
39+
ast_lowering_bad_return_type_notation_needs_dots = return type notation arguments must be elided with `..`
40+
.suggestion = add `..`
41+
3942
ast_lowering_bad_return_type_notation_output =
4043
return type not allowed with return type notation
4144
.suggestion = remove the return type
4245
46+
ast_lowering_bad_return_type_notation_position = return type notation not allowed in this position yet
47+
4348
ast_lowering_base_expression_double_dot =
4449
base expression required after `..`
4550
.suggestion = add a base expression here

compiler/rustc_ast_lowering/src/errors.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,17 @@ pub enum BadReturnTypeNotation {
393393
#[suggestion(code = "", applicability = "maybe-incorrect")]
394394
span: Span,
395395
},
396+
#[diag(ast_lowering_bad_return_type_notation_needs_dots)]
397+
NeedsDots {
398+
#[primary_span]
399+
#[suggestion(code = "(..)", applicability = "maybe-incorrect")]
400+
span: Span,
401+
},
402+
#[diag(ast_lowering_bad_return_type_notation_position)]
403+
Position {
404+
#[primary_span]
405+
span: Span,
406+
},
396407
}
397408

398409
#[derive(Diagnostic)]

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -985,20 +985,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
985985
self.lower_angle_bracketed_parameter_data(data, ParamMode::Explicit, itctx).0
986986
}
987987
GenericArgs::Parenthesized(data) => {
988-
if data.inputs.is_empty() && matches!(data.output, FnRetTy::Default(..)) {
989-
let parenthesized = if self.tcx.features().return_type_notation {
990-
hir::GenericArgsParentheses::ReturnTypeNotation
991-
} else {
992-
self.emit_bad_parenthesized_trait_in_assoc_ty(data);
993-
hir::GenericArgsParentheses::No
994-
};
995-
GenericArgsCtor {
996-
args: Default::default(),
997-
constraints: &[],
998-
parenthesized,
999-
span: data.inputs_span,
1000-
}
1001-
} else if let Some(first_char) = constraint.ident.as_str().chars().next()
988+
if let Some(first_char) = constraint.ident.as_str().chars().next()
1002989
&& first_char.is_ascii_lowercase()
1003990
{
1004991
let mut err = if !data.inputs.is_empty() {
@@ -1010,7 +997,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1010997
span: data.inputs_span.shrink_to_hi().to(ty.span),
1011998
})
1012999
} else {
1013-
unreachable!("inputs are empty and return type is not provided")
1000+
self.dcx().create_err(errors::BadReturnTypeNotation::NeedsDots {
1001+
span: data.inputs_span,
1002+
})
10141003
};
10151004
if !self.tcx.features().return_type_notation
10161005
&& self.tcx.sess.is_nightly_build()
@@ -1040,6 +1029,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
10401029
.0
10411030
}
10421031
}
1032+
GenericArgs::ParenthesizedElided(span) => GenericArgsCtor {
1033+
args: Default::default(),
1034+
constraints: &[],
1035+
parenthesized: hir::GenericArgsParentheses::ReturnTypeNotation,
1036+
span: *span,
1037+
},
10431038
};
10441039
gen_args_ctor.into_generic_args(self)
10451040
} else {

compiler/rustc_ast_lowering/src/path.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use crate::ImplTraitPosition;
22

33
use super::errors::{
4-
AsyncBoundNotOnTrait, AsyncBoundOnlyForFnTraits, GenericTypeWithParentheses, UseAngleBrackets,
4+
AsyncBoundNotOnTrait, AsyncBoundOnlyForFnTraits, BadReturnTypeNotation,
5+
GenericTypeWithParentheses, UseAngleBrackets,
56
};
67
use super::ResolverAstLoweringExt;
78
use super::{GenericArgsCtor, LifetimeRes, ParenthesizedGenericArgs};
@@ -271,6 +272,18 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
271272
)
272273
}
273274
},
275+
GenericArgs::ParenthesizedElided(span) => {
276+
self.dcx().emit_err(BadReturnTypeNotation::Position { span: *span });
277+
(
278+
GenericArgsCtor {
279+
args: Default::default(),
280+
constraints: &[],
281+
parenthesized: hir::GenericArgsParentheses::ReturnTypeNotation,
282+
span: *span,
283+
},
284+
false,
285+
)
286+
}
274287
}
275288
} else {
276289
(

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,6 +1312,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
13121312
self.with_impl_trait(None, |this| this.visit_ty(ty));
13131313
}
13141314
}
1315+
GenericArgs::ParenthesizedElided(_span) => {}
13151316
}
13161317
}
13171318

@@ -1468,7 +1469,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
14681469
span: args.span,
14691470
});
14701471
}
1471-
None => {}
1472+
Some(ast::GenericArgs::ParenthesizedElided(_)) | None => {}
14721473
}
14731474
}
14741475
}
@@ -1716,7 +1717,9 @@ fn deny_equality_constraints(
17161717
// Add `<Bar = RhsTy>` to `Foo`.
17171718
match &mut assoc_path.segments[len].args {
17181719
Some(args) => match args.deref_mut() {
1719-
GenericArgs::Parenthesized(_) => continue,
1720+
GenericArgs::Parenthesized(_) | GenericArgs::ParenthesizedElided(..) => {
1721+
continue;
1722+
}
17201723
GenericArgs::AngleBracketed(args) => {
17211724
args.args.push(arg);
17221725
}

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use rustc_ast as ast;
22
use rustc_ast::visit::{self, AssocCtxt, FnCtxt, FnKind, Visitor};
3-
use rustc_ast::{attr, AssocItemConstraint, AssocItemConstraintKind, NodeId};
3+
use rustc_ast::{attr, NodeId};
44
use rustc_ast::{token, PatKind};
55
use rustc_feature::{AttributeGate, BuiltinAttribute, Features, GateIssue, BUILTIN_ATTRIBUTE_MAP};
66
use rustc_session::parse::{feature_err, feature_err_issue, feature_warn};
@@ -445,23 +445,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
445445
visit::walk_fn(self, fn_kind)
446446
}
447447

448-
fn visit_assoc_item_constraint(&mut self, constraint: &'a AssocItemConstraint) {
449-
if let AssocItemConstraintKind::Bound { .. } = constraint.kind
450-
&& let Some(ast::GenericArgs::Parenthesized(args)) = constraint.gen_args.as_ref()
451-
&& args.inputs.is_empty()
452-
&& let ast::FnRetTy::Default(..) = args.output
453-
{
454-
gate!(
455-
&self,
456-
return_type_notation,
457-
constraint.span,
458-
"return type notation is experimental"
459-
);
460-
}
461-
462-
visit::walk_assoc_item_constraint(self, constraint)
463-
}
464-
465448
fn visit_assoc_item(&mut self, i: &'a ast::AssocItem, ctxt: AssocCtxt) {
466449
let is_fn = match &i.kind {
467450
ast::AssocItemKind::Fn(_) => true,
@@ -566,6 +549,7 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
566549
unsafe_extern_blocks,
567550
"`unsafe extern {}` blocks and `safe` keyword are experimental"
568551
);
552+
gate_all!(return_type_notation, "return type notation is experimental");
569553

570554
if !visitor.features.never_patterns {
571555
if let Some(spans) = spans.get(&sym::never_patterns) {
@@ -611,10 +595,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
611595

612596
gate_all_legacy_dont_use!(box_patterns, "box pattern syntax is experimental");
613597
gate_all_legacy_dont_use!(trait_alias, "trait aliases are experimental");
614-
// Despite being a new feature, `where T: Trait<Assoc(): Sized>`, which is RTN syntax now,
615-
// used to be gated under associated_type_bounds, which are right above, so RTN needs to
616-
// be too.
617-
gate_all_legacy_dont_use!(return_type_notation, "return type notation is experimental");
618598
gate_all_legacy_dont_use!(decl_macro, "`macro` is experimental");
619599
gate_all_legacy_dont_use!(try_blocks, "`try` blocks are unstable");
620600
gate_all_legacy_dont_use!(auto_traits, "`auto` traits are unstable");

0 commit comments

Comments
 (0)