Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ef98292

Browse files
committedJan 27, 2023
Auto merge of #107372 - JohnTitor:rollup-zkl2ges, r=JohnTitor
Rollup of 9 pull requests Successful merges: - #106806 (Replace format flags u32 by enums and bools.) - #107194 (Remove dependency on slice_internals feature in rustc_ast) - #107234 (Revisit fix_is_ci_llvm_available logic) - #107316 (Update snap from `1.0.1` to `1.1.0`) - #107321 (solver comments + remove `TyCtxt::evaluate_goal`) - #107332 (Fix wording from `rustbuild` to `bootstrap`) - #107347 (reduce rightward-drift) - #107352 (compiler: Fix E0587 explanation) - #107357 (Fix infinite loop in rustdoc get_all_import_attributes function) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 7919ef0 + c64f4c4 commit ef98292

File tree

21 files changed

+255
-128
lines changed

21 files changed

+255
-128
lines changed
 

‎Cargo.lock

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3672,6 +3672,7 @@ name = "rustc_ast"
36723672
version = "0.0.0"
36733673
dependencies = [
36743674
"bitflags",
3675+
"memchr",
36753676
"rustc_data_structures",
36763677
"rustc_index",
36773678
"rustc_lexer",
@@ -5215,9 +5216,9 @@ checksum = "cc88c725d61fc6c3132893370cac4a0200e3fedf5da8331c570664b1987f5ca2"
52155216

52165217
[[package]]
52175218
name = "snap"
5218-
version = "1.0.1"
5219+
version = "1.1.0"
52195220
source = "registry+https://github.com/rust-lang/crates.io-index"
5220-
checksum = "da73c8f77aebc0e40c300b93f0a5f1bece7a248a36eee287d4e095f35c7b7d6e"
5221+
checksum = "5e9f0ab6ef7eb7353d9119c170a436d1bf248eea575ac42d19d12f4e34130831"
52215222

52225223
[[package]]
52235224
name = "snapbox"

‎compiler/rustc_ast/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ edition = "2021"
77

88
[dependencies]
99
bitflags = "1.2.1"
10+
memchr = "2.5.0"
1011
rustc_data_structures = { path = "../rustc_data_structures" }
1112
rustc_index = { path = "../rustc_index" }
1213
rustc_lexer = { path = "../rustc_lexer" }

‎compiler/rustc_ast/src/format.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,30 @@ pub struct FormatOptions {
227227
pub alignment: Option<FormatAlignment>,
228228
/// The fill character. E.g. the `.` in `{:.>10}`.
229229
pub fill: Option<char>,
230-
/// The `+`, `-`, `0`, `#`, `x?` and `X?` flags.
231-
pub flags: u32,
230+
/// The `+` or `-` flag.
231+
pub sign: Option<FormatSign>,
232+
/// The `#` flag.
233+
pub alternate: bool,
234+
/// The `0` flag. E.g. the `0` in `{:02x}`.
235+
pub zero_pad: bool,
236+
/// The `x` or `X` flag (for `Debug` only). E.g. the `x` in `{:x?}`.
237+
pub debug_hex: Option<FormatDebugHex>,
238+
}
239+
240+
#[derive(Copy, Clone, Encodable, Decodable, Debug, PartialEq, Eq)]
241+
pub enum FormatSign {
242+
/// The `+` flag.
243+
Plus,
244+
/// The `-` flag.
245+
Minus,
246+
}
247+
248+
#[derive(Copy, Clone, Encodable, Decodable, Debug, PartialEq, Eq)]
249+
pub enum FormatDebugHex {
250+
/// The `x` flag in `{:x?}`.
251+
Lower,
252+
/// The `X` flag in `{:X?}`.
253+
Upper,
232254
}
233255

234256
#[derive(Copy, Clone, Encodable, Decodable, Debug, PartialEq, Eq)]

‎compiler/rustc_ast/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#![feature(let_chains)]
1717
#![feature(min_specialization)]
1818
#![feature(negative_impls)]
19-
#![feature(slice_internals)]
2019
#![feature(stmt_expr_attributes)]
2120
#![recursion_limit = "256"]
2221
#![deny(rustc::untranslatable_diagnostic)]

‎compiler/rustc_ast/src/util/unicode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub fn contains_text_flow_control_chars(s: &str) -> bool {
1717
// U+2069 - E2 81 A9
1818
let mut bytes = s.as_bytes();
1919
loop {
20-
match core::slice::memchr::memchr(0xE2, bytes) {
20+
match memchr::memchr(0xE2, bytes) {
2121
Some(idx) => {
2222
// bytes are valid UTF-8 -> E2 must be followed by two bytes
2323
let ch = &bytes[idx..idx + 3];

‎compiler/rustc_ast_lowering/src/format.rs

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,26 +137,43 @@ fn make_format_spec<'hir>(
137137
}
138138
Err(_) => ctx.expr(sp, hir::ExprKind::Err),
139139
};
140-
let fill = ctx.expr_char(sp, placeholder.format_options.fill.unwrap_or(' '));
140+
let &FormatOptions {
141+
ref width,
142+
ref precision,
143+
alignment,
144+
fill,
145+
sign,
146+
alternate,
147+
zero_pad,
148+
debug_hex,
149+
} = &placeholder.format_options;
150+
let fill = ctx.expr_char(sp, fill.unwrap_or(' '));
141151
let align = ctx.expr_lang_item_type_relative(
142152
sp,
143153
hir::LangItem::FormatAlignment,
144-
match placeholder.format_options.alignment {
154+
match alignment {
145155
Some(FormatAlignment::Left) => sym::Left,
146156
Some(FormatAlignment::Right) => sym::Right,
147157
Some(FormatAlignment::Center) => sym::Center,
148158
None => sym::Unknown,
149159
},
150160
);
151-
let flags = ctx.expr_u32(sp, placeholder.format_options.flags);
152-
let prec = make_count(ctx, sp, &placeholder.format_options.precision, argmap);
153-
let width = make_count(ctx, sp, &placeholder.format_options.width, argmap);
161+
// This needs to match `FlagV1` in library/core/src/fmt/mod.rs.
162+
let flags: u32 = ((sign == Some(FormatSign::Plus)) as u32)
163+
| ((sign == Some(FormatSign::Minus)) as u32) << 1
164+
| (alternate as u32) << 2
165+
| (zero_pad as u32) << 3
166+
| ((debug_hex == Some(FormatDebugHex::Lower)) as u32) << 4
167+
| ((debug_hex == Some(FormatDebugHex::Upper)) as u32) << 5;
168+
let flags = ctx.expr_u32(sp, flags);
169+
let precision = make_count(ctx, sp, &precision, argmap);
170+
let width = make_count(ctx, sp, &width, argmap);
154171
let format_placeholder_new = ctx.arena.alloc(ctx.expr_lang_item_type_relative(
155172
sp,
156173
hir::LangItem::FormatPlaceholder,
157174
sym::new,
158175
));
159-
let args = ctx.arena.alloc_from_iter([position, fill, align, flags, prec, width]);
176+
let args = ctx.arena.alloc_from_iter([position, fill, align, flags, precision, width]);
160177
ctx.expr_call_mut(sp, format_placeholder_new, args)
161178
}
162179

‎compiler/rustc_ast_pretty/src/pprust/state/expr.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ use rustc_ast::token;
66
use rustc_ast::util::literal::escape_byte_str_symbol;
77
use rustc_ast::util::parser::{self, AssocOp, Fixity};
88
use rustc_ast::{self as ast, BlockCheckMode};
9-
use rustc_ast::{FormatAlignment, FormatArgPosition, FormatArgsPiece, FormatCount, FormatTrait};
9+
use rustc_ast::{
10+
FormatAlignment, FormatArgPosition, FormatArgsPiece, FormatCount, FormatDebugHex, FormatSign,
11+
FormatTrait,
12+
};
1013
use std::fmt::Write;
1114

1215
impl<'a> State<'a> {
@@ -675,17 +678,15 @@ pub fn reconstruct_format_args_template_string(pieces: &[FormatArgsPiece]) -> St
675678
Some(FormatAlignment::Center) => template.push_str("^"),
676679
None => {}
677680
}
678-
let flags = p.format_options.flags;
679-
if flags >> (rustc_parse_format::FlagSignPlus as usize) & 1 != 0 {
680-
template.push('+');
681-
}
682-
if flags >> (rustc_parse_format::FlagSignMinus as usize) & 1 != 0 {
683-
template.push('-');
681+
match p.format_options.sign {
682+
Some(FormatSign::Plus) => template.push('+'),
683+
Some(FormatSign::Minus) => template.push('-'),
684+
None => {}
684685
}
685-
if flags >> (rustc_parse_format::FlagAlternate as usize) & 1 != 0 {
686+
if p.format_options.alternate {
686687
template.push('#');
687688
}
688-
if flags >> (rustc_parse_format::FlagSignAwareZeroPad as usize) & 1 != 0 {
689+
if p.format_options.zero_pad {
689690
template.push('0');
690691
}
691692
if let Some(width) = &p.format_options.width {
@@ -709,11 +710,10 @@ pub fn reconstruct_format_args_template_string(pieces: &[FormatArgsPiece]) -> St
709710
}
710711
}
711712
}
712-
if flags >> (rustc_parse_format::FlagDebugLowerHex as usize) & 1 != 0 {
713-
template.push('x');
714-
}
715-
if flags >> (rustc_parse_format::FlagDebugUpperHex as usize) & 1 != 0 {
716-
template.push('X');
713+
match p.format_options.debug_hex {
714+
Some(FormatDebugHex::Lower) => template.push('x'),
715+
Some(FormatDebugHex::Upper) => template.push('X'),
716+
None => {}
717717
}
718718
template.push_str(match p.format_trait {
719719
FormatTrait::Display => "",

‎compiler/rustc_builtin_macros/src/format.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use rustc_ast::tokenstream::TokenStream;
44
use rustc_ast::{
55
Expr, ExprKind, FormatAlignment, FormatArgPosition, FormatArgPositionKind, FormatArgs,
66
FormatArgsPiece, FormatArgument, FormatArgumentKind, FormatArguments, FormatCount,
7-
FormatOptions, FormatPlaceholder, FormatTrait,
7+
FormatDebugHex, FormatOptions, FormatPlaceholder, FormatSign, FormatTrait,
88
};
99
use rustc_data_structures::fx::FxHashSet;
1010
use rustc_errors::{pluralize, Applicability, MultiSpan, PResult};
@@ -435,7 +435,16 @@ pub fn make_format_args(
435435
format_options: FormatOptions {
436436
fill: format.fill,
437437
alignment,
438-
flags: format.flags,
438+
sign: format.sign.map(|s| match s {
439+
parse::Sign::Plus => FormatSign::Plus,
440+
parse::Sign::Minus => FormatSign::Minus,
441+
}),
442+
alternate: format.alternate,
443+
zero_pad: format.zero_pad,
444+
debug_hex: format.debug_hex.map(|s| match s {
445+
parse::DebugHex::Lower => FormatDebugHex::Lower,
446+
parse::DebugHex::Upper => FormatDebugHex::Upper,
447+
}),
439448
precision,
440449
width,
441450
},

‎compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,8 @@ fn add_unused_functions(cx: &CodegenCx<'_, '_>) {
295295
DefKind::Fn | DefKind::AssocFn | DefKind::Closure | DefKind::Generator
296296
) {
297297
return None;
298-
} else if ignore_unused_generics
299-
&& tcx.generics_of(def_id).requires_monomorphization(tcx)
300-
{
298+
}
299+
if ignore_unused_generics && tcx.generics_of(def_id).requires_monomorphization(tcx) {
301300
return None;
302301
}
303302
Some(local_def_id.to_def_id())

‎compiler/rustc_error_codes/src/error_codes/E0587.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ You cannot use `packed` and `align` hints on a same type. If you want to pack a
1111
type to a given size, you should provide a size to packed:
1212

1313
```
14-
#[repr(packed)] // ok!
14+
#[repr(packed(8))] // ok!
1515
struct Umbrella(i32);
1616
```

‎compiler/rustc_parse_format/src/lib.rs

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
pub use Alignment::*;
1818
pub use Count::*;
19-
pub use Flag::*;
2019
pub use Piece::*;
2120
pub use Position::*;
2221

@@ -111,8 +110,14 @@ pub struct FormatSpec<'a> {
111110
pub fill: Option<char>,
112111
/// Optionally specified alignment.
113112
pub align: Alignment,
114-
/// Packed version of various flags provided.
115-
pub flags: u32,
113+
/// The `+` or `-` flag.
114+
pub sign: Option<Sign>,
115+
/// The `#` flag.
116+
pub alternate: bool,
117+
/// The `0` flag.
118+
pub zero_pad: bool,
119+
/// The `x` or `X` flag. (Only for `Debug`.)
120+
pub debug_hex: Option<DebugHex>,
116121
/// The integer precision to use.
117122
pub precision: Count<'a>,
118123
/// The span of the precision formatting flag (for diagnostics).
@@ -162,24 +167,22 @@ pub enum Alignment {
162167
AlignUnknown,
163168
}
164169

165-
/// Various flags which can be applied to format strings. The meaning of these
166-
/// flags is defined by the formatters themselves.
170+
/// Enum for the sign flags.
167171
#[derive(Copy, Clone, Debug, PartialEq)]
168-
pub enum Flag {
169-
/// A `+` will be used to denote positive numbers.
170-
FlagSignPlus,
171-
/// A `-` will be used to denote negative numbers. This is the default.
172-
FlagSignMinus,
173-
/// An alternate form will be used for the value. In the case of numbers,
174-
/// this means that the number will be prefixed with the supplied string.
175-
FlagAlternate,
176-
/// For numbers, this means that the number will be padded with zeroes,
177-
/// and the sign (`+` or `-`) will precede them.
178-
FlagSignAwareZeroPad,
179-
/// For Debug / `?`, format integers in lower-case hexadecimal.
180-
FlagDebugLowerHex,
181-
/// For Debug / `?`, format integers in upper-case hexadecimal.
182-
FlagDebugUpperHex,
172+
pub enum Sign {
173+
/// The `+` flag.
174+
Plus,
175+
/// The `-` flag.
176+
Minus,
177+
}
178+
179+
/// Enum for the debug hex flags.
180+
#[derive(Copy, Clone, Debug, PartialEq)]
181+
pub enum DebugHex {
182+
/// The `x` flag in `{:x?}`.
183+
Lower,
184+
/// The `X` flag in `{:X?}`.
185+
Upper,
183186
}
184187

185188
/// A count is used for the precision and width parameters of an integer, and
@@ -597,7 +600,10 @@ impl<'a> Parser<'a> {
597600
let mut spec = FormatSpec {
598601
fill: None,
599602
align: AlignUnknown,
600-
flags: 0,
603+
sign: None,
604+
alternate: false,
605+
zero_pad: false,
606+
debug_hex: None,
601607
precision: CountImplied,
602608
precision_span: None,
603609
width: CountImplied,
@@ -626,13 +632,13 @@ impl<'a> Parser<'a> {
626632
}
627633
// Sign flags
628634
if self.consume('+') {
629-
spec.flags |= 1 << (FlagSignPlus as u32);
635+
spec.sign = Some(Sign::Plus);
630636
} else if self.consume('-') {
631-
spec.flags |= 1 << (FlagSignMinus as u32);
637+
spec.sign = Some(Sign::Minus);
632638
}
633639
// Alternate marker
634640
if self.consume('#') {
635-
spec.flags |= 1 << (FlagAlternate as u32);
641+
spec.alternate = true;
636642
}
637643
// Width and precision
638644
let mut havewidth = false;
@@ -647,7 +653,7 @@ impl<'a> Parser<'a> {
647653
spec.width_span = Some(self.span(end - 1, end + 1));
648654
havewidth = true;
649655
} else {
650-
spec.flags |= 1 << (FlagSignAwareZeroPad as u32);
656+
spec.zero_pad = true;
651657
}
652658
}
653659

@@ -678,14 +684,14 @@ impl<'a> Parser<'a> {
678684
// Optional radix followed by the actual format specifier
679685
if self.consume('x') {
680686
if self.consume('?') {
681-
spec.flags |= 1 << (FlagDebugLowerHex as u32);
687+
spec.debug_hex = Some(DebugHex::Lower);
682688
spec.ty = "?";
683689
} else {
684690
spec.ty = "x";
685691
}
686692
} else if self.consume('X') {
687693
if self.consume('?') {
688-
spec.flags |= 1 << (FlagDebugUpperHex as u32);
694+
spec.debug_hex = Some(DebugHex::Upper);
689695
spec.ty = "?";
690696
} else {
691697
spec.ty = "X";
@@ -708,7 +714,10 @@ impl<'a> Parser<'a> {
708714
let mut spec = FormatSpec {
709715
fill: None,
710716
align: AlignUnknown,
711-
flags: 0,
717+
sign: None,
718+
alternate: false,
719+
zero_pad: false,
720+
debug_hex: None,
712721
precision: CountImplied,
713722
precision_span: None,
714723
width: CountImplied,

‎compiler/rustc_parse_format/src/tests.rs

Lines changed: 60 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ fn fmtdflt() -> FormatSpec<'static> {
1010
return FormatSpec {
1111
fill: None,
1212
align: AlignUnknown,
13-
flags: 0,
13+
sign: None,
14+
alternate: false,
15+
zero_pad: false,
16+
debug_hex: None,
1417
precision: CountImplied,
1518
width: CountImplied,
1619
precision_span: None,
@@ -126,7 +129,10 @@ fn format_type() {
126129
format: FormatSpec {
127130
fill: None,
128131
align: AlignUnknown,
129-
flags: 0,
132+
sign: None,
133+
alternate: false,
134+
zero_pad: false,
135+
debug_hex: None,
130136
precision: CountImplied,
131137
width: CountImplied,
132138
precision_span: None,
@@ -147,7 +153,10 @@ fn format_align_fill() {
147153
format: FormatSpec {
148154
fill: None,
149155
align: AlignRight,
150-
flags: 0,
156+
sign: None,
157+
alternate: false,
158+
zero_pad: false,
159+
debug_hex: None,
151160
precision: CountImplied,
152161
width: CountImplied,
153162
precision_span: None,
@@ -165,7 +174,10 @@ fn format_align_fill() {
165174
format: FormatSpec {
166175
fill: Some('0'),
167176
align: AlignLeft,
168-
flags: 0,
177+
sign: None,
178+
alternate: false,
179+
zero_pad: false,
180+
debug_hex: None,
169181
precision: CountImplied,
170182
width: CountImplied,
171183
precision_span: None,
@@ -183,7 +195,10 @@ fn format_align_fill() {
183195
format: FormatSpec {
184196
fill: Some('*'),
185197
align: AlignLeft,
186-
flags: 0,
198+
sign: None,
199+
alternate: false,
200+
zero_pad: false,
201+
debug_hex: None,
187202
precision: CountImplied,
188203
width: CountImplied,
189204
precision_span: None,
@@ -204,7 +219,10 @@ fn format_counts() {
204219
format: FormatSpec {
205220
fill: None,
206221
align: AlignUnknown,
207-
flags: 0,
222+
sign: None,
223+
alternate: false,
224+
zero_pad: false,
225+
debug_hex: None,
208226
precision: CountImplied,
209227
precision_span: None,
210228
width: CountIs(10),
@@ -222,7 +240,10 @@ fn format_counts() {
222240
format: FormatSpec {
223241
fill: None,
224242
align: AlignUnknown,
225-
flags: 0,
243+
sign: None,
244+
alternate: false,
245+
zero_pad: false,
246+
debug_hex: None,
226247
precision: CountIs(10),
227248
precision_span: Some(InnerSpan { start: 6, end: 9 }),
228249
width: CountIsParam(10),
@@ -240,7 +261,10 @@ fn format_counts() {
240261
format: FormatSpec {
241262
fill: None,
242263
align: AlignUnknown,
243-
flags: 0,
264+
sign: None,
265+
alternate: false,
266+
zero_pad: false,
267+
debug_hex: None,
244268
precision: CountIs(10),
245269
precision_span: Some(InnerSpan { start: 6, end: 9 }),
246270
width: CountIsParam(0),
@@ -258,7 +282,10 @@ fn format_counts() {
258282
format: FormatSpec {
259283
fill: None,
260284
align: AlignUnknown,
261-
flags: 0,
285+
sign: None,
286+
alternate: false,
287+
zero_pad: false,
288+
debug_hex: None,
262289
precision: CountIsStar(0),
263290
precision_span: Some(InnerSpan { start: 3, end: 5 }),
264291
width: CountImplied,
@@ -276,7 +303,10 @@ fn format_counts() {
276303
format: FormatSpec {
277304
fill: None,
278305
align: AlignUnknown,
279-
flags: 0,
306+
sign: None,
307+
alternate: false,
308+
zero_pad: false,
309+
debug_hex: None,
280310
precision: CountIsParam(10),
281311
width: CountImplied,
282312
precision_span: Some(InnerSpan::new(3, 7)),
@@ -294,7 +324,10 @@ fn format_counts() {
294324
format: FormatSpec {
295325
fill: None,
296326
align: AlignUnknown,
297-
flags: 0,
327+
sign: None,
328+
alternate: false,
329+
zero_pad: false,
330+
debug_hex: None,
298331
precision: CountIsName("b", InnerSpan { start: 6, end: 7 }),
299332
precision_span: Some(InnerSpan { start: 5, end: 8 }),
300333
width: CountIsName("a", InnerSpan { start: 3, end: 4 }),
@@ -312,7 +345,10 @@ fn format_counts() {
312345
format: FormatSpec {
313346
fill: None,
314347
align: AlignUnknown,
315-
flags: 0,
348+
sign: None,
349+
alternate: false,
350+
zero_pad: false,
351+
debug_hex: None,
316352
precision: CountIs(4),
317353
precision_span: Some(InnerSpan { start: 3, end: 5 }),
318354
width: CountImplied,
@@ -333,7 +369,10 @@ fn format_flags() {
333369
format: FormatSpec {
334370
fill: None,
335371
align: AlignUnknown,
336-
flags: (1 << FlagSignMinus as u32),
372+
sign: Some(Sign::Minus),
373+
alternate: false,
374+
zero_pad: false,
375+
debug_hex: None,
337376
precision: CountImplied,
338377
width: CountImplied,
339378
precision_span: None,
@@ -351,7 +390,10 @@ fn format_flags() {
351390
format: FormatSpec {
352391
fill: None,
353392
align: AlignUnknown,
354-
flags: (1 << FlagSignPlus as u32) | (1 << FlagAlternate as u32),
393+
sign: Some(Sign::Plus),
394+
alternate: true,
395+
zero_pad: false,
396+
debug_hex: None,
355397
precision: CountImplied,
356398
width: CountImplied,
357399
precision_span: None,
@@ -374,7 +416,10 @@ fn format_mixture() {
374416
format: FormatSpec {
375417
fill: None,
376418
align: AlignUnknown,
377-
flags: 0,
419+
sign: None,
420+
alternate: false,
421+
zero_pad: false,
422+
debug_hex: None,
378423
precision: CountImplied,
379424
width: CountImplied,
380425
precision_span: None,

‎compiler/rustc_trait_selection/src/solve/mod.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,6 @@ type CanonicalResponse<'tcx> = Canonical<'tcx, Response<'tcx>>;
141141
/// solver, merge the two responses again.
142142
pub type QueryResult<'tcx> = Result<CanonicalResponse<'tcx>, NoSolution>;
143143

144-
pub trait TyCtxtExt<'tcx> {
145-
fn evaluate_goal(self, goal: CanonicalGoal<'tcx>) -> QueryResult<'tcx>;
146-
}
147-
148-
impl<'tcx> TyCtxtExt<'tcx> for TyCtxt<'tcx> {
149-
fn evaluate_goal(self, goal: CanonicalGoal<'tcx>) -> QueryResult<'tcx> {
150-
let mut search_graph = search_graph::SearchGraph::new(self);
151-
EvalCtxt::evaluate_canonical_goal(self, &mut search_graph, goal)
152-
}
153-
}
154-
155144
pub trait InferCtxtEvalExt<'tcx> {
156145
/// Evaluates a goal from **outside** of the trait solver.
157146
///
@@ -194,6 +183,15 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
194183
self.infcx.tcx
195184
}
196185

186+
/// The entry point of the solver.
187+
///
188+
/// This function deals with (coinductive) cycles, overflow, and caching
189+
/// and then calls [`EvalCtxt::compute_goal`] which contains the actual
190+
/// logic of the solver.
191+
///
192+
/// Instead of calling this function directly, use either [EvalCtxt::evaluate_goal]
193+
/// if you're inside of the solver or [InferCtxtEvalExt::evaluate_root_goal] if you're
194+
/// outside of it.
197195
#[instrument(level = "debug", skip(tcx, search_graph), ret)]
198196
fn evaluate_canonical_goal(
199197
tcx: TyCtxt<'tcx>,

‎compiler/rustc_trait_selection/src/solve/project_goals.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
2828
// To only compute normalization once for each projection we only
2929
// normalize if the expected term is an unconstrained inference variable.
3030
//
31-
// E.g. for `<T as Trait>::Assoc = u32` we recursively compute the goal
32-
// `exists<U> <T as Trait>::Assoc = U` and then take the resulting type for
31+
// E.g. for `<T as Trait>::Assoc == u32` we recursively compute the goal
32+
// `exists<U> <T as Trait>::Assoc == U` and then take the resulting type for
3333
// `U` and equate it with `u32`. This means that we don't need a separate
3434
// projection cache in the solver.
3535
if self.term_is_fully_unconstrained(goal) {

‎src/bootstrap/bootstrap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ def bootstrap_binary(self):
712712

713713
def build_bootstrap(self, color):
714714
"""Build bootstrap"""
715-
print("Building rustbuild")
715+
print("Building bootstrap")
716716
build_dir = os.path.join(self.build_dir, "bootstrap")
717717
if self.clean and os.path.exists(build_dir):
718718
shutil.rmtree(build_dir)

‎src/bootstrap/config.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,9 @@ impl Config {
965965
config.changelog_seen = toml.changelog_seen;
966966

967967
let build = toml.build.unwrap_or_default();
968+
if let Some(file_build) = build.build {
969+
config.build = TargetSelection::from_user(&file_build);
970+
};
968971

969972
set(&mut config.out, flags.build_dir.or_else(|| build.build_dir.map(PathBuf::from)));
970973
// NOTE: Bootstrap spawns various commands with different working directories.

‎src/bootstrap/config/tests.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ fn download_ci_llvm() {
1919
assert_eq!(parse_llvm(""), if_available);
2020
assert_eq!(parse_llvm("rust.channel = \"dev\""), if_available);
2121
assert!(!parse_llvm("rust.channel = \"stable\""));
22+
assert!(parse_llvm("build.build = \"x86_64-unknown-linux-gnu\""));
23+
assert!(parse_llvm(
24+
"llvm.assertions = true \r\n build.build = \"x86_64-unknown-linux-gnu\" \r\n llvm.download-ci-llvm = \"if-available\""
25+
));
26+
assert!(!parse_llvm(
27+
"llvm.assertions = true \r\n build.build = \"aarch64-apple-darwin\" \r\n llvm.download-ci-llvm = \"if-available\""
28+
));
2229
}
2330

2431
// FIXME: add test for detecting `src` and `out`

‎src/bootstrap/native.rs

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -180,43 +180,40 @@ pub(crate) fn is_ci_llvm_available(config: &Config, asserts: bool) -> bool {
180180
// https://doc.rust-lang.org/rustc/platform-support.html#tier-1
181181
let supported_platforms = [
182182
// tier 1
183-
"aarch64-unknown-linux-gnu",
184-
"i686-pc-windows-gnu",
185-
"i686-pc-windows-msvc",
186-
"i686-unknown-linux-gnu",
187-
"x86_64-unknown-linux-gnu",
188-
"x86_64-apple-darwin",
189-
"x86_64-pc-windows-gnu",
190-
"x86_64-pc-windows-msvc",
183+
("aarch64-unknown-linux-gnu", false),
184+
("i686-pc-windows-gnu", false),
185+
("i686-pc-windows-msvc", false),
186+
("i686-unknown-linux-gnu", false),
187+
("x86_64-unknown-linux-gnu", true),
188+
("x86_64-apple-darwin", true),
189+
("x86_64-pc-windows-gnu", true),
190+
("x86_64-pc-windows-msvc", true),
191191
// tier 2 with host tools
192-
"aarch64-apple-darwin",
193-
"aarch64-pc-windows-msvc",
194-
"aarch64-unknown-linux-musl",
195-
"arm-unknown-linux-gnueabi",
196-
"arm-unknown-linux-gnueabihf",
197-
"armv7-unknown-linux-gnueabihf",
198-
"mips-unknown-linux-gnu",
199-
"mips64-unknown-linux-gnuabi64",
200-
"mips64el-unknown-linux-gnuabi64",
201-
"mipsel-unknown-linux-gnu",
202-
"powerpc-unknown-linux-gnu",
203-
"powerpc64-unknown-linux-gnu",
204-
"powerpc64le-unknown-linux-gnu",
205-
"riscv64gc-unknown-linux-gnu",
206-
"s390x-unknown-linux-gnu",
207-
"x86_64-unknown-freebsd",
208-
"x86_64-unknown-illumos",
209-
"x86_64-unknown-linux-musl",
210-
"x86_64-unknown-netbsd",
192+
("aarch64-apple-darwin", false),
193+
("aarch64-pc-windows-msvc", false),
194+
("aarch64-unknown-linux-musl", false),
195+
("arm-unknown-linux-gnueabi", false),
196+
("arm-unknown-linux-gnueabihf", false),
197+
("armv7-unknown-linux-gnueabihf", false),
198+
("mips-unknown-linux-gnu", false),
199+
("mips64-unknown-linux-gnuabi64", false),
200+
("mips64el-unknown-linux-gnuabi64", false),
201+
("mipsel-unknown-linux-gnu", false),
202+
("powerpc-unknown-linux-gnu", false),
203+
("powerpc64-unknown-linux-gnu", false),
204+
("powerpc64le-unknown-linux-gnu", false),
205+
("riscv64gc-unknown-linux-gnu", false),
206+
("s390x-unknown-linux-gnu", false),
207+
("x86_64-unknown-freebsd", false),
208+
("x86_64-unknown-illumos", false),
209+
("x86_64-unknown-linux-musl", false),
210+
("x86_64-unknown-netbsd", false),
211211
];
212-
if !supported_platforms.contains(&&*config.build.triple) {
213-
return false;
214-
}
215212

216-
let triple = &*config.build.triple;
217-
if (triple == "aarch64-unknown-linux-gnu" || triple.contains("i686")) && asserts {
218-
// No alt builder for aarch64-unknown-linux-gnu today.
219-
return false;
213+
if !supported_platforms.contains(&(&*config.build.triple, asserts)) {
214+
if asserts == true || !supported_platforms.contains(&(&*config.build.triple, true)) {
215+
return false;
216+
}
220217
}
221218

222219
if CiEnv::is_ci() {

‎src/librustdoc/clean/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2112,10 +2112,12 @@ fn get_all_import_attributes<'hir>(
21122112
) {
21132113
let hir_map = tcx.hir();
21142114
let mut visitor = OneLevelVisitor::new(hir_map, target_def_id);
2115+
let mut visited = FxHashSet::default();
21152116
// If the item is an import and has at least a path with two parts, we go into it.
21162117
while let hir::ItemKind::Use(path, _) = item.kind &&
21172118
path.segments.len() > 1 &&
2118-
let hir::def::Res::Def(_, def_id) = path.segments[path.segments.len() - 2].res
2119+
let hir::def::Res::Def(_, def_id) = path.segments[path.segments.len() - 2].res &&
2120+
visited.insert(def_id)
21192121
{
21202122
if let Some(hir::Node::Item(parent_item)) = hir_map.get_if_local(def_id) {
21212123
// We add the attributes from this import into the list.

‎src/tools/clippy/clippy_utils/src/macros.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -711,8 +711,8 @@ pub struct FormatSpec<'tcx> {
711711
pub fill: Option<char>,
712712
/// Optionally specified alignment.
713713
pub align: Alignment,
714-
/// Packed version of various flags provided, see [`rustc_parse_format::Flag`].
715-
pub flags: u32,
714+
/// Whether all flag options are set to default (no flags specified).
715+
pub no_flags: bool,
716716
/// Represents either the maximum width or the integer precision.
717717
pub precision: Count<'tcx>,
718718
/// The minimum width, will be padded according to `width`/`align`
@@ -728,7 +728,7 @@ impl<'tcx> FormatSpec<'tcx> {
728728
Some(Self {
729729
fill: spec.fill,
730730
align: spec.align,
731-
flags: spec.flags,
731+
no_flags: spec.sign.is_none() && !spec.alternate && !spec.zero_pad && spec.debug_hex.is_none(),
732732
precision: Count::new(
733733
FormatParamUsage::Precision,
734734
spec.precision,
@@ -773,7 +773,7 @@ impl<'tcx> FormatSpec<'tcx> {
773773
self.width.is_implied()
774774
&& self.precision.is_implied()
775775
&& self.align == Alignment::AlignUnknown
776-
&& self.flags == 0
776+
&& self.no_flags
777777
}
778778
}
779779

‎tests/rustdoc/issue-107350.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// This is a regression test for <https://github.com/rust-lang/rust/issues/107350>.
2+
// It shouldn't loop indefinitely.
3+
4+
#![crate_name = "foo"]
5+
6+
// @has 'foo/oops/enum.OhNo.html'
7+
8+
pub mod oops {
9+
pub use crate::oops::OhNo;
10+
11+
mod inner {
12+
pub enum OhNo {
13+
Item = 1,
14+
}
15+
}
16+
17+
pub use self::inner::*;
18+
}

0 commit comments

Comments
 (0)
Please sign in to comment.