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 16 pull requests #82025

Merged
merged 35 commits into from
Feb 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
2b9ba46
fix indefinite article in cell.rs
petar-dambovaliev Dec 12, 2020
2a67e2e
Revert "Get rid of custom pretty-printing in rustdoc"
LeSeulArtichaut Feb 6, 2021
471ed5f
Use ItemCtxt::to_ty
camsteffen Feb 10, 2021
883988b
RELEASES.md 1.50: Group platform support notes together
joshtriplett Feb 10, 2021
d3fea13
bootstrap: Locate llvm-dwp based on llvm-config bindir
dtolnay Feb 10, 2021
a6d4137
Fix assosiated typo
therealprof Feb 10, 2021
f13bbea
Catch errors on localStorage setting failure
lovasoa Feb 10, 2021
16f0ccd
Fix getCurrentValue
lovasoa Feb 10, 2021
793e88a
Add regression test for #81289
LeSeulArtichaut Feb 6, 2021
089ee27
Do not ICE on range patterns in function arguments
LeSeulArtichaut Feb 8, 2021
5034b50
bootstrap: fix wrong docs installation path
pietroalbini Feb 10, 2021
e03f097
Make suggestion of changing mutability of arguments broader
hkmatsumoto Feb 11, 2021
a99d869
Improve long explanation for E0542 and E0546
jesusprubio Feb 11, 2021
f492b25
dist: include src/build_helper as part of the crate graph for rustc-dev.
bnjbvr Feb 11, 2021
0df8dde
Stack probes: fix error message
ojeda Feb 11, 2021
583563d
clean up clean::Static struct
GuillaumeGomez Feb 11, 2021
67fb96c
Fix private intra-doc warnings on associated items
jyn514 Feb 12, 2021
a355507
Tell user how to fix CI file being not up to date
Mark-Simulacrum Feb 12, 2021
c8eeb34
Fix typo in mod.rs
eltociear Feb 12, 2021
0b6876c
Rollup merge of #79983 - petar-dambovaliev:master, r=Dylan-DPC
JohnTitor Feb 12, 2021
327762f
Rollup merge of #81831 - LeSeulArtichaut:81289-mut-arg, r=camelid
JohnTitor Feb 12, 2021
c07260d
Rollup merge of #81947 - camsteffen:to-ty, r=jyn514
JohnTitor Feb 12, 2021
2a76add
Rollup merge of #81954 - joshtriplett:release-notes-group-platform-no…
JohnTitor Feb 12, 2021
67403da
Rollup merge of #81955 - dtolnay:dwp, r=Mark-Simulacrum
JohnTitor Feb 12, 2021
0b7fc80
Rollup merge of #81959 - therealprof:fix-typo, r=oli-obk
JohnTitor Feb 12, 2021
0f47e19
Rollup merge of #81964 - lovasoa:patch-1, r=GuillaumeGomez
JohnTitor Feb 12, 2021
459dda9
Rollup merge of #81968 - pietroalbini:fix-doc-install-path, r=Mark-Si…
JohnTitor Feb 12, 2021
46aef0e
Rollup merge of #81990 - matsujika:suggest-mut-reference, r=estebank
JohnTitor Feb 12, 2021
44d2871
Rollup merge of #81994 - jesusprubio:improve-long-explanation-e0542-e…
JohnTitor Feb 12, 2021
71fd431
Rollup merge of #81997 - bnjbvr:dist-include-build-helper, r=Mark-Sim…
JohnTitor Feb 12, 2021
55539cb
Rollup merge of #82003 - ojeda:stack-probe-msg, r=estebank
JohnTitor Feb 12, 2021
1a9d20b
Rollup merge of #82004 - GuillaumeGomez:clean-static-struct, r=jyn514
JohnTitor Feb 12, 2021
6830ea1
Rollup merge of #82011 - jyn514:warn-private-assoc-item, r=max-heller
JohnTitor Feb 12, 2021
095b76c
Rollup merge of #82013 - Mark-Simulacrum:better-ci-error, r=jyn514
JohnTitor Feb 12, 2021
ff8b7f2
Rollup merge of #82017 - eltociear:patch-8, r=jyn514
JohnTitor Feb 12, 2021
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
2 changes: 1 addition & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Compiler
- [Added tier 3\* support for the `armv5te-unknown-linux-uclibceabi` target.][78142]
- [Added tier 3 support for the `aarch64-apple-ios-macabi` target.][77484]
- [The `x86_64-unknown-freebsd` is now built with the full toolset.][79484]
- [Dropped support for all cloudabi targets.][78439]

\* Refer to Rust's [platform support page][forge-platform-support] for more
information on Rust's tiered platform support.
Expand Down Expand Up @@ -77,7 +78,6 @@ Compatibility Notes
- [`#![test]` as an inner attribute is now considered unstable like other inner macro
attributes, and reports an error by default through the `soft_unstable` lint.][79003]
- [Overriding a `forbid` lint at the same level that it was set is now a hard error.][78864]
- [Dropped support for all cloudabi targets.][78439]
- [You can no longer intercept `panic!` calls by supplying your own macro.][78343] It's
recommended to use the `#[panic_handler]` attribute to provide your own implementation.
- [Semi-colons after item statements (e.g. `struct Foo {};`) now produce a warning.][78296]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_error_codes/src/error_codes/E0542.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn _stable_const_fn() {}
fn _deprecated_fn() {}
```

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

```
#![feature(staged_api)]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_error_codes/src/error_codes/E0546.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn unstable_fn() {}
fn stable_fn() {}
```

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

```
#![feature(staged_api)]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ impl<'hir> Map<'hir> {
let owner = self.tcx.hir_owner_nodes(id.owner);
owner.and_then(|owner| {
let node = owner.nodes[id.local_id].as_ref();
// FIXME(eddyb) use a single generic type insted of having both
// FIXME(eddyb) use a single generic type instead of having both
// `Entry` and `ParentedNode`, which are effectively the same.
// Alternatively, rewrite code using `Entry` to use `ParentedNode`.
node.map(|node| Entry {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
);
}

// Attempt to search similar mutable assosiated items for suggestion.
// Attempt to search similar mutable associated items for suggestion.
// In the future, attempt in all path but initially for RHS of for_loop
fn suggest_similar_mut_method_for_for_loop(&self, err: &mut DiagnosticBuilder<'_>) {
let hir = self.infcx.tcx.hir();
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ impl StackProbeType {
Ok(StackProbeType::InlineOrCall { min_llvm_version_for_inline })
}
_ => Err(String::from(
"`kind` expected to be one of `inline-or-none`, `call` or `inline-or-call`",
"`kind` expected to be one of `none`, `inline`, `call` or `inline-or-call`",
)),
}
}
Expand Down
31 changes: 15 additions & 16 deletions compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,22 +468,21 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
trait_ref,
obligation.cause.body_id,
);
} else {
if !have_alt_message {
// Can't show anything else useful, try to find similar impls.
let impl_candidates = self.find_similar_impl_candidates(trait_ref);
self.report_similar_impl_candidates(impl_candidates, &mut err);
}
// Changing mutability doesn't make a difference to whether we have
// an `Unsize` impl (Fixes ICE in #71036)
if !is_unsize {
self.suggest_change_mut(
&obligation,
&mut err,
trait_ref,
points_at_arg,
);
}
} else if !have_alt_message {
// Can't show anything else useful, try to find similar impls.
let impl_candidates = self.find_similar_impl_candidates(trait_ref);
self.report_similar_impl_candidates(impl_candidates, &mut err);
}

// Changing mutability doesn't make a difference to whether we have
// an `Unsize` impl (Fixes ICE in #71036)
if !is_unsize {
self.suggest_change_mut(
&obligation,
&mut err,
trait_ref,
points_at_arg,
);
}

// If this error is due to `!: Trait` not implemented but `(): Trait` is
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ impl ItemCtxt<'tcx> {
ItemCtxt { tcx, item_def_id }
}

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

Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_typeck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,7 @@ pub fn hir_ty_to_ty<'tcx>(tcx: TyCtxt<'tcx>, hir_ty: &hir::Ty<'_>) -> Ty<'tcx> {
let env_node_id = tcx.hir().get_parent_item(hir_ty.hir_id);
let env_def_id = tcx.hir().local_def_id(env_node_id);
let item_cx = self::collect::ItemCtxt::new(tcx, env_def_id.to_def_id());

astconv::AstConv::ast_ty_to_ty(&item_cx, hir_ty)
item_cx.to_ty(hir_ty)
}

pub fn hir_trait_to_predicates<'tcx>(
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1622,7 +1622,7 @@ impl<T: ?Sized + fmt::Display> fmt::Display for RefMut<'_, T> {
/// `UnsafeCell<T>` is a type that wraps some `T` and indicates unsafe interior operations on the
/// wrapped type. Types with an `UnsafeCell<T>` field are considered to have an 'unsafe interior'.
/// The `UnsafeCell<T>` type is the only legal way to obtain aliasable data that is considered
/// mutable. In general, transmuting an `&T` type into an `&mut T` is considered undefined behavior.
/// mutable. In general, transmuting a `&T` type into a `&mut T` is considered undefined behavior.
///
/// If you have a reference `&SomeStruct`, then normally in Rust all fields of `SomeStruct` are
/// immutable. The compiler makes optimizations based on the knowledge that `&T` is not mutably
Expand Down
7 changes: 5 additions & 2 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1075,8 +1075,11 @@ impl Step for Assemble {
let src_exe = exe("llvm-dwp", target_compiler.host);
let dst_exe = exe("rust-llvm-dwp", target_compiler.host);
let llvm_config_bin = builder.ensure(native::Llvm { target: target_compiler.host });
let llvm_bin_dir = llvm_config_bin.parent().unwrap();
builder.copy(&llvm_bin_dir.join(&src_exe), &libdir_bin.join(&dst_exe));
if !builder.config.dry_run {
let llvm_bin_dir = output(Command::new(llvm_config_bin).arg("--bindir"));
let llvm_bin_dir = Path::new(llvm_bin_dir.trim());
builder.copy(&llvm_bin_dir.join(&src_exe), &libdir_bin.join(&dst_exe));
}
}

// Ensure that `libLLVM.so` ends up in the newly build compiler directory,
Expand Down
8 changes: 8 additions & 0 deletions src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,14 @@ impl Step for RustcDev {
&[],
&tarball.image_dir().join("lib/rustlib/rustc-src/rust"),
);
// This particular crate is used as a build dependency of the above.
copy_src_dirs(
builder,
&builder.src,
&["src/build_helper"],
&[],
&tarball.image_dir().join("lib/rustlib/rustc-src/rust"),
);
for file in src_files {
tarball.add_file(builder.src.join(file), "lib/rustlib/rustc-src/rust", 0o644);
}
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn install_sh(
let prefix = default_path(&builder.config.prefix, "/usr/local");
let sysconfdir = prefix.join(default_path(&builder.config.sysconfdir, "/etc"));
let datadir = prefix.join(default_path(&builder.config.datadir, "share"));
let docdir = prefix.join(default_path(&builder.config.docdir, "share/doc"));
let docdir = prefix.join(default_path(&builder.config.docdir, "share/doc/rust"));
let mandir = prefix.join(default_path(&builder.config.mandir, "share/man"));
let libdir = prefix.join(default_path(&builder.config.libdir, "lib"));
let bindir = prefix.join(&builder.config.bindir); // Default in config.rs
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ fn build_static(cx: &DocContext<'_>, did: DefId, mutable: bool) -> clean::Static
clean::Static {
type_: cx.tcx.type_of(did).clean(cx),
mutability: if mutable { Mutability::Mut } else { Mutability::Not },
expr: "\n\n\n".to_string(), // trigger the "[definition]" links
expr: None,
}
}

Expand Down
26 changes: 11 additions & 15 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ impl Clean<Constant> for hir::ConstArg {
.tcx
.type_of(cx.tcx.hir().body_owner_def_id(self.value.body).to_def_id())
.clean(cx),
expr: print_const_expr(cx, self.value.body),
expr: print_const_expr(cx.tcx, self.value.body),
value: None,
is_literal: is_literal_expr(cx, self.value.body.hir_id),
}
Expand Down Expand Up @@ -961,7 +961,7 @@ impl<'a> Clean<Arguments> for (&'a [hir::Ty<'a>], hir::BodyId) {
.iter()
.enumerate()
.map(|(i, ty)| Argument {
name: Symbol::intern(&rustc_hir_pretty::param_to_string(&body.params[i])),
name: name_from_pat(&body.params[i].pat),
type_: ty.clean(cx),
})
.collect(),
Expand Down Expand Up @@ -1052,7 +1052,7 @@ impl Clean<Item> for hir::TraitItem<'_> {
cx.with_param_env(local_did, || {
let inner = match self.kind {
hir::TraitItemKind::Const(ref ty, default) => {
AssocConstItem(ty.clean(cx), default.map(|e| print_const_expr(cx, e)))
AssocConstItem(ty.clean(cx), default.map(|e| print_const_expr(cx.tcx, e)))
}
hir::TraitItemKind::Fn(ref sig, hir::TraitFn::Provided(body)) => {
let mut m = (sig, &self.generics, body).clean(cx);
Expand Down Expand Up @@ -1093,7 +1093,7 @@ impl Clean<Item> for hir::ImplItem<'_> {
cx.with_param_env(local_did, || {
let inner = match self.kind {
hir::ImplItemKind::Const(ref ty, expr) => {
AssocConstItem(ty.clean(cx), Some(print_const_expr(cx, expr)))
AssocConstItem(ty.clean(cx), Some(print_const_expr(cx.tcx, expr)))
}
hir::ImplItemKind::Fn(ref sig, body) => {
let mut m = (sig, &self.generics, body).clean(cx);
Expand Down Expand Up @@ -1954,14 +1954,12 @@ impl Clean<Vec<Item>> for (&hir::Item<'_>, Option<Symbol>) {
let mut name = renamed.unwrap_or_else(|| cx.tcx.hir().name(item.hir_id));
cx.with_param_env(def_id, || {
let kind = match item.kind {
ItemKind::Static(ty, mutability, body_id) => StaticItem(Static {
type_: ty.clean(cx),
mutability,
expr: print_const_expr(cx, body_id),
}),
ItemKind::Static(ty, mutability, body_id) => {
StaticItem(Static { type_: ty.clean(cx), mutability, expr: Some(body_id) })
}
ItemKind::Const(ty, body_id) => ConstantItem(Constant {
type_: ty.clean(cx),
expr: print_const_expr(cx, body_id),
expr: print_const_expr(cx.tcx, body_id),
value: print_evaluated_const(cx, def_id),
is_literal: is_literal_expr(cx, body_id.hir_id),
}),
Expand Down Expand Up @@ -2263,11 +2261,9 @@ impl Clean<Item> for (&hir::ForeignItem<'_>, Option<Symbol>) {
},
})
}
hir::ForeignItemKind::Static(ref ty, mutability) => ForeignStaticItem(Static {
type_: ty.clean(cx),
mutability,
expr: String::new(),
}),
hir::ForeignItemKind::Static(ref ty, mutability) => {
ForeignStaticItem(Static { type_: ty.clean(cx), mutability, expr: None })
}
hir::ForeignItemKind::Type => ForeignTypeItem,
};

Expand Down
7 changes: 2 additions & 5 deletions src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use rustc_hir as hir;
use rustc_hir::def::{CtorKind, Res};
use rustc_hir::def_id::{CrateNum, DefId, DefIndex};
use rustc_hir::lang_items::LangItem;
use rustc_hir::Mutability;
use rustc_hir::{BodyId, Mutability};
use rustc_index::vec::IndexVec;
use rustc_middle::ty::{self, TyCtxt};
use rustc_session::Session;
Expand Down Expand Up @@ -1955,10 +1955,7 @@ crate struct BareFunctionDecl {
crate struct Static {
crate type_: Type,
crate mutability: Mutability,
/// It's useful to have the value of a static documented, but I have no
/// desire to represent expressions (that'd basically be all of the AST,
/// which is huge!). So, have a string.
crate expr: String,
crate expr: Option<BodyId>,
}

#[derive(Clone, PartialEq, Eq, Hash, Debug)]
Expand Down
78 changes: 73 additions & 5 deletions src/librustdoc/clean/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,25 @@ crate fn strip_path(path: &Path) -> Path {
Path { global: path.global, res: path.res, segments }
}

crate fn qpath_to_string(p: &hir::QPath<'_>) -> String {
let segments = match *p {
hir::QPath::Resolved(_, ref path) => &path.segments,
hir::QPath::TypeRelative(_, ref segment) => return segment.ident.to_string(),
hir::QPath::LangItem(lang_item, ..) => return lang_item.name().to_string(),
};

let mut s = String::new();
for (i, seg) in segments.iter().enumerate() {
if i > 0 {
s.push_str("::");
}
if seg.ident.name != kw::PathRoot {
s.push_str(&seg.ident.as_str());
}
}
s
}

crate fn build_deref_target_impls(cx: &DocContext<'_>, items: &[Item], ret: &mut Vec<Item>) {
let tcx = cx.tcx;

Expand Down Expand Up @@ -232,12 +251,60 @@ impl ToSource for rustc_span::Span {
}
}

crate fn name_from_pat(p: &hir::Pat<'_>) -> Symbol {
use rustc_hir::*;
debug!("trying to get a name from pattern: {:?}", p);

Symbol::intern(&match p.kind {
PatKind::Wild => return kw::Underscore,
PatKind::Binding(_, _, ident, _) => return ident.name,
PatKind::TupleStruct(ref p, ..) | PatKind::Path(ref p) => qpath_to_string(p),
PatKind::Struct(ref name, ref fields, etc) => format!(
"{} {{ {}{} }}",
qpath_to_string(name),
fields
.iter()
.map(|fp| format!("{}: {}", fp.ident, name_from_pat(&fp.pat)))
.collect::<Vec<String>>()
.join(", "),
if etc { ", .." } else { "" }
),
PatKind::Or(ref pats) => pats
.iter()
.map(|p| name_from_pat(&**p).to_string())
.collect::<Vec<String>>()
.join(" | "),
PatKind::Tuple(ref elts, _) => format!(
"({})",
elts.iter()
.map(|p| name_from_pat(&**p).to_string())
.collect::<Vec<String>>()
.join(", ")
),
PatKind::Box(ref p) => return name_from_pat(&**p),
PatKind::Ref(ref p, _) => return name_from_pat(&**p),
PatKind::Lit(..) => {
warn!(
"tried to get argument name from PatKind::Lit, which is silly in function arguments"
);
return Symbol::intern("()");
}
PatKind::Range(..) => return kw::Underscore,
PatKind::Slice(ref begin, ref mid, ref end) => {
let begin = begin.iter().map(|p| name_from_pat(&**p).to_string());
let mid = mid.as_ref().map(|p| format!("..{}", name_from_pat(&**p))).into_iter();
let end = end.iter().map(|p| name_from_pat(&**p).to_string());
format!("[{}]", begin.chain(mid).chain(end).collect::<Vec<_>>().join(", "))
}
})
}

crate fn print_const(cx: &DocContext<'_>, n: &'tcx ty::Const<'_>) -> String {
match n.val {
ty::ConstKind::Unevaluated(def, _, promoted) => {
let mut s = if let Some(def) = def.as_local() {
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(def.did);
print_const_expr(cx, cx.tcx.hir().body_owned_by(hir_id))
print_const_expr(cx.tcx, cx.tcx.hir().body_owned_by(hir_id))
} else {
inline::print_inlined_const(cx, def.did)
};
Expand Down Expand Up @@ -326,16 +393,17 @@ crate fn is_literal_expr(cx: &DocContext<'_>, hir_id: hir::HirId) -> bool {
false
}

crate fn print_const_expr(cx: &DocContext<'_>, body: hir::BodyId) -> String {
let value = &cx.tcx.hir().body(body).value;
crate fn print_const_expr(tcx: TyCtxt<'_>, body: hir::BodyId) -> String {
let hir = tcx.hir();
let value = &hir.body(body).value;

let snippet = if !value.span.from_expansion() {
cx.sess().source_map().span_to_snippet(value.span).ok()
tcx.sess.source_map().span_to_snippet(value.span).ok()
} else {
None
};

snippet.unwrap_or_else(|| rustc_hir_pretty::id_to_string(&cx.tcx.hir(), body.hir_id))
snippet.unwrap_or_else(|| rustc_hir_pretty::id_to_string(&hir, body.hir_id))
}

/// Given a type Path, resolve it to a Type using the TyCtxt
Expand Down
Loading