Skip to content

Commit 6312b89

Browse files
committed
Auto merge of #61649 - Centril:rollup-b4nx9k9, r=Centril
Rollup of 7 pull requests Successful merges: - #61223 (Document tuple's Ord behavior as sequential) - #61615 (syntax: Treat error literals in more principled way) - #61616 (parser: Remove `Deref` impl from `Parser`) - #61621 (Clarify when we run steps with ONLY_HOSTS) - #61627 (Add regression test for #61452.) - #61641 (Revert "Make LocalAnalizer visitor iterate instead of recurse") - #61647 (Use stable wrappers in f32/f64::signum) Failed merges: r? @ghost
2 parents d132f54 + b3bdc24 commit 6312b89

31 files changed

+378
-350
lines changed

src/bootstrap/builder.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash {
5959

6060
const DEFAULT: bool = false;
6161

62-
/// Run this rule for all hosts without cross compiling.
62+
/// If true, then this rule should be skipped if --target was specified, but --host was not
6363
const ONLY_HOSTS: bool = false;
6464

6565
/// Primary function to execute this rule. Can call `builder.ensure()`
@@ -163,7 +163,7 @@ impl StepDescription {
163163

164164
// Determine the targets participating in this rule.
165165
let targets = if self.only_hosts {
166-
if !builder.config.run_host_only {
166+
if builder.config.skip_only_host_steps {
167167
return; // don't run anything
168168
} else {
169169
&builder.hosts
@@ -1338,7 +1338,7 @@ mod __test {
13381338
let mut config = Config::default_opts();
13391339
// don't save toolstates
13401340
config.save_toolstates = None;
1341-
config.run_host_only = true;
1341+
config.skip_only_host_steps = false;
13421342
config.dry_run = true;
13431343
// try to avoid spurious failures in dist where we create/delete each others file
13441344
let dir = config.out.join("tmp-rustbuild-tests").join(
@@ -1583,7 +1583,7 @@ mod __test {
15831583
#[test]
15841584
fn dist_with_target_flag() {
15851585
let mut config = configure(&["B"], &["C"]);
1586-
config.run_host_only = false; // as-if --target=C was passed
1586+
config.skip_only_host_steps = true; // as-if --target=C was passed
15871587
let build = Build::new(config);
15881588
let mut builder = Builder::new(&build);
15891589
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Dist), &[]);
@@ -1831,7 +1831,7 @@ mod __test {
18311831
#[test]
18321832
fn build_with_target_flag() {
18331833
let mut config = configure(&["B"], &["C"]);
1834-
config.run_host_only = false;
1834+
config.skip_only_host_steps = true;
18351835
let build = Build::new(config);
18361836
let mut builder = Builder::new(&build);
18371837
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Build), &[]);

src/bootstrap/config.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub struct Config {
5151
pub test_compare_mode: bool,
5252
pub llvm_libunwind: bool,
5353

54-
pub run_host_only: bool,
54+
pub skip_only_host_steps: bool,
5555

5656
pub on_fail: Option<String>,
5757
pub stage: Option<u32>,
@@ -416,7 +416,9 @@ impl Config {
416416
}
417417

418418
// If --target was specified but --host wasn't specified, don't run any host-only tests.
419-
config.run_host_only = !(flags.host.is_empty() && !flags.target.is_empty());
419+
let has_hosts = !flags.host.is_empty();
420+
let has_targets = !flags.target.is_empty();
421+
config.skip_only_host_steps = !has_hosts && has_targets;
420422

421423
let toml = file.map(|file| {
422424
let contents = t!(fs::read_to_string(&file));

src/librustc/hir/intravisit.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,6 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
10201020
ExprKind::AddrOf(_, ref subexpression) | ExprKind::Unary(_, ref subexpression) => {
10211021
visitor.visit_expr(subexpression)
10221022
}
1023-
ExprKind::Lit(_) => {}
10241023
ExprKind::Cast(ref subexpression, ref typ) | ExprKind::Type(ref subexpression, ref typ) => {
10251024
visitor.visit_expr(subexpression);
10261025
visitor.visit_ty(typ)
@@ -1093,7 +1092,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
10931092
ExprKind::Yield(ref subexpression) => {
10941093
visitor.visit_expr(subexpression);
10951094
}
1096-
ExprKind::Err => {}
1095+
ExprKind::Lit(_) | ExprKind::Err => {}
10971096
}
10981097
}
10991098

src/librustc/ich/impls_syntax.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,14 @@ impl_stable_hash_for!(struct ::syntax::ast::Lit {
170170

171171
impl_stable_hash_for!(enum ::syntax::ast::LitKind {
172172
Str(value, style),
173-
Err(value),
174173
ByteStr(value),
175174
Byte(value),
176175
Char(value),
177176
Int(value, lit_int_type),
178177
Float(value, float_ty),
179178
FloatUnsuffixed(value),
180-
Bool(value)
179+
Bool(value),
180+
Err(value)
181181
});
182182

183183
impl_stable_hash_for_spanned!(::syntax::ast::LitKind);

src/librustc_codegen_ssa/mir/analyze.rs

+37-48
Original file line numberDiff line numberDiff line change
@@ -154,62 +154,51 @@ impl<'mir, 'a: 'mir, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
154154
context: PlaceContext,
155155
location: Location) {
156156
debug!("visit_place(place={:?}, context={:?})", place, context);
157-
let mut context = context;
158157
let cx = self.fx.cx;
159158

160-
place.iterate(|place_base, place_projections| {
161-
for proj in place_projections {
162-
// Allow uses of projections that are ZSTs or from scalar fields.
163-
let is_consume = match context {
164-
PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy) |
165-
PlaceContext::NonMutatingUse(NonMutatingUseContext::Move) => true,
166-
_ => false
167-
};
168-
if is_consume {
169-
let base_ty = proj.base.ty(self.fx.mir, cx.tcx());
170-
let base_ty = self.fx.monomorphize(&base_ty);
171-
172-
// ZSTs don't require any actual memory access.
173-
let elem_ty = base_ty
174-
.projection_ty(cx.tcx(), &proj.elem)
175-
.ty;
176-
let elem_ty = self.fx.monomorphize(&elem_ty);
177-
if cx.layout_of(elem_ty).is_zst() {
178-
return;
179-
}
180-
181-
if let mir::ProjectionElem::Field(..) = proj.elem {
182-
let layout = cx.layout_of(base_ty.ty);
183-
if cx.is_backend_immediate(layout) || cx.is_backend_scalar_pair(layout) {
184-
// Recurse with the same context, instead of `Projection`,
185-
// potentially stopping at non-operand projections,
186-
// which would trigger `not_ssa` on locals.
187-
continue;
188-
}
189-
}
159+
if let mir::Place::Projection(ref proj) = *place {
160+
// Allow uses of projections that are ZSTs or from scalar fields.
161+
let is_consume = match context {
162+
PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy) |
163+
PlaceContext::NonMutatingUse(NonMutatingUseContext::Move) => true,
164+
_ => false
165+
};
166+
if is_consume {
167+
let base_ty = proj.base.ty(self.fx.mir, cx.tcx());
168+
let base_ty = self.fx.monomorphize(&base_ty);
169+
170+
// ZSTs don't require any actual memory access.
171+
let elem_ty = base_ty
172+
.projection_ty(cx.tcx(), &proj.elem)
173+
.ty;
174+
let elem_ty = self.fx.monomorphize(&elem_ty);
175+
if cx.layout_of(elem_ty).is_zst() {
176+
return;
190177
}
191178

192-
// A deref projection only reads the pointer, never needs the place.
193-
if let mir::ProjectionElem::Deref = proj.elem {
194-
return self.visit_place(
195-
&proj.base,
196-
PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy),
197-
location
198-
);
179+
if let mir::ProjectionElem::Field(..) = proj.elem {
180+
let layout = cx.layout_of(base_ty.ty);
181+
if cx.is_backend_immediate(layout) || cx.is_backend_scalar_pair(layout) {
182+
// Recurse with the same context, instead of `Projection`,
183+
// potentially stopping at non-operand projections,
184+
// which would trigger `not_ssa` on locals.
185+
self.visit_place(&proj.base, context, location);
186+
return;
187+
}
199188
}
200-
201-
context = if context.is_mutating_use() {
202-
PlaceContext::MutatingUse(MutatingUseContext::Projection)
203-
} else {
204-
PlaceContext::NonMutatingUse(NonMutatingUseContext::Projection)
205-
};
206189
}
207190

208-
// Default base visit behavior
209-
if let mir::PlaceBase::Local(local) = place_base {
210-
self.visit_local(local, context, location);
191+
// A deref projection only reads the pointer, never needs the place.
192+
if let mir::ProjectionElem::Deref = proj.elem {
193+
return self.visit_place(
194+
&proj.base,
195+
PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy),
196+
location
197+
);
211198
}
212-
});
199+
}
200+
201+
self.super_place(place, context, location);
213202
}
214203

215204
fn visit_local(&mut self,

src/librustc_mir/hair/constant.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,6 @@ crate fn lit_to_const<'a, 'gcx, 'tcx>(
3434
let allocation = tcx.intern_const_alloc(allocation);
3535
ConstValue::Slice { data: allocation, start: 0, end: s.len() }
3636
},
37-
LitKind::Err(ref s) => {
38-
let s = s.as_str();
39-
let allocation = Allocation::from_byte_aligned_bytes(s.as_bytes());
40-
let allocation = tcx.intern_const_alloc(allocation);
41-
return Ok(tcx.mk_const(ty::Const {
42-
val: ConstValue::Slice{ data: allocation, start: 0, end: s.len() },
43-
ty: tcx.types.err,
44-
}));
45-
},
4637
LitKind::ByteStr(ref data) => {
4738
let id = tcx.allocate_bytes(data);
4839
ConstValue::Scalar(Scalar::Ptr(id.into()))
@@ -66,6 +57,7 @@ crate fn lit_to_const<'a, 'gcx, 'tcx>(
6657
}
6758
LitKind::Bool(b) => ConstValue::Scalar(Scalar::from_bool(b)),
6859
LitKind::Char(c) => ConstValue::Scalar(Scalar::from_char(c)),
60+
LitKind::Err(_) => unreachable!(),
6961
};
7062
Ok(tcx.mk_const(ty::Const { val: lit, ty }))
7163
}

src/libstd/f32.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ impl f32 {
188188
if self.is_nan() {
189189
NAN
190190
} else {
191-
unsafe { intrinsics::copysignf32(1.0, self) }
191+
1.0_f32.copysign(self)
192192
}
193193
}
194194

src/libstd/f64.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ impl f64 {
166166
if self.is_nan() {
167167
NAN
168168
} else {
169-
unsafe { intrinsics::copysignf64(1.0, self) }
169+
1.0_f64.copysign(self)
170170
}
171171
}
172172

src/libstd/primitive_docs.rs

+4
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,10 @@ mod prim_str { }
683683
/// assert_eq!(tuple.2, 'c');
684684
/// ```
685685
///
686+
/// The sequential nature of the tuple applies to its implementations of various
687+
/// traits. For example, in `PartialOrd` and `Ord`, the elements are compared
688+
/// sequentially until the first non-equal set is found.
689+
///
686690
/// For more about tuples, see [the book](../book/ch03-02-data-types.html#the-tuple-type).
687691
///
688692
/// # Trait implementations

src/libsyntax/ast.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1368,7 +1368,7 @@ pub enum LitKind {
13681368
FloatUnsuffixed(Symbol),
13691369
/// A boolean literal.
13701370
Bool(bool),
1371-
/// A recovered character literal that contains mutliple `char`s, most likely a typo.
1371+
/// Placeholder for a literal that wasn't well-formed in some way.
13721372
Err(Symbol),
13731373
}
13741374

@@ -1406,10 +1406,10 @@ impl LitKind {
14061406
| LitKind::ByteStr(..)
14071407
| LitKind::Byte(..)
14081408
| LitKind::Char(..)
1409-
| LitKind::Err(..)
14101409
| LitKind::Int(_, LitIntType::Unsuffixed)
14111410
| LitKind::FloatUnsuffixed(..)
1412-
| LitKind::Bool(..) => true,
1411+
| LitKind::Bool(..)
1412+
| LitKind::Err(..) => true,
14131413
// suffixed variants
14141414
LitKind::Int(_, LitIntType::Signed(..))
14151415
| LitKind::Int(_, LitIntType::Unsigned(..))

src/libsyntax/attr/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -735,9 +735,9 @@ pub fn inject(mut krate: ast::Crate, parse_sess: &ParseSess, attrs: &[String]) -
735735
raw_attr.clone(),
736736
);
737737

738-
let start_span = parser.span;
738+
let start_span = parser.token.span;
739739
let (path, tokens) = panictry!(parser.parse_meta_item_unrestricted());
740-
let end_span = parser.span;
740+
let end_span = parser.token.span;
741741
if parser.token != token::Eof {
742742
parse_sess.span_diagnostic
743743
.span_err(start_span.to(end_span), "invalid crate attribute");

src/libsyntax/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl<'a> StripUnconfigured<'a> {
121121
let mut expanded_attrs = Vec::with_capacity(1);
122122

123123
while !parser.check(&token::CloseDelim(token::Paren)) {
124-
let lo = parser.span.lo();
124+
let lo = parser.token.span.lo();
125125
let (path, tokens) = parser.parse_meta_item_unrestricted()?;
126126
expanded_attrs.push((path, tokens, parser.prev_span.with_lo(lo)));
127127
parser.expect_one_of(&[token::Comma], &[token::CloseDelim(token::Paren)])?;

src/libsyntax/ext/expand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ impl<'a> Parser<'a> {
10411041
let msg = format!("macro expansion ignores token `{}` and any following",
10421042
self.this_token_to_string());
10431043
// Avoid emitting backtrace info twice.
1044-
let def_site_span = self.span.with_ctxt(SyntaxContext::empty());
1044+
let def_site_span = self.token.span.with_ctxt(SyntaxContext::empty());
10451045
let mut err = self.diagnostic().struct_span_err(def_site_span, &msg);
10461046
err.span_label(span, "caused by the macro expansion here");
10471047
let msg = format!(

src/libsyntax/ext/source_util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ pub fn expand_include<'cx>(cx: &'cx mut ExtCtxt<'_>, sp: Span, tts: &[tokenstrea
105105
while self.p.token != token::Eof {
106106
match panictry!(self.p.parse_item()) {
107107
Some(item) => ret.push(item),
108-
None => self.p.diagnostic().span_fatal(self.p.span,
108+
None => self.p.diagnostic().span_fatal(self.p.token.span,
109109
&format!("expected item, found `{}`",
110110
self.p.this_token_to_string()))
111111
.raise()

src/libsyntax/ext/tt/macro_parser.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ pub fn parse(
675675
//
676676
// This MatcherPos instance is allocated on the stack. All others -- and
677677
// there are frequently *no* others! -- are allocated on the heap.
678-
let mut initial = initial_matcher_pos(ms, parser.span);
678+
let mut initial = initial_matcher_pos(ms, parser.token.span);
679679
let mut cur_items = smallvec![MatcherPosHandle::Ref(&mut initial)];
680680
let mut next_items = Vec::new();
681681

@@ -721,15 +721,15 @@ pub fn parse(
721721
return nameize(sess, ms, matches);
722722
} else if eof_items.len() > 1 {
723723
return Error(
724-
parser.span,
724+
parser.token.span,
725725
"ambiguity: multiple successful parses".to_string(),
726726
);
727727
} else {
728728
return Failure(
729-
Token::new(token::Eof, if parser.span.is_dummy() {
730-
parser.span
729+
Token::new(token::Eof, if parser.token.span.is_dummy() {
730+
parser.token.span
731731
} else {
732-
sess.source_map().next_point(parser.span)
732+
sess.source_map().next_point(parser.token.span)
733733
}),
734734
"missing tokens in macro arguments",
735735
);
@@ -753,7 +753,7 @@ pub fn parse(
753753
.join(" or ");
754754

755755
return Error(
756-
parser.span,
756+
parser.token.span,
757757
format!(
758758
"local ambiguity: multiple parsing options: {}",
759759
match next_items.len() {
@@ -927,7 +927,7 @@ fn parse_nt<'a>(p: &mut Parser<'a>, sp: Span, name: Symbol) -> Nonterminal {
927927
sym::ty => token::NtTy(panictry!(p.parse_ty())),
928928
// this could be handled like a token, since it is one
929929
sym::ident => if let Some((name, is_raw)) = get_macro_name(&p.token) {
930-
let span = p.span;
930+
let span = p.token.span;
931931
p.bump();
932932
token::NtIdent(Ident::new(name, span), is_raw)
933933
} else {

src/libsyntax/ext/tt/macro_rules.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl<'a> ParserAnyMacro<'a> {
4747
let fragment = panictry!(parser.parse_ast_fragment(kind, true).map_err(|mut e| {
4848
if parser.token == token::Eof && e.message().ends_with(", found `<eof>`") {
4949
if !e.span.is_dummy() { // early end of macro arm (#52866)
50-
e.replace_span_with(parser.sess.source_map().next_point(parser.span));
50+
e.replace_span_with(parser.sess.source_map().next_point(parser.token.span));
5151
}
5252
let msg = &e.message[0];
5353
e.message[0] = (
@@ -63,7 +63,7 @@ impl<'a> ParserAnyMacro<'a> {
6363
if parser.sess.source_map().span_to_filename(arm_span).is_real() {
6464
e.span_label(arm_span, "in this macro arm");
6565
}
66-
} else if !parser.sess.source_map().span_to_filename(parser.span).is_real() {
66+
} else if !parser.sess.source_map().span_to_filename(parser.token.span).is_real() {
6767
e.span_label(site_span, "in this macro invocation");
6868
}
6969
e

src/libsyntax/mut_visit.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,6 @@ pub fn noop_visit_expr<T: MutVisitor>(Expr { node, id, span, attrs }: &mut Expr,
11011101
vis.visit_expr(rhs);
11021102
}
11031103
ExprKind::Unary(_unop, ohs) => vis.visit_expr(ohs),
1104-
ExprKind::Lit(_lit) => {}
11051104
ExprKind::Cast(expr, ty) => {
11061105
vis.visit_expr(expr);
11071106
vis.visit_ty(ty);
@@ -1225,7 +1224,7 @@ pub fn noop_visit_expr<T: MutVisitor>(Expr { node, id, span, attrs }: &mut Expr,
12251224
}
12261225
ExprKind::Try(expr) => vis.visit_expr(expr),
12271226
ExprKind::TryBlock(body) => vis.visit_block(body),
1228-
ExprKind::Err => {}
1227+
ExprKind::Lit(_) | ExprKind::Err => {}
12291228
}
12301229
vis.visit_id(id);
12311230
vis.visit_span(span);

0 commit comments

Comments
 (0)