Skip to content

Commit ad8e1dc

Browse files
committed
Auto merge of rust-lang#107536 - GuillaumeGomez:rollup-xv7dx2h, r=GuillaumeGomez
Rollup of 12 pull requests Successful merges: - rust-lang#106898 (Include both md and yaml ICE ticket templates) - rust-lang#107331 (Clean up eslint annotations and remove unused JS function) - rust-lang#107348 (small refactor to new projection code) - rust-lang#107354 (rustdoc: update Source Serif 4 from 4.004 to 4.005) - rust-lang#107412 (avoid needless checks) - rust-lang#107467 (Improve enum checks) - rust-lang#107486 (Track bound types like bound regions) - rust-lang#107491 (rustdoc: remove unused CSS from `.setting-check`) - rust-lang#107508 (`Edition` micro refactor) - rust-lang#107525 (PointeeInfo is advisory only) - rust-lang#107527 (rustdoc: stop making unstable items transparent) - rust-lang#107535 (Replace unwrap with ? in TcpListener doc) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 5b6ed25 + adc3f8a commit ad8e1dc

File tree

71 files changed

+522
-407
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+522
-407
lines changed

.github/ISSUE_TEMPLATE/ice.md

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
name: Internal Compiler Error
3+
about: Create a report for an internal compiler error in rustc.
4+
labels: C-bug, I-ICE, T-compiler
5+
---
6+
<!--
7+
Thank you for finding an Internal Compiler Error! 🧊 If possible, try to provide
8+
a minimal verifiable example. You can read "Rust Bug Minimization Patterns" for
9+
how to create smaller examples.
10+
http://blog.pnkfx.org/blog/2019/11/18/rust-bug-minimization-patterns/
11+
-->
12+
13+
### Code
14+
15+
```Rust
16+
<code>
17+
```
18+
19+
20+
### Meta
21+
<!--
22+
If you're using the stable version of the compiler, you should also check if the
23+
bug also exists in the beta or nightly versions.
24+
-->
25+
26+
`rustc --version --verbose`:
27+
```
28+
<version>
29+
```
30+
31+
### Error output
32+
33+
```
34+
<output>
35+
```
36+
37+
<!--
38+
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
39+
environment. E.g. `RUST_BACKTRACE=1 cargo build`.
40+
-->
41+
<details><summary><strong>Backtrace</strong></summary>
42+
<p>
43+
44+
```
45+
<backtrace>
46+
```
47+
48+
</p>
49+
</details>

.github/ISSUE_TEMPLATE/ice.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
name: Internal Compiler Error
2-
description: Create a report for an internal compiler error in `rustc`
1+
name: Internal Compiler Error (Structured form)
2+
description: For now, you'll want to use the other ICE template, as GitHub forms have strict limits on the size of fields so backtraces cannot be pasted directly.
33
labels: ["C-bug", "I-ICE", "T-compiler"]
44
title: "[ICE]: "
55
body:
@@ -79,4 +79,4 @@ body:
7979
label: Anything else?
8080
description: If you have more details you want to give us to reproduce this issue, please add it here
8181
validations:
82-
required: false
82+
required: false

compiler/rustc_abi/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1456,6 +1456,8 @@ pub enum PointerKind {
14561456
UniqueOwned,
14571457
}
14581458

1459+
/// Note that this information is advisory only, and backends are free to ignore it.
1460+
/// It can only be used to encode potential optimizations, but no critical information.
14591461
#[derive(Copy, Clone, Debug)]
14601462
pub struct PointeeInfo {
14611463
pub size: Size,

compiler/rustc_ast/src/util/comments.rs

+17-16
Original file line numberDiff line numberDiff line change
@@ -58,23 +58,24 @@ pub fn beautify_doc_string(data: Symbol, kind: CommentKind) -> Symbol {
5858
// In case we have doc comments like `/**` or `/*!`, we want to remove stars if they are
5959
// present. However, we first need to strip the empty lines so they don't get in the middle
6060
// when we try to compute the "horizontal trim".
61-
let lines = if kind == CommentKind::Block {
62-
// Whatever happens, we skip the first line.
63-
let mut i = lines
64-
.get(0)
65-
.map(|l| if l.trim_start().starts_with('*') { 0 } else { 1 })
66-
.unwrap_or(0);
67-
let mut j = lines.len();
68-
69-
while i < j && lines[i].trim().is_empty() {
70-
i += 1;
71-
}
72-
while j > i && lines[j - 1].trim().is_empty() {
73-
j -= 1;
61+
let lines = match kind {
62+
CommentKind::Block => {
63+
// Whatever happens, we skip the first line.
64+
let mut i = lines
65+
.get(0)
66+
.map(|l| if l.trim_start().starts_with('*') { 0 } else { 1 })
67+
.unwrap_or(0);
68+
let mut j = lines.len();
69+
70+
while i < j && lines[i].trim().is_empty() {
71+
i += 1;
72+
}
73+
while j > i && lines[j - 1].trim().is_empty() {
74+
j -= 1;
75+
}
76+
&lines[i..j]
7477
}
75-
&lines[i..j]
76-
} else {
77-
lines
78+
CommentKind::Line => lines,
7879
};
7980

8081
for line in lines {

compiler/rustc_ast_pretty/src/pprust/state.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ pub fn print_crate<'a>(
131131

132132
// Currently, in Rust 2018 we don't have `extern crate std;` at the crate
133133
// root, so this is not needed, and actually breaks things.
134-
if edition == Edition::Edition2015 {
134+
if edition.rust_2015() {
135135
// `#![no_std]`
136136
let fake_attr = attr::mk_attr_word(g, ast::AttrStyle::Inner, sym::no_std, DUMMY_SP);
137137
s.print_attribute(&fake_attr);

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
344344
} else {
345345
err.span_help(source_info.span, "try removing `&mut` here");
346346
}
347-
} else if decl.mutability == Mutability::Not {
347+
} else if decl.mutability.is_not() {
348348
if matches!(
349349
decl.local_info,
350350
Some(box LocalInfo::User(ClearCrossCrate::Set(BindingForm::ImplicitSelf(

compiler/rustc_borrowck/src/type_check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2028,7 +2028,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
20282028
}
20292029
};
20302030

2031-
if ty_to_mut == Mutability::Mut && ty_mut == Mutability::Not {
2031+
if ty_to_mut.is_mut() && ty_mut.is_not() {
20322032
span_mirbug!(
20332033
self,
20342034
rvalue,

compiler/rustc_codegen_llvm/src/context.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -150,17 +150,14 @@ pub unsafe fn create_module<'ll>(
150150
target_data_layout =
151151
"e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:32-n8:16:32-a:0:32-S32"
152152
.to_string();
153-
}
154-
if sess.target.arch == "wasm32" {
153+
} else if sess.target.arch == "wasm32" {
155154
target_data_layout = target_data_layout.replace("-p10:8:8-p20:8:8", "");
156155
}
157156
}
158157
if llvm_version < (16, 0, 0) {
159158
if sess.target.arch == "s390x" {
160159
target_data_layout = target_data_layout.replace("-v128:64", "");
161-
}
162-
163-
if sess.target.arch == "riscv64" {
160+
} else if sess.target.arch == "riscv64" {
164161
target_data_layout = target_data_layout.replace("-n32:64-", "-n64-");
165162
}
166163
}

compiler/rustc_const_eval/src/const_eval/machine.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -622,10 +622,9 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
622622
let alloc = alloc.inner();
623623
if is_write {
624624
// Write access. These are never allowed, but we give a targeted error message.
625-
if alloc.mutability == Mutability::Not {
626-
Err(err_ub!(WriteToReadOnly(alloc_id)).into())
627-
} else {
628-
Err(ConstEvalErrKind::ModifiedGlobal.into())
625+
match alloc.mutability {
626+
Mutability::Not => Err(err_ub!(WriteToReadOnly(alloc_id)).into()),
627+
Mutability::Mut => Err(ConstEvalErrKind::ModifiedGlobal.into()),
629628
}
630629
} else {
631630
// Read access. These are usually allowed, with some exceptions.

compiler/rustc_const_eval/src/interpret/memory.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
304304
.into());
305305
};
306306

307-
if alloc.mutability == Mutability::Not {
307+
if alloc.mutability.is_not() {
308308
throw_ub_format!("deallocating immutable allocation {alloc_id:?}");
309309
}
310310
if alloc_kind != kind {
@@ -631,7 +631,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
631631
}
632632

633633
let (_kind, alloc) = self.memory.alloc_map.get_mut(id).unwrap();
634-
if alloc.mutability == Mutability::Not {
634+
if alloc.mutability.is_not() {
635635
throw_ub!(WriteToReadOnly(id))
636636
}
637637
Ok((alloc, &mut self.machine))

compiler/rustc_const_eval/src/transform/validate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
754754
// FIXME(JakobDegen) The validator should check that `self.mir_phase <
755755
// DropsLowered`. However, this causes ICEs with generation of drop shims, which
756756
// seem to fail to set their `MirPhase` correctly.
757-
if *kind == RetagKind::Raw || *kind == RetagKind::TwoPhase {
757+
if matches!(kind, RetagKind::Raw | RetagKind::TwoPhase) {
758758
self.fail(location, format!("explicit `{:?}` is forbidden", kind));
759759
}
760760
}

compiler/rustc_errors/src/emitter.rs

+31-23
Original file line numberDiff line numberDiff line change
@@ -2113,30 +2113,38 @@ impl EmitterWriter {
21132113
}
21142114
}
21152115
for sugg in suggestions {
2116-
if sugg.style == SuggestionStyle::CompletelyHidden {
2117-
// do not display this suggestion, it is meant only for tools
2118-
} else if sugg.style == SuggestionStyle::HideCodeAlways {
2119-
if let Err(e) = self.emit_message_default(
2120-
&MultiSpan::new(),
2121-
&[(sugg.msg.to_owned(), Style::HeaderMsg)],
2122-
args,
2123-
&None,
2124-
&Level::Help,
2125-
max_line_num_len,
2126-
true,
2127-
None,
2128-
) {
2129-
panic!("failed to emit error: {}", e);
2116+
match sugg.style {
2117+
SuggestionStyle::CompletelyHidden => {
2118+
// do not display this suggestion, it is meant only for tools
21302119
}
2131-
} else if let Err(e) = self.emit_suggestion_default(
2132-
span,
2133-
sugg,
2134-
args,
2135-
&Level::Help,
2136-
max_line_num_len,
2137-
) {
2138-
panic!("failed to emit error: {}", e);
2139-
};
2120+
SuggestionStyle::HideCodeAlways => {
2121+
if let Err(e) = self.emit_message_default(
2122+
&MultiSpan::new(),
2123+
&[(sugg.msg.to_owned(), Style::HeaderMsg)],
2124+
args,
2125+
&None,
2126+
&Level::Help,
2127+
max_line_num_len,
2128+
true,
2129+
None,
2130+
) {
2131+
panic!("failed to emit error: {}", e);
2132+
}
2133+
}
2134+
SuggestionStyle::HideCodeInline
2135+
| SuggestionStyle::ShowCode
2136+
| SuggestionStyle::ShowAlways => {
2137+
if let Err(e) = self.emit_suggestion_default(
2138+
span,
2139+
sugg,
2140+
args,
2141+
&Level::Help,
2142+
max_line_num_len,
2143+
) {
2144+
panic!("failed to emit error: {}", e);
2145+
}
2146+
}
2147+
}
21402148
}
21412149
}
21422150
}

compiler/rustc_errors/src/styled_buffer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl StyledBuffer {
142142
pub fn set_style(&mut self, line: usize, col: usize, style: Style, overwrite: bool) {
143143
if let Some(ref mut line) = self.lines.get_mut(line) {
144144
if let Some(StyledChar { style: s, .. }) = line.get_mut(col) {
145-
if overwrite || *s == Style::NoStyle || *s == Style::Quotation {
145+
if overwrite || matches!(s, Style::NoStyle | Style::Quotation) {
146146
*s = style;
147147
}
148148
}

compiler/rustc_expand/src/mbe/macro_parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ impl TtParser {
503503
mp.push_match(metavar_idx, seq_depth, MatchedSeq(vec![]));
504504
}
505505

506-
if op == KleeneOp::ZeroOrMore || op == KleeneOp::ZeroOrOne {
506+
if matches!(op, KleeneOp::ZeroOrMore | KleeneOp::ZeroOrOne) {
507507
// Try zero matches of this sequence, by skipping over it.
508508
self.cur_mps.push(MatcherPos {
509509
idx: idx_first_after,

compiler/rustc_hir_analysis/src/astconv/generics.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,9 @@ pub fn check_generic_arg_count_for_call(
385385
) -> GenericArgCountResult {
386386
let empty_args = hir::GenericArgs::none();
387387
let gen_args = seg.args.unwrap_or(&empty_args);
388-
let gen_pos = if is_method_call == IsMethodCall::Yes {
389-
GenericArgPosition::MethodCall
390-
} else {
391-
GenericArgPosition::Value
388+
let gen_pos = match is_method_call {
389+
IsMethodCall::Yes => GenericArgPosition::MethodCall,
390+
IsMethodCall::No => GenericArgPosition::Value,
392391
};
393392
let has_self = generics.parent.is_none() && generics.has_self;
394393

0 commit comments

Comments
 (0)