Auto merge of #86757 - JohnTitor:rollup-acevhz7, r=JohnTitor
Rollup of 8 pull requests Successful merges: - #85504 (the foundation owns rust trademarks) - #85520 (Fix typo and improve documentation for E0632) - #86680 (Improve error for missing -Z with debugging option) - #86728 (Check node kind to avoid ICE in `check_expr_return()`) - #86740 (copy rust-lld as ld in dist) - #86746 (Fix rustdoc query type filter) - #86750 (Test cross-crate usage of `feature(const_trait_impl)`) - #86755 (alloc: `RawVec<T, A>::shrink` can be in `no_global_oom_handling`.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
866335b337
30 changed files with 258 additions and 22 deletions
|
@ -29,7 +29,7 @@ use rustc_middle::middle::cstore::MetadataLoader;
|
|||
use rustc_save_analysis as save;
|
||||
use rustc_save_analysis::DumpHandler;
|
||||
use rustc_serialize::json::{self, ToJson};
|
||||
use rustc_session::config::nightly_options;
|
||||
use rustc_session::config::{nightly_options, CG_OPTIONS, DB_OPTIONS};
|
||||
use rustc_session::config::{ErrorOutputType, Input, OutputType, PrintRequest, TrimmedDefPaths};
|
||||
use rustc_session::getopts;
|
||||
use rustc_session::lint::{Lint, LintId};
|
||||
|
@ -1010,9 +1010,18 @@ pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
|
|||
for option in config::rustc_optgroups() {
|
||||
(option.apply)(&mut options);
|
||||
}
|
||||
let matches = options
|
||||
.parse(args)
|
||||
.unwrap_or_else(|f| early_error(ErrorOutputType::default(), &f.to_string()));
|
||||
let matches = options.parse(args).unwrap_or_else(|e| {
|
||||
let msg = match e {
|
||||
getopts::Fail::UnrecognizedOption(ref opt) => CG_OPTIONS
|
||||
.iter()
|
||||
.map(|&(name, ..)| ('C', name))
|
||||
.chain(DB_OPTIONS.iter().map(|&(name, ..)| ('Z', name)))
|
||||
.find(|&(_, name)| *opt == name.replace("_", "-"))
|
||||
.map(|(flag, _)| format!("{}. Did you mean `-{} {}`?", e, flag, opt)),
|
||||
_ => None,
|
||||
};
|
||||
early_error(ErrorOutputType::default(), &msg.unwrap_or_else(|| e.to_string()));
|
||||
});
|
||||
|
||||
// For all options we just parsed, we check a few aspects:
|
||||
//
|
||||
|
|
|
@ -361,6 +361,7 @@ E0626: include_str!("./error_codes/E0626.md"),
|
|||
E0627: include_str!("./error_codes/E0627.md"),
|
||||
E0628: include_str!("./error_codes/E0628.md"),
|
||||
E0631: include_str!("./error_codes/E0631.md"),
|
||||
E0632: include_str!("./error_codes/E0632.md"),
|
||||
E0633: include_str!("./error_codes/E0633.md"),
|
||||
E0634: include_str!("./error_codes/E0634.md"),
|
||||
E0635: include_str!("./error_codes/E0635.md"),
|
||||
|
@ -623,8 +624,6 @@ E0783: include_str!("./error_codes/E0783.md"),
|
|||
// E0629, // missing 'feature' (rustc_const_unstable)
|
||||
// E0630, // rustc_const_unstable attribute must be paired with stable/unstable
|
||||
// attribute
|
||||
E0632, // cannot provide explicit generic arguments when `impl Trait` is
|
||||
// used in argument position
|
||||
E0640, // infer outlives requirements
|
||||
// E0645, // trait aliases not finished
|
||||
E0667, // `impl Trait` in projections
|
||||
|
|
25
compiler/rustc_error_codes/src/error_codes/E0632.md
Normal file
25
compiler/rustc_error_codes/src/error_codes/E0632.md
Normal file
|
@ -0,0 +1,25 @@
|
|||
An explicit generic argument was provided when calling a function that
|
||||
uses `impl Trait` in argument position.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0632
|
||||
fn foo<T: Copy>(a: T, b: impl Clone) {}
|
||||
|
||||
foo::<i32>(0i32, "abc".to_string());
|
||||
```
|
||||
|
||||
Either all generic arguments should be inferred at the call site, or
|
||||
the function definition should use an explicit generic type parameter
|
||||
instead of `impl Trait`. Example:
|
||||
|
||||
```
|
||||
fn foo<T: Copy>(a: T, b: impl Clone) {}
|
||||
fn bar<T: Copy, U: Clone>(a: T, b: U) {}
|
||||
|
||||
foo(0i32, "abc".to_string());
|
||||
|
||||
bar::<i32, String>(0i32, "abc".to_string());
|
||||
bar::<_, _>(0i32, "abc".to_string());
|
||||
bar(0i32, "abc".to_string());
|
||||
```
|
|
@ -1084,7 +1084,7 @@ declare_lint! {
|
|||
///
|
||||
/// ### Explanation
|
||||
///
|
||||
/// An function with generics must have its symbol mangled to accommodate
|
||||
/// A function with generics must have its symbol mangled to accommodate
|
||||
/// the generic parameter. The [`no_mangle` attribute] has no effect in
|
||||
/// this situation, and should be removed.
|
||||
///
|
||||
|
|
|
@ -1223,7 +1223,12 @@ impl EncodeContext<'a, 'tcx> {
|
|||
let fn_data = if let hir::ImplItemKind::Fn(ref sig, body) = ast_item.kind {
|
||||
FnData {
|
||||
asyncness: sig.header.asyncness,
|
||||
constness: sig.header.constness,
|
||||
// Can be inside `impl const Trait`, so using sig.header.constness is not reliable
|
||||
constness: if self.tcx.is_const_fn_raw(def_id) {
|
||||
hir::Constness::Const
|
||||
} else {
|
||||
hir::Constness::NotConst
|
||||
},
|
||||
param_names: self.encode_fn_param_names_for_body(body),
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -682,9 +682,23 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
};
|
||||
|
||||
let encl_item_id = self.tcx.hir().get_parent_item(expr.hir_id);
|
||||
let encl_item = self.tcx.hir().expect_item(encl_item_id);
|
||||
|
||||
if let hir::ItemKind::Fn(..) = encl_item.kind {
|
||||
if let Some(hir::Node::Item(hir::Item {
|
||||
kind: hir::ItemKind::Fn(..),
|
||||
span: encl_fn_span,
|
||||
..
|
||||
}))
|
||||
| Some(hir::Node::TraitItem(hir::TraitItem {
|
||||
kind: hir::TraitItemKind::Fn(_, hir::TraitFn::Provided(_)),
|
||||
span: encl_fn_span,
|
||||
..
|
||||
}))
|
||||
| Some(hir::Node::ImplItem(hir::ImplItem {
|
||||
kind: hir::ImplItemKind::Fn(..),
|
||||
span: encl_fn_span,
|
||||
..
|
||||
})) = self.tcx.hir().find(encl_item_id)
|
||||
{
|
||||
// We are inside a function body, so reporting "return statement
|
||||
// outside of function body" needs an explanation.
|
||||
|
||||
|
@ -698,7 +712,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let encl_body = self.tcx.hir().body(encl_body_id);
|
||||
|
||||
err.encl_body_span = Some(encl_body.value.span);
|
||||
err.encl_fn_span = Some(encl_item.span);
|
||||
err.encl_fn_span = Some(*encl_fn_span);
|
||||
}
|
||||
|
||||
self.tcx.sess.emit_err(err);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue