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 11 pull requests #77557

Merged
merged 44 commits into from
Oct 5, 2020
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
8894b36
Remove error message in specific case
JulianKnodt Aug 26, 2020
badf4af
core::global_allocator docs link to std::alloc::GlobalAlloc
mightyiam Sep 26, 2020
e05e2f9
bootstrap: add ./x.py run src/tools/build-manifest
pietroalbini Sep 30, 2020
d4928ad
build-manifest: keep legacy behavior when invoking through ./x.py dist
pietroalbini Sep 30, 2020
6e15975
build-manifest: split the manifest struct definition in a separate file
pietroalbini Sep 30, 2020
df76cf8
BTreeMap: admit the existence of leaf edges in comments
ssomers Aug 9, 2020
0375ee8
build-manifest: move generating a target to the manifest mod
pietroalbini Oct 1, 2020
acd8e59
build-manifest: calculate checksums lazily and in parallel
pietroalbini Oct 1, 2020
fde1135
build-manifest: avoid collecting SHAs in parallel on legacy mode
pietroalbini Oct 1, 2020
9352062
build-manifest: use BufReader
pietroalbini Oct 1, 2020
0801263
Fix missing diagnostic span for `impl Trait` with const generics
varkor Oct 2, 2020
1db05e0
Add various `min_const_generics` regression tests
varkor Oct 2, 2020
d71d13e
BTreeMap: refactoring around edges, missed spots
ssomers Sep 26, 2020
488b759
Replace "non trivial" with "non-trivial"
varkor Oct 2, 2020
96eb68b
Add `FIXME` for const generic defaults
varkor Oct 3, 2020
3631d29
Add tests for `const_generics`
varkor Oct 3, 2020
7029065
Move tests
varkor Oct 3, 2020
6647eee
Add `const_generics` test for `impl-trait-with-const-arguments`
varkor Oct 3, 2020
0e68e1b
Prevent #[doc(alias = "...")] at crate level
GuillaumeGomez Sep 4, 2020
5c836e3
Add test for #[doc(alias = "...")] at crate level
GuillaumeGomez Sep 4, 2020
0e18017
Ensure that the error isn't displayed more than once
GuillaumeGomez Sep 11, 2020
3950a6d
Run attributes check at crate level
GuillaumeGomez Sep 21, 2020
6ec2474
Strenghten tests for crate-level attributes check
GuillaumeGomez Sep 29, 2020
98a2292
Allow `Abort` terminators in a const-context
ecstatic-morse Oct 3, 2020
a5f0831
Add check-pass test for `#[unwind(aborts)]` on a `const fn`
ecstatic-morse Oct 3, 2020
14c3705
Ensure that the const-eval engine handles `#[unwind(aborts)]`
ecstatic-morse Oct 3, 2020
d74b8e0
Replace some once(x).chain(once(y)) with [x, y] IntoIter
scottmcm Oct 3, 2020
3641a37
Enforce crate level attributes checks
GuillaumeGomez Oct 3, 2020
4585c22
Include scope id in SocketAddrV6::Display
tamird Oct 1, 2020
25fdbaf
Discuss cleanup blocks and `span_bug` on `Abort`
ecstatic-morse Oct 4, 2020
fe97990
Add comment to `Abort` match arm
ecstatic-morse Oct 4, 2020
6ae1da3
But whatever
ecstatic-morse Oct 4, 2020
17d3c0a
Use more intra-doc-links in `core::fmt`
LeSeulArtichaut Aug 23, 2020
6c9e857
Rollup merge of #75853 - LeSeulArtichaut:core-intra-docs-3, r=jyn514
Dylan-DPC Oct 5, 2020
5fa978f
Rollup merge of #75928 - JulianKnodt:non_utf8, r=estebank
Dylan-DPC Oct 5, 2020
e6e7ccc
Rollup merge of #76329 - GuillaumeGomez:doc-alias-crate-level, r=matt…
Dylan-DPC Oct 5, 2020
583269d
Rollup merge of #77219 - mightyiam:issue_77100, r=jyn514
Dylan-DPC Oct 5, 2020
fe087ec
Rollup merge of #77395 - ssomers:btree_love_the_leaf_edge_comments, r…
Dylan-DPC Oct 5, 2020
fffeaa7
Rollup merge of #77407 - pietroalbini:less-build-manifest, r=Mark-Sim…
Dylan-DPC Oct 5, 2020
f1afed5
Rollup merge of #77426 - tamird:sockaddr-scope-id, r=dtolnay
Dylan-DPC Oct 5, 2020
e032bb7
Rollup merge of #77439 - varkor:min_const_generics-tests, r=lcnr,este…
Dylan-DPC Oct 5, 2020
23b1e3d
Rollup merge of #77471 - ssomers:btree_cleanup_3, r=Mark-Simulacrum
Dylan-DPC Oct 5, 2020
5fbb411
Rollup merge of #77512 - ecstatic-morse:const-checking-allow-abort, r…
Dylan-DPC Oct 5, 2020
9dbc9ed
Rollup merge of #77514 - scottmcm:less-once-chain-once, r=estebank
Dylan-DPC Oct 5, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
72 changes: 64 additions & 8 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,16 @@ dependencies = [
"block-padding",
"byte-tools",
"byteorder",
"generic-array",
"generic-array 0.12.3",
]

[[package]]
name = "block-buffer"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4"
dependencies = [
"generic-array 0.14.4",
]

[[package]]
Expand Down Expand Up @@ -233,8 +242,11 @@ version = "0.1.0"
dependencies = [
"anyhow",
"flate2",
"hex 0.4.2",
"rayon",
"serde",
"serde_json",
"sha2",
"tar",
"toml",
]
Expand Down Expand Up @@ -687,6 +699,12 @@ version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a21fa21941700a3cd8fcb4091f361a6a712fac632f85d9f487cc892045d55c6"

[[package]]
name = "cpuid-bool"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634"

[[package]]
name = "crates-io"
version = "0.31.1"
Expand Down Expand Up @@ -884,7 +902,16 @@ version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5"
dependencies = [
"generic-array",
"generic-array 0.12.3",
]

[[package]]
name = "digest"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066"
dependencies = [
"generic-array 0.14.4",
]

[[package]]
Expand Down Expand Up @@ -1166,6 +1193,16 @@ dependencies = [
"typenum",
]

[[package]]
name = "generic-array"
version = "0.14.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817"
dependencies = [
"typenum",
"version_check",
]

[[package]]
name = "getopts"
version = "0.2.21"
Expand Down Expand Up @@ -1835,9 +1872,9 @@ version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a18af3dcaf2b0219366cdb4e2af65a6101457b415c3d1a5c71dd9c2b7c77b9c8"
dependencies = [
"block-buffer",
"digest",
"opaque-debug",
"block-buffer 0.7.3",
"digest 0.8.1",
"opaque-debug 0.2.3",
]

[[package]]
Expand Down Expand Up @@ -2097,6 +2134,12 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"

[[package]]
name = "opaque-debug"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"

[[package]]
name = "open"
version = "1.4.0"
Expand Down Expand Up @@ -4362,10 +4405,23 @@ version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df"
dependencies = [
"block-buffer",
"digest",
"block-buffer 0.7.3",
"digest 0.8.1",
"fake-simd",
"opaque-debug",
"opaque-debug 0.2.3",
]

[[package]]
name = "sha2"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2933378ddfeda7ea26f48c555bdad8bb446bf8a3d17832dc83e380d444cfb8c1"
dependencies = [
"block-buffer 0.9.0",
"cfg-if",
"cpuid-bool",
"digest 0.9.0",
"opaque-debug 0.3.0",
]

[[package]]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_feature/src/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ declare_features! (
/// Allows `if let` guard in match arms.
(active, if_let_guard, "1.47.0", Some(51114), None),

/// Allows non trivial generic constants which have to be manually propageted upwards.
/// Allows non-trivial generic constants which have to be manually propageted upwards.
(active, const_evaluatable_checked, "1.48.0", Some(76560), None),

/// Allows basic arithmetic on floating point types in a `const fn`.
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_hir/src/def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,7 @@ impl<T> PerNS<Option<T>> {

/// Returns an iterator over the items which are `Some`.
pub fn present_items(self) -> impl Iterator<Item = T> {
use std::iter::once;

once(self.type_ns).chain(once(self.value_ns)).chain(once(self.macro_ns)).filter_map(|it| it)
IntoIter::new([self.type_ns, self.value_ns, self.macro_ns]).filter_map(|it| it)
}
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir/src/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ use crate::{Item, ItemKind, TraitItem, TraitItemKind};

use std::fmt::{self, Display};

#[derive(Copy, Clone, PartialEq)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum MethodKind {
Trait { body: bool },
Inherent,
}

#[derive(Copy, Clone, PartialEq)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum Target {
ExternCrate,
Use,
Expand Down
12 changes: 0 additions & 12 deletions compiler/rustc_mir/src/transform/check_consts/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,6 @@ pub trait NonConstOp: std::fmt::Debug {
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx>;
}

#[derive(Debug)]
pub struct Abort;
impl NonConstOp for Abort {
fn status_in_item(&self, ccx: &ConstCx<'_, '_>) -> Status {
mcf_status_in_item(ccx)
}

fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
mcf_build_error(ccx, span, "abort is not stable in const fn")
}
}

#[derive(Debug)]
pub struct FloatingPointOp;
impl NonConstOp for FloatingPointOp {
Expand Down
16 changes: 11 additions & 5 deletions compiler/rustc_mir/src/transform/check_consts/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,11 +434,13 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
fn visit_basic_block_data(&mut self, bb: BasicBlock, block: &BasicBlockData<'tcx>) {
trace!("visit_basic_block_data: bb={:?} is_cleanup={:?}", bb, block.is_cleanup);

// Just as the old checker did, we skip const-checking basic blocks on the unwind path.
// These blocks often drop locals that would otherwise be returned from the function.
// We don't const-check basic blocks on the cleanup path since we never unwind during
// const-eval: a panic causes an immediate compile error. In other words, cleanup blocks
// are unreachable during const-eval.
//
// FIXME: This shouldn't be unsound since a panic at compile time will cause a compiler
// error anyway, but maybe we should do more here?
// We can't be more conservative (e.g., by const-checking cleanup blocks anyways) because
// locals that would never be dropped during normal execution are sometimes dropped during
// unwinding, which means backwards-incompatible live-drop errors.
if block.is_cleanup {
return;
}
Expand Down Expand Up @@ -874,12 +876,16 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
}

TerminatorKind::InlineAsm { .. } => self.check_op(ops::InlineAsm),
TerminatorKind::Abort => self.check_op(ops::Abort),

TerminatorKind::GeneratorDrop | TerminatorKind::Yield { .. } => {
self.check_op(ops::Generator(hir::GeneratorKind::Gen))
}

TerminatorKind::Abort => {
// Cleanup blocks are skipped for const checking (see `visit_basic_block_data`).
span_bug!(self.span, "`Abort` terminator outside of cleanup block")
}

TerminatorKind::Assert { .. }
| TerminatorKind::FalseEdge { .. }
| TerminatorKind::FalseUnwind { .. }
Expand Down
56 changes: 53 additions & 3 deletions compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ use rustc_errors::{pluralize, struct_span_err};
use rustc_hir as hir;
use rustc_hir::def_id::LocalDefId;
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
use rustc_hir::{self, FnSig, ForeignItem, ForeignItemKind, HirId, Item, ItemKind, TraitItem};
use rustc_hir::{
self, FnSig, ForeignItem, ForeignItemKind, HirId, Item, ItemKind, TraitItem, CRATE_HIR_ID,
};
use rustc_hir::{MethodKind, Target};
use rustc_session::lint::builtin::{CONFLICTING_REPR_HINTS, UNUSED_ATTRIBUTES};
use rustc_session::parse::feature_err;
use rustc_span::symbol::sym;
use rustc_span::Span;
use rustc_span::symbol::{sym, Symbol};
use rustc_span::{Span, DUMMY_SP};

pub(crate) fn target_from_impl_item<'tcx>(
tcx: TyCtxt<'tcx>,
Expand Down Expand Up @@ -333,6 +335,17 @@ impl CheckAttrVisitor<'tcx> {
.emit();
return false;
}
if CRATE_HIR_ID == hir_id {
self.tcx
.sess
.struct_span_err(
meta.span(),
"`#![doc(alias = \"...\")]` isn't allowed as a crate \
level attribute",
)
.emit();
return false;
}
}
}
}
Expand Down Expand Up @@ -808,9 +821,46 @@ fn is_c_like_enum(item: &Item<'_>) -> bool {
}
}

fn check_invalid_crate_level_attr(tcx: TyCtxt<'_>, attrs: &[Attribute]) {
const ATTRS_TO_CHECK: &[Symbol] = &[
sym::macro_export,
sym::repr,
sym::path,
sym::automatically_derived,
sym::start,
sym::main,
];

for attr in attrs {
for attr_to_check in ATTRS_TO_CHECK {
if tcx.sess.check_name(attr, *attr_to_check) {
tcx.sess
.struct_span_err(
attr.span,
&format!(
"`{}` attribute cannot be used at crate level",
attr_to_check.to_ident_string()
),
)
.emit();
}
}
}
}

fn check_mod_attrs(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
tcx.hir()
.visit_item_likes_in_module(module_def_id, &mut CheckAttrVisitor { tcx }.as_deep_visitor());
if module_def_id.is_top_level_module() {
CheckAttrVisitor { tcx }.check_attributes(
CRATE_HIR_ID,
tcx.hir().krate_attrs(),
&DUMMY_SP,
Target::Mod,
None,
);
check_invalid_crate_level_attr(tcx, tcx.hir().krate_attrs());
}
}

pub(crate) fn provide(providers: &mut Providers) {
Expand Down
44 changes: 26 additions & 18 deletions compiler/rustc_passes/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,29 +78,38 @@ fn entry_fn(tcx: TyCtxt<'_>, cnum: CrateNum) -> Option<(LocalDefId, EntryFnType)
// Beware, this is duplicated in `librustc_builtin_macros/test_harness.rs`
// (with `ast::Item`), so make sure to keep them in sync.
fn entry_point_type(sess: &Session, item: &Item<'_>, at_root: bool) -> EntryPointType {
match item.kind {
ItemKind::Fn(..) => {
if sess.contains_name(&item.attrs, sym::start) {
EntryPointType::Start
} else if sess.contains_name(&item.attrs, sym::main) {
EntryPointType::MainAttr
} else if item.ident.name == sym::main {
if at_root {
// This is a top-level function so can be `main`.
EntryPointType::MainNamed
} else {
EntryPointType::OtherMain
}
} else {
EntryPointType::None
}
if sess.contains_name(&item.attrs, sym::start) {
EntryPointType::Start
} else if sess.contains_name(&item.attrs, sym::main) {
EntryPointType::MainAttr
} else if item.ident.name == sym::main {
if at_root {
// This is a top-level function so can be `main`.
EntryPointType::MainNamed
} else {
EntryPointType::OtherMain
}
_ => EntryPointType::None,
} else {
EntryPointType::None
}
}

fn throw_attr_err(sess: &Session, span: Span, attr: &str) {
sess.struct_span_err(span, &format!("`{}` attribute can only be used on functions", attr))
.emit();
}

fn find_item(item: &Item<'_>, ctxt: &mut EntryContext<'_, '_>, at_root: bool) {
match entry_point_type(&ctxt.session, item, at_root) {
EntryPointType::None => (),
_ if !matches!(item.kind, ItemKind::Fn(..)) => {
if let Some(attr) = ctxt.session.find_by_name(item.attrs, sym::start) {
throw_attr_err(&ctxt.session, attr.span, "start");
}
if let Some(attr) = ctxt.session.find_by_name(item.attrs, sym::main) {
throw_attr_err(&ctxt.session, attr.span, "main");
}
}
EntryPointType::MainNamed => {
if ctxt.main_fn.is_none() {
ctxt.main_fn = Some((item.hir_id, item.span));
Expand Down Expand Up @@ -137,7 +146,6 @@ fn find_item(item: &Item<'_>, ctxt: &mut EntryContext<'_, '_>, at_root: bool) {
.emit();
}
}
EntryPointType::None => (),
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ impl<'a> Resolver<'a> {
ResolutionError::ParamInNonTrivialAnonConst { name, is_type } => {
let mut err = self.session.struct_span_err(
span,
"generic parameters must not be used inside of non trivial constant values",
"generic parameters must not be used inside of non-trivial constant values",
);
err.span_label(
span,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ enum ResolutionError<'a> {
ParamInTyOfConstParam(Symbol),
/// constant values inside of type parameter defaults must not depend on generic parameters.
ParamInAnonConstInTyDefault(Symbol),
/// generic parameters must not be used inside of non trivial constant values.
/// generic parameters must not be used inside of non-trivial constant values.
///
/// This error is only emitted when using `min_const_generics`.
ParamInNonTrivialAnonConst { name: Symbol, is_type: bool },
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_session/src/lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ declare_lint! {
/// ### Example
///
/// ```rust
/// #![macro_export]
/// #![ignore]
/// ```
///
/// {{produces}}
Expand Down