diff --git a/rust/rust_proc.py b/rust/rust_proc.py index 4bca4350..5cbe70bd 100644 --- a/rust/rust_proc.py +++ b/rust/rust_proc.py @@ -12,6 +12,7 @@ import threading import time import shellenv +import traceback from . import util @@ -298,13 +299,20 @@ def _read_stdout(self): try: self.listener.on_json(self, result) except: - self._cleanup() - raise + self.listener.on_error(self, + 'Rust Enhanced Internal Error: %s' % ( + traceback.format_exc(),)) else: if self.json_stop_pattern and \ re.match(self.json_stop_pattern, line): # Stop looking for JSON open curly bracket. self.decode_json = False + if line.startswith('--- stderr'): + # Rust 1.19 had a bug + # (https://github.com/rust-lang/cargo/issues/4223) where + # it was incorrectly printing stdout from the compiler + # (fixed in 1.20). + self.decode_json = False # Sublime always uses \n internally. line = line.replace('\r\n', '\n') self.listener.on_data(self, line) diff --git a/tests/error-tests/benches/bench_err.rs b/tests/error-tests/benches/bench_err.rs index c1185fa5..ea25da75 100644 --- a/tests/error-tests/benches/bench_err.rs +++ b/tests/error-tests/benches/bench_err.rs @@ -3,4 +3,5 @@ #[asdf] // ^^^^^^^ERR The attribute `asdf` is currently unknown +// ^^^^^^^HELP(>=1.21.0-nightly) add #![feature(custom_attribute)] fn f() {} diff --git a/tests/error-tests/tests/binop-mul-bool.rs b/tests/error-tests/tests/binop-mul-bool.rs index 45df6189..93dea91f 100644 --- a/tests/error-tests/tests/binop-mul-bool.rs +++ b/tests/error-tests/tests/binop-mul-bool.rs @@ -11,5 +11,7 @@ // error-pattern:`*` cannot be applied to type `bool` fn main() { let x = true * false; } -// ^^^^ERR binary operation -// ^^^^NOTE an implementation of +// ^^^^ERR(<1.19.0) binary operation +// ^^^^NOTE(<1.19.0) an implementation of +// ^^^^^^^^^^^^ERR(>=1.19.0) binary operation +// ^^^^^^^^^^^^NOTE(>=1.19.0) an implementation of diff --git a/tests/error-tests/tests/cast-to-unsized-trait-object-suggestion.rs b/tests/error-tests/tests/cast-to-unsized-trait-object-suggestion.rs index 85b51444..8ca65bcf 100644 --- a/tests/error-tests/tests/cast-to-unsized-trait-object-suggestion.rs +++ b/tests/error-tests/tests/cast-to-unsized-trait-object-suggestion.rs @@ -15,6 +15,6 @@ fn main() { // ^^^^HELP &1 as &Send Box::new(1) as Send; // ^^^^^^^^^^^^^^^^^^^ERR cast to unsized type -// ^^^^HELP try casting to a `Box` instead: +// ^^^^HELP try casting to a `Box` instead // ^^^^HELP Box::new(1) as Box; } diff --git a/tests/test_syntax_check.py b/tests/test_syntax_check.py index bb871ad2..a719eb55 100755 --- a/tests/test_syntax_check.py +++ b/tests/test_syntax_check.py @@ -83,6 +83,15 @@ def test_messages(self): methods.append('check') else: print('Skipping check, need rust >= 1.16.') + if semver.match(self.rustc_version, '>=1.19.0'): + # -Zno-trans now requires nightly + self._override_setting('cargo_build', { + 'variants': { + 'no-trans': { + 'toolchain': 'nightly' + } + } + }) for path in to_test: path = os.path.join('tests', path) self._with_open_file(path, self._test_messages, @@ -134,6 +143,15 @@ def _test_messages2(self, view, phantoms, regions, method): self._get_rust_thread().join() expected_messages = self._collect_expected_regions(view) + # Refresh based on the toolchain used. + window = sublime.active_window() + manifest_path = util.find_cargo_manifest(view.file_name()) + cs = cargo_settings.CargoSettings(window) + cs.load() + toolchain = cs.get_computed(manifest_path, method, None, 'toolchain') + self.rustc_version = util.get_rustc_version(window, manifest_path, + toolchain=toolchain) + def restriction_check(restrictions): if not restrictions: return True @@ -162,14 +180,14 @@ def restriction_check(restrictions): self.assertIn(emsg_info['level_text'], content) break else: - raise AssertionError('Did not find expected message "%s:%s" for region %r:%r for file %r' % ( + raise AssertionError('Did not find expected message "%s:%s" for region %r:%r for file %r method=%r\nAvailable phantoms=%r' % ( emsg_info['level'], emsg_info['message'], emsg_info['begin'], emsg_info['end'], - view.file_name())) + view.file_name(), method, phantoms)) del phantoms[i] if len(phantoms): - raise AssertionError('Got extra phantoms for %r: %r' % ( - view.file_name(), phantoms)) + raise AssertionError('Got extra phantoms for %r (method=%s): %r' % ( + view.file_name(), method, phantoms)) # Check regions. found_regions = set() @@ -181,8 +199,9 @@ def restriction_check(restrictions): if r in region_set: found_regions.add(r) else: - raise AssertionError('Did not find expected region %r,%r for file %r' % ( - emsg_info['begin'], emsg_info['end'], view.file_name())) + raise AssertionError('Did not find expected region %r,%r for file %r method %r\nActual regions=%r' % ( + emsg_info['begin'], emsg_info['end'], view.file_name(), + method, region_set)) if len(region_set) != len(found_regions): extra_regions = region_set - found_regions raise AssertionError('Got extra regions for %r: %r' % ( diff --git a/tests/workspace/workspace1/src/lib.rs b/tests/workspace/workspace1/src/lib.rs index 99773532..98f82fbc 100644 --- a/tests/workspace/workspace1/src/lib.rs +++ b/tests/workspace/workspace1/src/lib.rs @@ -5,6 +5,7 @@ mod anothermod; // ^^^^^^^^ERR(>=1.18.0) recursive type `S` has infinite size // ^^^^^^^^HELP(>=1.18.0) insert indirection recursive: S +// ^^^^^^^^^^^^ERR(>=1.19.0) recursive without indirection }/*END*/ // ~ERR(<1.18.0) recursive type has infinite size // ~ERR(<1.18.0) recursive type `S` has infinite size