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 14 pull requests #90119

Merged
merged 44 commits into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
734bfde
Disallow octal zeros in IPv4 addresses
syvb Jul 8, 2021
69de693
Clarify docs on what IPv4 octal addresses are
syvb Jul 9, 2021
b9b97bb
Reject too-long IPs quicker
syvb Jul 9, 2021
a331e5f
Simplify leading zero checks
syvb Jul 11, 2021
ace518d
Add example with a bunch of leading zeos
syvb Jul 11, 2021
d65ab29
Remove unnecessary condition in Barrier::wait()
twetzel59 Jul 24, 2021
403d269
Specify maximum IP address length
syvb Aug 10, 2021
85d6029
`AbstractConst::root`: Always run `subst` when `Node` is `Leaf`
eopb Sep 4, 2021
22c2738
Minor cleanup: make imports more consistent
eopb Sep 4, 2021
6e40618
Remove left over comment
eopb Sep 4, 2021
fc5633f
Make fields on `AbstractConst` private
eopb Sep 4, 2021
b7d9998
Add line that was unintentionally removed
eopb Sep 4, 2021
4a37b9c
Avoid overflow in `VecDeque::with_capacity_in()`.
hkratz Oct 18, 2021
93f80bf
Remove comment saying that we don't build debug rustc in CI, since we do
tgnottingham Oct 18, 2021
aefbd40
Add test for debug logging during incremental compilation
tgnottingham Oct 18, 2021
f2a234e
config: add the option to enable LLVM tests
durin42 Oct 18, 2021
e8b5af1
Upgrade browser-ui-test version to 0.4.5 (it allows to have multi-lin…
GuillaumeGomez Oct 19, 2021
05eb6f3
Cleanup dead code in hir::map::blocks.
cjgillot Oct 19, 2021
99b8c01
Address lcnr review
eopb Oct 19, 2021
6e98688
Replace FnLikeNode by FnKind.
cjgillot Oct 19, 2021
aad48f7
replace format!("") with String::new()
klensy Oct 9, 2021
f3fb821
use array explicitly instead of vec for const content (even if optimi…
klensy Oct 9, 2021
2fc7806
Make `From` impls of NonZero integer const.
lilasta Oct 20, 2021
be30e60
remove duplicate subst
eopb Oct 20, 2021
457f578
Add test for line-number setting
GuillaumeGomez Oct 19, 2021
0aa68a8
Prevent invalid values from existing in Vec::swap_remove
SkiFire13 Oct 20, 2021
50dc319
Add test for duplicated sidebar entries for reexported macro
GuillaumeGomez Oct 20, 2021
69ca324
Add test to ensure that the missing_doc_code_examples is not triggere…
GuillaumeGomez Oct 20, 2021
86b3dd9
stabilize CString::from_vec_with_nul[_unchecked]
CleanCut Sep 26, 2021
39af41e
fix 'since' version number
CleanCut Oct 20, 2021
09de34c
Rollup merge of #86984 - Smittyvb:ipv4-octal-zero, r=m-ou-se
JohnTitor Oct 21, 2021
fb9232b
Rollup merge of #87440 - twetzel59:fix-barrier-no-op, r=yaahc
JohnTitor Oct 21, 2021
6f0acbc
Rollup merge of #88644 - eopb:abstractconst_leaf_subst, r=lcnr
JohnTitor Oct 21, 2021
20687bb
Rollup merge of #89292 - CleanCut:stabilize-cstring_from_vec_with_nul…
JohnTitor Oct 21, 2021
d29e98f
Rollup merge of #90010 - rusticstuff:vecdeque_with_capacity_in_overfl…
JohnTitor Oct 21, 2021
a980587
Rollup merge of #90029 - tgnottingham:incr-debug-logging-test, r=Mark…
JohnTitor Oct 21, 2021
632f06d
Rollup merge of #90031 - durin42:allow-llvm-tests, r=Mark-Simulacrum
JohnTitor Oct 21, 2021
47a1f67
Rollup merge of #90048 - GuillaumeGomez:line-number-setting, r=jsha
JohnTitor Oct 21, 2021
afdd0c3
Rollup merge of #90071 - cjgillot:no-blocks, r=oli-obk
JohnTitor Oct 21, 2021
371fd4f
Rollup merge of #90074 - klensy:upvar-all, r=wesleywiser
JohnTitor Oct 21, 2021
e4cfaa1
Rollup merge of #90077 - woppopo:const_nonzero_from, r=oli-obk
JohnTitor Oct 21, 2021
759a8ae
Rollup merge of #90097 - GuillaumeGomez:duplicated-sidebar-entry-reex…
JohnTitor Oct 21, 2021
68a5680
Rollup merge of #90098 - GuillaumeGomez:add-test-foreign-impl-missing…
JohnTitor Oct 21, 2021
3680ecd
Rollup merge of #90099 - SkiFire13:fix-vec-swap-remove, r=dtolnay
JohnTitor Oct 21, 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
5 changes: 2 additions & 3 deletions compiler/rustc_const_eval/src/const_eval/fn_queries.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_middle::hir::map::blocks::FnLikeNode;
use rustc_middle::ty::query::Providers;
use rustc_middle::ty::TyCtxt;
use rustc_span::symbol::Symbol;
Expand Down Expand Up @@ -44,8 +43,8 @@ fn is_const_fn_raw(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
} else {
false
}
} else if let Some(fn_like) = FnLikeNode::from_node(node) {
if fn_like.constness() == hir::Constness::Const {
} else if let Some(fn_kind) = node.fn_kind() {
if fn_kind.constness() == hir::Constness::Const {
return true;
}

Expand Down
27 changes: 27 additions & 0 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::def::{CtorKind, DefKind, Res};
use crate::def_id::DefId;
crate use crate::hir_id::{HirId, ItemLocalId};
use crate::intravisit::FnKind;
use crate::LangItem;

use rustc_ast::util::parser::ExprPrecedence;
Expand Down Expand Up @@ -3258,6 +3259,32 @@ impl<'hir> Node<'hir> {
_ => None,
}
}

pub fn fn_kind(self) -> Option<FnKind<'hir>> {
match self {
Node::Item(i) => match i.kind {
ItemKind::Fn(ref sig, ref generics, _) => {
Some(FnKind::ItemFn(i.ident, generics, sig.header, &i.vis))
}
_ => None,
},
Node::TraitItem(ti) => match ti.kind {
TraitItemKind::Fn(ref sig, TraitFn::Provided(_)) => {
Some(FnKind::Method(ti.ident, sig, None))
}
_ => None,
},
Node::ImplItem(ii) => match ii.kind {
ImplItemKind::Fn(ref sig, _) => Some(FnKind::Method(ii.ident, sig, Some(&ii.vis))),
_ => None,
},
Node::Expr(e) => match e.kind {
ExprKind::Closure(..) => Some(FnKind::Closure),
_ => None,
},
_ => None,
}
}
}

// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_hir/src/intravisit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ impl<'a> FnKind<'a> {
FnKind::Closure => None,
}
}

pub fn constness(self) -> Constness {
self.header().map_or(Constness::NotConst, |header| header.constness)
}

pub fn asyncness(self) -> IsAsync {
self.header().map_or(IsAsync::NotAsync, |header| header.asyncness)
}
}

/// An abstract representation of the HIR `rustc_middle::hir::map::Map`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
// similar to the asyncness fn in rustc_ty_utils::ty
let hir_id = self.tcx().hir().local_def_id_to_hir_id(local_def_id);
let node = self.tcx().hir().get(hir_id);
let fn_like = rustc_middle::hir::map::blocks::FnLikeNode::from_node(node)?;

Some(fn_like.asyncness())
let fn_kind = node.fn_kind()?;
Some(fn_kind.asyncness())
}

// Here, we check for the case where the anonymous region
Expand Down
239 changes: 0 additions & 239 deletions compiler/rustc_middle/src/hir/map/blocks.rs

This file was deleted.

2 changes: 0 additions & 2 deletions compiler/rustc_middle/src/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ use rustc_span::Span;
use rustc_target::spec::abi::Abi;
use std::collections::VecDeque;

pub mod blocks;

fn fn_decl<'hir>(node: Node<'hir>) -> Option<&'hir FnDecl<'hir>> {
match node {
Node::Item(Item { kind: ItemKind::Fn(sig, _, _), .. })
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_mir_build/src/lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use rustc_data_structures::graph::iterate::{
NodeStatus, TriColorDepthFirstSearch, TriColorVisitor,
};
use rustc_hir::intravisit::FnKind;
use rustc_middle::hir::map::blocks::FnLikeNode;
use rustc_middle::mir::{BasicBlock, Body, Operand, TerminatorKind};
use rustc_middle::ty::subst::{GenericArg, InternalSubsts};
use rustc_middle::ty::{self, AssocItem, AssocItemContainer, Instance, TyCtxt};
Expand All @@ -14,8 +13,8 @@ crate fn check<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) {
let def_id = body.source.def_id().expect_local();
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);

if let Some(fn_like_node) = FnLikeNode::from_node(tcx.hir().get(hir_id)) {
if let FnKind::Closure = fn_like_node.kind() {
if let Some(fn_kind) = tcx.hir().get(hir_id).fn_kind() {
if let FnKind::Closure = fn_kind {
// closures can't recur, so they don't matter.
return;
}
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_mir_transform/src/const_prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,10 @@ impl<'tcx> MirPass<'tcx> for ConstProp {
return;
}

use rustc_middle::hir::map::blocks::FnLikeNode;
let def_id = body.source.def_id().expect_local();
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);

let is_fn_like = FnLikeNode::from_node(tcx.hir().get(hir_id)).is_some();
let is_fn_like = tcx.hir().get(hir_id).fn_kind().is_some();
let is_assoc_const = tcx.def_kind(def_id.to_def_id()) == DefKind::AssocConst;

// Only run const prop on functions, methods, closures and associated constants
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_mir_transform/src/coverage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::Lrc;
use rustc_index::vec::IndexVec;
use rustc_middle::hir;
use rustc_middle::hir::map::blocks::FnLikeNode;
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use rustc_middle::mir::coverage::*;
use rustc_middle::mir::dump_enabled;
Expand Down Expand Up @@ -64,7 +63,7 @@ impl<'tcx> MirPass<'tcx> for InstrumentCoverage {
}

let hir_id = tcx.hir().local_def_id_to_hir_id(mir_source.def_id().expect_local());
let is_fn_like = FnLikeNode::from_node(tcx.hir().get(hir_id)).is_some();
let is_fn_like = tcx.hir().get(hir_id).fn_kind().is_some();

// Only instrument functions, methods, and closures (not constants since they are evaluated
// at compile time by Miri).
Expand All @@ -74,7 +73,7 @@ impl<'tcx> MirPass<'tcx> for InstrumentCoverage {
// be tricky if const expressions have no corresponding statements in the enclosing MIR.
// Closures are carved out by their initial `Assign` statement.)
if !is_fn_like {
trace!("InstrumentCoverage skipped for {:?} (not an FnLikeNode)", mir_source.def_id());
trace!("InstrumentCoverage skipped for {:?} (not an fn-like)", mir_source.def_id());
return;
}

Expand Down
Loading