Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update nightly toolchain #6

Merged
merged 7 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ runs:
shell: bash

- name: Install Depot
run: curl https://raw.githubusercontent.com/cognitive-engineering-lab/depot/main/scripts/install.sh | sh -s e92a63edcb17cf156e399587b79192369911560e
run: cargo install --git https://github.com/cognitive-engineering-lab/depot.git depot-js && depot setup
shell: bash

- name: Install Test Libraries
Expand Down
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.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ If rustup fails, especially with an error like "could not rename the downloaded
To solve the issue, go to the command line and run:

```
rustup toolchain install nightly-2024-01-24 -c rust-src -c rustc-dev -c llvm-tools-preview
rustup toolchain install nightly-2024-05-20 -c rust-src -c rustc-dev -c llvm-tools-preview
```

Then go back to VSCode and click "Continue" to let Argus continue installing.
Expand Down
4 changes: 2 additions & 2 deletions crates/argus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ testing = ["lazy_static", "ts-rs"]
doctest = false

[dependencies]
rustc_utils = { version = "=0.9.0-nightly-2024-01-24", features = ["serde"] }
rustc_utils = { version = "=0.10.0-nightly-2024-05-20", features = ["serde"] }

log = "0.4"
index_vec = { version = "0.1.3", features = ["serde"] }
Expand All @@ -33,7 +33,7 @@ ts-rs = { version = "7.1.1", features = ["indexmap-impl"], optional = true }

[dev-dependencies]
argus-lib = { path = ".", features = ["testing"] }
rustc_utils = { version = "=0.9.0-nightly-2024-01-24", features = ["serde", "ts-rs"] }
rustc_utils = { version = "=0.10.0-nightly-2024-05-20", features = ["serde", "ts-rs"] }
test-log = "0.2.11"
env_logger = "0.9.3"
text-diff = "0.4"
Expand Down
32 changes: 14 additions & 18 deletions crates/argus/src/analysis/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ use anyhow::{anyhow, bail, Result};
use fluid_let::fluid_let;
use rustc_hir::BodyId;
use rustc_infer::{infer::InferCtxt, traits::PredicateObligation};
use rustc_middle::ty::{Predicate, TyCtxt, TypeckResults};
use rustc_middle::ty::{TyCtxt, TypeckResults};
use rustc_trait_selection::traits::solve::Goal;
use serde::Serialize;

use crate::{
analysis::{
Expand All @@ -17,7 +16,6 @@ use crate::{
},
ext::{EvaluationResultExt, InferCtxtExt},
proof_tree::{serialize::serialize_proof_tree, SerializedTree},
serialize::ty::PredicateDef,
types::{
intermediate::{
ErrorAssemblyCtx, Forgettable, FullData, ObligationQueriesInBody,
Expand All @@ -29,6 +27,7 @@ use crate::{

fluid_let! {
pub static INSPECTING: bool;
pub static BODY_ID: BodyId;
}

macro_rules! guard_inspection {
Expand All @@ -43,23 +42,19 @@ macro_rules! guard_inspection {
// --------------------------------
// Rustc inspection points

#[derive(Serialize)]
struct PredWrapper<'a, 'tcx: 'a>(
#[serde(with = "PredicateDef")] &'a Predicate<'tcx>,
);

pub fn process_obligation<'tcx>(
infcx: &InferCtxt<'tcx>,
obl: &PredicateObligation<'tcx>,
result: EvaluationResult,
) {
guard_inspection! {}

let Some(_ldef_id) = infcx.body_id() else {
log::warn!("Skipping obligation unassociated with local body {obl:?}");
let Some(body_id) = BODY_ID.copied() else {
return;
};

log::trace!("RECV OBLIGATION {result:?} {obl:?}");

// Use this to get rid of any resolved inference variables,
// these could have been resolved while trying to solve the obligation
// and we want to present it as such to the user.
Expand All @@ -78,8 +73,6 @@ pub fn process_obligation<'tcx>(
return;
}

log::debug!("Processing obligation {obl:?}");

let necessity = infcx.obligation_necessity(obl);
let dataid = if matches!(necessity, ObligationNecessity::Yes)
|| (matches!(necessity, ObligationNecessity::OnError) && result.is_no())
Expand All @@ -89,7 +82,8 @@ pub fn process_obligation<'tcx>(
None
};

let obligation = transform::compute_provenance(infcx, obl, result, dataid);
let obligation =
transform::compute_provenance(body_id, infcx, obl, result, dataid);

tls::store_obligation(obligation);

Expand Down Expand Up @@ -195,11 +189,13 @@ fn generate_tree<'tcx>(
predicate: obligation.predicate,
param_env: obligation.param_env,
};
let item_def_id = infcx
.body_id()
.ok_or(anyhow!("body not local"))?
.to_def_id();
serialize_proof_tree(goal, infcx, item_def_id)

let Some(body_id) = BODY_ID.copied() else {
bail!("missing body id");
};

let body_owner = infcx.tcx.hir().body_owner_def_id(body_id).to_def_id();
serialize_proof_tree(goal, obligation.cause.span, infcx, body_owner)
}

pub(in crate::analysis) fn build_obligations_in_body<'tcx>(
Expand Down
21 changes: 16 additions & 5 deletions crates/argus/src/analysis/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ impl BinCreator<'_, '_> {
.collect::<Vec<_>>();

if !obligations.is_empty() {
log::debug!(
"Associating obligations with {kind:?} {:?}\n{:#?}",
self.ctx.tcx.hir().node_to_string(target),
obligations
);

self.bins.push(Bin {
hir_id: target,
obligations,
Expand All @@ -104,23 +110,29 @@ impl BinCreator<'_, '_> {
}

impl<'a, 'tcx: 'a> HirVisitor<'_> for BinCreator<'a, 'tcx> {
// FIXME: after updating to nightly-2024-05-20 this binning logic broke slightly.
// Obligations associated with parameters are now being assigned to the overall call,
// this makes more things use a method call table than necessary.
fn visit_expr(&mut self, ex: &hir::Expr) {
// Drain nested obligations first to match the most specific node possible.
hir::intravisit::walk_expr(self, ex);

match ex.kind {
hir::ExprKind::Call(callable, args) => {
self.drain_nested(callable.hir_id, BinKind::CallableExpr);
for arg in args {
self.drain_nested(arg.hir_id, BinKind::CallArg);
}
self.drain_nested(callable.hir_id, BinKind::CallableExpr);
self.drain_nested(ex.hir_id, BinKind::Call);
}
hir::ExprKind::MethodCall(_, func, args, _) => {
self.drain_nested(func.hir_id, BinKind::MethodReceiver);
for arg in args {
self.drain_nested(arg.hir_id, BinKind::CallArg);
}
self.drain_nested(ex.hir_id, BinKind::MethodCall);
self.drain_nested(func.hir_id, BinKind::MethodReceiver);
// [ ] TODO (see above `FIXME`):
// self.drain_nested(ex.hir_id, BinKind::MethodCall);
self.drain_nested(ex.hir_id, BinKind::Misc);
}
_ => {}
}
Expand Down Expand Up @@ -193,14 +205,13 @@ macro_rules! simple_visitors {
impl HirVisitor<'_> for FindNodeBySpan {
simple_visitors! {
[visit_param, walk_param, hir::Param],
[visit_local, walk_local, hir::Local],
[visit_local, walk_local, hir::LetStmt],
[visit_block, walk_block, hir::Block],
[visit_stmt, walk_stmt, hir::Stmt],
[visit_arm, walk_arm, hir::Arm],
[visit_pat, walk_pat, hir::Pat],
[visit_pat_field, walk_pat_field, hir::PatField],
[visit_expr, walk_expr, hir::Expr],
[visit_let_expr, walk_let_expr, hir::Let],
[visit_expr_field, walk_expr_field, hir::ExprField],
[visit_ty, walk_ty, hir::Ty],
[visit_generic_param, walk_generic_param, hir::GenericParam],
Expand Down
7 changes: 6 additions & 1 deletion crates/argus/src/analysis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub fn obligations<'tcx>(
body_id: BodyId,
) -> Result<ObligationsInBody> {
rustc_middle::ty::print::with_no_trimmed_paths! {{
log::info!("Typeck'ing body {body_id:?}");
fluid_let::fluid_set!(entry::BODY_ID, body_id);

let typeck_results = tcx.inspect_typeck(body_id, entry::process_obligation);

Expand All @@ -50,6 +50,8 @@ pub fn tree<'tcx>(
body_id: BodyId,
) -> Result<SerializedTree> {
rustc_middle::ty::print::with_no_trimmed_paths! {{
fluid_let::fluid_set!(entry::BODY_ID, body_id);

let typeck_results =
tcx.inspect_typeck(body_id, entry::process_obligation_for_tree);

Expand All @@ -62,6 +64,8 @@ pub fn tree<'tcx>(
/// NOTE: this requires quite a bit of memory as everything is generated eagerly, favor
/// using a combination of `obligation` and `tree` analyses for a reduced memory footprint.
pub fn bundle<'tcx>(tcx: TyCtxt<'tcx>, body_id: BodyId) -> Result<BodyBundle> {
fluid_let::fluid_set!(entry::BODY_ID, body_id);

let (full_data, obligations_in_body) = body_data(tcx, body_id)?;
let t = (&*full_data, &obligations_in_body);
let thunk = || t;
Expand All @@ -82,6 +86,7 @@ pub fn bundle<'tcx>(tcx: TyCtxt<'tcx>, body_id: BodyId) -> Result<BodyBundle> {
.prefer_local()
.to_string_lossy()
.to_string();

Ok(BodyBundle {
filename,
body: obligations_in_body,
Expand Down
2 changes: 1 addition & 1 deletion crates/argus/src/analysis/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ pub fn replace_reported_errors(infcx: &InferCtxt) {
.reported_trait_errors
.borrow()
.iter()
.map(|(span, predicates)| {
.map(|(span, (predicates, _))| {
(
*span,
predicates
Expand Down
Loading
Loading