Skip to content

Remove -Z no-trans support and update tests #286

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

Merged
merged 1 commit into from
Jun 5, 2018
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
80 changes: 41 additions & 39 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,56 @@
env:
global:
- PACKAGE="Rust Enhanced"
- SUBLIME_TEXT_VERSION="3"
global:
- PACKAGE="Rust Enhanced"
- SUBLIME_TEXT_VERSION="3"

language: rust

matrix:
include:
- os: linux
rust: stable

- os: osx
rust: stable

- os: linux
rust: beta

- os: osx
rust: beta
os:
- linux
- osx

- os: linux
rust: nightly

- os: osx
rust: nightly
rust:
- stable
- beta
- nightly

matrix:
allow_failures:
- rust: beta
- rust: nightly

before_install:
- curl -OL https://github.com/raw/SublimeText/UnitTesting/master/sbin/travis.sh
- curl -OL https://github.com/raw/SublimeText/UnitTesting/master/sbin/travis.sh

# enable gui, see https://docs.travis-ci.com/user/gui-and-headless-browsers
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then
export DISPLAY=:99.0;
sh -e /etc/init.d/xvfb start;
fi
# enable gui, see https://docs.travis-ci.com/user/gui-and-headless-browsers
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then
export DISPLAY=:99.0;
sh -e /etc/init.d/xvfb start;
fi


install:
# Install Sublime and Sublime Unittesting.
- sh travis.sh bootstrap
# Install Package Control, needed for dependencies.
- sh travis.sh install_package_control

# Ensure nightly is installed to run no-trans, benchmarks, and Clippy.
- rustup install nightly
# Install Rust packages needed by integration tests.
- cargo +nightly install clippy || export RE_SKIP_CLIPPY=1
- cargo install cargo-script
# Install Sublime and Sublime Unittesting.
- sh travis.sh bootstrap
# Install Package Control, needed for dependencies.
- sh travis.sh install_package_control

# Ensure nightly is installed to run benchmarks and Clippy.
# Pin a known good version of nightly and clippy.
- >
if [ "$TRAVIS_RUST_VERSION" != "nightly" ]; then
rustup install nightly-2018-05-26;
host=$(rustc -Vv | grep ^host: | sed -e "s/host: //g");
toolchains=$(dirname $(dirname $(dirname $(rustup which rustc))));
mv $toolchains/nightly-* $toolchains/nightly-$host;
cargo +nightly install --version 0.0.205 clippy || export RE_SKIP_CLIPPY=1;
else
cargo +nightly install clippy || export RE_SKIP_CLIPPY=1;
fi
# Install Rust packages needed by integration tests.
- cargo install cargo-script


script:
- sh travis.sh run_syntax_tests
- sh travis.sh run_tests
- sh travis.sh run_syntax_tests
- sh travis.sh run_tests
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,13 @@ This relies on Cargo and Rust (>= 1.8.0) being installed and on your system path
| :------ | :------ | :---------- |
| `rust_syntax_checking` | `true` | Enable the on-save syntax checking. |
| `rust_syntax_checking_method` | `"check"` | The method used for checking your code (see below). |
| `rust_syntax_checking_include_tests` | `true` | Enable checking of test code within `#[cfg(test)]` sections (only for `no-trans` method). |
| `rust_syntax_checking_include_tests` | `true` | Enable checking of test code within `#[cfg(test)]` sections. |
| `rust_syntax_hide_warnings` | `false` | Don't show warnings when syntax checking |

The available checking methods are:

| Method | Description |
| :----- | :---------- |
| `no-trans` | Runs the rustc compiler with the `-Zno-trans` option. This will be deprecated soon, however it has the benefit of supporting `#[test]` sections. |
| `check` | Uses `cargo check` (requires at least Rust 1.16). |
| `clippy` | Uses `cargo clippy`. This requires [Clippy](https://github.com/Manishearth/rust-clippy) to be installed. This also may be a little slower since it must check every target in your package. |

Expand Down
2 changes: 1 addition & 1 deletion RustEnhanced.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"rust_syntax_checking": true,

// The method used to check code on-save.
// "check", "no-trans", or "clippy" (see README.md)
// "check" or "clippy" (see README.md)
"rust_syntax_checking_method": "check",

// Enable checking of test code within #[cfg(test)] sections.
Expand Down
63 changes: 17 additions & 46 deletions SyntaxCheckPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,6 @@
whenever you save a Rust file.
"""

# Notes:
# - -Zno-trans has been deprecated, and will only be available with the
# nightly compiler starting with rust 1.19. Using "cargo check" is the
# preferred alternative, though it currently has some limitations. See:
#
# - Unstable flags removed:
# https://github.com/rust-lang/rust/issues/31847
#
# - Cargo check added in rust 1.16:
# https://github.com/rust-lang/cargo/pull/3296 (based on original
# "cargo check" addon https://github.com/rsolomo/cargo-check/)
#
# - RLS was recently released
# (https://github.com/rust-lang-nursery/rls). It's unclear to me if
# this will perform full-linting that could replace this or not.
#
# - "cargo check" ignores #[test]:
# https://github.com/rust-lang/cargo/issues/3431
#
# - "cargo check" will not re-issue errors/warnings if nothing has
# changed. This generally should not be a problem since on-save
# syntax only runs after the file has been saved which updates the
# timestamp, but it's something to be careful about. See:
# https://github.com/rust-lang/cargo/issues/3624
#
# - -Zno-trans prevents some warnings and errors from being generated. For
# example, see const-err.rs. "cargo check" does not have this problem.
# Other issues:
# - Errors generated by compiling an extern crate do not not output as
# json.


class RustSyntaxCheckEvent(sublime_plugin.EventListener):

Expand Down Expand Up @@ -134,28 +103,30 @@ def get_rustc_messages(self):
p.wait()
return

# "no-trans" or "check" methods.
if method == 'no-trans':
print('rust_syntax_checking_method == "no-trans" is no longer supported.')
print('Please change the config setting to "check".')
method = 'check'

if method != 'check':
print('Unknown setting for `rust_syntax_checking_method`: %r' % (method,))
return

td = target_detect.TargetDetector(self.window)
targets = td.determine_targets(self.triggered_file_name)
for (target_src, target_args) in targets:
cmd = settings.get_command(method, command_info, self.cwd, self.cwd,
initial_settings={'target': ' '.join(target_args)},
force_json=True)
self.msg_rel_path = cmd['msg_rel_path']
if method == 'no-trans':
cmd['command'].extend(['--', '-Zno-trans', '-Zunstable-options'])
if (util.get_setting('rust_syntax_checking_include_tests', True) and
not ('--test' in target_args or '--bench' in target_args)):
# Including the test harness has a few drawbacks.
# missing_docs lint is disabled (see
# https://github.com/rust-lang/sublime-rust/issues/156)
# It also disables the "main function not found" error for
# binaries.
cmd['command'].append('--test')
elif method == 'check':
if (util.get_setting('rust_syntax_checking_include_tests', True) and
semver.match(cmd['rustc_version'], '>=1.23.0')):
cmd['command'].append('--profile=test')
if (util.get_setting('rust_syntax_checking_include_tests', True) and
semver.match(cmd['rustc_version'], '>=1.23.0')):
# Including the test harness has a few drawbacks.
# missing_docs lint is disabled (see
# https://github.com/rust-lang/sublime-rust/issues/156)
# It also disables the "main function not found" error for
# binaries.
cmd['command'].append('--profile=test')
p = rust_proc.RustProc()
self.current_target_src = target_src
p.run(self.window, cmd['command'], self.cwd, self, env=cmd['env'])
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ install:
- curl -sSf -o rustup-init.exe https://win.rustup.rs/
- rustup-init.exe -y --default-toolchain %RUST_VERSION%
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
# Ensure nightly is installed to run no-trans, benchmarks, and Clippy.
# Ensure nightly is installed to run benchmarks and Clippy.
- rustup install nightly
# Install Rust packages needed by integration tests.
- cargo +nightly install clippy || set RE_SKIP_CLIPPY=1
Expand Down
4 changes: 1 addition & 3 deletions rust/cargo_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,7 @@ def items_variant(self):
def filter_variant(self, x):
"""Subclasses override this to filter variants from the variant
list."""
# no-trans is a special, hidden, internal command. In theory, a user
# can configure it, but since it is deprecated, just hide it for now.
return x['name'] != 'no-trans'
return True

def items_which(self):
"""Choice to select at which level the setting should be saved at."""
Expand Down
12 changes: 0 additions & 12 deletions rust/cargo_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,6 @@
'requires_view_path': True,
'requires_manifest': False,
},
# This is a special command (not exposed) used by on-save syntax checking.
'no-trans': {
'name': 'no-trans',
'command': 'rustc',
'allows_target': True,
'allows_target_triple': True,
'allows_release': True,
'allows_features': True,
'allows_json': True,
'requires_view_path': False,
'requires_manifest': False,
}
}


Expand Down
2 changes: 0 additions & 2 deletions rust/target_detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ def determine_targets(self, file_name):
if result:
return result

# TODO: Alternatively, could run rustc directly without cargo.
# rustc -Zno-trans -Zunstable-options --error-format=json file_name
print('Rust Enhanced: Failed to find target for %r' % file_name)
return []

Expand Down
7 changes: 3 additions & 4 deletions tests/error-tests/examples/no_main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// Should display error about no main.

mod no_main_mod;
// Not sure why no-trans doesn't handle this properly.
// When --profile=test is used with `cargo check`, this error will not happen
// due to the synthesized main created by the test harness.
// end-msg: ERR(rust_syntax_checking_include_tests=False OR <1.23.0,rust_syntax_checking_include_tests=True,check) /`?main`? function not found/
// end-msg: NOTE(rust_syntax_checking_include_tests=False OR <1.23.0,rust_syntax_checking_include_tests=True,check) the main function must be defined
// end-msg: MSG(rust_syntax_checking_include_tests=False OR <1.23.0,rust_syntax_checking_include_tests=True,check) See Also: no_main_mod.rs:4
// end-msg: ERR(rust_syntax_checking_include_tests=False OR <1.23.0,rust_syntax_checking_include_tests=True) /`?main`? function not found/
// end-msg: NOTE(rust_syntax_checking_include_tests=False OR <1.23.0,rust_syntax_checking_include_tests=True) the main function must be defined
// end-msg: MSG(rust_syntax_checking_include_tests=False OR <1.23.0,rust_syntax_checking_include_tests=True) See Also: no_main_mod.rs:4
6 changes: 2 additions & 4 deletions tests/error-tests/examples/no_main_mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@
// ^^^^^^^^^WARN(>=1.23.0,rust_syntax_checking_include_tests=True) function is never used
// ^^^^^^^^^NOTE(>=1.23.0,rust_syntax_checking_include_tests=True) #[warn(dead_code)]
}/*END*/
// ~NOTE(rust_syntax_checking_include_tests=False OR <1.23.0,rust_syntax_checking_include_tests=True,check) here is a function named 'main'
// ~MSG(rust_syntax_checking_include_tests=False OR <1.23.0,rust_syntax_checking_include_tests=True,check) See Primary: no_main.rs
// ~WARN(<1.19.0,no-trans,rust_syntax_checking_include_tests=True) function is never used
// ~NOTE(>=1.17.0,<1.19.0,no-trans,rust_syntax_checking_include_tests=True) #[warn(dead_code)]
// ~NOTE(rust_syntax_checking_include_tests=False OR <1.23.0,rust_syntax_checking_include_tests=True) here is a function named 'main'
// ~MSG(rust_syntax_checking_include_tests=False OR <1.23.0,rust_syntax_checking_include_tests=True) See Primary: no_main.rs
8 changes: 4 additions & 4 deletions tests/error-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ mod tests {
// ^^^^^^^^^^^^ERR(<1.16.0,rust_syntax_checking_include_tests=True) type name
// ^^^^^^^^^^^^ERR(<1.16.0,rust_syntax_checking_include_tests=True) undefined or not in scope
// ^^^^^^^^^^^^HELP(<1.16.0,rust_syntax_checking_include_tests=True) no candidates
// ^^^^^^^^^^^^ERR(>=1.16.0,<1.19.0,rust_syntax_checking_include_tests=True,no-trans OR >=1.23.0,rust_syntax_checking_include_tests=True) cannot find type `DoesNotExist`
// ^^^^^^^^^^^^ERR(>=1.16.0,<1.19.0,rust_syntax_checking_include_tests=True,no-trans OR >=1.23.0,rust_syntax_checking_include_tests=True) not found in this scope
// ^^^^^^^^^^^^ERR(>=1.23.0,rust_syntax_checking_include_tests=True) cannot find type `DoesNotExist`
// ^^^^^^^^^^^^ERR(>=1.23.0,rust_syntax_checking_include_tests=True) not found in this scope
}

#[test]
fn it_works() {
asdf
// ^^^^ERR(<1.16.0,rust_syntax_checking_include_tests=True) unresolved name
// ^^^^ERR(<1.16.0,rust_syntax_checking_include_tests=True) unresolved name
// ^^^^ERR(>=1.16.0,<1.19.0,rust_syntax_checking_include_tests=True,no-trans OR >=1.23.0,rust_syntax_checking_include_tests=True) cannot find value
// ^^^^ERR(>=1.16.0,<1.19.0,rust_syntax_checking_include_tests=True,no-trans OR >=1.23.0,rust_syntax_checking_include_tests=True) not found in this scope
// ^^^^ERR(>=1.23.0,rust_syntax_checking_include_tests=True) cannot find value
// ^^^^ERR(>=1.23.0,rust_syntax_checking_include_tests=True) not found in this scope
}
}
56 changes: 0 additions & 56 deletions tests/error-tests/tests/const-err.rs

This file was deleted.

20 changes: 10 additions & 10 deletions tests/error-tests/tests/macro-expansion-outside-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ extern crate dcrate;
// ~ERR(>=1.20.0) this error originates in a macro outside of the current crate
// ~ERR(>=1.20.0) expected one of
// ~ERR(>=1.20.0,<1.24.0-beta) unexpected token
// end-msg: ERR(check,>=1.19.0,<1.20.0-beta) /expected one of .*, found `:`/
// end-msg: ERR(check,>=1.19.0,<1.20.0-beta) Errors occurred in macro <example_bad_syntax macros> from external crate
// end-msg: ERR(check,>=1.19.0,<1.20.0-beta) Macro text: ( ) => { enum E { Kind ( x : u32 ) } }
// end-msg: ERR(check,>=1.19.0,<1.20.0-beta) /expected one of .* here/
// end-msg: ERR(check,>=1.19.0,<1.20.0-beta) unexpected token
// end-msg: ERR(check,>=1.19.0,<1.20.0-beta) /expected one of .*, found `:`/
// end-msg: ERR(check,>=1.19.0,<1.20.0-beta) Errors occurred in macro <example_bad_syntax macros> from external crate
// end-msg: ERR(check,>=1.19.0,<1.20.0-beta) Macro text: ( ) => { enum E { Kind ( x : u32 ) } }
// end-msg: ERR(check,>=1.19.0,<1.20.0-beta) expected one of 7 possible tokens here
// end-msg: ERR(check,>=1.19.0,<1.20.0-beta) unexpected token
// end-msg: ERR(>=1.19.0,<1.20.0-beta) /expected one of .*, found `:`/
// end-msg: ERR(>=1.19.0,<1.20.0-beta) Errors occurred in macro <example_bad_syntax macros> from external crate
// end-msg: ERR(>=1.19.0,<1.20.0-beta) Macro text: ( ) => { enum E { Kind ( x : u32 ) } }
// end-msg: ERR(>=1.19.0,<1.20.0-beta) /expected one of .* here/
// end-msg: ERR(>=1.19.0,<1.20.0-beta) unexpected token
// end-msg: ERR(>=1.19.0,<1.20.0-beta) /expected one of .*, found `:`/
// end-msg: ERR(>=1.19.0,<1.20.0-beta) Errors occurred in macro <example_bad_syntax macros> from external crate
// end-msg: ERR(>=1.19.0,<1.20.0-beta) Macro text: ( ) => { enum E { Kind ( x : u32 ) } }
// end-msg: ERR(>=1.19.0,<1.20.0-beta) expected one of 7 possible tokens here
// end-msg: ERR(>=1.19.0,<1.20.0-beta) unexpected token
// end-msg: ERR(<1.19.0) /expected one of .*, found `:`/
// end-msg: ERR(<1.19.0) Errors occurred in macro <example_bad_syntax macros> from external crate
// end-msg: ERR(<1.19.0) Macro text: ( ) => { enum E { Kind ( x : u32 ) } }
Expand Down
Loading