Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request #483 from nrc/rust-field
Browse files Browse the repository at this point in the history
Fix a bug which causes field and variable references to be self-links
  • Loading branch information
erikrose committed Nov 6, 2015
2 parents b1dfbfb + b15c093 commit c550812
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dxr/plugins/rust/refs.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def prepare_menu_data(self, tree_index, datum):
else:
warn("no type for variable ref %s" % (var['qualname'],))
self.hover = truncate_value(typ, var['value'])
return trim_dict(datum, ['file_line', 'file_name', 'qualname'])
return trim_dict(var, ['file_line', 'file_name', 'qualname'])
# TODO what is the culprit here?
# print "variable ref missing def"

Expand Down
14 changes: 14 additions & 0 deletions dxr/plugins/rust/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from dxr.testing import SingleFileTestCase

class RustSingleFileTestCase(SingleFileTestCase):
"""Test case suited to testing the Rust plugin."""
source_filename = 'mod.rs'

@classmethod
def config_input(cls, config_dir_path):
config = super(RustSingleFileTestCase, cls).config_input(config_dir_path)

config['DXR']['enabled_plugins'] = 'pygmentize rust'
config['code']['build_command'] = '$RUSTC mod.rs'

return config
17 changes: 17 additions & 0 deletions dxr/plugins/rust/tests/test_var_menus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from dxr.plugins.rust.tests import RustSingleFileTestCase
from dxr.testing import menu_on

class VarMenuTests(RustSingleFileTestCase):
source = """
fn main() {
let _ = FOO;
}
const FOO: i32 = 42;
"""

def test_const_link(self):
""" test that the link to defintion works properly """
menu_on(self.source_page('mod.rs'),
'FOO',
{'html': 'Jump to definition',
'href': '/code/source/mod.rs#5'})

0 comments on commit c550812

Please sign in to comment.