Skip to content

Commit 02eb9a5

Browse files
committed
Auto merge of #57075 - Centril:rollup, r=Centril
Rollup of 10 pull requests Successful merges: - #56188 (enum type instead of variant suggestion unification ) - #56916 (Fix mutable references in `static mut`) - #56917 (Simplify MIR generation for logical operations) - #56953 (Mark tuple structs as live if their constructors are used) - #56964 (Remove `TokenStream::JointTree`.) - #56966 (Correct strings for raw pointer deref and array access suggestions) - #56999 (AST/HIR: Introduce `ExprKind::Err` for better error recovery in the front-end) - #57020 (Point to cause of `fn` expected return type) - #57032 (fix deprecation warnings in liballoc benches) - #57053 (Fix alignment for array indexing) Failed merges: r? @ghost
2 parents ddab10a + 35fa309 commit 02eb9a5

File tree

167 files changed

+1248
-585
lines changed

Some content is hidden

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

167 files changed

+1248
-585
lines changed

Diff for: Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ dependencies = [
1818
"compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
1919
"core 0.0.0",
2020
"rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
21+
"rand_xorshift 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
2122
]
2223

2324
[[package]]

Diff for: src/liballoc/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ compiler_builtins = { version = "0.1.0", features = ['rustc-dep-of-std'] }
1515

1616
[dev-dependencies]
1717
rand = "0.6"
18+
rand_xorshift = "0.1"
1819

1920
[[test]]
2021
name = "collectionstests"

Diff for: src/liballoc/benches/btree/map.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use std::iter::Iterator;
1313
use std::vec::Vec;
1414
use std::collections::BTreeMap;
15-
use rand::{Rng, thread_rng};
15+
use rand::{Rng, seq::SliceRandom, thread_rng};
1616
use test::{Bencher, black_box};
1717

1818
macro_rules! map_insert_rand_bench {
@@ -78,7 +78,7 @@ macro_rules! map_find_rand_bench {
7878
map.insert(k, k);
7979
}
8080

81-
rng.shuffle(&mut keys);
81+
keys.shuffle(&mut rng);
8282

8383
// measure
8484
let mut i = 0;

Diff for: src/liballoc/benches/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#![feature(test)]
1414

1515
extern crate rand;
16+
extern crate rand_xorshift;
1617
extern crate test;
1718

1819
mod btree;

Diff for: src/liballoc/benches/slice.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ use rand::{thread_rng};
1212
use std::mem;
1313
use std::ptr;
1414

15-
use rand::{Rng, SeedableRng, XorShiftRng};
15+
use rand::{Rng, SeedableRng};
1616
use rand::distributions::{Standard, Alphanumeric};
17+
use rand_xorshift::XorShiftRng;
1718
use test::{Bencher, black_box};
1819

1920
#[bench]

Diff for: src/liballoc/benches/str.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,11 @@ make_test!(split_a_str, s, s.split("a").count());
274274
make_test!(trim_ascii_char, s, {
275275
s.trim_matches(|c: char| c.is_ascii())
276276
});
277-
make_test!(trim_left_ascii_char, s, {
278-
s.trim_left_matches(|c: char| c.is_ascii())
277+
make_test!(trim_start_ascii_char, s, {
278+
s.trim_start_matches(|c: char| c.is_ascii())
279279
});
280-
make_test!(trim_right_ascii_char, s, {
281-
s.trim_right_matches(|c: char| c.is_ascii())
280+
make_test!(trim_end_ascii_char, s, {
281+
s.trim_end_matches(|c: char| c.is_ascii())
282282
});
283283

284284
make_test!(find_underscore_char, s, s.find('_'));

Diff for: src/librustc/cfg/construct.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,8 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
402402

403403
hir::ExprKind::Closure(..) |
404404
hir::ExprKind::Lit(..) |
405-
hir::ExprKind::Path(_) => {
405+
hir::ExprKind::Path(_) |
406+
hir::ExprKind::Err => {
406407
self.straightline(expr, pred, None::<hir::Expr>.iter())
407408
}
408409
}

Diff for: src/librustc/hir/intravisit.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
11091109
ExprKind::Yield(ref subexpression) => {
11101110
visitor.visit_expr(subexpression);
11111111
}
1112+
ExprKind::Err => {}
11121113
}
11131114
}
11141115

Diff for: src/librustc/hir/lowering.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -2719,7 +2719,6 @@ impl<'a> LoweringContext<'a> {
27192719
rules: self.lower_block_check_mode(&b.rules),
27202720
span: b.span,
27212721
targeted_by_break,
2722-
recovered: b.recovered,
27232722
})
27242723
}
27252724

@@ -3791,7 +3790,6 @@ impl<'a> LoweringContext<'a> {
37913790
rules: hir::DefaultBlock,
37923791
span,
37933792
targeted_by_break: false,
3794-
recovered: blk.recovered,
37953793
});
37963794
P(self.expr_block(blk, ThinVec::new()))
37973795
}
@@ -4127,6 +4125,8 @@ impl<'a> LoweringContext<'a> {
41274125
hir::ExprKind::Yield(P(expr))
41284126
}
41294127

4128+
ExprKind::Err => hir::ExprKind::Err,
4129+
41304130
// Desugar `ExprIfLet`
41314131
// from: `if let <pat> = <sub_expr> <body> [<else_opt>]`
41324132
ExprKind::IfLet(ref pats, ref sub_expr, ref body, ref else_opt) => {
@@ -4831,7 +4831,6 @@ impl<'a> LoweringContext<'a> {
48314831
rules: hir::DefaultBlock,
48324832
span,
48334833
targeted_by_break: false,
4834-
recovered: false,
48354834
}
48364835
}
48374836

Diff for: src/librustc/hir/mod.rs

+16-7
Original file line numberDiff line numberDiff line change
@@ -817,11 +817,6 @@ pub struct Block {
817817
/// break out of this block early.
818818
/// Used by `'label: {}` blocks and by `catch` statements.
819819
pub targeted_by_break: bool,
820-
/// If true, don't emit return value type errors as the parser had
821-
/// to recover from a parse error so this block will not have an
822-
/// appropriate type. A parse error will have been emitted so the
823-
/// compilation will never succeed if this is true.
824-
pub recovered: bool,
825820
}
826821

827822
#[derive(Clone, RustcEncodable, RustcDecodable)]
@@ -1372,6 +1367,7 @@ impl Expr {
13721367
ExprKind::Struct(..) => ExprPrecedence::Struct,
13731368
ExprKind::Repeat(..) => ExprPrecedence::Repeat,
13741369
ExprKind::Yield(..) => ExprPrecedence::Yield,
1370+
ExprKind::Err => ExprPrecedence::Err,
13751371
}
13761372
}
13771373

@@ -1422,7 +1418,8 @@ impl Expr {
14221418
ExprKind::AddrOf(..) |
14231419
ExprKind::Binary(..) |
14241420
ExprKind::Yield(..) |
1425-
ExprKind::Cast(..) => {
1421+
ExprKind::Cast(..) |
1422+
ExprKind::Err => {
14261423
false
14271424
}
14281425
}
@@ -1535,6 +1532,9 @@ pub enum ExprKind {
15351532

15361533
/// A suspension point for generators. This is `yield <expr>` in Rust.
15371534
Yield(P<Expr>),
1535+
1536+
/// Placeholder for an expression that wasn't syntactically well formed in some way.
1537+
Err,
15381538
}
15391539

15401540
/// Optionally `Self`-qualified value/type path or associated extension.
@@ -1979,6 +1979,15 @@ pub enum FunctionRetTy {
19791979
Return(P<Ty>),
19801980
}
19811981

1982+
impl fmt::Display for FunctionRetTy {
1983+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1984+
match self {
1985+
Return(ref ty) => print::to_string(print::NO_ANN, |s| s.print_type(ty)).fmt(f),
1986+
DefaultReturn(_) => "()".fmt(f),
1987+
}
1988+
}
1989+
}
1990+
19821991
impl FunctionRetTy {
19831992
pub fn span(&self) -> Span {
19841993
match *self {
@@ -2119,7 +2128,7 @@ impl StructField {
21192128
/// Id of the whole enum lives in `Item`.
21202129
///
21212130
/// For structs: `NodeId` represents an Id of the structure's constructor, so it is not actually
2122-
/// used for `Struct`-structs (but still presents). Structures don't have an analogue of "Id of
2131+
/// used for `Struct`-structs (but still present). Structures don't have an analogue of "Id of
21232132
/// the variant itself" from enum variants.
21242133
/// Id of the whole struct lives in `Item`.
21252134
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]

Diff for: src/librustc/hir/print.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,9 @@ impl<'a> State<'a> {
440440
self.s.word("_")?;
441441
}
442442
hir::TyKind::Err => {
443-
self.s.word("?")?;
443+
self.popen()?;
444+
self.s.word("/*ERROR*/")?;
445+
self.pclose()?;
444446
}
445447
}
446448
self.end()
@@ -1550,6 +1552,11 @@ impl<'a> State<'a> {
15501552
self.word_space("yield")?;
15511553
self.print_expr_maybe_paren(&expr, parser::PREC_JUMP)?;
15521554
}
1555+
hir::ExprKind::Err => {
1556+
self.popen()?;
1557+
self.s.word("/*ERROR*/")?;
1558+
self.pclose()?;
1559+
}
15531560
}
15541561
self.ann.post(self, AnnNode::Expr(expr))?;
15551562
self.end()

Diff for: src/librustc/ich/impls_hir.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,6 @@ impl_stable_hash_for!(struct hir::Block {
420420
rules,
421421
span,
422422
targeted_by_break,
423-
recovered,
424423
});
425424

426425
impl_stable_hash_for!(struct hir::Pat {
@@ -602,7 +601,8 @@ impl_stable_hash_for!(enum hir::ExprKind {
602601
InlineAsm(asm, inputs, outputs),
603602
Struct(path, fields, base),
604603
Repeat(val, times),
605-
Yield(val)
604+
Yield(val),
605+
Err
606606
});
607607

608608
impl_stable_hash_for!(enum hir::LocalSource {

Diff for: src/librustc/lint/levels.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -232,24 +232,22 @@ impl<'a> LintLevelsBuilder<'a> {
232232
match item.node {
233233
ast::MetaItemKind::Word => {} // actual lint names handled later
234234
ast::MetaItemKind::NameValue(ref name_value) => {
235-
let gate_reasons = !self.sess.features_untracked().lint_reasons;
236235
if item.ident == "reason" {
237236
// found reason, reslice meta list to exclude it
238237
metas = &metas[0..metas.len()-1];
239238
// FIXME (#55112): issue unused-attributes lint if we thereby
240239
// don't have any lint names (`#[level(reason = "foo")]`)
241240
if let ast::LitKind::Str(rationale, _) = name_value.node {
242-
if gate_reasons {
241+
if !self.sess.features_untracked().lint_reasons {
243242
feature_gate::emit_feature_err(
244243
&self.sess.parse_sess,
245244
"lint_reasons",
246245
item.span,
247246
feature_gate::GateIssue::Language,
248247
"lint reasons are experimental"
249248
);
250-
} else {
251-
reason = Some(rationale);
252249
}
250+
reason = Some(rationale);
253251
} else {
254252
let mut err = bad_attr(name_value.span);
255253
err.help("reason must be a string literal");

0 commit comments

Comments
 (0)