diff options
| author | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2020-04-28 13:02:58 +0300 |
|---|---|---|
| committer | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2020-04-28 13:02:58 +0300 |
| commit | 4d67c8da5563f7398dd7373b24bccd46c96ebb77 (patch) | |
| tree | 789610333484271ba5d8a67d0a8543bf8fa33e16 | |
| parent | fb5615a4771ea3d54256f969dc84d2dfd38d812c (diff) | |
| download | rust-4d67c8da5563f7398dd7373b24bccd46c96ebb77.tar.gz rust-4d67c8da5563f7398dd7373b24bccd46c96ebb77.zip | |
Revert "Rollup merge of #71372 - ayushmishra2005:shebang_stripping, r=estebank"
This reverts commit 46a8dcef5c9e4de0d412c6ac3c4765cb4aef4f7f, reversing changes made to f28e3873c55eb4bdcfc496e1f300b97aeb0d189c.
| -rw-r--r-- | src/librustc_lexer/src/lib.rs | 7 | ||||
| -rw-r--r-- | src/librustc_lexer/src/tests.rs | 18 |
2 files changed, 1 insertions, 24 deletions
diff --git a/src/librustc_lexer/src/lib.rs b/src/librustc_lexer/src/lib.rs index be85a34bd39..5ccfc1b276b 100644 --- a/src/librustc_lexer/src/lib.rs +++ b/src/librustc_lexer/src/lib.rs @@ -236,17 +236,12 @@ pub enum Base { /// (e.g. "#![deny(missing_docs)]"). pub fn strip_shebang(input: &str) -> Option<usize> { debug_assert!(!input.is_empty()); - let s: &str = &remove_whitespace(input); - if !s.starts_with("#!") || s.starts_with("#![") { + if !input.starts_with("#!") || input.starts_with("#![") { return None; } Some(input.find('\n').unwrap_or(input.len())) } -fn remove_whitespace(s: &str) -> String { - s.chars().filter(|c| !c.is_whitespace()).collect() -} - /// Parses the first token from the provided input string. pub fn first_token(input: &str) -> Token { debug_assert!(!input.is_empty()); diff --git a/src/librustc_lexer/src/tests.rs b/src/librustc_lexer/src/tests.rs index 065e8f3f646..06fc159fe25 100644 --- a/src/librustc_lexer/src/tests.rs +++ b/src/librustc_lexer/src/tests.rs @@ -145,22 +145,4 @@ mod tests { }), ); } - - #[test] - fn test_valid_shebang() { - // https://github.com/rust-lang/rust/issues/70528 - let input = "#!/usr/bin/rustrun"; - let actual = strip_shebang(input); - let expected: Option<usize> = Some(18); - assert_eq!(expected, actual); - } - - #[test] - fn test_invalid_shebang_valid_rust_syntax() { - // https://github.com/rust-lang/rust/issues/70528 - let input = "#! [bad_attribute]"; - let actual = strip_shebang(input); - let expected: Option<usize> = None; - assert_eq!(expected, actual); - } } |
