Skip to content

Rollup of 11 pull requests #79927

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

Merged
merged 32 commits into from
Dec 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
72a5cbb
Edit documentation for `std::{f32,f64}::mul_add`.
fu5ha Sep 21, 2020
a6d98d8
generalize warning
fu5ha Oct 13, 2020
87c1fdb
Make the kernel_copy tests more robust/concurrent.
vext01 Nov 24, 2020
36363e5
Refine E0212 error message
sasurau4 Dec 4, 2020
a1e94cd
Add long explanation for E0212
sasurau4 Dec 2, 2020
87c6216
Update some associated-types ui test suites
sasurau4 Dec 2, 2020
12db222
Dogfood 'str_split_once() with `compiler/`
Eric-Arellano Dec 7, 2020
d6baf38
Dogfood 'str_split_once() with Tidy
Eric-Arellano Dec 7, 2020
7bd47bd
Dogfood 'str_split_once() with linkchecker
Eric-Arellano Dec 7, 2020
85e9ea0
Dogfood 'str_split_once() with librustdoc
Eric-Arellano Dec 7, 2020
d2de69d
Dogfood 'str_split_once()` in the std lib
Eric-Arellano Dec 7, 2020
f68cc68
Review feedback for collect_intra_doc_links.rs
Eric-Arellano Dec 7, 2020
a3174de
Fix net.rs - rsplitn() returns a reverse iterator
Eric-Arellano Dec 7, 2020
989edf4
Review feedback
Eric-Arellano Dec 8, 2020
4e21942
Clarify the 'default is only allowed on...' error
camelid Dec 9, 2020
33ae62c
Clarify that String::split_at takes a byte index.
frewsxcv Dec 9, 2020
56d9784
Fix typo in `wrapping_shl` documentation
Pratyush Dec 9, 2020
2363a20
Make search results tab and help button focusable with keyboard
GuillaumeGomez Dec 10, 2020
caab16f
Update const-fn doc in unstable-book
sasurau4 Dec 9, 2020
40ed0f6
Use Symbol for inline asm register class names
sivadeilra Dec 10, 2020
f7306b1
Add tracking issue template for library features.
m-ou-se Dec 4, 2020
1b4ffe4
Rollup merge of #77027 - termhn:mul_add_doc_change, r=m-ou-se
tmandry Dec 11, 2020
a8c19e1
Rollup merge of #79375 - vext01:kernel-copy-temps, r=bjorn3
tmandry Dec 11, 2020
f3a3fc9
Rollup merge of #79639 - sasurau4:feature/add-long-explanation-E0212,…
tmandry Dec 11, 2020
8b9a59c
Rollup merge of #79698 - m-ou-se:libs-tracking-issue-template, r=KodrAus
tmandry Dec 11, 2020
17ec4b8
Rollup merge of #79809 - Eric-Arellano:split-once, r=matklad
tmandry Dec 11, 2020
dc90573
Rollup merge of #79851 - camelid:better-error-for-default-fn, r=david…
tmandry Dec 11, 2020
8709ac8
Rollup merge of #79858 - sasurau4:doc/update-unstable-book-const-fn, …
tmandry Dec 11, 2020
c0cc910
Rollup merge of #79860 - rust-lang:frewsxcv-patch-2, r=jyn514
tmandry Dec 11, 2020
c94345e
Rollup merge of #79871 - Pratyush:patch-1, r=joshtriplett
tmandry Dec 11, 2020
3a46a6b
Rollup merge of #79896 - GuillaumeGomez:more-elements-focus, r=Manish…
tmandry Dec 11, 2020
0327b5d
Rollup merge of #79917 - sivadeilra:asm_symbols, r=petrochenkov
tmandry Dec 11, 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
63 changes: 63 additions & 0 deletions .github/ISSUE_TEMPLATE/library_tracking_issue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
name: Library Tracking Issue
about: A tracking issue for an unstable library feature.
title: Tracking Issue for XXX
labels: C-tracking-issue T-libs
---
<!--
Thank you for creating a tracking issue!

Tracking issues are for tracking a feature from implementation to stabilization.

Make sure to include the relevant RFC for the feature if it has one.

If the new feature is small, it may be fine to skip the RFC process. In that
case, you can use use `issue = "none"` in your initial implementation PR. The
reviewer will ask you to open a tracking issue if they agree your feature can be
added without an RFC.
-->

Feature gate: `#![feature(...)]`

This is a tracking issue for ...

<!--
Include a short description of the feature.
-->

### Public API

<!--
For most library features, it'd be useful to include a summarized version of the public API.
(E.g. just the public function signatures without their doc comments or implementation.)
-->

```rust
...
```

### Steps / History

<!--
In the simplest case, this is a PR implementing the feature followed by a PR
that stabilises the feature. However it's not uncommon for the feature to be
changed before stabilization. For larger features, the implementation could be
split up in multiple steps.
-->

- [ ] Implementation: ...
- [ ] Stabilization PR

### Unresolved Questions

<!--
Include any open questions that need to be answered before the feature can be
stabilised. If multiple (unrelated) big questions come up, it can be a good idea
to open a separate issue for each, to make it easier to keep track of the
discussions.

It's useful to link any relevant discussions and conclusions (whether on GitHub,
Zulip, or the internals forum) here.
-->

- None yet.
2 changes: 1 addition & 1 deletion compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ impl<'a> AstValidator<'a> {
if let Defaultness::Default(def_span) = defaultness {
let span = self.session.source_map().guess_head_span(span);
self.err_handler()
.struct_span_err(span, "`default` is only allowed on items in `impl` definitions")
.struct_span_err(span, "`default` is only allowed on items in trait impls")
.span_label(def_span, "`default` because of this")
.emit();
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_error_codes/src/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ E0206: include_str!("./error_codes/E0206.md"),
E0207: include_str!("./error_codes/E0207.md"),
E0210: include_str!("./error_codes/E0210.md"),
E0211: include_str!("./error_codes/E0211.md"),
E0212: include_str!("./error_codes/E0212.md"),
E0214: include_str!("./error_codes/E0214.md"),
E0220: include_str!("./error_codes/E0220.md"),
E0221: include_str!("./error_codes/E0221.md"),
Expand Down Expand Up @@ -503,7 +504,6 @@ E0779: include_str!("./error_codes/E0779.md"),
// E0196, // cannot determine a type for this closure
E0208,
// E0209, // builtin traits can only be implemented on structs or enums
E0212, // cannot extract an associated type from a higher-ranked trait bound
// E0213, // associated types are not accepted in this context
// E0215, // angle-bracket notation is not stable with `Fn`
// E0216, // parenthetical notation is only stable with `Fn`
Expand Down
35 changes: 35 additions & 0 deletions compiler/rustc_error_codes/src/error_codes/E0212.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Cannot use the associated type of
a trait with uninferred generic parameters.

Erroneous code example:

```compile_fail,E0212
pub trait Foo<T> {
type A;

fn get(&self, t: T) -> Self::A;
}

fn foo2<I : for<'x> Foo<&'x isize>>(
field: I::A) {} // error!
```

In this example, we have to instantiate `'x`, and
we don't know what lifetime to instantiate it with.
To fix this, spell out the precise lifetimes involved.
Example:

```
pub trait Foo<T> {
type A;

fn get(&self, t: T) -> Self::A;
}

fn foo3<I : for<'x> Foo<&'x isize>>(
x: <I as Foo<&isize>>::A) {} // ok!


fn foo4<'a, I : for<'x> Foo<&'x isize>>(
x: <I as Foo<&'a isize>>::A) {} // ok!
```
1 change: 1 addition & 0 deletions compiler/rustc_mir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Rust MIR: a lowered representation of Rust.
#![feature(or_patterns)]
#![feature(once_cell)]
#![feature(control_flow_enum)]
#![feature(str_split_once)]
#![recursion_limit = "256"]

#[macro_use]
Expand Down
62 changes: 34 additions & 28 deletions compiler/rustc_mir/src/transform/coverage/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,40 +148,46 @@ impl DebugOptions {

if let Ok(env_debug_options) = std::env::var(RUSTC_COVERAGE_DEBUG_OPTIONS) {
for setting_str in env_debug_options.replace(" ", "").replace("-", "_").split(',') {
let mut setting = setting_str.splitn(2, '=');
match setting.next() {
Some(option) if option == "allow_unused_expressions" => {
allow_unused_expressions = bool_option_val(option, setting.next());
let (option, value) = match setting_str.split_once('=') {
None => (setting_str, None),
Some((k, v)) => (k, Some(v)),
};
match option {
"allow_unused_expressions" => {
allow_unused_expressions = bool_option_val(option, value);
debug!(
"{} env option `allow_unused_expressions` is set to {}",
RUSTC_COVERAGE_DEBUG_OPTIONS, allow_unused_expressions
);
}
Some(option) if option == "counter_format" => {
if let Some(strval) = setting.next() {
counter_format = counter_format_option_val(strval);
debug!(
"{} env option `counter_format` is set to {:?}",
RUSTC_COVERAGE_DEBUG_OPTIONS, counter_format
);
} else {
bug!(
"`{}` option in environment variable {} requires one or more \
plus-separated choices (a non-empty subset of \
`id+block+operation`)",
option,
RUSTC_COVERAGE_DEBUG_OPTIONS
);
}
"counter_format" => {
match value {
None => {
bug!(
"`{}` option in environment variable {} requires one or more \
plus-separated choices (a non-empty subset of \
`id+block+operation`)",
option,
RUSTC_COVERAGE_DEBUG_OPTIONS
);
}
Some(val) => {
counter_format = counter_format_option_val(val);
debug!(
"{} env option `counter_format` is set to {:?}",
RUSTC_COVERAGE_DEBUG_OPTIONS, counter_format
);
}
};
}
Some("") => {}
Some(invalid) => bug!(
"Unsupported setting `{}` in environment variable {}",
invalid,
RUSTC_COVERAGE_DEBUG_OPTIONS
),
None => {}
}
_ => {
bug!(
"Unsupported setting `{}` in environment variable {}",
option,
RUSTC_COVERAGE_DEBUG_OPTIONS
)
}
};
}
}

Expand Down
109 changes: 50 additions & 59 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1296,8 +1296,10 @@ fn parse_output_types(
if !debugging_opts.parse_only {
for list in matches.opt_strs("emit") {
for output_type in list.split(',') {
let mut parts = output_type.splitn(2, '=');
let shorthand = parts.next().unwrap();
let (shorthand, path) = match output_type.split_once('=') {
None => (output_type, None),
Some((shorthand, path)) => (shorthand, Some(PathBuf::from(path))),
};
let output_type = OutputType::from_shorthand(shorthand).unwrap_or_else(|| {
early_error(
error_format,
Expand All @@ -1308,7 +1310,6 @@ fn parse_output_types(
),
)
});
let path = parts.next().map(PathBuf::from);
output_types.insert(output_type, path);
}
}
Expand Down Expand Up @@ -1452,11 +1453,10 @@ fn parse_opt_level(
let max_c = matches
.opt_strs_pos("C")
.into_iter()
.flat_map(
|(i, s)| {
if let Some("opt-level") = s.splitn(2, '=').next() { Some(i) } else { None }
},
)
.flat_map(|(i, s)| {
// NB: This can match a string without `=`.
if let Some("opt-level") = s.splitn(2, '=').next() { Some(i) } else { None }
})
.max();
if max_o > max_c {
OptLevel::Default
Expand Down Expand Up @@ -1491,11 +1491,10 @@ fn select_debuginfo(
let max_c = matches
.opt_strs_pos("C")
.into_iter()
.flat_map(
|(i, s)| {
if let Some("debuginfo") = s.splitn(2, '=').next() { Some(i) } else { None }
},
)
.flat_map(|(i, s)| {
// NB: This can match a string without `=`.
if let Some("debuginfo") = s.splitn(2, '=').next() { Some(i) } else { None }
})
.max();
if max_g > max_c {
DebugInfo::Full
Expand Down Expand Up @@ -1528,23 +1527,26 @@ fn parse_libs(
.map(|s| {
// Parse string of the form "[KIND=]lib[:new_name]",
// where KIND is one of "dylib", "framework", "static".
let mut parts = s.splitn(2, '=');
let kind = parts.next().unwrap();
let (name, kind) = match (parts.next(), kind) {
(None, name) => (name, NativeLibKind::Unspecified),
(Some(name), "dylib") => (name, NativeLibKind::Dylib),
(Some(name), "framework") => (name, NativeLibKind::Framework),
(Some(name), "static") => (name, NativeLibKind::StaticBundle),
(Some(name), "static-nobundle") => (name, NativeLibKind::StaticNoBundle),
(_, s) => {
early_error(
error_format,
&format!(
"unknown library kind `{}`, expected \
one of dylib, framework, or static",
s
),
);
let (name, kind) = match s.split_once('=') {
None => (s, NativeLibKind::Unspecified),
Some((kind, name)) => {
let kind = match kind {
"dylib" => NativeLibKind::Dylib,
"framework" => NativeLibKind::Framework,
"static" => NativeLibKind::StaticBundle,
"static-nobundle" => NativeLibKind::StaticNoBundle,
s => {
early_error(
error_format,
&format!(
"unknown library kind `{}`, expected \
one of dylib, framework, or static",
s
),
);
}
};
(name.to_string(), kind)
}
};
if kind == NativeLibKind::StaticNoBundle
Expand All @@ -1556,10 +1558,11 @@ fn parse_libs(
accepted on the nightly compiler",
);
}
let mut name_parts = name.splitn(2, ':');
let name = name_parts.next().unwrap();
let new_name = name_parts.next();
(name.to_owned(), new_name.map(|n| n.to_owned()), kind)
let (name, new_name) = match name.split_once(':') {
None => (name, None),
Some((name, new_name)) => (name.to_string(), Some(new_name.to_owned())),
};
(name, new_name, kind)
})
.collect()
}
Expand All @@ -1580,20 +1583,13 @@ pub fn parse_externs(
let is_unstable_enabled = debugging_opts.unstable_options;
let mut externs: BTreeMap<String, ExternEntry> = BTreeMap::new();
for arg in matches.opt_strs("extern") {
let mut parts = arg.splitn(2, '=');
let name = parts
.next()
.unwrap_or_else(|| early_error(error_format, "--extern value must not be empty"));
let path = parts.next().map(|s| s.to_string());

let mut name_parts = name.splitn(2, ':');
let first_part = name_parts.next();
let second_part = name_parts.next();
let (options, name) = match (first_part, second_part) {
(Some(opts), Some(name)) => (Some(opts), name),
(Some(name), None) => (None, name),
(None, None) => early_error(error_format, "--extern name must not be empty"),
_ => unreachable!(),
let (name, path) = match arg.split_once('=') {
None => (arg, None),
Some((name, path)) => (name.to_string(), Some(path.to_string())),
};
let (options, name) = match name.split_once(':') {
None => (None, name),
Some((opts, name)) => (Some(opts), name.to_string()),
};

let entry = externs.entry(name.to_owned());
Expand Down Expand Up @@ -1682,17 +1678,12 @@ fn parse_remap_path_prefix(
matches
.opt_strs("remap-path-prefix")
.into_iter()
.map(|remap| {
let mut parts = remap.rsplitn(2, '='); // reverse iterator
let to = parts.next();
let from = parts.next();
match (from, to) {
(Some(from), Some(to)) => (PathBuf::from(from), PathBuf::from(to)),
_ => early_error(
error_format,
"--remap-path-prefix must contain '=' between FROM and TO",
),
}
.map(|remap| match remap.rsplit_once('=') {
None => early_error(
error_format,
"--remap-path-prefix must contain '=' between FROM and TO",
),
Some((from, to)) => (PathBuf::from(from), PathBuf::from(to)),
})
.collect()
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_session/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![feature(crate_visibility_modifier)]
#![feature(once_cell)]
#![feature(or_patterns)]
#![feature(str_split_once)]

#[macro_use]
extern crate bitflags;
Expand Down
7 changes: 4 additions & 3 deletions compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,10 @@ macro_rules! options {
{
let mut op = $defaultfn();
for option in matches.opt_strs($prefix) {
let mut iter = option.splitn(2, '=');
let key = iter.next().unwrap();
let value = iter.next();
let (key, value) = match option.split_once('=') {
None => (option, None),
Some((k, v)) => (k.to_string(), Some(v)),
};
let option_to_lookup = key.replace("-", "_");
let mut found = false;
for &(candidate, setter, type_desc, _) in $stat {
Expand Down
Loading