Skip to content

Rollup of 12 pull requests #69986

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 43 commits into from
Mar 13, 2020
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
79b8ad8
Implement `Copy` for `IoSlice`
LeSeulArtichaut Feb 23, 2020
9fa7981
rustdoc: don't call into_iter() on iterator. (clippy::identity_conver…
matthiaskrgr Mar 5, 2020
6bfff8a
rustdoc: Use .any(p) instead of find(p).is_some(). (clippy::search_is…
matthiaskrgr Mar 5, 2020
7aad89a
Use ?-operator in more places (clippy::question_mark, had some false …
matthiaskrgr Mar 5, 2020
45108b1
rustdoc: simplify boolean condition (clippy::nonminimal_bool)
matthiaskrgr Mar 6, 2020
1351db3
iterate over a maps values directly. (clippy::for_kv_map)
matthiaskrgr Mar 6, 2020
254ceae
call .as_deref() instead of .as_ref().map(Deref::deref) (clippy::opti…
matthiaskrgr Mar 6, 2020
0d7faaf
rustdoc: remove redundant static lifetimes (clippy::redundant_static_…
matthiaskrgr Mar 6, 2020
cca3d52
libtest: declare variables as floats instead of casting them (clippy:…
matthiaskrgr Mar 6, 2020
77af19e
remove unneeded mutable references (cippy::unnecessary_mut_passed)
matthiaskrgr Mar 6, 2020
f326f0f
libtest: remove redundant argument to writeln!() (clippy::writeln_emp…
matthiaskrgr Mar 6, 2020
3f87f8c
Use writeln!(fmt, "word") instead of write!(fmt, "word\n") (clippy::w…
matthiaskrgr Mar 6, 2020
8351138
reduce references on match patterns (clippy::match_ref_pats)
matthiaskrgr Mar 7, 2020
611cfd5
Clean up E0423 explanation
GuillaumeGomez Mar 12, 2020
118003d
triagebot.toml: add ping aliases
Centril Mar 12, 2020
7326e53
Move some const-eval `build-pass` tests to `check-pass`
LeSeulArtichaut Mar 12, 2020
8f0fa24
Move some more tests to `check-pass`
LeSeulArtichaut Mar 12, 2020
90e8058
triagebot.toml: add typo aliases
Centril Mar 12, 2020
f32cccc
rename panic_if_ intrinsics to assert_
RalfJung Mar 12, 2020
7b1b08c
remove lifetimes that can be elided (clippy::needless_lifetimes)
matthiaskrgr Mar 6, 2020
e9c9657
miri engine: fix treatment of abort intrinsic
RalfJung Mar 12, 2020
081e32b
Add test for issue-58490
JohnTitor Mar 13, 2020
0efc2cf
Add test for issue-60390
JohnTitor Mar 13, 2020
a2c41e9
Add test for issue-62504
JohnTitor Mar 13, 2020
3609bac
Add test for issue-67739
JohnTitor Mar 13, 2020
7c987eb
Add test for issue-69092
JohnTitor Mar 13, 2020
f61fb53
adjust enum naming
RalfJung Mar 13, 2020
13ea774
bless tests
RalfJung Mar 13, 2020
08a7fa6
update stable-since version for const_int_conversion
tspiteri Mar 13, 2020
a36bf9c
Clean up E0434 explanation
GuillaumeGomez Mar 13, 2020
87f8ee6
Add documentation for pub keyword
sjud Mar 5, 2020
5d90154
Rollup merge of #69403 - LeSeulArtichaut:copy-ioslice, r=sfackler
JohnTitor Mar 13, 2020
913a933
Rollup merge of #69460 - LeSeulArtichaut:move-compile-pass, r=RalfJung
JohnTitor Mar 13, 2020
35df9cc
Rollup merge of #69723 - sjud:sjud-doc-request, r=Mark-Simulacrum
JohnTitor Mar 13, 2020
8e17c83
Rollup merge of #69802 - matthiaskrgr:cl1ppy, r=Dylan-DPC
JohnTitor Mar 13, 2020
c13548d
Rollup merge of #69809 - matthiaskrgr:lifetimes, r=eddyb
JohnTitor Mar 13, 2020
78d722f
Rollup merge of #69947 - GuillaumeGomez:cleanup-e0423, r=Dylan-DPC
JohnTitor Mar 13, 2020
995e584
Rollup merge of #69949 - rust-lang:triagebot-ping-alias, r=Mark-Simul…
JohnTitor Mar 13, 2020
77263db
Rollup merge of #69954 - RalfJung:panic_if-assert, r=Centril,eddyb
JohnTitor Mar 13, 2020
f2af2cf
Rollup merge of #69960 - RalfJung:abort, r=oli-obk
JohnTitor Mar 13, 2020
93da9d7
Rollup merge of #69966 - JohnTitor:more-more-tests, r=Centril
JohnTitor Mar 13, 2020
b0d1fc5
Rollup merge of #69973 - tspiteri:const-int-conversion-since, r=dtolnay
JohnTitor Mar 13, 2020
1d8f5f0
Rollup merge of #69974 - GuillaumeGomez:cleanup-e0434, r=Dylan-DPC
JohnTitor Mar 13, 2020
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
13 changes: 5 additions & 8 deletions src/libcore/str/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,7 @@ unsafe impl<'a> ReverseSearcher<'a> for CharSearcher<'a> {
let haystack = self.haystack.as_bytes();
loop {
// get the haystack up to but not including the last character searched
let bytes = if let Some(slice) = haystack.get(self.finger..self.finger_back) {
slice
} else {
return None;
};
let bytes = haystack.get(self.finger..self.finger_back)?;
// the last byte of the utf8 encoded needle
// SAFETY: we have an invariant that `utf8_size < 5`
let last_byte = unsafe { *self.utf8_encoded.get_unchecked(self.utf8_size - 1) };
Expand Down Expand Up @@ -575,11 +571,12 @@ macro_rules! pattern_methods {

#[inline]
fn is_suffix_of(self, haystack: &'a str) -> bool
where $t: ReverseSearcher<'a>
where
$t: ReverseSearcher<'a>,
{
($pmap)(self).is_suffix_of(haystack)
}
}
};
}

macro_rules! searcher_methods {
Expand Down Expand Up @@ -614,7 +611,7 @@ macro_rules! searcher_methods {
fn next_reject_back(&mut self) -> Option<(usize, usize)> {
self.0.next_reject_back()
}
}
};
}

/////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ impl<'hir> Map<'hir> {
}

pub fn def_kind(&self, hir_id: HirId) -> Option<DefKind> {
let node = if let Some(node) = self.find(hir_id) { node } else { return None };
let node = self.find(hir_id)?;

Some(match node {
Node::Item(item) => match item.kind {
Expand Down
7 changes: 1 addition & 6 deletions src/librustc/ty/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,12 +346,7 @@ impl<'tcx> TyCtxt<'tcx> {
adt_did: DefId,
validate: &mut dyn FnMut(Self, DefId) -> Result<(), ErrorReported>,
) -> Option<ty::Destructor> {
let drop_trait = if let Some(def_id) = self.lang_items().drop_trait() {
def_id
} else {
return None;
};

let drop_trait = self.lang_items().drop_trait()?;
self.ensure().coherent_trait(drop_trait);

let mut dtor_did = None;
Expand Down
7 changes: 1 addition & 6 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1124,12 +1124,7 @@ fn extra_compiler_flags() -> Option<(Vec<String>, bool)> {
return None;
}

let matches = if let Some(matches) = handle_options(&args) {
matches
} else {
return None;
};

let matches = handle_options(&args)?;
let mut result = Vec::new();
let mut excluded_cargo_defaults = false;
for flag in ICE_REPORT_COMPILER_FLAGS {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_infer/traits/auto_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
return AutoTraitResult::ExplicitImpl;
}

return tcx.infer_ctxt().enter(|mut infcx| {
return tcx.infer_ctxt().enter(|infcx| {
let mut fresh_preds = FxHashSet::default();

// Due to the way projections are handled by SelectionContext, we need to run
Expand Down Expand Up @@ -164,7 +164,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {

let (full_env, full_user_env) = self
.evaluate_predicates(
&mut infcx,
&infcx,
trait_did,
ty,
new_env,
Expand Down
7 changes: 1 addition & 6 deletions src/librustc_infer/traits/specialize/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,12 +413,7 @@ pub(super) fn specialization_graph_provider(
fn to_pretty_impl_header(tcx: TyCtxt<'_>, impl_def_id: DefId) -> Option<String> {
use std::fmt::Write;

let trait_ref = if let Some(tr) = tcx.impl_trait_ref(impl_def_id) {
tr
} else {
return None;
};

let trait_ref = tcx.impl_trait_ref(impl_def_id)?;
let mut w = "impl".to_owned();

let substs = InternalSubsts::identity_for_item(tcx, impl_def_id);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/transform/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ fn create_generator_drop_shim<'tcx>(
// unrelated code from the resume part of the function
simplify::remove_dead_blocks(&mut body);

dump_mir(tcx, None, "generator_drop", &0, source, &mut body, |_, _| Ok(()));
dump_mir(tcx, None, "generator_drop", &0, source, &body, |_, _| Ok(()));

body
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/util/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ fn dump_matched_mir_node<'tcx>(
writeln!(file, "// MIR local liveness analysis for `{}`", node_path)?;
writeln!(file, "// source = {:?}", source)?;
writeln!(file, "// pass_name = {}", pass_name)?;
writeln!(file, "")?;
writeln!(file)?;
write_mir_fn(tcx, source, body, &mut file, result)?;
Ok(())
});
Expand All @@ -316,7 +316,7 @@ pub fn write_mir_fn<'tcx>(
write_basic_block(tcx, block, body, &mut |_, _| Ok(()), w)?;
print(w, " ", &result.outs)?;
if block.index() + 1 != body.basic_blocks().len() {
writeln!(w, "")?;
writeln!(w)?;
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/librustc_mir/util/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ fn dump_matched_mir_node<'tcx, F>(
if let Some(ref layout) = body.generator_layout {
writeln!(file, "// generator_layout = {:?}", layout)?;
}
writeln!(file, "")?;
writeln!(file)?;
extra_data(PassWhere::BeforeCFG, &mut file)?;
write_user_type_annotations(body, &mut file)?;
write_mir_fn(tcx, source, body, &mut extra_data, &mut file)?;
Expand Down Expand Up @@ -242,13 +242,13 @@ pub fn write_mir_pretty<'tcx>(
first = false;
} else {
// Put empty lines between all items
writeln!(w, "")?;
writeln!(w)?;
}

write_mir_fn(tcx, MirSource::item(def_id), body, &mut |_, _| Ok(()), w)?;

for (i, body) in tcx.promoted_mir(def_id).iter_enumerated() {
writeln!(w, "")?;
writeln!(w)?;
let src = MirSource { instance: ty::InstanceDef::Item(def_id), promoted: Some(i) };
write_mir_fn(tcx, src, body, &mut |_, _| Ok(()), w)?;
}
Expand All @@ -271,7 +271,7 @@ where
extra_data(PassWhere::BeforeBlock(block), w)?;
write_basic_block(tcx, block, body, extra_data, w)?;
if block.index() + 1 != body.basic_blocks().len() {
writeln!(w, "")?;
writeln!(w)?;
}
}

Expand Down Expand Up @@ -529,7 +529,7 @@ pub fn write_mir_intro<'tcx>(
write_scope_tree(tcx, body, &scope_tree, w, OUTERMOST_SOURCE_SCOPE, 1)?;

// Add an empty line before the first block is printed.
writeln!(w, "")?;
writeln!(w)?;

Ok(())
}
Expand Down
6 changes: 1 addition & 5 deletions src/librustc_resolve/late/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1107,11 +1107,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
}
};

match (
lifetime_names.len(),
lifetime_names.iter().next(),
snippet.as_ref().map(|s| s.as_str()),
) {
match (lifetime_names.len(), lifetime_names.iter().next(), snippet.as_deref()) {
(1, Some(name), Some("&")) => {
suggest_existing(err, format!("&{} ", name));
}
Expand Down
6 changes: 1 addition & 5 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2773,12 +2773,8 @@ impl<'a> Resolver<'a> {
} else {
let crate_id = if !speculative {
self.crate_loader.process_path_extern(ident.name, ident.span)
} else if let Some(crate_id) =
self.crate_loader.maybe_process_path_extern(ident.name, ident.span)
{
crate_id
} else {
return None;
self.crate_loader.maybe_process_path_extern(ident.name, ident.span)?
};
let crate_root = self.get_module(DefId { krate: crate_id, index: CRATE_DEF_INDEX });
Some(
Expand Down
6 changes: 1 addition & 5 deletions src/librustc_span/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1147,11 +1147,7 @@ impl SourceFile {
}

let begin = {
let line = if let Some(line) = self.lines.get(line_number) {
line
} else {
return None;
};
let line = self.lines.get(line_number)?;
let begin: BytePos = *line - self.start_pos;
begin.to_usize()
};
Expand Down
8 changes: 2 additions & 6 deletions src/librustdoc/clean/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@ pub fn try_inline(
attrs: Option<Attrs<'_>>,
visited: &mut FxHashSet<DefId>,
) -> Option<Vec<clean::Item>> {
let did = if let Some(did) = res.opt_def_id() {
did
} else {
return None;
};
let did = res.opt_def_id()?;
if did.is_local() {
return None;
}
Expand Down Expand Up @@ -578,7 +574,7 @@ fn filter_non_trait_generics(trait_did: DefId, mut g: clean::Generics) -> clean:
name: ref _name,
},
ref bounds,
} => !(*s == "Self" && did == trait_did) && !bounds.is_empty(),
} => !(bounds.is_empty() || *s == "Self" && did == trait_did),
_ => true,
});
g
Expand Down
8 changes: 2 additions & 6 deletions src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -844,11 +844,7 @@ pub fn plain_summary_line(md: &str) -> String {
type Item = String;

fn next(&mut self) -> Option<String> {
let next_event = self.inner.next();
if next_event.is_none() {
return None;
}
let next_event = next_event.unwrap();
let next_event = self.inner.next()?;
let (ret, is_in) = match next_event {
Event::Start(Tag::Paragraph) => (None, 1),
Event::Start(Tag::Heading(_)) => (None, 1),
Expand All @@ -870,7 +866,7 @@ pub fn plain_summary_line(md: &str) -> String {
}
let mut s = String::with_capacity(md.len() * 3 / 2);
let p = ParserWrapper { inner: Parser::new(md), is_in: 0, is_first: true };
p.into_iter().filter(|t| !t.is_empty()).for_each(|i| s.push_str(&i));
p.filter(|t| !t.is_empty()).for_each(|i| s.push_str(&i));
s
}

Expand Down
10 changes: 4 additions & 6 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1543,7 +1543,7 @@ impl Context {
}

if self.shared.sort_modules_alphabetically {
for (_, items) in &mut map {
for items in map.values_mut() {
items.sort();
}
}
Expand Down Expand Up @@ -3396,10 +3396,8 @@ fn render_assoc_items(
let deref_impl =
traits.iter().find(|t| t.inner_impl().trait_.def_id() == c.deref_trait_did);
if let Some(impl_) = deref_impl {
let has_deref_mut = traits
.iter()
.find(|t| t.inner_impl().trait_.def_id() == c.deref_mut_trait_did)
.is_some();
let has_deref_mut =
traits.iter().any(|t| t.inner_impl().trait_.def_id() == c.deref_mut_trait_did);
render_deref_methods(w, cx, impl_, containing_item, has_deref_mut);
}

Expand Down Expand Up @@ -3740,7 +3738,7 @@ fn render_impl(
) {
for trait_item in &t.items {
let n = trait_item.name.clone();
if i.items.iter().find(|m| m.name == n).is_some() {
if i.items.iter().any(|m| m.name == n) {
continue;
}
let did = i.trait_.as_ref().unwrap().def_id().unwrap();
Expand Down
Loading