mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
Merge from rust-lang/rust
This commit is contained in:
commit
f373437c22
@ -489,6 +489,14 @@ impl PatCx for MatchCheckCtx<'_> {
|
|||||||
fn complexity_exceeded(&self) -> Result<(), Self::Error> {
|
fn complexity_exceeded(&self) -> Result<(), Self::Error> {
|
||||||
Err(())
|
Err(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn report_mixed_deref_pat_ctors(
|
||||||
|
&self,
|
||||||
|
_deref_pat: &DeconstructedPat<'_>,
|
||||||
|
_normal_pat: &DeconstructedPat<'_>,
|
||||||
|
) {
|
||||||
|
// FIXME(deref_patterns): This could report an error comparable to the one in rustc.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for MatchCheckCtx<'_> {
|
impl fmt::Debug for MatchCheckCtx<'_> {
|
||||||
|
@ -261,7 +261,7 @@ pub fn layout_of_ty_query(
|
|||||||
}
|
}
|
||||||
// Potentially-wide pointers.
|
// Potentially-wide pointers.
|
||||||
TyKind::Ref(_, _, pointee) | TyKind::Raw(_, pointee) => {
|
TyKind::Ref(_, _, pointee) | TyKind::Raw(_, pointee) => {
|
||||||
let mut data_ptr = scalar_unit(dl, Primitive::Pointer(AddressSpace::DATA));
|
let mut data_ptr = scalar_unit(dl, Primitive::Pointer(AddressSpace::ZERO));
|
||||||
if matches!(ty.kind(Interner), TyKind::Ref(..)) {
|
if matches!(ty.kind(Interner), TyKind::Ref(..)) {
|
||||||
data_ptr.valid_range_mut().start = 1;
|
data_ptr.valid_range_mut().start = 1;
|
||||||
}
|
}
|
||||||
@ -285,7 +285,7 @@ pub fn layout_of_ty_query(
|
|||||||
scalar_unit(dl, Primitive::Int(dl.ptr_sized_integer(), false))
|
scalar_unit(dl, Primitive::Int(dl.ptr_sized_integer(), false))
|
||||||
}
|
}
|
||||||
TyKind::Dyn(..) => {
|
TyKind::Dyn(..) => {
|
||||||
let mut vtable = scalar_unit(dl, Primitive::Pointer(AddressSpace::DATA));
|
let mut vtable = scalar_unit(dl, Primitive::Pointer(AddressSpace::ZERO));
|
||||||
vtable.valid_range_mut().start = 1;
|
vtable.valid_range_mut().start = 1;
|
||||||
vtable
|
vtable
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use base_db::Crate;
|
use base_db::Crate;
|
||||||
use hir_def::layout::TargetDataLayout;
|
use hir_def::layout::TargetDataLayout;
|
||||||
use rustc_abi::{AlignFromBytesError, TargetDataLayoutErrors};
|
use rustc_abi::{AlignFromBytesError, TargetDataLayoutErrors, AddressSpace};
|
||||||
use triomphe::Arc;
|
use triomphe::Arc;
|
||||||
|
|
||||||
use crate::db::HirDatabase;
|
use crate::db::HirDatabase;
|
||||||
@ -12,7 +12,7 @@ pub fn target_data_layout_query(
|
|||||||
krate: Crate,
|
krate: Crate,
|
||||||
) -> Result<Arc<TargetDataLayout>, Arc<str>> {
|
) -> Result<Arc<TargetDataLayout>, Arc<str>> {
|
||||||
match &krate.workspace_data(db).data_layout {
|
match &krate.workspace_data(db).data_layout {
|
||||||
Ok(it) => match TargetDataLayout::parse_from_llvm_datalayout_string(it) {
|
Ok(it) => match TargetDataLayout::parse_from_llvm_datalayout_string(it, AddressSpace::ZERO) {
|
||||||
Ok(it) => Ok(Arc::new(it)),
|
Ok(it) => Ok(Arc::new(it)),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
Err(match e {
|
Err(match e {
|
||||||
@ -39,6 +39,7 @@ pub fn target_data_layout_query(
|
|||||||
target,
|
target,
|
||||||
} => format!(r#"inconsistent target specification: "data-layout" claims pointers are {pointer_size}-bit, while "target-pointer-width" is `{target}`"#),
|
} => format!(r#"inconsistent target specification: "data-layout" claims pointers are {pointer_size}-bit, while "target-pointer-width" is `{target}`"#),
|
||||||
TargetDataLayoutErrors::InvalidBitsSize { err } => err,
|
TargetDataLayoutErrors::InvalidBitsSize { err } => err,
|
||||||
|
TargetDataLayoutErrors::UnknownPointerSpecification { err } => format!(r#"use of unknown pointer specifer in "data-layout": {err}"#),
|
||||||
}.into())
|
}.into())
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -630,7 +630,7 @@ impl Evaluator<'_> {
|
|||||||
Ok(target_data_layout) => target_data_layout,
|
Ok(target_data_layout) => target_data_layout,
|
||||||
Err(e) => return Err(MirEvalError::TargetDataLayoutNotAvailable(e)),
|
Err(e) => return Err(MirEvalError::TargetDataLayoutNotAvailable(e)),
|
||||||
};
|
};
|
||||||
let cached_ptr_size = target_data_layout.pointer_size.bytes_usize();
|
let cached_ptr_size = target_data_layout.pointer_size().bytes_usize();
|
||||||
Ok(Evaluator {
|
Ok(Evaluator {
|
||||||
target_data_layout,
|
target_data_layout,
|
||||||
stack: vec![0],
|
stack: vec![0],
|
||||||
|
@ -4711,9 +4711,9 @@ The tracking issue for this feature is: [#133668]
|
|||||||
label: "const_trait_impl",
|
label: "const_trait_impl",
|
||||||
description: r##"# `const_trait_impl`
|
description: r##"# `const_trait_impl`
|
||||||
|
|
||||||
The tracking issue for this feature is: [#67792]
|
The tracking issue for this feature is: [#143874]
|
||||||
|
|
||||||
[#67792]: https://github.com/rust-lang/rust/issues/67792
|
[#143874]: https://github.com/rust-lang/rust/issues/143874
|
||||||
|
|
||||||
------------------------
|
------------------------
|
||||||
"##,
|
"##,
|
||||||
|
@ -608,8 +608,8 @@ fn let_statements() {
|
|||||||
StructureNode {
|
StructureNode {
|
||||||
parent: None,
|
parent: None,
|
||||||
label: "very_obsolete",
|
label: "very_obsolete",
|
||||||
navigation_range: 511..524,
|
navigation_range: 512..525,
|
||||||
node_range: 473..529,
|
node_range: 473..530,
|
||||||
kind: SymbolKind(
|
kind: SymbolKind(
|
||||||
Function,
|
Function,
|
||||||
),
|
),
|
||||||
@ -621,8 +621,8 @@ fn let_statements() {
|
|||||||
StructureNode {
|
StructureNode {
|
||||||
parent: None,
|
parent: None,
|
||||||
label: "Some region name",
|
label: "Some region name",
|
||||||
navigation_range: 531..558,
|
navigation_range: 532..559,
|
||||||
node_range: 531..558,
|
node_range: 532..559,
|
||||||
kind: Region,
|
kind: Region,
|
||||||
detail: None,
|
detail: None,
|
||||||
deprecated: false,
|
deprecated: false,
|
||||||
@ -630,8 +630,8 @@ fn let_statements() {
|
|||||||
StructureNode {
|
StructureNode {
|
||||||
parent: None,
|
parent: None,
|
||||||
label: "m",
|
label: "m",
|
||||||
navigation_range: 598..599,
|
navigation_range: 599..600,
|
||||||
node_range: 573..636,
|
node_range: 574..637,
|
||||||
kind: SymbolKind(
|
kind: SymbolKind(
|
||||||
Module,
|
Module,
|
||||||
),
|
),
|
||||||
@ -643,8 +643,8 @@ fn let_statements() {
|
|||||||
22,
|
22,
|
||||||
),
|
),
|
||||||
label: "dontpanic",
|
label: "dontpanic",
|
||||||
navigation_range: 573..593,
|
navigation_range: 574..594,
|
||||||
node_range: 573..593,
|
node_range: 574..594,
|
||||||
kind: Region,
|
kind: Region,
|
||||||
detail: None,
|
detail: None,
|
||||||
deprecated: false,
|
deprecated: false,
|
||||||
@ -654,8 +654,8 @@ fn let_statements() {
|
|||||||
22,
|
22,
|
||||||
),
|
),
|
||||||
label: "f",
|
label: "f",
|
||||||
navigation_range: 605..606,
|
navigation_range: 606..607,
|
||||||
node_range: 602..611,
|
node_range: 603..612,
|
||||||
kind: SymbolKind(
|
kind: SymbolKind(
|
||||||
Function,
|
Function,
|
||||||
),
|
),
|
||||||
@ -669,8 +669,8 @@ fn let_statements() {
|
|||||||
22,
|
22,
|
||||||
),
|
),
|
||||||
label: "g",
|
label: "g",
|
||||||
navigation_range: 628..629,
|
navigation_range: 629..630,
|
||||||
node_range: 612..634,
|
node_range: 613..635,
|
||||||
kind: SymbolKind(
|
kind: SymbolKind(
|
||||||
Function,
|
Function,
|
||||||
),
|
),
|
||||||
@ -682,8 +682,8 @@ fn let_statements() {
|
|||||||
StructureNode {
|
StructureNode {
|
||||||
parent: None,
|
parent: None,
|
||||||
label: "extern \"C\"",
|
label: "extern \"C\"",
|
||||||
navigation_range: 638..648,
|
navigation_range: 639..649,
|
||||||
node_range: 638..651,
|
node_range: 639..652,
|
||||||
kind: ExternBlock,
|
kind: ExternBlock,
|
||||||
detail: None,
|
detail: None,
|
||||||
deprecated: false,
|
deprecated: false,
|
||||||
@ -691,8 +691,8 @@ fn let_statements() {
|
|||||||
StructureNode {
|
StructureNode {
|
||||||
parent: None,
|
parent: None,
|
||||||
label: "let_statements",
|
label: "let_statements",
|
||||||
navigation_range: 656..670,
|
navigation_range: 657..671,
|
||||||
node_range: 653..813,
|
node_range: 654..814,
|
||||||
kind: SymbolKind(
|
kind: SymbolKind(
|
||||||
Function,
|
Function,
|
||||||
),
|
),
|
||||||
@ -706,8 +706,8 @@ fn let_statements() {
|
|||||||
27,
|
27,
|
||||||
),
|
),
|
||||||
label: "x",
|
label: "x",
|
||||||
navigation_range: 683..684,
|
navigation_range: 684..685,
|
||||||
node_range: 679..690,
|
node_range: 680..691,
|
||||||
kind: SymbolKind(
|
kind: SymbolKind(
|
||||||
Local,
|
Local,
|
||||||
),
|
),
|
||||||
@ -719,8 +719,8 @@ fn let_statements() {
|
|||||||
27,
|
27,
|
||||||
),
|
),
|
||||||
label: "mut y",
|
label: "mut y",
|
||||||
navigation_range: 699..704,
|
navigation_range: 700..705,
|
||||||
node_range: 695..709,
|
node_range: 696..710,
|
||||||
kind: SymbolKind(
|
kind: SymbolKind(
|
||||||
Local,
|
Local,
|
||||||
),
|
),
|
||||||
@ -732,8 +732,8 @@ fn let_statements() {
|
|||||||
27,
|
27,
|
||||||
),
|
),
|
||||||
label: "Foo { .. }",
|
label: "Foo { .. }",
|
||||||
navigation_range: 718..740,
|
navigation_range: 719..741,
|
||||||
node_range: 714..753,
|
node_range: 715..754,
|
||||||
kind: SymbolKind(
|
kind: SymbolKind(
|
||||||
Local,
|
Local,
|
||||||
),
|
),
|
||||||
@ -745,8 +745,8 @@ fn let_statements() {
|
|||||||
27,
|
27,
|
||||||
),
|
),
|
||||||
label: "_",
|
label: "_",
|
||||||
navigation_range: 803..804,
|
navigation_range: 804..805,
|
||||||
node_range: 799..811,
|
node_range: 800..812,
|
||||||
kind: SymbolKind(
|
kind: SymbolKind(
|
||||||
Local,
|
Local,
|
||||||
),
|
),
|
||||||
|
@ -11,8 +11,8 @@
|
|||||||
use std::ops;
|
use std::ops;
|
||||||
|
|
||||||
use rustc_literal_escaper::{
|
use rustc_literal_escaper::{
|
||||||
EscapeError, Mode, unescape_byte, unescape_byte_str, unescape_c_str, unescape_char,
|
unescape_byte, unescape_byte_str, unescape_c_str, unescape_char, unescape_str, EscapeError,
|
||||||
unescape_str,
|
Mode,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@ -44,7 +44,9 @@ impl<'a> LexedStr<'a> {
|
|||||||
|
|
||||||
// Re-create the tokenizer from scratch every token because `GuardedStrPrefix` is one token in the lexer
|
// Re-create the tokenizer from scratch every token because `GuardedStrPrefix` is one token in the lexer
|
||||||
// but we want to split it to two in edition <2024.
|
// but we want to split it to two in edition <2024.
|
||||||
while let Some(token) = rustc_lexer::tokenize(&text[conv.offset..]).next() {
|
while let Some(token) =
|
||||||
|
rustc_lexer::tokenize(&text[conv.offset..], rustc_lexer::FrontmatterAllowed::No).next()
|
||||||
|
{
|
||||||
let token_text = &text[conv.offset..][..token.len as usize];
|
let token_text = &text[conv.offset..][..token.len as usize];
|
||||||
|
|
||||||
conv.extend_token(&token.kind, token_text);
|
conv.extend_token(&token.kind, token_text);
|
||||||
@ -58,7 +60,7 @@ impl<'a> LexedStr<'a> {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let token = rustc_lexer::tokenize(text).next()?;
|
let token = rustc_lexer::tokenize(text, rustc_lexer::FrontmatterAllowed::No).next()?;
|
||||||
if token.len as usize != text.len() {
|
if token.len as usize != text.len() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ pub(super) fn literal_from_str<Span: Copy>(
|
|||||||
use proc_macro::bridge::LitKind;
|
use proc_macro::bridge::LitKind;
|
||||||
use rustc_lexer::{LiteralKind, Token, TokenKind};
|
use rustc_lexer::{LiteralKind, Token, TokenKind};
|
||||||
|
|
||||||
let mut tokens = rustc_lexer::tokenize(s);
|
let mut tokens = rustc_lexer::tokenize(s, rustc_lexer::FrontmatterAllowed::No);
|
||||||
let minus_or_lit = tokens.next().unwrap_or(Token { kind: TokenKind::Eof, len: 0 });
|
let minus_or_lit = tokens.next().unwrap_or(Token { kind: TokenKind::Eof, len: 0 });
|
||||||
|
|
||||||
let lit = if minus_or_lit.kind == TokenKind::Minus {
|
let lit = if minus_or_lit.kind == TokenKind::Minus {
|
||||||
|
@ -25,7 +25,7 @@ impl flags::Scip {
|
|||||||
eprintln!("Generating SCIP start...");
|
eprintln!("Generating SCIP start...");
|
||||||
let now = Instant::now();
|
let now = Instant::now();
|
||||||
|
|
||||||
let no_progress = &|s| (eprintln!("rust-analyzer: Loading {s}"));
|
let no_progress = &|s| eprintln!("rust-analyzer: Loading {s}");
|
||||||
let root =
|
let root =
|
||||||
vfs::AbsPathBuf::assert_utf8(std::env::current_dir()?.join(&self.path)).normalize();
|
vfs::AbsPathBuf::assert_utf8(std::env::current_dir()?.join(&self.path)).normalize();
|
||||||
|
|
||||||
|
@ -579,7 +579,7 @@ where
|
|||||||
{
|
{
|
||||||
use rustc_lexer::LiteralKind;
|
use rustc_lexer::LiteralKind;
|
||||||
|
|
||||||
let token = rustc_lexer::tokenize(text).next_tuple();
|
let token = rustc_lexer::tokenize(text, rustc_lexer::FrontmatterAllowed::No).next_tuple();
|
||||||
let Some((rustc_lexer::Token {
|
let Some((rustc_lexer::Token {
|
||||||
kind: rustc_lexer::TokenKind::Literal { kind, suffix_start },
|
kind: rustc_lexer::TokenKind::Literal { kind, suffix_start },
|
||||||
..
|
..
|
||||||
|
Loading…
x
Reference in New Issue
Block a user