Skip to content

Commit 67e5a18

Browse files
committed
Auto merge of #52366 - pietroalbini:beta-backports, r=pietroalbini
[beta] Rollup backports Merged and approved: * #51956: Fix rustdoc run failures by shutting down definitely some lints * #52232: use the adjusted type for cat_pattern in tuple patterns Closes #52311 Closes #52313 r? @ghost
2 parents b5f5c60 + e0e046c commit 67e5a18

File tree

9 files changed

+88
-8
lines changed

9 files changed

+88
-8
lines changed

src/librustc/lint/levels.rs

+5
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ impl LintLevelSets {
118118
// Ensure that we never exceed the `--cap-lints` argument.
119119
level = cmp::min(level, self.lint_cap);
120120

121+
if let Some(driver_level) = sess.driver_lint_caps.get(&LintId::of(lint)) {
122+
// Ensure that we never exceed driver level.
123+
level = cmp::min(*driver_level, level);
124+
}
125+
121126
return (level, src)
122127
}
123128

src/librustc/middle/mem_categorization.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1342,7 +1342,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
13421342
ref ty => span_bug!(pat.span, "tuple pattern unexpected type {:?}", ty),
13431343
};
13441344
for (i, subpat) in subpats.iter().enumerate_and_adjust(expected_len, ddpos) {
1345-
let subpat_ty = self.pat_ty_unadjusted(&subpat)?; // see (*2)
1345+
let subpat_ty = self.pat_ty_adjusted(&subpat)?; // see (*2)
13461346
let interior = InteriorField(FieldIndex(i, Name::intern(&i.to_string())));
13471347
let subcmt = Rc::new(self.cat_imm_interior(pat, cmt.clone(), subpat_ty, interior));
13481348
self.cat_pattern_(subcmt, &subpat, op)?;

src/librustc/session/mod.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use middle::dependency_format;
2222
use session::search_paths::PathKind;
2323
use session::config::{OutputType};
2424
use ty::tls;
25-
use util::nodemap::{FxHashSet};
25+
use util::nodemap::{FxHashMap, FxHashSet};
2626
use util::common::{duration_to_secs_str, ErrorReported};
2727
use util::common::ProfileQueriesMsg;
2828

@@ -160,6 +160,9 @@ pub struct Session {
160160

161161
/// Metadata about the allocators for the current crate being compiled
162162
pub has_global_allocator: Once<bool>,
163+
164+
/// Cap lint level specified by a driver specifically.
165+
pub driver_lint_caps: FxHashMap<lint::LintId, lint::Level>,
163166
}
164167

165168
pub struct PerfStats {
@@ -1164,6 +1167,7 @@ pub fn build_session_(
11641167
(*GLOBAL_JOBSERVER).clone()
11651168
},
11661169
has_global_allocator: Once::new(),
1170+
driver_lint_caps: FxHashMap(),
11671171
};
11681172

11691173
sess

src/librustc_lint/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnsafeCode {
283283
}
284284

285285
declare_lint! {
286-
MISSING_DOCS,
286+
pub MISSING_DOCS,
287287
Allow,
288288
"detects missing documentation for public members"
289289
}

src/librustc_lint/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ use lint::LintId;
5151
use lint::FutureIncompatibleInfo;
5252

5353
mod bad_style;
54-
mod builtin;
54+
pub mod builtin;
5555
mod types;
5656
mod unused;
5757

src/librustc_typeck/check/regionck.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,10 @@ use rustc::hir::{self, PatKind};
105105

106106
// a variation on try that just returns unit
107107
macro_rules! ignore_err {
108-
($e:expr) => (match $e { Ok(e) => e, Err(_) => return () })
108+
($e:expr) => (match $e { Ok(e) => e, Err(_) => {
109+
debug!("ignoring mem-categorization error!");
110+
return ()
111+
}})
109112
}
110113

111114
///////////////////////////////////////////////////////////////////////////
@@ -1034,7 +1037,7 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> {
10341037
debug!("link_pattern(discr_cmt={:?}, root_pat={:?})",
10351038
discr_cmt,
10361039
root_pat);
1037-
let _ = self.with_mc(|mc| {
1040+
ignore_err!(self.with_mc(|mc| {
10381041
mc.cat_pattern(discr_cmt, root_pat, |sub_cmt, sub_pat| {
10391042
match sub_pat.node {
10401043
// `ref x` pattern
@@ -1049,7 +1052,7 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> {
10491052
_ => {}
10501053
}
10511054
})
1052-
});
1055+
}));
10531056
}
10541057

10551058
/// Link lifetime of borrowed pointer resulting from autoref to lifetimes in the value being

src/librustdoc/core.rs

+21-1
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ pub fn run_core(search_paths: SearchPaths,
189189

190190
let intra_link_resolution_failure_name = lint::builtin::INTRA_DOC_LINK_RESOLUTION_FAILURE.name;
191191
let warnings_lint_name = lint::builtin::WARNINGS.name;
192+
let missing_docs = rustc_lint::builtin::MISSING_DOCS.name;
192193
let lints = lint::builtin::HardwiredLints.get_lints()
193194
.iter()
194195
.chain(rustc_lint::SoftLints.get_lints())
@@ -235,6 +236,26 @@ pub fn run_core(search_paths: SearchPaths,
235236
let mut sess = session::build_session_(
236237
sessopts, cpath, diagnostic_handler, codemap,
237238
);
239+
240+
lint::builtin::HardwiredLints.get_lints()
241+
.into_iter()
242+
.chain(rustc_lint::SoftLints.get_lints().into_iter())
243+
.filter_map(|lint| {
244+
// We don't want to whitelist *all* lints so let's
245+
// ignore those ones.
246+
if lint.name == warnings_lint_name ||
247+
lint.name == intra_link_resolution_failure_name ||
248+
lint.name == missing_docs {
249+
None
250+
} else {
251+
Some(lint)
252+
}
253+
})
254+
.for_each(|l| {
255+
sess.driver_lint_caps.insert(lint::LintId::of(l),
256+
lint::Allow);
257+
});
258+
238259
let codegen_backend = rustc_driver::get_codegen_backend(&sess);
239260
let cstore = Rc::new(CStore::new(codegen_backend.metadata_loader()));
240261
rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess));
@@ -299,7 +320,6 @@ pub fn run_core(search_paths: SearchPaths,
299320
&sess);
300321

301322
let resolver = RefCell::new(resolver);
302-
303323
abort_on_err(driver::phase_3_run_analysis_passes(&*codegen_backend,
304324
control,
305325
&sess,

src/test/compile-fail/issue-52213.rs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn transmute_lifetime<'a, 'b, T>(t: &'a (T,)) -> &'b T {
12+
match (&t,) { //~ ERROR cannot infer an appropriate lifetime
13+
((u,),) => u,
14+
}
15+
}
16+
17+
fn main() {
18+
let x = {
19+
let y = Box::new((42,));
20+
transmute_lifetime(&y)
21+
};
22+
23+
println!("{}", x);
24+
}

src/test/rustdoc-ui/unused.rs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// compile-pass
12+
13+
// This test purpose is to check that unused_imports lint isn't fired
14+
// by rustdoc. Why would it? Because when rustdoc is running, it uses
15+
// "everybody-loops" which replaces parts of code with "loop {}" to get
16+
// huge performance improvements.
17+
18+
#![deny(unused_imports)]
19+
20+
use std::fs::File;
21+
22+
pub fn f() {
23+
let _: File;
24+
}

0 commit comments

Comments
 (0)