Skip to content

Commit f36251f

Browse files
committed
Auto merge of rust-lang#3232 - rust-lang:rustup-2023-12-19, r=saethlin
Automatic Rustup
2 parents 1929606 + 0f70ced commit f36251f

File tree

623 files changed

+10572
-5337
lines changed

Some content is hidden

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

623 files changed

+10572
-5337
lines changed

Cargo.lock

+7-1
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ dependencies = [
598598
"itertools",
599599
"quine-mc_cluskey",
600600
"regex",
601-
"regex-syntax 0.7.2",
601+
"regex-syntax 0.8.2",
602602
"rustc-semver",
603603
"semver",
604604
"serde",
@@ -3195,6 +3195,12 @@ version = "0.7.2"
31953195
source = "registry+https://github.com/rust-lang/crates.io-index"
31963196
checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78"
31973197

3198+
[[package]]
3199+
name = "regex-syntax"
3200+
version = "0.8.2"
3201+
source = "registry+https://github.com/rust-lang/crates.io-index"
3202+
checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
3203+
31983204
[[package]]
31993205
name = "remote-test-client"
32003206
version = "0.1.0"

RELEASES.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
Version 1.74.1 (2023-12-07)
2+
===========================
3+
4+
- [Resolved spurious STATUS_ACCESS_VIOLATIONs in LLVM](https://github.com/rust-lang/rust/pull/118464)
5+
- [Clarify guarantees for std::mem::discriminant](https://github.com/rust-lang/rust/pull/118006)
6+
- [Fix some subtyping-related regressions](https://github.com/rust-lang/rust/pull/116415)
7+
18
Version 1.74.0 (2023-11-16)
29
==========================
310

compiler/rustc_abi/src/layout.rs

+14-6
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ pub trait LayoutCalculator {
382382
*offset += this_offset;
383383
}
384384
}
385-
_ => {
385+
FieldsShape::Primitive | FieldsShape::Array { .. } | FieldsShape::Union(..) => {
386386
panic!("Layout of fields should be Arbitrary for variants")
387387
}
388388
}
@@ -600,7 +600,9 @@ pub trait LayoutCalculator {
600600
variant.size = new_ity_size;
601601
}
602602
}
603-
_ => panic!(),
603+
FieldsShape::Primitive | FieldsShape::Array { .. } | FieldsShape::Union(..) => {
604+
panic!("encountered a non-arbitrary layout during enum layout")
605+
}
604606
}
605607
}
606608
}
@@ -628,7 +630,7 @@ pub trait LayoutCalculator {
628630
let mut common_prim_initialized_in_all_variants = true;
629631
for (field_layouts, layout_variant) in iter::zip(variants, &layout_variants) {
630632
let FieldsShape::Arbitrary { ref offsets, .. } = layout_variant.fields else {
631-
panic!();
633+
panic!("encountered a non-arbitrary layout during enum layout");
632634
};
633635
// We skip *all* ZST here and later check if we are good in terms of alignment.
634636
// This lets us handle some cases involving aligned ZST.
@@ -681,7 +683,7 @@ pub trait LayoutCalculator {
681683
assert_eq!(memory_index.raw, [0, 1]);
682684
offsets
683685
}
684-
_ => panic!(),
686+
_ => panic!("encountered a non-arbitrary layout during enum layout"),
685687
};
686688
if pair_offsets[FieldIdx::new(0)] == Size::ZERO
687689
&& pair_offsets[FieldIdx::new(1)] == *offset
@@ -758,7 +760,9 @@ pub trait LayoutCalculator {
758760
Variants::Multiple { tag, tag_encoding, tag_field, .. } => {
759761
Variants::Multiple { tag, tag_encoding, tag_field, variants: best_layout.variants }
760762
}
761-
_ => panic!(),
763+
Variants::Single { .. } => {
764+
panic!("encountered a single-variant enum during multi-variant layout")
765+
}
762766
};
763767
Some(best_layout.layout)
764768
}
@@ -1154,7 +1158,11 @@ fn univariant<
11541158
assert_eq!(memory_index.raw, [0, 1]);
11551159
offsets
11561160
}
1157-
_ => panic!(),
1161+
FieldsShape::Primitive
1162+
| FieldsShape::Array { .. }
1163+
| FieldsShape::Union(..) => {
1164+
panic!("encountered a non-arbitrary layout during enum layout")
1165+
}
11581166
};
11591167
if offsets[i] == pair_offsets[FieldIdx::new(0)]
11601168
&& offsets[j] == pair_offsets[FieldIdx::new(1)]

compiler/rustc_ast/src/ast.rs

+22
Original file line numberDiff line numberDiff line change
@@ -2845,6 +2845,28 @@ impl Item {
28452845
pub fn span_with_attributes(&self) -> Span {
28462846
self.attrs.iter().fold(self.span, |acc, attr| acc.to(attr.span))
28472847
}
2848+
2849+
pub fn opt_generics(&self) -> Option<&Generics> {
2850+
match &self.kind {
2851+
ItemKind::ExternCrate(_)
2852+
| ItemKind::Use(_)
2853+
| ItemKind::Mod(_, _)
2854+
| ItemKind::ForeignMod(_)
2855+
| ItemKind::GlobalAsm(_)
2856+
| ItemKind::MacCall(_)
2857+
| ItemKind::MacroDef(_) => None,
2858+
ItemKind::Static(_) => None,
2859+
ItemKind::Const(i) => Some(&i.generics),
2860+
ItemKind::Fn(i) => Some(&i.generics),
2861+
ItemKind::TyAlias(i) => Some(&i.generics),
2862+
ItemKind::TraitAlias(generics, _)
2863+
| ItemKind::Enum(_, generics)
2864+
| ItemKind::Struct(_, generics)
2865+
| ItemKind::Union(_, generics) => Some(&generics),
2866+
ItemKind::Trait(i) => Some(&i.generics),
2867+
ItemKind::Impl(i) => Some(&i.generics),
2868+
}
2869+
}
28482870
}
28492871

28502872
/// `extern` qualifier on a function item or function type.

compiler/rustc_ast/src/util/classify.rs

+32-3
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,44 @@ pub fn expr_trailing_brace(mut expr: &ast::Expr) -> Option<&ast::Expr> {
4040
| Range(_, Some(e), _)
4141
| Ret(Some(e))
4242
| Unary(_, e)
43-
| Yield(Some(e)) => {
43+
| Yield(Some(e))
44+
| Yeet(Some(e))
45+
| Become(e) => {
4446
expr = e;
4547
}
4648
Closure(closure) => {
4749
expr = &closure.body;
4850
}
4951
Gen(..) | Block(..) | ForLoop(..) | If(..) | Loop(..) | Match(..) | Struct(..)
50-
| TryBlock(..) | While(..) => break Some(expr),
51-
_ => break None,
52+
| TryBlock(..) | While(..) | ConstBlock(_) => break Some(expr),
53+
54+
// FIXME: These can end in `}`, but changing these would break stable code.
55+
InlineAsm(_) | OffsetOf(_, _) | MacCall(_) | IncludedBytes(_) | FormatArgs(_) => {
56+
break None;
57+
}
58+
59+
Break(_, None)
60+
| Range(_, None, _)
61+
| Ret(None)
62+
| Yield(None)
63+
| Array(_)
64+
| Call(_, _)
65+
| MethodCall(_)
66+
| Tup(_)
67+
| Lit(_)
68+
| Cast(_, _)
69+
| Type(_, _)
70+
| Await(_, _)
71+
| Field(_, _)
72+
| Index(_, _, _)
73+
| Underscore
74+
| Path(_, _)
75+
| Continue(_)
76+
| Repeat(_, _)
77+
| Paren(_)
78+
| Try(_)
79+
| Yeet(None)
80+
| Err => break None,
5281
}
5382
}
5483
}

compiler/rustc_ast/src/util/literal.rs

+30-44
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ impl LitKind {
7777
// new symbol because the string in the LitKind is different to the
7878
// string in the token.
7979
let s = symbol.as_str();
80+
// Vanilla strings are so common we optimize for the common case where no chars
81+
// requiring special behaviour are present.
8082
let symbol = if s.contains(['\\', '\r']) {
8183
let mut buf = String::with_capacity(s.len());
8284
let mut error = Ok(());
@@ -104,27 +106,20 @@ impl LitKind {
104106
LitKind::Str(symbol, ast::StrStyle::Cooked)
105107
}
106108
token::StrRaw(n) => {
107-
// Ditto.
108-
let s = symbol.as_str();
109-
let symbol =
110-
if s.contains('\r') {
111-
let mut buf = String::with_capacity(s.len());
112-
let mut error = Ok(());
113-
unescape_literal(s, Mode::RawStr, &mut |_, unescaped_char| {
114-
match unescaped_char {
115-
Ok(c) => buf.push(c),
116-
Err(err) => {
117-
if err.is_fatal() {
118-
error = Err(LitError::LexerError);
119-
}
120-
}
109+
// Raw strings have no escapes, so we only need to check for invalid chars, and we
110+
// can reuse the symbol on success.
111+
let mut error = Ok(());
112+
unescape_literal(symbol.as_str(), Mode::RawStr, &mut |_, unescaped_char| {
113+
match unescaped_char {
114+
Ok(_) => {}
115+
Err(err) => {
116+
if err.is_fatal() {
117+
error = Err(LitError::LexerError);
121118
}
122-
});
123-
error?;
124-
Symbol::intern(&buf)
125-
} else {
126-
symbol
127-
};
119+
}
120+
}
121+
});
122+
error?;
128123
LitKind::Str(symbol, ast::StrStyle::Raw(n))
129124
}
130125
token::ByteStr => {
@@ -143,25 +138,19 @@ impl LitKind {
143138
LitKind::ByteStr(buf.into(), StrStyle::Cooked)
144139
}
145140
token::ByteStrRaw(n) => {
141+
// Raw strings have no escapes, so we only need to check for invalid chars, and we
142+
// can convert the symbol directly to a `Lrc<u8>` on success.
146143
let s = symbol.as_str();
147-
let bytes = if s.contains('\r') {
148-
let mut buf = Vec::with_capacity(s.len());
149-
let mut error = Ok(());
150-
unescape_literal(s, Mode::RawByteStr, &mut |_, c| match c {
151-
Ok(c) => buf.push(byte_from_char(c)),
152-
Err(err) => {
153-
if err.is_fatal() {
154-
error = Err(LitError::LexerError);
155-
}
144+
let mut error = Ok(());
145+
unescape_literal(s, Mode::RawByteStr, &mut |_, c| match c {
146+
Ok(_) => {}
147+
Err(err) => {
148+
if err.is_fatal() {
149+
error = Err(LitError::LexerError);
156150
}
157-
});
158-
error?;
159-
buf
160-
} else {
161-
symbol.to_string().into_bytes()
162-
};
163-
164-
LitKind::ByteStr(bytes.into(), StrStyle::Raw(n))
151+
}
152+
});
153+
LitKind::ByteStr(s.to_owned().into_bytes().into(), StrStyle::Raw(n))
165154
}
166155
token::CStr => {
167156
let s = symbol.as_str();
@@ -172,7 +161,6 @@ impl LitKind {
172161
error = Err(LitError::NulInCStr(span));
173162
}
174163
Ok(CStrUnit::Byte(b)) => buf.push(b),
175-
Ok(CStrUnit::Char(c)) if c.len_utf8() == 1 => buf.push(c as u8),
176164
Ok(CStrUnit::Char(c)) => {
177165
buf.extend_from_slice(c.encode_utf8(&mut [0; 4]).as_bytes())
178166
}
@@ -187,25 +175,23 @@ impl LitKind {
187175
LitKind::CStr(buf.into(), StrStyle::Cooked)
188176
}
189177
token::CStrRaw(n) => {
178+
// Raw strings have no escapes, so we only need to check for invalid chars, and we
179+
// can convert the symbol directly to a `Lrc<u8>` on success.
190180
let s = symbol.as_str();
191-
let mut buf = Vec::with_capacity(s.len());
192181
let mut error = Ok(());
193182
unescape_c_string(s, Mode::RawCStr, &mut |span, c| match c {
194183
Ok(CStrUnit::Byte(0) | CStrUnit::Char('\0')) => {
195184
error = Err(LitError::NulInCStr(span));
196185
}
197-
Ok(CStrUnit::Byte(b)) => buf.push(b),
198-
Ok(CStrUnit::Char(c)) if c.len_utf8() == 1 => buf.push(c as u8),
199-
Ok(CStrUnit::Char(c)) => {
200-
buf.extend_from_slice(c.encode_utf8(&mut [0; 4]).as_bytes())
201-
}
186+
Ok(_) => {}
202187
Err(err) => {
203188
if err.is_fatal() {
204189
error = Err(LitError::LexerError);
205190
}
206191
}
207192
});
208193
error?;
194+
let mut buf = s.to_owned().into_bytes();
209195
buf.push(0);
210196
LitKind::CStr(buf.into(), StrStyle::Raw(n))
211197
}

compiler/rustc_ast_lowering/src/asm.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
336336
hir::InlineAsmOperand::Const { .. }
337337
| hir::InlineAsmOperand::SymFn { .. }
338338
| hir::InlineAsmOperand::SymStatic { .. } => {
339-
unreachable!()
339+
unreachable!("{op:?} is not a register operand");
340340
}
341341
};
342342

@@ -380,7 +380,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
380380
{
381381
reg_sym.as_str()
382382
} else {
383-
unreachable!();
383+
unreachable!("{op:?} is not a register operand");
384384
}
385385
};
386386

0 commit comments

Comments
 (0)