Skip to content

Commit

Permalink
Merge branch 'rust-lang:master' into docs-create-setup-document
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkurilla authored Oct 18, 2024
2 parents 5ba69c1 + 3ddfb0d commit f0c54fb
Show file tree
Hide file tree
Showing 18 changed files with 1,559 additions and 193 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ jobs:
if: matrix.os == 'ubuntu-latest'
run: target/${{ matrix.target }}/debug/rust-analyzer analysis-stats .

- name: Run analysis-stats on rust std library
- name: Run analysis-stats on the rust standard libraries
if: matrix.os == 'ubuntu-latest'
env:
RUSTC_BOOTSTRAP: 1
run: target/${{ matrix.target }}/debug/rust-analyzer analysis-stats --with-deps $(rustc --print sysroot)/lib/rustlib/src/rust/library/std
RUSTC_BOOTSTRAP: 1
run: target/${{ matrix.target }}/debug/rust-analyzer analysis-stats --with-deps --no-sysroot --no-test $(rustc --print sysroot)/lib/rustlib/src/rust/library/

- name: clippy
if: matrix.os == 'windows-latest'
Expand Down
70 changes: 47 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,18 @@ tt = { path = "./crates/tt", version = "0.0.0" }
vfs-notify = { path = "./crates/vfs-notify", version = "0.0.0" }
vfs = { path = "./crates/vfs", version = "0.0.0" }

ra-ap-rustc_lexer = { version = "0.68.0", default-features = false }
ra-ap-rustc_parse_format = { version = "0.68.0", default-features = false }
ra-ap-rustc_index = { version = "0.68.0", default-features = false }
ra-ap-rustc_abi = { version = "0.68.0", default-features = false }
ra-ap-rustc_pattern_analysis = { version = "0.68.0", default-features = false }
ra-ap-rustc_lexer = { version = "0.71.0", default-features = false }
ra-ap-rustc_parse_format = { version = "0.71.0", default-features = false }
ra-ap-rustc_index = { version = "0.71.0", default-features = false }
ra-ap-rustc_abi = { version = "0.71.0", default-features = false }
ra-ap-rustc_pattern_analysis = { version = "0.71.0", default-features = false }

# local crates that aren't published to crates.io. These should not have versions.
test-fixture = { path = "./crates/test-fixture" }
test-utils = { path = "./crates/test-utils" }

# In-tree crates that are published separately and follow semver. See lib/README.md
line-index = { version = "0.1.1" }
line-index = { version = "0.1.2" }
la-arena = { version = "0.3.1" }
lsp-server = { version = "0.7.6" }

Expand Down Expand Up @@ -153,6 +153,9 @@ tracing-tree = "0.3.0"
tracing-subscriber = { version = "0.3.18", default-features = false, features = [
"registry",
"fmt",
"local-time",
"std",
"time",
"tracing-log",
] }
triomphe = { version = "0.1.10", default-features = false, features = ["std"] }
Expand Down
12 changes: 11 additions & 1 deletion crates/hir-ty/src/infer/unify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -917,9 +917,19 @@ impl<'a> InferenceTable<'a> {
/// Check if given type is `Sized` or not
pub(crate) fn is_sized(&mut self, ty: &Ty) -> bool {
// Early return for some obvious types
if matches!(ty.kind(Interner), TyKind::Scalar(..) | TyKind::Ref(..) | TyKind::Raw(..)) {
if matches!(
ty.kind(Interner),
TyKind::Scalar(..)
| TyKind::Ref(..)
| TyKind::Raw(..)
| TyKind::Never
| TyKind::FnDef(..)
| TyKind::Array(..)
| TyKind::Function(_)
) {
return true;
}

if let Some((AdtId::StructId(id), subst)) = ty.as_adt() {
let struct_data = self.db.struct_data(id);
if let Some((last_field, _)) = struct_data.variant_data.fields().iter().last() {
Expand Down
7 changes: 7 additions & 0 deletions crates/parser/src/lexed_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,13 @@ impl<'a> Converter<'a> {
}

rustc_lexer::TokenKind::RawIdent => IDENT,

rustc_lexer::TokenKind::GuardedStrPrefix if self.edition.at_least_2024() => {
err = "Invalid string literal (reserved syntax)";
ERROR
}
rustc_lexer::TokenKind::GuardedStrPrefix => POUND,

rustc_lexer::TokenKind::Literal { kind, .. } => {
self.extend_literal(token_text.len(), kind);
return;
Expand Down
3 changes: 0 additions & 3 deletions crates/project-model/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,6 @@ fn rust_project_is_proc_macro_has_proc_macro_dep() {
}

#[test]
// FIXME Remove the ignore
#[ignore = "requires nightly until the sysroot ships a cargo workspace for library on stable"]
fn smoke_test_real_sysroot_cargo() {
let file_map = &mut FxHashMap::<AbsPathBuf, FileId>::default();
let meta: Metadata = get_test_json_file("hello-world-metadata.json");
Expand All @@ -235,7 +233,6 @@ fn smoke_test_real_sysroot_cargo() {
&Default::default(),
);
assert!(matches!(sysroot.mode(), SysrootMode::Workspace(_)));

let project_workspace = ProjectWorkspace {
kind: ProjectWorkspaceKind::Cargo {
cargo: cargo_workspace,
Expand Down
2 changes: 1 addition & 1 deletion crates/rust-analyzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ crossbeam-channel.workspace = true
dirs = "5.0.1"
dissimilar.workspace = true
itertools.workspace = true
scip = "0.3.3"
scip = "0.5.1"
lsp-types = { version = "=0.95.0", features = ["proposed"] }
parking_lot = "0.12.1"
xflags = "0.3.0"
Expand Down
9 changes: 7 additions & 2 deletions crates/rust-analyzer/src/cli/analysis_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::{
time::{SystemTime, UNIX_EPOCH},
};

use cfg::{CfgAtom, CfgDiff};
use hir::{
db::{DefDatabase, ExpandDatabase, HirDatabase},
Adt, AssocItem, Crate, DefWithBody, HasSource, HirDisplay, HirFileIdExt, ImportPathConfig,
Expand All @@ -31,7 +32,7 @@ use itertools::Itertools;
use load_cargo::{load_workspace, LoadCargoConfig, ProcMacroServerChoice};
use oorandom::Rand32;
use profile::{Bytes, StopWatch};
use project_model::{CargoConfig, ProjectManifest, ProjectWorkspace, RustLibSource};
use project_model::{CargoConfig, CfgOverrides, ProjectManifest, ProjectWorkspace, RustLibSource};
use rayon::prelude::*;
use rustc_hash::{FxHashMap, FxHashSet};
use syntax::{AstNode, SyntaxNode};
Expand Down Expand Up @@ -65,7 +66,11 @@ impl flags::AnalysisStats {
false => Some(RustLibSource::Discover),
},
all_targets: true,
set_test: true,
set_test: !self.no_test,
cfg_overrides: CfgOverrides {
global: CfgDiff::new(vec![CfgAtom::Flag(hir::sym::miri.clone())], vec![]).unwrap(),
selective: Default::default(),
},
..Default::default()
};
let no_progress = &|_| ();
Expand Down
3 changes: 3 additions & 0 deletions crates/rust-analyzer/src/cli/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ xflags::xflags! {
optional --with-deps
/// Don't load sysroot crates (`std`, `core` & friends).
optional --no-sysroot
/// Don't set #[cfg(test)].
optional --no-test

/// Don't run build scripts or load `OUT_DIR` values by running `cargo check` before analysis.
optional --disable-build-scripts
Expand Down Expand Up @@ -233,6 +235,7 @@ pub struct AnalysisStats {
pub only: Option<String>,
pub with_deps: bool,
pub no_sysroot: bool,
pub no_test: bool,
pub disable_build_scripts: bool,
pub disable_proc_macros: bool,
pub proc_macro_srv: Option<PathBuf>,
Expand Down
12 changes: 10 additions & 2 deletions crates/rust-analyzer/src/lsp/from_proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,18 @@ pub(crate) fn offset(
.ok_or_else(|| format_err!("Invalid wide col offset"))?
}
};
let text_size = line_index.index.offset(line_col).ok_or_else(|| {
let line_range = line_index.index.line(line_col.line).ok_or_else(|| {
format_err!("Invalid offset {line_col:?} (line index length: {:?})", line_index.index.len())
})?;
Ok(text_size)
let col = TextSize::from(line_col.col);
let clamped_len = col.min(line_range.len());
if clamped_len < col {
tracing::error!(
"Position {line_col:?} column exceeds line length {}, clamping it",
u32::from(line_range.len()),
);
}
Ok(line_range.start() + clamped_len)
}

pub(crate) fn text_range(
Expand Down
6 changes: 5 additions & 1 deletion crates/rust-analyzer/src/tracing/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use anyhow::Context;
use tracing::level_filters::LevelFilter;
use tracing_subscriber::{
filter::{filter_fn, Targets},
fmt::MakeWriter,
fmt::{time, MakeWriter},
layer::SubscriberExt,
Layer, Registry,
};
Expand Down Expand Up @@ -58,6 +58,10 @@ where
let writer = self.writer;

let ra_fmt_layer = tracing_subscriber::fmt::layer()
.with_timer(
time::OffsetTime::local_rfc_3339()
.expect("Could not get local offset, make sure you're on the main thread"),
)
.with_target(false)
.with_ansi(false)
.with_writer(writer)
Expand Down
Loading

0 comments on commit f0c54fb

Please sign in to comment.