Skip to content

Commit a289cfc

Browse files
committed
Auto merge of rust-lang#99462 - matthiaskrgr:rollup-ihhwaru, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang#98028 (Add E0790 as more specific variant of E0283) - rust-lang#99384 (use body's param-env when checking if type needs drop) - rust-lang#99401 (Avoid `Symbol` to `&str` conversions) - rust-lang#99419 (Stabilize `core::task::ready!`) - rust-lang#99435 (Revert "Stabilize $$ in Rust 1.63.0") - rust-lang#99438 (Improve suggestions for `NonZeroT` <- `T` coercion error) - rust-lang#99441 (Update mdbook) - rust-lang#99453 (:arrow_up: rust-analyzer) - rust-lang#99457 (use `par_for_each_in` in `par_body_owners` and `collect_crate_mono_items`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 8bd12e8 + e6904fc commit a289cfc

File tree

55 files changed

+705
-204
lines changed

Some content is hidden

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

55 files changed

+705
-204
lines changed

Cargo.lock

+7-38
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ version = "3.2.5"
634634
source = "registry+https://github.com/rust-lang/crates.io-index"
635635
checksum = "c11d40217d16aee8508cc8e5fde8b4ff24639758608e5374e731b53f85749fb9"
636636
dependencies = [
637-
"heck 0.4.0",
637+
"heck",
638638
"proc-macro-error",
639639
"proc-macro2",
640640
"quote",
@@ -1202,17 +1202,14 @@ checksum = "cd56b59865bce947ac5958779cfa508f6c3b9497cc762b7e24a12d11ccde2c4f"
12021202

12031203
[[package]]
12041204
name = "elasticlunr-rs"
1205-
version = "2.3.9"
1205+
version = "3.0.0"
12061206
source = "registry+https://github.com/rust-lang/crates.io-index"
1207-
checksum = "35622eb004c8f0c5e7e2032815f3314a93df0db30a1ce5c94e62c1ecc81e22b9"
1207+
checksum = "e6dae5cac90640734ee881bc5f21b6e5123f4e5235e52428db114abffc2391d6"
12081208
dependencies = [
1209-
"lazy_static",
12101209
"regex",
12111210
"serde",
12121211
"serde_derive",
12131212
"serde_json",
1214-
"strum",
1215-
"strum_macros",
12161213
]
12171214

12181215
[[package]]
@@ -1735,15 +1732,6 @@ dependencies = [
17351732
"rustc-std-workspace-core",
17361733
]
17371734

1738-
[[package]]
1739-
name = "heck"
1740-
version = "0.3.1"
1741-
source = "registry+https://github.com/rust-lang/crates.io-index"
1742-
checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205"
1743-
dependencies = [
1744-
"unicode-segmentation",
1745-
]
1746-
17471735
[[package]]
17481736
name = "heck"
17491737
version = "0.4.0"
@@ -2360,17 +2348,17 @@ dependencies = [
23602348

23612349
[[package]]
23622350
name = "mdbook"
2363-
version = "0.4.18"
2351+
version = "0.4.20"
23642352
source = "registry+https://github.com/rust-lang/crates.io-index"
2365-
checksum = "74612ae81a3e5ee509854049dfa4c7975ae033c06f5fc4735c7dfbe60ee2a39d"
2353+
checksum = "13cdad8057b09a519c6c63e6d7c93ea854f5d7fbfe284df864d5e1140d215a2d"
23662354
dependencies = [
23672355
"ammonia",
23682356
"anyhow",
23692357
"chrono",
23702358
"clap",
23712359
"clap_complete",
23722360
"elasticlunr-rs",
2373-
"env_logger 0.7.1",
2361+
"env_logger 0.9.0",
23742362
"handlebars",
23752363
"lazy_static",
23762364
"log",
@@ -2379,7 +2367,6 @@ dependencies = [
23792367
"pulldown-cmark",
23802368
"regex",
23812369
"serde",
2382-
"serde_derive",
23832370
"serde_json",
23842371
"shlex",
23852372
"tempfile",
@@ -3335,7 +3322,7 @@ dependencies = [
33353322
"difference",
33363323
"env_logger 0.9.0",
33373324
"futures 0.3.19",
3338-
"heck 0.4.0",
3325+
"heck",
33393326
"home",
33403327
"itertools",
33413328
"jsonrpc-core",
@@ -5134,24 +5121,6 @@ version = "0.10.0"
51345121
source = "registry+https://github.com/rust-lang/crates.io-index"
51355122
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
51365123

5137-
[[package]]
5138-
name = "strum"
5139-
version = "0.18.0"
5140-
source = "registry+https://github.com/rust-lang/crates.io-index"
5141-
checksum = "57bd81eb48f4c437cadc685403cad539345bf703d78e63707418431cecd4522b"
5142-
5143-
[[package]]
5144-
name = "strum_macros"
5145-
version = "0.18.0"
5146-
source = "registry+https://github.com/rust-lang/crates.io-index"
5147-
checksum = "87c85aa3f8ea653bfd3ddf25f7ee357ee4d204731f6aa9ad04002306f6e2774c"
5148-
dependencies = [
5149-
"heck 0.3.1",
5150-
"proc-macro2",
5151-
"quote",
5152-
"syn",
5153-
]
5154-
51555124
[[package]]
51565125
name = "syn"
51575126
version = "1.0.91"

compiler/rustc_ast_lowering/src/asm.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
145145
InlineAsmRegOrRegClass::Reg(s) => {
146146
asm::InlineAsmRegOrRegClass::Reg(if let Some(asm_arch) = asm_arch {
147147
asm::InlineAsmReg::parse(asm_arch, s).unwrap_or_else(|e| {
148-
let msg = format!("invalid register `{}`: {}", s.as_str(), e);
148+
let msg = format!("invalid register `{}`: {}", s, e);
149149
sess.struct_span_err(*op_sp, &msg).emit();
150150
asm::InlineAsmReg::Err
151151
})
@@ -156,7 +156,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
156156
InlineAsmRegOrRegClass::RegClass(s) => {
157157
asm::InlineAsmRegOrRegClass::RegClass(if let Some(asm_arch) = asm_arch {
158158
asm::InlineAsmRegClass::parse(asm_arch, s).unwrap_or_else(|e| {
159-
let msg = format!("invalid register class `{}`: {}", s.as_str(), e);
159+
let msg = format!("invalid register class `{}`: {}", s, e);
160160
sess.struct_span_err(*op_sp, &msg).emit();
161161
asm::InlineAsmRegClass::Err
162162
})

compiler/rustc_ast_passes/src/feature_gate.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ impl<'a> PostExpansionVisitor<'a> {
6262
let ast::StrLit { symbol_unescaped, span, .. } = abi;
6363

6464
if let ast::Const::Yes(_) = constness {
65-
match symbol_unescaped.as_str() {
65+
match symbol_unescaped {
6666
// Stable
67-
"Rust" | "C" => {}
67+
sym::Rust | sym::C => {}
6868
abi => gate_feature_post!(
6969
&self,
7070
const_extern_fn,

compiler/rustc_codegen_llvm/src/debuginfo/gdb.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub fn get_or_insert_gdb_debug_scripts_section_global<'ll>(cx: &CodegenCx<'ll, '
5555
// The initial byte `4` instructs GDB that the following pretty printer
5656
// is defined inline as opposed to in a standalone file.
5757
section_contents.extend_from_slice(b"\x04");
58-
let vis_name = format!("pretty-printer-{}-{}\n", crate_name.as_str(), index);
58+
let vis_name = format!("pretty-printer-{}-{}\n", crate_name, index);
5959
section_contents.extend_from_slice(vis_name.as_bytes());
6060
section_contents.extend_from_slice(&visualizer.src);
6161

compiler/rustc_data_structures/src/sync.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ cfg_if! {
146146
t.into_iter()
147147
}
148148

149-
pub fn par_for_each_in<T: IntoIterator>(t: T, for_each: impl Fn(T::Item) + Sync + Send) {
149+
pub fn par_for_each_in<T: IntoIterator>(t: T, mut for_each: impl FnMut(T::Item) + Sync + Send) {
150150
// We catch panics here ensuring that all the loop iterations execute.
151151
// This makes behavior consistent with the parallel compiler.
152152
let mut panic = None;

compiler/rustc_error_codes/src/error_codes.rs

+1
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ E0785: include_str!("./error_codes/E0785.md"),
492492
E0786: include_str!("./error_codes/E0786.md"),
493493
E0787: include_str!("./error_codes/E0787.md"),
494494
E0788: include_str!("./error_codes/E0788.md"),
495+
E0790: include_str!("./error_codes/E0790.md"),
495496
;
496497
// E0006, // merged with E0005
497498
// E0008, // cannot bind by-move into a pattern guard

compiler/rustc_error_codes/src/error_codes/E0283.md

+12-33
Original file line numberDiff line numberDiff line change
@@ -3,48 +3,27 @@ An implementation cannot be chosen unambiguously because of lack of information.
33
Erroneous code example:
44

55
```compile_fail,E0283
6-
trait Generator {
7-
fn create() -> u32;
8-
}
9-
10-
struct Impl;
11-
12-
impl Generator for Impl {
13-
fn create() -> u32 { 1 }
14-
}
15-
16-
struct AnotherImpl;
6+
struct Foo;
177
18-
impl Generator for AnotherImpl {
19-
fn create() -> u32 { 2 }
8+
impl Into<u32> for Foo {
9+
fn into(self) -> u32 { 1 }
2010
}
2111
22-
fn main() {
23-
let cont: u32 = Generator::create();
24-
// error, impossible to choose one of Generator trait implementation
25-
// Should it be Impl or AnotherImpl, maybe something else?
26-
}
12+
let foo = Foo;
13+
let bar: u32 = foo.into() * 1u32;
2714
```
2815

2916
This error can be solved by adding type annotations that provide the missing
30-
information to the compiler. In this case, the solution is to use a concrete
31-
type:
17+
information to the compiler. In this case, the solution is to specify the
18+
trait's type parameter:
3219

3320
```
34-
trait Generator {
35-
fn create() -> u32;
36-
}
37-
38-
struct AnotherImpl;
21+
struct Foo;
3922
40-
impl Generator for AnotherImpl {
41-
fn create() -> u32 { 2 }
23+
impl Into<u32> for Foo {
24+
fn into(self) -> u32 { 1 }
4225
}
4326
44-
fn main() {
45-
let gen1 = AnotherImpl::create();
46-
47-
// if there are multiple methods with same name (different traits)
48-
let gen2 = <AnotherImpl as Generator>::create();
49-
}
27+
let foo = Foo;
28+
let bar: u32 = Into::<u32>::into(foo) * 1u32;
5029
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
You need to specify a specific implementation of the trait in order to call the
2+
method.
3+
4+
Erroneous code example:
5+
6+
```compile_fail,E0790
7+
trait Generator {
8+
fn create() -> u32;
9+
}
10+
11+
struct Impl;
12+
13+
impl Generator for Impl {
14+
fn create() -> u32 { 1 }
15+
}
16+
17+
struct AnotherImpl;
18+
19+
impl Generator for AnotherImpl {
20+
fn create() -> u32 { 2 }
21+
}
22+
23+
let cont: u32 = Generator::create();
24+
// error, impossible to choose one of Generator trait implementation
25+
// Should it be Impl or AnotherImpl, maybe something else?
26+
```
27+
28+
This error can be solved by adding type annotations that provide the missing
29+
information to the compiler. In this case, the solution is to use a concrete
30+
type:
31+
32+
```
33+
trait Generator {
34+
fn create() -> u32;
35+
}
36+
37+
struct AnotherImpl;
38+
39+
impl Generator for AnotherImpl {
40+
fn create() -> u32 { 2 }
41+
}
42+
43+
let gen1 = AnotherImpl::create();
44+
45+
// if there are multiple methods with same name (different traits)
46+
let gen2 = <AnotherImpl as Generator>::create();
47+
```

compiler/rustc_expand/src/mbe/quoted.rs

+2
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ fn parse_tree(
234234
sess,
235235
&Token { kind: token::Dollar, span },
236236
);
237+
} else {
238+
maybe_emit_macro_metavar_expr_feature(features, sess, span);
237239
}
238240
TokenTree::token(token::Dollar, span)
239241
}

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ pub fn suggest_adding_lifetime_params<'tcx>(
228228
if is_impl {
229229
sugg.push_str(" and update trait if needed");
230230
}
231-
err.multipart_suggestion(sugg.as_str(), suggestions, Applicability::MaybeIncorrect);
231+
err.multipart_suggestion(sugg, suggestions, Applicability::MaybeIncorrect);
232232

233233
true
234234
}

compiler/rustc_middle/src/hir/map/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -491,9 +491,7 @@ impl<'hir> Map<'hir> {
491491
}
492492

493493
pub fn par_body_owners<F: Fn(LocalDefId) + Sync + Send>(self, f: F) {
494-
use rustc_data_structures::sync::{par_iter, ParallelIterator};
495-
496-
par_iter(&self.tcx.hir_crate_items(()).body_owners[..]).for_each(|&def_id| f(def_id));
494+
par_for_each_in(&self.tcx.hir_crate_items(()).body_owners[..], |&def_id| f(def_id));
497495
}
498496

499497
pub fn ty_param_owner(self, def_id: LocalDefId) -> LocalDefId {

compiler/rustc_middle/src/ty/trait_def.rs

+4
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ impl TraitImpls {
7474
pub fn blanket_impls(&self) -> &[DefId] {
7575
self.blanket_impls.as_slice()
7676
}
77+
78+
pub fn non_blanket_impls(&self) -> &FxIndexMap<SimplifiedType, Vec<DefId>> {
79+
&self.non_blanket_impls
80+
}
7781
}
7882

7983
impl<'tcx> TraitDef {

compiler/rustc_mir_build/src/check_unsafety.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -431,9 +431,9 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
431431
let lhs = &self.thir[lhs];
432432
if let ty::Adt(adt_def, _) = lhs.ty.kind() && adt_def.is_union() {
433433
if let Some((assigned_ty, assignment_span)) = self.assignment_info {
434-
if assigned_ty.needs_drop(self.tcx, self.tcx.param_env(adt_def.did())) {
434+
if assigned_ty.needs_drop(self.tcx, self.param_env) {
435435
// This would be unsafe, but should be outright impossible since we reject such unions.
436-
self.tcx.sess.delay_span_bug(assignment_span, "union fields that need dropping should be impossible");
436+
self.tcx.sess.delay_span_bug(assignment_span, format!("union fields that need dropping should be impossible: {assigned_ty}"));
437437
}
438438
} else {
439439
self.requires_unsafe(expr.span, AccessToUnionField);

compiler/rustc_mir_transform/src/check_unsafety.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,11 @@ impl<'tcx> Visitor<'tcx> for UnsafetyChecker<'_, 'tcx> {
219219
// We have to check the actual type of the assignment, as that determines if the
220220
// old value is being dropped.
221221
let assigned_ty = place.ty(&self.body.local_decls, self.tcx).ty;
222-
if assigned_ty.needs_drop(
223-
self.tcx,
224-
self.tcx.param_env(base_ty.ty_adt_def().unwrap().did()),
225-
) {
222+
if assigned_ty.needs_drop(self.tcx, self.param_env) {
226223
// This would be unsafe, but should be outright impossible since we reject such unions.
227224
self.tcx.sess.delay_span_bug(
228225
self.source_info.span,
229-
"union fields that need dropping should be impossible",
226+
format!("union fields that need dropping should be impossible: {assigned_ty}")
230227
);
231228
}
232229
} else {

compiler/rustc_monomorphize/src/collector.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@
180180
//! regardless of whether it is actually needed or not.
181181
182182
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
183-
use rustc_data_structures::sync::{par_iter, MTLock, MTRef, ParallelIterator};
183+
use rustc_data_structures::sync::{par_for_each_in, MTLock, MTRef};
184184
use rustc_hir as hir;
185185
use rustc_hir::def::DefKind;
186186
use rustc_hir::def_id::{DefId, DefIdMap, LocalDefId};
@@ -346,7 +346,7 @@ pub fn collect_crate_mono_items(
346346
let inlining_map: MTRef<'_, _> = &mut inlining_map;
347347

348348
tcx.sess.time("monomorphization_collector_graph_walk", || {
349-
par_iter(roots).for_each(|root| {
349+
par_for_each_in(roots, |root| {
350350
let mut recursion_depths = DefIdMap::default();
351351
collect_items_rec(
352352
tcx,

compiler/rustc_passes/src/entry.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ fn err_if_attr_found(ctxt: &EntryContext<'_>, attrs: &[Attribute], sym: Symbol)
7777
.sess
7878
.struct_span_err(
7979
attr.span,
80-
&format!("`{}` attribute can only be used on functions", sym.as_str()),
80+
&format!("`{}` attribute can only be used on functions", sym),
8181
)
8282
.emit();
8383
}

compiler/rustc_resolve/src/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1627,7 +1627,7 @@ impl<'a> Resolver<'a> {
16271627
"{}{} `{}` defined here",
16281628
prefix,
16291629
suggestion.res.descr(),
1630-
suggestion.candidate.as_str(),
1630+
suggestion.candidate,
16311631
),
16321632
);
16331633
}

0 commit comments

Comments
 (0)