Skip to content

Commit

Permalink
Auto merge of #80615 - m-ou-se:rollup-xz67at2, r=m-ou-se
Browse files Browse the repository at this point in the history
Rollup of 6 pull requests

Successful merges:

 - #80546 (clippy fixes for librustdoc)
 - #80555 (Improve library tracking issue template)
 - #80574 (Clean bootstrap artifacts on `x.py clean`)
 - #80578 (improve unconditional_panic description)
 - #80599 (`const_generics_defaults`: don't ICE in the unimplemented parts)
 - #80613 (Diag: print enum variant instead of enum type)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Jan 2, 2021
2 parents 929f66a + 4172756 commit 90ccf4f
Show file tree
Hide file tree
Showing 24 changed files with 149 additions and 118 deletions.
32 changes: 26 additions & 6 deletions .github/ISSUE_TEMPLATE/library_tracking_issue.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,41 @@ For most library features, it'd be useful to include a summarized version of the
-->

```rust
...
// core::magic

pub struct Magic;

impl Magic {
pub fn magic(self);
}
```

### Steps / History

<!--
In the simplest case, this is a PR implementing the feature followed by a PR
that stabilises the feature. However it's not uncommon for the feature to be
changed before stabilization. For larger features, the implementation could be
split up in multiple steps.
For larger features, more steps might be involved.
If the feature is changed later, please add those PRs here as well.
-->

- [ ] Implementation: ...
- [ ] Implementation: #...
- [ ] Final commenting period (FCP)
- [ ] Stabilization PR

<!--
Once the feature has gone through a few release cycles and there are no
unresolved questions left, the feature might be ready for stabilization.
If this feature didn't go through the RFC process, a final commenting period
(FCP) is always needed before stabilization. This works as follows:
A library team member can kick off the stabilization process, at which point
the rfcbot will ask all the team members to verify they agree with
stabilization. Once enough members agree and there are no concerns, the final
commenting period begins: this issue will be marked as such and will be listed
in the next This Week in Rust newsletter. If no blocking concerns are raised in
that period of 10 days, a stabilzation PR can be opened by anyone.
-->

### Unresolved Questions

<!--
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_ast_pretty/src/pprust/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2677,7 +2677,6 @@ impl<'a> State<'a> {
s.print_type_bounds(":", &param.bounds);
if let Some(ref _default) = default {
// FIXME(const_generics_defaults): print the `default` value here
todo!();
}
}
}
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_hir_pretty/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2210,7 +2210,6 @@ impl<'a> State<'a> {
self.print_type(ty);
if let Some(ref _default) = default {
// FIXME(const_generics_defaults): print the `default` value here
todo!();
}
}
}
Expand Down
12 changes: 4 additions & 8 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,10 @@ declare_lint! {
///
/// ### Explanation
///
/// This lint detects code that is very likely incorrect. When possible,
/// the compiler will attempt to detect situations where code can be
/// evaluated at compile-time to generate more efficient code. While
/// evaluating such code, if it detects that the code will unconditionally
/// panic, this usually indicates that it is doing something incorrectly.
/// If this lint is allowed, then the code will not be evaluated at
/// compile-time, and instead continue to generate code to evaluate at
/// runtime, which may panic during runtime.
/// This lint detects code that is very likely incorrect because it will
/// always panic, such as division by zero and out-of-bounds array
/// accesses. Consider adjusting your code if this is a bug, or using the
/// `panic!` or `unreachable!` macro instead in case the panic is intended.
pub UNCONDITIONAL_PANIC,
Deny,
"operation will cause a panic at runtime"
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_save_analysis/src/sig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,6 @@ impl<'hir> Sig for hir::Generics<'hir> {
param_text.push_str(&ty_to_string(&ty));
if let Some(ref _default) = default {
// FIXME(const_generics_defaults): push the `default` value here
todo!();
}
}
if !param.bounds.is_empty() {
Expand Down
49 changes: 36 additions & 13 deletions compiler/rustc_typeck/src/check/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1381,19 +1381,42 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
ty,
);
match variant.ctor_kind {
CtorKind::Fn => {
err.span_label(variant.ident.span, format!("`{adt}` defined here", adt = ty));
err.span_label(field.ident.span, "field does not exist");
err.span_label(
ty_span,
format!(
"`{adt}` is a tuple {kind_name}, \
use the appropriate syntax: `{adt}(/* fields */)`",
adt = ty,
kind_name = kind_name
),
);
}
CtorKind::Fn => match ty.kind() {
ty::Adt(adt, ..) if adt.is_enum() => {
err.span_label(
variant.ident.span,
format!(
"`{adt}::{variant}` defined here",
adt = ty,
variant = variant.ident,
),
);
err.span_label(field.ident.span, "field does not exist");
err.span_label(
ty_span,
format!(
"`{adt}::{variant}` is a tuple {kind_name}, \
use the appropriate syntax: `{adt}::{variant}(/* fields */)`",
adt = ty,
variant = variant.ident,
kind_name = kind_name
),
);
}
_ => {
err.span_label(variant.ident.span, format!("`{adt}` defined here", adt = ty));
err.span_label(field.ident.span, "field does not exist");
err.span_label(
ty_span,
format!(
"`{adt}` is a tuple {kind_name}, \
use the appropriate syntax: `{adt}(/* fields */)`",
adt = ty,
kind_name = kind_name
),
);
}
},
_ => {
// prevent all specified fields from being suggested
let skip_fields = skip_fields.iter().map(|ref x| x.ident.name);
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub fn clean(build: &Build, all: bool) {
} else {
rm_rf(&build.out.join("tmp"));
rm_rf(&build.out.join("dist"));
rm_rf(&build.out.join("bootstrap"));

for host in &build.hosts {
let entries = match build.out.join(host.triple).read_dir() {
Expand Down
10 changes: 5 additions & 5 deletions src/librustdoc/clean/auto_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -738,11 +738,11 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
}

fn is_fn_ty(&self, tcx: TyCtxt<'_>, ty: &Type) -> bool {
match &ty {
&&Type::ResolvedPath { ref did, .. } => {
*did == tcx.require_lang_item(LangItem::Fn, None)
|| *did == tcx.require_lang_item(LangItem::FnMut, None)
|| *did == tcx.require_lang_item(LangItem::FnOnce, None)
match ty {
&Type::ResolvedPath { did, .. } => {
did == tcx.require_lang_item(LangItem::Fn, None)
|| did == tcx.require_lang_item(LangItem::FnMut, None)
|| did == tcx.require_lang_item(LangItem::FnOnce, None)
}
_ => false,
}
Expand Down
16 changes: 4 additions & 12 deletions src/librustdoc/clean/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,29 +177,21 @@ impl Cfg {
Cfg::Any(ref sub_cfgs) | Cfg::All(ref sub_cfgs) => {
sub_cfgs.first().map(Cfg::should_capitalize_first_letter).unwrap_or(false)
}
Cfg::Cfg(name, _) => match name {
sym::debug_assertions | sym::target_endian => true,
_ => false,
},
Cfg::Cfg(name, _) => name == sym::debug_assertions || name == sym::target_endian,
}
}

fn should_append_only_to_description(&self) -> bool {
match *self {
Cfg::False | Cfg::True => false,
Cfg::Any(..) | Cfg::All(..) | Cfg::Cfg(..) => true,
Cfg::Not(ref child) => match **child {
Cfg::Cfg(..) => true,
_ => false,
},
Cfg::Not(box Cfg::Cfg(..)) => true,
Cfg::Not(..) => false,
}
}

fn should_use_with_in_description(&self) -> bool {
match *self {
Cfg::Cfg(name, _) if name == sym::target_feature => true,
_ => false,
}
matches!(self, Cfg::Cfg(sym::target_feature, _))
}

/// Attempt to simplify this cfg by assuming that `assume` is already known to be true, will
Expand Down
10 changes: 5 additions & 5 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -640,10 +640,10 @@ impl Clean<Generics> for hir::Generics<'_> {
///
/// [`lifetime_to_generic_param`]: rustc_ast_lowering::LoweringContext::lifetime_to_generic_param
fn is_elided_lifetime(param: &hir::GenericParam<'_>) -> bool {
match param.kind {
hir::GenericParamKind::Lifetime { kind: hir::LifetimeParamKind::Elided } => true,
_ => false,
}
matches!(
param.kind,
hir::GenericParamKind::Lifetime { kind: hir::LifetimeParamKind::Elided }
)
}

let impl_trait_params = self
Expand Down Expand Up @@ -801,7 +801,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics, ty::GenericPredicates<'tcx

for (param, mut bounds) in impl_trait {
// Move trait bounds to the front.
bounds.sort_by_key(|b| if let GenericBound::TraitBound(..) = b { false } else { true });
bounds.sort_by_key(|b| !matches!(b, GenericBound::TraitBound(..)));

if let crate::core::ImplTraitParam::ParamIndex(idx) = param {
if let Some(proj) = impl_trait_proj.remove(&idx) {
Expand Down
27 changes: 8 additions & 19 deletions src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,9 @@ impl Item {
}

crate fn is_crate(&self) -> bool {
match *self.kind {
matches!(*self.kind,
StrippedItem(box ModuleItem(Module { is_crate: true, .. }))
| ModuleItem(Module { is_crate: true, .. }) => true,
_ => false,
}
| ModuleItem(Module { is_crate: true, .. }))
}
crate fn is_mod(&self) -> bool {
self.type_() == ItemType::Module
Expand Down Expand Up @@ -378,10 +376,7 @@ impl ItemKind {
}

crate fn is_type_alias(&self) -> bool {
match *self {
ItemKind::TypedefItem(_, _) | ItemKind::AssocTypeItem(_, _) => true,
_ => false,
}
matches!(self, ItemKind::TypedefItem(..) | ItemKind::AssocTypeItem(..))
}
}

Expand Down Expand Up @@ -674,7 +669,7 @@ impl Attributes {
span: attr.span,
doc: contents,
kind: DocFragmentKind::Include { filename },
parent_module: parent_module,
parent_module,
});
}
}
Expand Down Expand Up @@ -750,7 +745,7 @@ impl Attributes {
Some(did) => {
if let Some((mut href, ..)) = href(did) {
if let Some(ref fragment) = *fragment {
href.push_str("#");
href.push('#');
href.push_str(fragment);
}
Some(RenderedLink {
Expand Down Expand Up @@ -945,10 +940,7 @@ crate enum GenericParamDefKind {

impl GenericParamDefKind {
crate fn is_type(&self) -> bool {
match *self {
GenericParamDefKind::Type { .. } => true,
_ => false,
}
matches!(self, GenericParamDefKind::Type { .. })
}

// FIXME(eddyb) this either returns the default of a type parameter, or the
Expand Down Expand Up @@ -1292,15 +1284,12 @@ impl Type {
}

crate fn is_full_generic(&self) -> bool {
match *self {
Type::Generic(_) => true,
_ => false,
}
matches!(self, Type::Generic(_))
}

crate fn projection(&self) -> Option<(&Type, DefId, Symbol)> {
let (self_, trait_, name) = match self {
QPath { ref self_type, ref trait_, name } => (self_type, trait_, name),
QPath { self_type, trait_, name } => (self_type, trait_, name),
_ => return None,
};
let trait_did = match **trait_ {
Expand Down
5 changes: 1 addition & 4 deletions src/librustdoc/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ crate enum OutputFormat {

impl OutputFormat {
crate fn is_json(&self) -> bool {
match self {
OutputFormat::Json => true,
_ => false,
}
matches!(self, OutputFormat::Json)
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/librustdoc/doctest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -636,15 +636,15 @@ fn partition_source(s: &str) -> (String, String, String) {
match state {
PartitionState::Attrs => {
before.push_str(line);
before.push_str("\n");
before.push('\n');
}
PartitionState::Crates => {
crates.push_str(line);
crates.push_str("\n");
crates.push('\n');
}
PartitionState::Other => {
after.push_str(line);
after.push_str("\n");
after.push('\n');
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ crate trait DocFolder: Sized {
j.fields = j.fields.into_iter().filter_map(|x| self.fold_item(x)).collect();
j.fields_stripped |= num_fields != j.fields.len()
|| j.fields.iter().any(|f| f.is_stripped());
VariantItem(Variant { kind: VariantKind::Struct(j), ..i2 })
VariantItem(Variant { kind: VariantKind::Struct(j) })
}
_ => VariantItem(i2),
}
Expand Down
Loading

0 comments on commit 90ccf4f

Please sign in to comment.