Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
71e5018
ci: replace MINGW_URL with CUSTOM_MINGW=1
pietroalbini Oct 30, 2019
53c2c04
ci: remove the MINGW_DIR and MINGW_ARCHIVE env vars
pietroalbini Oct 30, 2019
af6b266
ci: remove the MSYS_BITS env var
pietroalbini Oct 30, 2019
6104aa7
ci: extract validate-toolstate into a script
pietroalbini Oct 30, 2019
d623c56
ci: extract running the build into a script
pietroalbini Oct 30, 2019
e209ee4
ci: extract collecting cpu stats into a script
pietroalbini Oct 30, 2019
c90cc12
ci: move validate-toolstate.sh in the mingw-check image
pietroalbini Oct 31, 2019
14da85c
ci: move mirrors to https://ci-mirrors.rust-lang.org
pietroalbini Nov 4, 2019
85132b2
ci: download curl and openssl from s3 for dist-x86_64-linux
pietroalbini Nov 6, 2019
71cf364
Fix the source code highlighting on source comments
dns2utf8 Nov 15, 2019
1bbb816
Prevent jumps when selecting one or many lines
dns2utf8 Nov 15, 2019
4e1eeb9
Add explanation message for E0641
clemkoh Nov 16, 2019
dc137dd
Update ui tests
clemkoh Nov 16, 2019
0487f0c
Suggest calling async closure when needed
estebank Nov 9, 2019
d7efa5b
review comments
estebank Nov 17, 2019
d8ea786
Add JohnTitor to rustc-guide toolstate notification list
JohnTitor Nov 17, 2019
de122e6
std::error::Chain: remove Copy
haraldh Nov 15, 2019
4610867
Add long error explanation for E0594
GuillaumeGomez Nov 6, 2019
cd13335
Update ui tests
GuillaumeGomez Nov 6, 2019
0e2ccaa
Fix 'type annotations needed' error with opaque types
Aaron1011 Nov 15, 2019
61c75bd
Add explanation of unconstrained opaque type
Aaron1011 Nov 15, 2019
f87177b
Replace bool with new `FallbackMode` enum
Aaron1011 Nov 15, 2019
a11abe0
Update test output
Aaron1011 Nov 15, 2019
614da98
review comments
estebank Nov 17, 2019
f74fe81
resolve: Give derive helpers highest priority during resolution
petrochenkov Nov 18, 2019
c981c99
Move E0594 to new error code system
GuillaumeGomez Nov 18, 2019
f6b327b
Remove compiler_builtins_lib feature from libstd
dingelish Nov 19, 2019
c84fae1
Move the definition of `QueryResult` into `plumbing.rs`.
nnethercote Nov 1, 2019
49077c5
Rollup merge of #66090 - pietroalbini:ci-improvements, r=alexcrichton
Centril Nov 19, 2019
40deec8
Rollup merge of #66155 - GuillaumeGomez:long-err-explanation-E0594, r…
Centril Nov 19, 2019
0b0d683
Rollup merge of #66239 - estebank:suggest-async-closure-call, r=Centril
Centril Nov 19, 2019
95b9766
Rollup merge of #66430 - dns2utf8:fix_code_selection_click_handler, r…
Centril Nov 19, 2019
ee535a0
Rollup merge of #66431 - Aaron1011:fix/opaque-type-infer, r=varkor
Centril Nov 19, 2019
b5166b1
Rollup merge of #66461 - clemencetbk:master, r=GuillaumeGomez
Centril Nov 19, 2019
e99e5fb
Rollup merge of #66493 - JohnTitor:ping-me-rustc-guide, r=spastorino
Centril Nov 19, 2019
42e3b86
Rollup merge of #66511 - haraldh:error_chain_nocopy, r=dtolnay
Centril Nov 19, 2019
1f0f0ad
Rollup merge of #66529 - petrochenkov:reshelp2, r=davidtwco
Centril Nov 19, 2019
0ddd298
Rollup merge of #66536 - nnethercote:mv-QueryResult, r=Centril
Centril Nov 19, 2019
e1a32fa
Rollup merge of #66538 - dingelish:master, r=Centril
Centril Nov 19, 2019
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
25 changes: 16 additions & 9 deletions src/librustc_resolve/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,11 +466,12 @@ impl<'a> Resolver<'a> {
) -> Result<&'a NameBinding<'a>, Determinacy> {
bitflags::bitflags! {
struct Flags: u8 {
const MACRO_RULES = 1 << 0;
const MODULE = 1 << 1;
const MISC_SUGGEST_CRATE = 1 << 2;
const MISC_SUGGEST_SELF = 1 << 3;
const MISC_FROM_PRELUDE = 1 << 4;
const MACRO_RULES = 1 << 0;
const MODULE = 1 << 1;
const DERIVE_HELPER_COMPAT = 1 << 2;
const MISC_SUGGEST_CRATE = 1 << 3;
const MISC_SUGGEST_SELF = 1 << 4;
const MISC_FROM_PRELUDE = 1 << 5;
}
}

Expand Down Expand Up @@ -528,8 +529,10 @@ impl<'a> Resolver<'a> {
match this.resolve_macro_path(derive, Some(MacroKind::Derive),
parent_scope, true, force) {
Ok((Some(ext), _)) => if ext.helper_attrs.contains(&ident.name) {
let res = Res::NonMacroAttr(NonMacroAttrKind::DeriveHelper);
result = ok(res, derive.span, this.arenas);
let binding = (Res::NonMacroAttr(NonMacroAttrKind::DeriveHelper),
ty::Visibility::Public, derive.span, ExpnId::root())
.to_name_binding(this.arenas);
result = Ok((binding, Flags::DERIVE_HELPER_COMPAT));
break;
}
Ok(_) | Err(Determinacy::Determined) => {}
Expand Down Expand Up @@ -659,13 +662,17 @@ impl<'a> Resolver<'a> {
let (res, innermost_res) = (binding.res(), innermost_binding.res());
if res != innermost_res {
let builtin = Res::NonMacroAttr(NonMacroAttrKind::Builtin);
let derive_helper = Res::NonMacroAttr(NonMacroAttrKind::DeriveHelper);
let is_derive_helper_compat = |res, flags: Flags| {
res == Res::NonMacroAttr(NonMacroAttrKind::DeriveHelper) &&
flags.contains(Flags::DERIVE_HELPER_COMPAT)
};

let ambiguity_error_kind = if is_import {
Some(AmbiguityKind::Import)
} else if innermost_res == builtin || res == builtin {
Some(AmbiguityKind::BuiltinAttr)
} else if innermost_res == derive_helper || res == derive_helper {
} else if is_derive_helper_compat(innermost_res, innermost_flags) ||
is_derive_helper_compat(res, flags) {
Some(AmbiguityKind::DeriveHelper)
} else if innermost_flags.contains(Flags::MACRO_RULES) &&
flags.contains(Flags::MODULE) &&
Expand Down
12 changes: 12 additions & 0 deletions src/test/ui/proc-macro/auxiliary/derive-helper-shadowing-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// force-host
// no-prefer-dynamic

#![crate_type = "proc-macro"]

extern crate proc_macro;
use proc_macro::*;

#[proc_macro_derive(same_name, attributes(same_name))]
pub fn derive_a(_: TokenStream) -> TokenStream {
TokenStream::new()
}
16 changes: 16 additions & 0 deletions src/test/ui/proc-macro/derive-helper-shadowing-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// If a derive macro introduces a helper attribute with the same name as that macro,
// then make sure that it's usable without ambiguities.

// check-pass
// aux-build:derive-helper-shadowing-2.rs

#[macro_use]
extern crate derive_helper_shadowing_2;

#[derive(same_name)]
struct S {
#[same_name] // OK, no ambiguity, derive helpers have highest priority
field: u8,
}

fn main() {}
4 changes: 2 additions & 2 deletions src/test/ui/proc-macro/derive-helper-shadowing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ macro_rules! gen_helper_use {
#[empty_helper] //~ ERROR `empty_helper` is ambiguous
#[derive(Empty)]
struct S {
#[empty_helper] //~ ERROR `empty_helper` is ambiguous
#[empty_helper] // OK, no ambiguity, derive helpers have highest priority
field: [u8; {
use empty_helper; //~ ERROR `empty_helper` is ambiguous

#[empty_helper] //~ ERROR `empty_helper` is ambiguous
#[empty_helper] // OK, no ambiguity, derive helpers have highest priority
struct U;

mod inner {
Expand Down
38 changes: 1 addition & 37 deletions src/test/ui/proc-macro/derive-helper-shadowing.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -61,42 +61,6 @@ LL | use test_macros::empty_attr as empty_helper;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: use `crate::empty_helper` to refer to this attribute macro unambiguously

error[E0659]: `empty_helper` is ambiguous (derive helper attribute vs any other name)
--> $DIR/derive-helper-shadowing.rs:22:7
|
LL | #[empty_helper]
| ^^^^^^^^^^^^ ambiguous name
|
note: `empty_helper` could refer to the derive helper attribute defined here
--> $DIR/derive-helper-shadowing.rs:20:10
|
LL | #[derive(Empty)]
| ^^^^^
note: `empty_helper` could also refer to the attribute macro imported here
--> $DIR/derive-helper-shadowing.rs:10:5
|
LL | use test_macros::empty_attr as empty_helper;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: use `crate::empty_helper` to refer to this attribute macro unambiguously

error[E0659]: `empty_helper` is ambiguous (derive helper attribute vs any other name)
--> $DIR/derive-helper-shadowing.rs:26:11
|
LL | #[empty_helper]
| ^^^^^^^^^^^^ ambiguous name
|
note: `empty_helper` could refer to the derive helper attribute defined here
--> $DIR/derive-helper-shadowing.rs:20:10
|
LL | #[derive(Empty)]
| ^^^^^
note: `empty_helper` could also refer to the attribute macro imported here
--> $DIR/derive-helper-shadowing.rs:10:5
|
LL | use test_macros::empty_attr as empty_helper;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: use `crate::empty_helper` to refer to this attribute macro unambiguously

error: aborting due to 7 previous errors
error: aborting due to 5 previous errors

For more information about this error, try `rustc --explain E0659`.