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 19 pull requests #81013

Closed
wants to merge 68 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
64f11b9
Update tests of "unused_lifetimes" lint for async functions and corre…
Dec 4, 2020
3ea744e
Recommend panic::resume_unwind instead of panicking.
frewsxcv Dec 18, 2020
1f9a8a1
Add a `std::io::read_to_string` function
camelid Nov 5, 2020
4ee6d1b
Add description independent of `Read::read_to_string`
camelid Dec 30, 2020
588786a
Add error docs
camelid Dec 30, 2020
7ed824e
Add Iterator::intersperse_with
lukaslueg Dec 31, 2020
7a0ada0
Remove FIXME-notes
lukaslueg Jan 6, 2021
f7d261c
Get rid of `DepConstructor`
jyn514 Jan 8, 2021
ebe402d
Fix handling of malicious Readers in read_to_end
sfackler Jan 11, 2021
a9ef798
clean up control flow
sfackler Jan 11, 2021
5cb8303
make check a bit more clear
sfackler Jan 11, 2021
e6c07b0
clarify docs a bit
sfackler Jan 11, 2021
7463292
Add docs on performance
camelid Jan 12, 2021
16692ab
Suggest `_` and `..` if a pattern has too few fields
camelid Dec 13, 2020
5fe61a7
Simplify code
camelid Dec 19, 2020
f3d9df5
Suggest `Variant(..)` if all of the mentioned fields are `_`
camelid Dec 19, 2020
a5e8e6e
Pluralize 'parenthesis' correctly
camelid Dec 19, 2020
fe82cc3
Specialize `..` help message for all fields vs. the rest
camelid Dec 19, 2020
9959d6d
Only suggest `..` if more than one field is missing
camelid Dec 20, 2020
1bce775
Add a test case with lots of whitespace
camelid Jan 13, 2021
d7307a7
Always show suggestions in their own subwindows
camelid Jan 13, 2021
c3f7429
Use better ICE message when no MIR is available
camelid Jan 13, 2021
7e83fec
remove unstable deprecated Vec::remove_item
KodrAus Jan 13, 2021
6bfd987
Update books
ehuss Jan 13, 2021
e8c8793
Include `..` suggestion if fields are all wildcards
camelid Jan 13, 2021
d65cb6e
deprecate atomic::spin_loop_hint in favour of hint::spin_loop
KodrAus Jan 13, 2021
697b20f
Fixed incorrect doc comment
trevarj Jan 13, 2021
52adfdd
Use Option::map_or instead of `.map(..).unwrap_or(..)`
LingMan Jan 11, 2021
64c1b0d
Fix -Cpasses=list and llvm version print with -vV
bjorn3 Jan 13, 2021
5b1316f
unix ExitStatus: Do not treat WIFSTOPPED as WIFSIGNALED
ijackson Dec 12, 2020
12d62aa
unix ExitStatus: Clarify docs for .signal()
ijackson Dec 12, 2020
530270f
unix ExitStatus: Provide .into_raw()
ijackson Dec 12, 2020
3f05051
unix ExitStatus: Provide .core_dumped
ijackson Dec 12, 2020
f060b9e
unix ExitStatus: Provide .stopped_signal()
ijackson Dec 12, 2020
42ea8f6
unix ExitStatus: Provide .continued()
ijackson Dec 12, 2020
29c851a
Replace `Ie` with `In other words`
ijackson Dec 13, 2020
06a405c
Replace `Ie` with `In other words`
ijackson Dec 13, 2020
fa68567
unix ExitStatus: Add tracking issue to new methods
ijackson Jan 4, 2021
7012194
ExitStatusExt unix: Retrospectively seal this trait
ijackson Jan 4, 2021
f3e7199
ExitStatusExt windows: Retrospectively seal this trait
ijackson Jan 4, 2021
efddf59
Fix typo saeled -> sealed
dtolnay Jan 11, 2021
05a88aa
ExitStatusExt: Fix build on Fuchsia
ijackson Jan 13, 2021
b59fa3d
Fix stabilisation version of slice_strip
ijackson Jan 13, 2021
9528988
Add doc intralinks
lukaslueg Jan 13, 2021
0342fd1
Remove the unused context from CreateDebugLocation
cuviper Jan 13, 2021
391b4cc
Fix formatting specifiers doc link
calebsander Jan 13, 2021
9b2f085
Improve Iterator::intersperse_ docs
lukaslueg Jan 13, 2021
eb72dc5
Add as_ref and as_mut methods for Bound
glittershark Dec 28, 2020
a8d0161
Fix typos in Fuchsia unix_process_wait_more
dtolnay Jan 14, 2021
05f5db4
Rollup merge of #79689 - Vooblin:patch1, r=tmandry
m-ou-se Jan 14, 2021
aacb26d
Rollup merge of #79982 - ijackson:exit-status, r=dtolnay
m-ou-se Jan 14, 2021
b07415c
Rollup merge of #80017 - camelid:sugg-rest-pattern, r=estebank
m-ou-se Jan 14, 2021
473c292
Rollup merge of #80169 - frewsxcv:frewsxcv-docs-fix, r=jyn514
m-ou-se Jan 14, 2021
35833c2
Rollup merge of #80217 - camelid:io-read_to_string, r=m-ou-se
m-ou-se Jan 14, 2021
4ac831b
Rollup merge of #80444 - glittershark:bound-as-ref, r=dtolnay
m-ou-se Jan 14, 2021
7c4d34f
Rollup merge of #80567 - lukaslueg:intersperse_with, r=m-ou-se
m-ou-se Jan 14, 2021
4913b50
Rollup merge of #80829 - jyn514:dep-constructor, r=michaelwoerister
m-ou-se Jan 14, 2021
09276b0
Rollup merge of #80895 - sfackler:read-to-end-ub, r=m-ou-se
m-ou-se Jan 14, 2021
c0c379a
Rollup merge of #80944 - LingMan:map_or, r=nagisa
m-ou-se Jan 14, 2021
de47f47
Rollup merge of #80966 - KodrAus:deprecate/spin_loop_hint, r=m-ou-se
m-ou-se Jan 14, 2021
b480d2b
Rollup merge of #80969 - camelid:monomorph-ice-msg, r=nagisa
m-ou-se Jan 14, 2021
b18bbf5
Rollup merge of #80972 - KodrAus:deprecate/remove_item, r=nagisa
m-ou-se Jan 14, 2021
4e5eb81
Rollup merge of #80973 - ehuss:update-books, r=ehuss
m-ou-se Jan 14, 2021
e4f75cc
Rollup merge of #80980 - trevarj:patch-1, r=nagisa
m-ou-se Jan 14, 2021
459b274
Rollup merge of #80981 - bjorn3:bjorn3-patch-1, r=jonas-schievink
m-ou-se Jan 14, 2021
4dc3a44
Rollup merge of #80985 - ijackson:slice-strip-fix, r=jyn514
m-ou-se Jan 14, 2021
896757f
Rollup merge of #80990 - cuviper:unused-debug-context, r=nagisa
m-ou-se Jan 14, 2021
ce19d93
Rollup merge of #80991 - calebsander:fix/fmt-link, r=m-ou-se
m-ou-se Jan 14, 2021
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
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
if !generic_args.parenthesized && !has_lifetimes {
generic_args.args = self
.elided_path_lifetimes(
first_generic_span.map(|s| s.shrink_to_lo()).unwrap_or(segment.ident.span),
first_generic_span.map_or(segment.ident.span, |s| s.shrink_to_lo()),
expected_lifetimes,
)
.map(GenericArg::Lifetime)
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
gate_feature_post!(
&self,
negative_impls,
span.to(of_trait.as_ref().map(|t| t.path.span).unwrap_or(span)),
span.to(of_trait.as_ref().map_or(span, |t| t.path.span)),
"negative trait bounds are not yet fully implemented; \
use marker types for now"
);
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_codegen_llvm/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1002,8 +1002,7 @@ pub unsafe fn with_llvm_pmb(
// reasonable defaults and prepare it to actually populate the pass
// manager.
let builder = llvm::LLVMPassManagerBuilderCreate();
let opt_size =
config.opt_size.map(|x| to_llvm_opt_settings(x).1).unwrap_or(llvm::CodeGenOptSizeNone);
let opt_size = config.opt_size.map_or(llvm::CodeGenOptSizeNone, |x| to_llvm_opt_settings(x).1);
let inline_threshold = config.inline_threshold;
let pgo_gen_path = get_pgo_gen_path(config);
let pgo_use_path = get_pgo_use_path(config);
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_codegen_llvm/src/debuginfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,6 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {

unsafe {
llvm::LLVMRustDIBuilderCreateDebugLocation(
utils::debug_context(self).llcontext,
line.unwrap_or(UNKNOWN_LINE_NUMBER),
col.unwrap_or(UNKNOWN_COLUMN_NUMBER),
scope,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2102,7 +2102,6 @@ extern "C" {
);

pub fn LLVMRustDIBuilderCreateDebugLocation(
Context: &'a Context,
Line: c_uint,
Column: c_uint,
Scope: &'a DIScope,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ fn get_linker(
_ => match flavor {
LinkerFlavor::Lld(f) => Command::lld(linker, f),
LinkerFlavor::Msvc if sess.opts.cg.linker.is_none() && sess.target.linker.is_none() => {
Command::new(msvc_tool.as_ref().map(|t| t.path()).unwrap_or(linker))
Command::new(msvc_tool.as_ref().map_or(linker, |t| t.path()))
}
_ => Command::new(linker),
},
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_data_structures/src/profiling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ impl SelfProfilerRef {
// If there is no SelfProfiler then the filter mask is set to NONE,
// ensuring that nothing ever tries to actually access it.
let event_filter_mask =
profiler.as_ref().map(|p| p.event_filter_mask).unwrap_or(EventFilter::empty());
profiler.as_ref().map_or(EventFilter::empty(), |p| p.event_filter_mask);

SelfProfilerRef {
profiler,
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ pub fn version(binary: &str, matches: &getopts::Matches) {
println!("commit-date: {}", unw(util::commit_date_str()));
println!("host: {}", config::host_triple());
println!("release: {}", unw(util::release_str()));
if cfg!(llvm) {
if cfg!(feature = "llvm") {
get_builtin_codegen_backend("llvm")().print_version();
}
}
Expand Down Expand Up @@ -1087,7 +1087,7 @@ pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
}

if cg_flags.iter().any(|x| *x == "passes=list") {
if cfg!(llvm) {
if cfg!(feature = "llvm") {
get_builtin_codegen_backend("llvm")().print_passes();
}
return None;
Expand Down Expand Up @@ -1236,7 +1236,7 @@ pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) {
}

// If backtraces are enabled, also print the query stack
let backtrace = env::var_os("RUST_BACKTRACE").map(|x| &x != "0").unwrap_or(false);
let backtrace = env::var_os("RUST_BACKTRACE").map_or(false, |x| &x != "0");

let num_frames = if backtrace { None } else { Some(2) };

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ impl HandlerInner {
}

fn treat_err_as_bug(&self) -> bool {
self.flags.treat_err_as_bug.map(|c| self.err_count() >= c).unwrap_or(false)
self.flags.treat_err_as_bug.map_or(false, |c| self.err_count() >= c)
}

fn print_error_count(&mut self, registry: &Registry) {
Expand Down Expand Up @@ -913,7 +913,7 @@ impl HandlerInner {
// This is technically `self.treat_err_as_bug()` but `delay_span_bug` is called before
// incrementing `err_count` by one, so we need to +1 the comparing.
// FIXME: Would be nice to increment err_count in a more coherent way.
if self.flags.treat_err_as_bug.map(|c| self.err_count() + 1 >= c).unwrap_or(false) {
if self.flags.treat_err_as_bug.map_or(false, |c| self.err_count() + 1 >= c) {
// FIXME: don't abort here if report_delayed_bugs is off
self.span_bug(sp, msg);
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_expand/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ impl<'a> StripUnconfigured<'a> {

/// If attributes are not allowed on expressions, emit an error for `attr`
pub fn maybe_emit_expr_attr_err(&self, attr: &Attribute) {
if !self.features.map(|features| features.stmt_expr_attributes).unwrap_or(true) {
if !self.features.map_or(true, |features| features.stmt_expr_attributes) {
let mut err = feature_err(
&self.sess.parse_sess,
sym::stmt_expr_attributes,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_expand/src/mbe/macro_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ fn inner_parse_loop<'root, 'tt>(
if idx == len && item.sep.is_some() {
// We have a separator, and it is the current token. We can advance past the
// separator token.
if item.sep.as_ref().map(|sep| token_name_eq(token, sep)).unwrap_or(false) {
if item.sep.as_ref().map_or(false, |sep| token_name_eq(token, sep)) {
item.idx += 1;
next_items.push(item);
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_expand/src/mbe/macro_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ fn macro_rules_dummy_expander<'cx>(
}

fn trace_macros_note(cx_expansions: &mut FxHashMap<Span, Vec<String>>, sp: Span, message: String) {
let sp = sp.macro_backtrace().last().map(|trace| trace.call_site).unwrap_or(sp);
let sp = sp.macro_backtrace().last().map_or(sp, |trace| trace.call_site);
cx_expansions.entry(sp).or_default().push(message);
}

Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_expand/src/mbe/quoted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ pub(super) fn parse(
}
_ => token.span,
},
tree => tree.as_ref().map(tokenstream::TokenTree::span).unwrap_or(span),
tree => tree.as_ref().map_or(span, tokenstream::TokenTree::span),
}
}
tree => tree.as_ref().map(tokenstream::TokenTree::span).unwrap_or(start_sp),
tree => tree.as_ref().map_or(start_sp, tokenstream::TokenTree::span),
};
if node_id != DUMMY_NODE_ID {
// Macros loaded from other crates have dummy node ids.
Expand Down Expand Up @@ -250,7 +250,7 @@ fn parse_kleene_op(
Some(op) => Ok(Ok((op, token.span))),
None => Ok(Err(token)),
},
tree => Err(tree.as_ref().map(tokenstream::TokenTree::span).unwrap_or(span)),
tree => Err(tree.as_ref().map_or(span, tokenstream::TokenTree::span)),
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ impl WhereClause<'_> {
/// in `fn foo<T>(t: T) where T: Foo,` so we don't suggest two trailing commas.
pub fn tail_span_for_suggestion(&self) -> Span {
let end = self.span_for_predicates_or_empty_place().shrink_to_hi();
self.predicates.last().map(|p| p.span()).unwrap_or(end).shrink_to_hi().to(end)
self.predicates.last().map_or(end, |p| p.span()).shrink_to_hi().to(end)
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2118,7 +2118,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
let consider = format!(
"{} {}...",
msg,
if type_param_span.map(|(_, _, is_impl_trait)| is_impl_trait).unwrap_or(false) {
if type_param_span.map_or(false, |(_, _, is_impl_trait)| is_impl_trait) {
format!(" `{}` to `{}`", sub, bound_kind)
} else {
format!("`{}: {}`", bound_kind, sub)
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1533,7 +1533,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
// Note: if these two lines are combined into one we get
// dynamic borrow errors on `self.inner`.
let known = self.inner.borrow_mut().type_variables().probe(v).known();
known.map(|t| self.shallow_resolve_ty(t)).unwrap_or(typ)
known.map_or(typ, |t| self.shallow_resolve_ty(t))
}

ty::Infer(ty::IntVar(v)) => self
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_lint/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,7 @@ pub fn transparent_newtype_field<'a, 'tcx>(
let param_env = tcx.param_env(variant.def_id);
for field in &variant.fields {
let field_ty = tcx.type_of(field.did);
let is_zst =
tcx.layout_of(param_env.and(field_ty)).map(|layout| layout.is_zst()).unwrap_or(false);
let is_zst = tcx.layout_of(param_env.and(field_ty)).map_or(false, |layout| layout.is_zst());

if !is_zst {
return Some(field);
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_lint/src/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,8 @@ trait UnusedDelimLint {
pprust::expr_to_string(value)
};
let keep_space = (
left_pos.map(|s| s >= value.span.lo()).unwrap_or(false),
right_pos.map(|s| s <= value.span.hi()).unwrap_or(false),
left_pos.map_or(false, |s| s >= value.span.lo()),
right_pos.map_or(false, |s| s <= value.span.hi()),
);
self.emit_unused_delims(cx, value.span, &expr_text, ctx.into(), keep_space);
}
Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -994,11 +994,9 @@ LLVMRustDICompositeTypeReplaceArrays(LLVMRustDIBuilderRef Builder,
}

extern "C" LLVMMetadataRef
LLVMRustDIBuilderCreateDebugLocation(LLVMContextRef ContextRef, unsigned Line,
unsigned Column, LLVMMetadataRef Scope,
LLVMRustDIBuilderCreateDebugLocation(unsigned Line, unsigned Column,
LLVMMetadataRef Scope,
LLVMMetadataRef InlinedAt) {
LLVMContext &Context = *unwrap(ContextRef);

DebugLoc debug_loc = DebugLoc::get(Line, Column, unwrapDIPtr<MDNode>(Scope),
unwrapDIPtr<MDNode>(InlinedAt));

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_macros/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ fn add_query_description_impl(
};

let (tcx, desc) = modifiers.desc;
let tcx = tcx.as_ref().map(|t| quote! { #t }).unwrap_or(quote! { _ });
let tcx = tcx.as_ref().map_or(quote! { _ }, |t| quote! { #t });

let desc = quote! {
#[allow(unused_variables)]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_metadata/src/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ impl<'a> CrateLoader<'a> {
self.verify_no_symbol_conflicts(&crate_root)?;

let private_dep =
self.sess.opts.externs.get(&name.as_str()).map(|e| e.is_private_dep).unwrap_or(false);
self.sess.opts.externs.get(&name.as_str()).map_or(false, |e| e.is_private_dep);

// Claim this crate number and cache it
let cnum = self.cstore.alloc_new_crate_num();
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_metadata/src/native_libs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl ItemLikeVisitor<'tcx> for Collector<'tcx> {

impl Collector<'tcx> {
fn register_native_lib(&mut self, span: Option<Span>, lib: NativeLib) {
if lib.name.as_ref().map(|&s| s == kw::Empty).unwrap_or(false) {
if lib.name.as_ref().map_or(false, |&s| s == kw::Empty) {
match span {
Some(span) => {
struct_span_err!(
Expand Down
45 changes: 13 additions & 32 deletions compiler/rustc_middle/src/dep_graph/dep_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@
//! contained no `DefId` for thing that had been removed.
//!
//! `DepNode` definition happens in the `define_dep_nodes!()` macro. This macro
//! defines the `DepKind` enum and a corresponding `dep_constructor` module. The
//! `dep_constructor` module links a `DepKind` to the parameters that are needed at
//! runtime in order to construct a valid `DepNode` fingerprint.
//! defines the `DepKind` enum. Each `DepKind` has its own parameters that are
//! needed at runtime in order to construct a valid `DepNode` fingerprint.
//! However, only `CompileCodegenUnit` is constructed explicitly (with
//! `make_compile_codegen_unit`).
//!
//! Because the macro sees what parameters a given `DepKind` requires, it can
//! "infer" some properties for each kind of `DepNode`:
Expand All @@ -44,22 +45,14 @@
//! `DefId` it was computed from. In other cases, too much information gets
//! lost during fingerprint computation.
//!
//! The `dep_constructor` module, together with `DepNode::new()`, ensures that only
//! `make_compile_codegen_unit`, together with `DepNode::new()`, ensures that only
//! valid `DepNode` instances can be constructed. For example, the API does not
//! allow for constructing parameterless `DepNode`s with anything other
//! than a zeroed out fingerprint. More generally speaking, it relieves the
//! user of the `DepNode` API of having to know how to compute the expected
//! fingerprint for a given set of node parameters.

use crate::mir::interpret::{GlobalId, LitToConstInput};
use crate::traits;
use crate::traits::query::{
CanonicalPredicateGoal, CanonicalProjectionGoal, CanonicalTyGoal,
CanonicalTypeOpAscribeUserTypeGoal, CanonicalTypeOpEqGoal, CanonicalTypeOpNormalizeGoal,
CanonicalTypeOpProvePredicateGoal, CanonicalTypeOpSubtypeGoal,
};
use crate::ty::subst::{GenericArg, SubstsRef};
use crate::ty::{self, ParamEnvAnd, Ty, TyCtxt};
use crate::ty::TyCtxt;

use rustc_data_structures::fingerprint::Fingerprint;
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, CRATE_DEF_INDEX};
Expand Down Expand Up @@ -338,25 +331,6 @@ macro_rules! define_dep_nodes {
$($variant),*
}

#[allow(non_camel_case_types)]
pub mod dep_constructor {
use super::*;

$(
#[inline(always)]
#[allow(unreachable_code, non_snake_case)]
pub fn $variant(_tcx: TyCtxt<'_>, $(arg: $tuple_arg_ty)*) -> DepNode {
// tuple args
$({
erase!($tuple_arg_ty);
return DepNode::construct(_tcx, DepKind::$variant, &arg)
})*

return DepNode::construct(_tcx, DepKind::$variant, &())
}
)*
}

fn dep_kind_from_label_string(label: &str) -> Result<DepKind, ()> {
match label {
$(stringify!($variant) => Ok(DepKind::$variant),)*
Expand Down Expand Up @@ -384,9 +358,16 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>

[anon] TraitSelect,

// WARNING: if `Symbol` is changed, make sure you update `make_compile_codegen_unit` below.
[] CompileCodegenUnit(Symbol),
]);

// WARNING: `construct` is generic and does not know that `CompileCodegenUnit` takes `Symbol`s as keys.
// Be very careful changing this type signature!
crate fn make_compile_codegen_unit(tcx: TyCtxt<'_>, name: Symbol) -> DepNode {
DepNode::construct(tcx, DepKind::CompileCodegenUnit, &name)
}

pub type DepNode = rustc_query_system::dep_graph::DepNode<DepKind>;

// We keep a lot of `DepNode`s in memory during compilation. It's not
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_middle/src/dep_graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ pub use rustc_query_system::dep_graph::{
WorkProduct, WorkProductId,
};

pub use dep_node::{dep_constructor, label_strs, DepKind, DepNode, DepNodeExt};
crate use dep_node::make_compile_codegen_unit;
pub use dep_node::{label_strs, DepKind, DepNode, DepNodeExt};

pub type DepGraph = rustc_query_system::dep_graph::DepGraph<DepKind>;
pub type TaskDeps = rustc_query_system::dep_graph::TaskDeps<DepKind>;
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_middle/src/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ impl<'hir> Map<'hir> {
/// Given a node ID, gets a list of attributes associated with the AST
/// corresponding to the node-ID.
pub fn attrs(&self, id: HirId) -> &'hir [ast::Attribute] {
let attrs = self.find_entry(id).map(|entry| match entry.node {
self.find_entry(id).map_or(&[], |entry| match entry.node {
Node::Param(a) => &a.attrs[..],
Node::Local(l) => &l.attrs[..],
Node::Item(i) => &i.attrs[..],
Expand All @@ -840,8 +840,7 @@ impl<'hir> Map<'hir> {
| Node::Block(..)
| Node::Lifetime(..)
| Node::Visibility(..) => &[],
});
attrs.unwrap_or(&[])
})
}

/// Gets the span of the definition of the specified HIR node.
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/mir/mono.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::dep_graph::{dep_constructor, DepNode, WorkProduct, WorkProductId};
use crate::dep_graph::{DepNode, WorkProduct, WorkProductId};
use crate::ich::{NodeIdHashingMode, StableHashingContext};
use crate::ty::{subst::InternalSubsts, Instance, InstanceDef, SymbolName, TyCtxt};
use rustc_attr::InlineAttr;
Expand Down Expand Up @@ -362,7 +362,7 @@ impl<'tcx> CodegenUnit<'tcx> {
}

pub fn codegen_dep_node(&self, tcx: TyCtxt<'tcx>) -> DepNode {
dep_constructor::CompileCodegenUnit(tcx, self.name())
crate::dep_graph::make_compile_codegen_unit(tcx, self.name())
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/consts/kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl<'tcx> ConstKind<'tcx> {
/// Tries to evaluate the constant if it is `Unevaluated`. If that doesn't succeed, return the
/// unevaluated constant.
pub fn eval(self, tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>) -> Self {
self.try_eval(tcx, param_env).and_then(Result::ok).map(ConstKind::Value).unwrap_or(self)
self.try_eval(tcx, param_env).and_then(Result::ok).map_or(self, ConstKind::Value)
}

#[inline]
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1338,7 +1338,7 @@ impl<'tcx> TyCtxt<'tcx> {
}

pub fn serialize_query_result_cache(self, encoder: &mut FileEncoder) -> FileEncodeResult {
self.queries.on_disk_cache.as_ref().map(|c| c.serialize(self, encoder)).unwrap_or(Ok(()))
self.queries.on_disk_cache.as_ref().map_or(Ok(()), |c| c.serialize(self, encoder))
}

/// If `true`, we should use the MIR-based borrowck, but also
Expand Down Expand Up @@ -2601,7 +2601,7 @@ impl<'tcx> TyCtxt<'tcx> {
}

pub fn is_late_bound(self, id: HirId) -> bool {
self.is_late_bound_map(id.owner).map(|set| set.contains(&id.local_id)).unwrap_or(false)
self.is_late_bound_map(id.owner).map_or(false, |set| set.contains(&id.local_id))
}

pub fn object_lifetime_defaults(self, id: HirId) -> Option<&'tcx [ObjectLifetimeDefault]> {
Expand Down
Loading