Skip to content

Commit 8a09420

Browse files
committed
Auto merge of rust-lang#105008 - Dylan-DPC:rollup-wcd19yu, r=Dylan-DPC
Rollup of 6 pull requests Successful merges: - rust-lang#104360 (Stabilize native library modifier `verbatim`) - rust-lang#104732 (Refactor `ty::ClosureKind` related stuff) - rust-lang#104795 (Change multiline span ASCII art visual order) - rust-lang#104890 (small method code cleanup) - rust-lang#104907 (Remove `SelectionContext::infcx()` in favor of field access) - rust-lang#104927 (Simplify some binder shifting logic) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 69df0f2 + d5de2a8 commit 8a09420

File tree

56 files changed

+373
-470
lines changed

Some content is hidden

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

56 files changed

+373
-470
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -377,12 +377,8 @@ fn link_rlib<'a>(
377377
find_native_static_library(name.as_str(), lib.verbatim, &lib_search_paths, sess);
378378
if sess.opts.unstable_opts.packed_bundled_libs && flavor == RlibFlavor::Normal {
379379
let filename = lib.filename.unwrap();
380-
let lib_path = find_native_static_library(
381-
filename.as_str(),
382-
Some(true),
383-
&lib_search_paths,
384-
sess,
385-
);
380+
let lib_path =
381+
find_native_static_library(filename.as_str(), true, &lib_search_paths, sess);
386382
let src = read(lib_path)
387383
.map_err(|e| sess.emit_fatal(errors::ReadFileError { message: e }))?;
388384
let (data, _) = create_wrapper_file(sess, b".bundled_lib".to_vec(), &src);
@@ -465,7 +461,7 @@ fn collate_raw_dylibs<'a, 'b>(
465461

466462
for lib in used_libraries {
467463
if lib.kind == NativeLibKind::RawDylib {
468-
let ext = if matches!(lib.verbatim, Some(true)) { "" } else { ".dll" };
464+
let ext = if lib.verbatim { "" } else { ".dll" };
469465
let name = format!("{}{}", lib.name.expect("unnamed raw-dylib library"), ext);
470466
let imports = dylib_table.entry(name.clone()).or_default();
471467
for import in &lib.dll_imports {
@@ -1335,7 +1331,7 @@ fn print_native_static_libs(sess: &Session, all_native_libs: &[NativeLib]) {
13351331
NativeLibKind::Static { bundle: Some(false), .. }
13361332
| NativeLibKind::Dylib { .. }
13371333
| NativeLibKind::Unspecified => {
1338-
let verbatim = lib.verbatim.unwrap_or(false);
1334+
let verbatim = lib.verbatim;
13391335
if sess.target.is_like_msvc {
13401336
Some(format!("{}{}", name, if verbatim { "" } else { ".lib" }))
13411337
} else if sess.target.linker_flavor.is_gnu() {
@@ -2306,7 +2302,7 @@ fn add_native_libs_from_crate(
23062302
_ => &codegen_results.crate_info.native_libraries[&cnum],
23072303
};
23082304

2309-
let mut last = (None, NativeLibKind::Unspecified, None);
2305+
let mut last = (None, NativeLibKind::Unspecified, false);
23102306
for lib in native_libs {
23112307
let Some(name) = lib.name else {
23122308
continue;
@@ -2323,7 +2319,7 @@ fn add_native_libs_from_crate(
23232319
};
23242320

23252321
let name = name.as_str();
2326-
let verbatim = lib.verbatim.unwrap_or(false);
2322+
let verbatim = lib.verbatim;
23272323
match lib.kind {
23282324
NativeLibKind::Static { bundle, whole_archive } => {
23292325
if link_static {

compiler/rustc_codegen_ssa/src/back/linker.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ impl<'a> Linker for GccLinker<'a> {
515515
// -force_load is the macOS equivalent of --whole-archive, but it
516516
// involves passing the full path to the library to link.
517517
self.linker_arg("-force_load");
518-
let lib = find_native_static_library(lib, Some(verbatim), search_path, &self.sess);
518+
let lib = find_native_static_library(lib, verbatim, search_path, &self.sess);
519519
self.linker_arg(&lib);
520520
}
521521
}

compiler/rustc_codegen_ssa/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ pub struct NativeLib {
116116
pub name: Option<Symbol>,
117117
pub filename: Option<Symbol>,
118118
pub cfg: Option<ast::MetaItem>,
119-
pub verbatim: Option<bool>,
119+
pub verbatim: bool,
120120
pub dll_imports: Vec<cstore::DllImport>,
121121
}
122122

@@ -127,7 +127,7 @@ impl From<&cstore::NativeLib> for NativeLib {
127127
filename: lib.filename,
128128
name: lib.name,
129129
cfg: lib.cfg.clone(),
130-
verbatim: lib.verbatim,
130+
verbatim: lib.verbatim.unwrap_or(false),
131131
dll_imports: lib.dll_imports.clone(),
132132
}
133133
}

compiler/rustc_errors/src/emitter.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -2282,7 +2282,7 @@ impl FileWithAnnotatedLines {
22822282
}
22832283

22842284
// Find overlapping multiline annotations, put them at different depths
2285-
multiline_annotations.sort_by_key(|&(_, ref ml)| (ml.line_start, ml.line_end));
2285+
multiline_annotations.sort_by_key(|&(_, ref ml)| (ml.line_start, usize::MAX - ml.line_end));
22862286
for (_, ann) in multiline_annotations.clone() {
22872287
for (_, a) in multiline_annotations.iter_mut() {
22882288
// Move all other multiline annotations overlapping with this one
@@ -2300,8 +2300,14 @@ impl FileWithAnnotatedLines {
23002300
}
23012301

23022302
let mut max_depth = 0; // max overlapping multiline spans
2303-
for (file, ann) in multiline_annotations {
2303+
for (_, ann) in &multiline_annotations {
23042304
max_depth = max(max_depth, ann.depth);
2305+
}
2306+
// Change order of multispan depth to minimize the number of overlaps in the ASCII art.
2307+
for (_, a) in multiline_annotations.iter_mut() {
2308+
a.depth = max_depth - a.depth + 1;
2309+
}
2310+
for (file, ann) in multiline_annotations {
23052311
let mut end_ann = ann.as_end();
23062312
if !ann.overlaps_exactly {
23072313
// avoid output like

compiler/rustc_expand/src/tests.rs

+54-54
Original file line numberDiff line numberDiff line change
@@ -272,13 +272,13 @@ error: foo
272272
--> test.rs:3:3
273273
|
274274
3 | X0 Y0
275-
| ____^__-
276-
| | ___|
275+
| ___^__-
276+
| |___|
277277
| ||
278278
4 | || X1 Y1
279279
5 | || X2 Y2
280280
| ||____^__- `Y` is a good letter too
281-
| |____|
281+
| |_____|
282282
| `X` is a good letter
283283
284284
"#,
@@ -311,12 +311,12 @@ error: foo
311311
--> test.rs:3:3
312312
|
313313
3 | X0 Y0
314-
| ____^__-
315-
| | ___|
314+
| ___^__-
315+
| |___|
316316
| ||
317317
4 | || Y1 X1
318318
| ||____-__^ `X` is a good letter
319-
| |_____|
319+
| |____|
320320
| `Y` is a good letter too
321321
322322
"#,
@@ -351,13 +351,13 @@ error: foo
351351
--> test.rs:3:6
352352
|
353353
3 | X0 Y0 Z0
354-
| ______^
355-
4 | | X1 Y1 Z1
356-
| |_________-
354+
| _______^
355+
4 | | X1 Y1 Z1
356+
| | _________-
357357
5 | || X2 Y2 Z2
358358
| ||____^ `X` is a good letter
359-
6 | | X3 Y3 Z3
360-
| |_____- `Y` is a good letter too
359+
6 | | X3 Y3 Z3
360+
| |____- `Y` is a good letter too
361361
362362
"#,
363363
);
@@ -395,15 +395,15 @@ error: foo
395395
--> test.rs:3:3
396396
|
397397
3 | X0 Y0 Z0
398-
| _____^__-__-
399-
| | ____|__|
400-
| || ___|
398+
| ___^__-__-
399+
| |___|__|
400+
| ||___|
401401
| |||
402402
4 | ||| X1 Y1 Z1
403403
5 | ||| X2 Y2 Z2
404404
| |||____^__-__- `Z` label
405-
| ||____|__|
406-
| |____| `Y` is a good letter too
405+
| ||_____|__|
406+
| |______| `Y` is a good letter too
407407
| `X` is a good letter
408408
409409
"#,
@@ -487,17 +487,17 @@ error: foo
487487
--> test.rs:3:6
488488
|
489489
3 | X0 Y0 Z0
490-
| ______^
491-
4 | | X1 Y1 Z1
492-
| |____^_-
490+
| _______^
491+
4 | | X1 Y1 Z1
492+
| | ____^_-
493493
| ||____|
494-
| | `X` is a good letter
495-
5 | | X2 Y2 Z2
496-
| |____-______- `Y` is a good letter too
497-
| ____|
498-
| |
499-
6 | | X3 Y3 Z3
500-
| |________- `Z`
494+
| | `X` is a good letter
495+
5 | | X2 Y2 Z2
496+
| |___-______- `Y` is a good letter too
497+
| ___|
498+
| |
499+
6 | | X3 Y3 Z3
500+
| |_______- `Z`
501501
502502
"#,
503503
);
@@ -570,14 +570,14 @@ error: foo
570570
--> test.rs:3:6
571571
|
572572
3 | X0 Y0 Z0
573-
| ______^
574-
4 | | X1 Y1 Z1
575-
| |____^____-
573+
| _______^
574+
4 | | X1 Y1 Z1
575+
| | ____^____-
576576
| ||____|
577-
| | `X` is a good letter
578-
5 | | X2 Y2 Z2
579-
6 | | X3 Y3 Z3
580-
| |___________- `Y` is a good letter too
577+
| | `X` is a good letter
578+
5 | | X2 Y2 Z2
579+
6 | | X3 Y3 Z3
580+
| |__________- `Y` is a good letter too
581581
582582
"#,
583583
);
@@ -941,18 +941,18 @@ error: foo
941941
--> test.rs:3:6
942942
|
943943
3 | X0 Y0 Z0
944-
| ______^
945-
4 | | X1 Y1 Z1
946-
| |____^____-
944+
| _______^
945+
4 | | X1 Y1 Z1
946+
| | ____^____-
947947
| ||____|
948-
| | `X` is a good letter
949-
5 | | 1
950-
6 | | 2
951-
7 | | 3
952-
... |
953-
15 | | X2 Y2 Z2
954-
16 | | X3 Y3 Z3
955-
| |___________- `Y` is a good letter too
948+
| | `X` is a good letter
949+
5 | | 1
950+
6 | | 2
951+
7 | | 3
952+
... |
953+
15 | | X2 Y2 Z2
954+
16 | | X3 Y3 Z3
955+
| |__________- `Y` is a good letter too
956956
957957
"#,
958958
);
@@ -996,21 +996,21 @@ error: foo
996996
--> test.rs:3:6
997997
|
998998
3 | X0 Y0 Z0
999-
| ______^
1000-
4 | | 1
1001-
5 | | 2
1002-
6 | | 3
1003-
7 | | X1 Y1 Z1
1004-
| |_________-
999+
| _______^
1000+
4 | | 1
1001+
5 | | 2
1002+
6 | | 3
1003+
7 | | X1 Y1 Z1
1004+
| | _________-
10051005
8 | || 4
10061006
9 | || 5
10071007
10 | || 6
10081008
11 | || X2 Y2 Z2
10091009
| ||__________- `Z` is a good letter too
1010-
... |
1011-
15 | | 10
1012-
16 | | X3 Y3 Z3
1013-
| |_______^ `Y` is a good letter
1010+
... |
1011+
15 | | 10
1012+
16 | | X3 Y3 Z3
1013+
| |________^ `Y` is a good letter
10141014
10151015
"#,
10161016
);

compiler/rustc_feature/src/accepted.rs

+2
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ declare_features! (
237237
(accepted, native_link_modifiers, "1.61.0", Some(81490), None),
238238
/// Allows specifying the bundle link modifier
239239
(accepted, native_link_modifiers_bundle, "1.63.0", Some(81490), None),
240+
/// Allows specifying the verbatim link modifier
241+
(accepted, native_link_modifiers_verbatim, "CURRENT_RUSTC_VERSION", Some(81490), None),
240242
/// Allows specifying the whole-archive link modifier
241243
(accepted, native_link_modifiers_whole_archive, "1.61.0", Some(81490), None),
242244
/// Allows using non lexical lifetimes (RFC 2094).

compiler/rustc_feature/src/active.rs

-2
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,6 @@ declare_features! (
455455
(active, naked_functions, "1.9.0", Some(32408), None),
456456
/// Allows specifying the as-needed link modifier
457457
(active, native_link_modifiers_as_needed, "1.53.0", Some(81490), None),
458-
/// Allows specifying the verbatim link modifier
459-
(active, native_link_modifiers_verbatim, "1.53.0", Some(81490), None),
460458
/// Allow negative trait implementations.
461459
(active, negative_impls, "1.44.0", Some(68318), None),
462460
/// Allows the `!` type. Does not imply 'exhaustive_patterns' (below) any more.

compiler/rustc_hir_typeck/src/callee.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
179179

180180
// Hack: we know that there are traits implementing Fn for &F
181181
// where F:Fn and so forth. In the particular case of types
182-
// like `x: &mut FnMut()`, if there is a call `x()`, we would
183-
// normally translate to `FnMut::call_mut(&mut x, ())`, but
184-
// that winds up requiring `mut x: &mut FnMut()`. A little
185-
// over the top. The simplest fix by far is to just ignore
186-
// this case and deref again, so we wind up with
187-
// `FnMut::call_mut(&mut *x, ())`.
182+
// like `f: &mut FnMut()`, if there is a call `f()`, we would
183+
// normally translate to `FnMut::call_mut(&mut f, ())`, but
184+
// that winds up potentially requiring the user to mark their
185+
// variable as `mut` which feels unnecessary and unexpected.
186+
//
187+
// fn foo(f: &mut impl FnMut()) { f() }
188+
// ^ without this hack `f` would have to be declared as mutable
189+
//
190+
// The simplest fix by far is to just ignore this case and deref again,
191+
// so we wind up with `FnMut::call_mut(&mut *f, ())`.
188192
ty::Ref(..) if autoderef.step_count() == 0 => {
189193
return None;
190194
}

compiler/rustc_hir_typeck/src/cast.rs

-12
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ use rustc_span::def_id::{DefId, LOCAL_CRATE};
4646
use rustc_span::symbol::sym;
4747
use rustc_span::Span;
4848
use rustc_trait_selection::infer::InferCtxtExt;
49-
use rustc_trait_selection::traits::error_reporting::report_object_safety_error;
5049

5150
/// Reifies a cast check to be checked once we have full type information for
5251
/// a function context.
@@ -727,9 +726,6 @@ impl<'a, 'tcx> CastCheck<'tcx> {
727726
debug!(" -> CoercionCast");
728727
fcx.typeck_results.borrow_mut().set_coercion_cast(self.expr.hir_id.local_id);
729728
}
730-
Err(ty::error::TypeError::ObjectUnsafeCoercion(did)) => {
731-
self.report_object_unsafe_cast(&fcx, did);
732-
}
733729
Err(_) => {
734730
match self.do_check(fcx) {
735731
Ok(k) => {
@@ -741,14 +737,6 @@ impl<'a, 'tcx> CastCheck<'tcx> {
741737
};
742738
}
743739
}
744-
745-
fn report_object_unsafe_cast(&self, fcx: &FnCtxt<'a, 'tcx>, did: DefId) {
746-
let violations = fcx.tcx.object_safety_violations(did);
747-
let mut err = report_object_safety_error(fcx.tcx, self.cast_span, did, violations);
748-
err.note(&format!("required by cast to type '{}'", fcx.ty_to_string(self.cast_ty)));
749-
err.emit();
750-
}
751-
752740
/// Checks a cast, and report an error if one exists. In some cases, this
753741
/// can return Ok and create type errors in the fcx rather than returning
754742
/// directly. coercion-cast is handled in check instead of here.

compiler/rustc_hir_typeck/src/closure.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
178178
});
179179
let kind = object_type
180180
.principal_def_id()
181-
.and_then(|did| self.tcx.fn_trait_kind_from_lang_item(did));
181+
.and_then(|did| self.tcx.fn_trait_kind_from_def_id(did));
182182
(sig, kind)
183183
}
184184
ty::Infer(ty::TyVar(vid)) => self.deduce_signature_from_predicates(
@@ -235,7 +235,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
235235
_ => None,
236236
};
237237
if let Some(closure_kind) =
238-
trait_def_id.and_then(|def_id| self.tcx.fn_trait_kind_from_lang_item(def_id))
238+
trait_def_id.and_then(|def_id| self.tcx.fn_trait_kind_from_def_id(def_id))
239239
{
240240
expected_kind = Some(
241241
expected_kind
@@ -263,7 +263,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
263263

264264
let trait_def_id = projection.trait_def_id(tcx);
265265

266-
let is_fn = tcx.fn_trait_kind_from_lang_item(trait_def_id).is_some();
266+
let is_fn = tcx.is_fn_trait(trait_def_id);
267267
let gen_trait = tcx.require_lang_item(LangItem::Generator, cause_span);
268268
let is_gen = gen_trait == trait_def_id;
269269
if !is_fn && !is_gen {

0 commit comments

Comments
 (0)