Skip to content

Commit 866335b

Browse files
committed
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
2 parents e6f450b + 9e007e7 commit 866335b

30 files changed

+258
-22
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,15 +272,14 @@ See [LICENSE-APACHE](LICENSE-APACHE), [LICENSE-MIT](LICENSE-MIT), and
272272
273273
## Trademark
274274
275-
The Rust programming language is an open source, community project governed
276-
by a core team. It is also sponsored by the Mozilla Foundation (“Mozilla”),
277-
which owns and protects the Rust and Cargo trademarks and logos
278-
(the “Rust Trademarks”).
275+
[The Rust Foundation][rust-foundation] owns and protects the Rust and Cargo
276+
trademarks and logos (the “Rust Trademarks”).
279277
280278
If you want to use these names or brands, please read the [media guide][media-guide].
281279
282280
Third-party logos may be subject to third-party copyrights and trademarks. See
283281
[Licenses][policies-licenses] for details.
284282
283+
[rust-foundation]: https://foundation.rust-lang.org/
285284
[media-guide]: https://www.rust-lang.org/policies/media-guide
286285
[policies-licenses]: https://www.rust-lang.org/policies/licenses

compiler/rustc_driver/src/lib.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use rustc_middle::middle::cstore::MetadataLoader;
2929
use rustc_save_analysis as save;
3030
use rustc_save_analysis::DumpHandler;
3131
use rustc_serialize::json::{self, ToJson};
32-
use rustc_session::config::nightly_options;
32+
use rustc_session::config::{nightly_options, CG_OPTIONS, DB_OPTIONS};
3333
use rustc_session::config::{ErrorOutputType, Input, OutputType, PrintRequest, TrimmedDefPaths};
3434
use rustc_session::getopts;
3535
use rustc_session::lint::{Lint, LintId};
@@ -1010,9 +1010,18 @@ pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
10101010
for option in config::rustc_optgroups() {
10111011
(option.apply)(&mut options);
10121012
}
1013-
let matches = options
1014-
.parse(args)
1015-
.unwrap_or_else(|f| early_error(ErrorOutputType::default(), &f.to_string()));
1013+
let matches = options.parse(args).unwrap_or_else(|e| {
1014+
let msg = match e {
1015+
getopts::Fail::UnrecognizedOption(ref opt) => CG_OPTIONS
1016+
.iter()
1017+
.map(|&(name, ..)| ('C', name))
1018+
.chain(DB_OPTIONS.iter().map(|&(name, ..)| ('Z', name)))
1019+
.find(|&(_, name)| *opt == name.replace("_", "-"))
1020+
.map(|(flag, _)| format!("{}. Did you mean `-{} {}`?", e, flag, opt)),
1021+
_ => None,
1022+
};
1023+
early_error(ErrorOutputType::default(), &msg.unwrap_or_else(|| e.to_string()));
1024+
});
10161025

10171026
// For all options we just parsed, we check a few aspects:
10181027
//

compiler/rustc_error_codes/src/error_codes.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ E0626: include_str!("./error_codes/E0626.md"),
361361
E0627: include_str!("./error_codes/E0627.md"),
362362
E0628: include_str!("./error_codes/E0628.md"),
363363
E0631: include_str!("./error_codes/E0631.md"),
364+
E0632: include_str!("./error_codes/E0632.md"),
364365
E0633: include_str!("./error_codes/E0633.md"),
365366
E0634: include_str!("./error_codes/E0634.md"),
366367
E0635: include_str!("./error_codes/E0635.md"),
@@ -623,8 +624,6 @@ E0783: include_str!("./error_codes/E0783.md"),
623624
// E0629, // missing 'feature' (rustc_const_unstable)
624625
// E0630, // rustc_const_unstable attribute must be paired with stable/unstable
625626
// attribute
626-
E0632, // cannot provide explicit generic arguments when `impl Trait` is
627-
// used in argument position
628627
E0640, // infer outlives requirements
629628
// E0645, // trait aliases not finished
630629
E0667, // `impl Trait` in projections
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
An explicit generic argument was provided when calling a function that
2+
uses `impl Trait` in argument position.
3+
4+
Erroneous code example:
5+
6+
```compile_fail,E0632
7+
fn foo<T: Copy>(a: T, b: impl Clone) {}
8+
9+
foo::<i32>(0i32, "abc".to_string());
10+
```
11+
12+
Either all generic arguments should be inferred at the call site, or
13+
the function definition should use an explicit generic type parameter
14+
instead of `impl Trait`. Example:
15+
16+
```
17+
fn foo<T: Copy>(a: T, b: impl Clone) {}
18+
fn bar<T: Copy, U: Clone>(a: T, b: U) {}
19+
20+
foo(0i32, "abc".to_string());
21+
22+
bar::<i32, String>(0i32, "abc".to_string());
23+
bar::<_, _>(0i32, "abc".to_string());
24+
bar(0i32, "abc".to_string());
25+
```

compiler/rustc_lint/src/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,7 @@ declare_lint! {
10841084
///
10851085
/// ### Explanation
10861086
///
1087-
/// An function with generics must have its symbol mangled to accommodate
1087+
/// A function with generics must have its symbol mangled to accommodate
10881088
/// the generic parameter. The [`no_mangle` attribute] has no effect in
10891089
/// this situation, and should be removed.
10901090
///

compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,12 @@ impl EncodeContext<'a, 'tcx> {
12231223
let fn_data = if let hir::ImplItemKind::Fn(ref sig, body) = ast_item.kind {
12241224
FnData {
12251225
asyncness: sig.header.asyncness,
1226-
constness: sig.header.constness,
1226+
// Can be inside `impl const Trait`, so using sig.header.constness is not reliable
1227+
constness: if self.tcx.is_const_fn_raw(def_id) {
1228+
hir::Constness::Const
1229+
} else {
1230+
hir::Constness::NotConst
1231+
},
12271232
param_names: self.encode_fn_param_names_for_body(body),
12281233
}
12291234
} else {

compiler/rustc_typeck/src/check/expr.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -682,9 +682,23 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
682682
};
683683

684684
let encl_item_id = self.tcx.hir().get_parent_item(expr.hir_id);
685-
let encl_item = self.tcx.hir().expect_item(encl_item_id);
686685

687-
if let hir::ItemKind::Fn(..) = encl_item.kind {
686+
if let Some(hir::Node::Item(hir::Item {
687+
kind: hir::ItemKind::Fn(..),
688+
span: encl_fn_span,
689+
..
690+
}))
691+
| Some(hir::Node::TraitItem(hir::TraitItem {
692+
kind: hir::TraitItemKind::Fn(_, hir::TraitFn::Provided(_)),
693+
span: encl_fn_span,
694+
..
695+
}))
696+
| Some(hir::Node::ImplItem(hir::ImplItem {
697+
kind: hir::ImplItemKind::Fn(..),
698+
span: encl_fn_span,
699+
..
700+
})) = self.tcx.hir().find(encl_item_id)
701+
{
688702
// We are inside a function body, so reporting "return statement
689703
// outside of function body" needs an explanation.
690704

@@ -698,7 +712,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
698712
let encl_body = self.tcx.hir().body(encl_body_id);
699713

700714
err.encl_body_span = Some(encl_body.value.span);
701-
err.encl_fn_span = Some(encl_item.span);
715+
err.encl_fn_span = Some(*encl_fn_span);
702716
}
703717

704718
self.tcx.sess.emit_err(err);

library/alloc/src/raw_vec.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,6 @@ impl<T, A: Allocator> RawVec<T, A> {
463463
Ok(())
464464
}
465465

466-
#[cfg(not(no_global_oom_handling))]
467466
fn shrink(&mut self, amount: usize) -> Result<(), TryReserveError> {
468467
assert!(amount <= self.capacity(), "Tried to shrink to a larger capacity");
469468

src/bootstrap/dist.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,12 +400,12 @@ impl Step for Rustc {
400400

401401
// Copy over lld if it's there
402402
if builder.config.lld_enabled {
403-
let exe = exe("rust-lld", compiler.host);
404-
builder.copy(&src_dir.join(&exe), &dst_dir.join(&exe));
403+
let rust_lld = exe("rust-lld", compiler.host);
404+
builder.copy(&src_dir.join(&rust_lld), &dst_dir.join(&rust_lld));
405405
// for `-Z gcc-ld=lld`
406406
let gcc_lld_dir = dst_dir.join("gcc-ld");
407407
t!(fs::create_dir(&gcc_lld_dir));
408-
builder.copy(&src_dir.join(&exe), &gcc_lld_dir.join(&exe));
408+
builder.copy(&src_dir.join(&rust_lld), &gcc_lld_dir.join(exe("ld", compiler.host)));
409409
}
410410

411411
// Copy over llvm-dwp if it's there

src/librustdoc/html/static/search.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,8 @@ window.initSearch = function(rawSearchIndex) {
801801
results_returned[fullId].lev =
802802
Math.min(results_returned[fullId].lev, returned);
803803
}
804-
if (index !== -1 || lev <= MAX_LEV_DISTANCE) {
804+
if (typePassesFilter(typeFilter, ty.ty) &&
805+
(index !== -1 || lev <= MAX_LEV_DISTANCE)) {
805806
if (index !== -1 && paths.length < 2) {
806807
lev = 0;
807808
}

0 commit comments

Comments
 (0)