Skip to content

Rollup of 15 pull requests #76974

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

Closed
wants to merge 44 commits into from
Closed
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
fd79ed4
Add docs for `BasicBlock`
camelid Sep 15, 2020
a872ec4
Clarify how branching works in a CFG
camelid Sep 15, 2020
c051f61
Improve wording
camelid Sep 15, 2020
57eb29c
Update based on review suggestions
camelid Sep 16, 2020
c946c40
Let backends define custom targets
khyperia Sep 17, 2020
48655c2
PR feedback
khyperia Sep 17, 2020
451f7f6
Use relative link instead of absolute
camelid Sep 17, 2020
baafc71
Remove unused libc feature gate
est31 Sep 18, 2020
bdb039d
Use intra-doc links
denisvasilik Sep 18, 2020
4af1b90
Move to intra-doc links
denisvasilik Sep 18, 2020
49c8fcb
Use intra-doc links
denisvasilik Sep 18, 2020
b9af3e3
bootstrap: move the version number to a plaintext file
pietroalbini Sep 18, 2020
2230d8d
Update library/alloc/src/collections/binary_heap.rs
denisvasilik Sep 18, 2020
ec7225f
Update library/alloc/src/collections/binary_heap.rs
denisvasilik Sep 18, 2020
62e0ee1
Update library/alloc/src/collections/binary_heap.rs
denisvasilik Sep 18, 2020
719c40c
Update library/alloc/src/collections/binary_heap.rs
denisvasilik Sep 18, 2020
18ce4c1
README.md: Remove prompts from code blocks
Sep 18, 2020
28588e5
Add missing examples on HashSet iter types
GuillaumeGomez Sep 18, 2020
40dddd3
use matches!() macro for simple if let conditions
matthiaskrgr Sep 18, 2020
925cd26
don't take `TyCtxt` by reference
lcnr Sep 18, 2020
4debbdc
transmute: use diagnostic item
lcnr Sep 19, 2020
39f1259
cfg bootstrap
lcnr Sep 19, 2020
0eecbd4
wording
lcnr Sep 19, 2020
bfa2030
update docs
lcnr Sep 19, 2020
a60f978
Add tracking issue for feature(unix_socket_peek)
rijenkii Sep 19, 2020
c6a8cfb
BTreeMap: code readability tweaks
ssomers Aug 16, 2020
367efa8
Don't allow implementing trait directly on type-alias-impl-trait
Aaron1011 Sep 19, 2020
f9fa649
Use intra-doc links
denisvasilik Sep 18, 2020
562422e
Remove some unused features from alloc core and std
est31 Sep 18, 2020
332b43f
Rollup merge of #76732 - camelid:mir-basic-block-docs, r=RalfJung
RalfJung Sep 20, 2020
c37ed0e
Rollup merge of #76832 - khyperia:backend_target_override, r=eddyb
RalfJung Sep 20, 2020
4f20431
Rollup merge of #76866 - est31:master, r=lcnr
RalfJung Sep 20, 2020
c5531c6
Rollup merge of #76875 - denisvasilik:intra-doc-links-alloc-binary-he…
RalfJung Sep 20, 2020
f009ebe
Rollup merge of #76876 - denisvasilik:intra-doc-links-alloc, r=jyn514
RalfJung Sep 20, 2020
837ab96
Rollup merge of #76877 - denisvasilik:intra-doc-links-alloc-vec-deque…
RalfJung Sep 20, 2020
77b1580
Rollup merge of #76878 - pietroalbini:version, r=Mark-Simulacrum
RalfJung Sep 20, 2020
ba7142b
Rollup merge of #76883 - qlcom:master, r=Mark-Simulacrum
RalfJung Sep 20, 2020
eb9f51f
Rollup merge of #76887 - GuillaumeGomez:hashset-iter-types-examples, …
RalfJung Sep 20, 2020
da24493
Rollup merge of #76890 - matthiaskrgr:matches_simpl, r=lcnr
RalfJung Sep 20, 2020
c15cbc1
Rollup merge of #76891 - lcnr:less-ref, r=ecstatic-morse
RalfJung Sep 20, 2020
bd539e1
Rollup merge of #76910 - lcnr:foreign-item-like, r=oli-obk
RalfJung Sep 20, 2020
623af71
Rollup merge of #76924 - rijenkii:patch-1, r=oli-obk
RalfJung Sep 20, 2020
009e360
Rollup merge of #76926 - ssomers:btree_cleanup_1, r=Mark-Simulacrum
RalfJung Sep 20, 2020
a855358
Rollup merge of #76940 - Aaron1011:fix/trait-on-tait, r=oli-obk
RalfJung Sep 20, 2020
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
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -44,8 +44,8 @@ by running `./x.py --help` or reading the [rustc dev guide][rustcguidebuild].
2. Clone the [source] with `git`:

```sh
$ git clone https://github.com/rust-lang/rust.git
$ cd rust
git clone https://github.com/rust-lang/rust.git
cd rust
```

[source]: https://github.com/rust-lang/rust
@@ -57,7 +57,7 @@ by running `./x.py --help` or reading the [rustc dev guide][rustcguidebuild].
Copy the default `config.toml.example` to `config.toml` to get started.

```sh
$ cp config.toml.example config.toml
cp config.toml.example config.toml
```

If you plan to use `x.py install` to create an installation, it is recommended
@@ -68,7 +68,7 @@ by running `./x.py --help` or reading the [rustc dev guide][rustcguidebuild].
4. Build and install:

```sh
$ ./x.py build && ./x.py install
./x.py build && ./x.py install
```

When complete, `./x.py install` will place several programs into
@@ -106,15 +106,15 @@ build.

```sh
# Update package mirrors (may be needed if you have a fresh install of MSYS2)
$ pacman -Sy pacman-mirrors
pacman -Sy pacman-mirrors

# Install build tools needed for Rust. If you're building a 32-bit compiler,
# then replace "x86_64" below with "i686". If you've already got git, python,
# or CMake installed and in PATH you can remove them from this list. Note
# that it is important that you do **not** use the 'python2', 'cmake' and 'ninja'
# packages from the 'msys2' subsystem. The build has historically been known
# to fail with these packages.
$ pacman -S git \
pacman -S git \
make \
diffutils \
tar \
@@ -127,7 +127,7 @@ build.
4. Navigate to Rust's source code (or clone it), then build it:

```sh
$ ./x.py build && ./x.py install
./x.py build && ./x.py install
```

#### MSVC
@@ -145,7 +145,7 @@ With these dependencies installed, you can build the compiler in a `cmd.exe`
shell with:

```sh
> python x.py build
python x.py build
```

Currently, building Rust only works with some known versions of Visual Studio. If
@@ -154,8 +154,8 @@ you may need to force rustbuild to use an older version. This can be done
by manually calling the appropriate vcvars file before running the bootstrap.

```batch
> CALL "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
> python x.py build
CALL "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
python x.py build
```

#### Specifying an ABI
@@ -181,8 +181,8 @@ While it's not the recommended build system, this project also provides a
configure script and makefile (the latter of which just invokes `x.py`).

```sh
$ ./configure
$ make && sudo make install
./configure
make && sudo make install
```

When using the configure script, the generated `config.mk` file may override the
@@ -194,7 +194,7 @@ When using the configure script, the generated `config.mk` file may override the
If you’d like to build the documentation, it’s almost the same:

```sh
$ ./x.py doc
./x.py doc
```

The generated documentation will appear under `doc` in the `build` directory for
6 changes: 3 additions & 3 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
@@ -1931,7 +1931,7 @@ pub enum TyKind {

impl TyKind {
pub fn is_implicit_self(&self) -> bool {
if let TyKind::ImplicitSelf = *self { true } else { false }
matches!(self, TyKind::ImplicitSelf)
}

pub fn is_unit(&self) -> bool {
@@ -2227,7 +2227,7 @@ pub enum Async {

impl Async {
pub fn is_async(self) -> bool {
if let Async::Yes { .. } = self { true } else { false }
matches!(self, Async::Yes { .. })
}

/// In this case this is an `async` return, the `NodeId` for the generated `impl Trait` item.
@@ -2508,7 +2508,7 @@ pub enum VisibilityKind {

impl VisibilityKind {
pub fn is_pub(&self) -> bool {
if let VisibilityKind::Public = *self { true } else { false }
matches!(self, VisibilityKind::Public)
}
}

5 changes: 1 addition & 4 deletions compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
@@ -868,10 +868,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
.emit();
}

if !bounds
.iter()
.any(|b| if let GenericBound::Trait(..) = *b { true } else { false })
{
if !bounds.iter().any(|b| matches!(b, GenericBound::Trait(..))) {
self.err_handler().span_err(ty.span, "at least one trait must be specified");
}

4 changes: 2 additions & 2 deletions compiler/rustc_attr/src/builtin.rs
Original file line number Diff line number Diff line change
@@ -160,10 +160,10 @@ pub enum StabilityLevel {

impl StabilityLevel {
pub fn is_unstable(&self) -> bool {
if let StabilityLevel::Unstable { .. } = *self { true } else { false }
matches!(self, StabilityLevel::Unstable { .. })
}
pub fn is_stable(&self) -> bool {
if let StabilityLevel::Stable { .. } = *self { true } else { false }
matches!(self, StabilityLevel::Stable { .. })
}
}

2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
Original file line number Diff line number Diff line change
@@ -1529,7 +1529,7 @@ impl<'a> TraitDef<'a> {
}
}

let is_tuple = if let ast::VariantData::Tuple(..) = struct_def { true } else { false };
let is_tuple = matches!(struct_def, ast::VariantData::Tuple(..));
match (just_spans.is_empty(), named_idents.is_empty()) {
(false, false) => cx.span_bug(
self.span,
7 changes: 7 additions & 0 deletions compiler/rustc_codegen_ssa/src/traits/backend.rs
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ use rustc_session::{
};
use rustc_span::symbol::Symbol;
use rustc_target::abi::LayoutOf;
use rustc_target::spec::Target;

pub use rustc_data_structures::sync::MetadataRef;

@@ -54,6 +55,12 @@ pub trait CodegenBackend {
fn print_passes(&self) {}
fn print_version(&self) {}

/// If this plugin provides additional builtin targets, provide the one enabled by the options here.
/// Be careful: this is called *before* init() is called.
fn target_override(&self, _opts: &config::Options) -> Option<Target> {
None
}

fn metadata_loader(&self) -> Box<MetadataLoaderDyn>;
fn provide(&self, _providers: &mut Providers);
fn provide_extern(&self, _providers: &mut Providers);
8 changes: 3 additions & 5 deletions compiler/rustc_errors/src/snippet.rs
Original file line number Diff line number Diff line change
@@ -118,17 +118,15 @@ pub struct Annotation {
impl Annotation {
/// Whether this annotation is a vertical line placeholder.
pub fn is_line(&self) -> bool {
if let AnnotationType::MultilineLine(_) = self.annotation_type { true } else { false }
matches!(self.annotation_type, AnnotationType::MultilineLine(_))
}

pub fn is_multiline(&self) -> bool {
match self.annotation_type {
matches!(self.annotation_type,
AnnotationType::Multiline(_)
| AnnotationType::MultilineStart(_)
| AnnotationType::MultilineLine(_)
| AnnotationType::MultilineEnd(_) => true,
_ => false,
}
| AnnotationType::MultilineEnd(_))
}

pub fn len(&self) -> usize {
1 change: 1 addition & 0 deletions compiler/rustc_interface/src/tests.rs
Original file line number Diff line number Diff line change
@@ -40,6 +40,7 @@ fn mk_session(matches: getopts::Matches) -> (Session, CfgSpecs) {
DiagnosticOutput::Default,
Default::default(),
None,
None,
);
(sess, cfg)
}
15 changes: 9 additions & 6 deletions compiler/rustc_interface/src/util.rs
Original file line number Diff line number Diff line change
@@ -65,16 +65,21 @@ pub fn create_session(
lint_caps: FxHashMap<lint::LintId, lint::Level>,
descriptions: Registry,
) -> (Lrc<Session>, Lrc<Box<dyn CodegenBackend>>) {
let codegen_backend = get_codegen_backend(&sopts);
// target_override is documented to be called before init(), so this is okay
let target_override = codegen_backend.target_override(&sopts);

let mut sess = session::build_session(
sopts,
input_path,
descriptions,
diagnostic_output,
lint_caps,
file_loader,
target_override,
);

let codegen_backend = get_codegen_backend(&sess);
codegen_backend.init(&sess);

let mut cfg = config::build_configuration(&sess, config::to_crate_config(cfg));
add_configuration(&mut cfg, &mut sess, &*codegen_backend);
@@ -219,13 +224,13 @@ fn load_backend_from_dylib(path: &Path) -> fn() -> Box<dyn CodegenBackend> {
}
}

pub fn get_codegen_backend(sess: &Session) -> Box<dyn CodegenBackend> {
pub fn get_codegen_backend(sopts: &config::Options) -> Box<dyn CodegenBackend> {
static INIT: Once = Once::new();

static mut LOAD: fn() -> Box<dyn CodegenBackend> = || unreachable!();

INIT.call_once(|| {
let codegen_name = sess.opts.debugging_opts.codegen_backend.as_deref().unwrap_or("llvm");
let codegen_name = sopts.debugging_opts.codegen_backend.as_deref().unwrap_or("llvm");
let backend = match codegen_name {
filename if filename.contains('.') => load_backend_from_dylib(filename.as_ref()),
codegen_name => get_builtin_codegen_backend(codegen_name),
@@ -235,9 +240,7 @@ pub fn get_codegen_backend(sess: &Session) -> Box<dyn CodegenBackend> {
LOAD = backend;
}
});
let backend = unsafe { LOAD() };
backend.init(sess);
backend
unsafe { LOAD() }
}

// This is used for rustdoc, but it uses similar machinery to codegen backend
22 changes: 8 additions & 14 deletions compiler/rustc_lint/src/builtin.rs
Original file line number Diff line number Diff line change
@@ -1984,9 +1984,9 @@ impl ExplicitOutlivesRequirements {
.filter_map(|(i, bound)| {
if let hir::GenericBound::Outlives(lifetime) = bound {
let is_inferred = match tcx.named_region(lifetime.hir_id) {
Some(Region::Static) if infer_static => inferred_outlives
.iter()
.any(|r| if let ty::ReStatic = r { true } else { false }),
Some(Region::Static) if infer_static => {
inferred_outlives.iter().any(|r| matches!(r, ty::ReStatic))
}
Some(Region::EarlyBound(index, ..)) => inferred_outlives.iter().any(|r| {
if let ty::ReEarlyBound(ebr) = r { ebr.index == index } else { false }
}),
@@ -2078,9 +2078,10 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitOutlivesRequirements {
let mut lint_spans = Vec::new();

for param in hir_generics.params {
let has_lifetime_bounds = param.bounds.iter().any(|bound| {
if let hir::GenericBound::Outlives(_) = bound { true } else { false }
});
let has_lifetime_bounds = param
.bounds
.iter()
.any(|bound| matches!(bound, hir::GenericBound::Outlives(_)));
if !has_lifetime_bounds {
continue;
}
@@ -2349,13 +2350,6 @@ impl<'tcx> LateLintPass<'tcx> for InvalidValue {

/// Determine if this expression is a "dangerous initialization".
fn is_dangerous_init(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> Option<InitKind> {
// `transmute` is inside an anonymous module (the `extern` block?);
// `Invalid` represents the empty string and matches that.
// FIXME(#66075): use diagnostic items. Somehow, that does not seem to work
// on intrinsics right now.
const TRANSMUTE_PATH: &[Symbol] =
&[sym::core, sym::intrinsics, kw::Invalid, sym::transmute];

if let hir::ExprKind::Call(ref path_expr, ref args) = expr.kind {
// Find calls to `mem::{uninitialized,zeroed}` methods.
if let hir::ExprKind::Path(ref qpath) = path_expr.kind {
@@ -2365,7 +2359,7 @@ impl<'tcx> LateLintPass<'tcx> for InvalidValue {
return Some(InitKind::Zeroed);
} else if cx.tcx.is_diagnostic_item(sym::mem_uninitialized, def_id) {
return Some(InitKind::Uninit);
} else if cx.match_def_path(def_id, TRANSMUTE_PATH) {
} else if cx.tcx.is_diagnostic_item(sym::transmute, def_id) {
if is_zero(&args[0]) {
return Some(InitKind::Zeroed);
}
4 changes: 4 additions & 0 deletions compiler/rustc_lint/src/context.rs
Original file line number Diff line number Diff line change
@@ -720,6 +720,10 @@ impl<'tcx> LateContext<'tcx> {
/// Anonymous scopes such as `extern` imports are matched with `kw::Invalid`;
/// inherent `impl` blocks are matched with the name of the type.
///
/// Instead of using this method, it is often preferable to instead use
/// `rustc_diagnostic_item` or a `lang_item`. This is less prone to errors
/// as paths get invalidated if the target definition moves.
///
/// # Examples
///
/// ```rust,ignore (no context or def id available)
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/middle/cstore.rs
Original file line number Diff line number Diff line change
@@ -69,7 +69,7 @@ pub enum LibSource {

impl LibSource {
pub fn is_some(&self) -> bool {
if let LibSource::Some(_) = *self { true } else { false }
matches!(self, LibSource::Some(_))
}

pub fn option(&self) -> Option<PathBuf> {
6 changes: 3 additions & 3 deletions compiler/rustc_middle/src/middle/lang_items.rs
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ use rustc_target::spec::PanicStrategy;
impl<'tcx> TyCtxt<'tcx> {
/// Returns the `DefId` for a given `LangItem`.
/// If not found, fatally aborts compilation.
pub fn require_lang_item(&self, lang_item: LangItem, span: Option<Span>) -> DefId {
pub fn require_lang_item(self, lang_item: LangItem, span: Option<Span>) -> DefId {
self.lang_items().require(lang_item).unwrap_or_else(|msg| {
if let Some(span) = span {
self.sess.span_fatal(span, &msg)
@@ -27,7 +27,7 @@ impl<'tcx> TyCtxt<'tcx> {
})
}

pub fn fn_trait_kind_from_lang_item(&self, id: DefId) -> Option<ty::ClosureKind> {
pub fn fn_trait_kind_from_lang_item(self, id: DefId) -> Option<ty::ClosureKind> {
let items = self.lang_items();
match Some(id) {
x if x == items.fn_trait() => Some(ty::ClosureKind::Fn),
@@ -37,7 +37,7 @@ impl<'tcx> TyCtxt<'tcx> {
}
}

pub fn is_weak_lang_item(&self, item_def_id: DefId) -> bool {
pub fn is_weak_lang_item(self, item_def_id: DefId) -> bool {
self.lang_items().is_weak_lang_item(item_def_id)
}
}
Loading