Skip to content

Commit 5a50275

Browse files
committed
Auto merge of #66242 - Centril:rollup-h73ztr1, r=Centril
Rollup of 6 pull requests Successful merges: - #65949 (Move promotion into its own pass) - #65994 (Point at where clauses where the associated item was restricted) - #66050 (Fix C aggregate-passing ABI on powerpc) - #66134 (Point at formatting descriptor string when it is invalid) - #66172 (Stabilize @file command line arguments) - #66226 (add link to unstable book for asm! macro) Failed merges: r? @ghost
2 parents 98c173a + 3ef975d commit 5a50275

29 files changed

+453
-323
lines changed

src/libcore/macros.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1274,6 +1274,10 @@ pub(crate) mod builtin {
12741274
}
12751275

12761276
/// Inline assembly.
1277+
///
1278+
/// Read the [unstable book] for the usage.
1279+
///
1280+
/// [unstable book]: ../unstable-book/library-features/asm.html
12771281
#[unstable(feature = "asm", issue = "29722",
12781282
reason = "inline assembly is not stable enough for use and is subject to change")]
12791283
#[rustc_builtin_macro]

src/libfmt_macros/lib.rs

+17-7
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl InnerOffset {
3535

3636
/// A piece is a portion of the format string which represents the next part
3737
/// to emit. These are emitted as a stream by the `Parser` class.
38-
#[derive(Copy, Clone, PartialEq)]
38+
#[derive(Copy, Clone, Debug, PartialEq)]
3939
pub enum Piece<'a> {
4040
/// A literal string which should directly be emitted
4141
String(&'a str),
@@ -45,7 +45,7 @@ pub enum Piece<'a> {
4545
}
4646

4747
/// Representation of an argument specification.
48-
#[derive(Copy, Clone, PartialEq)]
48+
#[derive(Copy, Clone, Debug, PartialEq)]
4949
pub struct Argument<'a> {
5050
/// Where to find this argument
5151
pub position: Position,
@@ -54,7 +54,7 @@ pub struct Argument<'a> {
5454
}
5555

5656
/// Specification for the formatting of an argument in the format string.
57-
#[derive(Copy, Clone, PartialEq)]
57+
#[derive(Copy, Clone, Debug, PartialEq)]
5858
pub struct FormatSpec<'a> {
5959
/// Optionally specified character to fill alignment with.
6060
pub fill: Option<char>,
@@ -74,10 +74,12 @@ pub struct FormatSpec<'a> {
7474
/// this argument, this can be empty or any number of characters, although
7575
/// it is required to be one word.
7676
pub ty: &'a str,
77+
/// The span of the descriptor string (for diagnostics).
78+
pub ty_span: Option<InnerSpan>,
7779
}
7880

7981
/// Enum describing where an argument for a format can be located.
80-
#[derive(Copy, Clone, PartialEq)]
82+
#[derive(Copy, Clone, Debug, PartialEq)]
8183
pub enum Position {
8284
/// The argument is implied to be located at an index
8385
ArgumentImplicitlyIs(usize),
@@ -97,7 +99,7 @@ impl Position {
9799
}
98100

99101
/// Enum of alignments which are supported.
100-
#[derive(Copy, Clone, PartialEq)]
102+
#[derive(Copy, Clone, Debug, PartialEq)]
101103
pub enum Alignment {
102104
/// The value will be aligned to the left.
103105
AlignLeft,
@@ -111,7 +113,7 @@ pub enum Alignment {
111113

112114
/// Various flags which can be applied to format strings. The meaning of these
113115
/// flags is defined by the formatters themselves.
114-
#[derive(Copy, Clone, PartialEq)]
116+
#[derive(Copy, Clone, Debug, PartialEq)]
115117
pub enum Flag {
116118
/// A `+` will be used to denote positive numbers.
117119
FlagSignPlus,
@@ -131,7 +133,7 @@ pub enum Flag {
131133

132134
/// A count is used for the precision and width parameters of an integer, and
133135
/// can reference either an argument or a literal integer.
134-
#[derive(Copy, Clone, PartialEq)]
136+
#[derive(Copy, Clone, Debug, PartialEq)]
135137
pub enum Count {
136138
/// The count is specified explicitly.
137139
CountIs(usize),
@@ -475,6 +477,7 @@ impl<'a> Parser<'a> {
475477
width: CountImplied,
476478
width_span: None,
477479
ty: &self.input[..0],
480+
ty_span: None,
478481
};
479482
if !self.consume(':') {
480483
return spec;
@@ -548,6 +551,7 @@ impl<'a> Parser<'a> {
548551
spec.precision_span = sp;
549552
}
550553
}
554+
let ty_span_start = self.cur.peek().map(|(pos, _)| *pos);
551555
// Optional radix followed by the actual format specifier
552556
if self.consume('x') {
553557
if self.consume('?') {
@@ -567,6 +571,12 @@ impl<'a> Parser<'a> {
567571
spec.ty = "?";
568572
} else {
569573
spec.ty = self.word();
574+
let ty_span_end = self.cur.peek().map(|(pos, _)| *pos);
575+
if !spec.ty.is_empty() {
576+
spec.ty_span = ty_span_start
577+
.and_then(|s| ty_span_end.map(|e| (s, e)))
578+
.map(|(start, end)| self.to_span_index(start).to(self.to_span_index(end)));
579+
}
570580
}
571581
spec
572582
}

src/libfmt_macros/tests.rs

+28-15
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use super::*;
22

33
fn same(fmt: &'static str, p: &[Piece<'static>]) {
44
let parser = Parser::new(fmt, None, vec![], false);
5-
assert!(parser.collect::<Vec<Piece<'static>>>() == p);
5+
assert_eq!(parser.collect::<Vec<Piece<'static>>>(), p);
66
}
77

88
fn fmtdflt() -> FormatSpec<'static> {
@@ -15,6 +15,7 @@ fn fmtdflt() -> FormatSpec<'static> {
1515
precision_span: None,
1616
width_span: None,
1717
ty: "",
18+
ty_span: None,
1819
};
1920
}
2021

@@ -82,7 +83,7 @@ fn format_position_nothing_else() {
8283
#[test]
8384
fn format_type() {
8485
same(
85-
"{3:a}",
86+
"{3:x}",
8687
&[NextArgument(Argument {
8788
position: ArgumentIs(3),
8889
format: FormatSpec {
@@ -93,7 +94,8 @@ fn format_type() {
9394
width: CountImplied,
9495
precision_span: None,
9596
width_span: None,
96-
ty: "a",
97+
ty: "x",
98+
ty_span: None,
9799
},
98100
})]);
99101
}
@@ -112,6 +114,7 @@ fn format_align_fill() {
112114
precision_span: None,
113115
width_span: None,
114116
ty: "",
117+
ty_span: None,
115118
},
116119
})]);
117120
same(
@@ -127,6 +130,7 @@ fn format_align_fill() {
127130
precision_span: None,
128131
width_span: None,
129132
ty: "",
133+
ty_span: None,
130134
},
131135
})]);
132136
same(
@@ -142,6 +146,7 @@ fn format_align_fill() {
142146
precision_span: None,
143147
width_span: None,
144148
ty: "abcd",
149+
ty_span: Some(InnerSpan::new(6, 10)),
145150
},
146151
})]);
147152
}
@@ -150,7 +155,7 @@ fn format_counts() {
150155
use syntax_pos::{GLOBALS, Globals, edition};
151156
GLOBALS.set(&Globals::new(edition::DEFAULT_EDITION), || {
152157
same(
153-
"{:10s}",
158+
"{:10x}",
154159
&[NextArgument(Argument {
155160
position: ArgumentImplicitlyIs(0),
156161
format: FormatSpec {
@@ -161,11 +166,12 @@ fn format_counts() {
161166
width: CountIs(10),
162167
precision_span: None,
163168
width_span: None,
164-
ty: "s",
169+
ty: "x",
170+
ty_span: None,
165171
},
166172
})]);
167173
same(
168-
"{:10$.10s}",
174+
"{:10$.10x}",
169175
&[NextArgument(Argument {
170176
position: ArgumentImplicitlyIs(0),
171177
format: FormatSpec {
@@ -176,11 +182,12 @@ fn format_counts() {
176182
width: CountIsParam(10),
177183
precision_span: None,
178184
width_span: Some(InnerSpan::new(3, 6)),
179-
ty: "s",
185+
ty: "x",
186+
ty_span: None,
180187
},
181188
})]);
182189
same(
183-
"{:.*s}",
190+
"{:.*x}",
184191
&[NextArgument(Argument {
185192
position: ArgumentImplicitlyIs(1),
186193
format: FormatSpec {
@@ -191,11 +198,12 @@ fn format_counts() {
191198
width: CountImplied,
192199
precision_span: Some(InnerSpan::new(3, 5)),
193200
width_span: None,
194-
ty: "s",
201+
ty: "x",
202+
ty_span: None,
195203
},
196204
})]);
197205
same(
198-
"{:.10$s}",
206+
"{:.10$x}",
199207
&[NextArgument(Argument {
200208
position: ArgumentImplicitlyIs(0),
201209
format: FormatSpec {
@@ -206,11 +214,12 @@ fn format_counts() {
206214
width: CountImplied,
207215
precision_span: Some(InnerSpan::new(3, 7)),
208216
width_span: None,
209-
ty: "s",
217+
ty: "x",
218+
ty_span: None,
210219
},
211220
})]);
212221
same(
213-
"{:a$.b$s}",
222+
"{:a$.b$?}",
214223
&[NextArgument(Argument {
215224
position: ArgumentImplicitlyIs(0),
216225
format: FormatSpec {
@@ -221,7 +230,8 @@ fn format_counts() {
221230
width: CountIsName(Symbol::intern("a")),
222231
precision_span: None,
223232
width_span: None,
224-
ty: "s",
233+
ty: "?",
234+
ty_span: None,
225235
},
226236
})]);
227237
});
@@ -241,6 +251,7 @@ fn format_flags() {
241251
precision_span: None,
242252
width_span: None,
243253
ty: "",
254+
ty_span: None,
244255
},
245256
})]);
246257
same(
@@ -256,13 +267,14 @@ fn format_flags() {
256267
precision_span: None,
257268
width_span: None,
258269
ty: "",
270+
ty_span: None,
259271
},
260272
})]);
261273
}
262274
#[test]
263275
fn format_mixture() {
264276
same(
265-
"abcd {3:a} efg",
277+
"abcd {3:x} efg",
266278
&[
267279
String("abcd "),
268280
NextArgument(Argument {
@@ -275,7 +287,8 @@ fn format_mixture() {
275287
width: CountImplied,
276288
precision_span: None,
277289
width_span: None,
278-
ty: "a",
290+
ty: "x",
291+
ty_span: None,
279292
},
280293
}),
281294
String(" efg"),

src/librustc/query/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ rustc_queries! {
9393
/// Maps DefId's that have an associated `mir::Body` to the result
9494
/// of the MIR qualify_consts pass. The actual meaning of
9595
/// the value isn't known except to the pass itself.
96-
query mir_const_qualif(key: DefId) -> (u8, &'tcx BitSet<mir::Local>) {
96+
query mir_const_qualif(key: DefId) -> u8 {
9797
desc { |tcx| "const checking `{}`", tcx.def_path_str(key) }
9898
cache_on_disk_if { key.is_local() }
9999
}

src/librustc/traits/error_reporting.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -2287,11 +2287,14 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
22872287
);
22882288
}
22892289
}
2290-
ObligationCauseCode::AssocTypeBound(impl_span, orig) => {
2291-
err.span_label(orig, "associated type defined here");
2292-
if let Some(sp) = impl_span {
2290+
ObligationCauseCode::AssocTypeBound(ref data) => {
2291+
err.span_label(data.original, "associated type defined here");
2292+
if let Some(sp) = data.impl_span {
22932293
err.span_label(sp, "in this `impl` item");
22942294
}
2295+
for sp in &data.bounds {
2296+
err.span_label(*sp, "restricted in this bound");
2297+
}
22952298
}
22962299
}
22972300
}

src/librustc/traits/mod.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,14 @@ pub enum ObligationCauseCode<'tcx> {
276276
/// #[feature(trivial_bounds)] is not enabled
277277
TrivialBound,
278278

279-
AssocTypeBound(/*impl*/ Option<Span>, /*original*/ Span),
279+
AssocTypeBound(Box<AssocTypeBoundData>),
280+
}
281+
282+
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
283+
pub struct AssocTypeBoundData {
284+
pub impl_span: Option<Span>,
285+
pub original: Span,
286+
pub bounds: Vec<Span>,
280287
}
281288

282289
// `ObligationCauseCode` is used a lot. Make sure it doesn't unintentionally get bigger.

src/librustc/traits/structural_impls.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ impl<'a, 'tcx> Lift<'tcx> for traits::ObligationCauseCode<'a> {
549549
super::MethodReceiver => Some(super::MethodReceiver),
550550
super::BlockTailExpression(id) => Some(super::BlockTailExpression(id)),
551551
super::TrivialBound => Some(super::TrivialBound),
552-
super::AssocTypeBound(impl_sp, sp) => Some(super::AssocTypeBound(impl_sp, sp)),
552+
super::AssocTypeBound(ref data) => Some(super::AssocTypeBound(data.clone())),
553553
}
554554
}
555555
}

src/librustc/ty/query/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ use crate::util::common::ErrorReported;
4242
use crate::util::profiling::ProfileCategory::*;
4343

4444
use rustc_data_structures::svh::Svh;
45-
use rustc_index::bit_set::BitSet;
4645
use rustc_index::vec::IndexVec;
4746
use rustc_data_structures::fx::{FxIndexMap, FxHashMap, FxHashSet};
4847
use rustc_data_structures::stable_hasher::StableVec;

0 commit comments

Comments
 (0)