Skip to content

Commit a93f3d1

Browse files
committed
Merge branch 'master' into proc-macro-multi-abi-poc
2 parents f7326fb + 745be39 commit a93f3d1

File tree

93 files changed

+2796
-1740
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+2796
-1740
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ Forum for questions: https://users.rust-lang.org/c/ide/14
1313
1414
Before submitting, please make sure that you're not running into one of these known issues:
1515
16-
1. on-the-fly diagnostics are mostly unimplemented (`cargo check` diagnostics will be shown when saving a file)
17-
2. some platform-specific imports are not resolved: #6038
18-
3. attribute proc macros are not supported: #6029
19-
4. the version string is misleading (includes the previous week): #8571
16+
1. on-the-fly diagnostics are mostly unimplemented (`cargo check` diagnostics will be shown when saving a file): #3107
17+
2. attribute proc macros are supported but not enabled by default: #6029
18+
3. proc macros crash the language server on nightly and beta compiler versions: #8925
2019
2120
Otherwise please try to provide information which will help us to fix the issue faster. Minimal reproducible examples with few dependencies are especially lovely <3.
2221
-->

Cargo.lock

Lines changed: 20 additions & 47 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/flycheck/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ doctest = false
1111
[dependencies]
1212
crossbeam-channel = "0.5.0"
1313
log = "0.4.8"
14-
cargo_metadata = "0.13"
14+
cargo_metadata = "0.14"
1515
serde = { version = "1.0.106", features = ["derive"] }
1616
serde_json = "1.0.48"
1717
jod-thread = "0.1.1"

crates/flycheck/src/lib.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ impl FlycheckHandle {
6767
) -> FlycheckHandle {
6868
let actor = FlycheckActor::new(id, sender, config, workspace_root);
6969
let (sender, receiver) = unbounded::<Restart>();
70-
let thread = jod_thread::spawn(move || actor.run(receiver));
70+
let thread = jod_thread::Builder::new()
71+
.name("Flycheck".to_owned())
72+
.spawn(move || actor.run(receiver))
73+
.expect("failed to spawn thread");
7174
FlycheckHandle { sender, thread }
7275
}
7376

@@ -266,7 +269,10 @@ impl CargoHandle {
266269
let child_stdout = child.stdout.take().unwrap();
267270
let (sender, receiver) = unbounded();
268271
let actor = CargoActor::new(child_stdout, sender);
269-
let thread = jod_thread::spawn(move || actor.run());
272+
let thread = jod_thread::Builder::new()
273+
.name("CargoHandle".to_owned())
274+
.spawn(move || actor.run())
275+
.expect("failed to spawn thread");
270276
CargoHandle { child, thread, receiver }
271277
}
272278
fn join(mut self) -> io::Result<()> {

crates/hir/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,6 +1634,16 @@ impl HasVisibility for AssocItem {
16341634
}
16351635
}
16361636

1637+
impl From<AssocItem> for ModuleDef {
1638+
fn from(assoc: AssocItem) -> Self {
1639+
match assoc {
1640+
AssocItem::Function(it) => ModuleDef::Function(it),
1641+
AssocItem::Const(it) => ModuleDef::Const(it),
1642+
AssocItem::TypeAlias(it) => ModuleDef::TypeAlias(it),
1643+
}
1644+
}
1645+
}
1646+
16371647
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)]
16381648
pub enum GenericDef {
16391649
Function(Function),

crates/hir/src/semantics.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,19 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
216216
self.imp.type_of_expr(expr)
217217
}
218218

219+
/// Returns true in case a coercion happened.
220+
pub fn type_of_expr_with_coercion(&self, expr: &ast::Expr) -> Option<(Type, bool)> {
221+
self.imp.type_of_expr_with_coercion(expr)
222+
}
223+
219224
pub fn type_of_pat(&self, pat: &ast::Pat) -> Option<Type> {
220225
self.imp.type_of_pat(pat)
221226
}
222227

228+
pub fn type_of_pat_with_coercion(&self, expr: &ast::Pat) -> Option<Type> {
229+
self.imp.type_of_pat_with_coercion(expr)
230+
}
231+
223232
pub fn type_of_self(&self, param: &ast::SelfParam) -> Option<Type> {
224233
self.imp.type_of_self(param)
225234
}
@@ -560,10 +569,18 @@ impl<'db> SemanticsImpl<'db> {
560569
self.analyze(expr.syntax()).type_of_expr(self.db, expr)
561570
}
562571

572+
fn type_of_expr_with_coercion(&self, expr: &ast::Expr) -> Option<(Type, bool)> {
573+
self.analyze(expr.syntax()).type_of_expr_with_coercion(self.db, expr)
574+
}
575+
563576
fn type_of_pat(&self, pat: &ast::Pat) -> Option<Type> {
564577
self.analyze(pat.syntax()).type_of_pat(self.db, pat)
565578
}
566579

580+
fn type_of_pat_with_coercion(&self, pat: &ast::Pat) -> Option<Type> {
581+
self.analyze(pat.syntax()).type_of_pat_with_coercion(self.db, pat)
582+
}
583+
567584
fn type_of_self(&self, param: &ast::SelfParam) -> Option<Type> {
568585
self.analyze(param.syntax()).type_of_self(self.db, param)
569586
}

crates/hir/src/source_analyzer.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,42 @@ impl SourceAnalyzer {
122122
Type::new_with_resolver(db, &self.resolver, ty)
123123
}
124124

125+
pub(crate) fn type_of_expr_with_coercion(
126+
&self,
127+
db: &dyn HirDatabase,
128+
expr: &ast::Expr,
129+
) -> Option<(Type, bool)> {
130+
let expr_id = self.expr_id(db, expr)?;
131+
let infer = self.infer.as_ref()?;
132+
let (ty, coerced) = infer
133+
.expr_adjustments
134+
.get(&expr_id)
135+
.and_then(|adjusts| adjusts.last().map(|adjust| (&adjust.target, true)))
136+
.unwrap_or_else(|| (&infer[expr_id], false));
137+
Type::new_with_resolver(db, &self.resolver, ty.clone()).zip(Some(coerced))
138+
}
139+
125140
pub(crate) fn type_of_pat(&self, db: &dyn HirDatabase, pat: &ast::Pat) -> Option<Type> {
126141
let pat_id = self.pat_id(pat)?;
127142
let ty = self.infer.as_ref()?[pat_id].clone();
128143
Type::new_with_resolver(db, &self.resolver, ty)
129144
}
130145

146+
pub(crate) fn type_of_pat_with_coercion(
147+
&self,
148+
db: &dyn HirDatabase,
149+
pat: &ast::Pat,
150+
) -> Option<Type> {
151+
let pat_id = self.pat_id(pat)?;
152+
let infer = self.infer.as_ref()?;
153+
let ty = infer
154+
.pat_adjustments
155+
.get(&pat_id)
156+
.and_then(|adjusts| adjusts.last().map(|adjust| &adjust.target))
157+
.unwrap_or_else(|| &infer[pat_id]);
158+
Type::new_with_resolver(db, &self.resolver, ty.clone())
159+
}
160+
131161
pub(crate) fn type_of_self(
132162
&self,
133163
db: &dyn HirDatabase,

0 commit comments

Comments
 (0)