Skip to content
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

Rollup of 9 pull requests #70296

Merged
merged 23 commits into from
Mar 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
61ef72f
Use getentropy(2) on macos
hatoo Mar 21, 2020
e991df8
Only display definition on typo
LeSeulArtichaut Mar 21, 2020
cb7a2c1
Bless tests
LeSeulArtichaut Mar 21, 2020
e543e31
resolve: Avoid "self-confirming" import resolutions in one more case
petrochenkov Mar 21, 2020
d18ed20
parse: nix unused `root_module_name`.
Centril Mar 21, 2020
eaa0ae5
parse: nix new_sub_parser_from_file
Centril Mar 21, 2020
0c5c3bb
handle unevaluated consts after monomophize
lcnr Mar 22, 2020
ed48853
simplify eval_mir_constant
lcnr Mar 22, 2020
8533778
rename tests
lcnr Mar 22, 2020
263cbd1
remove redundant closures (clippy::redundant_closure)
matthiaskrgr Mar 22, 2020
fa5b727
Clean up E0449 explanation
GuillaumeGomez Mar 22, 2020
2ee2157
miri engine: turn error sanity checks into assertions
RalfJung Mar 10, 2020
97da6da
Allow #[track_caller] in traits.
anp Feb 17, 2020
69bd46a
Remove special-casing from TyCtxt::impl_of_method.
anp Mar 22, 2020
5ed9d7e
Rollup merge of #69251 - anp:track-caller-in-traits, r=eddyb
Centril Mar 23, 2020
a2b469c
Rollup merge of #69880 - RalfJung:miri-assert-error-sanity, r=oli-obk
Centril Mar 23, 2020
675bdf6
Rollup merge of #70207 - hatoo:macos-getentropy, r=dtolnay
Centril Mar 23, 2020
11f5309
Rollup merge of #70227 - LeSeulArtichaut:typo-def, r=Centril
Centril Mar 23, 2020
08dfd13
Rollup merge of #70236 - petrochenkov:globimpice, r=ecstatic-morse
Centril Mar 23, 2020
8dda617
Rollup merge of #70248 - Centril:unroot, r=petrochenkov
Centril Mar 23, 2020
092c821
Rollup merge of #70249 - lcnr:issue70125, r=eddyb
Centril Mar 23, 2020
c984a96
Rollup merge of #70269 - matthiaskrgr:clippy_closures, r=Dylan-DPC
Centril Mar 23, 2020
5f91f30
Rollup merge of #70270 - GuillaumeGomez:cleanup-e0449, r=Dylan-DPC
Centril Mar 23, 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
4 changes: 2 additions & 2 deletions src/liballoc/collections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ impl<K: Clone, V: Clone> Clone for BTreeMap<K, V> {
(root, length)
};

out_node.push(k, v, subroot.unwrap_or_else(|| node::Root::new_leaf()));
out_node.push(k, v, subroot.unwrap_or_else(node::Root::new_leaf));
out_tree.length += 1 + sublength;
}
}
Expand Down Expand Up @@ -2147,7 +2147,7 @@ impl<K, V> BTreeMap<K, V> {
/// If the root node is the empty (non-allocated) root node, allocate our
/// own node.
fn ensure_root_is_owned(&mut self) -> &mut node::Root<K, V> {
self.root.get_or_insert_with(|| node::Root::new_leaf())
self.root.get_or_insert_with(node::Root::new_leaf)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/dep_graph/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ impl DepGraph {
C: DepGraphSafe + StableHashingContextProvider<'a>,
{
if let Some(ref data) = self.data {
let task_deps = create_task(key).map(|deps| Lock::new(deps));
let task_deps = create_task(key).map(Lock::new);

// In incremental mode, hash the result of the task. We don't
// do anything with the hash yet, but we are computing it
Expand Down
1 change: 1 addition & 0 deletions src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#![feature(extern_types)]
#![feature(nll)]
#![feature(option_expect_none)]
#![feature(or_patterns)]
#![feature(range_is_empty)]
#![feature(specialization)]
#![feature(trusted_len)]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/mir/interpret/allocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ impl UndefMask {
}

// FIXME(oli-obk): optimize this for allocations larger than a block.
let idx = (start.bytes()..end.bytes()).map(|i| Size::from_bytes(i)).find(|&i| !self.get(i));
let idx = (start.bytes()..end.bytes()).map(Size::from_bytes).find(|&i| !self.get(i));

match idx {
Some(idx) => Err(idx),
Expand Down
18 changes: 4 additions & 14 deletions src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::{self, par_iter, Lrc, ParallelIterator};
use rustc_hir as hir;
use rustc_hir::def::{CtorKind, CtorOf, DefKind, Namespace, Res};
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, CRATE_DEF_INDEX, LOCAL_CRATE};
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, CRATE_DEF_INDEX};
use rustc_hir::{Constness, GlobMap, Node, TraitMap};
use rustc_index::vec::{Idx, IndexVec};
use rustc_macros::HashStable;
Expand Down Expand Up @@ -2875,8 +2875,8 @@ impl<'tcx> TyCtxt<'tcx> {
_ => false,
}
} else {
match self.def_kind(def_id).expect("no def for `DefId`") {
DefKind::AssocConst | DefKind::AssocFn | DefKind::AssocTy => true,
match self.def_kind(def_id) {
Some(DefKind::AssocConst | DefKind::AssocFn | DefKind::AssocTy) => true,
_ => false,
}
};
Expand Down Expand Up @@ -3054,17 +3054,7 @@ impl<'tcx> TyCtxt<'tcx> {
/// If the given defid describes a method belonging to an impl, returns the
/// `DefId` of the impl that the method belongs to; otherwise, returns `None`.
pub fn impl_of_method(self, def_id: DefId) -> Option<DefId> {
let item = if def_id.krate != LOCAL_CRATE {
if let Some(DefKind::AssocFn) = self.def_kind(def_id) {
Some(self.associated_item(def_id))
} else {
None
}
} else {
self.opt_associated_item(def_id)
};

item.and_then(|trait_item| match trait_item.container {
self.opt_associated_item(def_id).and_then(|trait_item| match trait_item.container {
TraitContainer(_) => None,
ImplContainer(def_id) => Some(def_id),
})
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_ast/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ impl ParenthesizedArgs {
pub fn as_angle_bracketed_args(&self) -> AngleBracketedArgs {
AngleBracketedArgs {
span: self.span,
args: self.inputs.iter().cloned().map(|input| GenericArg::Type(input)).collect(),
args: self.inputs.iter().cloned().map(GenericArg::Type).collect(),
constraints: vec![],
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_ast_lowering/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
if !generic_args.parenthesized && !has_lifetimes {
generic_args.args = self
.elided_path_lifetimes(path_span, expected_lifetimes)
.map(|lt| GenericArg::Lifetime(lt))
.map(GenericArg::Lifetime)
.chain(generic_args.args.into_iter())
.collect();
if expected_lifetimes > 0 && param_mode == ParamMode::Explicit {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_builtin_macros/deriving/generic/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ impl<'a> Path<'a> {
self.params.iter().map(|t| t.to_ty(cx, span, self_ty, self_generics)).collect();
let params = lt
.into_iter()
.map(|lt| GenericArg::Lifetime(lt))
.chain(tys.into_iter().map(|ty| GenericArg::Type(ty)))
.map(GenericArg::Lifetime)
.chain(tys.into_iter().map(GenericArg::Type))
.collect();

match self.kind {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_builtin_macros/source_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use rustc_ast_pretty::pprust;
use rustc_expand::base::{self, *};
use rustc_expand::module::DirectoryOwnership;
use rustc_expand::panictry;
use rustc_parse::{self, new_sub_parser_from_file, parser::Parser};
use rustc_parse::{self, new_parser_from_file, parser::Parser};
use rustc_session::lint::builtin::INCOMPLETE_INCLUDE;
use rustc_span::symbol::Symbol;
use rustc_span::{self, Pos, Span};
Expand Down Expand Up @@ -110,7 +110,7 @@ pub fn expand_include<'cx>(
return DummyResult::any(sp);
}
};
let p = new_sub_parser_from_file(cx.parse_sess(), &file, None, sp);
let p = new_parser_from_file(cx.parse_sess(), &file, Some(sp));

// If in the included file we have e.g., `mod bar;`,
// then the path of `bar.rs` should be relative to the directory of `file`.
Expand Down
43 changes: 19 additions & 24 deletions src/librustc_codegen_ssa/mir/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,31 +40,26 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
&mut self,
constant: &mir::Constant<'tcx>,
) -> Result<ConstValue<'tcx>, ErrorHandled> {
match constant.literal.val {
ty::ConstKind::Unevaluated(def_id, substs, promoted) => {
let substs = self.monomorphize(&substs);
self.cx
.tcx()
.const_eval_resolve(ty::ParamEnv::reveal_all(), def_id, substs, promoted, None)
.map_err(|err| {
if promoted.is_none() {
self.cx
.tcx()
.sess
.span_err(constant.span, "erroneous constant encountered");
}
err
})
}
match self.monomorphize(&constant.literal).val {
ty::ConstKind::Unevaluated(def_id, substs, promoted) => self
.cx
.tcx()
.const_eval_resolve(ty::ParamEnv::reveal_all(), def_id, substs, promoted, None)
.map_err(|err| {
if promoted.is_none() {
self.cx
.tcx()
.sess
.span_err(constant.span, "erroneous constant encountered");
}
err
}),
ty::ConstKind::Value(value) => Ok(value),
_ => {
let const_ = self.monomorphize(&constant.literal);
if let ty::ConstKind::Value(value) = const_.val {
Ok(value)
} else {
span_bug!(constant.span, "encountered bad ConstKind in codegen: {:?}", const_);
}
}
err => span_bug!(
constant.span,
"encountered bad ConstKind after monomorphizing: {:?}",
err
),
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_data_structures/sharded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub struct Sharded<T> {
impl<T: Default> Default for Sharded<T> {
#[inline]
fn default() -> Self {
Self::new(|| T::default())
Self::new(T::default)
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/librustc_error_codes/error_codes/E0449.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
A visibility qualifier was used when it was unnecessary. Erroneous code
examples:
A visibility qualifier was used when it was unnecessary.

Erroneous code examples:

```compile_fail,E0449
struct Bar;
Expand Down
45 changes: 4 additions & 41 deletions src/librustc_error_codes/error_codes/E0738.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,11 @@
`#[track_caller]` cannot be used in traits yet. This is due to limitations in
the compiler which are likely to be temporary. See [RFC 2091] for details on
this and other restrictions.
`#[track_caller]` cannot be used to annotate foreign functions.

Erroneous example with a trait method implementation:
Erroneous example:

```compile_fail,E0738
#![feature(track_caller)]

trait Foo {
fn bar(&self);
}

impl Foo for u64 {
#[track_caller]
fn bar(&self) {}
}
```

Erroneous example with a blanket trait method implementation:

```compile_fail,E0738
#![feature(track_caller)]

trait Foo {
extern "Rust" {
#[track_caller]
fn bar(&self) {}
fn baz(&self);
fn bar();
}
```

Erroneous example with a trait method declaration:

```compile_fail,E0738
#![feature(track_caller)]

trait Foo {
fn bar(&self) {}

#[track_caller]
fn baz(&self);
}
```

Note that while the compiler may be able to support the attribute in traits in
the future, [RFC 2091] prohibits their implementation without a follow-up RFC.

[RFC 2091]: https://github.com/rust-lang/rfcs/blob/master/text/2091-inline-semantic.md
2 changes: 1 addition & 1 deletion src/librustc_errors/diagnostic_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl<'a> DiagnosticBuilder<'a> {
message: &str,
span: Option<S>,
) -> &mut Self {
let span = span.map(|s| s.into()).unwrap_or_else(|| MultiSpan::new());
let span = span.map(|s| s.into()).unwrap_or_else(MultiSpan::new);
self.0.diagnostic.sub(level, message, span, None);
self
}
Expand Down
2 changes: 0 additions & 2 deletions src/librustc_expand/mbe/macro_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,6 @@ fn generic_extension<'cx>(
}

let mut p = Parser::new(sess, tts, false, None);
p.root_module_name =
cx.current_expansion.module.mod_path.last().map(|id| id.to_string());
p.last_type_ascription = cx.current_expansion.prior_type_ascription;

// Let the context choose how to interpret the result.
Expand Down
7 changes: 3 additions & 4 deletions src/librustc_expand/module.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use rustc_ast::ast::{self, Attribute, Ident, Mod};
use rustc_ast::{attr, token};
use rustc_errors::{struct_span_err, PResult};
use rustc_parse::new_sub_parser_from_file;
use rustc_parse::new_parser_from_file;
use rustc_session::parse::ParseSess;
use rustc_span::source_map::{FileName, Span};
use rustc_span::symbol::sym;
Expand Down Expand Up @@ -59,9 +59,8 @@ crate fn parse_external_mod(
*pop_mod_stack = true; // We have pushed, so notify caller.
drop(included_mod_stack);

// Actually parse the external file as amodule.
let mut p0 = new_sub_parser_from_file(sess, &mp.path, Some(id.to_string()), span);
let mut module = p0.parse_mod(&token::Eof)?;
// Actually parse the external file as a module.
let mut module = new_parser_from_file(sess, &mp.path, Some(span)).parse_mod(&token::Eof)?;
module.0.inline = false;
module
};
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_feature/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub struct Feature {

impl Feature {
fn issue(&self) -> Option<NonZeroU32> {
self.issue.and_then(|i| NonZeroU32::new(i))
self.issue.and_then(NonZeroU32::new)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_interface/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ impl<'tcx> QueryContext<'tcx> {
where
F: FnOnce(TyCtxt<'tcx>) -> R,
{
ty::tls::enter_global(self.0, |tcx| f(tcx))
ty::tls::enter_global(self.0, f)
}

pub fn print_stats(&mut self) {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_metadata/locator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ impl<'a> CrateLocator<'a> {
.into_iter()
.filter_map(|entry| entry.files())
.flatten()
.map(|location| PathBuf::from(location))
.map(PathBuf::from)
.collect()
} else {
// SVH being specified means this is a transitive dependency,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/dataflow/generic/graphviz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ fn write_diff<A: Analysis<'tcx>>(
let mut clear = HybridBitSet::new_empty(len);

// FIXME: Implement a lazy iterator over the symmetric difference of two bitsets.
for i in (0..len).map(|i| A::Idx::new(i)) {
for i in (0..len).map(A::Idx::new) {
match (from.contains(i), to.contains(i)) {
(false, true) => set.insert(i),
(true, false) => clear.insert(i),
Expand Down
7 changes: 3 additions & 4 deletions src/librustc_mir/interpret/validity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -825,11 +825,10 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
// Run it.
match visitor.visit_value(op) {
Ok(()) => Ok(()),
// We should only get validation errors here. Avoid other errors as
// those do not show *where* in the value the issue lies.
Err(err) if matches!(err.kind, err_ub!(ValidationFailure { .. })) => Err(err),
Err(err) if cfg!(debug_assertions) => {
bug!("Unexpected error during validation: {}", err)
}
Err(err) => Err(err),
Err(err) => bug!("Unexpected error during validation: {}", err),
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/monomorphize/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ fn create_mono_items_for_vtable_methods<'tcx>(
.unwrap()
})
.filter(|&instance| should_monomorphize_locally(tcx, &instance))
.map(|instance| create_fn_mono_item(instance));
.map(create_fn_mono_item);
output.extend(methods);
}

Expand Down
3 changes: 1 addition & 2 deletions src/librustc_mir/transform/const_prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
// Some errors shouldn't come up because creating them causes
// an allocation, which we should avoid. When that happens,
// dedicated error variants should be introduced instead.
// Only test this in debug builds though to avoid disruptions.
debug_assert!(
assert!(
!error.kind.allocates(),
"const-prop encountered allocating error: {}",
error
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir_build/hair/pattern/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2066,7 +2066,7 @@ fn split_grouped_constructors<'p, 'tcx>(
}
intersection
})
.flat_map(|range| range_borders(range));
.flat_map(range_borders);
let ctor_borders = range_borders(ctor_range.clone());
let mut borders: Vec<_> = row_borders.chain(ctor_borders).collect();
borders.sort_unstable();
Expand Down
Loading