Skip to content

Commit 90ccf4f

Browse files
committed
Auto merge of rust-lang#80615 - m-ou-se:rollup-xz67at2, r=m-ou-se
Rollup of 6 pull requests Successful merges: - rust-lang#80546 (clippy fixes for librustdoc) - rust-lang#80555 (Improve library tracking issue template) - rust-lang#80574 (Clean bootstrap artifacts on `x.py clean`) - rust-lang#80578 (improve unconditional_panic description) - rust-lang#80599 (`const_generics_defaults`: don't ICE in the unimplemented parts) - rust-lang#80613 (Diag: print enum variant instead of enum type) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 929f66a + 4172756 commit 90ccf4f

File tree

24 files changed

+149
-118
lines changed

24 files changed

+149
-118
lines changed

.github/ISSUE_TEMPLATE/library_tracking_issue.md

+26-6
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,41 @@ For most library features, it'd be useful to include a summarized version of the
3333
-->
3434

3535
```rust
36-
...
36+
// core::magic
37+
38+
pub struct Magic;
39+
40+
impl Magic {
41+
pub fn magic(self);
42+
}
3743
```
3844

3945
### Steps / History
4046

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

48-
- [ ] Implementation: ...
52+
- [ ] Implementation: #...
53+
- [ ] Final commenting period (FCP)
4954
- [ ] Stabilization PR
5055

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

5373
<!--

compiler/rustc_ast_pretty/src/pprust/state.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2677,7 +2677,6 @@ impl<'a> State<'a> {
26772677
s.print_type_bounds(":", &param.bounds);
26782678
if let Some(ref _default) = default {
26792679
// FIXME(const_generics_defaults): print the `default` value here
2680-
todo!();
26812680
}
26822681
}
26832682
}

compiler/rustc_hir_pretty/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2210,7 +2210,6 @@ impl<'a> State<'a> {
22102210
self.print_type(ty);
22112211
if let Some(ref _default) = default {
22122212
// FIXME(const_generics_defaults): print the `default` value here
2213-
todo!();
22142213
}
22152214
}
22162215
}

compiler/rustc_lint_defs/src/builtin.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -221,14 +221,10 @@ declare_lint! {
221221
///
222222
/// ### Explanation
223223
///
224-
/// This lint detects code that is very likely incorrect. When possible,
225-
/// the compiler will attempt to detect situations where code can be
226-
/// evaluated at compile-time to generate more efficient code. While
227-
/// evaluating such code, if it detects that the code will unconditionally
228-
/// panic, this usually indicates that it is doing something incorrectly.
229-
/// If this lint is allowed, then the code will not be evaluated at
230-
/// compile-time, and instead continue to generate code to evaluate at
231-
/// runtime, which may panic during runtime.
224+
/// This lint detects code that is very likely incorrect because it will
225+
/// always panic, such as division by zero and out-of-bounds array
226+
/// accesses. Consider adjusting your code if this is a bug, or using the
227+
/// `panic!` or `unreachable!` macro instead in case the panic is intended.
232228
pub UNCONDITIONAL_PANIC,
233229
Deny,
234230
"operation will cause a panic at runtime"

compiler/rustc_save_analysis/src/sig.rs

-1
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,6 @@ impl<'hir> Sig for hir::Generics<'hir> {
619619
param_text.push_str(&ty_to_string(&ty));
620620
if let Some(ref _default) = default {
621621
// FIXME(const_generics_defaults): push the `default` value here
622-
todo!();
623622
}
624623
}
625624
if !param.bounds.is_empty() {

compiler/rustc_typeck/src/check/expr.rs

+36-13
Original file line numberDiff line numberDiff line change
@@ -1381,19 +1381,42 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13811381
ty,
13821382
);
13831383
match variant.ctor_kind {
1384-
CtorKind::Fn => {
1385-
err.span_label(variant.ident.span, format!("`{adt}` defined here", adt = ty));
1386-
err.span_label(field.ident.span, "field does not exist");
1387-
err.span_label(
1388-
ty_span,
1389-
format!(
1390-
"`{adt}` is a tuple {kind_name}, \
1391-
use the appropriate syntax: `{adt}(/* fields */)`",
1392-
adt = ty,
1393-
kind_name = kind_name
1394-
),
1395-
);
1396-
}
1384+
CtorKind::Fn => match ty.kind() {
1385+
ty::Adt(adt, ..) if adt.is_enum() => {
1386+
err.span_label(
1387+
variant.ident.span,
1388+
format!(
1389+
"`{adt}::{variant}` defined here",
1390+
adt = ty,
1391+
variant = variant.ident,
1392+
),
1393+
);
1394+
err.span_label(field.ident.span, "field does not exist");
1395+
err.span_label(
1396+
ty_span,
1397+
format!(
1398+
"`{adt}::{variant}` is a tuple {kind_name}, \
1399+
use the appropriate syntax: `{adt}::{variant}(/* fields */)`",
1400+
adt = ty,
1401+
variant = variant.ident,
1402+
kind_name = kind_name
1403+
),
1404+
);
1405+
}
1406+
_ => {
1407+
err.span_label(variant.ident.span, format!("`{adt}` defined here", adt = ty));
1408+
err.span_label(field.ident.span, "field does not exist");
1409+
err.span_label(
1410+
ty_span,
1411+
format!(
1412+
"`{adt}` is a tuple {kind_name}, \
1413+
use the appropriate syntax: `{adt}(/* fields */)`",
1414+
adt = ty,
1415+
kind_name = kind_name
1416+
),
1417+
);
1418+
}
1419+
},
13971420
_ => {
13981421
// prevent all specified fields from being suggested
13991422
let skip_fields = skip_fields.iter().map(|ref x| x.ident.name);

src/bootstrap/clean.rs

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub fn clean(build: &Build, all: bool) {
2121
} else {
2222
rm_rf(&build.out.join("tmp"));
2323
rm_rf(&build.out.join("dist"));
24+
rm_rf(&build.out.join("bootstrap"));
2425

2526
for host in &build.hosts {
2627
let entries = match build.out.join(host.triple).read_dir() {

src/librustdoc/clean/auto_trait.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -738,11 +738,11 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
738738
}
739739

740740
fn is_fn_ty(&self, tcx: TyCtxt<'_>, ty: &Type) -> bool {
741-
match &ty {
742-
&&Type::ResolvedPath { ref did, .. } => {
743-
*did == tcx.require_lang_item(LangItem::Fn, None)
744-
|| *did == tcx.require_lang_item(LangItem::FnMut, None)
745-
|| *did == tcx.require_lang_item(LangItem::FnOnce, None)
741+
match ty {
742+
&Type::ResolvedPath { did, .. } => {
743+
did == tcx.require_lang_item(LangItem::Fn, None)
744+
|| did == tcx.require_lang_item(LangItem::FnMut, None)
745+
|| did == tcx.require_lang_item(LangItem::FnOnce, None)
746746
}
747747
_ => false,
748748
}

src/librustdoc/clean/cfg.rs

+4-12
Original file line numberDiff line numberDiff line change
@@ -177,29 +177,21 @@ impl Cfg {
177177
Cfg::Any(ref sub_cfgs) | Cfg::All(ref sub_cfgs) => {
178178
sub_cfgs.first().map(Cfg::should_capitalize_first_letter).unwrap_or(false)
179179
}
180-
Cfg::Cfg(name, _) => match name {
181-
sym::debug_assertions | sym::target_endian => true,
182-
_ => false,
183-
},
180+
Cfg::Cfg(name, _) => name == sym::debug_assertions || name == sym::target_endian,
184181
}
185182
}
186183

187184
fn should_append_only_to_description(&self) -> bool {
188185
match *self {
189186
Cfg::False | Cfg::True => false,
190187
Cfg::Any(..) | Cfg::All(..) | Cfg::Cfg(..) => true,
191-
Cfg::Not(ref child) => match **child {
192-
Cfg::Cfg(..) => true,
193-
_ => false,
194-
},
188+
Cfg::Not(box Cfg::Cfg(..)) => true,
189+
Cfg::Not(..) => false,
195190
}
196191
}
197192

198193
fn should_use_with_in_description(&self) -> bool {
199-
match *self {
200-
Cfg::Cfg(name, _) if name == sym::target_feature => true,
201-
_ => false,
202-
}
194+
matches!(self, Cfg::Cfg(sym::target_feature, _))
203195
}
204196

205197
/// Attempt to simplify this cfg by assuming that `assume` is already known to be true, will

src/librustdoc/clean/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -640,10 +640,10 @@ impl Clean<Generics> for hir::Generics<'_> {
640640
///
641641
/// [`lifetime_to_generic_param`]: rustc_ast_lowering::LoweringContext::lifetime_to_generic_param
642642
fn is_elided_lifetime(param: &hir::GenericParam<'_>) -> bool {
643-
match param.kind {
644-
hir::GenericParamKind::Lifetime { kind: hir::LifetimeParamKind::Elided } => true,
645-
_ => false,
646-
}
643+
matches!(
644+
param.kind,
645+
hir::GenericParamKind::Lifetime { kind: hir::LifetimeParamKind::Elided }
646+
)
647647
}
648648

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

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

806806
if let crate::core::ImplTraitParam::ParamIndex(idx) = param {
807807
if let Some(proj) = impl_trait_proj.remove(&idx) {

src/librustdoc/clean/types.rs

+8-19
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,9 @@ impl Item {
175175
}
176176

177177
crate fn is_crate(&self) -> bool {
178-
match *self.kind {
178+
matches!(*self.kind,
179179
StrippedItem(box ModuleItem(Module { is_crate: true, .. }))
180-
| ModuleItem(Module { is_crate: true, .. }) => true,
181-
_ => false,
182-
}
180+
| ModuleItem(Module { is_crate: true, .. }))
183181
}
184182
crate fn is_mod(&self) -> bool {
185183
self.type_() == ItemType::Module
@@ -378,10 +376,7 @@ impl ItemKind {
378376
}
379377

380378
crate fn is_type_alias(&self) -> bool {
381-
match *self {
382-
ItemKind::TypedefItem(_, _) | ItemKind::AssocTypeItem(_, _) => true,
383-
_ => false,
384-
}
379+
matches!(self, ItemKind::TypedefItem(..) | ItemKind::AssocTypeItem(..))
385380
}
386381
}
387382

@@ -674,7 +669,7 @@ impl Attributes {
674669
span: attr.span,
675670
doc: contents,
676671
kind: DocFragmentKind::Include { filename },
677-
parent_module: parent_module,
672+
parent_module,
678673
});
679674
}
680675
}
@@ -750,7 +745,7 @@ impl Attributes {
750745
Some(did) => {
751746
if let Some((mut href, ..)) = href(did) {
752747
if let Some(ref fragment) = *fragment {
753-
href.push_str("#");
748+
href.push('#');
754749
href.push_str(fragment);
755750
}
756751
Some(RenderedLink {
@@ -945,10 +940,7 @@ crate enum GenericParamDefKind {
945940

946941
impl GenericParamDefKind {
947942
crate fn is_type(&self) -> bool {
948-
match *self {
949-
GenericParamDefKind::Type { .. } => true,
950-
_ => false,
951-
}
943+
matches!(self, GenericParamDefKind::Type { .. })
952944
}
953945

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

12941286
crate fn is_full_generic(&self) -> bool {
1295-
match *self {
1296-
Type::Generic(_) => true,
1297-
_ => false,
1298-
}
1287+
matches!(self, Type::Generic(_))
12991288
}
13001289

13011290
crate fn projection(&self) -> Option<(&Type, DefId, Symbol)> {
13021291
let (self_, trait_, name) = match self {
1303-
QPath { ref self_type, ref trait_, name } => (self_type, trait_, name),
1292+
QPath { self_type, trait_, name } => (self_type, trait_, name),
13041293
_ => return None,
13051294
};
13061295
let trait_did = match **trait_ {

src/librustdoc/config.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ crate enum OutputFormat {
3737

3838
impl OutputFormat {
3939
crate fn is_json(&self) -> bool {
40-
match self {
41-
OutputFormat::Json => true,
42-
_ => false,
43-
}
40+
matches!(self, OutputFormat::Json)
4441
}
4542
}
4643

src/librustdoc/doctest.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -636,15 +636,15 @@ fn partition_source(s: &str) -> (String, String, String) {
636636
match state {
637637
PartitionState::Attrs => {
638638
before.push_str(line);
639-
before.push_str("\n");
639+
before.push('\n');
640640
}
641641
PartitionState::Crates => {
642642
crates.push_str(line);
643-
crates.push_str("\n");
643+
crates.push('\n');
644644
}
645645
PartitionState::Other => {
646646
after.push_str(line);
647-
after.push_str("\n");
647+
after.push('\n');
648648
}
649649
}
650650
}

src/librustdoc/fold.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ crate trait DocFolder: Sized {
6161
j.fields = j.fields.into_iter().filter_map(|x| self.fold_item(x)).collect();
6262
j.fields_stripped |= num_fields != j.fields.len()
6363
|| j.fields.iter().any(|f| f.is_stripped());
64-
VariantItem(Variant { kind: VariantKind::Struct(j), ..i2 })
64+
VariantItem(Variant { kind: VariantKind::Struct(j) })
6565
}
6666
_ => VariantItem(i2),
6767
}

0 commit comments

Comments
 (0)