Merge from rust-lang/rust

This commit is contained in:
Laurențiu Nicola 2025-05-20 10:01:00 +03:00
commit 9e86544698
10 changed files with 25 additions and 7 deletions

View file

@ -224,7 +224,7 @@ impl ExprCollector<'_> {
curarg = parser.curarg;
let to_span = |inner_span: rustc_parse_format::InnerSpan| {
let to_span = |inner_span: std::ops::Range<usize>| {
is_direct_literal.then(|| {
TextRange::new(
inner_span.start.try_into().unwrap(),

View file

@ -214,7 +214,7 @@ pub(crate) fn parse(
};
}
let to_span = |inner_span: parse::InnerSpan| {
let to_span = |inner_span: std::ops::Range<usize>| {
is_source_literal.then(|| {
TextRange::new(inner_span.start.try_into().unwrap(), inner_span.end.try_into().unwrap())
})
@ -297,7 +297,7 @@ pub(crate) fn parse(
unfinished_literal.clear();
}
let span = parser.arg_places.get(placeholder_index).and_then(|&s| to_span(s));
let span = parser.arg_places.get(placeholder_index).and_then(|s| to_span(s.clone()));
placeholder_index += 1;
let position_span = to_span(position_span);

View file

@ -301,6 +301,7 @@ impl<'db> MatchCheckCtx<'db> {
// ignore this issue.
Ref => PatKind::Deref { subpattern: subpatterns.next().unwrap() },
Slice(_) => unimplemented!(),
DerefPattern(_) => unimplemented!(),
&Str(void) => match void {},
Wildcard | NonExhaustive | Hidden | PrivateUninhabited => PatKind::Wild,
Never => PatKind::Never,
@ -351,6 +352,7 @@ impl PatCx for MatchCheckCtx<'_> {
},
Ref => 1,
Slice(..) => unimplemented!(),
DerefPattern(..) => unimplemented!(),
Never | Bool(..) | IntRange(..) | F16Range(..) | F32Range(..) | F64Range(..)
| F128Range(..) | Str(..) | Opaque(..) | NonExhaustive | PrivateUninhabited
| Hidden | Missing | Wildcard => 0,
@ -411,6 +413,7 @@ impl PatCx for MatchCheckCtx<'_> {
}
},
Slice(_) => unreachable!("Found a `Slice` constructor in match checking"),
DerefPattern(_) => unreachable!("Found a `DerefPattern` constructor in match checking"),
Never | Bool(..) | IntRange(..) | F16Range(..) | F32Range(..) | F64Range(..)
| F128Range(..) | Str(..) | Opaque(..) | NonExhaustive | PrivateUninhabited
| Hidden | Missing | Wildcard => {

View file

@ -5789,7 +5789,7 @@ The tracking issue for this feature is: [#120301]
------------------------
Add the methods `from_mins`, `from_hours` and `from_days` to `Duration`.
Add the methods `from_days` and `from_weeks` to `Duration`.
"##,
default_severity: Severity::Allow,
warn_since: None,

View file

@ -179,6 +179,15 @@ impl<'a> Converter<'a> {
COMMENT
}
rustc_lexer::TokenKind::Frontmatter { has_invalid_preceding_whitespace, invalid_infostring } => {
if *has_invalid_preceding_whitespace {
err = "invalid preceding whitespace for frontmatter opening"
} else if *invalid_infostring {
err = "invalid infostring for frontmatter"
}
FRONTMATTER
}
rustc_lexer::TokenKind::Whitespace => WHITESPACE,
rustc_lexer::TokenKind::Ident if token_text == "_" => UNDERSCORE,

File diff suppressed because one or more lines are too long

View file

@ -173,7 +173,6 @@ fn test_fn_like_macro_clone_raw_ident() {
}
#[test]
#[cfg(not(bootstrap))]
fn test_fn_like_fn_like_span_join() {
assert_expand(
"fn_like_span_join",
@ -200,7 +199,6 @@ fn test_fn_like_fn_like_span_join() {
}
#[test]
#[cfg(not(bootstrap))]
fn test_fn_like_fn_like_span_ops() {
assert_expand(
"fn_like_span_ops",

View file

@ -133,6 +133,7 @@ Meta =
SourceFile =
'#shebang'?
'#frontmatter'?
Attr*
Item*

View file

@ -1524,6 +1524,10 @@ impl ast::HasAttrs for SourceFile {}
impl ast::HasDocComments for SourceFile {}
impl ast::HasModuleItem for SourceFile {}
impl SourceFile {
#[inline]
pub fn frontmatter_token(&self) -> Option<SyntaxToken> {
support::token(&self.syntax, T![frontmatter])
}
#[inline]
pub fn shebang_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![shebang]) }
}

View file

@ -670,6 +670,7 @@ fn generate_syntax_kinds(grammar: KindsSrc) -> String {
[ident] => { $crate::SyntaxKind::IDENT };
[string] => { $crate::SyntaxKind::STRING };
[shebang] => { $crate::SyntaxKind::SHEBANG };
[frontmatter] => { $crate::SyntaxKind::FRONTMATTER };
}
impl ::core::marker::Copy for SyntaxKind {}