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 #79165

Closed
wants to merge 26 commits into from
Closed
Changes from 2 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9feb567
Updated the list of white-listed target features for x86
DevJPM Oct 25, 2020
cd95e93
Removed movbe from run-time-detect
DevJPM Oct 25, 2020
3daa93f
Updated documentation, x86 feature detection testing, and removed LLV…
DevJPM Oct 26, 2020
909c894
stability: More precise location for deprecation lint on macros
petrochenkov Nov 12, 2020
55d7f73
Tighten the bounds on atomic Ordering in std::sys::unix::weak
thomcc Nov 14, 2020
72b83af
Re-enable LLVM 9 target features with LLVM 9 being the minimum now
DevJPM Nov 15, 2020
c82a258
Turn top-level comments into module docs in MIR visitor
camelid Nov 15, 2020
dcc194c
instrument `QueryNormalizer::fold_ty`
lcnr Nov 16, 2020
d701bf9
Enable AVX512 *epi64 variants by updating stdarch
vertexclique Nov 17, 2020
d17874f
bootstrap: use the same version number for rustc and cargo
pietroalbini Nov 17, 2020
9bbc4c1
add trailing_zeros and leading_zeros to non zero types
andjo403 Nov 17, 2020
95eff66
Fix handling of panic calls
camelid Nov 17, 2020
bdaa76c
Fix typo in `std::io::Write` docs
wchargin Nov 17, 2020
7edc4f2
Update tests to remove old numeric constants
Oct 24, 2020
88584d5
change error for `LayoutErr::SizeOverflow`
lcnr Nov 18, 2020
db8ad67
Rollup merge of #78361 - DevJPM:master, r=workingjubilee
m-ou-se Nov 18, 2020
0b80f64
Rollup merge of #78380 - bstrie:rm-old-num-const-from-tests, r=jyn514
m-ou-se Nov 18, 2020
ed01d96
Rollup merge of #78999 - petrochenkov:deprid, r=eddyb
m-ou-se Nov 18, 2020
f7fb2a9
Rollup merge of #79039 - thomcc:weakly-relaxing, r=Amanieu
m-ou-se Nov 18, 2020
1bd70a2
Rollup merge of #79079 - camelid:mir-visit-docs, r=matthewjasper
m-ou-se Nov 18, 2020
6a6607a
Rollup merge of #79114 - andjo403:nonzero_leading_trailing_zeros, r=m…
m-ou-se Nov 18, 2020
6f0bf1a
Rollup merge of #79131 - vertexclique:stdarch-update, r=Amanieu
m-ou-se Nov 18, 2020
a43afdf
Rollup merge of #79133 - pietroalbini:simplify-stage0, r=Mark-Simulacrum
m-ou-se Nov 18, 2020
c15c1f4
Rollup merge of #79145 - camelid:clippy-fix-panics, r=flip1995
m-ou-se Nov 18, 2020
74e6442
Rollup merge of #79151 - wchargin:wchargin-io-write-docs, r=jyn514
m-ou-se Nov 18, 2020
97cd4c4
Rollup merge of #79158 - lcnr:lazy-norm-coerce, r=oli-obk
m-ou-se Nov 18, 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
124 changes: 62 additions & 62 deletions compiler/rustc_middle/src/mir/visit.rs
Original file line number Diff line number Diff line change
@@ -1,70 +1,70 @@
//! # The MIR Visitor
//!
//! ## Overview
//!
//! There are two visitors, one for immutable and one for mutable references,
//! but both are generated by the following macro. The code is written according
//! to the following conventions:
//!
//! - introduce a `visit_foo` and a `super_foo` method for every MIR type
//! - `visit_foo`, by default, calls `super_foo`
//! - `super_foo`, by default, destructures the `foo` and calls `visit_foo`
//!
//! This allows you as a user to override `visit_foo` for types are
//! interested in, and invoke (within that method) call
//! `self.super_foo` to get the default behavior. Just as in an OO
//! language, you should never call `super` methods ordinarily except
//! in that circumstance.
//!
//! For the most part, we do not destructure things external to the
//! MIR, e.g., types, spans, etc, but simply visit them and stop. This
//! avoids duplication with other visitors like `TypeFoldable`.
//!
//! ## Updating
//!
//! The code is written in a very deliberate style intended to minimize
//! the chance of things being overlooked. You'll notice that we always
//! use pattern matching to reference fields and we ensure that all
//! matches are exhaustive.
//!
//! For example, the `super_basic_block_data` method begins like this:
//!
//! ```rust
//! fn super_basic_block_data(&mut self,
//! block: BasicBlock,
//! data: & $($mutability)? BasicBlockData<'tcx>) {
//! let BasicBlockData {
//! statements,
//! terminator,
//! is_cleanup: _
//! } = *data;
//!
//! for statement in statements {
//! self.visit_statement(block, statement);
//! }
//!
//! ...
//! }
//! ```
//!
//! Here we used `let BasicBlockData { <fields> } = *data` deliberately,
//! rather than writing `data.statements` in the body. This is because if one
//! adds a new field to `BasicBlockData`, one will be forced to revise this code,
//! and hence one will (hopefully) invoke the correct visit methods (if any).
//!
//! For this to work, ALL MATCHES MUST BE EXHAUSTIVE IN FIELDS AND VARIANTS.
//! That means you never write `..` to skip over fields, nor do you write `_`
//! to skip over variants in a `match`.
//!
//! The only place that `_` is acceptable is to match a field (or
//! variant argument) that does not require visiting, as in
//! `is_cleanup` above.

use crate::mir::*;
use crate::ty::subst::SubstsRef;
use crate::ty::{CanonicalUserTypeAnnotation, Ty};
use rustc_span::Span;

// # The MIR Visitor
//
// ## Overview
//
// There are two visitors, one for immutable and one for mutable references,
// but both are generated by the following macro. The code is written according
// to the following conventions:
//
// - introduce a `visit_foo` and a `super_foo` method for every MIR type
// - `visit_foo`, by default, calls `super_foo`
// - `super_foo`, by default, destructures the `foo` and calls `visit_foo`
//
// This allows you as a user to override `visit_foo` for types are
// interested in, and invoke (within that method) call
// `self.super_foo` to get the default behavior. Just as in an OO
// language, you should never call `super` methods ordinarily except
// in that circumstance.
//
// For the most part, we do not destructure things external to the
// MIR, e.g., types, spans, etc, but simply visit them and stop. This
// avoids duplication with other visitors like `TypeFoldable`.
//
// ## Updating
//
// The code is written in a very deliberate style intended to minimize
// the chance of things being overlooked. You'll notice that we always
// use pattern matching to reference fields and we ensure that all
// matches are exhaustive.
//
// For example, the `super_basic_block_data` method begins like this:
//
// ```rust
// fn super_basic_block_data(&mut self,
// block: BasicBlock,
// data: & $($mutability)? BasicBlockData<'tcx>) {
// let BasicBlockData {
// statements,
// terminator,
// is_cleanup: _
// } = *data;
//
// for statement in statements {
// self.visit_statement(block, statement);
// }
//
// ...
// }
// ```
//
// Here we used `let BasicBlockData { <fields> } = *data` deliberately,
// rather than writing `data.statements` in the body. This is because if one
// adds a new field to `BasicBlockData`, one will be forced to revise this code,
// and hence one will (hopefully) invoke the correct visit methods (if any).
//
// For this to work, ALL MATCHES MUST BE EXHAUSTIVE IN FIELDS AND VARIANTS.
// That means you never write `..` to skip over fields, nor do you write `_`
// to skip over variants in a `match`.
//
// The only place that `_` is acceptable is to match a field (or
// variant argument) that does not require visiting, as in
// `is_cleanup` above.

macro_rules! make_mir_visitor {
($visitor_trait_name:ident, $($mutability:ident)?) => {
pub trait $visitor_trait_name<'tcx> {