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
This commit is contained in:
bors 2023-01-27 17:49:56 +00:00
commit ef982929c0
21 changed files with 255 additions and 128 deletions

View File

@ -3672,6 +3672,7 @@ name = "rustc_ast"
version = "0.0.0" version = "0.0.0"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"memchr",
"rustc_data_structures", "rustc_data_structures",
"rustc_index", "rustc_index",
"rustc_lexer", "rustc_lexer",
@ -5215,9 +5216,9 @@ checksum = "cc88c725d61fc6c3132893370cac4a0200e3fedf5da8331c570664b1987f5ca2"
[[package]] [[package]]
name = "snap" name = "snap"
version = "1.0.1" version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da73c8f77aebc0e40c300b93f0a5f1bece7a248a36eee287d4e095f35c7b7d6e" checksum = "5e9f0ab6ef7eb7353d9119c170a436d1bf248eea575ac42d19d12f4e34130831"
[[package]] [[package]]
name = "snapbox" name = "snapbox"

View File

@ -7,6 +7,7 @@ edition = "2021"
[dependencies] [dependencies]
bitflags = "1.2.1" bitflags = "1.2.1"
memchr = "2.5.0"
rustc_data_structures = { path = "../rustc_data_structures" } rustc_data_structures = { path = "../rustc_data_structures" }
rustc_index = { path = "../rustc_index" } rustc_index = { path = "../rustc_index" }
rustc_lexer = { path = "../rustc_lexer" } rustc_lexer = { path = "../rustc_lexer" }

View File

@ -227,8 +227,30 @@ pub struct FormatOptions {
pub alignment: Option<FormatAlignment>, pub alignment: Option<FormatAlignment>,
/// The fill character. E.g. the `.` in `{:.>10}`. /// The fill character. E.g. the `.` in `{:.>10}`.
pub fill: Option<char>, pub fill: Option<char>,
/// The `+`, `-`, `0`, `#`, `x?` and `X?` flags. /// The `+` or `-` flag.
pub flags: u32, pub sign: Option<FormatSign>,
/// The `#` flag.
pub alternate: bool,
/// The `0` flag. E.g. the `0` in `{:02x}`.
pub zero_pad: bool,
/// The `x` or `X` flag (for `Debug` only). E.g. the `x` in `{:x?}`.
pub debug_hex: Option<FormatDebugHex>,
}
#[derive(Copy, Clone, Encodable, Decodable, Debug, PartialEq, Eq)]
pub enum FormatSign {
/// The `+` flag.
Plus,
/// The `-` flag.
Minus,
}
#[derive(Copy, Clone, Encodable, Decodable, Debug, PartialEq, Eq)]
pub enum FormatDebugHex {
/// The `x` flag in `{:x?}`.
Lower,
/// The `X` flag in `{:X?}`.
Upper,
} }
#[derive(Copy, Clone, Encodable, Decodable, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Encodable, Decodable, Debug, PartialEq, Eq)]

View File

@ -16,7 +16,6 @@
#![feature(let_chains)] #![feature(let_chains)]
#![feature(min_specialization)] #![feature(min_specialization)]
#![feature(negative_impls)] #![feature(negative_impls)]
#![feature(slice_internals)]
#![feature(stmt_expr_attributes)] #![feature(stmt_expr_attributes)]
#![recursion_limit = "256"] #![recursion_limit = "256"]
#![deny(rustc::untranslatable_diagnostic)] #![deny(rustc::untranslatable_diagnostic)]

View File

@ -17,7 +17,7 @@ pub fn contains_text_flow_control_chars(s: &str) -> bool {
// U+2069 - E2 81 A9 // U+2069 - E2 81 A9
let mut bytes = s.as_bytes(); let mut bytes = s.as_bytes();
loop { loop {
match core::slice::memchr::memchr(0xE2, bytes) { match memchr::memchr(0xE2, bytes) {
Some(idx) => { Some(idx) => {
// bytes are valid UTF-8 -> E2 must be followed by two bytes // bytes are valid UTF-8 -> E2 must be followed by two bytes
let ch = &bytes[idx..idx + 3]; let ch = &bytes[idx..idx + 3];

View File

@ -137,26 +137,43 @@ fn make_format_spec<'hir>(
} }
Err(_) => ctx.expr(sp, hir::ExprKind::Err), Err(_) => ctx.expr(sp, hir::ExprKind::Err),
}; };
let fill = ctx.expr_char(sp, placeholder.format_options.fill.unwrap_or(' ')); let &FormatOptions {
ref width,
ref precision,
alignment,
fill,
sign,
alternate,
zero_pad,
debug_hex,
} = &placeholder.format_options;
let fill = ctx.expr_char(sp, fill.unwrap_or(' '));
let align = ctx.expr_lang_item_type_relative( let align = ctx.expr_lang_item_type_relative(
sp, sp,
hir::LangItem::FormatAlignment, hir::LangItem::FormatAlignment,
match placeholder.format_options.alignment { match alignment {
Some(FormatAlignment::Left) => sym::Left, Some(FormatAlignment::Left) => sym::Left,
Some(FormatAlignment::Right) => sym::Right, Some(FormatAlignment::Right) => sym::Right,
Some(FormatAlignment::Center) => sym::Center, Some(FormatAlignment::Center) => sym::Center,
None => sym::Unknown, None => sym::Unknown,
}, },
); );
let flags = ctx.expr_u32(sp, placeholder.format_options.flags); // This needs to match `FlagV1` in library/core/src/fmt/mod.rs.
let prec = make_count(ctx, sp, &placeholder.format_options.precision, argmap); let flags: u32 = ((sign == Some(FormatSign::Plus)) as u32)
let width = make_count(ctx, sp, &placeholder.format_options.width, argmap); | ((sign == Some(FormatSign::Minus)) as u32) << 1
| (alternate as u32) << 2
| (zero_pad as u32) << 3
| ((debug_hex == Some(FormatDebugHex::Lower)) as u32) << 4
| ((debug_hex == Some(FormatDebugHex::Upper)) as u32) << 5;
let flags = ctx.expr_u32(sp, flags);
let precision = make_count(ctx, sp, &precision, argmap);
let width = make_count(ctx, sp, &width, argmap);
let format_placeholder_new = ctx.arena.alloc(ctx.expr_lang_item_type_relative( let format_placeholder_new = ctx.arena.alloc(ctx.expr_lang_item_type_relative(
sp, sp,
hir::LangItem::FormatPlaceholder, hir::LangItem::FormatPlaceholder,
sym::new, sym::new,
)); ));
let args = ctx.arena.alloc_from_iter([position, fill, align, flags, prec, width]); let args = ctx.arena.alloc_from_iter([position, fill, align, flags, precision, width]);
ctx.expr_call_mut(sp, format_placeholder_new, args) ctx.expr_call_mut(sp, format_placeholder_new, args)
} }

View File

@ -6,7 +6,10 @@ use rustc_ast::token;
use rustc_ast::util::literal::escape_byte_str_symbol; use rustc_ast::util::literal::escape_byte_str_symbol;
use rustc_ast::util::parser::{self, AssocOp, Fixity}; use rustc_ast::util::parser::{self, AssocOp, Fixity};
use rustc_ast::{self as ast, BlockCheckMode}; use rustc_ast::{self as ast, BlockCheckMode};
use rustc_ast::{FormatAlignment, FormatArgPosition, FormatArgsPiece, FormatCount, FormatTrait}; use rustc_ast::{
FormatAlignment, FormatArgPosition, FormatArgsPiece, FormatCount, FormatDebugHex, FormatSign,
FormatTrait,
};
use std::fmt::Write; use std::fmt::Write;
impl<'a> State<'a> { impl<'a> State<'a> {
@ -675,17 +678,15 @@ pub fn reconstruct_format_args_template_string(pieces: &[FormatArgsPiece]) -> St
Some(FormatAlignment::Center) => template.push_str("^"), Some(FormatAlignment::Center) => template.push_str("^"),
None => {} None => {}
} }
let flags = p.format_options.flags; match p.format_options.sign {
if flags >> (rustc_parse_format::FlagSignPlus as usize) & 1 != 0 { Some(FormatSign::Plus) => template.push('+'),
template.push('+'); Some(FormatSign::Minus) => template.push('-'),
None => {}
} }
if flags >> (rustc_parse_format::FlagSignMinus as usize) & 1 != 0 { if p.format_options.alternate {
template.push('-');
}
if flags >> (rustc_parse_format::FlagAlternate as usize) & 1 != 0 {
template.push('#'); template.push('#');
} }
if flags >> (rustc_parse_format::FlagSignAwareZeroPad as usize) & 1 != 0 { if p.format_options.zero_pad {
template.push('0'); template.push('0');
} }
if let Some(width) = &p.format_options.width { if let Some(width) = &p.format_options.width {
@ -709,11 +710,10 @@ pub fn reconstruct_format_args_template_string(pieces: &[FormatArgsPiece]) -> St
} }
} }
} }
if flags >> (rustc_parse_format::FlagDebugLowerHex as usize) & 1 != 0 { match p.format_options.debug_hex {
template.push('x'); Some(FormatDebugHex::Lower) => template.push('x'),
} Some(FormatDebugHex::Upper) => template.push('X'),
if flags >> (rustc_parse_format::FlagDebugUpperHex as usize) & 1 != 0 { None => {}
template.push('X');
} }
template.push_str(match p.format_trait { template.push_str(match p.format_trait {
FormatTrait::Display => "", FormatTrait::Display => "",

View File

@ -4,7 +4,7 @@ use rustc_ast::tokenstream::TokenStream;
use rustc_ast::{ use rustc_ast::{
Expr, ExprKind, FormatAlignment, FormatArgPosition, FormatArgPositionKind, FormatArgs, Expr, ExprKind, FormatAlignment, FormatArgPosition, FormatArgPositionKind, FormatArgs,
FormatArgsPiece, FormatArgument, FormatArgumentKind, FormatArguments, FormatCount, FormatArgsPiece, FormatArgument, FormatArgumentKind, FormatArguments, FormatCount,
FormatOptions, FormatPlaceholder, FormatTrait, FormatDebugHex, FormatOptions, FormatPlaceholder, FormatSign, FormatTrait,
}; };
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{pluralize, Applicability, MultiSpan, PResult}; use rustc_errors::{pluralize, Applicability, MultiSpan, PResult};
@ -435,7 +435,16 @@ pub fn make_format_args(
format_options: FormatOptions { format_options: FormatOptions {
fill: format.fill, fill: format.fill,
alignment, alignment,
flags: format.flags, sign: format.sign.map(|s| match s {
parse::Sign::Plus => FormatSign::Plus,
parse::Sign::Minus => FormatSign::Minus,
}),
alternate: format.alternate,
zero_pad: format.zero_pad,
debug_hex: format.debug_hex.map(|s| match s {
parse::DebugHex::Lower => FormatDebugHex::Lower,
parse::DebugHex::Upper => FormatDebugHex::Upper,
}),
precision, precision,
width, width,
}, },

View File

@ -295,9 +295,8 @@ fn add_unused_functions(cx: &CodegenCx<'_, '_>) {
DefKind::Fn | DefKind::AssocFn | DefKind::Closure | DefKind::Generator DefKind::Fn | DefKind::AssocFn | DefKind::Closure | DefKind::Generator
) { ) {
return None; return None;
} else if ignore_unused_generics }
&& tcx.generics_of(def_id).requires_monomorphization(tcx) if ignore_unused_generics && tcx.generics_of(def_id).requires_monomorphization(tcx) {
{
return None; return None;
} }
Some(local_def_id.to_def_id()) Some(local_def_id.to_def_id())

View File

@ -11,6 +11,6 @@ You cannot use `packed` and `align` hints on a same type. If you want to pack a
type to a given size, you should provide a size to packed: type to a given size, you should provide a size to packed:
``` ```
#[repr(packed)] // ok! #[repr(packed(8))] // ok!
struct Umbrella(i32); struct Umbrella(i32);
``` ```

View File

@ -16,7 +16,6 @@
pub use Alignment::*; pub use Alignment::*;
pub use Count::*; pub use Count::*;
pub use Flag::*;
pub use Piece::*; pub use Piece::*;
pub use Position::*; pub use Position::*;
@ -111,8 +110,14 @@ pub struct FormatSpec<'a> {
pub fill: Option<char>, pub fill: Option<char>,
/// Optionally specified alignment. /// Optionally specified alignment.
pub align: Alignment, pub align: Alignment,
/// Packed version of various flags provided. /// The `+` or `-` flag.
pub flags: u32, pub sign: Option<Sign>,
/// The `#` flag.
pub alternate: bool,
/// The `0` flag.
pub zero_pad: bool,
/// The `x` or `X` flag. (Only for `Debug`.)
pub debug_hex: Option<DebugHex>,
/// The integer precision to use. /// The integer precision to use.
pub precision: Count<'a>, pub precision: Count<'a>,
/// The span of the precision formatting flag (for diagnostics). /// The span of the precision formatting flag (for diagnostics).
@ -162,24 +167,22 @@ pub enum Alignment {
AlignUnknown, AlignUnknown,
} }
/// Various flags which can be applied to format strings. The meaning of these /// Enum for the sign flags.
/// flags is defined by the formatters themselves.
#[derive(Copy, Clone, Debug, PartialEq)] #[derive(Copy, Clone, Debug, PartialEq)]
pub enum Flag { pub enum Sign {
/// A `+` will be used to denote positive numbers. /// The `+` flag.
FlagSignPlus, Plus,
/// A `-` will be used to denote negative numbers. This is the default. /// The `-` flag.
FlagSignMinus, Minus,
/// An alternate form will be used for the value. In the case of numbers, }
/// this means that the number will be prefixed with the supplied string.
FlagAlternate, /// Enum for the debug hex flags.
/// For numbers, this means that the number will be padded with zeroes, #[derive(Copy, Clone, Debug, PartialEq)]
/// and the sign (`+` or `-`) will precede them. pub enum DebugHex {
FlagSignAwareZeroPad, /// The `x` flag in `{:x?}`.
/// For Debug / `?`, format integers in lower-case hexadecimal. Lower,
FlagDebugLowerHex, /// The `X` flag in `{:X?}`.
/// For Debug / `?`, format integers in upper-case hexadecimal. Upper,
FlagDebugUpperHex,
} }
/// A count is used for the precision and width parameters of an integer, and /// A count is used for the precision and width parameters of an integer, and
@ -597,7 +600,10 @@ impl<'a> Parser<'a> {
let mut spec = FormatSpec { let mut spec = FormatSpec {
fill: None, fill: None,
align: AlignUnknown, align: AlignUnknown,
flags: 0, sign: None,
alternate: false,
zero_pad: false,
debug_hex: None,
precision: CountImplied, precision: CountImplied,
precision_span: None, precision_span: None,
width: CountImplied, width: CountImplied,
@ -626,13 +632,13 @@ impl<'a> Parser<'a> {
} }
// Sign flags // Sign flags
if self.consume('+') { if self.consume('+') {
spec.flags |= 1 << (FlagSignPlus as u32); spec.sign = Some(Sign::Plus);
} else if self.consume('-') { } else if self.consume('-') {
spec.flags |= 1 << (FlagSignMinus as u32); spec.sign = Some(Sign::Minus);
} }
// Alternate marker // Alternate marker
if self.consume('#') { if self.consume('#') {
spec.flags |= 1 << (FlagAlternate as u32); spec.alternate = true;
} }
// Width and precision // Width and precision
let mut havewidth = false; let mut havewidth = false;
@ -647,7 +653,7 @@ impl<'a> Parser<'a> {
spec.width_span = Some(self.span(end - 1, end + 1)); spec.width_span = Some(self.span(end - 1, end + 1));
havewidth = true; havewidth = true;
} else { } else {
spec.flags |= 1 << (FlagSignAwareZeroPad as u32); spec.zero_pad = true;
} }
} }
@ -678,14 +684,14 @@ impl<'a> Parser<'a> {
// Optional radix followed by the actual format specifier // Optional radix followed by the actual format specifier
if self.consume('x') { if self.consume('x') {
if self.consume('?') { if self.consume('?') {
spec.flags |= 1 << (FlagDebugLowerHex as u32); spec.debug_hex = Some(DebugHex::Lower);
spec.ty = "?"; spec.ty = "?";
} else { } else {
spec.ty = "x"; spec.ty = "x";
} }
} else if self.consume('X') { } else if self.consume('X') {
if self.consume('?') { if self.consume('?') {
spec.flags |= 1 << (FlagDebugUpperHex as u32); spec.debug_hex = Some(DebugHex::Upper);
spec.ty = "?"; spec.ty = "?";
} else { } else {
spec.ty = "X"; spec.ty = "X";
@ -708,7 +714,10 @@ impl<'a> Parser<'a> {
let mut spec = FormatSpec { let mut spec = FormatSpec {
fill: None, fill: None,
align: AlignUnknown, align: AlignUnknown,
flags: 0, sign: None,
alternate: false,
zero_pad: false,
debug_hex: None,
precision: CountImplied, precision: CountImplied,
precision_span: None, precision_span: None,
width: CountImplied, width: CountImplied,

View File

@ -10,7 +10,10 @@ fn fmtdflt() -> FormatSpec<'static> {
return FormatSpec { return FormatSpec {
fill: None, fill: None,
align: AlignUnknown, align: AlignUnknown,
flags: 0, sign: None,
alternate: false,
zero_pad: false,
debug_hex: None,
precision: CountImplied, precision: CountImplied,
width: CountImplied, width: CountImplied,
precision_span: None, precision_span: None,
@ -126,7 +129,10 @@ fn format_type() {
format: FormatSpec { format: FormatSpec {
fill: None, fill: None,
align: AlignUnknown, align: AlignUnknown,
flags: 0, sign: None,
alternate: false,
zero_pad: false,
debug_hex: None,
precision: CountImplied, precision: CountImplied,
width: CountImplied, width: CountImplied,
precision_span: None, precision_span: None,
@ -147,7 +153,10 @@ fn format_align_fill() {
format: FormatSpec { format: FormatSpec {
fill: None, fill: None,
align: AlignRight, align: AlignRight,
flags: 0, sign: None,
alternate: false,
zero_pad: false,
debug_hex: None,
precision: CountImplied, precision: CountImplied,
width: CountImplied, width: CountImplied,
precision_span: None, precision_span: None,
@ -165,7 +174,10 @@ fn format_align_fill() {
format: FormatSpec { format: FormatSpec {
fill: Some('0'), fill: Some('0'),
align: AlignLeft, align: AlignLeft,
flags: 0, sign: None,
alternate: false,
zero_pad: false,
debug_hex: None,
precision: CountImplied, precision: CountImplied,
width: CountImplied, width: CountImplied,
precision_span: None, precision_span: None,
@ -183,7 +195,10 @@ fn format_align_fill() {
format: FormatSpec { format: FormatSpec {
fill: Some('*'), fill: Some('*'),
align: AlignLeft, align: AlignLeft,
flags: 0, sign: None,
alternate: false,
zero_pad: false,
debug_hex: None,
precision: CountImplied, precision: CountImplied,
width: CountImplied, width: CountImplied,
precision_span: None, precision_span: None,
@ -204,7 +219,10 @@ fn format_counts() {
format: FormatSpec { format: FormatSpec {
fill: None, fill: None,
align: AlignUnknown, align: AlignUnknown,
flags: 0, sign: None,
alternate: false,
zero_pad: false,
debug_hex: None,
precision: CountImplied, precision: CountImplied,
precision_span: None, precision_span: None,
width: CountIs(10), width: CountIs(10),
@ -222,7 +240,10 @@ fn format_counts() {
format: FormatSpec { format: FormatSpec {
fill: None, fill: None,
align: AlignUnknown, align: AlignUnknown,
flags: 0, sign: None,
alternate: false,
zero_pad: false,
debug_hex: None,
precision: CountIs(10), precision: CountIs(10),
precision_span: Some(InnerSpan { start: 6, end: 9 }), precision_span: Some(InnerSpan { start: 6, end: 9 }),
width: CountIsParam(10), width: CountIsParam(10),
@ -240,7 +261,10 @@ fn format_counts() {
format: FormatSpec { format: FormatSpec {
fill: None, fill: None,
align: AlignUnknown, align: AlignUnknown,
flags: 0, sign: None,
alternate: false,
zero_pad: false,
debug_hex: None,
precision: CountIs(10), precision: CountIs(10),
precision_span: Some(InnerSpan { start: 6, end: 9 }), precision_span: Some(InnerSpan { start: 6, end: 9 }),
width: CountIsParam(0), width: CountIsParam(0),
@ -258,7 +282,10 @@ fn format_counts() {
format: FormatSpec { format: FormatSpec {
fill: None, fill: None,
align: AlignUnknown, align: AlignUnknown,
flags: 0, sign: None,
alternate: false,
zero_pad: false,
debug_hex: None,
precision: CountIsStar(0), precision: CountIsStar(0),
precision_span: Some(InnerSpan { start: 3, end: 5 }), precision_span: Some(InnerSpan { start: 3, end: 5 }),
width: CountImplied, width: CountImplied,
@ -276,7 +303,10 @@ fn format_counts() {
format: FormatSpec { format: FormatSpec {
fill: None, fill: None,
align: AlignUnknown, align: AlignUnknown,
flags: 0, sign: None,
alternate: false,
zero_pad: false,
debug_hex: None,
precision: CountIsParam(10), precision: CountIsParam(10),
width: CountImplied, width: CountImplied,
precision_span: Some(InnerSpan::new(3, 7)), precision_span: Some(InnerSpan::new(3, 7)),
@ -294,7 +324,10 @@ fn format_counts() {
format: FormatSpec { format: FormatSpec {
fill: None, fill: None,
align: AlignUnknown, align: AlignUnknown,
flags: 0, sign: None,
alternate: false,
zero_pad: false,
debug_hex: None,
precision: CountIsName("b", InnerSpan { start: 6, end: 7 }), precision: CountIsName("b", InnerSpan { start: 6, end: 7 }),
precision_span: Some(InnerSpan { start: 5, end: 8 }), precision_span: Some(InnerSpan { start: 5, end: 8 }),
width: CountIsName("a", InnerSpan { start: 3, end: 4 }), width: CountIsName("a", InnerSpan { start: 3, end: 4 }),
@ -312,7 +345,10 @@ fn format_counts() {
format: FormatSpec { format: FormatSpec {
fill: None, fill: None,
align: AlignUnknown, align: AlignUnknown,
flags: 0, sign: None,
alternate: false,
zero_pad: false,
debug_hex: None,
precision: CountIs(4), precision: CountIs(4),
precision_span: Some(InnerSpan { start: 3, end: 5 }), precision_span: Some(InnerSpan { start: 3, end: 5 }),
width: CountImplied, width: CountImplied,
@ -333,7 +369,10 @@ fn format_flags() {
format: FormatSpec { format: FormatSpec {
fill: None, fill: None,
align: AlignUnknown, align: AlignUnknown,
flags: (1 << FlagSignMinus as u32), sign: Some(Sign::Minus),
alternate: false,
zero_pad: false,
debug_hex: None,
precision: CountImplied, precision: CountImplied,
width: CountImplied, width: CountImplied,
precision_span: None, precision_span: None,
@ -351,7 +390,10 @@ fn format_flags() {
format: FormatSpec { format: FormatSpec {
fill: None, fill: None,
align: AlignUnknown, align: AlignUnknown,
flags: (1 << FlagSignPlus as u32) | (1 << FlagAlternate as u32), sign: Some(Sign::Plus),
alternate: true,
zero_pad: false,
debug_hex: None,
precision: CountImplied, precision: CountImplied,
width: CountImplied, width: CountImplied,
precision_span: None, precision_span: None,
@ -374,7 +416,10 @@ fn format_mixture() {
format: FormatSpec { format: FormatSpec {
fill: None, fill: None,
align: AlignUnknown, align: AlignUnknown,
flags: 0, sign: None,
alternate: false,
zero_pad: false,
debug_hex: None,
precision: CountImplied, precision: CountImplied,
width: CountImplied, width: CountImplied,
precision_span: None, precision_span: None,

View File

@ -141,17 +141,6 @@ type CanonicalResponse<'tcx> = Canonical<'tcx, Response<'tcx>>;
/// solver, merge the two responses again. /// solver, merge the two responses again.
pub type QueryResult<'tcx> = Result<CanonicalResponse<'tcx>, NoSolution>; pub type QueryResult<'tcx> = Result<CanonicalResponse<'tcx>, NoSolution>;
pub trait TyCtxtExt<'tcx> {
fn evaluate_goal(self, goal: CanonicalGoal<'tcx>) -> QueryResult<'tcx>;
}
impl<'tcx> TyCtxtExt<'tcx> for TyCtxt<'tcx> {
fn evaluate_goal(self, goal: CanonicalGoal<'tcx>) -> QueryResult<'tcx> {
let mut search_graph = search_graph::SearchGraph::new(self);
EvalCtxt::evaluate_canonical_goal(self, &mut search_graph, goal)
}
}
pub trait InferCtxtEvalExt<'tcx> { pub trait InferCtxtEvalExt<'tcx> {
/// Evaluates a goal from **outside** of the trait solver. /// Evaluates a goal from **outside** of the trait solver.
/// ///
@ -194,6 +183,15 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
self.infcx.tcx self.infcx.tcx
} }
/// The entry point of the solver.
///
/// This function deals with (coinductive) cycles, overflow, and caching
/// and then calls [`EvalCtxt::compute_goal`] which contains the actual
/// logic of the solver.
///
/// Instead of calling this function directly, use either [EvalCtxt::evaluate_goal]
/// if you're inside of the solver or [InferCtxtEvalExt::evaluate_root_goal] if you're
/// outside of it.
#[instrument(level = "debug", skip(tcx, search_graph), ret)] #[instrument(level = "debug", skip(tcx, search_graph), ret)]
fn evaluate_canonical_goal( fn evaluate_canonical_goal(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,

View File

@ -28,8 +28,8 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
// To only compute normalization once for each projection we only // To only compute normalization once for each projection we only
// normalize if the expected term is an unconstrained inference variable. // normalize if the expected term is an unconstrained inference variable.
// //
// E.g. for `<T as Trait>::Assoc = u32` we recursively compute the goal // E.g. for `<T as Trait>::Assoc == u32` we recursively compute the goal
// `exists<U> <T as Trait>::Assoc = U` and then take the resulting type for // `exists<U> <T as Trait>::Assoc == U` and then take the resulting type for
// `U` and equate it with `u32`. This means that we don't need a separate // `U` and equate it with `u32`. This means that we don't need a separate
// projection cache in the solver. // projection cache in the solver.
if self.term_is_fully_unconstrained(goal) { if self.term_is_fully_unconstrained(goal) {

View File

@ -712,7 +712,7 @@ class RustBuild(object):
def build_bootstrap(self, color): def build_bootstrap(self, color):
"""Build bootstrap""" """Build bootstrap"""
print("Building rustbuild") print("Building bootstrap")
build_dir = os.path.join(self.build_dir, "bootstrap") build_dir = os.path.join(self.build_dir, "bootstrap")
if self.clean and os.path.exists(build_dir): if self.clean and os.path.exists(build_dir):
shutil.rmtree(build_dir) shutil.rmtree(build_dir)

View File

@ -965,6 +965,9 @@ impl Config {
config.changelog_seen = toml.changelog_seen; config.changelog_seen = toml.changelog_seen;
let build = toml.build.unwrap_or_default(); let build = toml.build.unwrap_or_default();
if let Some(file_build) = build.build {
config.build = TargetSelection::from_user(&file_build);
};
set(&mut config.out, flags.build_dir.or_else(|| build.build_dir.map(PathBuf::from))); set(&mut config.out, flags.build_dir.or_else(|| build.build_dir.map(PathBuf::from)));
// NOTE: Bootstrap spawns various commands with different working directories. // NOTE: Bootstrap spawns various commands with different working directories.

View File

@ -19,6 +19,13 @@ fn download_ci_llvm() {
assert_eq!(parse_llvm(""), if_available); assert_eq!(parse_llvm(""), if_available);
assert_eq!(parse_llvm("rust.channel = \"dev\""), if_available); assert_eq!(parse_llvm("rust.channel = \"dev\""), if_available);
assert!(!parse_llvm("rust.channel = \"stable\"")); assert!(!parse_llvm("rust.channel = \"stable\""));
assert!(parse_llvm("build.build = \"x86_64-unknown-linux-gnu\""));
assert!(parse_llvm(
"llvm.assertions = true \r\n build.build = \"x86_64-unknown-linux-gnu\" \r\n llvm.download-ci-llvm = \"if-available\""
));
assert!(!parse_llvm(
"llvm.assertions = true \r\n build.build = \"aarch64-apple-darwin\" \r\n llvm.download-ci-llvm = \"if-available\""
));
} }
// FIXME: add test for detecting `src` and `out` // FIXME: add test for detecting `src` and `out`

View File

@ -180,43 +180,40 @@ pub(crate) fn is_ci_llvm_available(config: &Config, asserts: bool) -> bool {
// https://doc.rust-lang.org/rustc/platform-support.html#tier-1 // https://doc.rust-lang.org/rustc/platform-support.html#tier-1
let supported_platforms = [ let supported_platforms = [
// tier 1 // tier 1
"aarch64-unknown-linux-gnu", ("aarch64-unknown-linux-gnu", false),
"i686-pc-windows-gnu", ("i686-pc-windows-gnu", false),
"i686-pc-windows-msvc", ("i686-pc-windows-msvc", false),
"i686-unknown-linux-gnu", ("i686-unknown-linux-gnu", false),
"x86_64-unknown-linux-gnu", ("x86_64-unknown-linux-gnu", true),
"x86_64-apple-darwin", ("x86_64-apple-darwin", true),
"x86_64-pc-windows-gnu", ("x86_64-pc-windows-gnu", true),
"x86_64-pc-windows-msvc", ("x86_64-pc-windows-msvc", true),
// tier 2 with host tools // tier 2 with host tools
"aarch64-apple-darwin", ("aarch64-apple-darwin", false),
"aarch64-pc-windows-msvc", ("aarch64-pc-windows-msvc", false),
"aarch64-unknown-linux-musl", ("aarch64-unknown-linux-musl", false),
"arm-unknown-linux-gnueabi", ("arm-unknown-linux-gnueabi", false),
"arm-unknown-linux-gnueabihf", ("arm-unknown-linux-gnueabihf", false),
"armv7-unknown-linux-gnueabihf", ("armv7-unknown-linux-gnueabihf", false),
"mips-unknown-linux-gnu", ("mips-unknown-linux-gnu", false),
"mips64-unknown-linux-gnuabi64", ("mips64-unknown-linux-gnuabi64", false),
"mips64el-unknown-linux-gnuabi64", ("mips64el-unknown-linux-gnuabi64", false),
"mipsel-unknown-linux-gnu", ("mipsel-unknown-linux-gnu", false),
"powerpc-unknown-linux-gnu", ("powerpc-unknown-linux-gnu", false),
"powerpc64-unknown-linux-gnu", ("powerpc64-unknown-linux-gnu", false),
"powerpc64le-unknown-linux-gnu", ("powerpc64le-unknown-linux-gnu", false),
"riscv64gc-unknown-linux-gnu", ("riscv64gc-unknown-linux-gnu", false),
"s390x-unknown-linux-gnu", ("s390x-unknown-linux-gnu", false),
"x86_64-unknown-freebsd", ("x86_64-unknown-freebsd", false),
"x86_64-unknown-illumos", ("x86_64-unknown-illumos", false),
"x86_64-unknown-linux-musl", ("x86_64-unknown-linux-musl", false),
"x86_64-unknown-netbsd", ("x86_64-unknown-netbsd", false),
]; ];
if !supported_platforms.contains(&&*config.build.triple) {
return false;
}
let triple = &*config.build.triple; if !supported_platforms.contains(&(&*config.build.triple, asserts)) {
if (triple == "aarch64-unknown-linux-gnu" || triple.contains("i686")) && asserts { if asserts == true || !supported_platforms.contains(&(&*config.build.triple, true)) {
// No alt builder for aarch64-unknown-linux-gnu today. return false;
return false; }
} }
if CiEnv::is_ci() { if CiEnv::is_ci() {

View File

@ -2112,10 +2112,12 @@ fn get_all_import_attributes<'hir>(
) { ) {
let hir_map = tcx.hir(); let hir_map = tcx.hir();
let mut visitor = OneLevelVisitor::new(hir_map, target_def_id); let mut visitor = OneLevelVisitor::new(hir_map, target_def_id);
let mut visited = FxHashSet::default();
// If the item is an import and has at least a path with two parts, we go into it. // If the item is an import and has at least a path with two parts, we go into it.
while let hir::ItemKind::Use(path, _) = item.kind && while let hir::ItemKind::Use(path, _) = item.kind &&
path.segments.len() > 1 && path.segments.len() > 1 &&
let hir::def::Res::Def(_, def_id) = path.segments[path.segments.len() - 2].res let hir::def::Res::Def(_, def_id) = path.segments[path.segments.len() - 2].res &&
visited.insert(def_id)
{ {
if let Some(hir::Node::Item(parent_item)) = hir_map.get_if_local(def_id) { if let Some(hir::Node::Item(parent_item)) = hir_map.get_if_local(def_id) {
// We add the attributes from this import into the list. // We add the attributes from this import into the list.

View File

@ -711,8 +711,8 @@ pub struct FormatSpec<'tcx> {
pub fill: Option<char>, pub fill: Option<char>,
/// Optionally specified alignment. /// Optionally specified alignment.
pub align: Alignment, pub align: Alignment,
/// Packed version of various flags provided, see [`rustc_parse_format::Flag`]. /// Whether all flag options are set to default (no flags specified).
pub flags: u32, pub no_flags: bool,
/// Represents either the maximum width or the integer precision. /// Represents either the maximum width or the integer precision.
pub precision: Count<'tcx>, pub precision: Count<'tcx>,
/// The minimum width, will be padded according to `width`/`align` /// The minimum width, will be padded according to `width`/`align`
@ -728,7 +728,7 @@ impl<'tcx> FormatSpec<'tcx> {
Some(Self { Some(Self {
fill: spec.fill, fill: spec.fill,
align: spec.align, align: spec.align,
flags: spec.flags, no_flags: spec.sign.is_none() && !spec.alternate && !spec.zero_pad && spec.debug_hex.is_none(),
precision: Count::new( precision: Count::new(
FormatParamUsage::Precision, FormatParamUsage::Precision,
spec.precision, spec.precision,
@ -773,7 +773,7 @@ impl<'tcx> FormatSpec<'tcx> {
self.width.is_implied() self.width.is_implied()
&& self.precision.is_implied() && self.precision.is_implied()
&& self.align == Alignment::AlignUnknown && self.align == Alignment::AlignUnknown
&& self.flags == 0 && self.no_flags
} }
} }

View File

@ -0,0 +1,18 @@
// This is a regression test for <https://github.com/rust-lang/rust/issues/107350>.
// It shouldn't loop indefinitely.
#![crate_name = "foo"]
// @has 'foo/oops/enum.OhNo.html'
pub mod oops {
pub use crate::oops::OhNo;
mod inner {
pub enum OhNo {
Item = 1,
}
}
pub use self::inner::*;
}