mirror of
				https://github.com/rust-lang/rust-analyzer.git
				synced 2025-11-04 05:35:55 +00:00 
			
		
		
		
	Merge from rust-lang/rust
This commit is contained in:
		
						commit
						9e86544698
					
				
					 10 changed files with 25 additions and 7 deletions
				
			
		| 
						 | 
					@ -224,7 +224,7 @@ impl ExprCollector<'_> {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    curarg = parser.curarg;
 | 
					                    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(|| {
 | 
					                        is_direct_literal.then(|| {
 | 
				
			||||||
                            TextRange::new(
 | 
					                            TextRange::new(
 | 
				
			||||||
                                inner_span.start.try_into().unwrap(),
 | 
					                                inner_span.start.try_into().unwrap(),
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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(|| {
 | 
					        is_source_literal.then(|| {
 | 
				
			||||||
            TextRange::new(inner_span.start.try_into().unwrap(), inner_span.end.try_into().unwrap())
 | 
					            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();
 | 
					                    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;
 | 
					                placeholder_index += 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                let position_span = to_span(position_span);
 | 
					                let position_span = to_span(position_span);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -301,6 +301,7 @@ impl<'db> MatchCheckCtx<'db> {
 | 
				
			||||||
            // ignore this issue.
 | 
					            // ignore this issue.
 | 
				
			||||||
            Ref => PatKind::Deref { subpattern: subpatterns.next().unwrap() },
 | 
					            Ref => PatKind::Deref { subpattern: subpatterns.next().unwrap() },
 | 
				
			||||||
            Slice(_) => unimplemented!(),
 | 
					            Slice(_) => unimplemented!(),
 | 
				
			||||||
 | 
					            DerefPattern(_) => unimplemented!(),
 | 
				
			||||||
            &Str(void) => match void {},
 | 
					            &Str(void) => match void {},
 | 
				
			||||||
            Wildcard | NonExhaustive | Hidden | PrivateUninhabited => PatKind::Wild,
 | 
					            Wildcard | NonExhaustive | Hidden | PrivateUninhabited => PatKind::Wild,
 | 
				
			||||||
            Never => PatKind::Never,
 | 
					            Never => PatKind::Never,
 | 
				
			||||||
| 
						 | 
					@ -351,6 +352,7 @@ impl PatCx for MatchCheckCtx<'_> {
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            Ref => 1,
 | 
					            Ref => 1,
 | 
				
			||||||
            Slice(..) => unimplemented!(),
 | 
					            Slice(..) => unimplemented!(),
 | 
				
			||||||
 | 
					            DerefPattern(..) => unimplemented!(),
 | 
				
			||||||
            Never | Bool(..) | IntRange(..) | F16Range(..) | F32Range(..) | F64Range(..)
 | 
					            Never | Bool(..) | IntRange(..) | F16Range(..) | F32Range(..) | F64Range(..)
 | 
				
			||||||
            | F128Range(..) | Str(..) | Opaque(..) | NonExhaustive | PrivateUninhabited
 | 
					            | F128Range(..) | Str(..) | Opaque(..) | NonExhaustive | PrivateUninhabited
 | 
				
			||||||
            | Hidden | Missing | Wildcard => 0,
 | 
					            | Hidden | Missing | Wildcard => 0,
 | 
				
			||||||
| 
						 | 
					@ -411,6 +413,7 @@ impl PatCx for MatchCheckCtx<'_> {
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            Slice(_) => unreachable!("Found a `Slice` constructor in match checking"),
 | 
					            Slice(_) => unreachable!("Found a `Slice` constructor in match checking"),
 | 
				
			||||||
 | 
					            DerefPattern(_) => unreachable!("Found a `DerefPattern` constructor in match checking"),
 | 
				
			||||||
            Never | Bool(..) | IntRange(..) | F16Range(..) | F32Range(..) | F64Range(..)
 | 
					            Never | Bool(..) | IntRange(..) | F16Range(..) | F32Range(..) | F64Range(..)
 | 
				
			||||||
            | F128Range(..) | Str(..) | Opaque(..) | NonExhaustive | PrivateUninhabited
 | 
					            | F128Range(..) | Str(..) | Opaque(..) | NonExhaustive | PrivateUninhabited
 | 
				
			||||||
            | Hidden | Missing | Wildcard => {
 | 
					            | Hidden | Missing | Wildcard => {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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,
 | 
					        default_severity: Severity::Allow,
 | 
				
			||||||
        warn_since: None,
 | 
					        warn_since: None,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -179,6 +179,15 @@ impl<'a> Converter<'a> {
 | 
				
			||||||
                    COMMENT
 | 
					                    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::Whitespace => WHITESPACE,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                rustc_lexer::TokenKind::Ident if token_text == "_" => UNDERSCORE,
 | 
					                rustc_lexer::TokenKind::Ident if token_text == "_" => UNDERSCORE,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| 
						 | 
					@ -173,7 +173,6 @@ fn test_fn_like_macro_clone_raw_ident() {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[test]
 | 
					#[test]
 | 
				
			||||||
#[cfg(not(bootstrap))]
 | 
					 | 
				
			||||||
fn test_fn_like_fn_like_span_join() {
 | 
					fn test_fn_like_fn_like_span_join() {
 | 
				
			||||||
    assert_expand(
 | 
					    assert_expand(
 | 
				
			||||||
        "fn_like_span_join",
 | 
					        "fn_like_span_join",
 | 
				
			||||||
| 
						 | 
					@ -200,7 +199,6 @@ fn test_fn_like_fn_like_span_join() {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[test]
 | 
					#[test]
 | 
				
			||||||
#[cfg(not(bootstrap))]
 | 
					 | 
				
			||||||
fn test_fn_like_fn_like_span_ops() {
 | 
					fn test_fn_like_fn_like_span_ops() {
 | 
				
			||||||
    assert_expand(
 | 
					    assert_expand(
 | 
				
			||||||
        "fn_like_span_ops",
 | 
					        "fn_like_span_ops",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -133,6 +133,7 @@ Meta =
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SourceFile =
 | 
					SourceFile =
 | 
				
			||||||
  '#shebang'?
 | 
					  '#shebang'?
 | 
				
			||||||
 | 
					  '#frontmatter'?
 | 
				
			||||||
  Attr*
 | 
					  Attr*
 | 
				
			||||||
  Item*
 | 
					  Item*
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1524,6 +1524,10 @@ impl ast::HasAttrs for SourceFile {}
 | 
				
			||||||
impl ast::HasDocComments for SourceFile {}
 | 
					impl ast::HasDocComments for SourceFile {}
 | 
				
			||||||
impl ast::HasModuleItem for SourceFile {}
 | 
					impl ast::HasModuleItem for SourceFile {}
 | 
				
			||||||
impl SourceFile {
 | 
					impl SourceFile {
 | 
				
			||||||
 | 
					    #[inline]
 | 
				
			||||||
 | 
					    pub fn frontmatter_token(&self) -> Option<SyntaxToken> {
 | 
				
			||||||
 | 
					        support::token(&self.syntax, T![frontmatter])
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    #[inline]
 | 
					    #[inline]
 | 
				
			||||||
    pub fn shebang_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![shebang]) }
 | 
					    pub fn shebang_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![shebang]) }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -670,6 +670,7 @@ fn generate_syntax_kinds(grammar: KindsSrc) -> String {
 | 
				
			||||||
            [ident] => { $crate::SyntaxKind::IDENT };
 | 
					            [ident] => { $crate::SyntaxKind::IDENT };
 | 
				
			||||||
            [string] => { $crate::SyntaxKind::STRING };
 | 
					            [string] => { $crate::SyntaxKind::STRING };
 | 
				
			||||||
            [shebang] => { $crate::SyntaxKind::SHEBANG };
 | 
					            [shebang] => { $crate::SyntaxKind::SHEBANG };
 | 
				
			||||||
 | 
					            [frontmatter] => { $crate::SyntaxKind::FRONTMATTER };
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        impl ::core::marker::Copy for SyntaxKind {}
 | 
					        impl ::core::marker::Copy for SyntaxKind {}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue