Skip to content

Commit 8652177

Browse files
author
The Miri Cronjob Bot
committed
Merge from rustc
2 parents 70628f8 + f4f0faf commit 8652177

File tree

350 files changed

+3526
-1195
lines changed

Some content is hidden

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

350 files changed

+3526
-1195
lines changed

.gitattributes

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
*.cpp rust
55
*.h rust
66
*.rs rust diff=rust
7-
*.fixed linguist-language=Rust -merge
8-
*.mir linguist-language=Rust -merge
9-
*.stderr -merge
10-
*.stdout -merge
7+
*.fixed linguist-language=Rust
8+
*.mir linguist-language=Rust
119
src/etc/installer/gfx/* binary
1210
src/vendor/** -text
1311
Cargo.lock linguist-generated=false

compiler/rustc_ast/src/util/comments/tests.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg_attr(not(bootstrap), allow(rustc::symbol_intern_string_literal))]
2+
13
use rustc_span::create_default_session_globals_then;
24

35
use super::*;

compiler/rustc_ast_passes/src/feature_gate.rs

-5
Original file line numberDiff line numberDiff line change
@@ -511,11 +511,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
511511
"you can write `if matches!(<expr>, <pattern>)` instead of `if let <pattern> = <expr>`"
512512
);
513513
gate_all!(let_chains, "`let` expressions in this position are unstable");
514-
gate_all!(
515-
async_closure,
516-
"async closures are unstable",
517-
"to use an async block, remove the `||`: `async {`"
518-
);
519514
gate_all!(
520515
async_trait_bounds,
521516
"`async` trait bounds are unstable",

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ use super::debuginfo::{
1717
DebugEmissionKind, DebugNameTableKind,
1818
};
1919

20-
pub type Bool = c_uint;
20+
/// In the LLVM-C API, boolean values are passed as `typedef int LLVMBool`,
21+
/// which has a different ABI from Rust or C++ `bool`.
22+
pub type Bool = c_int;
2123

2224
pub const True: Bool = 1 as Bool;
2325
pub const False: Bool = 0 as Bool;

compiler/rustc_error_codes/src/error_codes/E0307.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,10 @@ impl Trait for Foo {
6565
```
6666

6767
The nightly feature [Arbitrary self types][AST] extends the accepted
68-
set of receiver types to also include any type that can dereference to
69-
`Self`:
68+
set of receiver types to also include any type that implements the
69+
`Receiver` trait and can follow its chain of `Target` types to `Self`.
70+
There's a blanket implementation of `Receiver` for `T: Deref`, so any
71+
type which dereferences to `Self` can be used.
7072

7173
```
7274
#![feature(arbitrary_self_types)]

compiler/rustc_error_codes/src/error_codes/E0708.md

-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
Erroneous code example:
66

77
```edition2018
8-
#![feature(async_closure)]
9-
108
fn main() {
119
let add_one = async |num: u8| {
1210
num + 1
@@ -18,8 +16,6 @@ fn main() {
1816
version, you can use successfully by using move:
1917

2018
```edition2018
21-
#![feature(async_closure)]
22-
2319
fn main() {
2420
let add_one = async move |num: u8| { // ok!
2521
num + 1

compiler/rustc_errors/src/lib.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ mod styled_buffer;
9494
mod tests;
9595
pub mod translation;
9696

97-
pub type PErr<'a> = Diag<'a>;
98-
pub type PResult<'a, T> = Result<T, PErr<'a>>;
97+
pub type PResult<'a, T> = Result<T, Diag<'a>>;
9998

10099
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
101100

@@ -576,6 +575,10 @@ pub enum StashKey {
576575
UndeterminedMacroResolution,
577576
/// Used by `Parser::maybe_recover_trailing_expr`
578577
ExprInPat,
578+
/// If in the parser we detect a field expr with turbofish generic params it's possible that
579+
/// it's a method call without parens. If later on in `hir_typeck` we find out that this is
580+
/// the case we suppress this message and we give a better suggestion.
581+
GenericInFieldExpr,
579582
}
580583

581584
fn default_track_diagnostic<R>(diag: DiagInner, f: &mut dyn FnMut(DiagInner) -> R) -> R {

compiler/rustc_feature/src/accepted.rs

+2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ declare_features! (
7272
(accepted, associated_types, "1.0.0", None),
7373
/// Allows free and inherent `async fn`s, `async` blocks, and `<expr>.await` expressions.
7474
(accepted, async_await, "1.39.0", Some(50547)),
75+
/// Allows `async || body` closures.
76+
(accepted, async_closure, "CURRENT_RUSTC_VERSION", Some(62290)),
7577
/// Allows async functions to be declared, implemented, and used in traits.
7678
(accepted, async_fn_in_trait, "1.75.0", Some(91611)),
7779
/// Allows all literals in attribute lists and values of key-value pairs.

compiler/rustc_feature/src/unstable.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,8 @@ declare_features! (
388388
(unstable, associated_const_equality, "1.58.0", Some(92827)),
389389
/// Allows associated type defaults.
390390
(unstable, associated_type_defaults, "1.2.0", Some(29661)),
391-
/// Allows `async || body` closures.
392-
(unstable, async_closure, "1.37.0", Some(62290)),
391+
/// Allows async functions to be called from `dyn Trait`.
392+
(incomplete, async_fn_in_dyn_trait, "CURRENT_RUSTC_VERSION", Some(133119)),
393393
/// Allows `#[track_caller]` on async functions.
394394
(unstable, async_fn_track_caller, "1.73.0", Some(110011)),
395395
/// Allows `for await` loops.

compiler/rustc_hir/src/tests.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg_attr(not(bootstrap), allow(rustc::symbol_intern_string_literal))]
2+
13
use rustc_data_structures::stable_hasher::Hash64;
24
use rustc_span::def_id::{DefPathHash, StableCrateId};
35
use rustc_span::edition::Edition;

compiler/rustc_hir_analysis/messages.ftl

+2-2
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,10 @@ hir_analysis_invalid_generic_receiver_ty_help =
241241
use a concrete type such as `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
242242
243243
hir_analysis_invalid_receiver_ty = invalid `self` parameter type: `{$receiver_ty}`
244-
.note = type of `self` must be `Self` or a type that dereferences to it
244+
.note = type of `self` must be `Self` or some type implementing `Receiver`
245245
246246
hir_analysis_invalid_receiver_ty_help =
247-
consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
247+
consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
248248
249249
hir_analysis_invalid_union_field =
250250
field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union

compiler/rustc_hir_analysis/src/autoderef.rs

+28-9
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ pub enum AutoderefKind {
1818
/// A type which must dispatch to a `Deref` implementation.
1919
Overloaded,
2020
}
21-
2221
struct AutoderefSnapshot<'tcx> {
2322
at_start: bool,
2423
reached_recursion_limit: bool,
@@ -27,6 +26,10 @@ struct AutoderefSnapshot<'tcx> {
2726
obligations: PredicateObligations<'tcx>,
2827
}
2928

29+
/// Recursively dereference a type, considering both built-in
30+
/// dereferences (`*`) and the `Deref` trait.
31+
/// Although called `Autoderef` it can be configured to use the
32+
/// `Receiver` trait instead of the `Deref` trait.
3033
pub struct Autoderef<'a, 'tcx> {
3134
// Meta infos:
3235
infcx: &'a InferCtxt<'tcx>,
@@ -39,6 +42,7 @@ pub struct Autoderef<'a, 'tcx> {
3942

4043
// Configurations:
4144
include_raw_pointers: bool,
45+
use_receiver_trait: bool,
4246
silence_errors: bool,
4347
}
4448

@@ -69,6 +73,10 @@ impl<'a, 'tcx> Iterator for Autoderef<'a, 'tcx> {
6973
}
7074

7175
// Otherwise, deref if type is derefable:
76+
// NOTE: in the case of self.use_receiver_trait = true, you might think it would
77+
// be better to skip this clause and use the Overloaded case only, since &T
78+
// and &mut T implement Receiver. But built-in derefs apply equally to Receiver
79+
// and Deref, and this has benefits for const and the emitted MIR.
7280
let (kind, new_ty) =
7381
if let Some(ty) = self.state.cur_ty.builtin_deref(self.include_raw_pointers) {
7482
debug_assert_eq!(ty, self.infcx.resolve_vars_if_possible(ty));
@@ -111,7 +119,7 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> {
111119
body_def_id: LocalDefId,
112120
span: Span,
113121
base_ty: Ty<'tcx>,
114-
) -> Autoderef<'a, 'tcx> {
122+
) -> Self {
115123
Autoderef {
116124
infcx,
117125
span,
@@ -125,6 +133,7 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> {
125133
reached_recursion_limit: false,
126134
},
127135
include_raw_pointers: false,
136+
use_receiver_trait: false,
128137
silence_errors: false,
129138
}
130139
}
@@ -137,8 +146,13 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> {
137146
return None;
138147
}
139148

140-
// <ty as Deref>
141-
let trait_ref = ty::TraitRef::new(tcx, tcx.lang_items().deref_trait()?, [ty]);
149+
// <ty as Deref>, or whatever the equivalent trait is that we've been asked to walk.
150+
let (trait_def_id, trait_target_def_id) = if self.use_receiver_trait {
151+
(tcx.lang_items().receiver_trait()?, tcx.lang_items().receiver_target()?)
152+
} else {
153+
(tcx.lang_items().deref_trait()?, tcx.lang_items().deref_target()?)
154+
};
155+
let trait_ref = ty::TraitRef::new(tcx, trait_def_id, [ty]);
142156
let cause = traits::ObligationCause::misc(self.span, self.body_id);
143157
let obligation = traits::Obligation::new(
144158
tcx,
@@ -151,11 +165,8 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> {
151165
return None;
152166
}
153167

154-
let (normalized_ty, obligations) = self.structurally_normalize(Ty::new_projection(
155-
tcx,
156-
tcx.lang_items().deref_target()?,
157-
[ty],
158-
))?;
168+
let (normalized_ty, obligations) =
169+
self.structurally_normalize(Ty::new_projection(tcx, trait_target_def_id, [ty]))?;
159170
debug!("overloaded_deref_ty({:?}) = ({:?}, {:?})", ty, normalized_ty, obligations);
160171
self.state.obligations.extend(obligations);
161172

@@ -234,6 +245,14 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> {
234245
self
235246
}
236247

248+
/// Use `core::ops::Receiver` and `core::ops::Receiver::Target` as
249+
/// the trait and associated type to iterate, instead of
250+
/// `core::ops::Deref` and `core::ops::Deref::Target`
251+
pub fn use_receiver_trait(mut self) -> Self {
252+
self.use_receiver_trait = true;
253+
self
254+
}
255+
237256
pub fn silence_errors(mut self) -> Self {
238257
self.silence_errors = true;
239258
self

0 commit comments

Comments
 (0)