Auto merge of #80960 - Dylan-DPC:rollup-89tri8x, r=Dylan-DPC
Rollup of 10 pull requests Successful merges: - #78901 (diagnostics: Note capturing closures can't be coerced to fns) - #79588 (Provide more information for HRTB lifetime errors involving closures) - #80232 (Remove redundant def_id lookups) - #80662 (Added support for i386-unknown-linux-gnu and i486-unknown-linux-gnu) - #80736 (use Once instead of Mutex to manage capture resolution) - #80796 (Update to LLVM 11.0.1) - #80859 (Fix --pretty=expanded with --remap-path-prefix) - #80922 (Revert "Auto merge of #76896 - spastorino:codegen-inline-fns2) - #80924 (Fix rustdoc --test-builder argument parsing) - #80935 (Rename `rustc_middle::lint::LevelSource` to `LevelAndSource`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
fc93e4719c
49 changed files with 661 additions and 101 deletions
|
@ -46,7 +46,7 @@ impl LintLevelSource {
|
|||
}
|
||||
|
||||
/// A tuple of a lint level and its source.
|
||||
pub type LevelSource = (Level, LintLevelSource);
|
||||
pub type LevelAndSource = (Level, LintLevelSource);
|
||||
|
||||
pub struct LintLevelSets {
|
||||
pub list: Vec<LintSet>,
|
||||
|
@ -57,11 +57,11 @@ pub enum LintSet {
|
|||
CommandLine {
|
||||
// -A,-W,-D flags, a `Symbol` for the flag itself and `Level` for which
|
||||
// flag.
|
||||
specs: FxHashMap<LintId, LevelSource>,
|
||||
specs: FxHashMap<LintId, LevelAndSource>,
|
||||
},
|
||||
|
||||
Node {
|
||||
specs: FxHashMap<LintId, LevelSource>,
|
||||
specs: FxHashMap<LintId, LevelAndSource>,
|
||||
parent: u32,
|
||||
},
|
||||
}
|
||||
|
@ -75,9 +75,9 @@ impl LintLevelSets {
|
|||
&self,
|
||||
lint: &'static Lint,
|
||||
idx: u32,
|
||||
aux: Option<&FxHashMap<LintId, LevelSource>>,
|
||||
aux: Option<&FxHashMap<LintId, LevelAndSource>>,
|
||||
sess: &Session,
|
||||
) -> LevelSource {
|
||||
) -> LevelAndSource {
|
||||
let (level, mut src) = self.get_lint_id_level(LintId::of(lint), idx, aux);
|
||||
|
||||
// If `level` is none then we actually assume the default level for this
|
||||
|
@ -113,7 +113,7 @@ impl LintLevelSets {
|
|||
&self,
|
||||
id: LintId,
|
||||
mut idx: u32,
|
||||
aux: Option<&FxHashMap<LintId, LevelSource>>,
|
||||
aux: Option<&FxHashMap<LintId, LevelAndSource>>,
|
||||
) -> (Option<Level>, LintLevelSource) {
|
||||
if let Some(specs) = aux {
|
||||
if let Some(&(level, src)) = specs.get(&id) {
|
||||
|
@ -157,7 +157,7 @@ impl LintLevelMap {
|
|||
lint: &'static Lint,
|
||||
id: HirId,
|
||||
session: &Session,
|
||||
) -> Option<LevelSource> {
|
||||
) -> Option<LevelAndSource> {
|
||||
self.id_to_set.get(&id).map(|idx| self.sets.get_lint_level(lint, *idx, None, session))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::dep_graph::{dep_constructor, DepNode, WorkProduct, WorkProductId};
|
||||
use crate::ich::{NodeIdHashingMode, StableHashingContext};
|
||||
use crate::ty::{subst::InternalSubsts, Instance, InstanceDef, SymbolName, TyCtxt};
|
||||
use rustc_attr::InlineAttr;
|
||||
use rustc_data_structures::base_n;
|
||||
use rustc_data_structures::fingerprint::Fingerprint;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
|
@ -78,6 +79,14 @@ impl<'tcx> MonoItem<'tcx> {
|
|||
}
|
||||
|
||||
pub fn instantiation_mode(&self, tcx: TyCtxt<'tcx>) -> InstantiationMode {
|
||||
let generate_cgu_internal_copies = tcx
|
||||
.sess
|
||||
.opts
|
||||
.debugging_opts
|
||||
.inline_in_all_cgus
|
||||
.unwrap_or_else(|| tcx.sess.opts.optimize != OptLevel::No)
|
||||
&& !tcx.sess.link_dead_code();
|
||||
|
||||
match *self {
|
||||
MonoItem::Fn(ref instance) => {
|
||||
let entry_def_id = tcx.entry_fn(LOCAL_CRATE).map(|(id, _)| id);
|
||||
|
@ -90,26 +99,21 @@ impl<'tcx> MonoItem<'tcx> {
|
|||
return InstantiationMode::GloballyShared { may_conflict: false };
|
||||
}
|
||||
|
||||
let generate_cgu_internal_copies = tcx
|
||||
.sess
|
||||
.opts
|
||||
.debugging_opts
|
||||
.inline_in_all_cgus
|
||||
.unwrap_or_else(|| tcx.sess.opts.optimize != OptLevel::No)
|
||||
&& !tcx.sess.link_dead_code();
|
||||
|
||||
// At this point we don't have explicit linkage and we're an
|
||||
// inlined function. If we should generate local copies for each CGU,
|
||||
// then return `LocalCopy`, otherwise we'll just generate one copy
|
||||
// and share it with all CGUs in this crate.
|
||||
// inlined function. If we're inlining into all CGUs then we'll
|
||||
// be creating a local copy per CGU.
|
||||
if generate_cgu_internal_copies {
|
||||
InstantiationMode::LocalCopy
|
||||
} else {
|
||||
// Finally, if we've reached this point, then we should optimize for
|
||||
// compilation speed. In that regard, we will ignore any `#[inline]`
|
||||
// annotations on the function and simply codegen it as usual. This could
|
||||
// conflict with upstream crates as it could be an exported symbol.
|
||||
InstantiationMode::GloballyShared { may_conflict: true }
|
||||
return InstantiationMode::LocalCopy;
|
||||
}
|
||||
|
||||
// Finally, if this is `#[inline(always)]` we're sure to respect
|
||||
// that with an inline copy per CGU, but otherwise we'll be
|
||||
// creating one copy of this `#[inline]` function which may
|
||||
// conflict with upstream crates as it could be an exported
|
||||
// symbol.
|
||||
match tcx.codegen_fn_attrs(instance.def_id()).inline {
|
||||
InlineAttr::Always => InstantiationMode::LocalCopy,
|
||||
_ => InstantiationMode::GloballyShared { may_conflict: true },
|
||||
}
|
||||
}
|
||||
MonoItem::Static(..) | MonoItem::GlobalAsm(..) => {
|
||||
|
|
|
@ -92,8 +92,7 @@ impl<'tcx> Const<'tcx> {
|
|||
let item_id = tcx.hir().get_parent_node(hir_id);
|
||||
let item_def_id = tcx.hir().local_def_id(item_id);
|
||||
let generics = tcx.generics_of(item_def_id.to_def_id());
|
||||
let index =
|
||||
generics.param_def_id_to_index[&tcx.hir().local_def_id(hir_id).to_def_id()];
|
||||
let index = generics.param_def_id_to_index[&def_id];
|
||||
let name = tcx.hir().name(hir_id);
|
||||
ty::ConstKind::Param(ty::ParamConst::new(index, name))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue