Skip to content

slog info macro not resolving #6955

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

Closed
wpbrown opened this issue Dec 19, 2020 · 9 comments
Closed

slog info macro not resolving #6955

wpbrown opened this issue Dec 19, 2020 · 9 comments
Labels
A-macro macro expansion S-actionable Someone could pick this issue up and work on it right now

Comments

@wpbrown
Copy link

wpbrown commented Dec 19, 2020

Rust analyzer nightly (83a2725) is reporting macros not resolving. Right-click go to definition and showing docs is working but it's indicating that it is unresolved at the same time. Stable is working.

Repro:

[package]
name = "slogtest"
version = "0.1.0"
edition = "2018"

[dependencies]
slog = "2.5.2"
slog-term = "2.6.0"
use slog::*;

fn main() {
    let decorator = slog_term::PlainSyncDecorator::new(std::io::stdout());
    let drain = slog_term::FullFormat::new(decorator).build().fuse();

    let root_log = slog::Logger::root(drain, o!("test" => "test"));
    info!(root_log, "test");
}

image

Related reports in #6847

@wpbrown
Copy link
Author

wpbrown commented Dec 19, 2020

Seen in server output:

Panic context:
> request: textDocument/codeAction CodeActionParams {
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            host: None,
            port: None,
            path: "/home/ubuntu/.cargo/registry/src/github.com-1ecc6299db9ec823/slog-2.5.2/src/lib.rs",
            query: None,
            fragment: None,
        },
    },
    range: Range {
        start: Position {
            line: 0,
            character: 0,
        },
        end: Position {
            line: 0,
            character: 0,
        },
    },
    context: CodeActionContext {
        diagnostics: [],
        only: None,
    },
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
    partial_result_params: PartialResultParams {
        partial_result_token: None,
    },
}

thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 1', /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/chalk-ir-0.43.0/src/fold/subst.rs:58:19
stack backtrace:
   0: rust_begin_unwind
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:483
   1: core::panicking::panic_fmt
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/panicking.rs:85
   2: core::panicking::panic_bounds_check
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/panicking.rs:62
   3: <chalk_ir::fold::subst::Subst<I> as chalk_ir::fold::Folder<I>>::fold_free_var_ty
   4: <chalk_ir::Ty<I> as chalk_ir::fold::SuperFold<I>>::super_fold_with
   5: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::Fold<I> for chalk_ir::GenericArg<I>>::fold_with
   6: <chalk_ir::cast::Casted<IT,U> as core::iter::traits::iterator::Iterator>::next
   7: <alloc::vec::Vec<T> as alloc::vec::SpecFromIter<T,I>>::from_iter
   8: core::iter::adapters::process_results
   9: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::Fold<I> for chalk_ir::Substitution<I>>::fold_with
  10: chalk_ir::_DERIVE_chalk_ir_fold_Fold_I_FOR_WhereClause::<impl chalk_ir::fold::Fold<I> for chalk_ir::WhereClause<I>>::fold_with
  11: chalk_ir::fold::binder_impls::<impl chalk_ir::fold::Fold<I> for chalk_ir::Binders<T>>::fold_with
  12: <core::iter::adapters::ResultShunt<I,E> as core::iter::traits::iterator::Iterator>::next
  13: <alloc::vec::Vec<T> as alloc::vec::SpecFromIter<T,I>>::from_iter
  14: core::iter::adapters::process_results
  15: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::Fold<I> for chalk_ir::QuantifiedWhereClauses<I>>::fold_with
  16: chalk_solve::infer::instantiate::<impl chalk_solve::infer::InferenceTable<I>>::instantiate_binders_universally
  17: <chalk_solve::infer::unify::Unifier<I> as chalk_ir::zip::Zipper<I>>::zip_binders
  18: chalk_solve::infer::unify::Unifier<I>::relate_ty_ty
  19: <chalk_solve::infer::unify::Unifier<I> as chalk_ir::zip::Zipper<I>>::zip_tys
  20: chalk_ir::zip::Zipper::zip_substs
  21: chalk_solve::infer::unify::Unifier<I>::relate_ty_ty
  22: chalk_solve::infer::unify::Unifier<I>::relate_var_ty
  23: chalk_solve::infer::unify::Unifier<I>::relate_ty_ty
  24: <chalk_solve::infer::unify::Unifier<I> as chalk_ir::zip::Zipper<I>>::zip_tys
  25: chalk_ir::zip::Zipper::zip_substs
  26: chalk_ir::_DERIVE_chalk_ir_zip_Zip_I_FOR_WhereClause::<impl chalk_ir::zip::Zip<I> for chalk_ir::WhereClause<I>>::zip_with
  27: chalk_solve::infer::unify::Unifier<I>::relate
  28: chalk_solve::infer::unify::<impl chalk_solve::infer::InferenceTable<I>>::relate
  29: chalk_recursive::fulfill::Fulfill<I,Solver,Infer>::new_with_clause
  30: <chalk_recursive::recursive::Solver<I> as chalk_recursive::solve::SolveDatabase<I>>::solve_goal
  31: <chalk_recursive::recursive::RecursiveSolver<I> as chalk_solve::solve::Solver<I>>::solve_limited
  32: hir_ty::traits::trait_solve_query
  33: salsa::runtime::Runtime::execute_query_implementation
  34: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  35: salsa::derived::slot::Slot<Q,MP>::read
  36: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  37: salsa::QueryTable<Q>::get
  38: <DB as hir_ty::db::HirDatabase>::trait_solve::__shim
  39: <DB as hir_ty::db::HirDatabase>::trait_solve
  40: hir_ty::infer::coerce::<impl hir_ty::infer::InferenceContext>::coerce
  41: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  42: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  43: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  44: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_block
  45: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  46: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  47: hir_ty::infer::infer_query
  48: salsa::runtime::Runtime::execute_query_implementation
  49: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  50: salsa::derived::slot::Slot<Q,MP>::read
  51: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  52: <DB as hir_ty::db::HirDatabase>::infer_query::__shim
  53: hir_ty::db::infer_wait
  54: hir_ty::diagnostics::validate_body
  55: hir::code_model::Function::diagnostics
  56: hir::code_model::Module::diagnostics
  57: ide::diagnostics::diagnostics
  58: ide::Analysis::diagnostics
  59: rust_analyzer::handlers::handle_code_action
  60: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@flodiebold flodiebold added A-macro macro expansion S-actionable Someone could pick this issue up and work on it right now labels Dec 19, 2020
@flodiebold flodiebold changed the title nightly: macro_rules not resolving nightly: slog info macro not resolving Dec 19, 2020
@wpbrown
Copy link
Author

wpbrown commented Dec 20, 2020

Bisected to c1cb595

c1cb5953820f26d4d0a614650bc8c50cbc5a3ce6 is the first bad commit
commit c1cb5953820f26d4d0a614650bc8c50cbc5a3ce6
Author: Jonas Schievink <[email protected]>
Date:   Tue Dec 15 15:37:37 2020 +0100

    Move to upstream `macro_rules!` model

 Cargo.lock                                         |   4 +-
 Cargo.toml                                         |   2 +
 crates/completion/src/render/macro_.rs             |   6 +-
 crates/hir/src/has_source.rs                       |   4 +-
 crates/hir/src/semantics.rs                        |   2 +-
 crates/hir/src/semantics/source_to_def.rs          |   5 +-
 crates/hir_def/src/body/lower.rs                   | 134 +++++++++++----------
 crates/hir_def/src/item_tree.rs                    |  19 ++-
 crates/hir_def/src/item_tree/lower.rs              |  24 ++--
 crates/hir_def/src/nameres/collector.rs            |  65 +++++-----
 crates/hir_def/src/path/lower.rs                   |   8 +-
 crates/hir_expand/src/builtin_macro.rs             |  16 ++-
 crates/hir_expand/src/lib.rs                       |   2 +-
 crates/hir_ty/src/tests/macros.rs                  |   1 -
 crates/ide/src/file_structure.rs                   |  14 +--
 crates/ide/src/references.rs                       |   2 +-
 crates/ide/src/syntax_highlighting.rs              |  52 ++++----
 .../test_data/highlight_doctest.html               |   2 +-
 .../test_data/highlight_strings.html               |   6 +-
 .../test_data/highlighting.html                    |   6 +-
 crates/ide_db/src/defs.rs                          |   2 +-
 crates/ide_db/src/symbol_index.rs                  |   8 +-
 crates/mbe/src/mbe_expander.rs                     |   2 +-
 crates/mbe/src/tests.rs                            |   4 +-
 crates/parser/src/grammar/items.rs                 |  44 +++++--
 crates/parser/src/syntax_kind/generated.rs         |   7 +-
 crates/syntax/src/ast/generated/nodes.rs           |  43 ++++++-
 crates/syntax/src/ast/node_ext.rs                  |  17 +--
 crates/syntax/src/display.rs                       |   2 +-
 crates/syntax/src/parsing/text_tree_sink.rs        |   4 +-
 .../parser/err/0002_duplicate_shebang.rast         |  14 ++-
 .../parser/inline/ok/0062_mod_contents.rast        |   7 +-
 .../parser/inline/ok/0096_no_semi_after_block.rast |  48 ++++----
 .../parser/inline/ok/0160_try_macro_rules.rast     |   7 +-
 .../ok/0053_outer_attribute_on_macro_rules.rast    |   7 +-
 xtask/src/ast_src.rs                               |   4 +-
 36 files changed, 322 insertions(+), 272 deletions(-)
bisect run success

@flodiebold
Copy link
Member

CC @jonas-schievink

@jonas-schievink
Copy link
Contributor

I'm assuming the index out of bounds in chalk is unrelated?

@flodiebold
Copy link
Member

I would assume so as well.

@wpbrown wpbrown changed the title nightly: slog info macro not resolving slog info macro not resolving Dec 22, 2020
@wpbrown
Copy link
Author

wpbrown commented Dec 22, 2020

This is now in the stable release.

@extrawurst
Copy link

just stumbled over It too on stable now, almost filed a new issue 🙈

@lnicola
Copy link
Member

lnicola commented Dec 22, 2020

The warning can be disabled with "rust-analyzer.diagnostics.disabled": ["macro-error"].

@jonas-schievink
Copy link
Contributor

Confirmed fixed by #7027

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macro macro expansion S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

No branches or pull requests

5 participants