Skip to content

Commit b76fec3

Browse files
committed
Auto merge of rust-lang#100511 - compiler-errors:rollup-vrte4w5, r=compiler-errors
Rollup of 11 pull requests Successful merges: - rust-lang#100355 (rustdoc: Rename ``@has` FILE PATTERN` to ``@hasraw` FILE PATTERN`) - rust-lang#100407 (avoid some int2ptr casts in thread_local_key tests) - rust-lang#100434 (Fix HIR pretty printing of let else) - rust-lang#100438 (Erase regions better in `promote_candidate`) - rust-lang#100445 (adapt test for msan message change) - rust-lang#100447 (Remove more Clean trait implementations) - rust-lang#100464 (Make `[rust] use-lld=true` work on windows) - rust-lang#100475 (Give a helpful diagnostic when the next struct field has an attribute) - rust-lang#100490 (wf: correctly `shallow_resolve` consts) - rust-lang#100501 (nicer Miri backtraces for from_exposed_addr) - rust-lang#100509 (merge two test directories that mean the same thing) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 75b7e52 + 860e093 commit b76fec3

File tree

128 files changed

+473
-353
lines changed

Some content is hidden

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

128 files changed

+473
-353
lines changed

Diff for: compiler/rustc_const_eval/src/transform/promote_consts.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -839,17 +839,12 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
839839
let mut promoted_operand = |ty, span| {
840840
promoted.span = span;
841841
promoted.local_decls[RETURN_PLACE] = LocalDecl::new(ty, span);
842+
let substs = tcx.erase_regions(InternalSubsts::identity_for_item(tcx, def.did));
842843
let _const = tcx.mk_const(ty::ConstS {
843844
ty,
844845
kind: ty::ConstKind::Unevaluated(ty::Unevaluated {
845846
def,
846-
substs: InternalSubsts::for_item(tcx, def.did, |param, _| {
847-
if let ty::GenericParamDefKind::Lifetime = param.kind {
848-
tcx.lifetimes.re_erased.into()
849-
} else {
850-
tcx.mk_param_from_def(param)
851-
}
852-
}),
847+
substs,
853848
promoted: Some(promoted_id),
854849
}),
855850
});

Diff for: compiler/rustc_hir_pretty/src/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,10 @@ impl<'a> State<'a> {
911911
if let Some(els) = els {
912912
self.nbsp();
913913
self.word_space("else");
914+
// containing cbox, will be closed by print-block at `}`
915+
self.cbox(0);
916+
// head-box, will be closed by print-block after `{`
917+
self.ibox(0);
914918
self.print_block(els);
915919
}
916920

Diff for: compiler/rustc_parse/src/parser/item.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -1544,8 +1544,12 @@ impl<'a> Parser<'a> {
15441544
}
15451545
}
15461546

1547-
if self.token.is_ident() {
1548-
// This is likely another field; emit the diagnostic and keep going
1547+
if self.token.is_ident()
1548+
|| (self.token.kind == TokenKind::Pound
1549+
&& (self.look_ahead(1, |t| t == &token::OpenDelim(Delimiter::Bracket))))
1550+
{
1551+
// This is likely another field, TokenKind::Pound is used for `#[..]` attribute for next field,
1552+
// emit the diagnostic and keep going
15491553
err.span_suggestion(
15501554
sp,
15511555
"try adding a comma",

Diff for: compiler/rustc_trait_selection/src/traits/wf.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,24 @@ pub fn obligations<'a, 'tcx>(
3131
if resolved_ty == ty {
3232
// No progress, bail out to prevent "livelock".
3333
return None;
34+
} else {
35+
resolved_ty
3436
}
35-
36-
resolved_ty
3737
}
3838
_ => ty,
3939
}
4040
.into()
4141
}
4242
GenericArgKind::Const(ct) => {
4343
match ct.kind() {
44-
ty::ConstKind::Infer(infer) => {
45-
let resolved = infcx.shallow_resolve(infer);
46-
if resolved == infer {
44+
ty::ConstKind::Infer(_) => {
45+
let resolved = infcx.shallow_resolve(ct);
46+
if resolved == ct {
4747
// No progress.
4848
return None;
49+
} else {
50+
resolved
4951
}
50-
51-
infcx
52-
.tcx
53-
.mk_const(ty::ConstS { kind: ty::ConstKind::Infer(resolved), ty: ct.ty() })
5452
}
5553
_ => ct,
5654
}

Diff for: library/core/src/ptr/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,7 @@ pub const fn invalid_mut<T>(addr: usize) -> *mut T {
603603
#[must_use]
604604
#[inline]
605605
#[unstable(feature = "strict_provenance", issue = "95228")]
606+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
606607
pub fn from_exposed_addr<T>(addr: usize) -> *const T
607608
where
608609
T: Sized,
@@ -639,6 +640,7 @@ where
639640
#[must_use]
640641
#[inline]
641642
#[unstable(feature = "strict_provenance", issue = "95228")]
643+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
642644
pub fn from_exposed_addr_mut<T>(addr: usize) -> *mut T
643645
where
644646
T: Sized,

Diff for: library/std/src/sys_common/thread_local_key/tests.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use super::{Key, StaticKey};
2+
use core::ptr;
23

34
fn assert_sync<T: Sync>() {}
45
fn assert_send<T: Send>() {}
@@ -12,8 +13,8 @@ fn smoke() {
1213
let k2 = Key::new(None);
1314
assert!(k1.get().is_null());
1415
assert!(k2.get().is_null());
15-
k1.set(1 as *mut _);
16-
k2.set(2 as *mut _);
16+
k1.set(ptr::invalid_mut(1));
17+
k2.set(ptr::invalid_mut(2));
1718
assert_eq!(k1.get() as usize, 1);
1819
assert_eq!(k2.get() as usize, 2);
1920
}
@@ -26,8 +27,8 @@ fn statik() {
2627
unsafe {
2728
assert!(K1.get().is_null());
2829
assert!(K2.get().is_null());
29-
K1.set(1 as *mut _);
30-
K2.set(2 as *mut _);
30+
K1.set(ptr::invalid_mut(1));
31+
K2.set(ptr::invalid_mut(2));
3132
assert_eq!(K1.get() as usize, 1);
3233
assert_eq!(K2.get() as usize, 2);
3334
}

Diff for: src/bootstrap/compile.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,12 @@ impl Step for Rustc {
658658

659659
// With LLD, we can use ICF (identical code folding) to reduce the executable size
660660
// of librustc_driver/rustc and to improve i-cache utilization.
661-
if builder.config.use_lld {
661+
//
662+
// -Wl,[link options] doesn't work on MSVC. However, /OPT:ICF (technically /OPT:REF,ICF)
663+
// is already on by default in MSVC optimized builds, which is interpreted as --icf=all:
664+
// https://github.com/llvm/llvm-project/blob/3329cec2f79185bafd678f310fafadba2a8c76d2/lld/COFF/Driver.cpp#L1746
665+
// https://github.com/rust-lang/rust/blob/f22819bcce4abaff7d1246a56eec493418f9f4ee/compiler/rustc_codegen_ssa/src/back/linker.rs#L827
666+
if builder.config.use_lld && !compiler.host.contains("msvc") {
662667
cargo.rustflag("-Clink-args=-Wl,--icf=all");
663668
}
664669

Diff for: src/etc/htmldocck.py

+13-9
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@
4141
`PATH` is relative to the output directory. It can be given as `-`
4242
which repeats the most recently used `PATH`.
4343
44-
* `@has PATH PATTERN` and `@matches PATH PATTERN` checks for
45-
the occurrence of the given pattern `PATTERN` in the specified file.
44+
* `@hasraw PATH PATTERN` and `@matchesraw PATH PATTERN` checks
45+
for the occurrence of the given pattern `PATTERN` in the specified file.
4646
Only one occurrence of the pattern is enough.
4747
48-
For `@has`, `PATTERN` is a whitespace-normalized (every consecutive
48+
For `@hasraw`, `PATTERN` is a whitespace-normalized (every consecutive
4949
whitespace being replaced by one single space character) string.
5050
The entire file is also whitespace-normalized including newlines.
5151
52-
For `@matches`, `PATTERN` is a Python-supported regular expression.
52+
For `@matchesraw`, `PATTERN` is a Python-supported regular expression.
5353
The file remains intact but the regexp is matched without the `MULTILINE`
5454
and `IGNORECASE` options. You can still use a prefix `(?m)` or `(?i)`
5555
to override them, and `\A` and `\Z` for definitely matching
@@ -542,19 +542,23 @@ def get_nb_matching_elements(cache, c, regexp, stop_at_first):
542542
def check_command(c, cache):
543543
try:
544544
cerr = ""
545-
if c.cmd == 'has' or c.cmd == 'matches': # string test
546-
regexp = (c.cmd == 'matches')
547-
if len(c.args) == 1 and not regexp: # @has <path> = file existence
545+
if c.cmd in ['has', 'hasraw', 'matches', 'matchesraw']: # string test
546+
regexp = c.cmd.startswith('matches')
547+
548+
# @has <path> = file existence
549+
if len(c.args) == 1 and not regexp and 'raw' not in c.cmd:
548550
try:
549551
cache.get_file(c.args[0])
550552
ret = True
551553
except FailedCheck as err:
552554
cerr = str(err)
553555
ret = False
554-
elif len(c.args) == 2: # @has/matches <path> <pat> = string test
556+
# @hasraw/matchesraw <path> <pat> = string test
557+
elif len(c.args) == 2 and 'raw' in c.cmd:
555558
cerr = "`PATTERN` did not match"
556559
ret = check_string(cache.get_file(c.args[0]), c.args[1], regexp)
557-
elif len(c.args) == 3: # @has/matches <path> <pat> <match> = XML tree test
560+
# @has/matches <path> <pat> <match> = XML tree test
561+
elif len(c.args) == 3 and 'raw' not in c.cmd:
558562
cerr = "`XPATH PATTERN` did not match"
559563
ret = get_nb_matching_elements(cache, c, regexp, True) != 0
560564
else:

Diff for: src/librustdoc/clean/mod.rs

+33-25
Original file line numberDiff line numberDiff line change
@@ -1322,14 +1322,17 @@ fn clean_qpath<'tcx>(hir_ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> Type
13221322
let trait_def = cx.tcx.associated_item(p.res.def_id()).container_id(cx.tcx);
13231323
let trait_ = self::Path {
13241324
res: Res::Def(DefKind::Trait, trait_def),
1325-
segments: trait_segments.iter().map(|x| x.clean(cx)).collect(),
1325+
segments: trait_segments.iter().map(|x| clean_path_segment(x, cx)).collect(),
13261326
};
13271327
register_res(cx, trait_.res);
13281328
let self_def_id = DefId::local(qself.hir_id.owner.local_def_index);
13291329
let self_type = clean_ty(qself, cx);
13301330
let should_show_cast = compute_should_show_cast(Some(self_def_id), &trait_, &self_type);
13311331
Type::QPath {
1332-
assoc: Box::new(p.segments.last().expect("segments were empty").clean(cx)),
1332+
assoc: Box::new(clean_path_segment(
1333+
p.segments.last().expect("segments were empty"),
1334+
cx,
1335+
)),
13331336
should_show_cast,
13341337
self_type: Box::new(self_type),
13351338
trait_,
@@ -1349,7 +1352,7 @@ fn clean_qpath<'tcx>(hir_ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> Type
13491352
let self_type = clean_ty(qself, cx);
13501353
let should_show_cast = compute_should_show_cast(self_def_id, &trait_, &self_type);
13511354
Type::QPath {
1352-
assoc: Box::new(segment.clean(cx)),
1355+
assoc: Box::new(clean_path_segment(segment, cx)),
13531356
should_show_cast,
13541357
self_type: Box::new(self_type),
13551358
trait_,
@@ -1507,7 +1510,7 @@ pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> T
15071510
if !lifetime.is_elided() { Some(clean_lifetime(*lifetime, cx)) } else { None };
15081511
DynTrait(bounds, lifetime)
15091512
}
1510-
TyKind::BareFn(barefn) => BareFunction(Box::new(barefn.clean(cx))),
1513+
TyKind::BareFn(barefn) => BareFunction(Box::new(clean_bare_fn_ty(barefn, cx))),
15111514
// Rustdoc handles `TyKind::Err`s by turning them into `Type::Infer`s.
15121515
TyKind::Infer | TyKind::Err => Infer,
15131516
TyKind::Typeof(..) => panic!("unimplemented type {:?}", ty.kind),
@@ -1823,7 +1826,10 @@ fn clean_variant_data<'tcx>(
18231826
}
18241827

18251828
fn clean_path<'tcx>(path: &hir::Path<'tcx>, cx: &mut DocContext<'tcx>) -> Path {
1826-
Path { res: path.res, segments: path.segments.iter().map(|x| x.clean(cx)).collect() }
1829+
Path {
1830+
res: path.res,
1831+
segments: path.segments.iter().map(|x| clean_path_segment(x, cx)).collect(),
1832+
}
18271833
}
18281834

18291835
fn clean_generic_args<'tcx>(
@@ -1861,28 +1867,30 @@ fn clean_generic_args<'tcx>(
18611867
}
18621868
}
18631869

1864-
impl<'tcx> Clean<'tcx, PathSegment> for hir::PathSegment<'tcx> {
1865-
fn clean(&self, cx: &mut DocContext<'tcx>) -> PathSegment {
1866-
PathSegment { name: self.ident.name, args: clean_generic_args(self.args(), cx) }
1867-
}
1870+
fn clean_path_segment<'tcx>(
1871+
path: &hir::PathSegment<'tcx>,
1872+
cx: &mut DocContext<'tcx>,
1873+
) -> PathSegment {
1874+
PathSegment { name: path.ident.name, args: clean_generic_args(path.args(), cx) }
18681875
}
18691876

1870-
impl<'tcx> Clean<'tcx, BareFunctionDecl> for hir::BareFnTy<'tcx> {
1871-
fn clean(&self, cx: &mut DocContext<'tcx>) -> BareFunctionDecl {
1872-
let (generic_params, decl) = enter_impl_trait(cx, |cx| {
1873-
// NOTE: generics must be cleaned before args
1874-
let generic_params = self
1875-
.generic_params
1876-
.iter()
1877-
.filter(|p| !is_elided_lifetime(p))
1878-
.map(|x| clean_generic_param(cx, None, x))
1879-
.collect();
1880-
let args = clean_args_from_types_and_names(cx, self.decl.inputs, self.param_names);
1881-
let decl = clean_fn_decl_with_args(cx, self.decl, args);
1882-
(generic_params, decl)
1883-
});
1884-
BareFunctionDecl { unsafety: self.unsafety, abi: self.abi, decl, generic_params }
1885-
}
1877+
fn clean_bare_fn_ty<'tcx>(
1878+
bare_fn: &hir::BareFnTy<'tcx>,
1879+
cx: &mut DocContext<'tcx>,
1880+
) -> BareFunctionDecl {
1881+
let (generic_params, decl) = enter_impl_trait(cx, |cx| {
1882+
// NOTE: generics must be cleaned before args
1883+
let generic_params = bare_fn
1884+
.generic_params
1885+
.iter()
1886+
.filter(|p| !is_elided_lifetime(p))
1887+
.map(|x| clean_generic_param(cx, None, x))
1888+
.collect();
1889+
let args = clean_args_from_types_and_names(cx, bare_fn.decl.inputs, bare_fn.param_names);
1890+
let decl = clean_fn_decl_with_args(cx, bare_fn.decl, args);
1891+
(generic_params, decl)
1892+
});
1893+
BareFunctionDecl { unsafety: bare_fn.unsafety, abi: bare_fn.abi, decl, generic_params }
18861894
}
18871895

18881896
fn clean_maybe_renamed_item<'tcx>(

Diff for: src/test/rustdoc/all.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ mod private_module {
2424
}
2525

2626
// @has foo/all.html '//a[@href="struct.ReexportedStruct.html"]' 'ReexportedStruct'
27-
// @!has foo/all.html 'private_module'
27+
// @!hasraw foo/all.html 'private_module'
2828
pub use private_module::ReexportedStruct;

Diff for: src/test/rustdoc/assoc-consts.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub trait Foo {
55
const FOO: usize = 12 + 1;
66
// @has - '//*[@id="associatedconstant.FOO_NO_DEFAULT"]' 'const FOO_NO_DEFAULT: bool'
77
const FOO_NO_DEFAULT: bool;
8-
// @!has - FOO_HIDDEN
8+
// @!hasraw - FOO_HIDDEN
99
#[doc(hidden)]
1010
const FOO_HIDDEN: u8 = 0;
1111
}
@@ -18,7 +18,7 @@ impl Foo for Bar {
1818
const FOO: usize = 12;
1919
// @has - '//*[@id="associatedconstant.FOO_NO_DEFAULT"]' 'const FOO_NO_DEFAULT: bool'
2020
const FOO_NO_DEFAULT: bool = false;
21-
// @!has - FOO_HIDDEN
21+
// @!hasraw - FOO_HIDDEN
2222
#[doc(hidden)]
2323
const FOO_HIDDEN: u8 = 0;
2424
}
@@ -50,9 +50,9 @@ impl Bar {
5050
}
5151

5252
impl Bar {
53-
// @!has assoc_consts/struct.Bar.html 'BAR_PRIVATE'
53+
// @!hasraw assoc_consts/struct.Bar.html 'BAR_PRIVATE'
5454
const BAR_PRIVATE: char = 'a';
55-
// @!has assoc_consts/struct.Bar.html 'BAR_HIDDEN'
55+
// @!hasraw assoc_consts/struct.Bar.html 'BAR_HIDDEN'
5656
#[doc(hidden)]
5757
pub const BAR_HIDDEN: &'static str = "a";
5858
}

Diff for: src/test/rustdoc/const-display.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub const fn foo() -> u32 { 42 }
2020
pub const unsafe fn foo_unsafe() -> u32 { 42 }
2121

2222
// @has 'foo/fn.foo2.html' '//pre' 'pub const fn foo2() -> u32'
23-
// @!has - '//span[@class="since"]'
23+
// @!hasraw - '//span[@class="since"]'
2424
#[unstable(feature = "humans", issue = "none")]
2525
pub const fn foo2() -> u32 { 42 }
2626

@@ -32,7 +32,7 @@ pub const fn bar2() -> u32 { 42 }
3232

3333

3434
// @has 'foo/fn.foo2_gated.html' '//pre' 'pub const unsafe fn foo2_gated() -> u32'
35-
// @!has - '//span[@class="since"]'
35+
// @!hasraw - '//span[@class="since"]'
3636
#[unstable(feature = "foo2", issue = "none")]
3737
pub const unsafe fn foo2_gated() -> u32 { 42 }
3838

@@ -43,7 +43,7 @@ pub const unsafe fn foo2_gated() -> u32 { 42 }
4343
pub const unsafe fn bar2_gated() -> u32 { 42 }
4444

4545
// @has 'foo/fn.bar_not_gated.html' '//pre' 'pub const unsafe fn bar_not_gated() -> u32'
46-
// @!has - '//span[@class="since"]'
46+
// @!hasraw - '//span[@class="since"]'
4747
pub const unsafe fn bar_not_gated() -> u32 { 42 }
4848

4949
pub struct Foo;

0 commit comments

Comments
 (0)