Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 11 pull requests #100511

Merged
merged 29 commits into from
Aug 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b5786dc
avoid some int2ptr casts in thread_local_key tests
RalfJung Aug 11, 2022
e182d12
Fix HIR pretty printing of let else
compiler-errors Aug 12, 2022
f94220f
Erase regions better in promote_candidate
compiler-errors Aug 12, 2022
43eda18
adapt test for msan message change
krasimirgg Aug 12, 2022
a65647a
remove Clean trait implementation for hir::PathSegment
GuillaumeGomez Aug 12, 2022
001cc12
remove Clean trait implementation for hir::BareFnTy
GuillaumeGomez Aug 12, 2022
dcead65
Make `[rust] use-lld=true` work on windows
khyperia Aug 12, 2022
2787eb0
Use different name for arity-2 `@has` and `@matches`
camelid Aug 10, 2022
01408fc
Rename `@{has,matches}-literal` to `...text`
camelid Aug 10, 2022
37eed1d
Update tests: arity-2 `@{has,matches}` -> `...text`
camelid Aug 10, 2022
13d5327
Rename `@hastext` to `@hasraw` (same for `matches`)
camelid Aug 10, 2022
9db6061
Fix line lengths
camelid Aug 11, 2022
52a1518
give a helpful diagnostic even when the next struct field has an attr…
chenyukang Aug 13, 2022
b34e240
Update `@!has` name in tests
camelid Aug 12, 2022
0d588e9
rustdoc: Fix incorrect usage of `@!has` and `@!matches`
camelid Aug 13, 2022
2dc9bf0
nicer Miri backtraces for from_exposed_addr
RalfJung Aug 13, 2022
40b1f61
move
BoxyUwU Aug 13, 2022
1ec2b9b
wf correctly shallow_resolve consts
lcnr Aug 13, 2022
4b51df3
Rollup merge of #100355 - camelid:has2-rename, r=GuillaumeGomez
compiler-errors Aug 13, 2022
ea42f3c
Rollup merge of #100407 - RalfJung:no-int2ptr, r=Mark-Simulacrum
compiler-errors Aug 13, 2022
2126cc6
Rollup merge of #100434 - compiler-errors:issue-100373, r=cjgillot
compiler-errors Aug 13, 2022
9ab54df
Rollup merge of #100438 - compiler-errors:issue-100360, r=lcnr
compiler-errors Aug 13, 2022
ef72484
Rollup merge of #100445 - krasimirgg:llvm-16-msan, r=tmiasko
compiler-errors Aug 13, 2022
b1d77dd
Rollup merge of #100447 - GuillaumeGomez:rm-clean-impl, r=Dylan-DPC
compiler-errors Aug 13, 2022
7a34d39
Rollup merge of #100464 - khyperia:lld-icf-on-windows, r=jyn514
compiler-errors Aug 13, 2022
29f905b
Rollup merge of #100475 - chenyukang:fix-100461, r=fee1-dead
compiler-errors Aug 13, 2022
aafaec3
Rollup merge of #100490 - lcnr:wf-consts, r=jackh726
compiler-errors Aug 13, 2022
f8bdd9c
Rollup merge of #100501 - RalfJung:miri-from-exposed-addr, r=Mark-Sim…
compiler-errors Aug 13, 2022
860e093
Rollup merge of #100509 - BoxyUwU:merge_hrtb_with_higher_rank_trait_b…
compiler-errors Aug 13, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions compiler/rustc_const_eval/src/transform/promote_consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -839,17 +839,12 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
let mut promoted_operand = |ty, span| {
promoted.span = span;
promoted.local_decls[RETURN_PLACE] = LocalDecl::new(ty, span);
let substs = tcx.erase_regions(InternalSubsts::identity_for_item(tcx, def.did));
let _const = tcx.mk_const(ty::ConstS {
ty,
kind: ty::ConstKind::Unevaluated(ty::Unevaluated {
def,
substs: InternalSubsts::for_item(tcx, def.did, |param, _| {
if let ty::GenericParamDefKind::Lifetime = param.kind {
tcx.lifetimes.re_erased.into()
} else {
tcx.mk_param_from_def(param)
}
}),
substs,
promoted: Some(promoted_id),
}),
});
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_hir_pretty/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,10 @@ impl<'a> State<'a> {
if let Some(els) = els {
self.nbsp();
self.word_space("else");
// containing cbox, will be closed by print-block at `}`
self.cbox(0);
// head-box, will be closed by print-block after `{`
self.ibox(0);
self.print_block(els);
}

Expand Down
8 changes: 6 additions & 2 deletions compiler/rustc_parse/src/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1544,8 +1544,12 @@ impl<'a> Parser<'a> {
}
}

if self.token.is_ident() {
// This is likely another field; emit the diagnostic and keep going
if self.token.is_ident()
|| (self.token.kind == TokenKind::Pound
&& (self.look_ahead(1, |t| t == &token::OpenDelim(Delimiter::Bracket))))
{
// This is likely another field, TokenKind::Pound is used for `#[..]` attribute for next field,
// emit the diagnostic and keep going
err.span_suggestion(
sp,
"try adding a comma",
Expand Down
16 changes: 7 additions & 9 deletions compiler/rustc_trait_selection/src/traits/wf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,24 @@ pub fn obligations<'a, 'tcx>(
if resolved_ty == ty {
// No progress, bail out to prevent "livelock".
return None;
} else {
resolved_ty
}

resolved_ty
}
_ => ty,
}
.into()
}
GenericArgKind::Const(ct) => {
match ct.kind() {
ty::ConstKind::Infer(infer) => {
let resolved = infcx.shallow_resolve(infer);
if resolved == infer {
ty::ConstKind::Infer(_) => {
let resolved = infcx.shallow_resolve(ct);
if resolved == ct {
// No progress.
return None;
} else {
resolved
}

infcx
.tcx
.mk_const(ty::ConstS { kind: ty::ConstKind::Infer(resolved), ty: ct.ty() })
}
_ => ct,
}
Expand Down
2 changes: 2 additions & 0 deletions library/core/src/ptr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ pub const fn invalid_mut<T>(addr: usize) -> *mut T {
#[must_use]
#[inline]
#[unstable(feature = "strict_provenance", issue = "95228")]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub fn from_exposed_addr<T>(addr: usize) -> *const T
where
T: Sized,
Expand Down Expand Up @@ -639,6 +640,7 @@ where
#[must_use]
#[inline]
#[unstable(feature = "strict_provenance", issue = "95228")]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub fn from_exposed_addr_mut<T>(addr: usize) -> *mut T
where
T: Sized,
Expand Down
9 changes: 5 additions & 4 deletions library/std/src/sys_common/thread_local_key/tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use super::{Key, StaticKey};
use core::ptr;

fn assert_sync<T: Sync>() {}
fn assert_send<T: Send>() {}
Expand All @@ -12,8 +13,8 @@ fn smoke() {
let k2 = Key::new(None);
assert!(k1.get().is_null());
assert!(k2.get().is_null());
k1.set(1 as *mut _);
k2.set(2 as *mut _);
k1.set(ptr::invalid_mut(1));
k2.set(ptr::invalid_mut(2));
assert_eq!(k1.get() as usize, 1);
assert_eq!(k2.get() as usize, 2);
}
Expand All @@ -26,8 +27,8 @@ fn statik() {
unsafe {
assert!(K1.get().is_null());
assert!(K2.get().is_null());
K1.set(1 as *mut _);
K2.set(2 as *mut _);
K1.set(ptr::invalid_mut(1));
K2.set(ptr::invalid_mut(2));
assert_eq!(K1.get() as usize, 1);
assert_eq!(K2.get() as usize, 2);
}
Expand Down
7 changes: 6 additions & 1 deletion src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,12 @@ impl Step for Rustc {

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

Expand Down
22 changes: 13 additions & 9 deletions src/etc/htmldocck.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@
`PATH` is relative to the output directory. It can be given as `-`
which repeats the most recently used `PATH`.

* `@has PATH PATTERN` and `@matches PATH PATTERN` checks for
the occurrence of the given pattern `PATTERN` in the specified file.
* `@hasraw PATH PATTERN` and `@matchesraw PATH PATTERN` checks
for the occurrence of the given pattern `PATTERN` in the specified file.
Only one occurrence of the pattern is enough.

For `@has`, `PATTERN` is a whitespace-normalized (every consecutive
For `@hasraw`, `PATTERN` is a whitespace-normalized (every consecutive
whitespace being replaced by one single space character) string.
The entire file is also whitespace-normalized including newlines.

For `@matches`, `PATTERN` is a Python-supported regular expression.
For `@matchesraw`, `PATTERN` is a Python-supported regular expression.
The file remains intact but the regexp is matched without the `MULTILINE`
and `IGNORECASE` options. You can still use a prefix `(?m)` or `(?i)`
to override them, and `\A` and `\Z` for definitely matching
Expand Down Expand Up @@ -542,19 +542,23 @@ def get_nb_matching_elements(cache, c, regexp, stop_at_first):
def check_command(c, cache):
try:
cerr = ""
if c.cmd == 'has' or c.cmd == 'matches': # string test
regexp = (c.cmd == 'matches')
if len(c.args) == 1 and not regexp: # @has <path> = file existence
if c.cmd in ['has', 'hasraw', 'matches', 'matchesraw']: # string test
regexp = c.cmd.startswith('matches')

# @has <path> = file existence
if len(c.args) == 1 and not regexp and 'raw' not in c.cmd:
try:
cache.get_file(c.args[0])
ret = True
except FailedCheck as err:
cerr = str(err)
ret = False
elif len(c.args) == 2: # @has/matches <path> <pat> = string test
# @hasraw/matchesraw <path> <pat> = string test
elif len(c.args) == 2 and 'raw' in c.cmd:
cerr = "`PATTERN` did not match"
ret = check_string(cache.get_file(c.args[0]), c.args[1], regexp)
elif len(c.args) == 3: # @has/matches <path> <pat> <match> = XML tree test
# @has/matches <path> <pat> <match> = XML tree test
elif len(c.args) == 3 and 'raw' not in c.cmd:
cerr = "`XPATH PATTERN` did not match"
ret = get_nb_matching_elements(cache, c, regexp, True) != 0
else:
Expand Down
58 changes: 33 additions & 25 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1322,14 +1322,17 @@ fn clean_qpath<'tcx>(hir_ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> Type
let trait_def = cx.tcx.associated_item(p.res.def_id()).container_id(cx.tcx);
let trait_ = self::Path {
res: Res::Def(DefKind::Trait, trait_def),
segments: trait_segments.iter().map(|x| x.clean(cx)).collect(),
segments: trait_segments.iter().map(|x| clean_path_segment(x, cx)).collect(),
};
register_res(cx, trait_.res);
let self_def_id = DefId::local(qself.hir_id.owner.local_def_index);
let self_type = clean_ty(qself, cx);
let should_show_cast = compute_should_show_cast(Some(self_def_id), &trait_, &self_type);
Type::QPath {
assoc: Box::new(p.segments.last().expect("segments were empty").clean(cx)),
assoc: Box::new(clean_path_segment(
p.segments.last().expect("segments were empty"),
cx,
)),
should_show_cast,
self_type: Box::new(self_type),
trait_,
Expand All @@ -1349,7 +1352,7 @@ fn clean_qpath<'tcx>(hir_ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> Type
let self_type = clean_ty(qself, cx);
let should_show_cast = compute_should_show_cast(self_def_id, &trait_, &self_type);
Type::QPath {
assoc: Box::new(segment.clean(cx)),
assoc: Box::new(clean_path_segment(segment, cx)),
should_show_cast,
self_type: Box::new(self_type),
trait_,
Expand Down Expand Up @@ -1507,7 +1510,7 @@ pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> T
if !lifetime.is_elided() { Some(clean_lifetime(*lifetime, cx)) } else { None };
DynTrait(bounds, lifetime)
}
TyKind::BareFn(barefn) => BareFunction(Box::new(barefn.clean(cx))),
TyKind::BareFn(barefn) => BareFunction(Box::new(clean_bare_fn_ty(barefn, cx))),
// Rustdoc handles `TyKind::Err`s by turning them into `Type::Infer`s.
TyKind::Infer | TyKind::Err => Infer,
TyKind::Typeof(..) => panic!("unimplemented type {:?}", ty.kind),
Expand Down Expand Up @@ -1823,7 +1826,10 @@ fn clean_variant_data<'tcx>(
}

fn clean_path<'tcx>(path: &hir::Path<'tcx>, cx: &mut DocContext<'tcx>) -> Path {
Path { res: path.res, segments: path.segments.iter().map(|x| x.clean(cx)).collect() }
Path {
res: path.res,
segments: path.segments.iter().map(|x| clean_path_segment(x, cx)).collect(),
}
}

fn clean_generic_args<'tcx>(
Expand Down Expand Up @@ -1861,28 +1867,30 @@ fn clean_generic_args<'tcx>(
}
}

impl<'tcx> Clean<'tcx, PathSegment> for hir::PathSegment<'tcx> {
fn clean(&self, cx: &mut DocContext<'tcx>) -> PathSegment {
PathSegment { name: self.ident.name, args: clean_generic_args(self.args(), cx) }
}
fn clean_path_segment<'tcx>(
path: &hir::PathSegment<'tcx>,
cx: &mut DocContext<'tcx>,
) -> PathSegment {
PathSegment { name: path.ident.name, args: clean_generic_args(path.args(), cx) }
}

impl<'tcx> Clean<'tcx, BareFunctionDecl> for hir::BareFnTy<'tcx> {
fn clean(&self, cx: &mut DocContext<'tcx>) -> BareFunctionDecl {
let (generic_params, decl) = enter_impl_trait(cx, |cx| {
// NOTE: generics must be cleaned before args
let generic_params = self
.generic_params
.iter()
.filter(|p| !is_elided_lifetime(p))
.map(|x| clean_generic_param(cx, None, x))
.collect();
let args = clean_args_from_types_and_names(cx, self.decl.inputs, self.param_names);
let decl = clean_fn_decl_with_args(cx, self.decl, args);
(generic_params, decl)
});
BareFunctionDecl { unsafety: self.unsafety, abi: self.abi, decl, generic_params }
}
fn clean_bare_fn_ty<'tcx>(
bare_fn: &hir::BareFnTy<'tcx>,
cx: &mut DocContext<'tcx>,
) -> BareFunctionDecl {
let (generic_params, decl) = enter_impl_trait(cx, |cx| {
// NOTE: generics must be cleaned before args
let generic_params = bare_fn
.generic_params
.iter()
.filter(|p| !is_elided_lifetime(p))
.map(|x| clean_generic_param(cx, None, x))
.collect();
let args = clean_args_from_types_and_names(cx, bare_fn.decl.inputs, bare_fn.param_names);
let decl = clean_fn_decl_with_args(cx, bare_fn.decl, args);
(generic_params, decl)
});
BareFunctionDecl { unsafety: bare_fn.unsafety, abi: bare_fn.abi, decl, generic_params }
}

fn clean_maybe_renamed_item<'tcx>(
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc/all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ mod private_module {
}

// @has foo/all.html '//a[@href="struct.ReexportedStruct.html"]' 'ReexportedStruct'
// @!has foo/all.html 'private_module'
// @!hasraw foo/all.html 'private_module'
pub use private_module::ReexportedStruct;
8 changes: 4 additions & 4 deletions src/test/rustdoc/assoc-consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub trait Foo {
const FOO: usize = 12 + 1;
// @has - '//*[@id="associatedconstant.FOO_NO_DEFAULT"]' 'const FOO_NO_DEFAULT: bool'
const FOO_NO_DEFAULT: bool;
// @!has - FOO_HIDDEN
// @!hasraw - FOO_HIDDEN
#[doc(hidden)]
const FOO_HIDDEN: u8 = 0;
}
Expand All @@ -18,7 +18,7 @@ impl Foo for Bar {
const FOO: usize = 12;
// @has - '//*[@id="associatedconstant.FOO_NO_DEFAULT"]' 'const FOO_NO_DEFAULT: bool'
const FOO_NO_DEFAULT: bool = false;
// @!has - FOO_HIDDEN
// @!hasraw - FOO_HIDDEN
#[doc(hidden)]
const FOO_HIDDEN: u8 = 0;
}
Expand Down Expand Up @@ -50,9 +50,9 @@ impl Bar {
}

impl Bar {
// @!has assoc_consts/struct.Bar.html 'BAR_PRIVATE'
// @!hasraw assoc_consts/struct.Bar.html 'BAR_PRIVATE'
const BAR_PRIVATE: char = 'a';
// @!has assoc_consts/struct.Bar.html 'BAR_HIDDEN'
// @!hasraw assoc_consts/struct.Bar.html 'BAR_HIDDEN'
#[doc(hidden)]
pub const BAR_HIDDEN: &'static str = "a";
}
Expand Down
6 changes: 3 additions & 3 deletions src/test/rustdoc/const-display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub const fn foo() -> u32 { 42 }
pub const unsafe fn foo_unsafe() -> u32 { 42 }

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

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


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

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

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

pub struct Foo;
Expand Down
Loading