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

cargo check fails only in incremental mode #58291

Closed
matklad opened this issue Feb 8, 2019 · 13 comments
Closed

cargo check fails only in incremental mode #58291

matklad opened this issue Feb 8, 2019 · 13 comments
Assignees
Labels
A-incr-comp Area: Incremental compilation A-traits Area: Trait system C-bug Category: This is a bug. regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matklad
Copy link
Member

matklad commented Feb 8, 2019

I think I see a behavior where incremental compilation introduce a spurious compiler error.

The code is rust-lang/rust-analyzer@9798463.

I run cargo check and env CARGO_INCREMENTAL=0 cargo check in crates/ra_ide_api directory.

The first (incremental) fails with

[E0599]
    Checking ra_arena v0.1.0 (/home/matklad/projects/rust-analyzer/crates/ra_arena)
    Checking ra_tt v0.1.0 (/home/matklad/projects/rust-analyzer/crates/ra_tt)
    Checking test_utils v0.1.0 (/home/matklad/projects/rust-analyzer/crates/test_utils)
    Checking ra_text_edit v0.1.0 (/home/matklad/projects/rust-analyzer/crates/ra_text_edit)
    Checking ra_syntax v0.1.0 (/home/matklad/projects/rust-analyzer/crates/ra_syntax)
    Checking ra_mbe v0.1.0 (/home/matklad/projects/rust-analyzer/crates/ra_mbe)
    Checking ra_db v0.1.0 (/home/matklad/projects/rust-analyzer/crates/ra_db)
    Checking ra_ide_api_light v0.1.0 (/home/matklad/projects/rust-analyzer/crates/ra_ide_api_light)
    Checking ra_hir v0.1.0 (/home/matklad/projects/rust-analyzer/crates/ra_hir)
    Checking ra_assists v0.1.0 (/home/matklad/projects/rust-analyzer/crates/ra_assists)
    Checking ra_ide_api v0.1.0 (/home/matklad/projects/rust-analyzer/crates/ra_ide_api)
error[E0599]: no method named `file_text` found for type `salsa::Snapshot<db::RootDatabase>` in the current scope
   --> crates/ra_ide_api/src/lib.rs:219:17
    |
219 |         self.db.file_text(file_id)
    |                 ^^^^^^^^^
    |
    = note: the method `file_text` exists but the following trait bounds were not satisfied:
            `salsa::Snapshot<db::RootDatabase> : ra_db::SourceDatabase`
            `db::RootDatabase : ra_db::SourceDatabase`
    = help: items from traits can only be used if the trait is implemented and in scope
    = note: the following trait defines an item `file_text`, perhaps you need to implement it:
            candidate #1: `ra_db::SourceDatabase`

error[E0599]: no method named `parse` found for type `salsa::Snapshot<db::RootDatabase>` in the current scope
   --> crates/ra_ide_api/src/lib.rs:224:17
    |
224 |         self.db.parse(file_id).clone()
    |                 ^^^^^
    |
    = note: the method `parse` exists but the following trait bounds were not satisfied:
            `salsa::Snapshot<db::RootDatabase> : ra_db::SourceDatabase`
            `db::RootDatabase : ra_db::SourceDatabase`
    = help: items from traits can only be used if the trait is implemented and in scope
    = note: the following trait defines an item `parse`, perhaps you need to implement it:
            candidate #1: `ra_db::SourceDatabase`

error[E0599]: no method named `parse` found for type `salsa::Snapshot<db::RootDatabase>` in the current scope
   --> crates/ra_ide_api/src/lib.rs:241:28
    |
241 |         let file = self.db.parse(position.file_id);
    |                            ^^^^^
    |
    = note: the method `parse` exists but the following trait bounds were not satisfied:
            `salsa::Snapshot<db::RootDatabase> : ra_db::SourceDatabase`
            `db::RootDatabase : ra_db::SourceDatabase`
    = help: items from traits can only be used if the trait is implemented and in scope
    = note: the following trait defines an item `parse`, perhaps you need to implement it:
            candidate #1: `ra_db::SourceDatabase`

error[E0599]: no method named `parse` found for type `salsa::Snapshot<db::RootDatabase>` in the current scope
   --> crates/ra_ide_api/src/lib.rs:248:28
    |
248 |         let file = self.db.parse(file_id);
    |                            ^^^^^
    |
    = note: the method `parse` exists but the following trait bounds were not satisfied:
            `salsa::Snapshot<db::RootDatabase> : ra_db::SourceDatabase`
            `db::RootDatabase : ra_db::SourceDatabase`
    = help: items from traits can only be used if the trait is implemented and in scope
    = note: the following trait defines an item `parse`, perhaps you need to implement it:
            candidate #1: `ra_db::SourceDatabase`

error[E0599]: no method named `parse` found for type `salsa::Snapshot<db::RootDatabase>` in the current scope
   --> crates/ra_ide_api/src/lib.rs:255:28
    |
255 |         let file = self.db.parse(frange.file_id);
    |                            ^^^^^
    |
    = note: the method `parse` exists but the following trait bounds were not satisfied:
            `salsa::Snapshot<db::RootDatabase> : ra_db::SourceDatabase`
            `db::RootDatabase : ra_db::SourceDatabase`
    = help: items from traits can only be used if the trait is implemented and in scope
    = note: the following trait defines an item `parse`, perhaps you need to implement it:
            candidate #1: `ra_db::SourceDatabase`

error[E0599]: no method named `parse` found for type `salsa::Snapshot<db::RootDatabase>` in the current scope
   --> crates/ra_ide_api/src/lib.rs:265:28
    |
265 |         let file = self.db.parse(position.file_id);
    |                            ^^^^^
    |
    = note: the method `parse` exists but the following trait bounds were not satisfied:
            `salsa::Snapshot<db::RootDatabase> : ra_db::SourceDatabase`
            `db::RootDatabase : ra_db::SourceDatabase`
    = help: items from traits can only be used if the trait is implemented and in scope
    = note: the following trait defines an item `parse`, perhaps you need to implement it:
            candidate #1: `ra_db::SourceDatabase`

error[E0599]: no method named `parse` found for type `salsa::Snapshot<db::RootDatabase>` in the current scope
   --> crates/ra_ide_api/src/lib.rs:274:28
    |
274 |         let file = self.db.parse(position.file_id);
    |                            ^^^^^
    |
    = note: the method `parse` exists but the following trait bounds were not satisfied:
            `salsa::Snapshot<db::RootDatabase> : ra_db::SourceDatabase`
            `db::RootDatabase : ra_db::SourceDatabase`
    = help: items from traits can only be used if the trait is implemented and in scope
    = note: the following trait defines an item `parse`, perhaps you need to implement it:
            candidate #1: `ra_db::SourceDatabase`

error[E0599]: no method named `parse` found for type `salsa::Snapshot<db::RootDatabase>` in the current scope
   --> crates/ra_ide_api/src/lib.rs:281:28
    |
281 |         let file = self.db.parse(position.file_id);
    |                            ^^^^^
    |
    = note: the method `parse` exists but the following trait bounds were not satisfied:
            `salsa::Snapshot<db::RootDatabase> : ra_db::SourceDatabase`
            `db::RootDatabase : ra_db::SourceDatabase`
    = help: items from traits can only be used if the trait is implemented and in scope
    = note: the following trait defines an item `parse`, perhaps you need to implement it:
            candidate #1: `ra_db::SourceDatabase`

error[E0599]: no method named `parse` found for type `salsa::Snapshot<db::RootDatabase>` in the current scope
   --> crates/ra_ide_api/src/lib.rs:289:28
    |
289 |         let file = self.db.parse(file_id);
    |                            ^^^^^
    |
    = note: the method `parse` exists but the following trait bounds were not satisfied:
            `salsa::Snapshot<db::RootDatabase> : ra_db::SourceDatabase`
            `db::RootDatabase : ra_db::SourceDatabase`
    = help: items from traits can only be used if the trait is implemented and in scope
    = note: the following trait defines an item `parse`, perhaps you need to implement it:
            candidate #1: `ra_db::SourceDatabase`

error[E0599]: no method named `parse` found for type `salsa::Snapshot<db::RootDatabase>` in the current scope
   --> crates/ra_ide_api/src/lib.rs:295:28
    |
295 |         let file = self.db.parse(file_id);
    |                            ^^^^^
    |
    = note: the method `parse` exists but the following trait bounds were not satisfied:
            `salsa::Snapshot<db::RootDatabase> : ra_db::SourceDatabase`
            `db::RootDatabase : ra_db::SourceDatabase`
    = help: items from traits can only be used if the trait is implemented and in scope
    = note: the following trait defines an item `parse`, perhaps you need to implement it:
            candidate #1: `ra_db::SourceDatabase`

error[E0599]: no method named `crate_graph` found for type `&db::RootDatabase` in the current scope
   --> crates/ra_ide_api/src/lib.rs:350:30
    |
350 |         self.with_db(|db| db.crate_graph().crate_root(crate_id))
    |                              ^^^^^^^^^^^
    |
    = note: the method `crate_graph` exists but the following trait bounds were not satisfied:
            `db::RootDatabase : ra_db::SourceDatabase`
            `&db::RootDatabase : ra_db::SourceDatabase`
            `db::RootDatabase : ra_db::SourceDatabase`
    = help: items from traits can only be used if the trait is implemented and in scope
    = note: the following trait defines an item `crate_graph`, perhaps you need to implement it:
            candidate #1: `ra_db::SourceDatabase`

error[E0599]: no method named `parse` found for type `&db::RootDatabase` in the current scope
  --> crates/ra_ide_api/src/goto_definition.rs:15:19
   |
15 |     let file = db.parse(position.file_id);
   |                   ^^^^^
   |
   = note: the method `parse` exists but the following trait bounds were not satisfied:
           `db::RootDatabase : ra_db::SourceDatabase`
           `&db::RootDatabase : ra_db::SourceDatabase`
           `db::RootDatabase : ra_db::SourceDatabase`
   = help: items from traits can only be used if the trait is implemented and in scope
   = note: the following trait defines an item `parse`, perhaps you need to implement it:
           candidate #1: `ra_db::SourceDatabase`

error[E0599]: no method named `parse` found for type `&db::RootDatabase` in the current scope
  --> crates/ra_ide_api/src/hover.rs:10:19
   |
10 |     let file = db.parse(position.file_id);
   |                   ^^^^^
   |
   = note: the method `parse` exists but the following trait bounds were not satisfied:
           `db::RootDatabase : ra_db::SourceDatabase`
           `&db::RootDatabase : ra_db::SourceDatabase`
           `db::RootDatabase : ra_db::SourceDatabase`
   = help: items from traits can only be used if the trait is implemented and in scope
   = note: the following trait defines an item `parse`, perhaps you need to implement it:
           candidate #1: `ra_db::SourceDatabase`

error[E0599]: no method named `parse` found for type `&db::RootDatabase` in the current scope
  --> crates/ra_ide_api/src/impls.rs:14:19
   |
14 |     let file = db.parse(position.file_id);
   |                   ^^^^^
   |
   = note: the method `parse` exists but the following trait bounds were not satisfied:
           `db::RootDatabase : ra_db::SourceDatabase`
           `&db::RootDatabase : ra_db::SourceDatabase`
           `db::RootDatabase : ra_db::SourceDatabase`
   = help: items from traits can only be used if the trait is implemented and in scope
   = note: the following trait defines an item `parse`, perhaps you need to implement it:
           candidate #1: `ra_db::SourceDatabase`

error: aborting due to 14 previous errors

For more information about this error, try `rustc --explain E0599`.
error: Could not compile `ra_ide_api`.

To learn more, run the command again with --verbose.

The second (non-incremental) exists successfully.

@matklad
Copy link
Member Author

matklad commented Feb 8, 2019

Here are full steps to reproduce:

λ git clone git@github.com:rust-analyzer/rust-analyzer
Cloning into 'rust-analyzer'...
remote: Enumerating objects: 12, done.
remote: Counting objects: 100% (12/12), done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 25560 (delta 1), reused 4 (delta 0), pack-reused 25548
Receiving objects: 100% (25560/25560), 4.59 MiB | 5.92 MiB/s, done.
Resolving deltas: 100% (16039/16039), done.

11:36:57|~/tmp
λ cd rust-analyzer/

11:37:21|~/tmp/rust-analyzer|master✓
λ git checkout incremental-bug 
Branch 'incremental-bug' set up to track remote branch 'incremental-bug' from 'origin'.
Switched to a new branch 'incremental-bug'

11:37:25|~/tmp/rust-analyzer|incremental-bug✓
λ cd crates/ra_ide_api

11:37:31|~/tmp/rust-analyzer/crates/ra_ide_api|incremental-bug✓
λ cargo check
   Compiling semver-parser v0.7.0
   Compiling libc v0.2.48
   Compiling autocfg v0.1.2
   Compiling proc-macro2 v0.4.27
    Checking rand_core v0.4.0
   Compiling unicode-xid v0.1.0
    Checking void v1.0.2
    Checking stable_deref_trait v1.1.1
    Checking cfg-if v0.1.6
    Checking remove_dir_all v0.5.1
   Compiling serde v1.0.87
   Compiling byteorder v1.3.1
   Compiling num-traits v0.2.6
   Compiling ryu v0.2.7
    Checking quick-error v1.2.2
    Checking spin v0.4.10
    Checking fnv v1.0.6
    Checking scopeguard v0.3.3
    Checking bit-vec v0.5.0
    Checking ucd-util v0.1.3
   Compiling unicode-segmentation v1.2.1
   Compiling arrayvec v0.4.10
    Checking bitflags v1.0.4
    Checking itoa v0.4.3
    Checking colosseum v0.2.2
    Checking either v1.5.0
    Checking nodrop v0.1.13
    Checking memoffset v0.2.1
    Checking difference v2.0.0
    Checking drop_bomb v0.1.4
    Checking indexmap v1.0.2
   Compiling version_check v0.1.5
   Compiling rayon-core v1.4.1
    Checking ra_arena v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_arena)
    Checking relative-path v0.4.0
    Checking superslice v0.1.0
   Compiling rayon v1.0.3
    Checking join_to_string v0.1.3
    Checking unreachable v1.0.0
    Checking owning_ref v0.4.0
    Checking crossbeam-utils v0.2.2
    Checking log v0.4.6
    Checking rand_core v0.3.1
    Checking rand_jitter v0.1.2
   Compiling semver v0.9.0
   Compiling rand_chacha v0.1.1
   Compiling rand v0.6.5
    Checking lazy_static v1.2.0
    Checking regex-syntax v0.6.5
    Checking bit-set v0.5.0
    Checking itertools v0.8.0
   Compiling heck v0.3.1
    Checking smallvec v0.6.8
   Compiling unicase v2.2.0
    Checking lock_api v0.1.5
    Checking rand_xorshift v0.1.1
    Checking rand_hc v0.1.0
    Checking rand_isaac v0.1.1
    Checking ena v0.11.0
   Compiling rustc_version v0.2.3
    Checking rand_os v0.1.2
    Checking wait-timeout v0.1.5
    Checking num_cpus v1.9.0
    Checking memmap v0.6.2
    Checking rustc-hash v1.0.1
    Checking crossbeam-epoch v0.3.1
   Compiling rand_pcg v0.1.1
   Compiling parking_lot_core v0.4.0
   Compiling quote v0.6.11
    Checking fst v0.3.3
    Checking crossbeam-deque v0.2.0
   Compiling syn v0.15.26
    Checking tempfile v3.0.5
    Checking rusty-fork v0.2.1
    Checking parking_lot v0.7.1
    Checking proptest v0.9.0
   Compiling serde_derive v1.0.87
   Compiling derive-new v0.5.6
   Compiling salsa-macros v0.10.0
    Checking salsa v0.10.0
    Checking text_unit v0.1.6
    Checking smol_str v0.1.9
    Checking serde_json v1.0.38
    Checking ra_tt v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_tt)
    Checking rowan v0.3.3
    Checking ra_text_edit v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_text_edit)
    Checking ra_syntax v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_syntax)
    Checking test_utils v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/test_utils)
    Checking ra_db v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_db)
    Checking ra_mbe v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_mbe)
    Checking ra_ide_api_light v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_ide_api_light)
    Checking ra_hir v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_hir)
    Checking ra_assists v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_assists)
    Checking ra_ide_api v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_ide_api)
    Finished dev [unoptimized + debuginfo] target(s) in 32.79s

11:38:06|~/tmp/rust-analyzer/crates/ra_ide_api|incremental-bug✓
λ env CARGO_INCREMENTAL=0 cargo check
    Checking ra_arena v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_arena)
    Checking ra_tt v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_tt)
    Checking test_utils v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/test_utils)
    Checking ra_text_edit v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_text_edit)
    Checking ra_syntax v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_syntax)
    Checking ra_db v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_db)
    Checking ra_mbe v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_mbe)
    Checking ra_ide_api_light v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_ide_api_light)
    Checking ra_hir v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_hir)
    Checking ra_assists v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_assists)
    Checking ra_ide_api v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_ide_api)
    Finished dev [unoptimized + debuginfo] target(s) in 6.31s

11:38:22|~/tmp/rust-analyzer/crates/ra_ide_api|incremental-bug✓
λ nvim src/impls.rs # add a blank line before pub(crate) fn goto_implementation

11:44:30|~/tmp/rust-analyzer/crates/ra_ide_api|incremental-bug⚡*
λ git diff
diff --git a/crates/ra_ide_api/src/impls.rs b/crates/ra_ide_api/src/impls.rs
index 4fb05413..a1780017 100644
--- a/crates/ra_ide_api/src/impls.rs
+++ b/crates/ra_ide_api/src/impls.rs
@@ -7,6 +7,7 @@ use hir::{db::HirDatabase, source_binder};
 
 use crate::{FilePosition, NavigationTarget, db::RootDatabase, RangeInfo};
 
+
 pub(crate) fn goto_implementation(
     db: &RootDatabase,
     position: FilePosition,

11:38:38|~/tmp/rust-analyzer/crates/ra_ide_api|incremental-bug⚡*
λ cargo check
    Checking ra_arena v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_arena)
    Checking ra_tt v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_tt)
    Checking test_utils v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/test_utils)
    Checking ra_text_edit v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_text_edit)
    Checking ra_syntax v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_syntax)
    Checking ra_mbe v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_mbe)
    Checking ra_db v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_db)
    Checking ra_ide_api_light v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_ide_api_light)
    Checking ra_hir v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_hir)
    Checking ra_assists v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_assists)
    Checking ra_ide_api v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_ide_api)
error[E0599]: no method named `parse` found for type `&db::RootDatabase` in the current scope
  --> crates/ra_ide_api/src/impls.rs:15:19
   |
15 |     let file = db.parse(position.file_id);
   |                   ^^^^^
   |
   = note: the method `parse` exists but the following trait bounds were not satisfied:
           `db::RootDatabase : ra_db::SourceDatabase`
           `&db::RootDatabase : ra_db::SourceDatabase`
           `db::RootDatabase : ra_db::SourceDatabase`
   = help: items from traits can only be used if the trait is implemented and in scope
   = note: the following trait defines an item `parse`, perhaps you need to implement it:
           candidate #1: `ra_db::SourceDatabase`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0599`.
error: Could not compile `ra_ide_api`.

To learn more, run the command again with --verbose.

11:44:31|~/tmp/rust-analyzer/crates/ra_ide_api|incremental-bug⚡*
λ env CARGO_INCREMENTAL=0 cargo check
    Checking ra_arena v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_arena)
    Checking ra_tt v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_tt)
    Checking test_utils v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/test_utils)
    Checking ra_text_edit v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_text_edit)
    Checking ra_syntax v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_syntax)
    Checking ra_db v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_db)
    Checking ra_mbe v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_mbe)
    Checking ra_ide_api_light v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_ide_api_light)
    Checking ra_hir v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_hir)
    Checking ra_assists v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_assists)
    Checking ra_ide_api v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_ide_api)
    Finished dev [unoptimized + debuginfo] target(s) in 5.93s

11:45:16|~/tmp/rust-analyzer/crates/ra_ide_api|incremental-bug⚡*
λ cargo check
    Checking ra_arena v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_arena)
    Checking ra_tt v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_tt)
    Checking test_utils v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/test_utils)
    Checking ra_text_edit v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_text_edit)
    Checking ra_syntax v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_syntax)
    Checking ra_db v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_db)
    Checking ra_mbe v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_mbe)
    Checking ra_ide_api_light v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_ide_api_light)
    Checking ra_hir v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_hir)
    Checking ra_assists v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_assists)
    Checking ra_ide_api v0.1.0 (/home/matklad/tmp/rust-analyzer/crates/ra_ide_api)
error[E0599]: no method named `parse` found for type `&db::RootDatabase` in the current scope
  --> crates/ra_ide_api/src/impls.rs:15:19
   |
15 |     let file = db.parse(position.file_id);
   |                   ^^^^^
   |
   = note: the method `parse` exists but the following trait bounds were not satisfied:
           `db::RootDatabase : ra_db::SourceDatabase`
           `&db::RootDatabase : ra_db::SourceDatabase`
           `db::RootDatabase : ra_db::SourceDatabase`
   = help: items from traits can only be used if the trait is implemented and in scope
   = note: the following trait defines an item `parse`, perhaps you need to implement it:
           candidate #1: `ra_db::SourceDatabase`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0599`.
error: Could not compile `ra_ide_api`.

To learn more, run the command again with --verbose.

11:45:23|~/tmp/rust-analyzer/crates/ra_ide_api|incremental-bug⚡*
λ rustc --version
rustc 1.32.0 (9fda7c223 2019-01-16)

@jonas-schievink jonas-schievink added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-incr-comp Area: Incremental compilation C-bug Category: This is a bug. labels Feb 8, 2019
@matklad
Copy link
Member Author

matklad commented Feb 11, 2019

I continue to see this problem, so it is not a completely random thing.

@flodiebold
Copy link
Member

flodiebold commented Feb 11, 2019

Yes, I've experienced this as well in rust-analyzer. It might be related to salsa using a procedural macro?

Deleting the incremental folder also fixes the build, btw.

@matklad
Copy link
Member Author

matklad commented Feb 11, 2019

Happens on beta (rustc 1.33.0-beta.6 (b203178 2019-02-05)) as well.

@kjeremy
Copy link

kjeremy commented Mar 1, 2019

Still happening on 1.33.0

@kjeremy
Copy link

kjeremy commented Mar 13, 2019

Can reproduce on nightly too.

cargo 1.35.0-nightly (95b45eca1 2019-03-06)

@nikomatsakis
Copy link
Contributor

Is this a regression? Can we bisect it down to a specific PR using cargo-bisect-rustc, or at least a specific nightly?

@matklad
Copy link
Member Author

matklad commented Mar 23, 2019

Did a little investigation, looks like two events are the most likely causes of this issue:

salsa's upgrade to the proc-macro version: rust-lang/rust-analyzer@a2ca03d
rustc upgrade to 1.32 from 1.32 rust-lang/rust-analyzer@b028472

It's not super easy to bisect between the two, because salsa at the time of upgrade required 1.32

@pnkfelix pnkfelix self-assigned this Apr 11, 2019
@pnkfelix
Copy link
Member

pnkfelix commented Apr 15, 2019

I spent a (quite a) while narrowing this down to a single crate test case with no dependencies.

https://gist.github.com/pnkfelix/5a27ed7f789f90f3c6256aef39a73c82

I wasn't able to get it down to a single file; manually inlining each of the mod impls; (into two distinct versions of lib.rs) causes the problem to go away.

But its less than 300 lines of code and it is indeed enough to reproduce the problem on its own via calls to cargo check, and you can cargo clean very fast in between each call since its a single crate.

  • plus I'm betting it can be reduced much further if someone wants to invest the time into that.

Here's a sample run to demo how to use the files there:

% cargo clean && echo ---- THE DIFF ---- && diff -u src/impls_v1.rs src/impls_v2.rs ; echo ---- IMPL 1 ---- && cp src/impls_v1.rs src/impls.rs && cargo +nightly check && \
cp src/impls_v2.rs src/impls.rs && echo ---- IMPL 2 ---- && cargo +nightly check
---- THE DIFF ----
--- src/impls_v1.rs     2019-04-15 14:33:59.693052503 +0200
+++ src/impls_v2.rs     2019-04-15 14:34:03.190103348 +0200
@@ -2,5 +2,6 @@
 use crate::SourceDatabase;
 use crate::RootDatabase;

+
 pub(crate) fn goto_implementation(db: &RootDatabase) -> u32
 { db.parse(); loop { } }
---- IMPL 1 ----
    Checking ra_ide_api v0.1.0 (/tmp/issue_58291/ra_ide_api)
warning: function is never used: `goto_implementation`
 --> src/impls.rs:5:1
  |
5 | pub(crate) fn goto_implementation(db: &RootDatabase) -> u32
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: #[warn(dead_code)] on by default

    Finished dev [unoptimized + debuginfo] target(s) in 0.19s
---- IMPL 2 ----
    Checking ra_ide_api v0.1.0 (/tmp/issue_58291/ra_ide_api)
error[E0599]: no method named `parse` found for type `&RootDatabase` in the current scope
 --> src/impls.rs:7:6
  |
7 | { db.parse(); loop { } }
  |      ^^^^^
  |
  = note: the method `parse` exists but the following trait bounds were not satisfied:
          `&RootDatabase : SourceDatabase`
          `RootDatabase : SourceDatabase`
  = help: items from traits can only be used if the trait is implemented and in scope
  = note: the following trait defines an item `parse`, perhaps you need to implement it:
          candidate #1: `SourceDatabase`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0599`.
error: Could not compile `ra_ide_api`.

To learn more, run the command again with --verbose.
%

@pnkfelix
Copy link
Member

pnkfelix commented Apr 15, 2019

(Oh! And of course the obvious next step is to figure out if my reduced test case show that this is a regression.)

@pnkfelix
Copy link
Member

pnkfelix commented Apr 16, 2019

Holy cow, it is an injection (i.e. regression)!

With some modifications to deal with the slightly older build, I was able to observe the same bug occurring on nightly-2018-04-28 (version info: "rustc 1.27.0-nightly (686d0ae 2018-04-27)"). It does not occur on nightly-2018-04-27 (version info: "rustc 1.27.0-nightly (7f3444e 2018-04-26)")

% git log 7f3444e1b..686d0ae13 --author=bors --format=oneline

@pnkfelix
Copy link
Member

pnkfelix commented Apr 16, 2019

Here's another potentially interesting fact: some small modifications to the test input reveal differing behavior (in terms of whether the parse method is resolved or not) between the aformentioned pair of nightly builds, when building from scratch.

I.e. this may be a (very old) regression with respect to trait resolution that is independent of incremental compilation (but may be more easily exposed via incremental compilation.)

And the regression in that latter case is exposed even when I inline the mod impls into lib.rs, so I can reduce it to the following single file:

https://gist.github.com/8a153e8b9ca82eaf748684e38f33f6e5

I'm going to file this new test case as a separate bug (#60010), since I want to make sure that I treat the incremental compilation bug as a distinct problem, at least until we've seen more evidence that a fix for the pure trait-resolution bug would actually fix the incremental compilation problem.

@pnkfelix pnkfelix added regression-from-stable-to-stable Performance or correctness regression from one stable version to another. A-traits Area: Trait system labels Apr 16, 2019
matklad added a commit to rust-lang/rust-analyzer that referenced this issue May 18, 2019
Unfortunately, that `: RefUnwindSafe` bound gives rustc a hard time,
so let's remove it for know.

See

* #1283
* rust-lang/rust#60444
* rust-lang/rust#58291

closes #1283
@pnkfelix
Copy link
Member

This was resolved between rustc 1.36.0-nightly (a9ec99f 2019-05-13) and rustc 1.36.0-nightly (372be4f 2019-05-14).

(The resolution is that neither variant of the code should have been accepted by the compiler; the fact that it was accepted was due to a bug in the way that we mixed inductive and co-inductive reasoning when resolving trait constraints.)

The difference between the above two nightlies is these three bors commits:

% git log --format=oneline --author=bors a9ec99f42..372be4f36
372be4f360ce42b1a10126a711189796f8440ab4 Auto merge of #60834 - Centril:rollup-fikyi9i, r=Centril
f59c71eb8ed808347c1e4245b842d673c75daeb6 Auto merge of #60787 - alexcrichton:error-type-id-destabilize-master, r=pietroalbini
80e7cde2238e837a9d6a240af9a3253f469bb2cf Auto merge of #60794 - Centril:rollup-vlguvns, r=Centril

based on my knowledge of this bug, its pretty certain that this was fixed by PR #60444, which was part of rollup #60834.

Closing as fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-incr-comp Area: Incremental compilation A-traits Area: Trait system C-bug Category: This is a bug. regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants