Skip to content

Commit

Permalink
Supress Iterator bounds, out-of-control highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinleroy committed Sep 4, 2024
1 parent 9ba45fa commit 8bafdaa
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 29 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions crates/argus-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "argus-cli"
version = "0.1.11"
version = "0.1.12"
edition = "2021"
authors = ["Gavin Gray <[email protected]>"]
repository = "https://github.com/cognitive-engineering-lab/argus"
Expand All @@ -10,8 +10,8 @@ license = "MIT"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
argus-lib = { version = "0.1.11", path = "../argus" }
argus-ext = { version = "0.1.11", path = "../argus-ext" }
argus-lib = { version = "0.1.12", path = "../argus" }
argus-ext = { version = "0.1.12", path = "../argus-ext" }
rustc_plugin = "=0.10.0-nightly-2024-05-20"

rustc_utils.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/argus-ext/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "argus-ext"
version = "0.1.11"
version = "0.1.12"
edition = "2021"
authors = ["Gavin Gray <[email protected]>"]
repository = "https://github.com/cognitive-engineering-lab/argus"
Expand Down
4 changes: 2 additions & 2 deletions crates/argus-ser/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "argus-ser"
version = "0.1.11"
version = "0.1.12"
edition = "2021"
authors = ["Gavin Gray <[email protected]>"]
repository = "https://github.com/cognitive-engineering-lab/argus"
Expand Down Expand Up @@ -28,7 +28,7 @@ smallvec = "1.11.2"
itertools = "0.12.0"
ts-rs = { version = "7.1.1", features = ["indexmap-impl"], optional = true }
index_vec = { version = "0.1.3", features = ["serde"] }
argus-ext = { version = "0.1.11", path = "../argus-ext" }
argus-ext = { version = "0.1.12", path = "../argus-ext" }

[dev-dependencies]
argus-ser = { path = ".", features = ["testing"] }
Expand Down
8 changes: 4 additions & 4 deletions crates/argus/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "argus-lib"
version = "0.1.11"
version = "0.1.12"
edition = "2021"
authors = ["Gavin Gray <[email protected]>"]
repository = "https://github.com/cognitive-engineering-lab/argus"
Expand All @@ -21,8 +21,8 @@ fluid-let.workspace = true
serde.workspace = true
serde_json.workspace = true

argus-ext = { version = "0.1.11", path = "../argus-ext" }
argus-ser = { version = "0.1.11", path = "../argus-ser" }
argus-ext = { version = "0.1.12", path = "../argus-ext" }
argus-ser = { version = "0.1.12", path = "../argus-ser" }
index_vec = { version = "0.1.3", features = ["serde"] }
smallvec = "1.11.2"
itertools = "0.12.0"
Expand All @@ -35,7 +35,7 @@ ts-rs = { version = "7.1.1", features = ["indexmap-impl"], optional = true }

[dev-dependencies]
argus-lib = { path = ".", features = ["testing"] }
argus-ser = { version = "0.1.11", path = "../argus-ser", features = ["testing"] }
argus-ser = { version = "0.1.12", path = "../argus-ser", features = ["testing"] }
rustc_utils = { version = "=0.10.0-nightly-2024-05-20", features = ["serde", "ts-rs"] }
test-log = "0.2.11"
env_logger = "0.9.3"
Expand Down
19 changes: 19 additions & 0 deletions crates/argus/src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,23 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
) -> ObligationNecessity {
use ObligationNecessity as ON;

// HACK REMOVE: for the user study we want to reduce
// noise that otherwise shouldn't be there. Iterator / IntoIterator
// bounds are common when the solver is scrambling for diagnostic
// notes and we don't have any problems that "need" them.
let is_user_study_hack = || {
use rustc_hir::lang_items::LangItem as LI;
let items = vec![LI::Iterator, LI::Sized, LI::Deref];
let lis = self.tcx.lang_items();
for i in items {
if let Some(def_id) = lis.get(i) && p.is_trait_pred_rhs(def_id) {
return true;
}
}

false
};

let is_rhs_lang_item = || {
self
.tcx
Expand All @@ -67,6 +84,8 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {

if !is_writeable() || p.is_lhs_unit() {
ON::No
} else if is_user_study_hack() {
ON::No
} else if (p.is_trait_predicate() && is_rhs_lang_item())
|| !p.is_trait_predicate()
{
Expand Down
16 changes: 16 additions & 0 deletions ide/packages/common/src/BodyInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,22 @@ class BodyInfo {
return this.oib.tys;
}

traitErrors() {
return _.compact(
_.flatMap(this.oib.traitErrors, e =>
this.hasVisibleObligations(e.idx) ? null : e
)
);
}

ambiguityErrors() {
return _.compact(
_.flatMap(this.oib.ambiguityErrors, e =>
this.hasVisibleObligations(e.idx) ? null : e
)
);
}

exprs(): ExprIdx[] {
return _.range(0, this.oib.exprs.length);
}
Expand Down
2 changes: 1 addition & 1 deletion ide/packages/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "A trait debugger for Rust",
"license": "MIT",
"icon": "argus-logo-128.png",
"version": "0.1.11",
"version": "0.1.12",
"engines": {
"vscode": "^1.79.0"
},
Expand Down
27 changes: 13 additions & 14 deletions ide/packages/extension/src/ctx.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import BodyInfo from "@argus/common/BodyInfo";
import type {
BodyHash,
CharRange,
Expand Down Expand Up @@ -372,34 +373,32 @@ export class Ctx {
private refreshDiagnostics(editor: RustEditor, info: ObligationsInBody[]) {
this.diagnosticCollection.clear();

const traitDiags = _.flatMap(info, ob =>
_.map(
ob.traitErrors,
const diags = _.flatMap(info, ob => {
// NOTE: the false is to hide superfluous errors.
const body = new BodyInfo(ob, false);
const traitDiags = _.map(
body.traitErrors(),
e =>
new vscode.Diagnostic(
rustRangeToVscodeRange(e.range),
diagnosticMessage("trait"),
vscode.DiagnosticSeverity.Error
)
)
);
);

const ambigDiags = _.flatMap(info, ob =>
_.map(
ob.ambiguityErrors,
const ambigDiags = _.map(
body.ambiguityErrors(),
e =>
new vscode.Diagnostic(
rustRangeToVscodeRange(e.range),
diagnosticMessage("ambig"),
vscode.DiagnosticSeverity.Error
)
)
);
);
return [...traitDiags, ...ambigDiags];
});

this.diagnosticCollection.set(editor.document.uri, [
...traitDiags,
...ambigDiags
]);
this.diagnosticCollection.set(editor.document.uri, diags);
}

private buildOpenErrorItemCmd(
Expand Down

0 comments on commit 8bafdaa

Please sign in to comment.