Skip to content

parser: Remove old diagnostic notes for type ascription syntax #139908

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions compiler/rustc_parse/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -806,9 +806,6 @@ parse_trait_alias_cannot_be_unsafe = trait aliases cannot be `unsafe`
parse_transpose_dyn_or_impl = `for<...>` expected after `{$kw}`, not before
.suggestion = move `{$kw}` before the `for<...>`

parse_type_ascription_removed =
if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>

parse_unclosed_unicode_escape = unterminated unicode escape
.label = missing a closing `{"}"}`
.terminate = terminate the unicode escape
Expand Down
6 changes: 0 additions & 6 deletions compiler/rustc_parse/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1598,9 +1598,6 @@ pub(crate) struct PathSingleColon {

#[suggestion(applicability = "machine-applicable", code = ":", style = "verbose")]
pub suggestion: Span,

#[note(parse_type_ascription_removed)]
pub type_ascription: bool,
}

#[derive(Diagnostic)]
Expand All @@ -1617,9 +1614,6 @@ pub(crate) struct ColonAsSemi {
#[primary_span]
#[suggestion(applicability = "machine-applicable", code = ";", style = "verbose")]
pub span: Span,

#[note(parse_type_ascription_removed)]
pub type_ascription: bool,
}

#[derive(Diagnostic)]
Expand Down
5 changes: 1 addition & 4 deletions compiler/rustc_parse/src/parser/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1943,10 +1943,7 @@ impl<'a> Parser<'a> {
&& self.token == token::Colon
&& self.look_ahead(1, |next| line_idx(self.token.span) < line_idx(next.span))
{
self.dcx().emit_err(ColonAsSemi {
span: self.token.span,
type_ascription: self.psess.unstable_features.is_nightly_build(),
});
self.dcx().emit_err(ColonAsSemi { span: self.token.span });
self.bump();
return true;
}
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_parse/src/parser/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ impl<'a> Parser<'a> {
self.dcx().emit_err(PathSingleColon {
span: self.prev_token.span,
suggestion: self.prev_token.span.shrink_to_hi(),
type_ascription: self.psess.unstable_features.is_nightly_build(),
});
}
continue;
Expand Down Expand Up @@ -348,7 +347,6 @@ impl<'a> Parser<'a> {
err = self.dcx().create_err(PathSingleColon {
span: self.token.span,
suggestion: self.prev_token.span.shrink_to_hi(),
type_ascription: self.psess.unstable_features.is_nightly_build(),
});
}
// Attempt to find places where a missing `>` might belong.
Expand Down
4 changes: 0 additions & 4 deletions compiler/rustc_parse/src/parser/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -771,10 +771,6 @@ impl<'a> Parser<'a> {
Applicability::MaybeIncorrect,
);
}
if self.psess.unstable_features.is_nightly_build() {
// FIXME(Nilstrieb): Remove this again after a few months.
err.note("type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>");
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ error: unexpected `,` in pattern
LL | let women, men: (Vec<Genome>, Vec<Genome>) = genomes.iter().cloned()
| ^
|
= note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
help: try adding parentheses to match on a tuple
|
LL | let (women, men): (Vec<Genome>, Vec<Genome>) = genomes.iter().cloned()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ error: path separator must be a double colon
LL | a: Vec<foo::bar:A>,
| ^
|
= note: if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
help: use a double colon instead
|
LL | a: Vec<foo::bar::A>,
Expand Down
1 change: 0 additions & 1 deletion tests/ui/or-patterns/or-patterns-syntactic-fail.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ LL | let _ = |A | B: E| ();
| |
| while parsing the body of this closure
|
= note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
help: you might have meant to open the body of the closure
|
LL | let _ = |A | { B: E| ();
Expand Down
18 changes: 0 additions & 18 deletions tests/ui/parser/issues/issue-35813-postfix-after-cast.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,18 @@ error: expected one of `.`, `;`, `?`, `else`, or an operator, found `:`
|
LL | let _ = 0i32: i32: i32.count_ones();
| ^ expected one of `.`, `;`, `?`, `else`, or an operator
|
= note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>

error: expected one of `!`, `(`, `.`, `::`, `;`, `<`, `?`, or `else`, found `:`
--> $DIR/issue-35813-postfix-after-cast.rs:43:21
|
LL | let _ = 0 as i32: i32.count_ones();
| ^ expected one of 8 possible tokens
|
= note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>

error: expected one of `.`, `;`, `?`, `else`, or an operator, found `:`
--> $DIR/issue-35813-postfix-after-cast.rs:47:17
|
LL | let _ = 0i32: i32 as i32.count_ones();
| ^ expected one of `.`, `;`, `?`, `else`, or an operator
|
= note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>

error: cast cannot be followed by a method call
--> $DIR/issue-35813-postfix-after-cast.rs:51:13
Expand All @@ -84,16 +78,12 @@ error: expected one of `.`, `;`, `?`, `else`, or an operator, found `:`
|
LL | let _ = 0i32: i32: i32 as u32 as i32.count_ones();
| ^ expected one of `.`, `;`, `?`, `else`, or an operator
|
= note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>

error: expected one of `.`, `;`, `?`, `else`, or an operator, found `:`
--> $DIR/issue-35813-postfix-after-cast.rs:60:17
|
LL | let _ = 0i32: i32.count_ones(): u32;
| ^ expected one of `.`, `;`, `?`, `else`, or an operator
|
= note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>

error: cast cannot be followed by a method call
--> $DIR/issue-35813-postfix-after-cast.rs:64:13
Expand All @@ -111,16 +101,12 @@ error: expected one of `.`, `;`, `?`, or `else`, found `:`
|
LL | let _ = 0 as i32.count_ones(): u32;
| ^ expected one of `.`, `;`, `?`, or `else`
|
= note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>

error: expected one of `.`, `;`, `?`, `else`, or an operator, found `:`
--> $DIR/issue-35813-postfix-after-cast.rs:69:17
|
LL | let _ = 0i32: i32.count_ones() as u32;
| ^ expected one of `.`, `;`, `?`, `else`, or an operator
|
= note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>

error: cast cannot be followed by a method call
--> $DIR/issue-35813-postfix-after-cast.rs:73:13
Expand All @@ -138,8 +124,6 @@ error: expected one of `.`, `;`, `?`, `else`, or an operator, found `:`
|
LL | let _ = 0i32: i32: i32.count_ones() as u32 as i32;
| ^ expected one of `.`, `;`, `?`, `else`, or an operator
|
= note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>

error: cast cannot be followed by a method call
--> $DIR/issue-35813-postfix-after-cast.rs:82:13
Expand Down Expand Up @@ -262,8 +246,6 @@ error: expected identifier, found `:`
|
LL | drop_ptr: F();
| ^ expected identifier
|
= note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>

error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `:`
--> $DIR/issue-35813-postfix-after-cast.rs:160:13
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, fo
LL | let x = Tr<A, A:>;
| ^ expected one of 8 possible tokens
|
= note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
help: maybe write a path separator here
|
LL | let x = Tr<A, A::>;
Expand Down
2 changes: 0 additions & 2 deletions tests/ui/parser/ternary_operator.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ error: expected one of `.`, `;`, `?`, `else`, or an operator, found `:`
|
LL | let x = 5 > 2 ? { let x = vec![]: Vec<u16>; x } : { false };
| ^ expected one of `.`, `;`, `?`, `else`, or an operator
|
= note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>

error: Rust has no ternary operator
--> $DIR/ternary_operator.rs:26:19
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ error: expected one of `)`, `,`, `@`, `if`, or `|`, found `:`
|
LL | let a @ (b: u8);
| ^ expected one of `)`, `,`, `@`, `if`, or `|`
|
= note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>

error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `=`, found `@`
--> $DIR/nested-type-ascription-syntactically-invalid.rs:30:15
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ error: path separator must be a double colon
LL | fn fmt(&self, f: &mut fmt:Formatter) -> fmt::Result {
| ^
|
= note: if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
help: use a double colon instead
|
LL | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
Expand Down
2 changes: 0 additions & 2 deletions tests/ui/suggestions/many-type-ascription.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ error: expected one of `.`, `;`, `?`, `else`, or an operator, found `:`
|
LL | let _ = 0: i32;
| ^ expected one of `.`, `;`, `?`, `else`, or an operator
|
= note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>

error: aborting due to 1 previous error

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ error: path separator must be a double colon
LL | a: foo:A,
| ^
|
= note: if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
help: use a double colon instead
|
LL | a: foo::A,
Expand All @@ -16,7 +15,6 @@ error: path separator must be a double colon
LL | b: foo::bar:B,
| ^
|
= note: if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
help: use a double colon instead
|
LL | b: foo::bar::B,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ error: path separator must be a double colon
LL | let _ = Box:new("foo".to_string());
| ^
|
= note: if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
help: use a double colon instead
|
LL | let _ = Box::new("foo".to_string());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ error: expected one of `(`, `.`, `::`, `;`, `?`, `else`, or an operator, found `
LL | let _ = vec![Ok(2)].into_iter().collect:<Result<Vec<_>,_>>()?;
| ^ expected one of 7 possible tokens
|
= note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
help: maybe write a path separator here
|
LL | let _ = vec![Ok(2)].into_iter().collect::<Result<Vec<_>,_>>()?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ error: path separator must be a double colon
LL | std:io::stdin();
| ^
|
= note: if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
help: use a double colon instead
|
LL | std::io::stdin();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ error: path separator must be a double colon
LL | let _ = Option:Some("");
| ^
|
= note: if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
help: use a double colon instead
|
LL | let _ = Option::Some("");
Expand Down
1 change: 0 additions & 1 deletion tests/ui/type/ascription/issue-47666.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ error: path separator must be a double colon
LL | let _ = Option:Some(vec![0, 1]);
| ^
|
= note: if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
help: use a double colon instead
|
LL | let _ = Option::Some(vec![0, 1]);
Expand Down
1 change: 0 additions & 1 deletion tests/ui/type/ascription/issue-54516.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ error: path separator must be a double colon
LL | println!("{}", std::mem:size_of::<BTreeMap<u32, u32>>());
| ^
|
= note: if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
help: use a double colon instead
|
LL | println!("{}", std::mem::size_of::<BTreeMap<u32, u32>>());
Expand Down
1 change: 0 additions & 1 deletion tests/ui/type/ascription/issue-60933.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ error: path separator must be a double colon
LL | let _: usize = std::mem:size_of::<u32>();
| ^
|
= note: if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
help: use a double colon instead
|
LL | let _: usize = std::mem::size_of::<u32>();
Expand Down
1 change: 0 additions & 1 deletion tests/ui/type/missing-let-in-binding.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ error: expected identifier, found `:`
LL | _foo: i32 = 4;
| ^ expected identifier
|
= note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
help: you might have meant to introduce a new binding
|
LL | let _foo: i32 = 4;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ error: statements are terminated with a semicolon
LL | println!("test"):
| ^
|
= note: if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
help: use a semicolon instead
|
LL - println!("test"):
Expand Down
2 changes: 0 additions & 2 deletions tests/ui/type/type-ascription-precedence.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ error: expected identifier, found `:`
|
LL | S .. S: S;
| ^ expected identifier
|
= note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>

error: expected one of `.`, `;`, `?`, `}`, or an operator, found `:`
--> $DIR/type-ascription-precedence.rs:53:13
Expand Down
1 change: 0 additions & 1 deletion tests/ui/type/type-ascription-with-fn-call.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ error: statements are terminated with a semicolon
LL | f() :
| ^
|
= note: if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
help: use a semicolon instead
|
LL - f() :
Expand Down
Loading