Skip to content

Commit 4d7defb

Browse files
committed
Auto merge of #59721 - Centril:rollup-ieam9ke, r=Centril
Rollup of 5 pull requests Successful merges: - #59665 (improve worst-case performance of HashSet.is_subset) - #59687 (cleanup shebang handling in the lexer) - #59690 (Mark unix::ffi::OsStrExt methods as inline) - #59702 (Use declare_lint_pass! and impl_lint_pass! in more places) - #59712 (wasm32: Default to a "static" relocation model) Failed merges: r? @ghost
2 parents a781c47 + 7249036 commit 4d7defb

File tree

6 files changed

+24
-32
lines changed

6 files changed

+24
-32
lines changed

src/librustc/lint/internal.rs

+2-20
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,7 @@ impl DefaultHashTypes {
2828
}
2929
}
3030

31-
impl LintPass for DefaultHashTypes {
32-
fn get_lints(&self) -> LintArray {
33-
lint_array!(DEFAULT_HASH_TYPES)
34-
}
35-
36-
fn name(&self) -> &'static str {
37-
"DefaultHashTypes"
38-
}
39-
}
31+
impl_lint_pass!(DefaultHashTypes => [DEFAULT_HASH_TYPES]);
4032

4133
impl EarlyLintPass for DefaultHashTypes {
4234
fn check_ident(&mut self, cx: &EarlyContext<'_>, ident: Ident) {
@@ -68,17 +60,7 @@ declare_lint! {
6860
"Usage of `ty::TyKind` outside of the `ty::sty` module"
6961
}
7062

71-
pub struct TyKindUsage;
72-
73-
impl LintPass for TyKindUsage {
74-
fn get_lints(&self) -> LintArray {
75-
lint_array!(USAGE_OF_TY_TYKIND)
76-
}
77-
78-
fn name(&self) -> &'static str {
79-
"TyKindUsage"
80-
}
81-
}
63+
declare_lint_pass!(TyKindUsage => [USAGE_OF_TY_TYKIND]);
8264

8365
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TyKindUsage {
8466
fn check_path(&mut self, cx: &LateContext<'_, '_>, path: &'tcx Path, _: HirId) {

src/librustc_target/spec/wasm32_base.rs

+9
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,15 @@ pub fn options() -> TargetOptions {
118118

119119
pre_link_args,
120120

121+
// This has no effect in LLVM 8 or prior, but in LLVM 9 and later when
122+
// PIC code is implemented this has quite a drastric effect if it stays
123+
// at the default, `pic`. In an effort to keep wasm binaries as minimal
124+
// as possible we're defaulting to `static` for now, but the hope is
125+
// that eventually we can ship a `pic`-compatible standard library which
126+
// works with `static` as well (or works with some method of generating
127+
// non-relative calls and such later on).
128+
relocation_model: "static".to_string(),
129+
121130
.. Default::default()
122131
}
123132
}

src/libstd/collections/hash/set.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,11 @@ impl<T, S> HashSet<T, S>
627627
/// ```
628628
#[stable(feature = "rust1", since = "1.0.0")]
629629
pub fn is_subset(&self, other: &HashSet<T, S>) -> bool {
630-
self.iter().all(|v| other.contains(v))
630+
if self.len() <= other.len() {
631+
self.iter().all(|v| other.contains(v))
632+
} else {
633+
false
634+
}
631635
}
632636

633637
/// Returns `true` if the set is a superset of another,

src/libstd/ffi/os_str.rs

+1
Original file line numberDiff line numberDiff line change
@@ -960,6 +960,7 @@ impl IntoInner<Buf> for OsString {
960960
}
961961

962962
impl AsInner<Slice> for OsStr {
963+
#[inline]
963964
fn as_inner(&self) -> &Slice {
964965
&self.inner
965966
}

src/libstd/sys_common/os_str_bytes.rs

+2
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,11 @@ pub trait OsStrExt {
236236

237237
#[stable(feature = "rust1", since = "1.0.0")]
238238
impl OsStrExt for OsStr {
239+
#[inline]
239240
fn from_bytes(slice: &[u8]) -> &OsStr {
240241
unsafe { mem::transmute(slice) }
241242
}
243+
#[inline]
242244
fn as_bytes(&self) -> &[u8] {
243245
&self.as_inner().inner
244246
}

src/libsyntax/parse/lexer/mod.rs

+5-11
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
use crate::ast::{self, Ident};
2-
use crate::source_map::{SourceMap, FilePathMapping};
32
use crate::parse::{token, ParseSess};
43
use crate::symbol::Symbol;
54

65
use errors::{Applicability, FatalError, Diagnostic, DiagnosticBuilder};
7-
use syntax_pos::{BytePos, CharPos, Pos, Span, NO_EXPANSION};
6+
use syntax_pos::{BytePos, Pos, Span, NO_EXPANSION};
87
use core::unicode::property::Pattern_White_Space;
98

109
use std::borrow::Cow;
@@ -667,14 +666,9 @@ impl<'a> StringReader<'a> {
667666
return None;
668667
}
669668

670-
// I guess this is the only way to figure out if
671-
// we're at the beginning of the file...
672-
let smap = SourceMap::new(FilePathMapping::empty());
673-
smap.files.borrow_mut().source_files.push(self.source_file.clone());
674-
let loc = smap.lookup_char_pos_adj(self.pos);
675-
debug!("Skipping a shebang");
676-
if loc.line == 1 && loc.col == CharPos(0) {
677-
// FIXME: Add shebang "token", return it
669+
let is_beginning_of_file = self.pos == self.source_file.start_pos;
670+
if is_beginning_of_file {
671+
debug!("Skipping a shebang");
678672
let start = self.pos;
679673
while !self.ch_is('\n') && !self.is_eof() {
680674
self.bump();
@@ -1911,7 +1905,7 @@ mod tests {
19111905

19121906
use crate::ast::{Ident, CrateConfig};
19131907
use crate::symbol::Symbol;
1914-
use crate::source_map::SourceMap;
1908+
use crate::source_map::{SourceMap, FilePathMapping};
19151909
use crate::feature_gate::UnstableFeatures;
19161910
use crate::parse::token;
19171911
use crate::diagnostics::plugin::ErrorMap;

0 commit comments

Comments
 (0)