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 14 pull requests #82460

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
3ed189e
Cleanup `PpMode` and friends
LeSeulArtichaut Feb 18, 2021
dd3772e
A few more code cleanups
LeSeulArtichaut Feb 19, 2021
7ad4b7a
Replace normalize.css 3.0.0 with unminified version.
jsha Feb 20, 2021
9bbd482
Update normalize.css to 8.0.1
jsha Feb 20, 2021
7acb105
Re-minify normalize.css.
jsha Feb 20, 2021
10f2342
Remove some P-s
bugadani Feb 20, 2021
fece59b
Change `find_anon_type` method to function
0yoyoyo Feb 21, 2021
17176cc
Add indication of anonymous lifetime position
0yoyoyo Feb 21, 2021
ce1a521
Apply tidy check
0yoyoyo Feb 21, 2021
b9449a3
Add option enabling MIR inlining independently of mir-opt-level
tmiasko Feb 21, 2021
5c546be
Use optional values for inlining thresholds
tmiasko Feb 21, 2021
5f7d663
:arrow_up: rust-analyzer
lnicola Feb 22, 2021
75d1e30
Update test cases
0yoyoyo Feb 22, 2021
24c23f5
Test hexagon-enum only when llvm target is present
nagisa Feb 22, 2021
c02d210
Add tests
petrochenkov Feb 22, 2021
fc9d578
expand: Preserve order of inert attributes during expansion
petrochenkov Feb 22, 2021
e8dcc02
Add a `size()` function to WASI's `MetadataExt`.
sunfishcode Feb 22, 2021
fa74d48
Improve error msgs when found type is deref of expected
osa1 Feb 21, 2021
132ec26
Enable API documentation for `std::os::wasi`.
sunfishcode Feb 22, 2021
a6eb836
Use #[doc = include_str!()] in std
LeSeulArtichaut Dec 30, 2020
de6f1b8
Do not consider using a semicolon inside of a different-crate macro
notriddle Feb 14, 2021
df78eea
expand: Resolve and expand inner attributes on out-of-line modules
petrochenkov Feb 21, 2021
408ccd7
Rollup merge of #80534 - LeSeulArtichaut:doc-include, r=jyn514
Dylan-DPC Feb 24, 2021
d3e3d58
Rollup merge of #82090 - notriddle:consider-using-a-semicolon-here, r…
Dylan-DPC Feb 24, 2021
1975088
Rollup merge of #82269 - LeSeulArtichaut:cleanup-ppmode, r=spastorino
Dylan-DPC Feb 24, 2021
b98f608
Rollup merge of #82313 - jsha:update-normalize-css, r=GuillaumeGomez
Dylan-DPC Feb 24, 2021
2ffc621
Rollup merge of #82321 - bugadani:ast3, r=varkor
Dylan-DPC Feb 24, 2021
b0458bc
Rollup merge of #82364 - osa1:issue82361, r=estebank
Dylan-DPC Feb 24, 2021
5fdfc09
Rollup merge of #82370 - 0yoyoyo:update-issue-81650-point-anonymous-l…
Dylan-DPC Feb 24, 2021
936a488
Rollup merge of #82376 - tmiasko:inline-options, r=oli-obk
Dylan-DPC Feb 24, 2021
5878913
Rollup merge of #82394 - lnicola:rust-analyzer-2021-02-22, r=jonas-sc…
Dylan-DPC Feb 24, 2021
cc0c8f1
Rollup merge of #82399 - petrochenkov:modin2, r=Aaron1011
Dylan-DPC Feb 24, 2021
fb19700
Rollup merge of #82404 - nagisa:nagisa/hexagon-enums-llvm-comps, r=pe…
Dylan-DPC Feb 24, 2021
4f3203f
Rollup merge of #82419 - petrochenkov:inertord, r=Aaron1011
Dylan-DPC Feb 24, 2021
2d80e0b
Rollup merge of #82420 - sunfishcode:wasi-docs, r=alexcrichton
Dylan-DPC Feb 24, 2021
ec0e4c2
Rollup merge of #82421 - sunfishcode:wasi-metadata-size, r=alexcrichton
Dylan-DPC Feb 24, 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
Next Next commit
Cleanup PpMode and friends
  • Loading branch information
LeSeulArtichaut committed Feb 19, 2021
commit 3ed189e8af09c60aa9410193dacc7c9f11144344
38 changes: 18 additions & 20 deletions compiler/rustc_driver/src/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc_hir_pretty as pprust_hir;
use rustc_middle::hir::map as hir_map;
use rustc_middle::ty::{self, TyCtxt};
use rustc_mir::util::{write_mir_graphviz, write_mir_pretty};
use rustc_session::config::{Input, PpMode, PpSourceMode};
use rustc_session::config::{Input, PpHirMode, PpMode, PpSourceMode};
use rustc_session::Session;
use rustc_span::symbol::Ident;
use rustc_span::FileName;
Expand Down Expand Up @@ -42,43 +42,41 @@ where
F: FnOnce(&dyn PrinterSupport) -> A,
{
match *ppmode {
PpmNormal | PpmEveryBodyLoops | PpmExpanded => {
Normal | EveryBodyLoops | Expanded => {
let annotation = NoAnn { sess, tcx };
f(&annotation)
}

PpmIdentified | PpmExpandedIdentified => {
Identified | ExpandedIdentified => {
let annotation = IdentifiedAnnotation { sess, tcx };
f(&annotation)
}
PpmExpandedHygiene => {
ExpandedHygiene => {
let annotation = HygieneAnnotation { sess };
f(&annotation)
}
_ => panic!("Should use call_with_pp_support_hir"),
}
}
fn call_with_pp_support_hir<A, F>(ppmode: &PpSourceMode, tcx: TyCtxt<'_>, f: F) -> A
fn call_with_pp_support_hir<A, F>(ppmode: &PpHirMode, tcx: TyCtxt<'_>, f: F) -> A
where
F: FnOnce(&dyn HirPrinterSupport<'_>, &hir::Crate<'_>) -> A,
{
match *ppmode {
PpmNormal => {
PpHirMode::Normal => {
let annotation = NoAnn { sess: tcx.sess, tcx: Some(tcx) };
f(&annotation, tcx.hir().krate())
}

PpmIdentified => {
PpHirMode::Identified => {
let annotation = IdentifiedAnnotation { sess: tcx.sess, tcx: Some(tcx) };
f(&annotation, tcx.hir().krate())
}
PpmTyped => {
PpHirMode::Typed => {
abort_on_err(tcx.analysis(LOCAL_CRATE), tcx.sess);

let annotation = TypedAnnotation { tcx, maybe_typeck_results: Cell::new(None) };
tcx.dep_graph.with_ignore(|| f(&annotation, tcx.hir().krate()))
}
_ => panic!("Should use call_with_pp_support"),
}
}

Expand Down Expand Up @@ -395,7 +393,7 @@ pub fn print_after_parsing(

let mut out = String::new();

if let PpmSource(s) = ppm {
if let Source(s) = ppm {
// Silently ignores an identified node.
let out = &mut out;
call_with_pp_support(&s, sess, None, move |annotation| {
Expand Down Expand Up @@ -436,7 +434,7 @@ pub fn print_after_hir_lowering<'tcx>(
let mut out = String::new();

match ppm {
PpmSource(s) => {
Source(s) => {
// Silently ignores an identified node.
let out = &mut out;
call_with_pp_support(&s, tcx.sess, Some(tcx), move |annotation| {
Expand All @@ -455,20 +453,20 @@ pub fn print_after_hir_lowering<'tcx>(
})
}

PpmHir(s) => {
Hir(s) => {
let out = &mut out;
call_with_pp_support_hir(&s, tcx, move |annotation, krate| {
debug!("pretty printing source code {:?}", s);
debug!("pretty printing HIR {:?}", s);
let sess = annotation.sess();
let sm = sess.source_map();
*out = pprust_hir::print_crate(sm, krate, src_name, src, annotation.pp_ann())
})
}

PpmHirTree(s) => {
HirTree => {
let out = &mut out;
call_with_pp_support_hir(&s, tcx, move |_annotation, krate| {
debug!("pretty printing source code {:?}", s);
call_with_pp_support_hir(&PpHirMode::Normal, tcx, move |_annotation, krate| {
debug!("pretty printing HIR tree");
*out = format!("{:#?}", krate);
});
}
Expand All @@ -493,9 +491,9 @@ fn print_with_analysis(
tcx.analysis(LOCAL_CRATE)?;

match ppm {
PpmMir | PpmMirCFG => match ppm {
PpmMir => write_mir_pretty(tcx, None, &mut out),
PpmMirCFG => write_mir_graphviz(tcx, None, &mut out),
Mir | MirCFG => match ppm {
Mir => write_mir_pretty(tcx, None, &mut out),
MirCFG => write_mir_graphviz(tcx, None, &mut out),
_ => unreachable!(),
},
_ => unreachable!(),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_interface/src/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ fn configure_and_expand_inner<'a>(
rustc_builtin_macros::test_harness::inject(&sess, &mut resolver, &mut krate)
});

if let Some(PpMode::PpmSource(PpSourceMode::PpmEveryBodyLoops)) = sess.opts.pretty {
if let Some(PpMode::Source(PpSourceMode::EveryBodyLoops)) = sess.opts.pretty {
tracing::debug!("replacing bodies with loop {{}}");
util::ReplaceBodyWithLoop::new(&mut resolver).visit_crate(&mut krate);
}
Expand Down
117 changes: 64 additions & 53 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2068,40 +2068,21 @@ fn parse_pretty(
debugging_opts: &DebuggingOptions,
efmt: ErrorOutputType,
) -> Option<PpMode> {
let pretty = if debugging_opts.unstable_options {
matches.opt_default("pretty", "normal").map(|a| {
// stable pretty-print variants only
parse_pretty_inner(efmt, &a, false)
})
} else {
None
};

return if pretty.is_none() {
debugging_opts.unpretty.as_ref().map(|a| {
// extended with unstable pretty-print variants
parse_pretty_inner(efmt, &a, true)
})
} else {
pretty
};

fn parse_pretty_inner(efmt: ErrorOutputType, name: &str, extended: bool) -> PpMode {
use PpMode::*;
use PpSourceMode::*;
let first = match (name, extended) {
("normal", _) => PpmSource(PpmNormal),
("identified", _) => PpmSource(PpmIdentified),
("everybody_loops", true) => PpmSource(PpmEveryBodyLoops),
("expanded", _) => PpmSource(PpmExpanded),
("expanded,identified", _) => PpmSource(PpmExpandedIdentified),
("expanded,hygiene", _) => PpmSource(PpmExpandedHygiene),
("hir", true) => PpmHir(PpmNormal),
("hir,identified", true) => PpmHir(PpmIdentified),
("hir,typed", true) => PpmHir(PpmTyped),
("hir-tree", true) => PpmHirTree(PpmNormal),
("mir", true) => PpmMir,
("mir-cfg", true) => PpmMirCFG,
("normal", _) => Source(PpSourceMode::Normal),
("identified", _) => Source(PpSourceMode::Identified),
("everybody_loops", true) => Source(PpSourceMode::EveryBodyLoops),
("expanded", _) => Source(PpSourceMode::Expanded),
("expanded,identified", _) => Source(PpSourceMode::ExpandedIdentified),
("expanded,hygiene", _) => Source(PpSourceMode::ExpandedHygiene),
("hir", true) => Hir(PpHirMode::Normal),
("hir,identified", true) => Hir(PpHirMode::Identified),
("hir,typed", true) => Hir(PpHirMode::Typed),
("hir-tree", true) => HirTree,
("mir", true) => Mir,
("mir-cfg", true) => MirCFG,
_ => {
if extended {
early_error(
Expand Down Expand Up @@ -2130,6 +2111,18 @@ fn parse_pretty(
tracing::debug!("got unpretty option: {:?}", first);
first
}

if debugging_opts.unstable_options {
if let Some(a) = matches.opt_default("pretty", "normal") {
// stable pretty-print variants only
return Some(parse_pretty_inner(efmt, &a, false));
}
}

debugging_opts.unpretty.as_ref().map(|a| {
// extended with unstable pretty-print variants
parse_pretty_inner(efmt, &a, true)
})
}

pub fn make_crate_type_option() -> RustcOptGroup {
Expand Down Expand Up @@ -2237,45 +2230,63 @@ impl fmt::Display for CrateType {

#[derive(Copy, Clone, PartialEq, Debug)]
pub enum PpSourceMode {
PpmNormal,
PpmEveryBodyLoops,
PpmExpanded,
PpmIdentified,
PpmExpandedIdentified,
PpmExpandedHygiene,
PpmTyped,
/// `--pretty=normal`
Normal,
/// `-Zunpretty=everybody_loops`
EveryBodyLoops,
/// `--pretty=expanded`
Expanded,
/// `--pretty=identified`
Identified,
/// `--pretty=expanded,identified`
ExpandedIdentified,
/// `--pretty=expanded,hygiene`
ExpandedHygiene,
}

#[derive(Copy, Clone, PartialEq, Debug)]
pub enum PpHirMode {
/// `-Zunpretty=hir`
Normal,
/// `-Zunpretty=hir,identified`
Identified,
/// `-Zunpretty=hir,typed`
Typed,
}

#[derive(Copy, Clone, PartialEq, Debug)]
pub enum PpMode {
PpmSource(PpSourceMode),
PpmHir(PpSourceMode),
PpmHirTree(PpSourceMode),
PpmMir,
PpmMirCFG,
/// Options that print the source code, i.e.
/// `--pretty` and `-Zunpretty=everybody_loops`
Source(PpSourceMode),
/// Options that print the HIR, i.e. `-Zunpretty=hir`
Hir(PpHirMode),
/// `-Zunpretty=hir-tree`
HirTree,
/// `-Zunpretty=mir`
Mir,
/// `-Zunpretty=mir-cfg`
MirCFG,
}

impl PpMode {
pub fn needs_ast_map(&self) -> bool {
use PpMode::*;
use PpSourceMode::*;
match *self {
PpmSource(PpmNormal | PpmIdentified) => false,
Source(Normal | Identified) => false,

PpmSource(
PpmExpanded | PpmEveryBodyLoops | PpmExpandedIdentified | PpmExpandedHygiene,
)
| PpmHir(_)
| PpmHirTree(_)
| PpmMir
| PpmMirCFG => true,
PpmSource(PpmTyped) => panic!("invalid state"),
Source(Expanded | EveryBodyLoops | ExpandedIdentified | ExpandedHygiene)
| Hir(_)
| HirTree
| Mir
| MirCFG => true,
}
}

pub fn needs_analysis(&self) -> bool {
use PpMode::*;
matches!(*self, PpmMir | PpmMirCFG)
matches!(*self, Mir | MirCFG)
}
}

Expand Down