Skip to content

Commit d416093

Browse files
committed
Auto merge of rust-lang#82025 - JohnTitor:rollup-cohp0gy, r=JohnTitor
Rollup of 16 pull requests Successful merges: - rust-lang#79983 (fix indefinite article in cell.rs) - rust-lang#81831 (Don't display `mut` in arguments for functions documentation) - rust-lang#81947 (Relax ItemCtxt::to_ty lifetime) - rust-lang#81954 (RELEASES.md 1.50: Group platform support notes together) - rust-lang#81955 (bootstrap: Locate llvm-dwp based on llvm-config bindir) - rust-lang#81959 (Fix assosiated typo) - rust-lang#81964 (Fix documentation not showing on localStorage error) - rust-lang#81968 (bootstrap: fix wrong docs installation path) - rust-lang#81990 (Make suggestion of changing mutability of arguments broader) - rust-lang#81994 (Improve long explanation for E0542 and E0546) - rust-lang#81997 (dist: include src/build_helper as part of the crate graph for rustc-dev) - rust-lang#82003 (Stack probes: fix error message) - rust-lang#82004 (clean up clean::Static struct) - rust-lang#82011 (Fix private intra-doc warnings on associated items) - rust-lang#82013 (Tell user how to fix CI file being not up to date) - rust-lang#82017 (Fix typo in mod.rs) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents a118ee2 + ff8b7f2 commit d416093

File tree

28 files changed

+288
-135
lines changed

28 files changed

+288
-135
lines changed

RELEASES.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Compiler
1212
- [Added tier 3\* support for the `armv5te-unknown-linux-uclibceabi` target.][78142]
1313
- [Added tier 3 support for the `aarch64-apple-ios-macabi` target.][77484]
1414
- [The `x86_64-unknown-freebsd` is now built with the full toolset.][79484]
15+
- [Dropped support for all cloudabi targets.][78439]
1516

1617
\* Refer to Rust's [platform support page][forge-platform-support] for more
1718
information on Rust's tiered platform support.
@@ -77,7 +78,6 @@ Compatibility Notes
7778
- [`#![test]` as an inner attribute is now considered unstable like other inner macro
7879
attributes, and reports an error by default through the `soft_unstable` lint.][79003]
7980
- [Overriding a `forbid` lint at the same level that it was set is now a hard error.][78864]
80-
- [Dropped support for all cloudabi targets.][78439]
8181
- [You can no longer intercept `panic!` calls by supplying your own macro.][78343] It's
8282
recommended to use the `#[panic_handler]` attribute to provide your own implementation.
8383
- [Semi-colons after item statements (e.g. `struct Foo {};`) now produce a warning.][78296]

compiler/rustc_error_codes/src/error_codes/E0542.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn _stable_const_fn() {}
1919
fn _deprecated_fn() {}
2020
```
2121

22-
To fix the issue you need to provide the `since` field.
22+
To fix this issue, you need to provide the `since` field. Example:
2323

2424
```
2525
#![feature(staged_api)]

compiler/rustc_error_codes/src/error_codes/E0546.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fn unstable_fn() {}
1313
fn stable_fn() {}
1414
```
1515

16-
To fix the issue you need to provide the `feature` field.
16+
To fix this issue, you need to provide the `feature` field. Example:
1717

1818
```
1919
#![feature(staged_api)]

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ impl<'hir> Map<'hir> {
285285
let owner = self.tcx.hir_owner_nodes(id.owner);
286286
owner.and_then(|owner| {
287287
let node = owner.nodes[id.local_id].as_ref();
288-
// FIXME(eddyb) use a single generic type insted of having both
288+
// FIXME(eddyb) use a single generic type instead of having both
289289
// `Entry` and `ParentedNode`, which are effectively the same.
290290
// Alternatively, rewrite code using `Entry` to use `ParentedNode`.
291291
node.map(|node| Entry {

compiler/rustc_mir/src/borrow_check/diagnostics/mutability_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
540540
);
541541
}
542542

543-
// Attempt to search similar mutable assosiated items for suggestion.
543+
// Attempt to search similar mutable associated items for suggestion.
544544
// In the future, attempt in all path but initially for RHS of for_loop
545545
fn suggest_similar_mut_method_for_for_loop(&self, err: &mut DiagnosticBuilder<'_>) {
546546
let hir = self.infcx.tcx.hir();

compiler/rustc_target/src/spec/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ impl StackProbeType {
589589
Ok(StackProbeType::InlineOrCall { min_llvm_version_for_inline })
590590
}
591591
_ => Err(String::from(
592-
"`kind` expected to be one of `inline-or-none`, `call` or `inline-or-call`",
592+
"`kind` expected to be one of `none`, `inline`, `call` or `inline-or-call`",
593593
)),
594594
}
595595
}

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

+15-16
Original file line numberDiff line numberDiff line change
@@ -468,22 +468,21 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
468468
trait_ref,
469469
obligation.cause.body_id,
470470
);
471-
} else {
472-
if !have_alt_message {
473-
// Can't show anything else useful, try to find similar impls.
474-
let impl_candidates = self.find_similar_impl_candidates(trait_ref);
475-
self.report_similar_impl_candidates(impl_candidates, &mut err);
476-
}
477-
// Changing mutability doesn't make a difference to whether we have
478-
// an `Unsize` impl (Fixes ICE in #71036)
479-
if !is_unsize {
480-
self.suggest_change_mut(
481-
&obligation,
482-
&mut err,
483-
trait_ref,
484-
points_at_arg,
485-
);
486-
}
471+
} else if !have_alt_message {
472+
// Can't show anything else useful, try to find similar impls.
473+
let impl_candidates = self.find_similar_impl_candidates(trait_ref);
474+
self.report_similar_impl_candidates(impl_candidates, &mut err);
475+
}
476+
477+
// Changing mutability doesn't make a difference to whether we have
478+
// an `Unsize` impl (Fixes ICE in #71036)
479+
if !is_unsize {
480+
self.suggest_change_mut(
481+
&obligation,
482+
&mut err,
483+
trait_ref,
484+
points_at_arg,
485+
);
487486
}
488487

489488
// If this error is due to `!: Trait` not implemented but `(): Trait` is

compiler/rustc_typeck/src/collect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ impl ItemCtxt<'tcx> {
280280
ItemCtxt { tcx, item_def_id }
281281
}
282282

283-
pub fn to_ty(&self, ast_ty: &'tcx hir::Ty<'tcx>) -> Ty<'tcx> {
283+
pub fn to_ty(&self, ast_ty: &hir::Ty<'_>) -> Ty<'tcx> {
284284
AstConv::ast_ty_to_ty(self, ast_ty)
285285
}
286286

compiler/rustc_typeck/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,7 @@ pub fn hir_ty_to_ty<'tcx>(tcx: TyCtxt<'tcx>, hir_ty: &hir::Ty<'_>) -> Ty<'tcx> {
421421
let env_node_id = tcx.hir().get_parent_item(hir_ty.hir_id);
422422
let env_def_id = tcx.hir().local_def_id(env_node_id);
423423
let item_cx = self::collect::ItemCtxt::new(tcx, env_def_id.to_def_id());
424-
425-
astconv::AstConv::ast_ty_to_ty(&item_cx, hir_ty)
424+
item_cx.to_ty(hir_ty)
426425
}
427426

428427
pub fn hir_trait_to_predicates<'tcx>(

library/core/src/cell.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1622,7 +1622,7 @@ impl<T: ?Sized + fmt::Display> fmt::Display for RefMut<'_, T> {
16221622
/// `UnsafeCell<T>` is a type that wraps some `T` and indicates unsafe interior operations on the
16231623
/// wrapped type. Types with an `UnsafeCell<T>` field are considered to have an 'unsafe interior'.
16241624
/// The `UnsafeCell<T>` type is the only legal way to obtain aliasable data that is considered
1625-
/// mutable. In general, transmuting an `&T` type into an `&mut T` is considered undefined behavior.
1625+
/// mutable. In general, transmuting a `&T` type into a `&mut T` is considered undefined behavior.
16261626
///
16271627
/// If you have a reference `&SomeStruct`, then normally in Rust all fields of `SomeStruct` are
16281628
/// immutable. The compiler makes optimizations based on the knowledge that `&T` is not mutably

src/bootstrap/compile.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1075,8 +1075,11 @@ impl Step for Assemble {
10751075
let src_exe = exe("llvm-dwp", target_compiler.host);
10761076
let dst_exe = exe("rust-llvm-dwp", target_compiler.host);
10771077
let llvm_config_bin = builder.ensure(native::Llvm { target: target_compiler.host });
1078-
let llvm_bin_dir = llvm_config_bin.parent().unwrap();
1079-
builder.copy(&llvm_bin_dir.join(&src_exe), &libdir_bin.join(&dst_exe));
1078+
if !builder.config.dry_run {
1079+
let llvm_bin_dir = output(Command::new(llvm_config_bin).arg("--bindir"));
1080+
let llvm_bin_dir = Path::new(llvm_bin_dir.trim());
1081+
builder.copy(&llvm_bin_dir.join(&src_exe), &libdir_bin.join(&dst_exe));
1082+
}
10801083
}
10811084

10821085
// Ensure that `libLLVM.so` ends up in the newly build compiler directory,

src/bootstrap/dist.rs

+8
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,14 @@ impl Step for RustcDev {
645645
&[],
646646
&tarball.image_dir().join("lib/rustlib/rustc-src/rust"),
647647
);
648+
// This particular crate is used as a build dependency of the above.
649+
copy_src_dirs(
650+
builder,
651+
&builder.src,
652+
&["src/build_helper"],
653+
&[],
654+
&tarball.image_dir().join("lib/rustlib/rustc-src/rust"),
655+
);
648656
for file in src_files {
649657
tarball.add_file(builder.src.join(file), "lib/rustlib/rustc-src/rust", 0o644);
650658
}

src/bootstrap/install.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn install_sh(
2929
let prefix = default_path(&builder.config.prefix, "/usr/local");
3030
let sysconfdir = prefix.join(default_path(&builder.config.sysconfdir, "/etc"));
3131
let datadir = prefix.join(default_path(&builder.config.datadir, "share"));
32-
let docdir = prefix.join(default_path(&builder.config.docdir, "share/doc"));
32+
let docdir = prefix.join(default_path(&builder.config.docdir, "share/doc/rust"));
3333
let mandir = prefix.join(default_path(&builder.config.mandir, "share/man"));
3434
let libdir = prefix.join(default_path(&builder.config.libdir, "lib"));
3535
let bindir = prefix.join(&builder.config.bindir); // Default in config.rs

src/librustdoc/clean/inline.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ fn build_static(cx: &DocContext<'_>, did: DefId, mutable: bool) -> clean::Static
510510
clean::Static {
511511
type_: cx.tcx.type_of(did).clean(cx),
512512
mutability: if mutable { Mutability::Mut } else { Mutability::Not },
513-
expr: "\n\n\n".to_string(), // trigger the "[definition]" links
513+
expr: None,
514514
}
515515
}
516516

src/librustdoc/clean/mod.rs

+11-15
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ impl Clean<Constant> for hir::ConstArg {
408408
.tcx
409409
.type_of(cx.tcx.hir().body_owner_def_id(self.value.body).to_def_id())
410410
.clean(cx),
411-
expr: print_const_expr(cx, self.value.body),
411+
expr: print_const_expr(cx.tcx, self.value.body),
412412
value: None,
413413
is_literal: is_literal_expr(cx, self.value.body.hir_id),
414414
}
@@ -961,7 +961,7 @@ impl<'a> Clean<Arguments> for (&'a [hir::Ty<'a>], hir::BodyId) {
961961
.iter()
962962
.enumerate()
963963
.map(|(i, ty)| Argument {
964-
name: Symbol::intern(&rustc_hir_pretty::param_to_string(&body.params[i])),
964+
name: name_from_pat(&body.params[i].pat),
965965
type_: ty.clean(cx),
966966
})
967967
.collect(),
@@ -1052,7 +1052,7 @@ impl Clean<Item> for hir::TraitItem<'_> {
10521052
cx.with_param_env(local_did, || {
10531053
let inner = match self.kind {
10541054
hir::TraitItemKind::Const(ref ty, default) => {
1055-
AssocConstItem(ty.clean(cx), default.map(|e| print_const_expr(cx, e)))
1055+
AssocConstItem(ty.clean(cx), default.map(|e| print_const_expr(cx.tcx, e)))
10561056
}
10571057
hir::TraitItemKind::Fn(ref sig, hir::TraitFn::Provided(body)) => {
10581058
let mut m = (sig, &self.generics, body).clean(cx);
@@ -1093,7 +1093,7 @@ impl Clean<Item> for hir::ImplItem<'_> {
10931093
cx.with_param_env(local_did, || {
10941094
let inner = match self.kind {
10951095
hir::ImplItemKind::Const(ref ty, expr) => {
1096-
AssocConstItem(ty.clean(cx), Some(print_const_expr(cx, expr)))
1096+
AssocConstItem(ty.clean(cx), Some(print_const_expr(cx.tcx, expr)))
10971097
}
10981098
hir::ImplItemKind::Fn(ref sig, body) => {
10991099
let mut m = (sig, &self.generics, body).clean(cx);
@@ -1954,14 +1954,12 @@ impl Clean<Vec<Item>> for (&hir::Item<'_>, Option<Symbol>) {
19541954
let mut name = renamed.unwrap_or_else(|| cx.tcx.hir().name(item.hir_id));
19551955
cx.with_param_env(def_id, || {
19561956
let kind = match item.kind {
1957-
ItemKind::Static(ty, mutability, body_id) => StaticItem(Static {
1958-
type_: ty.clean(cx),
1959-
mutability,
1960-
expr: print_const_expr(cx, body_id),
1961-
}),
1957+
ItemKind::Static(ty, mutability, body_id) => {
1958+
StaticItem(Static { type_: ty.clean(cx), mutability, expr: Some(body_id) })
1959+
}
19621960
ItemKind::Const(ty, body_id) => ConstantItem(Constant {
19631961
type_: ty.clean(cx),
1964-
expr: print_const_expr(cx, body_id),
1962+
expr: print_const_expr(cx.tcx, body_id),
19651963
value: print_evaluated_const(cx, def_id),
19661964
is_literal: is_literal_expr(cx, body_id.hir_id),
19671965
}),
@@ -2263,11 +2261,9 @@ impl Clean<Item> for (&hir::ForeignItem<'_>, Option<Symbol>) {
22632261
},
22642262
})
22652263
}
2266-
hir::ForeignItemKind::Static(ref ty, mutability) => ForeignStaticItem(Static {
2267-
type_: ty.clean(cx),
2268-
mutability,
2269-
expr: String::new(),
2270-
}),
2264+
hir::ForeignItemKind::Static(ref ty, mutability) => {
2265+
ForeignStaticItem(Static { type_: ty.clean(cx), mutability, expr: None })
2266+
}
22712267
hir::ForeignItemKind::Type => ForeignTypeItem,
22722268
};
22732269

src/librustdoc/clean/types.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use rustc_hir as hir;
1919
use rustc_hir::def::{CtorKind, Res};
2020
use rustc_hir::def_id::{CrateNum, DefId, DefIndex};
2121
use rustc_hir::lang_items::LangItem;
22-
use rustc_hir::Mutability;
22+
use rustc_hir::{BodyId, Mutability};
2323
use rustc_index::vec::IndexVec;
2424
use rustc_middle::ty::{self, TyCtxt};
2525
use rustc_session::Session;
@@ -1955,10 +1955,7 @@ crate struct BareFunctionDecl {
19551955
crate struct Static {
19561956
crate type_: Type,
19571957
crate mutability: Mutability,
1958-
/// It's useful to have the value of a static documented, but I have no
1959-
/// desire to represent expressions (that'd basically be all of the AST,
1960-
/// which is huge!). So, have a string.
1961-
crate expr: String,
1958+
crate expr: Option<BodyId>,
19621959
}
19631960

19641961
#[derive(Clone, PartialEq, Eq, Hash, Debug)]

src/librustdoc/clean/utils.rs

+73-5
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,25 @@ crate fn strip_path(path: &Path) -> Path {
195195
Path { global: path.global, res: path.res, segments }
196196
}
197197

198+
crate fn qpath_to_string(p: &hir::QPath<'_>) -> String {
199+
let segments = match *p {
200+
hir::QPath::Resolved(_, ref path) => &path.segments,
201+
hir::QPath::TypeRelative(_, ref segment) => return segment.ident.to_string(),
202+
hir::QPath::LangItem(lang_item, ..) => return lang_item.name().to_string(),
203+
};
204+
205+
let mut s = String::new();
206+
for (i, seg) in segments.iter().enumerate() {
207+
if i > 0 {
208+
s.push_str("::");
209+
}
210+
if seg.ident.name != kw::PathRoot {
211+
s.push_str(&seg.ident.as_str());
212+
}
213+
}
214+
s
215+
}
216+
198217
crate fn build_deref_target_impls(cx: &DocContext<'_>, items: &[Item], ret: &mut Vec<Item>) {
199218
let tcx = cx.tcx;
200219

@@ -232,12 +251,60 @@ impl ToSource for rustc_span::Span {
232251
}
233252
}
234253

254+
crate fn name_from_pat(p: &hir::Pat<'_>) -> Symbol {
255+
use rustc_hir::*;
256+
debug!("trying to get a name from pattern: {:?}", p);
257+
258+
Symbol::intern(&match p.kind {
259+
PatKind::Wild => return kw::Underscore,
260+
PatKind::Binding(_, _, ident, _) => return ident.name,
261+
PatKind::TupleStruct(ref p, ..) | PatKind::Path(ref p) => qpath_to_string(p),
262+
PatKind::Struct(ref name, ref fields, etc) => format!(
263+
"{} {{ {}{} }}",
264+
qpath_to_string(name),
265+
fields
266+
.iter()
267+
.map(|fp| format!("{}: {}", fp.ident, name_from_pat(&fp.pat)))
268+
.collect::<Vec<String>>()
269+
.join(", "),
270+
if etc { ", .." } else { "" }
271+
),
272+
PatKind::Or(ref pats) => pats
273+
.iter()
274+
.map(|p| name_from_pat(&**p).to_string())
275+
.collect::<Vec<String>>()
276+
.join(" | "),
277+
PatKind::Tuple(ref elts, _) => format!(
278+
"({})",
279+
elts.iter()
280+
.map(|p| name_from_pat(&**p).to_string())
281+
.collect::<Vec<String>>()
282+
.join(", ")
283+
),
284+
PatKind::Box(ref p) => return name_from_pat(&**p),
285+
PatKind::Ref(ref p, _) => return name_from_pat(&**p),
286+
PatKind::Lit(..) => {
287+
warn!(
288+
"tried to get argument name from PatKind::Lit, which is silly in function arguments"
289+
);
290+
return Symbol::intern("()");
291+
}
292+
PatKind::Range(..) => return kw::Underscore,
293+
PatKind::Slice(ref begin, ref mid, ref end) => {
294+
let begin = begin.iter().map(|p| name_from_pat(&**p).to_string());
295+
let mid = mid.as_ref().map(|p| format!("..{}", name_from_pat(&**p))).into_iter();
296+
let end = end.iter().map(|p| name_from_pat(&**p).to_string());
297+
format!("[{}]", begin.chain(mid).chain(end).collect::<Vec<_>>().join(", "))
298+
}
299+
})
300+
}
301+
235302
crate fn print_const(cx: &DocContext<'_>, n: &'tcx ty::Const<'_>) -> String {
236303
match n.val {
237304
ty::ConstKind::Unevaluated(def, _, promoted) => {
238305
let mut s = if let Some(def) = def.as_local() {
239306
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(def.did);
240-
print_const_expr(cx, cx.tcx.hir().body_owned_by(hir_id))
307+
print_const_expr(cx.tcx, cx.tcx.hir().body_owned_by(hir_id))
241308
} else {
242309
inline::print_inlined_const(cx, def.did)
243310
};
@@ -326,16 +393,17 @@ crate fn is_literal_expr(cx: &DocContext<'_>, hir_id: hir::HirId) -> bool {
326393
false
327394
}
328395

329-
crate fn print_const_expr(cx: &DocContext<'_>, body: hir::BodyId) -> String {
330-
let value = &cx.tcx.hir().body(body).value;
396+
crate fn print_const_expr(tcx: TyCtxt<'_>, body: hir::BodyId) -> String {
397+
let hir = tcx.hir();
398+
let value = &hir.body(body).value;
331399

332400
let snippet = if !value.span.from_expansion() {
333-
cx.sess().source_map().span_to_snippet(value.span).ok()
401+
tcx.sess.source_map().span_to_snippet(value.span).ok()
334402
} else {
335403
None
336404
};
337405

338-
snippet.unwrap_or_else(|| rustc_hir_pretty::id_to_string(&cx.tcx.hir(), body.hir_id))
406+
snippet.unwrap_or_else(|| rustc_hir_pretty::id_to_string(&hir, body.hir_id))
339407
}
340408

341409
/// Given a type Path, resolve it to a Type using the TyCtxt

0 commit comments

Comments
 (0)